-
Notifications
You must be signed in to change notification settings - Fork 242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable IOMMUFD for VM device passthrough #4004
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4031,9 +4031,25 @@ def hostdev_define_by_params(self, name, params, bus=None): | |
"failover_pair_id": params.get("vm_hostdev_failover_pair_id"), | ||
} | ||
) | ||
# Use hard code 'iommufd0' here, multiple devices use the same iommufd | ||
if params.get("iommufd") == "yes": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this code block, all parameters use |
||
dev_params["iommufd"] = "iommufd0" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently, the iommufd is only used for VFIO devices, so I have an idea here, devs = []
...
...
fd_id = params.get("vm_hostdev_iommufd")
if fd_id and not self.get_by_qid(fd_id):
iommufd = iommufd_object_define_by_params()
dev_params["iommufd"] = fd_id
devs.append(iommufd)
...
...
dev = qdevices.QDevice(driver, dev_params, parent_bus=dev_bus)
devs.append(dev)
return devs If you have any concern, please don't hesitate to raise them. |
||
# TODO: Support vfio-ap and vfio-ccw, currently only for pci devices | ||
dev_bus = bus or {"aobject": params.get("pci_bus", "pci.0")} | ||
dev = qdevices.QDevice(driver, dev_params, parent_bus=dev_bus) | ||
for ext_k, ext_v in params.get_dict("vm_hostdev_extra_params").items(): | ||
dev.set_param(ext_k, ext_v) | ||
return dev | ||
|
||
def iommufd_object_define_by_params(self, obj_id): | ||
""" | ||
Create iommufd object device by params | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before creating an iommufd device, it is better to check that |
||
|
||
The iommufd objects cmdlines: | ||
-object iommufd,id=iommufd0 | ||
|
||
:param obj_id: The id of the QObject device, e.g. iommufd0 | ||
:return: the iommufd QObject device | ||
""" | ||
backend, properties = "iommufd", {"id": obj_id} | ||
return qdevices.QObject(backend, properties) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you mentioned here, multiple devices can use the same one. How about checking the iommufd as an ID? If the iommufd device exists with the same ID, reuse it; if not, create a new one, cause we should also support using different iommufd devices, what do you think?