From mboxrd@z Thu Jan 1 00:00:00 1970 From: Simon Horman Subject: [patch] xend: pass-through: device state in xenstore may be null Date: Mon, 27 Jul 2009 19:35:46 +1000 Message-ID: <20090727093545.GA29786@verge.net.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline 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@lists.xensource.com Cc: Tom Rotenberg List-Id: xen-devel@lists.xenproject.org From: Tom Rotenberg This patch was proposed by Tom Rotenberg to fix a bug that he found. After devices are inserted into xenstore using _createDevices() they may not have a state entry. This is a problem for cleanupDevices() which is called when PCI devices are passed-through. This patch seems to be correct as with it applied cleanupDevices() simply ignores the state if it is unknown. The confusing part about this problem is that on Tom's system devices don't have state entries and on my system they have have state=3 (Initialised). The latter seems to be wrong. Error Log: Traceback (most recent call last): File "usr/lib/python2.5/site-packages/xen/xend/XendDomainInfo.py", line 99, in create vm.start() File "usr/lib/python2.5/site-packages/xen/xend/XendDomainInfo.py", line 459, in start XendTask.log_progress(31, 60, self._initDomain) File "usr/lib/python2.5/site-packages/xen/xend/XendTask.py", line 209, in log_progress retval = func(*args, **kwds) File "usr/lib/python2.5/site-packages/xen/xend/XendDomainInfo.py", line 2544, in _initDomain self._createDevices() File "usr/lib/python2.5/site-packages/xen/xend/XendDomainInfo.py", line 2170, in _createDevices self.pci_device_configure_boot() File "usr/lib/python2.5/site-packages/xen/xend/XendDomainInfo.py", line 594, in pci_device_configure_boot self.pci_device_configure(dev_sxp) File "usr/lib/python2.5/site-packages/xen/xend/XendDomainInfo.py", line 876, in pci_device_configure num_devs = dev_control.cleanupDevice(devid) File "usr/lib/python2.5/site-packages/xen/xend/server/pciif.py", line 502, in cleanupDevice state = int(self.readBackend(devid, 'state-%i' % i)) TypeError: int() argument must be a string or a number, not 'NoneType' Cc: Tom Rotenberg Signed-off-by: Tom Rotenberg --- This patch is applicable to the pass-through backport to xen-3.4-testing. Accordingly I have pushed it to the following trees: * http://hg.vergenet.net/xen/xen-3.4-testing-pass-through-multi-function/ * http://hg.vergenet.net/xen/xen-3.4-testing-pass-through/ It is also applicable to xen-unstable.hg. Index: xen-unstable.hg/tools/python/xen/xend/server/pciif.py =================================================================== --- xen-unstable.hg.orig/tools/python/xen/xend/server/pciif.py 2009-07-14 15:12:46.000000000 +1000 +++ xen-unstable.hg/tools/python/xen/xend/server/pciif.py 2009-07-27 18:55:14.000000000 +1000 @@ -489,7 +489,11 @@ class PciController(DevController): num_devs = int(self.readBackend(devid, 'num_devs')) new_num_devs = 0 for i in range(num_devs): - state = int(self.readBackend(devid, 'state-%i' % i)) + try: + state = int(self.readBackend(devid, 'state-%i' % i)) + except: + state = xenbusState['Unknown'] + if state == xenbusState['Closing']: # Detach I/O resources. pci_dev = parse_pci_name(self.readBackend(devid, 'dev-%i' % i))