ia64/xen-unstable

changeset 19566:c7d2f046aa29

stubdoms: generate stubdom config file

This patch removes the need for a second configuration file for
stubdoms: it is going to be automatically generated by the script
stubdom-dm using command line options and xenstore to find any needed
information.
The configuration script will be placed under /etc/xen/stubdoms and
automatically removed when the domain is destroyed.
The only change needed in xend is not to write on xenstore sdl,
opengl and serial command line options for qemu, because stubdoms do
not support them.
It is safe to remove those two options from xenstore because qemu does
not use xenstore to read commans line options.
Finally this patch fixes blkfront disconnections from backends and
display and xauthority variables for pv guests.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Apr 23 10:08:04 2009 +0100 (2009-04-23)
parents 1afc1ded0ed7
children cd92432a7af4
files extras/mini-os/blkfront.c stubdom/stubdom-dm tools/python/xen/xend/image.py
line diff
     1.1 --- a/extras/mini-os/blkfront.c	Wed Apr 22 13:46:50 2009 +0100
     1.2 +++ b/extras/mini-os/blkfront.c	Thu Apr 23 10:08:04 2009 +0100
     1.3 @@ -244,10 +244,6 @@ void shutdown_blkfront(struct blkfront_d
     1.4      xenbus_wait_for_value(path, "5", &dev->events);
     1.5  
     1.6      err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 6);
     1.7 -    xenbus_wait_for_value(path, "6", &dev->events);
     1.8 -
     1.9 -    err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 1);
    1.10 -    xenbus_wait_for_value(path, "2", &dev->events);
    1.11  
    1.12      xenbus_unwatch_path(XBT_NIL, path);
    1.13  
     2.1 --- a/stubdom/stubdom-dm	Wed Apr 22 13:46:50 2009 +0100
     2.2 +++ b/stubdom/stubdom-dm	Thu Apr 23 10:08:04 2009 +0100
     2.3 @@ -15,7 +15,10 @@ domname=
     2.4  vncviewer=0
     2.5  vncpid=
     2.6  extra=
     2.7 -videoram=4
     2.8 +sdl=0
     2.9 +opengl=1
    2.10 +vnc=0
    2.11 +vncunused=0
    2.12  while [ "$#" -gt 0 ];
    2.13  do
    2.14      if [ "$#" -ge 2 ];
    2.15 @@ -31,22 +34,30 @@ do
    2.16                  shift
    2.17                  ;;
    2.18  	    -vnc)
    2.19 -		ip=${2%:*};
    2.20 -		vnc_port=${2#*:};
    2.21 +                vnc=1
    2.22 +                op=${2%,*}
    2.23 +		ip=${op%:*};
    2.24 +		vnc_port=${op#*:};
    2.25  		shift
    2.26  		;;
    2.27 +            -vncunused)
    2.28 +                vncunused=1
    2.29 +                shift
    2.30 +                ;;
    2.31              -loadvm)
    2.32                  extra="$extra -loadvm $2";
    2.33                  shift
    2.34                  ;;
    2.35 -	    -videoram)
    2.36 -	        videoram="$2"
    2.37 -		shift
    2.38 -		;;
    2.39 +            -k)
    2.40 +                keymap=$2
    2.41 +                shift
    2.42 +                ;;
    2.43  	esac
    2.44      fi
    2.45      case "$1" in
    2.46  	-vncviewer) vncviewer=1 ;;
    2.47 +        -sdl) sdl=1 ;;
    2.48 +        -disable-opengl) opengl=0 ;;
    2.49      esac
    2.50      shift
    2.51  done
    2.52 @@ -61,7 +72,7 @@ term() {
    2.53      (
    2.54  	[ -n "$vncpid" ] && kill -9 $vncpid
    2.55  	xm destroy $domname-dm
    2.56 -	#xm destroy $domname
    2.57 +        rm /etc/xen/stubdoms/$domname-dm
    2.58      ) &
    2.59      # We need to exit immediately so as to let xend do the commands above
    2.60      exit 0
    2.61 @@ -77,7 +88,58 @@ do
    2.62  	sleep 1
    2.63  done
    2.64  
    2.65 -creation="xm create -c $domname-dm target=$domid memory=32 videoram=$videoram extra=\"$extra\""
    2.66 +# Generate stubdom config file
    2.67 +mkdir -p /etc/xen/stubdoms &>/dev/null
    2.68 +echo "#This file is autogenerated, edit $domname instead!" > /etc/xen/stubdoms/$domname-dm
    2.69 +echo "kernel = '/usr/lib/xen/boot/ioemu-stubdom.gz'" >> /etc/xen/stubdoms/$domname-dm
    2.70 +
    2.71 +vfb="sdl=$sdl, opengl=$opengl"
    2.72 +test "$DISPLAY" && vfb="$vfb, display=$DISPLAY"
    2.73 +test "$XAUTHORITY" && vfb="$vfb, xauthority=$XAUTHORITY"
    2.74 +test $vnc != 0 && vfb="$vfb, vnc=$vnc, vncdisplay=$vnc_port, vnclisten=$ip, vncunused=$vncunused"
    2.75 +vncpasswd=`xenstore-read /local/domain/0/backend/vfb/$domid/0/vncpasswd 2>/dev/null`
    2.76 +test "$vncpasswd" && vfb="$vfb, vncpasswd=$vncpasswd"
    2.77 +test "$keymap" && vfb="$vfb, keymap=$keymap"
    2.78 +echo "vfb = ['$vfb']" >> /etc/xen/stubdoms/$domname-dm
    2.79 +
    2.80 +echo -n "disk = [ " >> /etc/xen/stubdoms/$domname-dm
    2.81 +j=0
    2.82 +for i in `xenstore-ls /local/domain/$domid/device/vbd | grep 'backend =' | awk '{print $3}'`
    2.83 +do
    2.84 +    i=${i%\"}
    2.85 +    i=${i#\"}
    2.86 +    vbd_mode=`xenstore-read $i/mode`
    2.87 +    vbd_disk=`xenstore-read $i/params`
    2.88 +    vbd_type=`xenstore-read $i/type`
    2.89 +    vbd_dev=`xenstore-read $i/dev`
    2.90 +    if [ $vbd_type = "file" ]
    2.91 +    then
    2.92 +        vbd_type="tap:aio"
    2.93 +    fi
    2.94 +    if [ $j -ne 0 ]
    2.95 +    then
    2.96 +        echo -n "," >> /etc/xen/stubdoms/$domname-dm
    2.97 +    fi
    2.98 +    echo -n "'$vbd_type:$vbd_disk,$vbd_dev,$vbd_mode'" >> /etc/xen/stubdoms/$domname-dm
    2.99 +    j=$(( $j + 1 ))
   2.100 +done
   2.101 +echo " ] " >> /etc/xen/stubdoms/$domname-dm
   2.102 +echo -n "vif = [ " >> /etc/xen/stubdoms/$domname-dm
   2.103 +j=0
   2.104 +for i in `xenstore-ls /local/domain/$domid/device/vif | grep 'backend =' | awk '{print $3}'`
   2.105 +do
   2.106 +    i=${i%\"}
   2.107 +    i=${i#\"}
   2.108 +    vif_mac=`xenstore-read $i/mac`
   2.109 +    if [ $j -ne 0 ]
   2.110 +    then
   2.111 +        echo -n "," >> /etc/xen/stubdoms/$domname-dm
   2.112 +    fi
   2.113 +    echo -n "'mac=$vif_mac'" >> /etc/xen/stubdoms/$domname-dm
   2.114 +    j=$(( $j + 1 ))
   2.115 +done
   2.116 +echo " ] " >> /etc/xen/stubdoms/$domname-dm
   2.117 +creation="xm create -c /etc/xen/stubdoms/$domname-dm target=$domid memory=32 extra=\"$extra\""
   2.118  
   2.119  (while true ; do sleep 60 ; done) | /bin/sh -c "$creation" &
   2.120  #xterm -geometry +0+0 -e /bin/sh -c "$creation ; echo ; echo press ENTER to shut down ; read" &
     3.1 --- a/tools/python/xen/xend/image.py	Wed Apr 22 13:46:50 2009 +0100
     3.2 +++ b/tools/python/xen/xend/image.py	Thu Apr 23 10:08:04 2009 +0100
     3.3 @@ -729,7 +729,12 @@ class HVMImageHandler(ImageHandler):
     3.4  
     3.5          if not self.display :
     3.6              self.display = ''
     3.7 -        self.vm.storeVm(("image/dmargs", " ".join(self.dmargs)),
     3.8 +        # Do not store sdl, opengl and serial related qemu cli options
     3.9 +        self.vm.storeVm(("image/dmargs", " ".join([ x for x in self.dmargs
    3.10 +                        if x != "-sdl"
    3.11 +                        and x != "-disable-opengl"
    3.12 +                        and x != "-serial"
    3.13 +                        and x != "pty" ])),
    3.14                          ("image/device-model", self.device_model),
    3.15                          ("image/display", self.display))
    3.16          self.vm.permissionsVm("image/dmargs", { 'dom': self.vm.getDomid(), 'read': True } )