def test_get_interface_by_cfg_hostdev_pci(self): self.domain.XMLDesc.return_value = """<domain> <devices> <hostdev mode='subsystem' type='pci' managed='yes'> <driver name='vfio'/> <source> <address domain='0x0000' bus='0x81' slot='0x00' function='0x1'/> </source> <alias name='hostdev0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </hostdev> </devices> </domain>""" cfg = vconfig.LibvirtConfigGuestHostdevPCI() cfg.parse_str(""" <hostdev mode='subsystem' type='pci' managed='yes'> <driver name='vfio'/> <source> <address domain='0x0000' bus='0x81' slot='0x00' function='0x1'/> </source> </hostdev>""") self.assertIsNotNone(self.guest.get_interface_by_cfg(cfg)) cfg.parse_str(""" <hostdev mode='subsystem' type='pci' managed='yes'> <driver name='vfio'/> <source> <address domain='0000' bus='81' slot='00' function='1'/> </source> </hostdev>""") self.assertIsNotNone(self.guest.get_interface_by_cfg(cfg)) self.assertIsNone(self.guest.get_interface_by_cfg(None))
def get_base_hostdev_pci_config(self, vif): conf = vconfig.LibvirtConfigGuestHostdevPCI() pci_slot = vif['profile']['pci_slot'] designer.set_vif_host_backend_hostdev_pci_config(conf, pci_slot) return conf
def get_config_ib_hostdev(self, instance, vif, image_meta, inst_type, virt_type, host): conf = vconfig.LibvirtConfigGuestHostdevPCI() pci_slot = vif['profile']['pci_slot'] designer.set_vif_host_backend_ib_hostdev_config(conf, pci_slot) return conf