[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] Fix pci passthru in xend interface used by libvirt



# HG changeset patch
# User Jim Fehlig <jfehlig@xxxxxxxxxx>
# Date 1289233462 0
# Node ID 2c32482d8c90eb2b51c708fd770e19bbdfb5d2b6
# Parent  d8b8490d73ded5787c4e1cd10b2f29c9e4be3632
Fix pci passthru in xend interface used by libvirt

Attempting to define or create a domain whose XML config contains a
passthru PCI device fails with libvirt

xen84: # cat win2k8r2.xml
...
   <hostdev mode='subsystem' type='pci' managed='no'>
      <source>
        <address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
      </source>
    </hostdev>
...

xen84: # virsh create ./win2k8r2.xml
error: Failed to create domain from ./win2k8r2.xml
error: POST operation failed: xend_post: error from xen daemon:
  (xend.err "Error creating domain: 'key'")

The PCI device config maintained by xend includes a 'key' field, which is
initialized by xm client when using that tool and traditional xen config
file.  libvirt, which uses xend's sexpr-over-http interface (is that the
proper name for that interface??), does not initialize this field - and
shouldn't be expected to do so IMO.  Clients should not be bothered with
xend's internal representation of a PCI device.

This patch populates the 'key' field within xend if it is uninitialized,
similar to current initialization of 'uuid' field.  The 'vdevfn' field
suffers a similar problem if not (optionally) specified by user.
AFAICT, the xm client initializes 'vdevfn' to 0x100 if not specified so
I've done the same here.

Signed-off-by: Jim Fehlig <jfehlig@xxxxxxxxxx>
Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 tools/python/xen/util/pci.py |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff -r d8b8490d73de -r 2c32482d8c90 tools/python/xen/util/pci.py
--- a/tools/python/xen/util/pci.py      Mon Nov 08 15:44:02 2010 +0000
+++ b/tools/python/xen/util/pci.py      Mon Nov 08 16:24:22 2010 +0000
@@ -240,10 +240,16 @@ def pci_convert_sxp_to_dict(dev_sxp):
         pci_dev_info = dict(pci_dev[1:])
         if 'opts' in pci_dev_info:
             pci_dev_info['opts'] = pci_opts_list_from_sxp(pci_dev)
-        # append uuid to each pci device that does't already have one.
+        # If necessary, initialize uuid, key, and vdevfn for each pci device
         if not pci_dev_info.has_key('uuid'):
-            dpci_uuid = pci_dev_info.get('uuid', uuid.createString())
-            pci_dev_info['uuid'] = dpci_uuid
+            pci_dev_info['uuid'] = uuid.createString()
+        if not pci_dev_info.has_key('key'):
+            pci_dev_info['key'] = "%02x:%02x.%x" % \
+            (int(pci_dev_info['bus'], 16),
+             int(pci_dev_info['slot'], 16),
+             int(pci_dev_info['func'], 16))
+        if not pci_dev_info.has_key('vdevfn'):
+            pci_dev_info['vdevfn'] =  "0x%02x" % AUTO_PHP_SLOT
         pci_devs.append(pci_dev_info)
     dev_config['devs'] = pci_devs
 

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.