WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] merge

# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 0aeb37de0e4ad74902f72c6423f32c1123b51769
# Parent  66dd96e90be4c2a66a98ed67ddd4ee8cec6bd599
# Parent  055efdd6b7c5ed07ac6903923634637793ff9106
merge

diff -r 66dd96e90be4 -r 0aeb37de0e4a tools/python/xen/xend/XendCheckpoint.py
--- a/tools/python/xen/xend/XendCheckpoint.py   Tue Nov  8 02:40:31 2005
+++ b/tools/python/xen/xend/XendCheckpoint.py   Tue Nov  8 10:44:48 2005
@@ -209,9 +209,9 @@
         raise XendError("%s failed" % string.join(cmd))
 
 
-def slurp(file):
+def slurp(infile):
     while 1:
-        line = file.readline()
+        line = infile.readline()
         if line == "":
             break
         else:
diff -r 66dd96e90be4 -r 0aeb37de0e4a tools/python/xen/xend/XendClient.py
--- a/tools/python/xen/xend/XendClient.py       Tue Nov  8 02:40:31 2005
+++ b/tools/python/xen/xend/XendClient.py       Tue Nov  8 10:44:48 2005
@@ -219,6 +219,10 @@
 
     def xend_domain(self, id):
         return self.xendGet(self.domainurl(id))
