def _prepare_pci_devices_for_use(self, pci_devices):
    if (CONF.libvirt.virt_type != 'xen'):
        return
    try:
        for dev in pci_devices:
            libvirt_dev_addr = dev['hypervisor_name']
            libvirt_dev = self._conn.nodeDeviceLookupByName(libvirt_dev_addr)
            libvirt_dev.dettach()
        for dev in pci_devices:
            libvirt_dev_addr = dev['hypervisor_name']
            libvirt_dev = self._conn.nodeDeviceLookupByName(libvirt_dev_addr)
            libvirt_dev.reset()
    except libvirt.libvirtError as exc:
        raise exception.PciDevicePrepareFailed(id=dev['id'], instance_uuid=dev['instance_uuid'], reason=str(exc))
def _prepare_pci_devices_for_use(self, pci_devices):
    if (CONF.libvirt.virt_type != 'xen'):
        return
    try:
        for dev in pci_devices:
            libvirt_dev_addr = dev['hypervisor_name']
            libvirt_dev = self._conn.nodeDeviceLookupByName(libvirt_dev_addr)
            libvirt_dev.dettach()
        for dev in pci_devices:
            libvirt_dev_addr = dev['hypervisor_name']
            libvirt_dev = self._conn.nodeDeviceLookupByName(libvirt_dev_addr)
            libvirt_dev.reset()
    except libvirt.libvirtError as exc:
        raise exception.PciDevicePrepareFailed(id=dev['id'], instance_uuid=dev['instance_uuid'], reason=str(exc))