Skip to contentSkip to conversation

Plumb bootloader I/O through xenconsole.

RFC PATCH In review Tim Deegan 2 participants 6 messages Jan 15, 2007 – Jan 30, 2007

lore
Share & tools
lore

Tim Deegan

author
#0 lore raw

RFC PATCH 1/1 Plumb bootloader I/O through xenconsole.

The attached patches change the way the bootloader is called when creating a PV domain. Currently, in order to provide an interactive environment for the bootloader, the bootloader is run by xm create, using the tty of xm create's caller. This is a problem when a domain is rebooted, as there is no equivalent of xm create with a useful tty.

With these patches, Xend always calls the bootloader, and its interactive I/O is passed through the same pty channel that the domain's console will use when it is created.

All comments appreciated!

Details:

Patch 1 (ptsname) is a wrapper around the ptsname(3) POSIX library function, which doesn't appear to be available in python otherwise.

Patch 2 (bootloader-console) makes the following changes:
- the xenconsole client can handle the domain's console pty changing.
- xend forwards console traffic between the running bootloader and a pty which it writes to the store so the xenconsole client can see it.
- xend runs the bootloader interactively unless the config file tells it explicitly not to.
- xm create no longer runs the bootloader.

Yet to come: making "xm console" and "xm create -c" attach early enough in domain building to see the bootloader (at the moment you need to run xenconsole by hand for that).

Cheers,

Tim.

author
#1 lore raw

Argh. Patches are actually attached this time. :)

Tim.

Quoted 25 lines · Tim Deegan

The attached patches change the way the bootloader is called when creating a PV domain. Currently, in order to provide an interactive environment for the bootloader, the bootloader is run by xm create, using the tty of xm create's caller. This is a problem when a domain is rebooted, as there is no equivalent of xm create with a useful tty.

With these patches, Xend always calls the bootloader, and its interactive I/O is passed through the same pty channel that the domain's console will use when it is created.

All comments appreciated!

Details:

Patch 1 (ptsname) is a wrapper around the ptsname(3) POSIX library function, which doesn't appear to be available in python otherwise.

Patch 2 (bootloader-console) makes the following changes:
- the xenconsole client can handle the domain's console pty changing.
- xend forwards console traffic between the running bootloader and a pty which it writes to the store so the xenconsole client can see it.
- xend runs the bootloader interactively unless the config file tells it explicitly not to.
- xm create no longer runs the bootloader.

Quoted 7 lines

Yet to come: making "xm console" and "xm create -c" attach early enough in domain building to see the bootloader (at the moment you need to run xenconsole by hand for that).

Cheers,

Tim.

tools/Makefile +1 -0
diff -r 204c2724f800 tools/Makefile
@@ -26,6 +26,7 @@ ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_A
 ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH))
 SUBDIRS-y += python
 SUBDIRS-y += pygrub
+SUBDIRS-y += ptsname
 endif
 
 .PHONY: all
tools/ptsname/Makefile new file +22 -0
diff -r 204c2724f800 tools/ptsname/Makefile
@@ -0,0 +1,22 @@
+
+XEN_ROOT = ../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+.PHONY: all
+all: build
+.PHONY: build
+build:
+	CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py build
+
+.PHONY: install
+ifndef XEN_PYTHON_NATIVE_INSTALL
+install: all
+	CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --home="$(DESTDIR)/usr" --prefix=""
+else
+install: all
+	CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --root="$(DESTDIR)"
+endif
+
+.PHONY: clean
+clean:
+	rm -rf build tmp *.pyc *.pyo *.o *.a *~ a.out
tools/ptsname/ptsname.c new file +44 -0

44 lines not on this page · raw message

