# convert raw image to qcow2
sudo qemu-img convert -f raw -O qcow2 <raw> <qcow2>

# resize a qcow2 disk
sudo qemu-img resize <qcow2> +<size increase>g

# install a VM
sudo virt-install  --name $1 --memory 4096 --vcpus 2 --disk <qcow2 disk to use>,bus=sata --import --os-variant ubuntu20.04 --network network=default,model=virtio,driver.iommu=on

# if there is no network when you run virt-install, then do the below
virsh net-start default
# always start
virsh net-autostart default

# list nets
virsh net-list

# list net info
virsh net-info default

# Create a virtual disk
qemu-img create -f qcow2 <disk name> <disk size>G

# attach disk to VM
virsh attach-disk <vm name> --source <absolute path to disk> --target <device name. ex: sdb> --persistent

# sometimes the new device within the VM doesn't show the full size
virsh edit <vm name>
# Make sure the XML entry looks similar to
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='<path to disk image>'/>
      <target dev='sdb' bus='sata'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>

# list VM IP leases 
sudo virsh net-dhcp-leases default

# Misc
=======
# Adding a user
sudo addgroup  --gid $GID $USER
# Add user with specific UID and GID
sudo useradd $USER -u $UID -g $GID -m -s /bin/bash
# Give user sudo permissions
sudo usermod -aG sudo $USER
# reset the user password
sudo passwd $USER

# Enabling console access to a KVM using virsh
=============================================
# On the guest
systemctl enable serial-getty@ttyS0.service
systemctl start serial-getty@ttyS0.service

# on the host
virsh console centos8

Some Useful links