KVM/oVirt Commands

KVM and oVirt CLI commands for open-source virtualization.

Host Startup Procedure

Step 1: Power on KVM host

Boot the physical server

Step 2: Wait for host boot

Wait for Linux OS to fully boot

systemctl status libvirtdKVM/libvirt

Verify libvirt service is running

systemctl start libvirtdKVM/libvirt

Start libvirt service if stopped

Step 3: VMs auto-startKVM/libvirt

VMs with autostart enabled will boot automatically

virsh list --allKVM/libvirt

List all VMs and their states

systemctl status vdsmdoVirt

Verify VDSM service on oVirt host

Step 4: Check oVirt EngineoVirt

Verify oVirt Engine is accessible

systemctl status ovirt-engineoVirt

Check Engine service status

Host Shutdown Procedure

Step 1: Shutdown all VMs (KVM)KVM/libvirt

Gracefully shutdown all VMs

virsh list --state-runningKVM/libvirt

List running VMs

virsh shutdown <vm-name>KVM/libvirt

Gracefully shutdown each VM

Step 2: Put host in maintenance (oVirt)oVirt

Move VMs to other hosts first

action host <host> deactivateoVirt

Put host in maintenance mode

Step 3: Stop servicesKVM/libvirt

Stop virtualization services

systemctl stop libvirtdKVM/libvirt

Stop libvirt service

systemctl stop vdsmdoVirt

Stop VDSM service

Step 4: Shutdown hostBoth

Gracefully shutdown the host

shutdown -h now

Shutdown the host immediately

reboot

Reboot the host (alternative)

VM Management - KVM/libvirt

virsh list --allKVM/libvirt

List all VMs

virsh dominfo <vm-name>KVM/libvirt

Display VM information

virsh start <vm-name>KVM/libvirt

Start VM

virsh shutdown <vm-name>KVM/libvirt

Graceful shutdown VM

virsh destroy <vm-name>KVM/libvirt

Force stop VM

virsh reboot <vm-name>KVM/libvirt

Reboot VM

virsh suspend <vm-name>KVM/libvirt

Pause VM

virsh resume <vm-name>KVM/libvirt

Resume paused VM

virsh autostart <vm-name>KVM/libvirt

Enable VM autostart

virsh autostart --disable <vm-name>KVM/libvirt

Disable VM autostart

virsh undefine <vm-name>KVM/libvirt

Delete VM definition

virsh undefine <vm-name> --remove-all-storageKVM/libvirt

Delete VM and storage

virt-install --name <name> --memory <MB> --vcpus <num> --disk path=<path>,size=<GB>KVM/libvirt

Create new VM

virsh setvcpus <vm-name> <count> --config --maximumKVM/libvirt

Set max vCPU count

virsh setmem <vm-name> <size-KB> --configKVM/libvirt

Set VM memory

VM Management - oVirt CLI

ovirt-shelloVirt

Start oVirt shell

list vmsoVirt

List all VMs in oVirt shell

show vm <vm-name>oVirt

Display VM details

action vm <vm-name> startoVirt

Start VM

action vm <vm-name> stopoVirt

Stop VM

action vm <vm-name> shutdownoVirt

Graceful shutdown

action vm <vm-name> suspendoVirt

Suspend VM

add vm --name <name> --cluster-name <cluster> --template-name BlankoVirt

Create VM

update vm <vm-name> --memory <bytes>oVirt

Update VM memory

update vm <vm-name> --cpu-topology-cores <num>oVirt

Update CPU cores

Storage Management - KVM

virsh pool-list --allKVM/libvirt

List storage pools

virsh pool-define-as <name> dir --target <path>KVM/libvirt

Create directory pool

virsh pool-start <pool-name>KVM/libvirt

Start storage pool

virsh pool-autostart <pool-name>KVM/libvirt

Enable pool autostart

virsh pool-destroy <pool-name>KVM/libvirt

Stop storage pool

virsh vol-list <pool-name>KVM/libvirt

List volumes in pool

virsh vol-create-as <pool> <name> <size>GKVM/libvirt

Create volume

virsh vol-delete <volume> --pool <pool>KVM/libvirt

Delete volume

virsh vol-resize <volume> --pool <pool> <size>GKVM/libvirt

Resize volume

qemu-img create -f qcow2 <file> <size>GKVM/libvirt

Create qcow2 disk image

qemu-img info <file>KVM/libvirt

