kubevirt: Sometimes SRIOV VFs (vfio-pci) are not passed to qemu-kvm command line breaking the guest VM

I recently got around to ugprading from 0.53 to 1.4.0 (along with upgrading k8s from 1.23 to 1.31 because it was about time) and now I am seeing a strange problem that I would love suggestions on how to debug.

Sometimes when the system boots up, a VM running under kubevirt is missing the VFs that are supposed to be assigned using vfio-pci. So they don’t show up in the guest, but they are also missing from the qemu-kvm command line and from the ctrl-vmi.xml file. I am trying to understand why they are suddenly missing. Often rebooting the host will allow it to work the next time, while it seems future reboots may sometimes bring the issue back. So it seems like some timing issue in the startup between the various parts of kubernetes and kubevirt and the sriov containers. I just can’t seem to find a log in any of them showing anything failing, nor why kubevirt is choosing to completely leave the vfio arguments out of the command line for qemu-kvm.

Obviously I was expecting it to always just consistently run kubevirt with the configured settings for the VM.

Exactly how to reproduce it I am still working on, but I am seeing it on multiple machines muliple times so far, while some machines I have never seen it yet.

  • KubeVirt version (use virtctl version): Client Version: version.Info{GitVersion:“v0.0.0-master+$Format:%h$”, GitCommit:“$Format:%H$”, GitTreeState:“”, BuildDate:“1970-01-01T00:00:00Z”, GoVersion:“go1.22.6”, Compiler:“gc”, Platform:“linux/amd64”} Server Version: version.Info{GitVersion:“v1.4.0”, GitCommit:“9b9b3d4e7b681af96ca1b6b6a5cea75e2f05ce5b”, GitTreeState:“clean”, BuildDate:“2024-11-13T09:51:17Z”, GoVersion:“go1.22.8 X:nocoverageredesign”, Compiler:“gc”, Platform:“linux/amd64”}
  • Kubernetes version (use kubectl version): Client Version: v1.31.1-dirty Kustomize Version: v5.4.2 Server Version: v1.31.1
  • VM or VMI specifications: N/A apiVersion: kubevirt.io/v1 kind: VirtualMachine metadata: annotations: kubectl.kubernetes.io/last-applied-configuration: | {“apiVersion”:“kubevirt.io/v1”,“kind”:“VirtualMachine”,“metadata”:{“annotations”:{},“name”:“ctrl-vmi”,“namespace”:“xiq-se-1”},“spec”:{“dataVolumeTemplates”:[{“metadata”:{“annotations”:{“kubevirt.io/provisionOnNode”:“ucp2130.extremenetworks.com”},“name”:“xiq-se-dv”},“spec”:{“pvc”:{“accessModes”:[“ReadWriteOnce”],“resources”:{“requests”:{“storage”:“850Gi”}},“storageClassName”:“hostpath-provisioner”},“source”:{“registry”:{“url”:“docker://10.48.4.101:5000/site_engine:24.10.99.12”}}}}],“runStrategy”:“Always”,“template”:{“metadata”:{“labels”:{“special”:“svckey”}},“spec”:{“affinity”:{“nodeAffinity”:{“requiredDuringSchedulingIgnoredDuringExecution”:{“nodeSelectorTerms”:[{“matchExpressions”:[{“key”:“kubernetes.io/hostname”,“operator”:“In”,“values”:[“ucp2130.extremenetworks.com”]}]}]}}},“domain”:{“cpu”:{“cores”:30,“model”:“host-passthrough”,“sockets”:1},“devices”:{“autoattachGraphicsDevice”:false,“autoattachMemBalloon”:false,“disks”:[{“disk”:{“bus”:“virtio”},“name”:“xiq-sedrive”}],“interfaces”:[{“name”:“sriov1”,“sriov”:{}},{“name”:“sriov2”,“sriov”:{}},{“name”:“sriov3”,“sriov”:{}},{“name”:“sriov4”,“sriov”:{}}]},“resources”:{“requests”:{“memory”:“52Gi”}}},“networks”:[{“multus”:{“networkName”:“default/sriov-bnxt-net1-01”},“name”:“sriov1”},{“multus”:{“networkName”:“default/sriov-bnxt-net2-01”},“name”:“sriov2”},{“multus”:{“networkName”:“default/sriov-ice-net3-01”},“name”:“sriov3”},{“multus”:{“networkName”:“default/sriov-ice-net4-01”},“name”:“sriov4”}],“terminationGracePeriodSeconds”:0,“volumes”:[{“dataVolume”:{“name”:“xiq-se-dv”},“name”:“xiq-sedrive”}]}}}} kubevirt.io/latest-observed-api-version: v1 kubevirt.io/storage-observed-api-version: v1 creationTimestamp: “2024-12-19T18:18:22Z” finalizers:
    • kubevirt.io/virtualMachineControllerFinalize generation: 1 name: ctrl-vmi namespace: xiq-se-1 resourceVersion: “2326872” uid: 678d3e7b-3dd3-4ccd-add4-e5cf6b8b94d3 spec: dataVolumeTemplates:
    • metadata: annotations: kubevirt.io/provisionOnNode: ucp2130.extremenetworks.com creationTimestamp: null name: xiq-se-dv spec: pvc: accessModes: - ReadWriteOnce resources: requests: storage: 850Gi storageClassName: hostpath-provisioner source: registry: url: docker://10.48.4.101:5000/site_engine:24.10.99.12 runStrategy: Always template: metadata: creationTimestamp: null labels: special: svckey spec: affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: kubernetes.io/hostname operator: In values: - ucp2130.extremenetworks.com architecture: amd64 domain: cpu: cores: 30 model: host-passthrough sockets: 1 devices: autoattachGraphicsDevice: false autoattachMemBalloon: false disks: - disk: bus: virtio name: xiq-sedrive interfaces: - name: sriov1 sriov: {} - name: sriov2 sriov: {} - name: sriov3 sriov: {} - name: sriov4 sriov: {} machine: type: q35 resources: requests: memory: 52Gi networks:
      • multus: networkName: default/sriov-bnxt-net1-01 name: sriov1
      • multus: networkName: default/sriov-bnxt-net2-01 name: sriov2
      • multus: networkName: default/sriov-ice-net3-01 name: sriov3
      • multus: networkName: default/sriov-ice-net4-01 name: sriov4 terminationGracePeriodSeconds: 0 volumes:
      • dataVolume: name: xiq-se-dv name: xiq-sedrive status: conditions:
    • lastProbeTime: null lastTransitionTime: “2024-12-20T21:10:17Z” status: “True” type: Ready
    • lastProbeTime: null lastTransitionTime: null message: All of the VMI’s DVs are bound and not running reason: AllDVsReady status: “True” type: DataVolumesReady
    • lastProbeTime: null lastTransitionTime: null message: ‘cannot migrate VMI: PVC xiq-se-dv is not shared, live migration requires that all PVCs must be shared (using ReadWriteMany access mode)’ reason: DisksNotLiveMigratable status: “False” type: LiveMigratable
    • lastProbeTime: null lastTransitionTime: null status: “True” type: StorageLiveMigratable created: true desiredGeneration: 1 observedGeneration: 1 printableStatus: Running ready: true runStrategy: Always volumeSnapshotStatuses:
    • enabled: false name: xiq-sedrive reason: ‘No VolumeSnapshotClass: Volume snapshots are not configured for this StorageClass [hostpath-provisioner] [xiq-sedrive]’
  • Cloud provider or hardware configuration: Custom yocto linux on supermicro server hardware
  • OS (e.g. from /etc/os-release): Yocto 5.0
  • Kernel (e.g. uname -a): 5.15.59

Before upgrading it was using kubernetes 1.23.6 and kubevirt 0.53 and did not show this strange behaviour.

Any suggestions on what logs or status or configuration to look at would be welcome to try and narrow down why this is happening.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 20 (8 by maintainers)

Most upvoted comments

Hi @lsorense! I’m here to help you with bug fixes, answer your questions, and guide you on becoming a contributor. Let’s work on this together!

To address the issue of SRIOV VFs not being passed to the qemu-kvm command line, it seems like a timing issue where KubeVirt might be launching VM instances before the necessary components, like Multus, are ready. You can ensure that KubeVirt waits for the kube-multus-ds to be ready before launching VM instances by using the sriov_components::wait_pods_ready function. This function checks that all necessary pods, including kube-multus-ds, are in a ready state before proceeding with launching VMs. Here’s a snippet of how you can implement this:

## Deploy Multus and SRIOV components
sriov_components::deploy_multus
sriov_components::deploy \
  "$PFS_IN_USE" \
  "$VFS_DRIVER" \
  "$SRIOVDP_RESOURCE_PREFIX" "$SRIOVDP_RESOURCE_NAME" \
  "$SRIOV_NODE_LABEL_KEY" "$SRIOV_NODE_LABEL_VALUE"

# Verify that each sriov capable node has sriov VFs allocatable resource
validate_nodes_sriov_allocatable_resource
sriov_components::wait_pods_ready

This script uses a retry mechanism to ensure that all necessary components are ready before any VM instances are launched, preventing SRIOV VFs from being missing in the qemu-kvm command line [1][2].

Additionally, you might want to check the virt-launcher pod logs for any errors or warnings related to the SRIOV VFs. You can retrieve these logs using:

$ kubectl get pods
$ kubectl logs <virt-launcher-pod-name>

This can help you trace any issues during the VM lifecycle related to SRIOV VFs [3].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other