-
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?
Conversation
Signed-off-by: Farrah Chen <[email protected]> Signed-off-by: Xudong Hao <[email protected]>
|
||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Before creating an iommufd device, it is better to check that /dev/iommu
exists.
@@ -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 |
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?
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
In this code block, all parameters use vm_hostdev
prefix, I would suggest align with this.
@@ -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": | |||
dev_params["iommufd"] = "iommufd0" |
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.
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.
iommufd-backed VFIO, for example:
-object iommufd,id=iommufd0
-device vfio-pci,host=01:00.0,iommufd=iommufd0
Multiple pcie device can use the same iommufd.