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-devel

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

To: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [RFC][PATCH 08/13] Kemari: add dev state "Attached" to python
From: Yoshiaki Tamura <tamura.yoshiaki@xxxxxxxxxxxxx>
Date: Fri, 06 Mar 2009 15:46:54 +0900
Cc: ospk-vm@xxxxxxxxxxxxx, Ian Pratt <ian.pratt@xxxxxxxxxx>, ian.jackson@xxxxxxxxxxxxx, Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
Delivery-date: Thu, 05 Mar 2009 23:02:22 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <49B0B8DC.5000606@xxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <49B0B8DC.5000606@xxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.19 (Windows/20081209)
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

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