Virtual machines

As stated in the introduction, Virtual machines are full machines, started from within your host’s OS or hypervisor
Within the platform, we are relying on multiple Virtualization technologies depending on the use case.

Access to the VMs

There’s a race condition between firewalld and libvirt concerning port forwarding. To be sure that packets are well forwarded, executes: sudo sh /etc/libvirt/hooks/qemu at each reboot of firewalld (includin machine reboot)

Wipe VMS

Sometimes script can mess and you want to restart from a blank page. As VMs are not that easy to manage, you should execute some commands in order to go back to the initial mode (for example, when you modified the name of one VM)

  1. Delete the machines You should first delete the machine:

sudo virsh list
sudo virsh destroy <the machines>
sudo virsh undefine <the machines>
  1. Delete the dhcp host entries

sudo virsh net-dumpxml default
sudo virsh net-update default delete ip-dhcp-host "<host mac='<the macadress>' name='<the host' ip='<the ip>'/>" --live

You can also use virsh net-edit default, virsh net-destroy default, virsh net-start default for bulk edit.

  1. Delete the firewall redirection rules

sudo firewall-cmd --list-all --zone=public
sudo firewall-cmd --zone=public --remove-rich-rule='rule family="ipv4" forward-port port="<the port>" protocol="<the protocol>" to-port="<the destination port>" to-addr="<the vm adress>"'
sudo firewall-cmd --runtime-to-permanent
  1. Delete ssh hook The default vagrant boxes ssh keys are downloaded on the host in order to access the machines when they are downloaded, then these keys are deleted and VMs are considered 'configured'. If you want to reset VMs, you’ll also have to delete the persistent facts

sudo rm /etc/ansible/facts.d/ansible_virtualization_guest.fact
  1. Delete the images The box images could have been updated, please also remove the content of the sudo rm -rf /var/lib/libvirt/images folder

  2. additional host entries

Finally, there could be some additional entries in /etc/host that won’t be useful anymore

Make the network configuration permanent

It’s not very clear if network dhcp leases configuration are permanent or not after reboots

You can verify after reboot if you already have your <host entries while typing the command `sudo virsh net-dumpxml default`on your host.

In order to be sure that it’s the actual behavior, you’ve to first retrieve the guests mac adress: sudo virsh domiflist <guest hostname>

Then update the virsh net configuration: sudo virsh net-update default add ip-dhcp-host '<host mac="<mac address>" ip="<target ip>"/>' --live --config