]> git.ipfire.org Git - thirdparty/libvirt.git/commit
qemu_hotplug: Do not report unknown error when hot-unplugging non-existing device
authorMartin Kletzander <mkletzan@redhat.com>
Fri, 8 Nov 2024 11:30:06 +0000 (12:30 +0100)
committerMartin Kletzander <mkletzan@redhat.com>
Tue, 12 Nov 2024 14:41:34 +0000 (15:41 +0100)
commitbf2af76ec24aa8042c15b263ecb5e70c52e04837
tree74711781b05da122d5abaa368f86a1cc2908c46e
parentaeebb30ba237f7798cacacbea3aa95e2d034a042
qemu_hotplug: Do not report unknown error when hot-unplugging non-existing device

When qemuDomainDeleteDevice() gets "DeviceNotFound" error it is a
special case as we're trying to remove a device which does not exists
any more.  Such occasion is indicated by the return value -2.

Callers of the aforementioned function ought to base their behaviour on
the return value.  However not all callers take as much care for the
return value as one could realistically anticipate.

Follow the usual direction of removing possible backend object (in case
of character devices), remove the device from its XML without waiting
for the device removal from QEMU (since it is already not there) and
basically follow the same algorithm as there is when the device was
removed, skipping over the wait for the device removal.

The overall return value also needs to be adjusted since
qemuDomainDeleteDevice() does not set an error on the -2 return value
and would otherwise trigger an unknown error being reported to the user
or management application.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_hotplug.c