ia64/xen-unstable

changeset 5096:3f6a8dd4050a

bitkeeper revision 1.1515.1.1 (42922641RfGxKY5iamyIb3lRFjlpzQ)

better support for vnc in qemu device model:
- different ports for different VMs
- allow reverse connect to a running viewer

Signed-off-by: Rolf Neugebauer <rolf.neugebauer@intel.com>
author rneugeba@wyvis.research.intel-research.net
date Mon May 23 18:51:45 2005 +0000 (2005-05-23)
parents 53d5ba4a4aed
children a33909b1daaf
files BitKeeper/etc/ignore tools/ioemu/Makefile tools/ioemu/target-i386-dm/Makefile tools/ioemu/target-i386-dm/device-model tools/ioemu/vl.c tools/ioemu/vl.h tools/ioemu/vnc.c tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xm/create.py
line diff
     1.1 --- a/BitKeeper/etc/ignore	Mon May 23 18:17:51 2005 +0000
     1.2 +++ b/BitKeeper/etc/ignore	Mon May 23 18:51:45 2005 +0000
     1.3 @@ -149,3 +149,4 @@ xen/tools/figlet/figlet
     1.4  xen/xen
     1.5  xen/xen-syms
     1.6  xen/xen.*
     1.7 +Makefile.rej
     2.1 --- a/tools/ioemu/Makefile	Mon May 23 18:17:51 2005 +0000
     2.2 +++ b/tools/ioemu/Makefile	Mon May 23 18:51:45 2005 +0000
     2.3 @@ -42,7 +42,7 @@ distclean: clean
     2.4  	rm -f config-host.mak config-host.h
     2.5  	rm -f keysym_adapter_sdl.h keysym_adapter_vnc.h
     2.6  	for d in $(TARGET_DIRS); do \
     2.7 -	rm -rf $$d || exit 1 ; \
     2.8 +	$(MAKE) -C $$d $@ || exit 1 ; \
     2.9          done
    2.10  
    2.11  KEYMAPS=da     en-gb  et  fr     fr-ch  is  lt  modifiers  no  pt-br  sv \
     3.1 --- a/tools/ioemu/target-i386-dm/Makefile	Mon May 23 18:17:51 2005 +0000
     3.2 +++ b/tools/ioemu/target-i386-dm/Makefile	Mon May 23 18:51:45 2005 +0000
     3.3 @@ -378,6 +378,9 @@ mixeng.o: mixeng.c mixeng.h mixeng_templ
     3.4  clean:
     3.5  	rm -rf *.o  *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe slirp qemu-vgaram-bin
     3.6  
     3.7 +distclean:
     3.8 +	rm -rf *.o  *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe slirp qemu-vgaram-bin
     3.9 +
    3.10  install: all 
    3.11  	if [ ! -d $(DESTDIR)$(bindir) ];then mkdir -p $(DESTDIR)$(bindir);fi
    3.12  	if [ ! -d $(DESTDIR)$(configdir) ];then mkdir -p $(DESTDIR)$(configdir);fi
     4.1 --- a/tools/ioemu/target-i386-dm/device-model	Mon May 23 18:17:51 2005 +0000
     4.2 +++ b/tools/ioemu/target-i386-dm/device-model	Mon May 23 18:51:45 2005 +0000
     4.3 @@ -10,13 +10,22 @@ ulimit -c unlimited
     4.4  #gdb --args /usr/sbin/qemu-dm -hda /var/images/qemu-linux.img -nographic \
     4.5  #	-serial pty -l 'ioport,int' $*
     4.6  
     4.7 -while getopts ":f:" opt;
     4.8 +# XXX this is a bit skanky. we assume an order of arguments here.
     4.9 +# namely to have configfile and vncconnect argument as the first 
    4.10 +# two arguments.
    4.11 +
    4.12 +while getopts ":f:v:d:" opt;
    4.13  do
    4.14      case $opt in
    4.15 -      f) QEMUCONFIGFILE=$OPTARG;shift;shift;;
    4.16 +      f) QEMUCONFIGFILE=$OPTARG;;
    4.17 +      v) VNCCONNECT=$OPTARG;;
    4.18 +      d) DOMAIN=$OPTARG;;
    4.19        \?) echo;;
    4.20      esac
    4.21  done
    4.22 +if [ "x$QEMUCONFIGFILE" != "x" ]; then shift; shift; fi
    4.23 +if [ "x$VNCCONNECT" != "x" ]; then shift; shift; fi
    4.24 +
    4.25  
    4.26  echo $QEMUCONFIGFILE
    4.27  if [ ! -z $QEMUCONFIGFILE ];then
    4.28 @@ -57,6 +66,11 @@ if qemu-dm 2>&1 |grep vnc > /dev/null;th
    4.29  	elif [ $vnc -eq 1 ];then
    4.30  		PARMETER="$PARMETER -vnc -k en-us"
    4.31  	fi
    4.32 +    VNCPORT=`expr 5900 + $DOMAIN`
    4.33 +    PARMETER="$PARMETER -vncport $VNCPORT"
    4.34 +    if [ "x$VNCCONNECT" != "x" ]; then
    4.35 +        PARMETER="$PARMETER -vncconnect $VNCCONNECT"
    4.36 +    fi
    4.37  fi
    4.38  
    4.39  #optional cmdline for qemu        
     5.1 --- a/tools/ioemu/vl.c	Mon May 23 18:17:51 2005 +0000
     5.2 +++ b/tools/ioemu/vl.c	Mon May 23 18:51:45 2005 +0000
     5.3 @@ -110,6 +110,8 @@ int bios_size;
     5.4  static DisplayState display_state;
     5.5  int nographic;
     5.6  int usevnc; /* 1=vnc only, 2=vnc and sdl */
     5.7 +long vncport; /* server port */
     5.8 +const char* vncconnect; /* do a reverse connect to this host*/
     5.9  const char* keyboard_layout = 0;
    5.10  int64_t ticks_per_sec;
    5.11  int boot_device = 'c';
    5.12 @@ -2098,7 +2100,9 @@ void help(void)
    5.13             "-m megs         set virtual RAM size to megs MB [default=%d]\n"
    5.14             "-nographic      disable graphical output and redirect serial I/Os to console\n"
    5.15  #ifdef CONFIG_VNC
    5.16 -	   "-vnc            use vnc instead of sdl\n"
    5.17 +	   "-vnc port             use vnc instead of sdl\n"
    5.18 +	   "-vncport port         use a different port\n"
    5.19 +	   "-vncconnect host:port do a reverse connect\n"
    5.20  #ifdef CONFIG_SDL
    5.21  	   "-vnc-and-sdl    use vnc and sdl simultaneously\n"
    5.22  #endif
    5.23 @@ -2194,6 +2198,8 @@ enum {
    5.24      QEMU_OPTION_nographic,
    5.25  #ifdef CONFIG_VNC
    5.26      QEMU_OPTION_vnc,
    5.27 +    QEMU_OPTION_vncport,
    5.28 +    QEMU_OPTION_vncconnect,
    5.29  #ifdef CONFIG_SDL
    5.30      QEMU_OPTION_vnc_and_sdl,
    5.31  #endif
    5.32 @@ -2258,6 +2264,8 @@ const QEMUOption qemu_options[] = {
    5.33      { "nographic", 0, QEMU_OPTION_nographic },
    5.34  #ifdef CONFIG_VNC
    5.35      { "vnc", 0, QEMU_OPTION_vnc },
    5.36 +    { "vncport", HAS_ARG, QEMU_OPTION_vncport },
    5.37 +    { "vncconnect", HAS_ARG, QEMU_OPTION_vncconnect },
    5.38  #ifdef CONFIG_SDL
    5.39      { "vnc-and-sdl", 0, QEMU_OPTION_vnc_and_sdl },
    5.40  #endif
    5.41 @@ -2370,6 +2378,8 @@ int main(int argc, char **argv)
    5.42      snapshot = 0;
    5.43      nographic = 0;
    5.44      usevnc = 0;
    5.45 +    vncport=0;
    5.46 +    vncconnect=NULL;
    5.47      kernel_filename = NULL;
    5.48      kernel_cmdline = "";
    5.49      has_cdrom = 1;
    5.50 @@ -2464,8 +2474,20 @@ int main(int argc, char **argv)
    5.51                  break;
    5.52  #ifdef CONFIG_VNC
    5.53  	    case QEMU_OPTION_vnc:
    5.54 -		usevnc = 1;
    5.55 -		break;
    5.56 +            usevnc = 1;
    5.57 +            break;  
    5.58 +	    case QEMU_OPTION_vncport:
    5.59 +        {
    5.60 +            const char *p;
    5.61 +            p = optarg;
    5.62 +            vncport= strtol(optarg, (char **)&p, 0);
    5.63 +        }
    5.64 +        break;
    5.65 +	    case QEMU_OPTION_vncconnect:
    5.66 +        {
    5.67 +            vncconnect=optarg;
    5.68 +        }
    5.69 +        break;
    5.70  #ifdef CONFIG_SDL
    5.71  	    case QEMU_OPTION_vnc_and_sdl:
    5.72  		usevnc = 2;
    5.73 @@ -2852,7 +2874,7 @@ int main(int argc, char **argv)
    5.74      } else {
    5.75  	if (usevnc) {
    5.76  #ifdef CONFIG_VNC
    5.77 -	    vnc_display_init(ds, (usevnc==2));
    5.78 +	    vnc_display_init(ds, (usevnc==2), vncport, vncconnect);
    5.79  #else
    5.80  	    perror("qemu not configured with vnc support");
    5.81  #endif
     6.1 --- a/tools/ioemu/vl.h	Mon May 23 18:17:51 2005 +0000
     6.2 +++ b/tools/ioemu/vl.h	Mon May 23 18:51:45 2005 +0000
     6.3 @@ -537,7 +537,8 @@ void vga_invalidate_display(void);
     6.4  void vga_screen_dump(const char *filename);
     6.5  
     6.6  /* vnc.c */
     6.7 -void vnc_display_init(DisplayState *ds, int useAlsoSDL);
     6.8 +void vnc_display_init(DisplayState *ds, int useAlsoSDL,
     6.9 +                      long port, const char* connect);
    6.10  
    6.11  /* cirrus_vga.c */
    6.12  void pci_cirrus_vga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base, 
     7.1 --- a/tools/ioemu/vnc.c	Mon May 23 18:17:51 2005 +0000
     7.2 +++ b/tools/ioemu/vnc.c	Mon May 23 18:51:45 2005 +0000
     7.3 @@ -21,6 +21,15 @@
     7.4   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     7.5   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
     7.6   * THE SOFTWARE.
     7.7 + *
     7.8 + *
     7.9 + * reverse connection setup copied from x11vnc.c
    7.10 + * Copyright (c) 2002-2005 Karl J. Runge <runge@karlrunge.com>
    7.11 + * All rights reserved.
    7.12 + * based on:
    7.13 + *       the originial x11vnc.c in libvncserver (Johannes E. Schindelin)
    7.14 + *       x0rfbserver, the original native X vnc server (Jens Wagner)
    7.15 + *       krfb, the KDE desktopsharing project (Tim Jansen)
    7.16   */
    7.17  #include "vl.h"
    7.18  
    7.19 @@ -447,8 +456,15 @@ static void vnc_cleanup(void)
    7.20  	rfbScreenCleanup(screen);
    7.21  }
    7.22  
    7.23 -void vnc_display_init(DisplayState *ds, int useAlsoSDL)
    7.24 +
    7.25 +void vnc_display_init(DisplayState *ds, int useAlsoSDL,
    7.26 +                      long port, const char* connect)
    7.27  {
    7.28 +    int   len, rport = 5500;
    7.29 +    char  host[1024];
    7.30 +    char *p;
    7.31 +    rfbClientPtr cl;
    7.32 +    
    7.33  	if(!keyboard_layout) {
    7.34  		fprintf(stderr, "No keyboard language specified\n");
    7.35  		exit(1);
    7.36 @@ -460,6 +476,7 @@ void vnc_display_init(DisplayState *ds, 
    7.37  		exit(1);
    7.38  	}
    7.39  
    7.40 +
    7.41  	mouse_magic=init_mouse_magic();
    7.42  	register_savevm("vnc", 0, 1, vnc_save, vnc_load, mouse_magic);
    7.43  
    7.44 @@ -470,6 +487,7 @@ void vnc_display_init(DisplayState *ds, 
    7.45  		exit(1);
    7.46  	}
    7.47  
    7.48 +
    7.49  	screen->serverFormat.redShift = 11;
    7.50  	screen->serverFormat.greenShift = 5;
    7.51  	screen->serverFormat.blueShift = 0;
    7.52 @@ -477,6 +495,11 @@ void vnc_display_init(DisplayState *ds, 
    7.53  	screen->serverFormat.greenMax = 63;
    7.54  	screen->serverFormat.blueMax = 31;
    7.55  
    7.56 +    if (port != 0) 
    7.57 +        screen->port = port;
    7.58 +    else
    7.59 +        screen->autoPort = TRUE;
    7.60 +
    7.61  	if(useAlsoSDL) {
    7.62  		ds_sdl=(DisplayState*)malloc(sizeof(DisplayState));
    7.63  		sdl_display_init(ds_sdl,0);
    7.64 @@ -496,6 +519,31 @@ void vnc_display_init(DisplayState *ds, 
    7.65  	ds->dpy_resize = vnc_resize;
    7.66  	ds->dpy_refresh = vnc_refresh;
    7.67  
    7.68 +    /* deal with reverse connections */
    7.69 +    if ( connect == NULL || (len = strlen(connect)) < 1) {
    7.70 +        return;
    7.71 +    }
    7.72 +    if ( len > 1024 ) {
    7.73 +        fprintf(stderr, "vnc reverse connect name too long\n");
    7.74 +		exit(1);
    7.75 +    }
    7.76 +    strncpy(host, connect, len);
    7.77 +    host[len] = '\0';
    7.78 +    /* extract port, if any */
    7.79 +    if ((p = strchr(host, ':')) != NULL) {
    7.80 +        rport = atoi(p+1);
    7.81 +        *p = '\0';
    7.82 +    }
    7.83 +    cl = rfbReverseConnection(screen, host, rport);
    7.84 +    if (cl == NULL) {
    7.85 +        fprintf(stderr, "reverse_connect: %s failed\n", connect);
    7.86 +    } else {
    7.87 +        fprintf(stderr, "reverse_connect: %s/%s OK\n", connect, cl->host);
    7.88 +    }
    7.89 +
    7.90  	atexit(vnc_cleanup);
    7.91 +
    7.92 +
    7.93 +
    7.94  }
    7.95  
     8.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Mon May 23 18:17:51 2005 +0000
     8.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Mon May 23 18:51:45 2005 +0000
     8.3 @@ -724,6 +724,7 @@ class XendDomainInfo:
     8.4          if self.blkif_backend: flags |= SIF_BLK_BE_DOMAIN
     8.5          #todo generalise this
     8.6          if ostype == "vmx":
     8.7 +            log.debug('building vmx domain')            
     8.8              err = buildfn(dom            = dom,
     8.9                            image          = kernel,
    8.10                            control_evtchn = 0,
    8.11 @@ -733,7 +734,7 @@ class XendDomainInfo:
    8.12                            ramdisk        = ramdisk,
    8.13                            flags          = flags)
    8.14          else:
    8.15 -            log.warning('building dom with %d vcpus', self.vcpus)
    8.16 +            log.debug('building dom with %d vcpus', self.vcpus)
    8.17              err = buildfn(dom            = dom,
    8.18                            image          = kernel,
    8.19                            control_evtchn = self.channel.getRemotePort(),
    8.20 @@ -819,10 +820,25 @@ class XendDomainInfo:
    8.21          memory = sxp.child_value(self.config, "memory")
    8.22          # Create an event channel
    8.23          device_channel = channel.eventChannel(0, self.dom)
    8.24 +        # see if a vncviewer was specified
    8.25 +        # XXX RN: bit of a hack. should unify this, maybe stick in config space
    8.26 +        vncconnect=""
    8.27 +        image = sxp.child_value(self.config, "image")
    8.28 +        args = sxp.child_value(image, "args")
    8.29 +        if args:
    8.30 +            arg_list = string.split(args)
    8.31 +            for arg in arg_list:
    8.32 +                al = string.split(arg, '=')
    8.33 +                if al[0] == "VNC_VIEWER":
    8.34 +                    vncconnect=" -v %s" % al[1]
    8.35 +                    break
    8.36 +
    8.37          # Execute device model.
    8.38          #todo: Error handling
    8.39 +        # XXX RN: note that the order of args matter!
    8.40          os.system(device_model
    8.41                    + " -f %s" % device_config
    8.42 +                  + vncconnect
    8.43                    + " -d %d" % self.dom
    8.44                    + " -p %d" % device_channel['port1']
    8.45                    + " -m %s" % memory)
    8.46 @@ -1158,6 +1174,7 @@ def vm_image_plan9(vm, image):
    8.47      if args:
    8.48          cmdline += " " + args
    8.49      ramdisk = sxp.child_value(image, "ramdisk", '')
    8.50 +    log.debug("creating plan9 domain with cmdline: %s" %(cmdline,))
    8.51      vm.create_domain("plan9", kernel, ramdisk, cmdline)
    8.52      return vm
    8.53      
    8.54 @@ -1185,6 +1202,7 @@ def vm_image_vmx(vm, image):
    8.55      memmap = sxp.parse(open(memmap))[0]
    8.56      from xen.util.memmap import memmap_parse
    8.57      memmap = memmap_parse(memmap)
    8.58 +    log.debug("creating vmx domain with cmdline: %s" %(cmdline,))
    8.59      vm.create_domain("vmx", kernel, ramdisk, cmdline, memmap)
    8.60      return vm
    8.61  
     9.1 --- a/tools/python/xen/xm/create.py	Mon May 23 18:17:51 2005 +0000
     9.2 +++ b/tools/python/xen/xm/create.py	Mon May 23 18:51:45 2005 +0000
     9.3 @@ -532,7 +532,8 @@ def choose_vnc_display():
     9.4      return None
     9.5  
     9.6  def spawn_vnc(display):
     9.7 -    os.system("vncviewer -listen %d &" % display)
     9.8 +    os.system("vncviewer -log *:stdout:0 -listen %d &" %
     9.9 +              (VNC_BASE_PORT + display))
    9.10      return VNC_BASE_PORT + display
    9.11      
    9.12  def preprocess_vnc(opts, vals):