0

I'm trying to get VirtManager/virsh to see VMs created by Vagrant but no joy so far...

I have installed qemu and libvirt via brew.

Here is the Vagrantfile:

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

After running vagrant up I can see a qemu instance running and the VM is available:

$ 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/python@3.11/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

I then run virsh list but I still don't see any VMs (same thing happens when I sudo virsh list ).

I found a reference that suggested I need to specify the connection socket so I did that and this is the result:

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

So I did some more research and found that I need to specify the libvirt-sock on the query string:

sudo virsh -c "qemu:///session?socket=/Users/stefletcher/.cache/libvirt/libvirt-sock" list                      
 Id   Name   State
--------------------

It tried to list but couldn't see the qemu VM.

I get the feeling that I'm missing something basic but can't put my finger on it.

1 Answers1

0

I found that article on medium

https://medium.com/@aryangodara_19887/qemu-virt-manager-and-libvirt-on-macos-with-apple-silicon-m2-dc677e6b8559

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 22 '23 at 22:35