Re: [PATCH v2 3/5] qemuMonitorJSONDelDevice: Return -2 on DeviceNotFound error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 14, 2019 at 13:22:37 +0100, Michal Privoznik wrote:
> A caller might be interested in differentiating the cause for
> error, especially if DeviceNotFound error occurred.
> 
> Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
> ---
>  src/qemu/qemu_monitor.c      | 10 ++++++++++
>  src/qemu/qemu_monitor_json.c |  5 +++++
>  2 files changed, 15 insertions(+)
> 
> diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
> index 8bd4d4d761..5602a20ee4 100644
> --- a/src/qemu/qemu_monitor.c
> +++ b/src/qemu/qemu_monitor.c
> @@ -3008,6 +3008,16 @@ qemuMonitorDriveDel(qemuMonitorPtr mon,
>  }
>  
>  
> +/**
> + * @mon: monitor object
> + * @devalias: alias of the device to detach
> + *
> + * Sends device detach request to qemu.
> + *
> + * Returns: 0 on success,
> + *         -2 if DeviceNotFound error encountered
> + *         -1 otherwise
> + */
>  int
>  qemuMonitorDelDevice(qemuMonitorPtr mon,
>                       const char *devalias)
> diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
> index 0236323a51..5c16e1f3a1 100644
> --- a/src/qemu/qemu_monitor_json.c
> +++ b/src/qemu/qemu_monitor_json.c
> @@ -4191,6 +4191,11 @@ int qemuMonitorJSONDelDevice(qemuMonitorPtr mon,
>      if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
>          goto cleanup;
>  
> +    if (qemuMonitorJSONHasError(reply, "DeviceNotFound")) {
> +        ret = -2;
> +        goto cleanup;

With this patch you'll stop reporting the error. Given that callers
currently jump to an error label this would make us return error
without setting the error object.

Callers need to be fixed that in case when they choose not to ignore the
error they report some error.

Attachment: signature.asc
Description: PGP signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux