* New version of my kvmctl script @ 2008-06-02 17:29 FinnTux N/A 2008-06-02 18:11 ` Freddie Cash 2008-06-04 9:36 ` Thomas Besser 0 siblings, 2 replies; 15+ messages in thread From: FinnTux N/A @ 2008-06-02 17:29 UTC (permalink / raw) To: kvm For some reason I couldn't reply to my previous post... But here is a new version. Now with version number! :) Changes: - includes init script /etc/initd.d/kvm which starts and stops virtual machines when booting and shutting down the host. Shutting down the guest is done by sending "system_powerdown" to the guest. If the guest doesn't powerdown in 120 seconds (adjustable) it will be killed. - kvmctl can set vm to start or not to start during boot (kvmctl vmname onboot yes|no). Without yes/no script shows whether VM is started on boot or not. Download: http://81.209.59.133/kvmctl-0.0.1.tar.gz ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: New version of my kvmctl script 2008-06-02 17:29 New version of my kvmctl script FinnTux N/A @ 2008-06-02 18:11 ` Freddie Cash 2008-06-02 18:20 ` FinnTux N/A 2008-06-04 9:36 ` Thomas Besser 1 sibling, 1 reply; 15+ messages in thread From: Freddie Cash @ 2008-06-02 18:11 UTC (permalink / raw) To: kvm On June 2, 2008 10:29 am you wrote: > For some reason I couldn't reply to my previous post... > > But here is a new version. Now with version number! :) > > Changes: > - includes init script /etc/initd.d/kvm which starts and stops virtual > machines when booting and shutting down the host. Shutting down the > guest is done by sending "system_powerdown" to the guest. If the guest > doesn't powerdown in 120 seconds (adjustable) it will be killed. You should rename the init script. At least on Debian systems, there's already an /etc/init.d/kvm script that auto-loads the kvm modules. > - kvmctl can set vm to start or not to start during boot (kvmctl > vmname onboot yes|no). Without yes/no script shows whether VM is > started on boot or not. You may want to rename the script. There's already a kvmctl (at least on Debian) in the /usr/sbin directory that is used for testing. I ran into this issue when I named my management script kvmctl, and /usr/sbin is ahead of /usr/local/sbin in the default PATH. -- Freddie Cash fjwcash@gmail.com ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: New version of my kvmctl script 2008-06-02 18:11 ` Freddie Cash @ 2008-06-02 18:20 ` FinnTux N/A 2008-06-02 18:36 ` FinnTux N/A ` (2 more replies) 0 siblings, 3 replies; 15+ messages in thread From: FinnTux N/A @ 2008-06-02 18:20 UTC (permalink / raw) To: kvm 2008/6/2 Freddie Cash <fjwcash@gmail.com>: > You may want to rename the script. There's already a kvmctl (at least on > Debian) in the /usr/sbin directory that is used for testing. It comes with some debian kvm packages? Anyways, I was afraid of these naming issues. kvmctl is pretty generic name. Any suggestions? ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: New version of my kvmctl script 2008-06-02 18:20 ` FinnTux N/A @ 2008-06-02 18:36 ` FinnTux N/A 2008-06-02 18:37 ` Freddie Cash [not found] ` <4863A487.5080706@tmr.com> 2 siblings, 0 replies; 15+ messages in thread From: FinnTux N/A @ 2008-06-02 18:36 UTC (permalink / raw) To: kvm After quick googling I renamed the script/product/whatever to virmactl (VIrtual MAchine ConTroL). Download: http://81.209.59.133/virmactl-0.0.1.tar.gz ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: New version of my kvmctl script 2008-06-02 18:20 ` FinnTux N/A 2008-06-02 18:36 ` FinnTux N/A @ 2008-06-02 18:37 ` Freddie Cash 2008-06-02 23:02 ` Javier Guerra ` (2 more replies) [not found] ` <4863A487.5080706@tmr.com> 2 siblings, 3 replies; 15+ messages in thread From: Freddie Cash @ 2008-06-02 18:37 UTC (permalink / raw) To: kvm On June 2, 2008 11:20 am FinnTux N/A wrote: > 2008/6/2 Freddie Cash <fjwcash@gmail.com>: > > You may want to rename the script. There's already a kvmctl (at > > least on Debian) in the /usr/sbin directory that is used for testing. > > It comes with some debian kvm packages? It's part of the kvm package in Lenny (kvm-60) and Sid (kvm-69). Sorry, it's installed under /usr/bin, not /usr/sbin. Here's the output of --help: # /usr/bin/kvmctl --help Usage: /usr/bin/kvmctl [OPTIONS] [bootstrap] flatfile KVM test harness. -s, --smp=NUM create a VM with NUM virtual CPUs -p, --protected-mode start VM in protected mode -m, --memory=NUM[GMKB] allocate NUM memory for virtual machine. A suffix can be used to change the unit (default: `M') -h, --help display this help screen and exit Report bugs to <kvm-devel@lists.sourceforge.net>. Considering this is a test harness and not a control program, perhaps it should be renamed in the kvm sources/builds, to something more appropriate like kvmtest. > Anyways, I was afraid of these naming issues. kvmctl is pretty generic > name. Any suggestions? I'd prefer to keep the management/control scripts/apps named kvmctl, as that's easier to remember and fits with things like sysctl, apachectl, brctl, and other similar apps. -- Freddie Cash fjwcash@gmail.com ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: New version of my kvmctl script 2008-06-02 18:37 ` Freddie Cash @ 2008-06-02 23:02 ` Javier Guerra 2008-06-03 17:05 ` Javier Guerra 2008-06-04 9:41 ` Thomas Besser 2008-06-04 10:38 ` Avi Kivity 2 siblings, 1 reply; 15+ messages in thread From: Javier Guerra @ 2008-06-02 23:02 UTC (permalink / raw) To: Freddie Cash; +Cc: kvm i got it running under non-root. first, i used to have a group 'kvm', and /dev/net/tun is writable by this group. so, i made the 'temp' directories (/var/run/kvmctl/, and a couple extra) also writable by the same group. then, i added a couple calls to "tunctl" to pre-create the tap device before running kvm. i also added a "sdl" option to the "start" command, it simply removes the VNC parameters from the startup line. as i feel VNC is too clumsy for a workstation, but i think it should be an 'ephemeral' option, not for the config file. i'll post my diffs tomorrow, i have to run now. -- Javier ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: New version of my kvmctl script 2008-06-02 23:02 ` Javier Guerra @ 2008-06-03 17:05 ` Javier Guerra 0 siblings, 0 replies; 15+ messages in thread From: Javier Guerra @ 2008-06-03 17:05 UTC (permalink / raw) To: Freddie Cash; +Cc: kvm [-- Attachment #1: Type: text/plain, Size: 69 bytes --] as promised, here's my patch against your first version. -- Javier [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: kvmctl.patch --] [-- Type: text/x-diff; name=kvmctl.patch, Size: 1994 bytes --] --- usr/local/sbin/kvmctl 2008-05-31 18:03:14.000000000 -0500 +++ /usr/local/sbin/kvmctl 2008-06-03 12:05:11.000000000 -0500 @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Script for controlling kvm (kernel-based virtual machine) # (c) finntux@gmail.com # @@ -149,7 +149,15 @@ } - +function addtun +{ + ifconfig "$1" > /dev/null 2>&1 + if [ "$?" = "0" ]; then + tunctl -d "$1" + fi + USERID=$(whoami) + sudo tunctl -b -u "$USERID" -t "$1" +} function usage { @@ -195,7 +203,11 @@ fi - HDPARM=" -drive file=$HDA,if=$DISKMODEL,boot=on" + if [ "$DISKMODEL" == "ide" ]; then + HDPARM=" -hda $HDA" + else + HDPARM=" -drive file=$HDA,if=$DISKMODEL,boot=on" + fi } @@ -216,7 +228,7 @@ function getvnc { VNC=`grep ^"$1 " $globalconf | awk {'print $2'}` - if [ -z $VNC ] || [ x$VNC == "x-" ];then + if [ -z "$VNC" ] || [ "x$VNC" == "x-" ]; then vf=$rundir/$1.vnc if [ -f $vf ];then VNC=`cat $rundir/$1.vnc` @@ -370,8 +382,15 @@ if ! isrunning $name;then createhdparm $DISKMODEL shift 2 + addtun "$IFNAME" + if [ "$1" == "sdl" ]; then + shift + SCREEN="" + else + SCREEN=" -vnc :$VNC" + fi - nice -n $NICE $IONICEBIN -n $IONICE $TASKSET -c $CPULIST /usr/local/bin/qemu-system-x86_64 -std-vga -cpu $CPU -k $KEYBOARD -localtime -name $name -usbdevice tablet -smp $SMP -m $MEM -vnc :$VNC $HDPARM -net nic,macaddr=$MACADDR,model=$NICMODEL -net tap,ifname=$IFNAME -daemonize -pidfile $pidfile -monitor unix:$monfile,server,nowait $EXTRAPARM $* > $logfile 2>&1 + nice -n $NICE $IONICEBIN -n $IONICE $TASKSET -c $CPULIST /usr/local/bin/qemu-system-x86_64 -cpu $CPU -k $KEYBOARD -localtime -name $name -usbdevice tablet -smp $SMP -m $MEM $SCREEN $HDPARM -net nic,macaddr=$MACADDR,model=$NICMODEL -net tap,ifname=$IFNAME -daemonize -pidfile $pidfile -monitor unix:$monfile,server,nowait $EXTRAPARM $* > $logfile 2>&1 if [ $? -eq 0 ];then pid=`cat $pidfile` #renice $NICE -p $pid > /dev/null 2>&1 ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: New version of my kvmctl script 2008-06-02 18:37 ` Freddie Cash 2008-06-02 23:02 ` Javier Guerra @ 2008-06-04 9:41 ` Thomas Besser 2008-06-04 10:38 ` Avi Kivity 2 siblings, 0 replies; 15+ messages in thread From: Thomas Besser @ 2008-06-04 9:41 UTC (permalink / raw) To: kvm Freddie Cash wrote: > On June 2, 2008 11:20 am FinnTux N/A wrote: >> 2008/6/2 Freddie Cash <fjwcash@gmail.com>: > Considering this is a test harness and not a control program, perhaps it > should be renamed in the kvm sources/builds, to something more > appropriate like kvmtest. > >> Anyways, I was afraid of these naming issues. kvmctl is pretty generic >> name. Any suggestions? > > I'd prefer to keep the management/control scripts/apps named kvmctl, as > that's easier to remember and fits with things like sysctl, apachectl, > brctl, and other similar apps. Full ACK from me! I would also prefer, that 'kvmctl' is really for controlling kvm virtual machines. Should we make a bug report to package 'kvm'? Regards Thomas ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: New version of my kvmctl script 2008-06-02 18:37 ` Freddie Cash 2008-06-02 23:02 ` Javier Guerra 2008-06-04 9:41 ` Thomas Besser @ 2008-06-04 10:38 ` Avi Kivity 2 siblings, 0 replies; 15+ messages in thread From: Avi Kivity @ 2008-06-04 10:38 UTC (permalink / raw) To: Freddie Cash; +Cc: kvm Freddie Cash wrote: > Considering this is a test harness and not a control program, perhaps it > should be renamed in the kvm sources/builds, to something more > appropriate like kvmtest. > > Sure, patches welcome. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain. ^ permalink raw reply [flat|nested] 15+ messages in thread
[parent not found: <4863A487.5080706@tmr.com>]
* Re: New version of my kvmctl script [not found] ` <4863A487.5080706@tmr.com> @ 2008-07-24 19:57 ` FinnTux 2008-09-07 21:41 ` FinnTux 0 siblings, 1 reply; 15+ messages in thread From: FinnTux @ 2008-07-24 19:57 UTC (permalink / raw) To: kvm > Let debian get out of your way, rather than using a non-intuitive name for > the script. Good stuff, keep it coming. These encouraging words made me rename it back to kvmctl and so here comes a new version. It works (for me) without root privileges now. Lot's of minor fixes and improvements too. See it for youself. Download: http://81.209.59.133/kvmctl-0.1.0.tar.gz ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: New version of my kvmctl script 2008-07-24 19:57 ` FinnTux @ 2008-09-07 21:41 ` FinnTux 2008-09-07 21:51 ` FinnTux 0 siblings, 1 reply; 15+ messages in thread From: FinnTux @ 2008-09-07 21:41 UTC (permalink / raw) To: kvm New, much improved version available. This pretty much a total rewrite and lots of planned functions/commands are still missing but give it a try. New features - Support for multiple hard disks (see /etc/kvmctl/cfg/example.cfg) - Support for multiple NICs (see /etc/kvmctl/cfg/example.cfg) - Soundhw support (currently hard coded to es1370) - Check VM settings with 'kvmctl vmname details' ('kvmctl list' for overview) Plans: - Handle CPU affinity, nice and ionice levels better so that root can control them in vm.conf (only root can set negative nice level - Add monitor commands (change CD, manage USB devices etc) - Automatically restart VM after crash (configurable) ------------------- Installation instructions that work on debian. Other distributions should work with minor changes. 1. Install KVM 2. Download and untar kvmctl package - cd / ; tar xzvf kvmctl-<version>.tar.gz 3. Install needed utilities - sudo (sudo) - brctl (bridge-utils) - socat (socat) - tunctl (uml-utilities) - ionice (util-linux) - nice (coreutils) - taskset (util-linux) - Your prefered text editor. Define in /etc/kvmctl/global.conf 4. Create group kvm and add users who should be able to control VMs - usermod -a -G kvm <username> 5. Set /dev/kvm permissions - /etc/udev/rules.d/91-permissions.rules -> KERNEL=="kvm", GROUP="kvm" 6. Create group kvm (use gid if possible 117) Following files/directories must be owned by group kvm /var/run/kvmctl (must be writable) /var/log/kvmctl (must be writable) /usr/local/bin/kvmctl (executable) /etc/qemu-ifup (executable) /etc/qemu-ifdown (executable) /etc/kvmctl (readable) /etc/kvmctl/cfg (writable) /etc/kvmctl/startup (writable) 7. Set up sudo - install sudo - edit /etc/sudoers Cmnd_Alias KVM=/sbin/ifconfig,/usr/sbin/brctl,/usr/sbin/tunctl %kvm ALL=NOPASSWD: KVM 8. Use /etc/kvmctl/cfg/example.cfg as a template for new VMs 9. Set up network interfaces (bridges). /etc/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 auto vbr1 iface vbr1 inet static ... ... 10. Make /etc/init.d/kvm run automatically update-rc.d kvm defaults (as root) ------------------- Download link http://81.209.59.200/kvmctl-0.2.0.tar.gz ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: New version of my kvmctl script 2008-09-07 21:41 ` FinnTux @ 2008-09-07 21:51 ` FinnTux 2008-09-10 14:04 ` Marshal Newrock 0 siblings, 1 reply; 15+ messages in thread From: FinnTux @ 2008-09-07 21:51 UTC (permalink / raw) To: kvm ...and of course I forgot to mention few known issues there are. - init script is not working correctly. Starts VM as root -> normal user can't control it after that - init script should also check that VM is set to use vnc for display. SDL won't work. - File/directory permissions might need fine tuning. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: New version of my kvmctl script 2008-09-07 21:51 ` FinnTux @ 2008-09-10 14:04 ` Marshal Newrock 2009-01-20 18:20 ` FinnTux 0 siblings, 1 reply; 15+ messages in thread From: Marshal Newrock @ 2008-09-10 14:04 UTC (permalink / raw) To: kvm [-- Attachment #1: Type: text/plain, Size: 782 bytes --] First, I'd suggest changing the name of the init script from kvm to kvmctl. On some platforms, installing the kvm package will include a kvm init script which loads the modules. I've also been working on an init script, based off some other efforts that I've seen. It is written in python. From the Readme: This is a script to start, stop, and otherwise manage KVM machines. It is written on Ubuntu 8.04 (Hardy), with the goal of managing machines in a VPS hosting environment. As such, it does not support the full capabilities of KVM. Full readme at: https://central.freedombi.com/svn/kvm-control/README Download with subversion from https://central.freedombi.com/svn/kvm-control/ -- Marshal Newrock FreedomBI, LLC - http://www.freedombi.com [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 197 bytes --] ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: New version of my kvmctl script 2008-09-10 14:04 ` Marshal Newrock @ 2009-01-20 18:20 ` FinnTux 0 siblings, 0 replies; 15+ messages in thread From: FinnTux @ 2009-01-20 18:20 UTC (permalink / raw) To: kvm 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 ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: New version of my kvmctl script 2008-06-02 17:29 New version of my kvmctl script FinnTux N/A 2008-06-02 18:11 ` Freddie Cash @ 2008-06-04 9:36 ` Thomas Besser 1 sibling, 0 replies; 15+ messages in thread From: Thomas Besser @ 2008-06-04 9:36 UTC (permalink / raw) To: kvm FinnTux N/A wrote: > But here is a new version. Now with version number! :) > > Changes: > - includes init script /etc/initd.d/kvm which starts and stops virtual > machines when booting and shutting down the host. Shutting down the > guest is done by sending "system_powerdown" to the guest. If the guest > doesn't powerdown in 120 seconds (adjustable) it will be killed. > - kvmctl can set vm to start or not to start during boot (kvmctl > vmname onboot yes|no). Without yes/no script shows whether VM is > started on boot or not. Great! I planned to make my own start/stop scripts. Now I will use yours and perhaps help to improve them. Regards Thomas ^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2009-01-20 18:20 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-02 17:29 New version of my kvmctl script FinnTux N/A
2008-06-02 18:11 ` Freddie Cash
2008-06-02 18:20 ` FinnTux N/A
2008-06-02 18:36 ` FinnTux N/A
2008-06-02 18:37 ` Freddie Cash
2008-06-02 23:02 ` Javier Guerra
2008-06-03 17:05 ` Javier Guerra
2008-06-04 9:41 ` Thomas Besser
2008-06-04 10:38 ` Avi Kivity
[not found] ` <4863A487.5080706@tmr.com>
2008-07-24 19:57 ` FinnTux
2008-09-07 21:41 ` FinnTux
2008-09-07 21:51 ` FinnTux
2008-09-10 14:04 ` Marshal Newrock
2009-01-20 18:20 ` FinnTux
2008-06-04 9:36 ` Thomas Besser
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox