Create libvirt Virtual Network From an XML File

I have a need to setup a virtual network on a VM-host server. Usually, I just use the virt-manager gui application to create this task. However, I’d like to do this via command line this time. Why? Well, why not? It’s always fun to learn new thing. :) libvirt keeps network configuration in XML files under /etc/libvirt/qemu/networks/. Here is what I have on one of my machines: # ls -1 /etc/libvirt/qemu/networks/*xml /etc/libvirt/qemu/networks/classroom.xml /etc/libvirt/qemu/networks/default.xml /etc/libvirt/qemu/networks/kubernetes.xml /etc/libvirt/qemu/networks/minikube-net.xml /etc/libvirt/qemu/networks/other.xml /etc/libvirt/qemu/networks/storage.xml /etc/libvirt/qemu/networks/student.xml We can use also list all the available libvirt-related virtual networks using virsh command: ...

March 22, 2021 · 3 min · 543 words · kenno

Attaching a Disk to KVM Guest on Command Line

Again, just a quick note to remind myself how to attach a disk to a VM guest from the command line. The following steps is based on these assumptions: A spare disk: an LVM volume name db2_data on data volume group The name/domain of the VM is db2 List the name of the VM guest and available logical volume. [root@mathvm5 ~]# virsh list | grep db2 20 db2 running [root@mathvm5 ~]# lvs | grep db2 db2 vm -wi-ao---- 80.00g db2_data vm -wi-a----- 128.00g Run virsh attach-disk command to attach a disk to a VM. Notice that –persistent option is passed to the command so that this new disk will be permanently attached to the VM. ...

December 2, 2020 · 1 min · 170 words · kenno

Autostart a KVM Domain

Again this is a quick note to explain myself how to set a kvm (domain/vm) autostart when the server boots up. To list autostart domains: virsh list --autostart To set a domian, e.g. dhcp1, to autostart: virsh autostart dhcp1 To disable autostart for a domain (e.g. named dhcp1): virsh autostart dhcp1 --disable Ref: KVM: Start a Virtual Machine / Guest At Boot Time

February 13, 2019 · 1 min · 63 words · Kenno