Repository navigation
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi, Thank you for the detailed proposal and PR, @luckyh That said, I would prefer a diffrent approach. I strongly prefer avoiding any API changes in the VMI spec (no iommufd: {} field on GPUs/hostDevices/SRIOV) From my point of view, the node labeller can detect whether iommufd is supported on the node and add a label such as Device plugins / DRA drivers will own the compatibility decidion. If a given device, such as the modern NVIDIA devices, require iommufd, the driver will advertise the resource on that node only if it detects iommufd presense. This way, we don't need to confuse our users and there is a clear separation of responsibilities. What do you think? |
Actually I think we need the device plugins to offer the iommufd device and the vfio device (not group as with the legacy approach), from there we just need the relevant changes in launcher. The additional label would be miss leading as only the plugin can know what it will offer... |
@xpivarc we don't need the iommufd device in the pod per se. We only need to know if the host support iommufd. This could be discovered from sysfs in the pod as wee, without the label on the vmi. |
Hi @vladikr , thank you for your review! Let me comment inline.
Agree. Only one thing is that, regarding the live migration case (i.e. introduced by VEP #109), We need to check if qemu supports VFIO legacy <-> iommufd migration (I will investigate this). If not, looks some mechanism is required for noting the type of the allocated resources within virt-launcher. Do you have any preference, I mean, like metadata?
Make sense.
Thanks. |
|
@xpivarc thanks for the comment!
What I'm concerned is, I'm not sure if all the device plugins would follow that. For example, the NVIDIA sandbox-device-plugin (well, for Kata) used to offer the iommufd device but recently removed by the PR with no clear reason I could find (originally, it was introduced as the same, see commit). Anyway..
But seems we still need a label for indicating the capability of libvirt? |
I double checked and you are right, |
I wouldn't worry about Kata's device plugin because we are not using the same anyway. We need to make sure that we are clearly defining what KubeVirt supports and that we have a correct implementation in the NVIDIA KubeVirt Device plugin and later in DRA.
Yes, I think so. We would still need this. |
|
Updated per @vladikr 's suggestion. Several notes:
|
|
The libvirt patch is merged on upstream (commits), FYI. |
|
Regarding the approach of informing launcher about the iommufd node label, I'd like to propose using the diff --git a/pkg/virt-handler/vm.go b/pkg/virt-handler/vm.go
index 90ce01cc68..ed029d2851 100644
--- a/pkg/virt-handler/vm.go
+++ b/pkg/virt-handler/vm.go
@@ -2104,6 +2104,12 @@ func (c *VirtualMachineController) syncVirtualMachine(client cmdclient.LauncherC
options := virtualMachineOptions(smbios, period, preallocatedVolumes, c.capabilities, c.clusterConfig)
options.InterfaceDomainAttachment = domainspec.DomainAttachmentByInterfaceName(vmi.Spec.Domain.Devices.Interfaces, c.clusterConfig.GetNetworkBindings())
+ if c.clusterConfig.IOMMUFDEnabled() {
+ if c.isVMIOwnedByNode(vmi) && util.IsVFIOVMI(vmi) {
+ options.IOMMUFDAvailabe = c.isIOMMUFDAvailabe()
+ }
+ }
+
err := client.SyncVirtualMachine(vmi, options)
if err != nil {
if strings.Contains(err.Error(), "EFI OVMF rom missing") {
@@ -2114,6 +2120,35 @@ func (c *VirtualMachineController) syncVirtualMachine(client cmdclient.LauncherC
return err
}
+func (c *VirtualMachineController) isIOMMUFDAvailabe() bool {
+ node, err := c.getNode()
+ if err != nil {
+ // log error
+ return false
+ }
+ val, exist := node.Labels[v1.IOMMUFDLabel]
+ if !exist || val != "available" {
+ return false
+ }
+}
+
+func (c *VirtualMachineController) getNode() (*k8sv1.Node, error) {
+ nodeObj, exists, err := c.nodeStore.GetByKey(c.host)
+ if err != nil {
+ return nil, err
+ }
+ if !exists {
+ return nil, fmt.Errorf("node %s does not exist", c.host)
+ }
+
+ node, ok := nodeObj.(*k8sv1.Node)
+ if !ok {
+ return nil, fmt.Errorf("unknown object type found in node informer")
+ }
+
+ return node, nil
+}
+
func (c *VirtualMachineController) handleHousekeeping(vmi *v1.VirtualMachineInstance, cgroupManager cgroup.Manager, domainExists bool) error {
if vmi.IsCPUDedicated() && vmi.Spec.Domain.CPU.IsolateEmulatorThread {
err := c.configureHousekeepingCgroup(vmi, cgroupManager)@vladikr @xpivarc does it look good to you, or would you like to suggest a different one? |
|
@luckyh virt-launcher will have all the info and that is |
|
@xpivarc sorry for the delayed reply.
Right, the logic of detecting the presence of iommufd and vfio devices can be handled within virt-launcher. However, as the iommufd support on libvirt side is just newly introduced, I suppose that kubevirt needs to cover both the supported and unsupported cases of iommufd. The iommufd setting of Hence, in my proposal, the iommufd label is passed from handler to launcher for giving the hint of the corresponding libvirt domain capability, for enforcing the deterministic outcome for source domain configuration. That is, the iommufd xml settings will be rendered by virt-launcher only if,
otherwise, it will fall back to legacy vfio. Apart from that, the domain capabilities could be also probed within the launcher process, but I'm not sure if that is a suggested approach, do we? |
|
Updated the proposal for adopting the latest change of libvirt (since 12.2.0), that is, now the per-domain configuration Apart from that, it expects kubevirt to handle the configuration of the iommufd device instead of libvirt. Due to this requires the [1] https://libvirt.org/formatdomain.html#host-device-iommufd |
Signed-off-by: Xu Han <[email protected]> Co-authored-by: Vladik Romanovsky <[email protected]> Co-authored-by: fossedihelm <[email protected]> Co-authored-by: Lee Yarwood <[email protected]> Co-authored-by: Luboslav Pivarc <[email protected]>
|
Updated with adding the IOMMUFD device plugin content. |
Am I understanding this correctly? Basically we need either a webhook or expand virt-handler to do some fd-passing. Currently virt-handler doesn't have this capability correct? |
@ajcaldelas the original idea came up to my mind is that, we could let virt-hander open the However, @vladikr gives another proposal, that is, introducing a new device plugin [1] for handling the above procedure. Based on that, it needs to use either the virt-controller or a webhook to inject the iommufd resource request for the device assignments to VMs. |
@luckyh The iommu-device-plugin was created as an external plugin. |
VEP Metadata
Tracking issue: #186
SIG label: /sig compute
What this PR does
Add first proposal for VEP 186: Host Devices Assignment with IOMMUFD
Special notes for your reviewer