New version. Lots of small improvements and couple of new features.
- Ability to change CD for virtual machine
- Ability to add and remove USB devices to virtual machines
- Init script (in /usr/local/share/doc/kvmctl/kvmctl.init) to start
and stop virtual machines
during boot/shutdown
Installation instructions:
-----------------------------
. Install KVM
. Download and untar kvmctl package
- cd / ; tar xzvf kvmctl-<version>.tar.gz
. Install needed utilities
- sudo (sudo)
- brctl (bridge-utils)
- socat (socat)
- tunctl (uml-utilities)
- ionice (util-linux)
- nice (coreutils)
- taskset (util-linux)
- $EDITOR
. Create group kvm and add users who should be able to control VMs
- usermod -a -G kvm <username>
. Set /dev/kvm permissions
- /etc/udev/rules.d/91-permissions.rules -> KERNEL=="kvm",
GROUP="kvm"
. To be able to use USB devices edit /etc/rcS.d/S02mountkernfs.sh
Change line
domount usbfs usbdevfs /proc/bus/usb usbfs -onodev,noexec,nosuid
to
domount usbfs usbdevfs /proc/bus/usb usbfs -
nodev,noexec,nosuid,devmode=0660,devgid=117
(117 is gid of the kvm group)
. Create group kvm (gid 117 in package)
. If kvm gid != 117 ->
chgrp kvm /usr/local/bin /var/log/kvmctl /var/run/kvmctl
/etc/qemu-ifup /etc/qemu-ifdown
chgrp kvm /etc/kvmctl /etc/kvmctl/cfg
. Set up sudo
- install sudo
- edit /etc/sudoers
Cmnd_Alias
KVM=/sbin/ifconfig,/usr/sbin/brctl,/usr/sbin/tunctl
%kvm ALL=NOPASSWD: KVM
. Use /etc/kvmctl/cfg/example.cfg as a template for new VMs
. Set up network interfaces
auto eth0
iface eth0 inet manual
auto br0
iface br0 inet static
address 192.168.0.1
network 192.168.0.0
netmask 255.255.255.0
broadcast 192.168.0.255
gateway 192.168.0.1
bridge_ports eth0
bridge_fd 9
bridge_hello 2
bridge_maxage 10
bridge_stp off
auto vbr0
iface vbr0 inet static
address 192.168.1.1
netmask 255.255.255.0
bridge_ports none
bridge_fd 9
bridge_hello 2
bridge_maxage 12
bridge_stp off
Usage
-----
- Start a virtual machine
$ kvmctl vmname start
- Shutdown a virtual machine
$ kvmctl vmname powerdown
If guest doesn't power down in 30 seconds (configurable) it will be killed
- Show details of a virtual machine
$kvmctl vmname details
- List all defined virtual machines and their status
$ kvmctl list
- List all running virtual machines
$ kvmctl list onlyrunning
- Show info about host USB devices
$ kvmctl vmname hostusb
- Add USB device to guest
$ kvmctl vmname addusb 058f:6610
- Remove same USB device
$ kvmctl vmname delusb 058f:6610
- Set a virtual machine to start during boot
$ kvmctl vmname onboot yes
Warning is displayed if virtual machine is defined to use SDL display
- Check if virtual machine is started during boot
$ kvmctl vmname onboot
- Set a virtual machine not to start during boot
$ kvmctl vmname onboot no
- Print some info of the host every 10 seconds
$ kvmctl monhost 10
If interval is omitted default value of 30 seconds is used
- Change CD of the virtual machine
$ kvmctl chcd /path/to/my/iso/image.img
Configration files
------------------
/etc/kvmctl/vm.conf
This file is used by root (or anyone who has write access) to list and
manage index numbers (VNC numbers). Also nice levels and CPU affinity
are defined here.
/etc/kvmctl/global.conf
Path defines go here
/etc/kvmctl/cfg/*
Configuration files of the virtual machines. See example.cfg for instructions.
Utility scripts
---------------
/usr/local/bin/kvmctledit
Is used to edit vm.conf. Simply starts $EDITOR.
/usr/local/bin/kvmctl_fixperm
Scans all config files for disk images and makes sure they are
writable by kvm group. Works for files, lvm volumes and iSCSI volumes.
/usr/local/share/doc/kvmctl/kvmctl.init
Init script that can be copied to /etc/init.d. Manages virtual
machines starting and stopping automatically during boot.
Few notes
---------
- Make sure you have configuration for each virtual machine defined in vm.conf
- Edit /etc/qemu-ifup and make sure it uses same bridge names your system has
- Don't use tabulator after virtual machine name in vm.conf
Thats about it. Give it a try and let me know if you find it helpful.
Most likely there are bugs but it works pretty well for me. If it
breaks something it is very unfortunate but you're the only one to
blame :)
Download http://81.209.59.200/kvmctl-0.3.0.tar.gz
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html