コード例 #1
0
ファイル: devspec.py プロジェクト: hsluoyz/patron
 def _init_address_fields(self, pci_addr):
     if self.is_physical_function:
         (self.domain, self.bus, self.slot,
          self.func) = utils.get_pci_address_fields(pci_addr)
         return
     dbs, sep, func = pci_addr.partition('.')
     if func:
         fstr = func.strip()
         if fstr != ANY:
             try:
                 f = get_value(fstr)
             except SyntaxError:
                 raise exception.PciDeviceWrongAddressFormat(
                     address=pci_addr)
             if f > MAX_FUNC:
                 raise exception.PciDeviceInvalidAddressField(
                     address=pci_addr, field="function")
             self.func = "%1x" % f
     if dbs:
         dbs_fields = dbs.split(':')
         if len(dbs_fields) > 3:
             raise exception.PciDeviceWrongAddressFormat(address=pci_addr)
         # If we got a partial address like ":00.", we need to to turn this
         # into a domain of ANY, a bus of ANY, and a slot of 00. This code
         # allows the address bus and/or domain to be left off
         dbs_all = [ANY for x in range(3 - len(dbs_fields))]
         dbs_all.extend(dbs_fields)
         dbs_checked = [s.strip() or ANY for s in dbs_all]
         self.domain, self.bus, self.slot = dbs_checked
         get_pci_dev_info(self, 'domain', MAX_DOMAIN, '%04x')
         get_pci_dev_info(self, 'bus', MAX_BUS, '%02x')
         get_pci_dev_info(self, 'slot', MAX_SLOT, '%02x')
         self._check_physical_function()
コード例 #2
0
ファイル: devspec.py プロジェクト: 2Exception/patron
 def _init_address_fields(self, pci_addr):
     if self.is_physical_function:
         (self.domain, self.bus, self.slot,
          self.func) = utils.get_pci_address_fields(pci_addr)
         return
     dbs, sep, func = pci_addr.partition('.')
     if func:
         fstr = func.strip()
         if fstr != ANY:
             try:
                 f = get_value(fstr)
             except SyntaxError:
                 raise exception.PciDeviceWrongAddressFormat(
                     address=pci_addr)
             if f > MAX_FUNC:
                 raise exception.PciDeviceInvalidAddressField(
                     address=pci_addr, field="function")
             self.func = "%1x" % f
     if dbs:
         dbs_fields = dbs.split(':')
         if len(dbs_fields) > 3:
             raise exception.PciDeviceWrongAddressFormat(address=pci_addr)
         # If we got a partial address like ":00.", we need to to turn this
         # into a domain of ANY, a bus of ANY, and a slot of 00. This code
         # allows the address bus and/or domain to be left off
         dbs_all = [ANY for x in range(3 - len(dbs_fields))]
         dbs_all.extend(dbs_fields)
         dbs_checked = [s.strip() or ANY for s in dbs_all]
         self.domain, self.bus, self.slot = dbs_checked
         get_pci_dev_info(self, 'domain', MAX_DOMAIN, '%04x')
         get_pci_dev_info(self, 'bus', MAX_BUS, '%02x')
         get_pci_dev_info(self, 'slot', MAX_SLOT, '%02x')
         self._check_physical_function()
コード例 #3
0
ファイル: devspec.py プロジェクト: 2Exception/patron
 def match(self, pci_addr, pci_phys_addr):
     # Assume this is called given pci_add and pci_phys_addr from libvirt,
     # no attempt is made to verify pci_addr is a VF of pci_phys_addr
     if self.is_physical_function:
         if not pci_phys_addr:
             return False
         domain, bus, slot, func = (
             utils.get_pci_address_fields(pci_phys_addr))
         return (self.domain == domain and self.bus == bus
                 and self.slot == slot and self.func == func)
     else:
         domain, bus, slot, func = (utils.get_pci_address_fields(pci_addr))
         conditions = [
             self.domain in (ANY, domain), self.bus in (ANY, bus), self.slot
             in (ANY, slot), self.func in (ANY, func)
         ]
         return all(conditions)
コード例 #4
0
ファイル: devspec.py プロジェクト: hsluoyz/patron
 def match(self, pci_addr, pci_phys_addr):
     # Assume this is called given pci_add and pci_phys_addr from libvirt,
     # no attempt is made to verify pci_addr is a VF of pci_phys_addr
     if self.is_physical_function:
         if not pci_phys_addr:
             return False
         domain, bus, slot, func = (
             utils.get_pci_address_fields(pci_phys_addr))
         return (self.domain == domain and self.bus == bus and
                 self.slot == slot and self.func == func)
     else:
         domain, bus, slot, func = (
             utils.get_pci_address_fields(pci_addr))
         conditions = [
             self.domain in (ANY, domain),
             self.bus in (ANY, bus),
             self.slot in (ANY, slot),
             self.func in (ANY, func)
         ]
         return all(conditions)