KVM Command

Table of Contents

Some KVM frequently used commands.

Connection string

virsh and virt-manager use same connection string.

  • Local

    virsh -c qemu:///system
  • Remote

    virsh -c qemu+ssh://user@hostname/system
  • Remote from MacOS

    virsh -c qemu+ssh://user@hostname/system?socket=/var/run/libvirt/libvirt-sock


virsh list      # List running VMs only
virsh list -all # List VMs regardless of running state
virsh list --with-snapshot

virsh start <vm name>
virsh stop <vm name>


  • List

    virsh snapshot-list <vm name>
  • Create

    virsh snapshot-create -domain <vm name>
    virsh snapshot-create-as --domain <vm name> --name <snapshot name>
  • Revert

    virsh snapshot-revert <vm name> <snapshot name>
  • Delete

    virsh snapshot-delete --snapshotname <snapshot name> <vm name>


virsh net-list
virsh net-list --all

Pool and Vol

virsh pool-list
virsh pool-list --all

virsh vol-list <pool name>
virsh vol-list default


  • Create

    qemu-img create -f <format> <filename> <size>
    qemu-img create -f qcow2 ubuntu.img 500M

    vmdk(vmware) and vdi(virtualbox) are supported.

  • Info

qemu-img info <filename>
  • Resize

    qemu-img resize <filename> [+|-]<size>
    qemu-img resize ubuntu.img 550M # set image to new size, use --shrink if new size is smaller
    qemu-img resize ubuntu.img +10M # increase image size by 10M
    qemu-img resize --shrink ubuntu.img -10M # decrease image size by 10M

    Check Linux Commands for resizing partition after an image resize.

John Siu
Minimize the Effort, Maximize the Effect!
comments powered by Disqus