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

[Xen-devel] [rfc 6/9] xend: pass-through: Add key to pci device dictionary



This will be used to identify the functions belonging to
a multi-function device.

Cc: Dexuan Cui <dexuan.cui@xxxxxxxxx>
Cc: Masaki Kanno <kanno.masaki@xxxxxxxxxxxxxx>
Signed-off-by: Simon Horman <horms@xxxxxxxxxxxx>

--- 

 tools/python/xen/util/pci.py            |    3 ++-
 tools/python/xen/xend/XendConfig.py     |    3 ++-
 tools/python/xen/xend/XendDPCI.py       |    8 +++++++-
 tools/python/xen/xend/XendDomainInfo.py |    1 +
 tools/python/xen/xend/server/pciif.py   |    8 ++++++--
 tools/python/xen/xm/create.dtd          |    3 ++-
 tools/python/xen/xm/create.py           |    7 ++++---
 tools/python/xen/xm/main.py             |   10 +++++++---
 tools/python/xen/xm/xenapi_create.py    |    6 +++++-
 9 files changed, 36 insertions(+), 13 deletions(-)

Index: xen-unstable.hg/tools/python/xen/xend/XendDomainInfo.py
===================================================================
--- xen-unstable.hg.orig/tools/python/xen/xend/XendDomainInfo.py        
2009-06-15 11:24:56.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/xend/XendDomainInfo.py     2009-06-15 
11:25:00.000000000 +1000
@@ -3733,6 +3733,7 @@ class XendDomainInfo:
                    ['slot', '0x%02x' % ppci.get_slot()],
                    ['func', '0x%1x' % ppci.get_func()],
                    ['vslot', '0x%02x' % xenapi_pci.get('hotplug_slot')],
+                   ['key', xenapi_pci['key']],
                    ['uuid', dpci_uuid]]
         dev_sxp = sxp.merge(dev_sxp, opts_sxp)
 
Index: xen-unstable.hg/tools/python/xen/xm/main.py
===================================================================
--- xen-unstable.hg.orig/tools/python/xen/xm/main.py    2009-06-15 
11:24:59.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/xm/main.py 2009-06-15 11:25:00.000000000 
+1000
@@ -2182,7 +2182,8 @@ def attached_pci_dict_bin(dom):
                 'bus':    int(ppci_record['bus']),
                 'slot':   int(ppci_record['slot']),
                 'func':   int(ppci_record['func']),
-                'vslot':  int(server.xenapi.DPCI.get_hotplug_slot(dpci_ref))
+                'vslot':  int(server.xenapi.DPCI.get_hotplug_slot(dpci_ref)),
+                'key':    server.xenapi.DPCI.get_key(dpci_ref)
             }
             devs.append(dev)
 
@@ -2193,7 +2194,8 @@ def attached_pci_dict_bin(dom):
                 'bus':    int(x['bus'], 16),
                 'slot':   int(x['slot'], 16),
                 'func':   int(x['func'], 16),
-                'vslot':  int(x['vslot'], 16)
+                'vslot':  int(x['vslot'], 16),
+                'key':    x['key']
             }
             devs.append(dev)
 
@@ -2539,6 +2541,7 @@ def xm_pci_attach(args):
         slot = int(sxp.child_value(pci_dev, 'slot'), 16)
         func = int(sxp.child_value(pci_dev, 'func'), 16)
         vslot = int(sxp.child_value(pci_dev, 'vslot'), 16)
+        key = sxp.child_value(pci_dev, 'key')
         name = "%04x:%02x:%02x.%01x" % (domain, bus, slot, func)
 
         target_ref = None
@@ -2553,7 +2556,8 @@ def xm_pci_attach(args):
             "VM":           get_single_vm(dom),
             "PPCI":         target_ref,
             "hotplug_slot": vslot,
-            "options":      dict(config_pci_opts)
+            "options":      dict(config_pci_opts),
+            "key":          key
         }
         server.xenapi.DPCI.create(dpci_record)
 
Index: xen-unstable.hg/tools/python/xen/util/pci.py
===================================================================
--- xen-unstable.hg.orig/tools/python/xen/util/pci.py   2009-06-15 
11:24:53.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/util/pci.py        2009-06-15 
11:25:00.000000000 +1000
@@ -284,7 +284,7 @@ def parse_pci_name_extended(pci_dev_str)
     template['domain'] = "0x%04x" % domain
     template['bus']    = "0x%02x" % int(pci_dev_info['bus'], 16)
     template['slot']   = "0x%02x" % int(pci_dev_info['slot'], 16)
