Please Note:
The KVM module example makes the following assumptions:
- The hypervisor is KVM for CentOS 7 and it is installed on both servers
- The VM_PATH/VM_NAME folder contains a single exported virtual machine
- On the first module configuration, the VM is configured only on one server
Apply the following procedure to setup the module. In the following,the vm is configured only on server1 ;
VM_PATH is
/var/lib/libvirt/images and VM_NAME is
vm1.
- On server1:
- Stop vm1:
virsh shutdown vm1
- Copy the vm1 image to the new VM image location:
cp -a /var/lib/libvirt/images/vm1.qcow2 /var/lib/libvirt/images/vm1/
(Note: the original VM image can be deleted as soon as tests with the new location are successfull)
- Edit the vm1 configuration:
EDITOR=vi virsh edit vm1 and change the line:
<source file='/var/lib/libvirt/images/vm1.qcow2'>
by replacing the file value with /var/lib/libvirt/images/vm1/vm1.qcow2
- Disable vm1 automatic start:
virsh autostart vm1 --disable
- Create a configuration xml dump for vm1:
virsh dumpxml vm1 > vm1.xml
- On server2:
- Copy the xml configuration vm1.xml from server1
- Create the vm1 but do not start:
virsh define vm1.xml
- Disable vm1 automatic start:
virsh autostart vm1 --disable
- Create the directory for the image location:
mkdir -p /var/lib/libvirt/images/vm1/
On the first start, start server1 as primary.
Note: Whenever vm1 configuration is changed, you must reapply the new configuration on the other server