Basic virsh commands

Libvirt is an open source API, daemon and management tool for managing platform virtualization. The virsh command is the way the user is able to manage his virtualization environment.

The virsh program is the main interface for managing virsh guest domains. The program can be used to create, pause, and shutdown domains. It can also be used to list current domains.

Use virsh on a host system as root to manage your guests (VM’s) from the command line:

Show active guests:
===================
[root@proteus ~]# virsh list
 Id    Name                           State
----------------------------------------------------
 2     hadron - ubuntu 14.04.2        running
 3     ies_team-sles12                running
 
Show also powered off guests:
===============+++++=========
[root@proteus ~]# virsh list --all 
 Id    Name                           State
----------------------------------------------------
 2     hadron - ubuntu 14.04.2        running
 3     ies_team-sles12                running
 -     RHEL-7.0-Tests                 shut off
 -     RHEL-7.2-LE-daniel             shut off

Start the domain you select:
============================
[root@proteus ~]# virsh start ubuntu-14.04.3-daniel-tests
Domain ubuntu-14.04.3-daniel-tests started

Power off the domain you select:
================================
[root@proteus ~]# virsh destroy ubuntu-14.04.3-daniel-tests
Domain ubuntu-14.04.3-daniel-tests destroyed

The "--console" flag (start and drop into the VM's console)
=====================
[root@proteus ~]# virsh start ubuntu-14.04.3-daniel-tests --console

Grab the console of your VM:
============================
[root@proteus ~]# virsh console ubuntu-14.04.3-daniel-tests
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s