Installing and Running a Headless Virtualization Server

Re-list all locally installed virtual machines. Listed will be your newly created machine, and it is currently in a "running" state:


$ sudo /usr/bin/virsh list --all
 Id    Name                           State
----------------------------------------------------
 1     CentOS6.5-vm1                  running

Note: the virt-install manual page showcases many examples of utility usage and invocation.

Managing the Virtual Machine

Once the virtual machine(s) is/are defined, the virsh utility provides the administrator with all the facilities required to manage the virtual machines.

I already covered listing virtual machine, with their domain ID, name and state:


$ sudo /usr/bin/virsh list --all
 Id    Name                           State
----------------------------------------------------
 -     CentOS6.5-vm1                  shut off

To start an already shut down virtual machine, type:


$ sudo /usr/bin/virsh start CentOS6.5-vm1
Domain CentOS6.5-vm1 started

To reboot an already running virtual machine, type:


$ sudo /usr/bin/virsh reboot CentOS6.5-vm1
Domain CentOS6.5-vm1 is being rebooted

When a virtual machine is running, it will be assigned a domain ID. This domain ID also can be used to manage a virtual machine. For instance, the same reboot command can be invoked the following way:


$ sudo /usr/bin/virsh reboot 1
Domain 1 is being rebooted

To shut down the virtual machine, type:


$ sudo /usr/bin/virsh shutdown 1
Domain 1 is being shutdown

Sometimes, a virtual machine may become unresponsive and will not adhere to your reboot or shutdown requests. This is where the destroy command comes into play. To force a complete shutdown of the virtual machine, type:


$ sudo /usr/bin/virsh destroy 1
Domain 1 destroyed

To pause a virtual machine, type:


$ sudo /usr/bin/virsh suspend 1
Domain 1 suspended

$ sudo /usr/bin/virsh list --all
 Id    Name                           State
----------------------------------------------------
 1     CentOS6.5-vm1                  paused

To resume an already paused virtual machine, type:


$ sudo /usr/bin/virsh resume 1
Domain 1 resumed

$ sudo /usr/bin/virsh list --all
 Id    Name                           State
----------------------------------------------------
 1     CentOS6.5-vm1                  running

If there is ever a scenario in which you need to remove a virtual machine completely, you must undefine it. In order to undefine a virtual machine, it must be in a shut-off state. To undefine a virtual machine, type:


$ sudo /usr/bin/virsh undefine CentOS6.5-vm1
Domain CentOS6.5-vm1 has been undefined

$ sudo /usr/bin/virsh list --all
 Id    Name                           State
----------------------------------------------------

The virsh command also is capable of providing the user with domain, network and more details/functionality. Read through the manual page to learn more of these features.

______________________

Petros Koutoupis is a software developer at IBM for its Cloud Object Storage division (formerly Cleversafe). He is also the creator and maintainer of the RapidDisk Project. Petros has worked in the data storage industry for more than a decade.