-    template['func']   = "0x%x"   % int(pci_dev_info['func'], 16)
+    template['key']    = pci_dev_str
     if pci_dev_info['opts'] != '':
         template['opts'] = split_pci_opts(pci_dev_info['opts'])
         check_pci_opts(template['opts'])
@@ -297,6 +297,7 @@ def parse_pci_name_extended(pci_dev_str)
                                       pci_dev_info['func'])
     for func in func_list:
         pci_dev = template.copy()
+        pci_dev['func'] = "0x%x" % func
 
         if len(func_list) == 1:
             # For single-function devices vfunc must be 0
Index: xen-unstable.hg/tools/python/xen/xend/XendConfig.py
===================================================================
--- xen-unstable.hg.orig/tools/python/xen/xend/XendConfig.py    2009-06-15 
11:24:53.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/xend/XendConfig.py 2009-06-15 
11:25:00.000000000 +1000
@@ -1237,7 +1237,8 @@ class XendConfig(dict):
             dpci_record = {
                 'VM': self['uuid'],
                 'PPCI': ppci_uuid,
-                'hotplug_slot': pci_dev.get('vslot', '0x%02x' % AUTO_PHP_SLOT)
+                'hotplug_slot': pci_dev.get('vslot', '0x%02x' % AUTO_PHP_SLOT),
+                'key': pci_dev['key']
             }
 
             dpci_opts = pci_dev.get('opts')
Index: xen-unstable.hg/tools/python/xen/xend/XendDPCI.py
===================================================================
--- xen-unstable.hg.orig/tools/python/xen/xend/XendDPCI.py      2009-06-15 
11:23:57.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/xend/XendDPCI.py   2009-06-15 
11:25:00.000000000 +1000
@@ -42,6 +42,7 @@ class XendDPCI(XendBase):
                   'VM',
                   'PPCI',
                   'hotplug_slot',
+                  'key',
                   'options']
         return XendBase.getAttrRO() + attrRO
 
@@ -52,7 +53,8 @@ class XendDPCI(XendBase):
     def getAttrInst(self):
         attrInst = ['VM',
                     'PPCI',
-                    'hotplug_slot']
+                    'hotplug_slot',
+                    'key']
         return XendBase.getAttrInst() + attrInst
 
     def getMethods(self):
@@ -120,6 +122,7 @@ class XendDPCI(XendBase):
         self.VM = record['VM']
         self.PPCI = record['PPCI']
         self.hotplug_slot = int(record['hotplug_slot'], 16)
+        self.key = record['key']
         if 'options' in record.keys():
             self.options = record['options']
 
@@ -155,5 +158,8 @@ class XendDPCI(XendBase):
     def get_hotplug_slot(self):
         return "%d" % self.hotplug_slot
 
+    def get_key(self):
+        return self.key
+
     def get_options(self):
         return self.options
Index: xen-unstable.hg/tools/python/xen/xend/server/pciif.py
===================================================================
--- xen-unstable.hg.orig/tools/python/xen/xend/server/pciif.py  2009-06-15 
11:24:53.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/xend/server/pciif.py       2009-06-15 
11:25:00.000000000 +1000
@@ -83,6 +83,7 @@ class PciController(DevController):
             back['dev-%i' % pcidevid] = "%04x:%02x:%02x.%01x" % \
                                         (domain, bus, slot, func)
             back['uuid-%i' % pcidevid] = pci_config.get('uuid', '')
+            back['key-%i' % pcidevid] = pci_config.get('key', '')
             back['vslot-%i' % pcidevid] = "%02x" % vslot
             pcidevid += 1
 
@@ -113,6 +114,7 @@ class PciController(DevController):
                 dev = back['dev-%i' % i]
                 state = states[i]
                 uuid = back['uuid-%i' %i]
+                key = back['key-%i' %i]
                 opts = ''
                 if 'opts-%i' % i in back:
                     opts = back['opts-%i' % i]
@@ -135,6 +137,7 @@ class PciController(DevController):
                 self.writeBackend(devid, 'state-%i' % devno,
                                   str(xenbusState['Initialising']))
                 self.writeBackend(devid, 'uuid-%i' % devno, uuid)
+                self.writeBackend(devid, 'key-%i' % devno, key)
                 if len(opts) > 0:
                     self.writeBackend(devid, 'opts-%i' % devno, opts)
                 if back.has_key('vslot-%i' % i):
