[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [RFC][PATCH 08/13] Kemari: add dev state "Attached" to python



This patch implements python code that sends information necessary to attach
devices.  It also restores the information to the XenStore.

Signed-off-by: Yoshi Tamura <tamura.yoshiaki@xxxxxxxxxxxxx>
Signed-off-by: Yoshisato Yanagisawa <yanagisawa.yoshisato@xxxxxxxxxxxxx>
---
 tools/python/xen/xend/XendDomainInfo.py       |    8 +++
 tools/python/xen/xend/server/DevController.py |   61 ++++++++++++++++++++++++++
 tools/python/xen/xend/server/vfbif.py         |    4 +
 3 files changed, 73 insertions(+)

diff -r 19201eebab16 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Thu Sep 25 13:33:50 2008 +0100
+++ b/tools/python/xen/xend/XendDomainInfo.py   Wed Mar 04 17:04:24 2009 +0900
@@ -868,6 +868,14 @@
         """
         for devclass in XendDevices.valid_devices():
             self.getDeviceController(devclass).waitForDevices()
+
+    def waitForAttachedDevices(self, devinfo):
+        """Wait for this domain's configured devices to connect.
+
+        @raise VmError: if any device fails to initialise.
+        """
+        for devclass in XendDevices.valid_devices():
+            self.getDeviceController(devclass).waitForAttachedDevices(devinfo)

     def hvm_destroyPCIDevice(self, vslot):
         log.debug("hvm_destroyPCIDevice called %s", vslot)
diff -r 19201eebab16 tools/python/xen/xend/server/DevController.py
--- a/tools/python/xen/xend/server/DevController.py     Thu Sep 25 13:33:50 
2008 +0100
+++ b/tools/python/xen/xend/server/DevController.py     Wed Mar 04 17:04:24 
2009 +0900
@@ -53,6 +53,7 @@
     'Closed'       : 6,
     'Reconfiguring': 7,
     'Reconfigured' : 8,
+    'Attached'     : 9,
     }

 xoptions = XendOptions.instance()
@@ -192,6 +193,59 @@
                           (devid, self.deviceClass, err))


+    def waitForAttachedDevices(self, devinfo):
+        log.debug("Waiting for attached devices %s.", self.deviceClass)
+        seq = self.deviceIDs()
+        return [self.waitForAttachedDevice(item, devinfo) for item in seq]
+
+
+    def waitForAttachedDevice(self, devid, devinfo):
+        log.debug("Waiting for attached %s.", devid)
+
+        if not self.hotplug:
+            return
+
+        (status, err) = self.waitForBackend(devid)
+
+        if status == Timeout:
+            self.destroyDevice(devid, False)
+            raise VmError("Device %s (%s) could not be connected. "
+                          "Hotplug scripts not working." %
+                          (devid, self.deviceClass))
+
+        elif status == Error:
+            self.destroyDevice(devid, False)
+            raise VmError("Device %s (%s) could not be connected. "
+                          "Backend device not found." %
+                          (devid, self.deviceClass))
+
+        elif status == Missing:
+            # Don't try to destroy the device; it's already gone away.
+            raise VmError("Device %s (%s) could not be connected. "
+                          "Device not found." % (devid, self.deviceClass))
+
+        elif status == Busy:
+            err = None
+            frontpath = self.frontendPath(devid)
+            backpath = xstransact.Read(frontpath, "backend")
+            if backpath:
+                err = xstransact.Read(backpath, HOTPLUG_ERROR_NODE)
+            if not err:
+                err = "Busy."
+
+            self.destroyDevice(devid, False)
+            raise VmError("Device %s (%s) could not be connected.\n%s" %
+                          (devid, self.deviceClass, err))
+
+        for x in devinfo:
+            if x[0] == str(devid): # x[0] was changed to string for transfer.
+                for y in x[1]:
+                    if y[0] and y[1]:
+                        self.writeFrontend(devid, y[0], str(y[1]))
+                        log.debug("%s %s set for %s.", y[0], y[1], devid)
+                self.writeFrontend(devid, 'state', 
str(xenbusState['Attached']))
+
+
     def waitForDevice_destroy(self, devid, backpath):
         log.debug("Waiting for %s - destroyDevice.", devid)

@@ -483,6 +537,13 @@
         else:
             raise VmError("Device %s not connected" % devid)

+    def writeFrontend(self, devid, *args):
+        frontpath = self.frontendPath(devid)
+
+        if frontpath:
+            xstransact.Write(frontpath, *args)
+        else:
+            raise VmError("Device %s not connected" % devid)

 ## private:

diff -r 19201eebab16 tools/python/xen/xend/server/vfbif.py
--- a/tools/python/xen/xend/server/vfbif.py     Thu Sep 25 13:33:50 2008 +0100
+++ b/tools/python/xen/xend/server/vfbif.py     Wed Mar 04 17:04:24 2009 +0900
@@ -39,6 +39,10 @@
                      if devinfo[i] is not None])

     def waitForDevice(self, devid):
+        # is a qemu-dm managed device, don't wait for hotplug for these.
+        return
+
+    def waitForAttachedDevice(self, devid, devinfo):
         # is a qemu-dm managed device, don't wait for hotplug for these.
         return




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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.