ia64/xen-unstable

changeset 19007:989bd3f2fd72

pci: add pci option support for XenAPI sever

Allow the per-device options for passthrough pci devices
This patch is for XenAPI server

A new key-value pair element of 'pci' named 'pci_opt' is added
to xml config file

Signed-off-by: Qing He <qing.he@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jan 08 11:26:16 2009 +0000 (2009-01-08)
parents 13c8e6bac9ab
children 3a92e1a446d9
files tools/python/xen/xend/XendConfig.py tools/python/xen/xend/XendDPCI.py tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xm/create.dtd tools/python/xen/xm/main.py tools/python/xen/xm/xenapi_create.py
line diff
     1.1 --- a/tools/python/xen/xend/XendConfig.py	Thu Jan 08 11:25:43 2009 +0000
     1.2 +++ b/tools/python/xen/xend/XendConfig.py	Thu Jan 08 11:26:16 2009 +0000
     1.3 @@ -1247,6 +1247,11 @@ class XendConfig(dict):
     1.4                          'PPCI': ppci_uuid,
     1.5                          'hotplug_slot': pci_dev.get('vslot', 0)
     1.6                      }
     1.7 +
     1.8 +                    dpci_opts = pci_dev.get('opts')
     1.9 +                    if dpci_opts and len(dpci_opts) > 0:
    1.10 +                        dpci_record['options'] = dpci_opts
    1.11 +
    1.12                      XendDPCI(dpci_uuid, dpci_record)
    1.13  
    1.14                  target['devices'][pci_devs_uuid] = (dev_type,
    1.15 @@ -1762,6 +1767,11 @@ class XendConfig(dict):
    1.16                          'PPCI': ppci_uuid,
    1.17                          'hotplug_slot': pci_dev.get('vslot', 0)
    1.18                      }
    1.19 +
    1.20 +                    dpci_opts = pci_dev.get('opts')
    1.21 +                    if dpci_opts and len(dpci_opts) > 0:
    1.22 +                        dpci_record['options'] = dpci_opts
    1.23 +
    1.24                      XendDPCI(dpci_uuid, dpci_record)
    1.25  
    1.26                  self['devices'][dev_uuid] = (dev_type,
     2.1 --- a/tools/python/xen/xend/XendDPCI.py	Thu Jan 08 11:25:43 2009 +0000
     2.2 +++ b/tools/python/xen/xend/XendDPCI.py	Thu Jan 08 11:26:16 2009 +0000
     2.3 @@ -41,7 +41,8 @@ class XendDPCI(XendBase):
     2.4                    'virtual_name',
     2.5                    'VM',
     2.6                    'PPCI',
     2.7 -                  'hotplug_slot']
     2.8 +                  'hotplug_slot',
     2.9 +                  'options']
    2.10          return XendBase.getAttrRO() + attrRO
    2.11  
    2.12      def getAttrRW(self):
    2.13 @@ -119,6 +120,8 @@ class XendDPCI(XendBase):
    2.14          self.VM = record['VM']
    2.15          self.PPCI = record['PPCI']
    2.16          self.hotplug_slot = record['hotplug_slot']
    2.17 +        if 'options' in record.keys():
    2.18 +            self.options = record['options']
    2.19  
    2.20      def destroy(self):
    2.21          xendom = XendDomain.instance()
    2.22 @@ -152,3 +155,5 @@ class XendDPCI(XendBase):
    2.23      def get_hotplug_slot(self):
    2.24          return self.hotplug_slot
    2.25  
    2.26 +    def get_options(self):
    2.27 +        return self.options
     3.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Thu Jan 08 11:25:43 2009 +0000
     3.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Thu Jan 08 11:26:16 2009 +0000
     3.3 @@ -3538,6 +3538,11 @@ class XendDomainInfo:
     3.4  
     3.5          dpci_uuid = uuid.createString()
     3.6  
     3.7 +        dpci_opts = []
     3.8 +        opts_dict = xenapi_pci.get('options')
     3.9 +        for k in opts_dict.keys():
    3.10 +            dpci_opts.append([k, opts_dict[k]])
    3.11 +
    3.12          # Convert xenapi to sxp
    3.13          ppci = XendAPIStore.get(xenapi_pci.get('PPCI'), 'PPCI')
    3.14  
    3.15 @@ -3549,6 +3554,7 @@ class XendDomainInfo:
    3.16                      ['slot', '0x%02x' % ppci.get_slot()],
    3.17                      ['func', '0x%1x' % ppci.get_func()],
    3.18                      ['vslt', '0x%02x' % xenapi_pci.get('hotplug_slot')],
    3.19 +                    ['opts', dpci_opts],
    3.20                      ['uuid', dpci_uuid]
    3.21                  ],
    3.22                  ['state', 'Initialising']
     4.1 --- a/tools/python/xen/xm/create.dtd	Thu Jan 08 11:25:43 2009 +0000
     4.2 +++ b/tools/python/xen/xm/create.dtd	Thu Jan 08 11:26:16 2009 +0000
     4.3 @@ -82,11 +82,12 @@
     4.4  <!ELEMENT vtpm   (name*)>
     4.5  <!ATTLIST vtpm   backend         CDATA #REQUIRED>
     4.6  
     4.7 -<!ELEMENT pci    EMPTY>
     4.8 +<!ELEMENT pci    (pci_opt*)>
     4.9  <!ATTLIST pci    domain          CDATA #REQUIRED
    4.10                   bus             CDATA #REQUIRED
    4.11                   slot            CDATA #REQUIRED
    4.12                   func            CDATA #REQUIRED
    4.13 +                 opts_str        CDATA #IMPLIED
    4.14                   vslt            CDATA #IMPLIED>
    4.15  
    4.16  <!ELEMENT vscsi  EMPTY>
    4.17 @@ -138,6 +139,10 @@
    4.18  <!ATTLIST vcpu_param key   CDATA #REQUIRED
    4.19                       value CDATA #REQUIRED>
    4.20  
    4.21 +<!ELEMENT pci_opt    EMPTY>
    4.22 +<!ATTLIST pci_opt    key   CDATA #REQUIRED
    4.23 +                     value CDATA #REQUIRED>
    4.24 +
    4.25  <!ELEMENT other_config EMPTY>
    4.26  <!ATTLIST other_config key   CDATA #REQUIRED
    4.27                         value CDATA #REQUIRED>
     5.1 --- a/tools/python/xen/xm/main.py	Thu Jan 08 11:25:43 2009 +0000
     5.2 +++ b/tools/python/xen/xm/main.py	Thu Jan 08 11:26:16 2009 +0000
     5.3 @@ -2499,7 +2499,8 @@ def xm_pci_attach(args):
     5.4          dpci_record = {
     5.5              "VM":           get_single_vm(dom),
     5.6              "PPCI":         target_ref,
     5.7 -            "hotplug_slot": vslt
     5.8 +            "hotplug_slot": vslt,
     5.9 +            "options":      dict([k, v] for k, v in config_pci_opts)
    5.10          }
    5.11          server.xenapi.DPCI.create(dpci_record)
    5.12  
     6.1 --- a/tools/python/xen/xm/xenapi_create.py	Thu Jan 08 11:25:43 2009 +0000
     6.2 +++ b/tools/python/xen/xm/xenapi_create.py	Thu Jan 08 11:26:16 2009 +0000
     6.3 @@ -533,7 +533,10 @@ class xenapi_create:
     6.4              "PPCI":
     6.5                  target_ref,
     6.6              "hotplug_slot":
     6.7 -                int(pci.attributes["func"].value, 16)
     6.8 +                int(pci.attributes["func"].value, 16),
     6.9 +            "options":
    6.10 +                get_child_nodes_as_dict(pci,
    6.11 +                  "pci_opt", "key", "value")
    6.12          }
    6.13  
    6.14          return server.xenapi.DPCI.create(dpci_record)
    6.15 @@ -931,6 +934,12 @@ class sxp2xml:
    6.16                      = get_child_by_name(dev_sxp, "func", "0")
    6.17                  pci.attributes["vslt"] \
    6.18                      = get_child_by_name(dev_sxp, "vslt", "0")
    6.19 +                for opt in get_child_by_name(dev_sxp, "opts", ""):
    6.20 +                    if len(opt) > 0:
    6.21 +                        pci_opt = document.createElement("pci_opt")
    6.22 +                        pci_opt.attributes["key"] = opt[0]
    6.23 +                        pci_opt.attributes["value"] = opt[1]
    6.24 +                        pci.appendChild(pci_opt)
    6.25  
    6.26                  pcis.append(pci)
    6.27