ia64/xen-unstable

changeset 7760:74737286e9f5

Enable xm console for vmx guest.
When the serial port is redirect to pty, write the allocated
device to xenstore, then xm console can get it.
TODO:serial port by pty shall not block if there are no reading
on the other end

Signed-off-by: Xiaofeng Ling <xiaofeng.ling@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Nov 10 12:04:29 2005 +0100 (2005-11-10)
parents d5775d0bcf1e
children bdb8c00ddb85
files tools/examples/xmexample.vmx tools/ioemu/target-i386-dm/Makefile tools/ioemu/vl.c
line diff
     1.1 --- a/tools/examples/xmexample.vmx	Thu Nov 10 12:01:15 2005 +0100
     1.2 +++ b/tools/examples/xmexample.vmx	Thu Nov 10 12:04:29 2005 +0100
     1.3 @@ -117,6 +117,11 @@ vncviewer=1
     1.4  #nographic=0
     1.5  
     1.6  
     1.7 +#-----------------------------------------------------------------------------
     1.8 +#   serial port re-direct to pty deivce, /dev/pts/n 
     1.9 +#   then xm console or minicom can connect
    1.10 +#serial='pty'
    1.11 +
    1.12  #----------------------------------------------------------------------------
    1.13  # enable ne2000, default = 0(use pcnet)
    1.14  ne2000=0
     2.1 --- a/tools/ioemu/target-i386-dm/Makefile	Thu Nov 10 12:01:15 2005 +0100
     2.2 +++ b/tools/ioemu/target-i386-dm/Makefile	Thu Nov 10 12:04:29 2005 +0100
     2.3 @@ -7,7 +7,7 @@ INSTALL_DIR := $(DESTDIR)/usr/$(LIBDIR)/
     2.4  TARGET_PATH=$(SRC_PATH)/target-$(TARGET_ARCH)
     2.5  VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw:$(SRC_PATH)/audio
     2.6  DEFINES=-I. -I$(TARGET_PATH) -I$(SRC_PATH)
     2.7 -DEFINES+= -I$(XEN_ROOT)/tools/libxc
     2.8 +DEFINES+= -I$(XEN_ROOT)/tools/libxc -I$(XEN_ROOT)/tools/xenstore
     2.9  ifdef CONFIG_USER_ONLY
    2.10  VPATH+=:$(SRC_PATH)/linux-user
    2.11  DEFINES+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ARCH)
    2.12 @@ -188,7 +188,7 @@ endif
    2.13  #########################################################
    2.14  
    2.15  DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
    2.16 -LIBS+=-lm -L../../libxc -lxenctrl -lxenguest
    2.17 +LIBS+=-lm -L../../libxc -lxenctrl -lxenguest -L../../xenstore -lxenstore
    2.18  ifndef CONFIG_USER_ONLY
    2.19  LIBS+=-lz
    2.20  endif
     3.1 --- a/tools/ioemu/vl.c	Thu Nov 10 12:01:15 2005 +0100
     3.2 +++ b/tools/ioemu/vl.c	Thu Nov 10 12:04:29 2005 +0100
     3.3 @@ -76,6 +76,7 @@
     3.4  #endif /* CONFIG_SDL */
     3.5  
     3.6  #include "xenctrl.h"
     3.7 +#include "xs.h"
     3.8  #include "exec-all.h"
     3.9  
    3.10  //#define DO_TB_FLUSH
    3.11 @@ -1171,6 +1172,48 @@ CharDriverState *qemu_chr_open_stdio(voi
    3.12      return chr;
    3.13  }
    3.14  
    3.15 +int store_console_dev(int domid, char *pts)
    3.16 +{
    3.17 +    int xc_handle;
    3.18 +    unsigned int len = 0;
    3.19 +    struct xs_handle *xs;
    3.20 +    char *path;
    3.21 +
    3.22 +    xs = xs_daemon_open();
    3.23 +    if (xs == NULL) {
    3.24 +        fprintf(logfile, "Could not contact XenStore\n");
    3.25 +        return -1;
    3.26 +    }
    3.27 +
    3.28 +    xc_handle = xc_interface_open();
    3.29 +    if (xc_handle == -1) {
    3.30 +        fprintf(logfile, "xc_interface_open() error\n");
    3.31 +        return -1;
    3.32 +    }
    3.33 +    
    3.34 +    path = xs_get_domain_path(xs, domid);
    3.35 +    if (path == NULL) {
    3.36 +        fprintf(logfile, "xs_get_domain_path() error\n");
    3.37 +        return -1;
    3.38 +    }
    3.39 +    path = realloc(path, strlen(path) + strlen("/console/tty") + 1);
    3.40 +    if (path == NULL) {
    3.41 +        fprintf(logfile, "realloc error\n");
    3.42 +        return -1;
    3.43 +    }
    3.44 +    strcat(path, "/console/tty");
    3.45 +    if (!xs_write(xs, NULL, path, pts, strlen(pts))) {
    3.46 +        fprintf(logfile, "xs_write for console fail");
    3.47 +        return -1;
    3.48 +    }
    3.49 +    
    3.50 +    free(path);
    3.51 +    xs_daemon_close(xs);
    3.52 +    close(xc_handle);
    3.53 +
    3.54 +    return 0;
    3.55 +}
    3.56 +
    3.57  #if defined(__linux__)
    3.58  CharDriverState *qemu_chr_open_pty(void)
    3.59  {
    3.60 @@ -1182,6 +1225,7 @@ CharDriverState *qemu_chr_open_pty(void)
    3.61          return NULL;
    3.62      }
    3.63      fprintf(stderr, "char device redirected to %s\n", slave_name);
    3.64 +    store_console_dev(domid, slave_name);
    3.65      return qemu_chr_open_fd(master_fd, master_fd);
    3.66  }
    3.67  #else
    3.68 @@ -2701,7 +2745,9 @@ int main(int argc, char **argv)
    3.69                  break;
    3.70              case QEMU_OPTION_nographic:
    3.71                  pstrcpy(monitor_device, sizeof(monitor_device), "stdio");
    3.72 -                pstrcpy(serial_devices[0], sizeof(serial_devices[0]), "stdio");
    3.73 +                if(!strcmp(serial_devices[0], "vc"))
    3.74 +                    pstrcpy(serial_devices[0], sizeof(serial_devices[0]),
    3.75 +                            "stdio");
    3.76                  nographic = 1;
    3.77                  break;
    3.78  #ifdef CONFIG_VNC