Hits : 4817

libvirt : The virtualization API

Contents



virsh --version=long


virsh -c qemu:///system
#virsh list

virsh -c qemu:///system start archlinux
virsh -c qemu:///system shutdown archlinux


snapshot & restore

Formatter "highlight/html" not found

virsh connect


virsh -c qemu:///system list --all

or via ssh

virsh -c qemu+ssh://example.com/system list --all


Problem on client:

error: End of file while reading data: sh: nc.openbsd: command not found: Input/output error


Solution on server:

# ln -s /usr/bin/nc /usr/bin/nc.openbsd


top

virt-install


eg.

#!/bin/sh

virt-install \
        --connect=qemu+ssh://ebal@example.com/system \
        -n archlinux \
        -r 512 \
        -d \
        --description='Arch Linux, a lightweight and flexible Linux' \
        --os-type=linux \
        --boot menu=on \
        --disk path=/var/lib/libvirt/images/archlinux.qcow2,size=8 \
        -c /var/lib/libvirt/isos/archlinux-2011.08.19-core-dual.iso \
        --livecd \
        --graphics vnc,listen=10.10.10.1,port=5902


top

libvirtd PolicyKit


/etc/polkit-1/localauthority/50-local.d/libvirtd.pkla


[Local access to libvirtd to group: kvm]
Identity = unix-group:kvm
Action = org.libvirt.unix.manage
ResultAny = yes
ResultInactive = yes
ResultActive = yes


top


libvirt capabilities


# virsh capabilities


top


interfaces


virsh iface-list
virsh iface-undefine em1
virsh iface-destroy em1


top

auth


unix_sock_group = "kvm"
unix_sock_ro_perms = "0777"
unix_sock_rw_perms = "0770"
unix_sock_dir = "/var/run/libvirt"
auth_unix_ro = "none"
auth_unix_rw = "none"


top


domstate


$ sudo virsh domstate winxp
running

$ sudo virsh domstate f17
shut off