Detaching a CD-ROM device that has no media inserted currently logs an internal error:
internal error: unable to execute QEMU command 'blockdev-del': Failed to find node with node-name='libvirt-N-storage' or, when no stale node name is present in the source: internal error: argument key 'node-name' must not have null value The root cause is that an empty disk source (path == NULL) satisfies virStorageSourceIsBacking() while no corresponding blockdev node ever exists in QEMU, so the detach path prepares a blockdev-del for a node that was never created. Patch 1 fixes the detach path itself: qemuDomainRemoveDiskDevice() now skips the blockdev detach preparation for an empty source, mirroring what the old-media detach in qemuDomainChangeMediaBlockdev() already does. Patch 2 fixes the way the stale node name gets there in the first place: qemuDomainChangeEjectableMedia() ran the full image setup (qemuDomainPrepareDiskSource(), backing chain detection, storage access, managed PR) even when ejecting to no media, assigning node names to an empty source that are never realized in QEMU. The setup is now skipped for an empty source, mirroring qemuDomainAttachDeviceDiskLiveInternal(), and rollback only revokes storage access when it was actually granted. To reproduce the 1st message: 1. Start a domain with a CD-ROM device with media attached 2. virsh change-media $dom $target --eject --live 3. virsh detach-disk $dom $target --live To reproduce the 2nd message: 1. Start a domain with a CD-ROM device without media attached 2. virsh detach-disk $dom $target --live No regression tests are added. Neither failure mode is reachable from qemuhotplugtest: the "null value" variant fails while constructing the blockdev-del arguments, before any QMP command is sent, leaving nothing for the test monitor to observe; the stale-node-name variant does emit a blockdev-del and would be detectable, but requires a preceding media eject to set up, which qemuhotplugtest cannot drive. Mitsuru Kariya (2): qemu: Skip empty disk source when detaching a disk device qemu: Don't prepare an empty disk source on media change src/qemu/qemu_hotplug.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) base-commit: 674fcf87bdd479302032fbeb331fea2aa51606ac -- 2.43.0
