en En
es Es

Managing VMs with virsh

VMmanager uses the Libvirt toolkit to manage virtualization. Libvirt includes the virsh utility, which allows you to perform operations on virtual machines (VM) via the command line. This article contains examples of how to use the virsh utility. For detailed information on how virsh works, see the official Libvirt documentation.

Use the commands from this article if you cannot perform VM operations through the platform's web interface.

Usage examples

To manage VMs via virsh, connect to the cluster node hosting these VMs via SSH. For more information on connecting via SSH, see the article Workstation setup.

Display VM list

virsh list --all


Example answer
Id    Name                           State
------------------------------------------------
 13    2289_phthalo_onyx              paused
 15    2921_sshstorage                running
 100   4820_cocoa-silver              running
 103   4831_grafana                   running
 -     2925_storage2                  shut off

Comments:

  • Id — VM id in the hypervisor. Not available if the VM is not running;
  • Name — VM name in Libvirt. For example, if the VM has id 12 and name test in the platform, it will have name 12_test in Libvirt;
  • State — VM status:
    • running;
    • shut off — completely stopped;
    • paused;
    • in shutdown — shutdown process in progress;
    • crashed — terminated abnormally;
    • pmsuspended — paused via power management.

Start VM

virsh start <VM_name_or_id>

Correctly terminate VM

virsh shutdown <VM_name_or_id>

Forcefully terminate VM

Use this command only if the VM cannot be stopped using the virsh shutdown command. The command acts similarly to an emergency power shutdown on a server. In some cases, the command may result in data loss and damage to the file system within the guest OS.


virsh destroy <VM_name_or_id>

Reboot ВМ

virsh reboot <VM_name_or_id>

Pause ВМ

virsh suspend <VM_name_or_id>

Remove VM from Paused state

virsh resume <VM_name_or_id>

Get VM configuration

virsh dumpxml <VM_name_or_id>
Example answer
<domain type='kvm' id='15'>
  <name>2921_sshstorage</name>
  <uuid>11111111-6716-440c-977e-1712dd752411</uuid>
  <memory>1048576</memory>
  <vcpu>1</vcpu>
  <os>
    <type arch='x86_64'>hvm</type>
  </os>
  <devices>
    <disk type='file' device='disk'>
      <source file='/var/lib/libvirt/images/minimal-vm.qcow2'/>
      <target dev='vda' bus='virtio'/>
    </disk>
    <interface type='network'>
      <source network='default'/>
    </interface>
    <console type='pty'/>
  </devices>
</domain>

Comments:

  • domain — root configuration element:
    • type — hypervisor type;
    • id — VM ID;
  • name — VM name;
  • uuid — universal unique identifier of the VM;
  • memory — RAM capacity in KiB;
  • vcpu — number of vCPUs;
  • os — guest OS settings;
  • devices — connected devices:
    • disk — virtual disks;
    • interface — network interfaces;
    • console — virtual console.

For more information about configuration, see the Libvirt documentation.

Edit VM configuration

virsh edit <VM_name_or_id>

The file contents will open in the vim editor. To edit the file, press i and make the necessary changes. To exit the editor:

  • with saving changes — press Esc and enter :wq
  • without saving — press Esc and enter :q!


Connect to VM console

virsh console <VM_name_or_id>


The article was last updated on 10.31.2025. The article was prepared by technical writers of ISPsystem