On a Tuesday in 2024, Martin Kletzander wrote:
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(a)redhat.com>
---
v3:
- Skip qemuDomainWaitForDeviceRemoval() when the vCPU does not exist, as
written in the commit message
- Do all the other necessary things when the vCPU is missing
I stared at the condition for so long I did not notice this being
skipped in v2 *facepalm*
v2:
- Adjust for -2 return value in callers
src/qemu/qemu_hotplug.c | 32 +++++++++++++++++++-------------
1 file changed, 19 insertions(+), 13 deletions(-)
Reviewed-by: Ján Tomko <jtomko(a)redhat.com>
Jano