+
+    def xend_domain_wait_for_devices(self, id):
+        return self.xendPost(self.domainurl(id),
+                             {'op'      : 'wait_for_devices' })
 
     def xend_domain_unpause(self, id):
         return self.xendPost(self.domainurl(id),
diff -r 66dd96e90be4 -r 0aeb37de0e4a tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Tue Nov  8 02:40:31 2005
+++ b/tools/python/xen/xend/XendDomainInfo.py   Tue Nov  8 10:44:48 2005
@@ -89,6 +89,8 @@
 
 """Minimum time between domain restarts in seconds."""
 MINIMUM_RESTART_TIME = 20
+
+RESTART_IN_PROGRESS = 'xend/restart_in_progress'
 
 
 xc = xen.lowlevel.xc.new()
@@ -895,6 +897,14 @@
         return self.getDeviceController(deviceClass).createDevice(devconfig)
 
 
+    def waitForDevices_(self, deviceClass):
+        return self.getDeviceController(deviceClass).waitForDevices()
+
+
+    def waitForDevice(self, deviceClass, devid):
+        return self.getDeviceController(deviceClass).waitForDevice(devid)
+
+
     def reconfigureDevice(self, deviceClass, devid, devconfig):
         return self.getDeviceController(deviceClass).reconfigureDevice(
             devid, devconfig)
@@ -1230,6 +1240,15 @@
             self.image.createDeviceModel()
 
 
+    def waitForDevices(self):
+        """Wait for this domain's configured devices to connect.
+
+        @raise: VmError if any device fails to initialise.
+        """
+        for c in controllerClasses:
+            self.waitForDevices_(c)
+
+
     def device_create(self, dev_config):
         """Create a new device.
 
@@ -1237,6 +1256,7 @@
         """
         dev_type = sxp.name(dev_config)
         devid = self.createDevice(dev_type, dev_config)
+        self.waitForDevice(dev_type, devid)
 #        self.config.append(['device', dev.getConfig()])
         return self.getDeviceController(dev_type).sxpr(devid)
 
@@ -1269,14 +1289,14 @@
 
         config = self.sxpr()
 
-        if self.readVm('xend/restart_in_progress'):
+        if self.readVm(RESTART_IN_PROGRESS):
             log.error('Xend failed during restart of domain %d.  '
                       'Refusing to restart to avoid loops.',
                       self.domid)
             self.destroy()
             return
 
-        self.writeVm('xend/restart_in_progress', 'True')
+        self.writeVm(RESTART_IN_PROGRESS, 'True')
 
         now = time.time()
         rst = self.readVm('xend/previous_restart_time')
@@ -1298,26 +1318,28 @@
                 self.preserveForRestart()
             else:
                 self.destroyDomain()
-                
+
+            # new_dom's VM will be the same as this domain's VM, except where
+            # the rename flag has instructed us to call preserveForRestart.
+            # In that case, it is important that we remove the
+            # RESTART_IN_PROGRESS node from the new domain, not the old one,
+            # once the new one is available.
+
+            new_dom = None
             try:
                 xd = get_component('xen.xend.XendDomain')
                 new_dom = xd.domain_create(config)
-                try:
-                    new_dom.unpause()
-                except:
+                new_dom.unpause()
+                new_dom.removeVm(RESTART_IN_PROGRESS)
+            except:
+                if new_dom:
+                    new_dom.removeVm(RESTART_IN_PROGRESS)
                     new_dom.destroy()
-                    raise
-            except:
-                log.exception('Failed to restart domain %d.', self.domid)
-        finally:
-            # new_dom's VM will be the same as this domain's VM, except where
-            # the rename flag has instructed us to call preserveForRestart.
-            # In that case, it is important that we use new_dom.removeVm, not
-            # self.removeVm.
-            new_dom.removeVm('xend/restart_in_progress')
-            
-        # self.configure_bootloader()
-        #        self.exportToDB()
+                else:
+                    self.removeVm(RESTART_IN_PROGRESS)
+                raise
+        except:
+            log.exception('Failed to restart domain %d.', self.domid)
 
 
     def preserveForRestart(self):
diff -r 66dd96e90be4 -r 0aeb37de0e4a 
tools/python/xen/xend/server/DevController.py
--- a/tools/python/xen/xend/server/DevController.py     Tue Nov  8 02:40:31 2005
+++ b/tools/python/xen/xend/server/DevController.py     Tue Nov  8 10:44:48 2005
@@ -62,6 +62,18 @@
 
         self.writeDetails(config, devid, back, front)
 
+        return devid
+
+
+    def waitForDevices(self):
+        log.debug("Waiting for devices %s.", self.deviceClass)
+        
+        return map(self.waitForDevice, self.deviceIDs())
+
+
+    def waitForDevice(self, devid):
+        log.debug("Waiting for %s.", devid)
+        
         status, fn_ret = self.waitForBackend(devid)
         if status:
             self.destroyDevice(devid)
@@ -74,7 +86,6 @@
             raise VmError( ("Device %s (%s) could not be connected. "
                             "Backend device not found!") 
                             % (devid, self.deviceClass))
-        return devid
 
 
     def reconfigureDevice(self, devid, config):
@@ -122,10 +133,11 @@
         specified device.  This would be suitable for giving to {@link
         #createDevice} in order to recreate that device."""
 
-        backdomid = int(xstransact.Read(self.frontendPath(devid),
-                                        "backend-id"))
-
-        return [self.deviceClass, ['backend', backdomid]]
+        backdomid = xstransact.Read(self.frontendPath(devid), "backend-id")
+        if backdomid is None:
+            raise VmError("Device %s not connected" % devid)
+        
+        return [self.deviceClass, ['backend', int(backdomid)]]
 
 
     def sxprs(self):
@@ -200,7 +212,10 @@
     def readBackend(self, devid, *args):
         frontpath = self.frontendPath(devid)
         backpath = xstransact.Read(frontpath, "backend")
-        return xstransact.Read(backpath, *args)
+        if backpath:
+            return xstransact.Read(backpath, *args)
+        else:
+            raise VmError("Device %s not connected" % devid)
 
 
     def deviceIDs(self):
@@ -242,6 +257,8 @@
         frontpath = self.frontendPath(devid)
         backpath  = self.backendPath(backdom, devid)
         
+        xstransact.Remove(backpath, HOTPLUG_STATUS_NODE)
+
         frontDetails.update({
             'backend' : backpath,
             'backend-id' : "%i" % backdom.getDomid()
@@ -266,7 +283,10 @@
         ev = Event()
 
         def hotplugStatus():
-            status = self.readBackend(devid, HOTPLUG_STATUS_NODE)
+            try:
+                status = self.readBackend(devid, HOTPLUG_STATUS_NODE)
+            except VmError:
+                status = "died"
             if status is not None:
                 watch.xs.unwatch(backpath, watch)
                 hotplugStatus.value = status
@@ -276,14 +296,16 @@
         frontpath = self.frontendPath(devid)
         backpath = xstransact.Read(frontpath, "backend")
 
-        watch = xswatch(backpath, hotplugStatus)
-
-        ev.wait(DEVICE_CREATE_TIMEOUT)
-        if ev.isSet():
-            return (0, hotplugStatus.value)
+        if backpath:
+            watch = xswatch(backpath, hotplugStatus)
+
+            ev.wait(DEVICE_CREATE_TIMEOUT)
+            if ev.isSet():
+                return (0, hotplugStatus.value)
+            else:
+                return (-1, hotplugStatus.value)
         else:
-            return (-1, hotplugStatus.value)
-
+            return (-1, "missing")
 
 
     def backendPath(self, backdom, devid):
diff -r 66dd96e90be4 -r 0aeb37de0e4a tools/python/xen/xend/server/SrvDomain.py
--- a/tools/python/xen/xend/server/SrvDomain.py Tue Nov  8 02:40:31 2005
+++ b/tools/python/xen/xend/server/SrvDomain.py Tue Nov  8 10:44:48 2005
@@ -13,13 +13,13 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #============================================================================
 # Copyright (C) 2004, 2005 Mike Wray <mike.wray@xxxxxx>
+# Copyright (C) 2005 Xensource Ltd
 #============================================================================
 
 from xen.web import http
 
 from xen.xend import sxp
 from xen.xend import XendDomain
-from xen.xend import PrettyPrint
 from xen.xend.Args import FormFn
 
 from xen.web.SrvDir import SrvDir
@@ -33,7 +33,7 @@
         self.dom = dom
         self.xd = XendDomain.instance()
 
-    def op_configure(self, op, req):
+    def op_configure(self, _, req):
         """Configure an existing domain.
         Configure is unusual in that it requires a domain id,
         not a domain name.
@@ -43,11 +43,11 @@
                      ['config', 'sxpr']])
         return fn(req.args, {'dom': self.dom.domid})
 
-    def op_unpause(self, op, req):
+    def op_unpause(self, _1, _2):
         val = self.xd.domain_unpause(self.dom.domid)
         return val
         
-    def op_pause(self, op, req):
+    def op_pause(self, _1, _2):
         val = self.xd.domain_pause(self.dom.domid)
         return val
 
@@ -55,15 +55,19 @@
         req.setResponseCode(http.ACCEPTED)
         req.setHeader("Location", "%s/.." % req.prePathURL())
 
-    def op_shutdown(self, op, req):
+    def op_shutdown(self, _, req):
         self.acceptCommand(req)
         return self.dom.shutdown(req.args['reason'][0])
 
-    def op_sysrq(self, op, req):
+    def op_sysrq(self, _, req):
         self.acceptCommand(req)
         return self.dom.send_sysrq(int(req.args['key'][0]))
 
-    def op_destroy(self, op, req):
+    def op_wait_for_devices(self, _, req):
+        self.acceptCommand(req)
+        return self.dom.waitForDevices()
+
+    def op_destroy(self, _, req):
         self.acceptCommand(req)
         return self.xd.domain_destroy(self.dom.domid)
 
@@ -71,13 +75,13 @@
         self.acceptCommand(req)
         return req.threadRequest(self.do_save, op, req)
 
-    def do_save(self, op, req):
+    def do_save(self, _, req):
         return self.xd.domain_save(self.dom.domid, req.args['file'][0])
 
     def op_migrate(self, op, req):
         return req.threadRequest(self.do_migrate, op, req)
     
-    def do_migrate(self, op, req):
+    def do_migrate(self, _, req):
         fn = FormFn(self.xd.domain_migrate,
                     [['dom',         'int'],
                      ['destination', 'str'],
@@ -85,7 +89,7 @@
                      ['resource',    'int']])
         return fn(req.args, {'dom': self.dom.domid})
 
-    def op_pincpu(self, op, req):
+    def op_pincpu(self, _, req):
         fn = FormFn(self.xd.domain_pincpu,
                     [['dom', 'int'],
                      ['vcpu', 'int'],
@@ -93,7 +97,7 @@
         val = fn(req.args, {'dom': self.dom.domid})
         return val
 
-    def op_cpu_bvt_set(self, op, req):
+    def op_cpu_bvt_set(self, _, req):
         fn = FormFn(self.xd.domain_cpu_bvt_set,
                     [['dom',       'int'],
                      ['mcuadv',    'int'],
@@ -105,14 +109,14 @@
         return val
     
     
-    def op_cpu_sedf_get(self, op, req):
+    def op_cpu_sedf_get(self, _, req):
         fn = FormFn(self.xd.domain_cpu_sedf_get,
                     [['dom', 'int']])
         val = fn(req.args, {'dom': self.dom.domid})
         return val
 
 
-    def op_cpu_sedf_set(self, op, req):
+    def op_cpu_sedf_set(self, _, req):
         fn = FormFn(self.xd.domain_cpu_sedf_set,
                     [['dom', 'int'],
                      ['period', 'int'],
@@ -123,7 +127,7 @@
         val = fn(req.args, {'dom': self.dom.domid})
         return val
 
-    def op_maxmem_set(self, op, req):
+    def op_maxmem_set(self, _, req):
         fn = FormFn(self.xd.domain_maxmem_set,
                     [['dom',    'int'],
                      ['memory', 'int']])
@@ -135,35 +139,35 @@
         return FormFn(fn, args)(req.args)
 
 
-    def op_mem_target_set(self, op, req):
+    def op_mem_target_set(self, _, req):
         return self.call(self.dom.setMemoryTarget,
                          [['target', 'int']],
                          req)
 
-    def op_devices(self, op, req):
+    def op_devices(self, _, req):
         return self.call(self.dom.getDeviceSxprs,
                          [['type', 'str']],
                          req)
 
-    def op_device_create(self, op, req):
+    def op_device_create(self, _, req):
         return self.call(self.dom.device_create,
                          [['config', 'sxpr']],
                          req)
 
-    def op_device_destroy(self, op, req):
+    def op_device_destroy(self, _, req):
         return self.call(self.dom.destroyDevice,
                          [['type', 'str'],
                           ['dev',  'str']],
                          req)
                 
-    def op_device_configure(self, op, req):
+    def op_device_configure(self, _, req):
         return self.call(self.dom.device_configure,
                          [['config', 'sxpr'],
                           ['dev',    'str']],
                          req)
 
 
-    def op_vif_limit_set(self, op, req):
+    def op_vif_limit_set(self, _, req):
         fn = FormFn(self.xd.domain_vif_limit_set,
                     [['dom',    'int'],
                      ['vif',    'int'],
@@ -172,7 +176,7 @@
         val = fn(req.args, {'dom': self.dom.domid})
         return val
 
-    def op_set_vcpus(self, op, req):
+    def op_set_vcpus(self, _, req):
         return self.call(self.dom.setVCpuCount,
                          [['vcpus', 'int']],
                          req)
diff -r 66dd96e90be4 -r 0aeb37de0e4a tools/python/xen/xend/server/params.py
--- a/tools/python/xen/xend/server/params.py    Tue Nov  8 02:40:31 2005
+++ b/tools/python/xen/xend/server/params.py    Tue Nov  8 10:44:48 2005
@@ -44,8 +44,3 @@
 XEND_USER          = 'root'
 XEND_DEBUG         = getenv("XEND_DEBUG",     0, conv=int)
 XEND_DAEMONIZE     = getenv("XEND_DAEMONIZE", not XEND_DEBUG, conv=int)
-
-XENSTORED_PID_FILE = '/var/run/xenstored.pid'
-XENSTORED_RUN_DIR  = '/var/run/xenstored'
-XENSTORED_LIB_DIR  = '/var/lib/xenstored'
-XENSTORED_DEBUG    = getenv("XENSTORED_DEBUG", 0, conv=int)
diff -r 66dd96e90be4 -r 0aeb37de0e4a tools/python/xen/xm/create.py
--- a/tools/python/xen/xm/create.py     Tue Nov  8 02:40:31 2005
+++ b/tools/python/xen/xm/create.py     Tue Nov  8 10:44:48 2005
@@ -815,6 +815,10 @@
 
     dom = sxp.child_value(dominfo, 'name')
 
+    if server.xend_domain_wait_for_devices(dom) < 0:
+        server.xend_domain_destroy(dom)
+        err("Device creation failed for domain %s" % dom)
+
     if not opts.vals.paused:
         if server.xend_domain_unpause(dom) < 0:
             server.xend_domain_destroy(dom)

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>