xenconsole support for multiple consoles
PATCH 1/1 xenconsole support for multiple consoles
This patch adds a new command line argument to xenconsole to specify to which console to connect to in case a domain has more than one.
Signed-off-by Stefano Stabellini <[email protected]>
---
stubdom/stubdom-dm +5 -0
@@ -52,6 +52,10 @@ keymap=$2 shift ;; + -serial) + serial="$2" + shift + ;; esac fi case "$1" in
@@ -100,6 +104,7 @@ vncpasswd=`xenstore-read /local/domain/0/backend/vfb/$domid/0/vncpasswd 2>/dev/null` test "$vncpasswd" && vfb="$vfb, vncpasswd=$vncpasswd" test "$keymap" && vfb="$vfb, keymap=$keymap" +test "$serial" && vfb="$vfb, serial=$serial" echo "vfb = ['$vfb']" >> /etc/xen/stubdoms/$domname-dm echo -n "disk = [ " >> /etc/xen/stubdoms/$domname-dm
tools/examples/xmexample.hvm-stubdom +5 -3
@@ -177,10 +177,12 @@ #----------------------------------------------------------------------------- # serial port re-direct to pty deivce, /dev/pts/n -# then xm console or minicom can connect +# then xm console or minicom can connect. +# In the stubdoms case this option adds a secondary console to the +# stubdom because there is always one for logging. +# To connect to the guest serial you can use "xm console -n 1" +# followed by the domain name of the stubdom. # -# STUBDOM: always disable as the stub domain doesn't have access to dom0's -# ptys #serial='pty'
tools/python/xen/xend/XendConfig.py +10 -0
@@ -1433,6 +1433,16 @@ del dev_info['type'] log.debug("iwj dev_type=%s vfb setting dev_info['%s']" % (dev_type, vfb_type)) + if dev_info.get('serial') is not None : + # Create two serial backends now, the location value is bogus, but does not matter + cfg = self.console_add('vt100', '0') + c_uuid = uuid.createString() + target['devices'][c_uuid] = ('console', cfg) + target['console_refs'].append(c_uuid) + cfg = self.console_add('vt100', '1') + c_uuid = uuid.createString() + target['devices'][c_uuid] = ('console', cfg) + target['console_refs'].append(c_uuid) elif dev_type == 'console': if 'console_refs' not in target:
tools/python/xen/xend/image.py +5 -4
@@ -286,6 +286,9 @@ if dev_type == 'vfb': if 'keymap' in dev_info: keymap = dev_info.get('keymap',{}) + if 'serial' in dev_info: + ret.append("-serial") + ret.append(dev_info.get('serial',{})) if int(dev_info.get('vnc', 0)) != 0 : has_vnc = True if int(dev_info.get('sdl', 0)) != 0 :
@@ -746,12 +749,10 @@ if not self.display : self.display = '' - # Do not store sdl, opengl and serial related qemu cli options + # Do not store sdl and opengl qemu cli options self.vm.storeVm(("image/dmargs", " ".join([ x for x in self.dmargs if x != "-sdl" - and x != "-disable-opengl" - and x != "-serial" - and x != "pty" ])), + and x != "-disable-opengl" ])), ("image/device-model", self.device_model), ("image/display", self.display)) self.vm.permissionsVm("image/dmargs", { 'dom': self.vm.getDomid(), 'read': True } )
tools/python/xen/xm/create.py +4 -3
@@ -352,7 +352,7 @@ For example 'irq=7'. This option may be repeated to add more than one IRQ.""") -gopts.var('vfb', val="vnc=1,sdl=1,vncunused=1,vncdisplay=N,vnclisten=ADDR,display=DISPLAY,xauthority=XAUTHORITY,vncpasswd=PASSWORD,opengl=1,keymap=FILE", +gopts.var('vfb', val="vnc=1,sdl=1,vncunused=1,vncdisplay=N,vnclisten=ADDR,display=DISPLAY,xauthority=XAUTHORITY,vncpasswd=PASSWORD,opengl=1,keymap=FILE,serial=FILE", fn=append_value, default=[], use="""Make the domain a framebuffer backend. Both sdl=1 and vnc=1 can be enabled at the same time.
@@ -364,7 +364,8 @@ For sdl=1, a viewer will be started automatically using the given DISPLAY and XAUTHORITY, which default to the current user's ones. OpenGL will be used by default unless opengl is set to 0. - keymap overrides the XendD configured default layout file.""") + keymap overrides the XendD configured default layout file. + Serial adds a second serial support to qemu.""") gopts.var('vif', val="type=TYPE,mac=MAC,bridge=BRIDGE,ip=IPADDR,script=SCRIPT," + \ "backend=DOM,vifname=NAME,rate=RATE,model=MODEL,accel=ACCEL",
@@ -827,7 +828,7 @@ for (k,v) in d.iteritems(): if not k in [ 'vnclisten', 'vncunused', 'vncdisplay', 'display', 'videoram', 'xauthority', 'sdl', 'vnc', 'vncpasswd', - 'opengl', 'keymap' ]: + 'opengl', 'keymap', 'serial' ]: err("configuration option %s unknown to vfbs" % k) config.append([k,v]) if not d.has_key("keymap"):
Quoted 5 lines · Stefano Stabellini
This patch adds a new command line argument to xenconsole to specify to which console to connect to in case a domain has more than one.
Signed-off-by Stefano Stabellini <[email protected]>
Sorry I sent two copies of the third patch.
This is the correct xenconsole patch.
---
tools/console/client/main.c +20 -15
@@ -71,6 +71,7 @@"Attaches to a virtual domain console\n" "\n" " -h, --help display this help and exit\n" +" -n, --num N use console number N\n" , program); }
@@ -255,15 +256,17 @@ {struct termios attr;int domid; -char *sopt ="h" ; +char *sopt ="hn:" ;int ch; +unsigned int num =0 ;int opt_ind=0 ;struct option lopt[] = { + {"num" ,1 ,0 ,'n' }, {"help" ,0 ,0 ,'h' }, {0 }, }; -char *path; +char *dom_path =NULL , *path =NULL ;int spty, xsfd;struct xs_handle *xs;char *end;
@@ -274,14 +277,15 @@usage (argv[0 ]);exit (0 );break ; +case 'n' : + num =atoi (optarg); +break ; +default : +fprintf (stderr,"Invalid argument\n" ); +fprintf (stderr,"Try `%s --help' for more information.\n" , + argv[0 ]); +exit (EINVAL ); } - } - -if ((argc - optind) !=1 ) { -fprintf (stderr,"Invalid number of arguments\n" ); -fprintf (stderr,"Try `%s --help' for more information.\n" , - argv[0 ]); -exit (EINVAL ); } domid =strtol (argv[optind], &end,10 );
@@ -299,13 +303,13 @@signal (SIGTERM , sighandler); - path =xs_get_domain_path (xs, domid); + dom_path =xs_get_domain_path (xs, domid); +if (dom_path ==NULL ) +err (errno,"xs_get_domain_path()" ); + path =malloc (strlen (dom_path) +strlen ("/serial/0/tty" ) +3 );if (path ==NULL ) -err (errno,"xs_get_domain_path()" ); - path =realloc (path,strlen (path) +strlen ("/console/tty" ) +1 ); -if (path ==NULL ) -err (ENOMEM ,"realloc" ); -strcat (path,"/console/tty" ); +err (ENOMEM ,"malloc" ); +snprintf (path,strlen (dom_path) +strlen ("/serial/0/tty" ) +2 ,"%s/serial/%d/tty" , dom_path, num);/* FIXME consoled currently does not assume domain-0 doesn't have a console which is good when we break domain-0 up. To keep us
@@ -336,5 +340,6 @@restore_term (STDIN_FILENO , &attr);free (path); +free (dom_path);return 0 ; }
tools/python/xen/xm/console.py +2 -2
@@ -24,8 +24,8 @@ XENCONSOLE = "xenconsole" -def execConsole(domid): - xen.util.auxbin.execute(XENCONSOLE, [str(domid)]) +def execConsole(domid, num = 0): + xen.util.auxbin.execute(XENCONSOLE, [str(domid), "--num", str(num)]) class OurXenstoreConnection:
tools/python/xen/xm/main.py +6 -3
@@ -1779,12 +1779,13 @@ print "%-23s:" % x[0], x[1] def xm_console(args): - arg_check(args, "console", 1, 2) + arg_check(args, "console", 1, 3) + num = 0 quiet = False; try: - (options, params) = getopt.gnu_getopt(args, 'q', ['quiet']) + (options, params) = getopt.gnu_getopt(args, 'qn:', ['quiet', 'num']) except getopt.GetoptError, opterr: err(opterr) usage('console')
@@ -1792,6 +1793,8 @@ for (k, v) in options: if k in ['-q', '--quiet']: quiet = True + elif k in ['-n', '--num']: + num = int(v[0]) else: assert False
@@ -1819,7 +1822,7 @@ else: raise xmlrpclib.Fault(0, "Domain '%s' is not started" % dom) - console.execConsole(domid) + console.execConsole(domid, num) def domain_name_to_domid(domain_name):