virsh
Created: May 11, 2020
To completey remove a VM (domain)
virsh undefine --domain ns01.lunartech.tech
virsh destroy --domain ns01.lunartech.tech
virsh pool-refresh default
virsh vol-delete --pool default --vol ns01.lunartech.tech.qcow2
Get the VNC/Spice port of a VM
virsh domdisplay --domain [DOMAIN]
Libvirt Network Types
- NAT (default).
- Routed. Requires static routing set up on a router.
-
Isolated.
- Bridged. Essentially manual and not managed by libvirt. Harder but stops libvirt manipulating iptables by itself.
To Create An Isolated Network
Create an isolated.xml file:
<network>
<name>isolated</name>
<bridge name="isolated" />
<ip address="172.16.5.0" netmask="255.255.255.0">
<dhcp>
<range start="172.16.5.2" end="172.16.5.128"/>
</dhcp>
</ip>
</network>
Define the network:
virsh net-define isolated.xml
Enable virsh console Access on CentOS8/RHEL8
Edit /etc/default/grub and add the following to the kernel line:
console=tty0 console=ttyS0,115200
Re-build GRUB (UEFI):
grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
Connect via the serial console:
virsh console --domain VM_NAME