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 libvirtdVerify libvirt service is running
systemctl start libvirtdStart libvirt service if stopped
Step 3: VMs auto-startVMs with autostart enabled will boot automatically
virsh list --allList all VMs and their states
systemctl status vdsmdVerify VDSM service on oVirt host
Step 4: Check oVirt EngineVerify oVirt Engine is accessible
systemctl status ovirt-engineCheck Engine service status
Host Shutdown Procedure
Step 1: Shutdown all VMs (KVM)Gracefully shutdown all VMs
virsh list --state-runningList running VMs
virsh shutdown <vm-name>Gracefully shutdown each VM
Step 2: Put host in maintenance (oVirt)Move VMs to other hosts first
action host <host> deactivatePut host in maintenance mode
Step 3: Stop servicesStop virtualization services
systemctl stop libvirtdStop libvirt service
systemctl stop vdsmdStop VDSM service
Step 4: Shutdown hostGracefully shutdown the host
shutdown -h nowShutdown the host immediately
rebootReboot the host (alternative)
VM Management - KVM/libvirt
virsh list --allList all VMs
virsh dominfo <vm-name>Display VM information
virsh start <vm-name>Start VM
virsh shutdown <vm-name>Graceful shutdown VM
virsh destroy <vm-name>Force stop VM
virsh reboot <vm-name>Reboot VM
virsh suspend <vm-name>Pause VM
virsh resume <vm-name>Resume paused VM
virsh autostart <vm-name>Enable VM autostart
virsh autostart --disable <vm-name>Disable VM autostart
virsh undefine <vm-name>Delete VM definition
virsh undefine <vm-name> --remove-all-storageDelete VM and storage
virt-install --name <name> --memory <MB> --vcpus <num> --disk path=<path>,size=<GB>Create new VM
virsh setvcpus <vm-name> <count> --config --maximumSet max vCPU count
virsh setmem <vm-name> <size-KB> --configSet VM memory
VM Management - oVirt CLI
ovirt-shellStart oVirt shell
list vmsList all VMs in oVirt shell
show vm <vm-name>Display VM details
action vm <vm-name> startStart VM
action vm <vm-name> stopStop VM
action vm <vm-name> shutdownGraceful shutdown
action vm <vm-name> suspendSuspend VM
add vm --name <name> --cluster-name <cluster> --template-name BlankCreate VM
update vm <vm-name> --memory <bytes>Update VM memory
update vm <vm-name> --cpu-topology-cores <num>Update CPU cores
Storage Management - KVM
virsh pool-list --allList storage pools
virsh pool-define-as <name> dir --target <path>Create directory pool
virsh pool-start <pool-name>Start storage pool
virsh pool-autostart <pool-name>Enable pool autostart
virsh pool-destroy <pool-name>Stop storage pool
virsh vol-list <pool-name>List volumes in pool
virsh vol-create-as <pool> <name> <size>GCreate volume
virsh vol-delete <volume> --pool <pool>Delete volume
virsh vol-resize <volume> --pool <pool> <size>GResize volume
qemu-img create -f qcow2 <file> <size>GCreate qcow2 disk image
qemu-img info <file>Display image information
qemu-img convert -f qcow2 -O raw <source> <dest>Convert image format
qemu-img resize <file> +<size>GResize disk image
Storage Management - oVirt
list storagedo mainsList storage domains
show storagedomain <name>Display storage domain details
list disksList all disks
show disk <disk-id>Display disk details
add disk --name <name> --size <GB> --storage-domain-name <domain>Create disk
action disk <disk-id> attach --vm-name <vm>Attach disk to VM
action disk <disk-id> detachDetach disk from VM
Network Management - KVM
virsh net-list --allList all networks
virsh net-info <network>Display network information
virsh net-start <network>Start network
virsh net-autostart <network>Enable network autostart
virsh net-define <xml-file>Define network from XML
virsh net-destroy <network>Stop network
virsh net-undefine <network>Delete network definition
virsh domiflist <vm-name>List VM network interfaces
virsh attach-interface <vm> network <network> --model virtio --configAdd network interface to VM
virsh detach-interface <vm> network --mac <mac>Remove network interface
ip link add <bridge> type bridgeCreate Linux bridge
ip link set <interface> master <bridge>Add interface to bridge
Network Management - oVirt
list networksList all networks
show network <name>Display network details
add network --name <name> --data_center-name <dc>Create network
list nics --vm-name <vm>List VM NICs
add nic --vm-name <vm> --network-name <network> --name <nic>Add NIC to VM
delete nic <nic-id> --vm-name <vm>Remove NIC from VM
Snapshot Management
virsh snapshot-create-as <vm> <snapshot-name>Create snapshot
virsh snapshot-list <vm>List VM snapshots
virsh snapshot-info <vm> <snapshot>Display snapshot info
virsh snapshot-revert <vm> <snapshot>Revert to snapshot
virsh snapshot-delete <vm> <snapshot>Delete snapshot
action vm <vm> snapshot --description <desc>Create VM snapshot
list snapshots --vm-name <vm>List snapshots
action vm <vm> preview_snapshot --snapshot-id <id>Preview snapshot
action vm <vm> undo_snapshotUndo snapshot preview
delete snapshot <id> --vm-name <vm>Delete snapshot
Migration & HA - oVirt
action vm <vm> migrate --host-name <target-host>Migrate VM to another host
update vm <vm> --high_availability-enabled trueEnable HA for VM
update vm <vm> --high_availability-priority <num>Set HA priority
list hostsList all hosts in cluster
action host <host> fenceFence (power manage) host
action host <host> activateActivate host
action host <host> deactivatePut host in maintenance
Monitoring & Troubleshooting
virsh nodeinfoDisplay host node information
virsh nodecpustatsDisplay host CPU stats
virsh nodememstatsDisplay host memory stats
virsh domstats <vm>Display VM statistics
virsh vcpuinfo <vm>Display VM vCPU information
virsh console <vm>Connect to VM console
virsh edit <vm>Edit VM XML configuration
virsh dumpxml <vm>Display VM XML definition
virt-topMonitor VM resource usage (top-like)
journalctl -u libvirtd -fMonitor libvirt logs
tail -f /var/log/libvirt/qemu/<vm>.logMonitor VM QEMU logs
systemctl status vdsmdCheck VDSM status
vdsm-client Host getStatsGet host statistics
tail -f /var/log/vdsm/vdsm.logMonitor VDSM logs