How to Display Virtual Machine List in KVM via Command Line

Posted on

KVM or Kernel-based Virtual Machine is one of the alternative technology available to create virtual machines which can used further. There can be lots of virtual machines created in the server installed with it. In the context of this article, in order to display those virtual machines created in the form of list in KVM (Kernel-based Virtualization Machine) as a virtualization technology platform chosen installed in the actual physical server, it can actually be done by executing a certain command via command line, that certain command in the following is the actual command which can be executed as shown below :

virsh list

The above command is executed in a real situation with the output generated as shown below :

[root@hostname ~]# virsh list
 Id    Name                           State
----------------------------------------------------
 3     instance-00000023              running
 4     instance-0000007b              running
 5     instance-00000040              running
 6     instance-00000053              running
 7     instance-0000007f              running
 10    instance-0000002b              running
 13    instance-00000025              running

[root@hostname ~]#

The above output generated only shows the virtual machine with a running state. So, in order to display all of the actual virtual machine exist in the machine installed or utilized with KVM Virtualization Platform, just add an additional argument in order to display all of it with the following pattern :

virsh list --all

Below is the actual output of the command generated in a real situation executed in a physical server installed with KVM Virtualization Platform :

[root@hostname ~]# virsh list --all                                                                                                                                                                                                  
 Id    Name                           State                                                                                                                                                                                       
----------------------------------------------------                                                                                                                                                                              
 3     instance-00000023              running                                                                                                                                                                                     
 4     instance-0000007b              running                                                                                                                                                                                     
 5     instance-00000040              running                                                                                                                                                                                     
 6     instance-00000053              running                                                                                                                                                                                     
 7     instance-0000007f              running                                                                                                                                                                                     
 10    instance-0000002b              running                                                                                                                                                                                     
 13    instance-00000025              running                                                                                                                                                                                     
 -     instance-0000001c              shut off                                                                                                                                                                                    
 -     instance-00000021              shut off                                                                                                                                                                                    
 -     instance-0000002a              shut off                                                                                                                                                                                    
 -     instance-0000002e              shut off
 -     instance-0000002f              shut off
 -     instance-00000031              shut off
 -     instance-00000032              shut off
 -     instance-00000035              shut off
 -     instance-00000036              shut off
 -     instance-00000037              shut off
 -     instance-00000044              shut off

[root@hostname ~]#

As shown in the above output generated after the command execution, it can be seen that the only virtual machine displayed are not not only the running one but also the virtual machine exist in the state of poweroff or shut off.

One thought on “How to Display Virtual Machine List in KVM via Command Line

Leave a Reply