kubevirt: Hot-Unplugging Secondary Network Interface Leads to SyncVMI Failure and Live Migration Failure
What happened: After attempting to hot-unplug a secondary network interface (dyniface1) from a VirtualMachineInstance (VMI) in KubeVirt, the VMI enters a state where it fails to sync, displaying the following error:
LibvirtError(Code=99, Domain=20, Message='device not found: no device found at address '0.0.0000' matching MAC address '02:6c:5b:00:00:06' and alias 'ua-dyniface1') This results in subsequent live migration failures for the VM.
What you expected to happen: The hot-unplug operation should successfully remove the secondary network interface without causing issues. The VMI should continue to function normally, without synchronization failures or live migration issues.
How to reproduce it (as minimally and precisely as possible):
- Create a new NetworkAttachmentDefinition using the following YAML:
apiVersion: k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
metadata:
name: new-fancy-net
spec:
config: '{
"cniVersion": "0.3.1",
"type": "bridge",
"mtu": 1300,
"name":"new-fancy-net"
}'
- Create a VM with the following YAML configuration:
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
name: vm-fedora
spec:
runStrategy: Always
template:
metadata:
labels:
kubevirt.io/domain: vm-fedora
special: key
spec:
domain:
devices:
disks:
- disk:
bus: virtio
name: containerdisk
interfaces:
- name: default
masquerade: {}
- name: dyniface1
bridge: {}
resources:
requests:
memory: 1Gi
networks:
- name: default
pod: {}
- name: dyniface1
multus:
networkName: new-fancy-net
volumes:
- containerDisk:
image: quay.io/kubevirt/fedora-with-test-tooling-container-disk:20241126_959eee0dfd-s390x
name: containerdisk
- Verify that the secondary network interface (dyniface1) is active:
$kubectl get vmi vm-fedora -ojsonpath=“{ @.status.interfaces }”
[
{"infoSource":"domain","ipAddress":"10.244.186.236","mac":"02:6c:5b:00:00:05","name":"default","podInterfaceName":"eth0"},
{"infoSource":"domain, multus-status","mac":"02:6c:5b:00:00:06","name":"dyniface1"}
]
- Perform the hot-unplug operation by editing the VM and setting state: absent for dyniface1: kubectl edit vm vm-fedora-ap
- name: dyniface1
state: absent
bridge: {}
After editing, observe the error in kubectl describe vmi vm-fedora:
Error message:
server error. command SyncVMI failed: "LibvirtError(Code=99, Domain=20, Message='device not found: no device found at address '0.0.0000' matching MAC address '02:6c:5b:00:00:06' and alias 'ua-dyniface1')"
complete output is as follows : kubectl describe vmi vm-fedora
Name: vm-fedora
Namespace: default
Labels: kubevirt.io/domain=vm-fedora
kubevirt.io/nodeName=node03
special=key
Annotations: kubevirt.io/latest-observed-api-version: v1
kubevirt.io/storage-observed-api-version: v1
kubevirt.io/vm-generation: 1
API Version: kubevirt.io/v1
Kind: VirtualMachineInstance
Metadata:
Creation Timestamp: 2025-01-16T09:31:01Z
Finalizers:
kubevirt.io/virtualMachineControllerFinalize
foregroundDeleteVirtualMachine
Generation: 11
Owner References:
API Version: kubevirt.io/v1
Block Owner Deletion: true
Controller: true
Kind: VirtualMachine
Name: vm-fedora
UID: 9cd970d4-d3af-4ee4-811a-7100a53e883b
Resource Version: 26429482
UID: f561f38a-7a53-4bac-9dd7-e2c4133e1ec7
Spec:
Architecture: s390x
Domain:
Cpu:
Cores: 1
Model: host-model
Sockets: 1
Threads: 1
Devices:
Disks:
Disk:
Bus: virtio
Name: containerdisk
Interfaces:
Mac Address: 02:6c:5b:00:00:05
Masquerade:
Name: default
Bridge:
Mac Address: 02:6c:5b:00:00:06
Name: dyniface1
State: absent
Features:
Acpi:
Enabled: false
Firmware:
Uuid: c9dc132f-1bb1-5f88-9891-deed35a6d803
Machine:
Type: s390-ccw-virtio
Memory:
Guest: 1Gi
Resources:
Requests:
Memory: 1Gi
Eviction Strategy: None
Networks:
Name: default
Pod:
Multus:
Network Name: new-fancy-net
Name: dyniface1
Volumes:
Container Disk:
Image: quay.io/kubevirt/fedora-with-test-tooling-container-disk:20241126_959eee0dfd-s390x
Image Pull Policy: IfNotPresent
Name: containerdisk
Status:
Active Pods:
ca8be2de-8509-4b0e-bddb-bb1339b490d5: node03
Conditions:
Last Probe Time: <nil>
Last Transition Time: 2025-01-16T09:31:04Z
Status: True
Type: Ready
Last Probe Time: <nil>
Last Transition Time: <nil>
Status: True
Type: LiveMigratable
Last Probe Time: <nil>
Last Transition Time: <nil>
Status: True
Type: StorageLiveMigratable
Last Probe Time: 2025-01-16T09:32:40Z
Last Transition Time: <nil>
Status: True
Type: AgentConnected
Last Probe Time: <nil>
Last Transition Time: 2025-01-16T09:34:02Z
Message: server error. command SyncVMI failed: "LibvirtError(Code=99, Domain=20, Message='device not found: no device found at address '0.0.0000' matching MAC address '02:6c:5b:00:00:06' and alias 'ua-dyniface1'')"
Reason: Synchronizing with the Domain failed.
Status: False
Type: Synchronized
Current CPU Topology:
Cores: 1
Sockets: 1
Threads: 1
Guest OS Info:
Id: fedora
Kernel Release: 6.5.6-300.fc39.s390x
Kernel Version: #1 SMP Fri Oct 6 18:43:21 UTC 2023
Machine: s390x
Name: Fedora Linux
Pretty Name: Fedora Linux 39 (Cloud Edition)
Version: 39 (Cloud Edition)
Version Id: 39
Interfaces:
Info Source: domain, guest-agent
Interface Name: eth0
Ip Address: 10.244.186.236
Ip Addresses:
10.244.186.236
fd10:244::baf0
Mac: 02:6c:5b:00:00:05
Name: default
Pod Interface Name: eth0
Queue Count: 1
Info Source: domain, guest-agent, multus-status
Interface Name: eth1
Ip Address: fe80::13cc:d69d:e600:d097
Ip Addresses:
fe80::13cc:d69d:e600:d097
Mac: 02:6c:5b:00:00:06
Name: dyniface1
Queue Count: 1
Launcher Container Image Version: quay.io/kubevirt/virt-launcher:20241219_4e1f0a5bb4-s390x
Machine:
Type: s390-ccw-virtio-rhel9.4.0
Memory:
Guest At Boot: 1Gi
Guest Current: 1Gi
Guest Requested: 1Gi
Migration Method: BlockMigration
Migration Transport: Unix
Node Name: node03
Phase: Running
Phase Transition Timestamps:
Phase: Pending
Phase Transition Timestamp: 2025-01-16T09:31:01Z
Phase: Scheduling
Phase Transition Timestamp: 2025-01-16T09:31:01Z
Phase: Scheduled
Phase Transition Timestamp: 2025-01-16T09:31:04Z
Phase: Running
Phase Transition Timestamp: 2025-01-16T09:31:05Z
Qos Class: Burstable
Runtime User: 107
Selinux Context: system_u:object_r:container_file_t:s0:c48,c118
Virtual Machine Revision Name: revision-start-vm-9cd970d4-d3af-4ee4-811a-7100a53e883b-1
Volume Status:
Container Disk Volume:
Checksum: 85912331
Name: containerdisk
Target: vda
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal SuccessfulCreate 3m21s virtualmachine-controller Created virtual machine pod virt-launcher-vm-fedora-srwb7
Normal Created 3m17s virt-handler VirtualMachineInstance defined.
Normal Started 3m17s virt-handler VirtualMachineInstance started.
Warning SyncFailed 10s (x12 over 20s) virt-handler server error. command SyncVMI failed: "LibvirtError(Code=99, Domain=20, Message='device not found: no device found at address '0.0.0000' matching MAC address '02:6c:5b:00:00:06' and alias 'ua-dyniface1'')"
- Check the logs in the virt-launcher pod for the error:
{"component":"virt-launcher","level":"info","msg":"preparing to hot-unplug dyniface1","pos":"nichotplug.go:100","timestamp":"2025-01-16T09:34:02.637256Z"}
{"component":"virt-launcher","level":"error","msg":"device not found: no device found at address '0.0.0000' matching MAC address '02:6c:5b:00:00:06' and alias 'ua-dyniface1'","pos":"virDomainNetFindIdx:14763","subcomponent":"libvirt","thread":"27","timestamp":"2025-01-16T09:34:02.638000Z"}
{"component":"virt-launcher","level":"error","msg":"libvirt failed to detach interface dyniface1: virError(Code=99, Domain=20, Message='device not found: no device found at address '0.0.0000' matching MAC address '02:6c:5b:00:00:06' and alias 'ua-dyniface1'')","pos":"nichotplug.go:108","reason":"virError(Code=99, Domain=20, Message='device not found: no device found at address '0.0.0000' matching MAC address '02:6c:5b:00:00:06' and alias 'ua-dyniface1'')","timestamp":"2025-01-16T09:34:02.638853Z"}
{"component":"virt-launcher","kind":"","level":"error","msg":"Failed to sync vmi","name":"vm-fedora","namespace":"default","pos":"server.go:202","reason":"virError(Code=99, Domain=20, Message='device not found: no device found at address '0.0.0000' matching MAC address '02:6c:5b:00:00:06' and alias 'ua-dyniface1'')","timestamp":"2025-01-16T09:34:02.638904Z","uid":"f561f38a-7a53-4bac-9dd7-e2c4133e1ec7"}
{"component":"virt-launcher","level":"info","msg":"preparing to hot-unplug dyniface1","pos":"nichotplug.go:100","timestamp":"2025-01-16T09:34:02.659996Z"}
{"component":"virt-launcher","level":"error","msg":"device not found: no device found at address '0.0.0000' matching MAC address '02:6c:5b:00:00:06' and alias 'ua-dyniface1'","pos":"virDomainNetFindIdx:14763","subcomponent":"libvirt","thread":"29","timestamp":"2025-01-16T09:34:02.661000Z"}
{"component":"virt-launcher","level":"error","msg":"libvirt failed to detach interface dyniface1: virError(Code=99, Domain=20, Message='device not found: no device found at address '0.0.0000' matching MAC address '02:6c:5b:00:00:06' and alias 'ua-dyniface1'')","pos":"nichotplug.go:108","reason":"virError(Code=99, Domain=20, Message='device not found: no device found at address '0.0.0000' matching MAC address '02:6c:5b:00:00:06' and alias 'ua-dyniface1'')","timestamp":"2025-01-16T09:34:02.661223Z"}
- Attempt to perform a live migration of the VM and observe the failure:
# kubectl get VirtualMachineInstanceMigration -w
NAME PHASE VMI
migration-job vm-fedora
migration-job vm-fedora
migration-job Pending vm-fedora
migration-job Scheduling vm-fedora
migration-job Scheduled vm-fedora
migration-job PreparingTarget vm-fedora
migration-job TargetReady vm-fedora
migration-job Running vm-fedora
migration-job Failed vm-fedora
migration-job Failed vm-fedora
migration-job Failed vm-fedora
Additional context: The issue occurs after hot-unplugging the secondary network interface (dyniface1), leading to synchronization failures (SyncVMI failed) and live migration failures. The hot-unplug operation seems to leave the VM in a state where the interface is no longer found by libvirt, causing synchronization issues. It is unclear whether the state change (state: absent) is being fully processed by the underlying infrastructure, leading to the interface not being properly detached, However, after restarting the VM, the errors are cleared, the secondary interface is successfully removed, and live migrations work as expected.
Environment:
- KubeVirt version (use
virtctl version): N/A - Kubernetes version (use
kubectl version): v1.30.4 - VM or VMI specifications: N/A
- Cloud provider or hardware configuration: N/A
- OS (e.g. from /etc/os-release): N/A
- Kernel (e.g.
uname -a): s390x - Install tools: N/A
- Others: N/A
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 62 (61 by maintainers)
It really shouldn’t happen, since the two XML snippets are semantically identical. However, confirming this should be trivial: just get the snippet out of the virt-launcher log, remove the escaping that was added to make it valid JSON and pass the result to virsh.
Yes, please. AFAIU, this issue is limited to the in-place hotunplug scenario, because AFAIK the veth pair should be removed when the pod’s network namespace is removed.
@ashokpariya0 Thank you for looking into it.
With bridge binding we put a dummy interface with the veth interface’s original name and rename the veth interface to have its
podprefix removed and add the-nicsuffix [1]. I guess the CNI tries to remove the dummy instead of the veth. This concern was raised in [2].[1] https://github.com/kubevirt/kubevirt/blob/ce88686376060833eda4e31d67aed901a619c330/pkg/network/setup/netpod/netpod.go#L336 [2] https://github.com/kubevirt/kubevirt/issues/2076#issuecomment-1592463381
For the virsh case, the output is what I expect:
libvirt executes the
device_delQMP command, it gets back an empty return value, and shortly afterwards theDEVICE_DELETEDevent is emitted.For the KubeVirt case, things are different:
Instead of getting a return value and an event, QEMU crashes.
Note that the command sent by libvirt is absolutely identical in both cases. Something else must be going on.
I think you need to dig deeper into what operation KubeVirt performs before calling the libvirt API. Maybe the host-side device is deleted earlier than intended? Or something else that might cause QEMU to find itself in an unexpected state?
Another thing you could try, although I don’t know how much effort that would entail, would be to modify KubeVirt so that it runs virsh to detach the device instead of calling the libvirt API directly. That could provide additional insights.
If all else fails, you will need to instrument QEMU somehow so that you get a stack trace or something like that when it crashes. I don’t know if attaching gdb is feasible. Maybe Alice’s documentation has something that can help you.
I’m sorry for not being able to point you in a more precise direction. I basically have no idea what’s going on, so I’m simply listing a number of things that I would try myself.
https://github.com/alicefr/kubevirt-debug/tree/main/logging in particular is relevant. If you follow it, you should see all the QMP chatter between libvirt and QEMU. I’d be interested in seeing whether that conversation is any different depending on whether KubeVirt triggers the unplug or virsh does.
The log you provided earlier doesn’t seem very useful, all I can see is that libvirt requests the unplug and QEMU disappears.
@alicefr wrote several documents about debugging https://github.com/alicefr/kubevirt-debug Maybe they could help.
I’m getting very confused to be honest. You say that the interface was successfully removed by
virsh detach-device, but also that the output ofvirsh dumpxmlremained the same. And yet inside the guest:So you’re saying that the interface is successfully detached from the guest, but the output of
virsh dumpxmldoesn’t reflect this change? That would be a bug in libvirt.Note that I’m not sure if the output of
ip ain thevirt-launcherpod is supposed to change when a guest interface is detached. I certainly wouldn’t be surprised if it didn’t, especially since in this case you’re detaching the device behind KubeVirt’s back so only the guest can possibly be affected.Either way. Looking at the logs you’ve provided again, these are the relevant bits:
So it’s not virtqemud crashing, as I have incorrectly stated previously, but QEMU. libvirt notices the issue and reports it.
I think there are a couples of things that you could try next.
One is to add a short sleep right after the
DetachDeviceFlags()API is called, to ensure that KubeVirt doesn’t attempt to do something before the guest has a chance to process the request. It might be the case that there’s a race somewhere, and having KubeVirt take it easy on the QEMU process might avoid it.Another is to enable verbose debug logging for libvirt (there’s documentation on this somewhere) and compare the QMP interactions between the detach operation triggered via virsh and the one triggered by KubeVirt. There might be something useful in there, though I can’t imagine what it could possibly be.
If the NIC was detached by virsh, virt-launcher saw that it needs to hotplug an interface that is in the VMI spec but not in the domain. So the hotplug operation makes sense to me.
@ashokpariya0 Could you please collect the libvirt log while performing the hotunplug operation using just KubeVirt? @andreabolognani is it possible that libvirt parses the two “versions” of the interface xml differently?
Sure, I can try that.
@ashokpariya0 thank you for providing the additional details. I suspect that the XML format used in
s390is different, and has additional fields. KubeVirt uses a custom implementation of the domain xml interface format, that lacks theaddress.devnofield for example.We pass the interface in xml format to libvirt’s DetachDeviceFlags, and I have a feeling that it lacks info that is required in the
s390arch.Do you have the knowledge to extend the Address struct to contain all the required fields?