KVM/oVirt Commands
KVM and oVirt CLI commands for open-source virtualization.
Host Startup Procedure
Step 1: Power on KVM hostBoot the physical server
Step 2: Wait for host bootWait for Linux OS to fully boot
systemctl status libvirtdKVM/libvirtVerify libvirt service is running
systemctl start libvirtdKVM/libvirtStart libvirt service if stopped
Step 3: VMs auto-startKVM/libvirtVMs with autostart enabled will boot automatically
virsh list --allKVM/libvirtList all VMs and their states
systemctl status vdsmdoVirtVerify VDSM service on oVirt host
Step 4: Check oVirt EngineoVirtVerify oVirt Engine is accessible
systemctl status ovirt-engineoVirtCheck Engine service status
Host Shutdown Procedure
Step 1: Shutdown all VMs (KVM)KVM/libvirtGracefully shutdown all VMs
virsh list --state-runningKVM/libvirtList running VMs
virsh shutdown <vm-name>KVM/libvirtGracefully shutdown each VM
Step 2: Put host in maintenance (oVirt)oVirtMove VMs to other hosts first
action host <host> deactivateoVirtPut host in maintenance mode
Step 3: Stop servicesKVM/libvirtStop virtualization services
systemctl stop libvirtdKVM/libvirtStop libvirt service
systemctl stop vdsmdoVirtStop VDSM service
Step 4: Shutdown hostBothGracefully shutdown the host
shutdown -h nowShutdown the host immediately
rebootReboot the host (alternative)
VM Management - KVM/libvirt
virsh list --allKVM/libvirtList all VMs
virsh dominfo <vm-name>KVM/libvirtDisplay VM information
virsh start <vm-name>KVM/libvirtStart VM
virsh shutdown <vm-name>KVM/libvirtGraceful shutdown VM
virsh destroy <vm-name>KVM/libvirtForce stop VM
virsh reboot <vm-name>KVM/libvirtReboot VM
virsh suspend <vm-name>KVM/libvirtPause VM
virsh resume <vm-name>KVM/libvirtResume paused VM
virsh autostart <vm-name>KVM/libvirtEnable VM autostart
virsh autostart --disable <vm-name>KVM/libvirtDisable VM autostart
virsh undefine <vm-name>KVM/libvirtDelete VM definition
virsh undefine <vm-name> --remove-all-storageKVM/libvirtDelete VM and storage
virt-install --name <name> --memory <MB> --vcpus <num> --disk path=<path>,size=<GB>KVM/libvirtCreate new VM
virsh setvcpus <vm-name> <count> --config --maximumKVM/libvirtSet max vCPU count
virsh setmem <vm-name> <size-KB> --configKVM/libvirtSet VM memory
VM Management - oVirt CLI
ovirt-shelloVirtStart oVirt shell
list vmsoVirtList all VMs in oVirt shell
show vm <vm-name>oVirtDisplay VM details
action vm <vm-name> startoVirtStart VM
action vm <vm-name> stopoVirtStop VM
action vm <vm-name> shutdownoVirtGraceful shutdown
action vm <vm-name> suspendoVirtSuspend VM
add vm --name <name> --cluster-name <cluster> --template-name BlankoVirtCreate VM
update vm <vm-name> --memory <bytes>oVirtUpdate VM memory
update vm <vm-name> --cpu-topology-cores <num>oVirtUpdate CPU cores
Storage Management - KVM
virsh pool-list --allKVM/libvirtList storage pools
virsh pool-define-as <name> dir --target <path>KVM/libvirtCreate directory pool
virsh pool-start <pool-name>KVM/libvirtStart storage pool
virsh pool-autostart <pool-name>KVM/libvirtEnable pool autostart
virsh pool-destroy <pool-name>KVM/libvirtStop storage pool
virsh vol-list <pool-name>KVM/libvirtList volumes in pool
virsh vol-create-as <pool> <name> <size>GKVM/libvirtCreate volume
virsh vol-delete <volume> --pool <pool>KVM/libvirtDelete volume
virsh vol-resize <volume> --pool <pool> <size>GKVM/libvirtResize volume
qemu-img create -f qcow2 <file> <size>GKVM/libvirtCreate qcow2 disk image
qemu-img info <file>KVM/libvirtDisplay image information
qemu-img convert -f qcow2 -O raw <source> <dest>KVM/libvirtConvert image format
qemu-img resize <file> +<size>GKVM/libvirtResize disk image
Storage Management - oVirt
list storagedo mainsoVirtList storage domains
show storagedomain <name>oVirtDisplay storage domain details
list disksoVirtList all disks
show disk <disk-id>oVirtDisplay disk details
add disk --name <name> --size <GB> --storage-domain-name <domain>oVirtCreate disk
action disk <disk-id> attach --vm-name <vm>oVirtAttach disk to VM
action disk <disk-id> detachoVirtDetach disk from VM
Network Management - KVM
virsh net-list --allKVM/libvirtList all networks
virsh net-info <network>KVM/libvirtDisplay network information
virsh net-start <network>KVM/libvirtStart network
virsh net-autostart <network>KVM/libvirtEnable network autostart
virsh net-define <xml-file>KVM/libvirtDefine network from XML
virsh net-destroy <network>KVM/libvirtStop network
virsh net-undefine <network>KVM/libvirtDelete network definition
virsh domiflist <vm-name>KVM/libvirtList VM network interfaces
virsh attach-interface <vm> network <network> --model virtio --configKVM/libvirtAdd network interface to VM
virsh detach-interface <vm> network --mac <mac>KVM/libvirtRemove network interface
ip link add <bridge> type bridgeKVM/libvirtCreate Linux bridge
ip link set <interface> master <bridge>KVM/libvirtAdd interface to bridge
Network Management - oVirt
list networksoVirtList all networks
show network <name>oVirtDisplay network details
add network --name <name> --data_center-name <dc>oVirtCreate network
list nics --vm-name <vm>oVirtList VM NICs
add nic --vm-name <vm> --network-name <network> --name <nic>oVirtAdd NIC to VM
delete nic <nic-id> --vm-name <vm>oVirtRemove NIC from VM
Snapshot Management
virsh snapshot-create-as <vm> <snapshot-name>KVM/libvirtCreate snapshot
virsh snapshot-list <vm>KVM/libvirtList VM snapshots
virsh snapshot-info <vm> <snapshot>KVM/libvirtDisplay snapshot info
virsh snapshot-revert <vm> <snapshot>KVM/libvirtRevert to snapshot
virsh snapshot-delete <vm> <snapshot>KVM/libvirtDelete snapshot
action vm <vm> snapshot --description <desc>oVirtCreate VM snapshot
list snapshots --vm-name <vm>oVirtList snapshots
action vm <vm> preview_snapshot --snapshot-id <id>oVirtPreview snapshot
action vm <vm> undo_snapshotoVirtUndo snapshot preview
delete snapshot <id> --vm-name <vm>oVirtDelete snapshot
Migration & HA - oVirt
action vm <vm> migrate --host-name <target-host>oVirtMigrate VM to another host
update vm <vm> --high_availability-enabled trueoVirtEnable HA for VM
update vm <vm> --high_availability-priority <num>oVirtSet HA priority
list hostsoVirtList all hosts in cluster
action host <host> fenceoVirtFence (power manage) host
action host <host> activateoVirtActivate host
action host <host> deactivateoVirtPut host in maintenance
Monitoring & Troubleshooting
virsh nodeinfoKVM/libvirtDisplay host node information
virsh nodecpustatsKVM/libvirtDisplay host CPU stats
virsh nodememstatsKVM/libvirtDisplay host memory stats
virsh domstats <vm>KVM/libvirtDisplay VM statistics
virsh vcpuinfo <vm>KVM/libvirtDisplay VM vCPU information
virsh console <vm>KVM/libvirtConnect to VM console
virsh edit <vm>KVM/libvirtEdit VM XML configuration
virsh dumpxml <vm>KVM/libvirtDisplay VM XML definition
virt-topKVM/libvirtMonitor VM resource usage (top-like)
journalctl -u libvirtd -fKVM/libvirtMonitor libvirt logs
tail -f /var/log/libvirt/qemu/<vm>.logKVM/libvirtMonitor VM QEMU logs
systemctl status vdsmdoVirtCheck VDSM status
vdsm-client Host getStatsoVirtGet host statistics
tail -f /var/log/vdsm/vdsm.logoVirtMonitor VDSM logs