libvirt / qemu guest won’t start

If you see the error message “Error starting domain: Requested operation is not valid: network ‘default’ is not active”, it means the network hasn’t started.

Do the following:

sudo virsh net-list --all

You will see:

Name State Autostart Persistent

default inactive no yes

sudo virsh net-start default

Network default started

Set it to autostart:

sudo virsh net-autostart default

Check status:

sudo virsh net-list --all

Name State Autostart Persistent

default active yes yes

Posted in KVM

Using KVM/libvirt/qemu

Setup KVM in Linux

Install virsh:

$ sudo apt-get install libvirt-bin
This can be local, or even remote. In most cases, if you want to manage VMs running on the local hypervisor:
$ virsh connect qemu:///system
List any existing VMs:
$ virsh list

You can export the XML of an existing virtual machine:

$ virsh dumpxml myoldvm > ~/myoldvm.xml

And then edit myoldvm.xml, which should be rather straightforward. For more information about libvirt XML format, see:
http://libvirt.org/format.html

Once you have an XML file describing the new virtual machine you want to create, import it into virsh, and run it immediately:

$ virsh create ~/myoldvm.xml
See if it worked:
$ virsh list

Working with a Running Virtual Machine:

$ virsh start mynewvm
$ virsh reboot mynewvm
$ virsh shutdown mynewvm
$ virsh suspend mynewvm
$ virsh resume mynewvm

To delete a virtual machine, first terminate it (if running), and then undefine it:

$ virsh destroy mynewvm
$ virsh undefine mynewvm
Posted in KVM

Ubuntu install qemu/libvirtd

egrep -c '(vmx|svm)' /proc/cpuinfo # to confirm virtualization is enabled in BIOS > you need anything greater than zero returned
sudo apt update
sudo apt install -y qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils
sudo apt install -y qemu-kvm
qemu-system-x86_64 --version ## verify install
sudo apt install -y  virtinst libvirt-daemon
sudo systemctl enable --now libvirtd # enable service
sudo apt install -y virt-manager ## install the GUI
reboot



when transferring from old machine:

copy over the qcow files to appropriate path

restore backups of folder /etc/libvirt/qemu

make sure the paths in the xml files are correct

fix/import the xml files with:

virsh define rhel901.xml

Posted in KVM