XenAPI: Add Direct PCI Assignment (DPCI) Support
PATCH 2/3 XenAPI: Add Direct PCI Assignment (DPCI) Support
Add direct pci device assignment support.
This patch depends on the previous patch (1/3).
-----------------------------------------
Fields for DPCI class:
(RO_inst) VM
PPCI
hotplug_slot <- same as vslot param of pci-attach/detach.
(RO_run) virtual_domain
virtual_bus
virtual_slot
virtual_func
virtual_name <- domain:bus:slot:func that is seen from guest.
RPCs for DPCI class:
create(session_id, dpci_record) destroy(session_id, dpci_ref)
-----------------------------------------
Regards,
-----------------------
Yosuke Iwamatsu
NEC Corporation
XenAPI: Add Direct PCI Device (DPCI) Assignment Support
tools/python/xen/xend/XendAPI.py +9 -0
@@ -41,6 +41,7 @@ from XendPIF import XendPIF from XendPIF import XendPIF from XendPBD import XendPBD from XendPPCI import XendPPCI +from XendDPCI import XendDPCI from XendXSPolicy import XendXSPolicy, XendACMPolicy from XendAPIConstants import *
@@ -479,6 +480,7 @@ classes = { 'PBD' : valid_object("PBD"), 'PIF_metrics' : valid_object("PIF_metrics"), 'PPCI' : valid_object("PPCI"), + 'DPCI' : valid_object("DPCI") } autoplug_classes = {
@@ -488,6 +490,7 @@ autoplug_classes = { 'PBD' : XendPBD, 'PIF_metrics' : XendPIFMetrics, 'PPCI' : XendPPCI, + 'DPCI' : XendDPCI, 'XSPolicy' : XendXSPolicy, 'ACMPolicy' : XendACMPolicy, }
@@ -1154,6 +1157,7 @@ class XendAPI(object): 'VIFs', 'VBDs', 'VTPMs', + 'DPCIs', 'tools_version', 'domid', 'is_control_domain',
@@ -1296,6 +1300,10 @@ class XendAPI(object): dom = XendDomain.instance().get_vm_by_uuid(vm_ref) return xen_api_success(dom.get_consoles()) + def VM_get_DPCIs(self, session, vm_ref): + dom = XendDomain.instance().get_vm_by_uuid(vm_ref) + return xen_api_success(dom.get_dpcis()) + def VM_get_tools_version(self, session, vm_ref): dom = XendDomain.instance().get_vm_by_uuid(vm_ref) return dom.get_tools_version()
@@ -1675,6 +1683,7 @@ class XendAPI(object): 'VIFs': xeninfo.get_vifs(), 'VBDs': xeninfo.get_vbds(), 'VTPMs': xeninfo.get_vtpms(), + 'DPCIs': xeninfo.get_dpcis(), 'PV_bootloader': xeninfo.info.get('PV_bootloader'), 'PV_kernel': xeninfo.info.get('PV_kernel'), 'PV_ramdisk': xeninfo.info.get('PV_ramdisk'),
tools/python/xen/xend/XendConfig.py +121 -38
197 lines not on this page · raw message
tools/python/xen/xend/XendDPCI.py new file +154 -0
154 lines not on this page · raw message
tools/python/xen/xend/XendDomain.py +3 -0
@@ -478,6 +478,8 @@ class XendDomain: if domid in self.domains: del self.domains[domid] + + info.destroy_xapi_device_instances() else: log.warning("Attempted to remove non-existent domain.")
@@ -1091,6 +1093,7 @@ class XendDomain: self._managed_domain_unregister(dominfo) self._remove_domain(dominfo) XendDevices.destroy_device_state(dominfo) + dominfo.destroy_xapi_device_instances() def domain_configure(self, config):
tools/python/xen/xend/XendDomainInfo.py +126 -45
213 lines not on this page · raw message
tools/python/xen/xend/XendError.py +11 -0
@@ -174,6 +174,17 @@ class NetworkError(XendAPIError): def __str__(self): return 'NETWORK_ERROR: %s %s' % (self.error, self.network) + +class DirectPCIError(XendAPIError): + def __init__(self, error): + XendAPIError.__init__(self) + self.error = error + + def get_api_error(self): + return ['DIRECT_PCI_ERROR', self.error] + + def __str__(self): + return 'DIRECT_PCI_ERROR: %s' % self.error from xen.util.xsconstants import xserr2string
tools/python/xen/xend/server/pciif.py +11 -1
@@ -76,6 +76,7 @@ class PciController(DevController): back['dev-%i' % pcidevid] = "%04x:%02x:%02x.%02x" % \ (domain, bus, slot, func) + back['uuid-%i' % pcidevid] = pci_config.get('uuid', '') pcidevid += 1 if vslots != "":
@@ -101,6 +102,7 @@ class PciController(DevController): try: dev = back['dev-%i' % i] state = states[i] + uuid = back['uuid-%i' %i] except: raise XendError('Error reading config')
@@ -121,6 +123,7 @@ class PciController(DevController): self.writeBackend(devid, 'dev-%i' % (num_olddevs + i), dev) self.writeBackend(devid, 'state-%i' % (num_olddevs + i), str(xenbusState['Initialising'])) + self.writeBackend(devid, 'uuid-%i' % (num_olddevs + i), uuid) self.writeBackend(devid, 'num_devs', str(num_olddevs + i + 1)) # Update vslots
@@ -141,7 +144,7 @@ class PciController(DevController): raise XendError('Device %s is not connected' % dev) # Update vslots - if back['vslots'] is not None: + if back.get('vslots') is not None: vslots = old_vslots for vslt in back['vslots'].split(';'): if vslt != '':
@@ -185,6 +188,9 @@ class PciController(DevController): 'bus': '0x%(bus)s' % pci_dev_info, 'slot': '0x%(slot)s' % pci_dev_info, 'func': '0x%(func)s' % pci_dev_info} + + # Per device uuid info + dev_dict['uuid'] = self.readBackend(devid, 'uuid-%d' % i) #append vslot info if vslots is not None:
@@ -442,6 +448,7 @@ class PciController(DevController): self.removeBackend(devid, 'dev-%i' % i) self.removeBackend(devid, 'vdev-%i' % i) self.removeBackend(devid, 'state-%i' % i) + self.removeBackend(devid, 'uuid-%i' % i) else: if new_num_devs != i: tmpdev = self.readBackend(devid, 'dev-%i' % i)
@@ -455,6 +462,9 @@ class PciController(DevController): tmpstate = self.readBackend(devid, 'state-%i' % i) self.writeBackend(devid, 'state-%i' % new_num_devs, tmpstate) self.removeBackend(devid, 'state-%i' % i) + tmpuuid = self.readBackend(devid, 'uuid-%i' % i) + self.writeBackend(devid, 'uuid-%i' % new_num_devs, tmpuuid) + self.removeBackend(devid, 'uuid-%i' % i) new_num_devs = new_num_devs + 1 self.writeBackend(devid, 'num_devs', str(new_num_devs))
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel