def append_mediated_device(devices, log, mdev_type, vm_id): mdev_uuid = get_mdev_uuid(vm_id) old_device_id = None for dev in devices[hwclass.HOSTDEV]: # REQUIRED_FOR: Engine < 4.2 # Legacy Engine tracks the mdev device once it is created and sends it # in device parameters on the next VM run. However the sent device is # incomplete and inaccurate (and we must handle devices created by # former vfio-mdev hook) and the easiest way to deal with that is to # replace it. We must be careful not to change the device id, # otherwise Engine would track it as an additional device together with # the original device. if getattr(dev, 'address', {}).get('uuid') == mdev_uuid: old_device_id = dev.deviceId devices[hwclass.HOSTDEV].remove(dev) break mdev_dom = libvirtxml.make_mdev_element(mdev_uuid) mdev = HostDevice.from_xml_tree(log, mdev_dom, {'mdevType': mdev_type}) if old_device_id is not None: mdev.deviceId = old_device_id devices[hwclass.HOSTDEV].append(mdev)
def append_mediated_device(devices, log, mdev_type, vm_id): mdev_uuid = get_mdev_uuid(vm_id) old_device_id = None for dev in devices[hwclass.HOSTDEV]: # REQUIRED_FOR: Engine < 4.2 # Legacy Engine tracks the mdev device once it is created and sends it # in device parameters on the next VM run. However the sent device is # incomplete and inaccurate (and we must handle devices created by # former vfio-mdev hook) and the easiest way to deal with that is to # replace it. We must be careful not to change the device id, # otherwise Engine would track it as an additional device together with # the original device. if getattr(dev, 'address', {}).get('uuid') == mdev_uuid: old_device_id = dev.deviceId devices[hwclass.HOSTDEV].remove(dev) break mdev_dom = libvirtxml.make_mdev_element(mdev_uuid) mdev = HostDevice.from_xml_tree(log, mdev_dom, {'mdevType': mdev_type}) if old_device_id is not None: mdev.deviceId = old_device_id devices[hwclass.HOSTDEV].append(mdev)
def getXML(self): return libvirtxml.make_mdev_element(self.mdev_uuid)
def add_mediated_device(dom, mdev_uuid): devs = vmxml.find_first(dom, 'devices') hostdev = libvirtxml.make_mdev_element(mdev_uuid) devs.append(hostdev)
def getXML(self): return libvirtxml.make_mdev_element(self.mdev_uuid)