def remove_PPCI(self, pci_name): # Update lspci info PciUtil.create_lspci_info() # Remove the PPCI (domain, bus, slot, func) = PciUtil.parse_pci_name(pci_name) ppci_ref = XendPPCI.get_by_sbdf(domain, bus, slot, func) XendAPIStore.get(ppci_ref, "PPCI").destroy() self.save_PPCIs()
def add_PPCI(self, pci_name): # Update lspci info PciUtil.create_lspci_info() # Initialise the PPCI saved_ppcis = self.state_store.load_state('ppci') saved_ppci_table = {} if saved_ppcis: for ppci_uuid, ppci_record in saved_ppcis.items(): try: saved_ppci_table[ppci_record['name']] = ppci_uuid except KeyError: pass (domain, bus, slot, func) = PciUtil.parse_pci_name(pci_name) pci_dev = PciUtil.PciDevice(domain, bus, slot, func) ppci_record = { 'domain': pci_dev.domain, 'bus': pci_dev.bus, 'slot': pci_dev.slot, 'func': pci_dev.func, 'vendor_id': pci_dev.vendor, 'vendor_name': pci_dev.vendorname, 'device_id': pci_dev.device, 'device_name': pci_dev.devicename, 'revision_id': pci_dev.revision, 'class_code': pci_dev.classcode, 'class_name': pci_dev.classname, 'subsystem_vendor_id': pci_dev.subvendor, 'subsystem_vendor_name': pci_dev.subvendorname, 'subsystem_id': pci_dev.subdevice, 'subsystem_name': pci_dev.subdevicename, 'driver': pci_dev.driver } # If saved uuid exists, use it. Otherwise create one. ppci_uuid = saved_ppci_table.get(pci_dev.name, uuid.createString()) XendPPCI(ppci_uuid, ppci_record) self.save_PPCIs()
def add_PPCI(self, pci_name): # Update lspci info PciUtil.create_lspci_info() # Initialise the PPCI saved_ppcis = self.state_store.load_state('ppci') saved_ppci_table = {} if saved_ppcis: for ppci_uuid, ppci_record in saved_ppcis.items(): try: saved_ppci_table[ppci_record['name']] = ppci_uuid except KeyError: pass pci_dev = PciUtil.PciDevice(PciUtil.parse_pci_name(pci_name)) ppci_record = { 'domain': pci_dev.domain, 'bus': pci_dev.bus, 'slot': pci_dev.slot, 'func': pci_dev.func, 'vendor_id': pci_dev.vendor, 'vendor_name': pci_dev.vendorname, 'device_id': pci_dev.device, 'device_name': pci_dev.devicename, 'revision_id': pci_dev.revision, 'class_code': pci_dev.classcode, 'class_name': pci_dev.classname, 'subsystem_vendor_id': pci_dev.subvendor, 'subsystem_vendor_name': pci_dev.subvendorname, 'subsystem_id': pci_dev.subdevice, 'subsystem_name': pci_dev.subdevicename, 'driver': pci_dev.driver } # If saved uuid exists, use it. Otherwise create one. ppci_uuid = saved_ppci_table.get(pci_dev.name, uuid.createString()) XendPPCI(ppci_uuid, ppci_record) self.save_PPCIs()