Display image information

qemu-img convert -f qcow2 -O raw <source> <dest>KVM/libvirt

Convert image format

qemu-img resize <file> +<size>GKVM/libvirt

Resize disk image

Storage Management - oVirt

list storagedo mainsoVirt

List storage domains

show storagedomain <name>oVirt

Display storage domain details

list disksoVirt

List all disks

show disk <disk-id>oVirt

Display disk details

add disk --name <name> --size <GB> --storage-domain-name <domain>oVirt

Create disk

action disk <disk-id> attach --vm-name <vm>oVirt

Attach disk to VM

action disk <disk-id> detachoVirt

Detach disk from VM

Network Management - KVM

virsh net-list --allKVM/libvirt

List all networks

virsh net-info <network>KVM/libvirt

Display network information

virsh net-start <network>KVM/libvirt

Start network

virsh net-autostart <network>KVM/libvirt

Enable network autostart

virsh net-define <xml-file>KVM/libvirt

Define network from XML

virsh net-destroy <network>KVM/libvirt

Stop network

virsh net-undefine <network>KVM/libvirt

Delete network definition

virsh domiflist <vm-name>KVM/libvirt

List VM network interfaces

virsh attach-interface <vm> network <network> --model virtio --configKVM/libvirt

Add network interface to VM

virsh detach-interface <vm> network --mac <mac>KVM/libvirt

Remove network interface

ip link add <bridge> type bridgeKVM/libvirt

Create Linux bridge

ip link set <interface> master <bridge>KVM/libvirt

Add interface to bridge

Network Management - oVirt

list networksoVirt

List all networks

show network <name>oVirt

Display network details

add network --name <name> --data_center-name <dc>oVirt

Create network

list nics --vm-name <vm>oVirt

List VM NICs

add nic --vm-name <vm> --network-name <network> --name <nic>oVirt

Add NIC to VM

delete nic <nic-id> --vm-name <vm>oVirt

Remove NIC from VM

Snapshot Management

virsh snapshot-create-as <vm> <snapshot-name>KVM/libvirt

Create snapshot

virsh snapshot-list <vm>KVM/libvirt

List VM snapshots

virsh snapshot-info <vm> <snapshot>KVM/libvirt

Display snapshot info

virsh snapshot-revert <vm> <snapshot>KVM/libvirt

Revert to snapshot

virsh snapshot-delete <vm> <snapshot>KVM/libvirt

Delete snapshot

action vm <vm> snapshot --description <desc>oVirt

Create VM snapshot

list snapshots --vm-name <vm>oVirt

List snapshots

action vm <vm> preview_snapshot --snapshot-id <id>oVirt

Preview snapshot

action vm <vm> undo_snapshotoVirt

Undo snapshot preview

delete snapshot <id> --vm-name <vm>oVirt

Delete snapshot

Migration & HA - oVirt

action vm <vm> migrate --host-name <target-host>oVirt

Migrate VM to another host

update vm <vm> --high_availability-enabled trueoVirt

Enable HA for VM

update vm <vm> --high_availability-priority <num>oVirt

Set HA priority

list hostsoVirt

List all hosts in cluster

action host <host> fenceoVirt

Fence (power manage) host

action host <host> activateoVirt

Activate host

action host <host> deactivateoVirt

Put host in maintenance

Monitoring & Troubleshooting

virsh nodeinfoKVM/libvirt

Display host node information

virsh nodecpustatsKVM/libvirt

Display host CPU stats

virsh nodememstatsKVM/libvirt

Display host memory stats

virsh domstats <vm>KVM/libvirt

Display VM statistics

virsh vcpuinfo <vm>KVM/libvirt

Display VM vCPU information

virsh console <vm>KVM/libvirt

Connect to VM console

virsh edit <vm>KVM/libvirt

Edit VM XML configuration

virsh dumpxml <vm>KVM/libvirt

Display VM XML definition

virt-topKVM/libvirt

Monitor VM resource usage (top-like)

journalctl -u libvirtd -fKVM/libvirt

Monitor libvirt logs

tail -f /var/log/libvirt/qemu/<vm>.logKVM/libvirt

Monitor VM QEMU logs

systemctl status vdsmdoVirt

Check VDSM status

vdsm-client Host getStatsoVirt

Get host statistics

tail -f /var/log/vdsm/vdsm.logoVirt

Monitor VDSM logs