@@ -173,6 +176,7 @@ class PciController(DevController):
 
             # Per device uuid info
             pci_dev['uuid'] = self.readBackend(devid, 'uuid-%d' % i)
+            pci_dev['key'] = self.readBackend(devid, 'key-%d' % i)
             pci_dev['vslot'] = '0x%s' % self.readBackend(devid, 'vslot-%d' % i)
 
             #append opts info
@@ -500,7 +504,7 @@ class PciController(DevController):
                 # In HVM case, I/O resources are disabled in ioemu.
                 self.cleanupOneDevice(pci_dev)
                 # Remove xenstore nodes.
-                list = ['dev', 'vdev', 'state', 'uuid', 'vslot']
+                list = ['dev', 'vdev', 'state', 'uuid', 'vslot', 'key']
                 if self.readBackend(devid, 'opts-%i' % i) is not None:
                     list.append('opts')
                 for key in list:
@@ -510,7 +514,7 @@ class PciController(DevController):
                 if new_num_devs == i + 1:
                     continue
 
-                list = ['dev', 'vdev', 'state', 'uuid', 'opts', 'vslot']
+                list = ['dev', 'vdev', 'state', 'uuid', 'opts', 'vslot', 'key']
                 for key in list:
                     tmp = self.readBackend(devid, '%s-%i' % (key, i))
                     if tmp is None:
Index: xen-unstable.hg/tools/python/xen/xm/create.dtd
===================================================================
--- xen-unstable.hg.orig/tools/python/xen/xm/create.dtd 2009-06-15 
11:23:57.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/xm/create.dtd      2009-06-15 
11:25:00.000000000 +1000
@@ -90,7 +90,8 @@
                  slot            CDATA #REQUIRED
                  func            CDATA #REQUIRED
                  opts_str        CDATA #IMPLIED
-                 vslot           CDATA #IMPLIED>
+                 vslot           CDATA #IMPLIED
+                 key             CDATA #IMPLIED>
 
 <!ELEMENT vscsi  EMPTY>
 <!ATTLIST vscsi  p-dev           CDATA #REQUIRED
Index: xen-unstable.hg/tools/python/xen/xm/xenapi_create.py
===================================================================
--- xen-unstable.hg.orig/tools/python/xen/xm/xenapi_create.py   2009-06-15 
11:24:25.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/xm/xenapi_create.py        2009-06-15 
11:25:00.000000000 +1000
@@ -543,7 +543,9 @@ class xenapi_create:
                 int(pci.attributes["vslot"].value, 16),
             "options":
                 get_child_nodes_as_dict(pci,
-                  "pci_opt", "key", "value")
+                  "pci_opt", "key", "value"),
+            "key":
+                pci.attributes["key"].value
         }
 
         return server.xenapi.DPCI.create(dpci_record)
@@ -946,6 +948,8 @@ class sxp2xml:
                     = get_child_by_name(dev_sxp, "func", "0")
                 pci.attributes["vslot"] \
                     = get_child_by_name(dev_sxp, "vslot", "0")
+                pci.attributes["key"] \
+                    = get_child_by_name(dev_sxp, "key", "0")
                 for opt in pci_opts_list_from_sxp(dev_sxp):
                     pci_opt = document.createElement("pci_opt")
                     pci_opt.attributes["key"] = opt[0]
Index: xen-unstable.hg/tools/python/xen/xm/create.py
===================================================================
--- xen-unstable.hg.orig/tools/python/xen/xm/create.py  2009-06-15 
11:24:53.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/xm/create.py       2009-06-15 
11:25:00.000000000 +1000
@@ -1044,14 +1044,15 @@ def preprocess_cpuid(vals, attr_name):
 
 def pci_dict_to_tuple(dev):
     return (dev['domain'], dev['bus'], dev['slot'], dev['func'],
-            dev['vslot'], dev.get('opts', []))
+            dev['vslot'], dev.get('opts', []), dev['key'])
 
-def pci_tuple_to_dict((domain, bus, slot, func, vslot, opts)):
+def pci_tuple_to_dict((domain, bus, slot, func, vslot, opts, key)):
     pci_dev = { 'domain': domain,
                 'bus':    bus,
                 'slot':   slot,
                 'func':   func,
-                'vslot':  vslot}
+                'vslot':  vslot,
+                'key':    key}
     if len(opts) > 0:
         pci_dev['opts'] = opts
     return pci_dev

-- 

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


 


Rackspace

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