KVM, QEMU start or stop virtual machine from command line (CLI)

Written by
Date: 2013-02-11 16:59:13 00:00

KVM or Kernel Based Virtual Machine is a popular virtualization technology. It allows you to run virtual guest machines over a host machine.

To start or stop virtual machines created on head-less servers you have to use the CLI or command line interface. There are more than one option, but we will see just one.

We will use virsh, which is based on libvirt.

A toolkit to interact with the virtualization capabilities of recent versions of Linux (and other OSes), see our project goals for details.

First check which virtual machines are available:

virsh list --all

In my case the output is:

 Id    Name                           State
----------------------------------------------------
 -     ubuntu-desktop                 shut off
 -     ubuntu-server                  shut off

I will start the ubuntu-server virtual machine:

virsh start ubuntu-server

The output is:

Domain ubuntu-server started

To shut it down, just enter.

virsh shutdown ubuntu-server