From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yoshiaki Tamura Subject: [RFC][PATCH 08/13] Kemari: add dev state "Attached" to python Date: Thu, 12 Mar 2009 10:19:54 +0900 Message-ID: <49B8633A.5090202@lab.ntt.co.jp> References: <49B86208.2020205@lab.ntt.co.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <49B86208.2020205@lab.ntt.co.jp> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel Cc: =?ISO-2022-JP?B?IhskQkx4XzcyQk4kGyhCKHlhbmFnaXNhd2EgeW9zaGlzYXRvKSI=?= , Ian Pratt , ian.jackson@eu.citrix.com, Keir Fraser , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org 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 Signed-off-by: Yoshi Tamura --- 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)