提问人:stefletcher 提问时间:7/25/2023 更新时间:8/19/2023 访问量:1159
MacOS M1/M2 上的 QEMU 和 LIBVIRT
QEMU and LIBVIRT on MacOS M1/M2
问:
我正在尝试让 VirtManager/virsh 查看 Vagrant 创建的 VM,但到目前为止还没有喜悦......
我已经通过 brew 安装了 qemu 和 libvirt。
这是流浪者文件:
Vagrant.configure("2") do |config|
# Define the VM box and provider
config.vm.box = "perk/ubuntu-2204-arm64"
config.vm.define "ubuntu-arm64" do |node|
config.vm.provider :qemu do |qemu|
qemu.cpus = 4
qemu.memory = 4096
end
node.vm.network :private_network, type: "dhcp"
node.vm.network :forwarded_port, guest: 22, host: 2223, id: "ssh"
end
end
运行 vagrant up 后,我可以看到一个 qemu 实例正在运行并且 VM 可用:
$ ps -ef | awk '/qemu/ && !/awk/' | sed -e 's/[^/]*//' -e 's/ -/\n\t-/g'
/opt/homebrew/bin/qemu-system-aarch64
-machine virt,accel=hvf,highmem=on
-cpu host
-smp 2
-m 4096
-device virtio-net-device,netdev=net0
-netdev user,id=net0,hostfwd=tcp::50022-:22
-drive if=virtio,format=qcow2,file=/.vagrant/machines/ubuntu-arm64/qemu/pBvXRX29gW8/linked-box.img
-drive if=pflash,format=raw,file=/.vagrant/machines/ubuntu-arm64/qemu/pBvXRX29gW8/edk2-aarch64-code.fd,readonly=on
-drive if=pflash,format=raw,file=/.vagrant/machines/ubuntu-arm64/qemu/pBvXRX29gW8/edk2-arm-vars.fd
-chardev socket,id=mon0,path=/.vagrant.d/tmp/vagrant-qemu/pBvXRX29gW8/qemu_socket,server=on,wait=off
-mon chardev=mon0,mode=readline
-chardev socket,id=ser0,path=/.vagrant.d/tmp/vagrant-qemu/pBvXRX29gW8/qemu_socket_serial,server=on,wait=off
-serial chardev:ser0
-pidfile /.vagrant/machines/ubuntu-arm64/qemu/pBvXRX29gW8/qemu.pid
-parallel null
-monitor none
-display none
-vga none
-daemonize
/opt/homebrew/Cellar/[email protected]/3.11.4_1/Frameworks/Python.framework/Versions/3.11/Resources/Python.app/Contents/MacOS/Python /opt/homebrew/bin/virt-manager
-c qemu:///session
--no-fork
然后我运行virsh list,但我仍然没有看到任何VM(当我sudo virsh list时也会发生同样的事情)。
我找到了一个参考资料,建议我需要指定连接套接字,所以我这样做了,结果如下:
sudo virsh -c "qemu:///session" list
error: failed to connect to the hypervisor
error: Failed to connect socket to '/opt/homebrew/var/run/libvirt/virtqemud-sock': No such file or directory
所以我做了更多的研究,发现我需要在查询字符串上指定 libvirt-sock:
sudo virsh -c "qemu:///session?socket=/Users/stefletcher/.cache/libvirt/libvirt-sock" list
Id Name State
--------------------
它尝试列出,但看不到 qemu VM。
我感觉我错过了一些基本的东西,但不能把手指放在上面。
答: 暂无答案
评论