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):

  1. 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"
  }'
  1. 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
  1. 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"}
]
  1. 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'')"
  1. 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"}
  1. 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)

Most upvoted comments

is it possible that libvirt parses the two “versions” of the interface xml differently?

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.

Okay, Thanks @orelmisan Should I create a separate issue for the CNI DEL cleanup problem with the bridge binding interface?

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 pod prefix removed and add the -nic suffix [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:

{"component":"virt-launcher","level":"info","msg":"QEMU_MONITOR_IO_WRITE: mon=0x3ffac01d5d0 buf={\"execute\":\"device_del\",\"arguments\":{\"id\":\"ua-dyniface1\"},\"id\":\"libvirt-30\"}","pos":"qemuMonitorIOWrite:340","subcomponent":"libvirt","thread":"77","timestamp":"2025-02-11T17:56:21.229000Z"}
{"component":"virt-launcher","level":"info","msg":" len=78 ret=78 errno=0","subcomponent":"libvirt","timestamp":"2025-02-11T17:56:21.229711Z"}
{"component":"virt-launcher","level":"info","msg":"Line [{\"return\": {}, \"id\": \"libvirt-30\"}]","pos":"qemuMonitorJSONIOProcessLine:191","subcomponent":"libvirt","thread":"77","timestamp":"2025-02-11T17:56:21.230000Z"}
{"component":"virt-launcher","level":"info","msg":"QEMU_MONITOR_RECV_REPLY: mon=0x3ffac01d5d0 reply={\"return\": {}, \"id\": \"libvirt-30\"}","pos":"qemuMonitorJSONIOProcessLine:210","subcomponent":"libvirt","thread":"77","timestamp":"2025-02-11T17:56:21.230000Z"}
{"component":"virt-launcher","level":"info","msg":"Exited monitor (mon=0x3ffac01d5d0 vm=0x3ffac01ba20 name=default_vm-fedora)","pos":"qemuDomainObjExitMonitor:4912","subcomponent":"libvirt","thread":"34","timestamp":"2025-02-11T17:56:21.230000Z"}
{"component":"virt-launcher","level":"info","msg":"Line [{\"timestamp\": {\"seconds\": 1739296581, \"microseconds\": 280890}, \"event\": \"DEVICE_DELETED\", \"data\": {\"path\": \"/machine/peripheral/ua-dyniface1/virtio-backend\"}}]","pos":"qemuMonitorJSONIOProcessLine:191","subcomponent":"libvirt","thread":"77","timestamp":"2025-02-11T17:56:21.281000Z"}
{"component":"virt-launcher","level":"info","msg":"QEMU_MONITOR_RECV_EVENT: mon=0x3ffac01d5d0 event={\"timestamp\": {\"seconds\": 1739296581, \"microseconds\": 280890}, \"event\": \"DEVICE_DELETED\", \"data\": {\"path\": \"/machine/peripheral/ua-dyniface1/virtio-backend\"}}","pos":"qemuMonitorJSONIOProcessLine:205","subcomponent":"libvirt","thread":"77","timestamp":"2025-02-11T17:56:21.281000Z"}

libvirt executes the device_del QMP command, it gets back an empty return value, and shortly afterwards the DEVICE_DELETED event is emitted.

For the KubeVirt case, things are different:

{"component":"virt-launcher","level":"info","msg":"QEMU_MONITOR_IO_WRITE: mon=0x3ffac01d5d0 buf={\"execute\":\"device_del\",\"arguments\":{\"id\":\"ua-dyniface1\"},\"id\":\"libvirt-54\"}","pos":"qemuMonitorIOWrite:340","subcomponent":"libvirt","thread":"77","timestamp":"2025-02-11T18:04:23.621000Z"}
{"component":"virt-launcher","level":"info","msg":" len=78 ret=78 errno=0","subcomponent":"libvirt","timestamp":"2025-02-11T18:04:23.621116Z"}
{"component":"virt-launcher","level":"info","msg":"dispatching to max 0 clients, called from event watch 5","pos":"virNetlinkEventCallback:851","subcomponent":"libvirt","thread":"26","timestamp":"2025-02-11T18:04:23.627000Z"}
{"component":"virt-launcher","level":"info","msg":"event not handled.","pos":"virNetlinkEventCallback:867","subcomponent":"libvirt","thread":"26","timestamp":"2025-02-11T18:04:23.627000Z"}
{"component":"virt-launcher","level":"error","msg":"internal error: End of file from agent socket","pos":"qemuAgentIO:513","subcomponent":"libvirt","thread":"77","timestamp":"2025-02-11T18:04:23.974000Z"}
{"component":"virt-launcher","level":"info","msg":"Error on agent internal error: End of file from agent socket","pos":"qemuAgentIO:538","subcomponent":"libvirt","thread":"77","timestamp":"2025-02-11T18:04:23.974000Z"}

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 added a 30-second sleep to verify whether the virsh detach-interface from the virt-launcher pod actually removes the interface from the VM. During this time, I observed that the secondary interface is successfully removed from the VM, while everything else remains unchanged—meaning the output of ip a and the virsh dumpxml on the virt-launcher pod stay the same.

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 of virsh dumpxml remained the same. And yet inside the guest:

after virsh-detach was successfull: we can see eth1 was removed( this was done by virsh detach-interface)

[fedora@vm-fedora ~]$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host noprefixroute 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1480 qdisc fq_codel state UP group default qlen 1000
    link/ether 02:33:2e:00:00:00 brd ff:ff:ff:ff:ff:ff
    altname enc1
    inet 10.0.2.2/24 brd 10.0.2.255 scope global dynamic noprefixroute eth0
       valid_lft 86311661sec preferred_lft 86311661sec
    inet6 fe80::13bd:245:59f3:9e49/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

So you’re saying that the interface is successfully detached from the guest, but the output of virsh dumpxml doesn’t reflect this change? That would be a bug in libvirt.

Note that I’m not sure if the output of ip a in the virt-launcher pod 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:

{"component":"virt-launcher","level":"error","msg":"internal error: End of file from agent socket","pos":"qemuAgentIO:513","subcomponent":"libvirt","thread":"78","timestamp":"2025-01-30T01:17:08.894000Z"}
{"component":"virt-launcher","level":"error","msg":"Unable to read from monitor: Connection reset by peer","pos":"qemuMonitorIORead:397","subcomponent":"libvirt","thread":"78","timestamp":"2025-01-30T01:17:08.895000Z"}
{"component":"virt-launcher","level":"info","msg":"Process default_vm-fedora and pid 77 is a zombie, sending SIGCHLD to pid 1 to reap process","pos":"monitor.go:186","timestamp":"2025-01-30T01:17:08.965838Z"}

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.

Above output says Device detached successfully successfully, but i don’t see anything getting changed meaning I see same dumpxml, everything remains same

Wait, so even when you use virsh you don’t actually manage to detach the device? The only difference is that the daemon doesn’t crash?

Yes, there was no crash. What I observed is that the interface goes down and then quickly comes back up. I believe virt-handler is re-adding the interface simultaneously, as we can see in the log below from the virt-handler pod, which suggests that a hotplug event occurred again and was successful(this happens in parallel with virsh detach-interface). is this behaviour correct ? @orelmisan

{"component":"virt-launcher","level":"info","msg":"Domain Device Removed event received","pos":"client.go:506","timestamp":"2025-02-06T15:15:02.674910Z"}
{"component":"virt-launcher","level":"info","msg":"DomainLifecycle event Domain event=\"defined\" detail=\"updated\" with event id 0 reason 1 received","pos":"client.go:480","timestamp":"2025-02-06T15:15:02.677512Z"}
{"component":"virt-launcher","level":"info","msg":"Domain name event: default_vm-fedora","pos":"client.go:434","timestamp":"2025-02-06T15:15:02.679824Z"}
{"component":"virt-launcher","level":"info","msg":"Domain name event: default_vm-fedora","pos":"client.go:434","timestamp":"2025-02-06T15:15:02.681760Z"}
{"component":"virt-launcher","level":"info","msg":"will hot plug dyniface1","pos":"nichotplug.go:69","timestamp":"2025-02-06T15:15:02.682824Z"}
{"component":"virt-launcher","level":"info","msg":"will hot plug \"dyniface1\" with MAC \"02:e6:50:00:00:09\"","pos":"nichotplug.go:84","timestamp":"2025-02-06T15:15:02.683137Z"}
{"component":"virt-launcher","level":"info","msg":"ashok hot-plug  xml.Marshal value <interface type=\"ethernet\"><source></source><target dev=\"tap9a6a0c3b4d8\" managed=\"no\"></target><model type=\"virtio\"></model><mac address=\"02:e6:50:00:00:09\"></mac><mtu size=\"1300\"></mtu><alias name=\"ua-dyniface1\"></alias></interface>","pos":"nichotplug.go:86","timestamp":"2025-02-06T15:15:02.683185Z"}
{"component":"virt-launcher","level":"info","msg":"ashok after hot-plug  xml.Marshal value <interface type=\"ethernet\"><target dev=\"tap9a6a0c3b4d8\" managed=\"no\"></target><model type=\"virtio\"></model><mac address=\"02:e6:50:00:00:09\"></mac><mtu size=\"1300\"></mtu><alias name=\"ua-dyniface1\"></alias></interface>","pos":"nichotplug.go:91","timestamp":"2025-02-06T15:15:02.683213Z"}
{"component":"virt-launcher","level":"info","msg":"strings lower <interface type=\"ethernet\"><target dev=\"tap9a6a0c3b4d8\" managed=\"no\"></target><model type=\"virtio\"></model><mac address=\"02:e6:50:00:00:09\"></mac><mtu size=\"1300\"></mtu><alias name=\"ua-dyniface1\"></alias></interface>","pos":"nichotplug.go:93","timestamp":"2025-02-06T15:15:02.683225Z"}
{"component":"virt-launcher","level":"info","msg":"Domain Device Added event received","pos":"client.go:493","timestamp":"2025-02-06T15:15:02.735655Z"}
{"component":"virt-launcher","kind":"","level":"info","msg":"Synced vmi","name":"vm-fedora","namespace":"default","pos":"server.go:208","timestamp":"2025-02-06T15:15:02.737636Z","uid":"15e1d2d2-290e-4c60-88d8-e41b3491de76"}

Is it possible that the daemon crashes even in that case, and virsh simply disconnects before that happens? What if you call detach-device from within the interactive shell, e.g.

$ virsh
Welcome to virsh, the virtualization interactive terminal.

Type:  'help' for help with commands
       'quit' to quit

virsh # detach-device default_vm-fedora --file net.xml --live --persistent

Does virsh remain operational after the command returns, or does it quit because it loses connection to the daemon?

There are no issues with virsh, whether using an interactive shell or not; the connection remains active.

Also we don’t see this issue without kubevirt

So if you run libvirt natively on an s390x host, with no containers involved, and attempt to detach a network interface, it actually works correctly in that case? The live XML is updated as expected and the device actually disappears from the guest OS?

Yes, that is correct.

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?

Could you please try programmatically removing it prior to passing it to DetachDeviceFlags?

Sure, I can try that.

@ashokpariya0 thank you for providing the additional details. I suspect that the XML format used in s390 is different, and has additional fields. KubeVirt uses a custom implementation of the domain xml interface format, that lacks the address.devno field 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 s390 arch.

Do you have the knowledge to extend the Address struct to contain all the required fields?