tools/ptsname/setup.py new file +11 -0
diff -r 204c2724f800 tools/ptsname/setup.py
@@ -0,0 +1,11 @@
+from distutils.core import setup, Extension
+
+extra_compile_args  = [ "-fno-strict-aliasing", "-Werror" ]
+
+setup(name         = 'ptsname',
+      version      = '1.0',
+      description  = 'POSIX ptsname() function',
+      author       = 'Tim Deegan',
+      author_email = '[email protected]',
+      license      = 'GPL',
+      ext_modules  = [ Extension("ptsname", [ "ptsname.c" ]) ])
tools/console/client/main.c +83 -46

188 lines not on this page · raw message

tools/misc/xend +1 -1
diff -r 56ca95a1d07b tools/misc/xend
@@ -44,7 +44,7 @@ for p in ['python%s' % sys.version[:3], 
         if os.path.exists(os.path.join(d, AUXBIN)):
             sys.path.append(d)
             import xen.util.auxbin
-            libpath = xen.util.auxbin.libpath()
+            libpath = os.path.join(xen.util.auxbin.libpath(), p)
             sys.path = sys.path[:-1]
             sys.path.append(libpath)
             break
tools/python/xen/xend/XendBootloader.py +59 -8

99 lines not on this page · raw message

tools/python/xen/xend/XendDomainInfo.py +1 -1
diff -r 56ca95a1d07b tools/python/xen/xend/XendDomainInfo.py
@@ -1615,7 +1615,7 @@ class XendDomainInfo:
                     fn = BOOTLOADER_LOOPBACK_DEVICE
 
                 try:
-                    blcfg = bootloader(blexec, fn, True,
+                    blcfg = bootloader(blexec, fn, self, False,
                                        bootloader_args, kernel, ramdisk, args)
                 finally:
                     if mounted:
tools/python/xen/xm/create.py +0 -25
diff -r 56ca95a1d07b tools/python/xen/xm/create.py
@@ -704,26 +704,6 @@ def configure_hvm(config_image, vals):
             config_image.append([a, vals.__dict__[a]])
     config_image.append(['vncpasswd', vals.vncpasswd])
 
-def run_bootloader(vals, config_image):
-    if not os.access(vals.bootloader, os.F_OK):
-        err("Bootloader '%s' does not exist" % vals.bootloader)
-    if not os.access(vals.bootloader, os.X_OK):
-        err("Bootloader '%s' isn't executable" % vals.bootloader)
-    if len(vals.disk) < 1:
-        err("No disks configured and boot loader requested")
-    (uname, dev, mode, backend) = vals.disk[0]
-    file = blkif.blkdev_uname_to_file(uname)
-
-    if vals.bootentry:
-        warn("The bootentry option is deprecated.  Use bootargs and pass "
-             "--entry= directly.")
-        vals.bootargs = "--entry=%s" %(vals.bootentry,)
-
-    kernel = sxp.child_value(config_image, 'kernel')
-    ramdisk = sxp.child_value(config_image, 'ramdisk')
-    args = sxp.child_value(config_image, 'args')
-    return bootloader(vals.bootloader, file, not vals.console_autoconnect,
-                      vals.bootargs, kernel, ramdisk, args)
 
 def make_config(vals):
     """Create the domain configuration.
@@ -766,11 +746,6 @@ def make_config(vals):
         if vals.bootloader == "pygrub":
             vals.bootloader = osdep.pygrub_path
 
-        # if a kernel is specified, we're using the bootloader
-        # non-interactively, and need to let xend run it so we preserve the
-        # real kernel choice.
-        if not vals.kernel:
-            config_image = run_bootloader(vals, config_image)
         config.append(['bootloader', vals.bootloader])
         if vals.bootargs:
             config.append(['bootloader_args', vals.bootargs])

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

author
#2 lore raw
In reply to Tim Deegan

An updated version of this patch is attached. Unless there's any objection, something very like this will be checked in soon.

This version makes a change to the way Xend records its list of active domains -- they are now added as soon as they are created, rather than after startup, which lets "xm console" see domains which are still at the bootloader stage.

Cheers,

Tim.

Quoted 25 lines · Tim Deegan

The attached patches change the way the bootloader is called when creating a PV domain. Currently, in order to provide an interactive environment for the bootloader, the bootloader is run by xm create, using the tty of xm create's caller. This is a problem when a domain is rebooted, as there is no equivalent of xm create with a useful tty.

With these patches, Xend always calls the bootloader, and its interactive I/O is passed through the same pty channel that the domain's console will use when it is created.

All comments appreciated!

Details:

Patch 1 (ptsname) is a wrapper around the ptsname(3) POSIX library function, which doesn't appear to be available in python otherwise.

Patch 2 (bootloader-console) makes the following changes:
- the xenconsole client can handle the domain's console pty changing.
- xend forwards console traffic between the running bootloader and a pty which it writes to the store so the xenconsole client can see it.
- xend runs the bootloader interactively unless the config file tells it explicitly not to.
- xm create no longer runs the bootloader.

Quoted 7 lines

Yet to come: making "xm console" and "xm create -c" attach early enough in domain building to see the bootloader (at the moment you need to run xenconsole by hand for that).

Cheers,

Tim.

tools/Makefile +1 -0
diff -r 204c2724f800 tools/Makefile
@@ -26,6 +26,7 @@ ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_A
 ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH))
 SUBDIRS-y += python
 SUBDIRS-y += pygrub
+SUBDIRS-y += ptsname
 endif
 
 .PHONY: all
tools/ptsname/Makefile new file +22 -0
diff -r 204c2724f800 tools/ptsname/Makefile
@@ -0,0 +1,22 @@
+
+XEN_ROOT = ../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+.PHONY: all
+all: build
+.PHONY: build
+build:
+	CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py build
+
+.PHONY: install
+ifndef XEN_PYTHON_NATIVE_INSTALL
+install: all
+	CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --home="$(DESTDIR)/usr" --prefix=""
+else
+install: all
+	CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --root="$(DESTDIR)"
+endif
+
+.PHONY: clean
+clean:
+	rm -rf build tmp *.pyc *.pyo *.o *.a *~ a.out
tools/ptsname/ptsname.c new file +44 -0

44 lines not on this page · raw message

tools/ptsname/setup.py new file +11 -0
diff -r 204c2724f800 tools/ptsname/setup.py
@@ -0,0 +1,11 @@
+from distutils.core import setup, Extension
+
+extra_compile_args  = [ "-fno-strict-aliasing", "-Werror" ]
+
+setup(name         = 'ptsname',
+      version      = '1.0',
+      description  = 'POSIX ptsname() function',
+      author       = 'Tim Deegan',
+      author_email = '[email protected]',
+      license      = 'GPL',
+      ext_modules  = [ Extension("ptsname", [ "ptsname.c" ]) ])
tools/console/client/main.c +83 -46

188 lines not on this page · raw message

tools/misc/xend +1 -1
diff -r 5a3960e15d4a tools/misc/xend
@@ -44,7 +44,7 @@ for p in ['python%s' % sys.version[:3], 
         if os.path.exists(os.path.join(d, AUXBIN)):
             sys.path.append(d)
             import xen.util.auxbin
-            libpath = xen.util.auxbin.libpath()
+            libpath = os.path.join(xen.util.auxbin.libpath(), p)
             sys.path = sys.path[:-1]
             sys.path.append(libpath)
             break
tools/pygrub/src/pygrub +3 -1
diff -r 5a3960e15d4a tools/pygrub/src/pygrub
@@ -201,7 +201,9 @@ class Grub:
             enable_cursor(False)
             self.entry_win = curses.newwin(10, 74, 2, 1)
             self.text_win = curses.newwin(10, 70, 12, 5)
-            
+            curses.def_prog_mode()
+        
+        curses.reset_prog_mode()
         self.screen.clear()
         self.screen.refresh()
 
tools/python/xen/xend/XendBootloader.py +88 -9

139 lines not on this page · raw message

tools/python/xen/xend/XendDomain.py +6 -14
diff -r 5a3960e15d4a tools/python/xen/xend/XendDomain.py
@@ -115,7 +115,6 @@ class XendDomain:
                 
                 dom0info['name'] = DOM0_NAME
                 dom0 = XendDomainInfo.recreate(dom0info, True)
-                self._add_domain(dom0)
             except IndexError:
                 raise XendError('Unable to find Domain 0')
             
@@ -172,7 +171,6 @@ class XendDomain:
                 if dom['domid'] != DOM0_ID:
                     try:
                         new_dom = XendDomainInfo.recreate(dom, False)
-                        self._add_domain(new_dom)
                     except Exception:
                         log.exception("Failed to create reference to running "
                                       "domain id: %d" % dom['domid'])
@@ -397,7 +395,6 @@ class XendDomain:
             elif domid not in self.domains and dom['dying'] != 1:
                 try:
                     new_dom = XendDomainInfo.recreate(dom, False)
-                    self._add_domain(new_dom)                    
                 except VmError:
                     log.exception("Unable to recreate domain")
                     try:
@@ -416,10 +413,10 @@ class XendDomain:
         running_domids = [d['domid'] for d in running if d['dying'] != 1]
         for domid, dom in self.domains.items():
             if domid not in running_domids and domid != DOM0_ID:
-                self._remove_domain(dom, domid)
-
-
-    def _add_domain(self, info):
+                self.remove_domain(dom, domid)
+
+
+    def add_domain(self, info):
         """Add a domain to the list of running domains
         
         @requires: Expects to be protected by the domains_lock.
@@ -434,7 +431,7 @@ class XendDomain:
         if info.get_uuid() in self.managed_domains:
             self._managed_domain_register(info)
 
-    def _remove_domain(self, info, domid = None):
+    def remove_domain(self, info, domid = None):
         """Remove the domain from the list of running domains
         
         @requires: Expects to be protected by the domains_lock.
@@ -473,7 +470,6 @@ class XendDomain:
         try:
             security.refresh_ssidref(config)
             dominfo = XendDomainInfo.restore(config)
-            self._add_domain(dominfo)
             return dominfo
         finally:
             self.domains_lock.release()
@@ -848,7 +844,6 @@ class XendDomain:
                                            os.open(chkpath, os.O_RDONLY),
                                            dominfo,
                                            paused = start_paused)
-                    self._add_domain(dominfo)
                     os.unlink(chkpath)
                 except OSError, ex:
                     raise XendError("Failed to read stored checkpoint file")
@@ -873,7 +868,6 @@ class XendDomain:
             self._refresh()
 
             dominfo = XendDomainInfo.create(config)
-            self._add_domain(dominfo)
             self.domain_sched_credit_set(dominfo.getDomid(),
                                          dominfo.getWeight(),
                                          dominfo.getCap())
@@ -893,7 +887,6 @@ class XendDomain:
             self._refresh()
 
             dominfo = XendDomainInfo.create_from_dict(config_dict)
-            self._add_domain(dominfo)
             self.domain_sched_credit_set(dominfo.getDomid(),
                                          dominfo.getWeight(),
                                          dominfo.getCap())
@@ -950,7 +943,6 @@ class XendDomain:
                                  POWER_STATE_NAMES[dominfo.state])
             
             dominfo.start(is_managed = True)
-            self._add_domain(dominfo)
         finally:
             self.domains_lock.release()
         dominfo.waitForDevices()
@@ -983,7 +975,7 @@ class XendDomain:
                          (dominfo.getName(), dominfo.info.get('uuid')))
 
                 self._managed_domain_unregister(dominfo)
-                self._remove_domain(dominfo)
+                self.remove_domain(dominfo)
                 XendDevices.destroy_device_state(dominfo)
             except Exception, ex:
                 raise XendError(str(ex))
tools/python/xen/xend/XendDomainInfo.py +14 -3
diff -r 5a3960e15d4a tools/python/xen/xend/XendDomainInfo.py
@@ -41,7 +41,7 @@ from xen.xend import XendRoot, XendNode,
 from xen.xend import XendRoot, XendNode, XendConfig
 
 from xen.xend.XendConfig import scrub_password
-from xen.xend.XendBootloader import bootloader
+from xen.xend.XendBootloader import bootloader, bootloader_tidy
 from xen.xend.XendError import XendError, VmError
 from xen.xend.XendDevices import XendDevices
 from xen.xend.xenstore.xstransact import xstransact, complete
@@ -120,7 +120,6 @@ def create_from_dict(config_dict):
         log.exception('Domain construction failed')
         vm.destroy()
         raise
-
     return vm
 
 def recreate(info, priv):
@@ -206,6 +205,11 @@ def recreate(info, priv):
 
     vm._registerWatches()
     vm.refreshShutdown(xeninfo)
+
+    # register the domain in the list 
+    from xen.xend import XendDomain
+    XendDomain.instance().add_domain(vm)
+
     return vm
 
 
@@ -1343,6 +1347,9 @@ class XendDomainInfo:
         # Set maximum number of vcpus in domain
         xc.domain_max_vcpus(self.domid, int(self.info['vcpus_number']))
 
+        # register the domain in the list 
+        from xen.xend import XendDomain
+        XendDomain.instance().add_domain(self)
 
     def _introduceDomain(self):
         assert self.domid is not None
@@ -1440,6 +1447,7 @@ class XendDomainInfo:
         try:
             self.unwatchShutdown()
             self._releaseDevices()
+            bootloader_tidy(self)
 
             if self.image:
                 try:
@@ -1529,6 +1537,9 @@ class XendDomainInfo:
                     self.info[state] = 0
         except:
             log.exception("XendDomainInfo.destroy: xc.domain_destroy failed.")
+
+        from xen.xend import XendDomain
+        XendDomain.instance().remove_domain(self)
 
         self.cleanupDomain()
 
@@ -1615,7 +1626,7 @@ class XendDomainInfo:
                     fn = BOOTLOADER_LOOPBACK_DEVICE
 
                 try:
-                    blcfg = bootloader(blexec, fn, True,
+                    blcfg = bootloader(blexec, fn, self, False,
                                        bootloader_args, kernel, ramdisk, args)
                 finally:
                     if mounted:
tools/python/xen/xm/create.py +23 -28

75 lines not on this page · raw message

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#3 lore raw
In reply to Tim Deegan
Quoted 3 lines · Tim Deegan

Yet to come: making "xm console" and "xm create -c" attach early enough in domain building to see the bootloader (at the moment you need to run xenconsole by hand for that).

Do you have a timeline? The code needs some portability changes for streams (%%^%$^) and I don't want to step on your toes.

regards
john

author
#4 lore raw
Quoted 8 lines · John Levon
Quoted 3 lines · Tim Deegan

Yet to come: making "xm console" and "xm create -c" attach early enough in domain building to see the bootloader (at the moment you need to run xenconsole by hand for that).

Do you have a timeline? The code needs some portability changes for streams (%%^%$^) and I don't want to step on your toes.

That was in the next patch I posted, and has now gone into -unstable.

Cheers,

Tim.

#5 lore raw
Quoted 8 lines · Tim Deegan
Quoted 6 lines
Quoted 3 lines

Yet to come: making "xm console" and "xm create -c" attach early enough in domain building to see the bootloader (at the moment you need to run xenconsole by hand for that).

Do you have a timeline? The code needs some portability changes for streams (%%^%$^) and I don't want to step on your toes.

That was in the next patch I posted, and has now gone into -unstable.

Hmmph. I don't seem to be seeing any bootloader output, but if I use xm console directly, I can...

regards
john