[libvirt] [PATCH] qemuMonitorJSONEjectMedia: don't stringify the replay at all

Michal Privoznik mprivozn at redhat.com
Tue Dec 15 10:22:41 UTC 2015


On 15.12.2015 11:08, Pavel Hrdina wrote:
> Commit 256496e1 introduced a detection if "is locked" in error replay
> from qemu monitor. Commit c4073657 fixed a memory leak, but it was
> pointed out by Peter, that this could be done cleaner without
> stringifing the replay.
> 
> Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
> ---
>  src/qemu/qemu_monitor_json.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
> index 4ae63cf..d4b6514 100644
> --- a/src/qemu/qemu_monitor_json.c
> +++ b/src/qemu/qemu_monitor_json.c
> @@ -2223,11 +2223,12 @@ int qemuMonitorJSONEjectMedia(qemuMonitorPtr mon,
>          ret = qemuMonitorJSONCheckError(cmd, reply);
>  
>      if (ret < 0) {
> -        char *replyStr = virJSONValueToString(reply, false);
> -
> -        if (c_strcasestr(replyStr, "is locked"))
> -            ret = -2;
> -        VIR_FREE(replyStr);
> +        virJSONValuePtr error = virJSONValueObjectGet(reply, "error");
> +        if (error) {
> +            const char *errorStr = virJSONValueObjectGetString(error, "desc");
> +            if (errorStr && c_strcasestr(errorStr, "is locked"))
> +                ret = -2;
> +        }
>      }
>  
>      virJSONValueFree(cmd);
> 

Hm.. good point. ACK

Michal




More information about the libvir-list mailing list