Skip to contentSkip to conversation

xend: pass-through: device state in xenstore may be null

PATCH New Simon Horman 1 participant 1 message Jul 27, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xend: pass-through: device state in xenstore may be null

From: Tom Rotenberg <[email protected]>

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'

---

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.

tools/python/xen/xend/server/pciif.py +5 -1
Index: xen-unstable.hg/tools/python/xen/xend/server/pciif.py
===================================================================
@@ -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))