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: Thu, 12 Mar 2009 10:19:54 +0900
Cc: "柳澤佳里(yanagisawa yoshisato)" <yanagisawa.yoshisato@xxxxxxxxxxxxx>, Ian Pratt <ian.pratt@xxxxxxxxxx>, ian.jackson@xxxxxxxxxxxxx, Keir Fraser <keir.fraser@xxxxxxxxxxxxx>, Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Delivery-date: Wed, 11 Mar 2009 18:41:44 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <49B86208.2020205@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: <49B86208.2020205@xxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.19 (Windows/20081209)
This is an updated version of the following patch.  No major changes.

http://lists.xensource.com/archives/html/xen-devel/2009-03/msg00377.html

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

diff -r b249f3e979a5 -r cf6a910e3663 
tools/python/xen/xend/server/DevConstants.py
--- a/tools/python/xen/xend/server/DevConstants.py      Mon Mar 09 10:32:24 
2009 +0000
+++ b/tools/python/xen/xend/server/DevConstants.py      Wed Mar 11 18:03:47 
2009 +0900
@@ -40,6 +40,7 @@
     'Closed'        : 6,
     'Reconfiguring' : 7,
     'Reconfigured'  : 8,
+    'Attached'      : 9,
     }
 xenbusState.update(dict(zip(xenbusState.values(), xenbusState.keys())))

diff -r b249f3e979a5 -r cf6a910e3663 
tools/python/xen/xend/server/DevController.py
--- a/tools/python/xen/xend/server/DevController.py     Mon Mar 09 10:32:24 
2009 +0000
+++ b/tools/python/xen/xend/server/DevController.py     Wed Mar 11 18:03:47 
2009 +0900
@@ -176,6 +176,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)

@@ -473,6 +526,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 b249f3e979a5 -r cf6a910e3663 tools/python/xen/xend/server/vfbif.py
--- a/tools/python/xen/xend/server/vfbif.py     Mon Mar 09 10:32:24 2009 +0000
+++ b/tools/python/xen/xend/server/vfbif.py     Wed Mar 11 18:03:47 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

diff -r b249f3e979a5 -r cf6a910e3663 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Mon Mar 09 10:32:24 2009 +0000
+++ b/tools/python/xen/xend/XendDomainInfo.py   Wed Mar 11 18:03:47 2009 +0900
@@ -1018,6 +1018,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)



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