To delete a KVM virtual machine (VM) guest using the virsh
command, you can use the following steps:
virsh shutdown
command. For example:virsh shutdown <vm name>
Replace <vm name>
with the name of the VM you want to shut down.
virsh undefine
command to remove the VM's definition from the libvirt configuration. For example:virsh undefine <vm name>
Replace <vm name>
with the name of the VM you want to undefine.
rm
command to delete the file. For example:rm /path/to/vm/disk.img
Replace /path/to/vm/disk.img
with the path to the VM's disk image.
Keep in mind that these steps will delete the VM and all of its data. Make sure you have a backup of any important data before deleting the VM.