On Mon, Nov 11, 2024 at 09:53:09 +0100, Martin Kletzander wrote:
> The code just does not match the comment above which says we should
> claim success. And it makes sense since a removal from qemu was
> requested and qemu could not find the device. Without this patch such
> codepath would lead to libvirt not removing the device from the XML and
> no error being set, but the API would still return an error value.
>
> Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
> ---
> src/qemu/qemu_hotplug.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
> index f856e26c1877..d23da0a553c0 100644
> --- a/src/qemu/qemu_hotplug.c
> +++ b/src/qemu/qemu_hotplug.c
> @@ -136,6 +136,7 @@ qemuDomainDeleteDevice(virDomainObj *vm,
> * domain XML is queried right after detach API the
> * device would still be there. */
> VIR_DEBUG("Detaching of device %s failed and no event arrived", alias);
> + rc = 0;
After doing this the function can't return -2, but it will still be
documented as such. There is also a caller which explicitly checks for
-2.
I guess a better course of actions would be to add the '-2' check to
qemuDomainDetachDeviceChr instead. Possibly also to
'qemuDomainHotplugDelVcpu' but there that shouldn't be possible to
happen.