Virsh – a quick guide to everyday use commands (Linux/KVM)

Virsh is the command-line tool for managing KVM-based virtual servers, it is an interface to libvirt through the command line.

If you have limited exposure to this tool it can seem daunting due to the huge amount of options and submenu options it provides. This guide is intended to give you some of the commands you are likely to need to get started.

In this guide, we will assume that you keep your virtual server config files (XML) in /etc/libvirt/qemu as is the libvirt standard, if you are running a virtual server control panel such as SolusVM they may be in /home/kvm/kvm1234/kvm1234.xml, both virtualizor and proxmox tend to use libvirt standard file paths.

We will also assume the name of the virtual server we will be working with is kvm101 which would mean the config file for this server is named kvm101.xml

Start a virtual server

virsh create /etc/libvirt/qemu/kvm101.xml

To issue a clean shutdown request 

virsh shutdown kvm101

To instantly stop a virtual server (this does not actually destroy or delete the virtual server as the command may suggest but just stops it instantly like a power off)

virsh destroy kvm101

To reboot a virtual server

virsh reboot kvm101

Check a live virtual servers active config

virsh dumpxml kvm101

Stop a virtual server disk from using more than 100 iops at any given time (add –config to the end to survive a reboot)

virsh blkdeviotune kvm101 /dev/Volgroup00/kvm101_img –total-iops-sec 100 –live

Set IO weight of a virtual server (the higher the number the higher the resource priority) 

virsh blkiotune –weight 250 kvm101 –live