virsh cannot see VM created using qemu-system-x86_64, even while VM is running

mr.zog asked:

I thought I understood KVM/QEMU pretty well but then I tried following the instructions on this page:

Took me a while to figure out I needed to substitute the kvm command with qemu-system-x86_64 on a CentOS host.

Now I’m wondering why I need to run the below syntax every time I want to start the VM.

qemu-system-x86_64  -enable-kvm    \
                    -curses           \
                    -name leaf0         \
                    -pidfile    \
                    -smp 1             \
                    -m 256             \
                    -net nic,vlan=10,macaddr=00:01:00:00:01:00,model=virtio \
                    -net user,vlan=10,net=,hostfwd=tcp::1401-:22 \
                    -netdev socket,udp=,localaddr=,id=dev0 \
                    -device virtio-net-pci,mac=00:02:00:00:00:01,addr=6.0,multifunction=on,netdev=dev0,id=swp1 \
                    -netdev socket,udp=,localaddr=,id=dev1 \
                    -device virtio-net-pci,mac=00:02:00:00:00:02,addr=6.1,multifunction=off,netdev=dev1,id=swp2 \
                    -netdev socket,udp=,localaddr=,id=dev2 \
                    -device virtio-net-pci,mac=00:02:00:00:00:09,addr=6.2,multifunction=off,netdev=dev2,id=swp3 /home/libvirt/images/leaf0.qcow2

I expected that when I shut down the VM it would be defined, but virsh cannot see it even when it’s running. (virsh list –all) fails to find it too.

Is there some way of dumping a xml file for this VM so I can define it?


My answer:

The tutorial you linked to provides directions to install libvirtd, but then it never actually uses it anywhere. Instead it advises creating VMs manually, which is completely insane, not least because their configuration isn’t saved anywhere.

Use libvirt-aware tools such as the virt-manager GUI or virt-install to create virtual machines with libvirt.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.