The following instruction will explain how to completely remove KVM-based Virtual Machines on Redhat Linux from command line using virsh command.

Operating System and Software Versions

  • Operating System: - Redhat 7.3
  • Software: - libvirtd (libvirt) 2.0.0


Privileged access to your Redhat Linux installation will be required.




  • # - requires given command to be executed with root privileges either directly as a root user or by use of sudo command
  • $ - given command to be executed as a regular non-privileged user


Obtain Virtual Machine's name

First obtain domain name of the virtual machine you wish to remove. This can be done by using a following command:
# virsh list
 Id    Name                           State
 3     linuxconfig                    running

Destroy Virtual machine

Once we have Virtual Machine name we wish to delete we first disassociate it from Virtual Manager:
# virsh destroy linuxconfig
Domain linuxconfig destroyed
After execution of the above command the virtual machine no longer exists within virtual manager inventory:
# virsh list
 Id    Name                           State

Undefine Virtual Machine

After destroying the above Virtual Machine its XML configuration file within /etc/libvirt/qemu directory and virtual disk(s) located in /var/lib/libvirt/images still exists.

To completely remove virtual machine and all its associated files we need to execute:
# virsh undefine linuxconfig --remove-all-storage
Domain linuxconfig has been undefined
Volume 'vda'(/var/lib/libvirt/images/linuxconfig.img) removed.