]> gitweb.fluxo.info Git - kvm-manager.git/commitdiff
control the guest if signals are sent to the parent shell
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Fri, 11 Feb 2011 03:11:16 +0000 (22:11 -0500)
committerDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Fri, 11 Feb 2011 04:59:30 +0000 (23:59 -0500)
README
kvm-manager

diff --git a/README b/README
index 8a72befd210467e7ccacfec5a34e9a0613909b72..1ef51f6ceabcac4b882aab74541e8e233adaa680 100644 (file)
--- a/README
+++ b/README
@@ -18,13 +18,13 @@ Dependencies:
  runit : for system supervision
  uml-utilities : for tunctl for the tun/tap interface
  kvm : for the virtual machine emulator
+ socat : For communications with the monitor and console of guests
  screen : for the detached, logged serial console
  bridge-utils : for configuring a bridge device
  lvm2 : for creating the relevant block devices
  udev : for configuring the block devices with proper permissions
  fakeroot : for rebuilding the initramfs as a regular user in di-maker
  xorriso : for grub2 to make an iso in di-maker
- socat : so users can talk to the kvm monitor of their VMs
 
 Recommendations:
 
@@ -34,7 +34,7 @@ INSTALLATION
 
  * Install dependencies:
 
-   apt-get install runit uml-utilities kvm screen bridge-utils lvm2 udev
+   apt-get install runit uml-utilities kvm screen bridge-utils lvm2 udev socat
 
    If you want to be able to use di-maker, you'll also need:
 
index b1f260caf045ff160106cb3570e85ddccd2fa642..be3db9f872962c08fe8739d34349fb24b729aeea 100755 (executable)
@@ -58,8 +58,16 @@ up() {
     if [ -e "$LOGNAME" ] ; then
        chpst -u "$OWNER" mv "$LOGNAME" "$LOGNAME".$(date +%F_%T%z|tr : .)
     fi
+    
+    MONITORNAME="$OWNERHOME/vms/$VMNAME/monitor.socket"
+
+    kvmsend() {
+        socat STDIO "UNIX:$MONITORNAME" <<EOF
+$1
+EOF
+    }
 
-    exec chpst -u "$OWNER:$OWNERGROUP:kvm" \
+    chpst -u "$OWNER:$OWNERGROUP:kvm" \
         /usr/bin/kvm $KVMARGS \
         -M "${MACHINE:-pc}" \
         -enable-kvm \
@@ -68,14 +76,26 @@ up() {
         -name "$VMNAME" \
         -m "$RAM" \
         -boot "$BOOTCHOICE" \
-        -chardev "socket,id=monitor,path=$OWNERHOME/vms/$VMNAME/monitor.socket,server,nowait" -mon chardev=monitor,mode=readline \
+        -chardev "socket,id=monitor,path=$MONITORNAME,server,nowait" -mon chardev=monitor,mode=readline \
         -rtc base=utc \
         -usb \
         -device virtio-balloon-pci,id=balloon0,bus=pci.0 \
         -chardev "socket,id=serial0,path=$OWNERHOME/vms/$VMNAME/console.socket,server,nowait" -device isa-serial,chardev=serial0 \
         -smp "${SMP:-1},maxcpus=${MAXCPUS:-8}" \
         -device "virtio-net-pci,vlan=0,id=net0,mac=$MAC,bus=pci.0" \
-        -net "tap,ifname=$TAP,script=no,downscript=no,vlan=0,name=hostnet0"
+        -net "tap,ifname=$TAP,script=no,downscript=no,vlan=0,name=hostnet0" &
+
+    set +e
+    # handle regular signals
+    trap 'kvmsend system_reset; wait' HUP
+    trap 'kvmsend system_powerdown; wait' TERM
+    trap 'kvmsend cont; wait' CONT
+ # use SIGINT instead of SIGSTOP for freezing the guest because
+ # trapping SIGSTOP is undefined:
+ # http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_28
+    trap 'kvmsend stop; wait' INT
+
+    wait
 }