hv — kvm virtualization swiss knife (requires kvm-admin)

Author: nme · Saturday, 12 February, 2011 · No comments ·

Kvm is currently one of best choices for virtualization under GNU Linux operating systems. It is fast and stable. No wonder there are many frontend utilities that handles it.

RedHat Enterprise Linux and Ubuntu Server Linux are both suggesting to relay on libvirt, but whenever I try to use that I always finish with "It is not good enough yet", "new features come, old bugs still exist" etc. As I suppose — it will never be good enough. The reason is the libvirt layer which completly separates system administrator from kvm console.

In opposition to libvirt — we can use kvm and qemu tools, but sooner or later we will start to look after another toolkit to make life easier. I found mine — kvmtools — it is slick, lightweight, written in Python language and offers possibility to perform most tasks using single command. It is really great, but... I don't like kvm-admin command syntax. That is why I created hv — simple bash script that makes kvm-admin more friendly — especially — for (former) virsh users.

Mercurial repository for hv util is available here.
You can download it using the following command: hg clone http://nme.pl/pub/repos/hv
hv
Usage:
hv (list|running) hv (boot|bootp|reboot|kill) domain-name (bootp = boot domain-name, but keep it in paused state) hv (vnc|vncinfo) domain-name hv serial domain-name hv monitor domain-name qemu-monitor-command hv (pause|cont|status) domain-name hv edit domain-name hv snapshots domain-name hv (savevm|loadvm|delvm|bootvm) domain-name snapshot-name hv shutdown domain-name hv verify hv example-domain
Commands might be shortened, eg. hv li

What does hv offer?

List of all commands with examples, like mentioned in hv usage above — it is possible to shorten commands, as long as they are unambiguous. hv offers as much syntatic sweetness as I could figure out ;)

More verbose help:

hv listlist all available virtual machines.
hv runninglist running virtual machines.
hv boot domain-namestart given virtual machine.
hv bootp domain-namestart given virtual machine in a paused state.
hv reboot domain-namewarm reboot virtual machine.
hv kill domain-namepower off virtual machine.
hv vnc domain-nameconnect vncviewer with virtual machine (and keep it turning on when it disconnects — in case of resolution change etc, ^C breakable).
hv vncinfo domain-namereturn vnc listen ip:port.
hv serial domain-nameconnect to serial tty of virtual machine.
hv monitor domain-name qemu-monitor-commandkvm monitor interface — if no monitor-command is given, issuing help command will be suggested.
hv pause domain-namefreeze virtual machine.
hv cont domain-namecontinue feezed virtual machine.
hv status domain-namevirtual machine status.
hv edit domain-namesame as vim /etc/kvm/domain/name.
hv snapshots domain-namelist current virtual-machine snapshots.
hv savevm domain-name snapshot-namecreate snapshot for virtual-machine
hv loadvm domain-name snapshot-nameapply (load) snapshot for virtual-machine
hv delvm domain-name snapshot-namedelete snapshot
hv bootvm domain-name snapshot-nameboot domain and apply (load) snapshot
hv shutdown domain-namegracefully shutdown virtual machine (requires acpid / acpi support on virtual-machine).
hv verifysimplifies manual check of all virtual machines configuration — disks, mac addresses, tap interfaces and vnc ports.
hv example-domainbootstrap configuration of virtual machine, eg. hv example >/etc/kvm/domain/new-vm

Feedback?

As usual — every opinion and suggestion is appreciated!

Leave a comment