Virsh commands

From DISI
Jump to navigation Jump to search

virsh is command line tool for the libvirt API which allows us to interact with Linux kernel virtual machines (KVM)

Handy Commands

To list all virtual machines and their state on hypervisor

virsh list --all

To start a powered down virtual machine

virsh start <vm_name>

To force shutdown a virtual machine (pulling the plug on a VM)

virsh destroy --graceful <vm_name>

To view virtual machine network interfaces

virsh domiflist <vm_name>

Adding a network interface to a VM

virsh attach-interface --domain <vm_name> --type <bridge/network> --source <source-device> --model virtio --mac <insert-whatever-mac-address> --config

To detach a virtual cdrom/iso file from a VM

sudo virsh detach-disk <vmname> <full path on server to iso/cd image file> --config