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

Re: [libvirt] [PATCH 2/2] check whether qemuMonitorJSONHMP() failed



On Tue, Mar 29, 2011 at 17:48:48 +0800, Wen Congyang wrote:
> diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
> index eed83f4..647e2bb 100644
> --- a/src/qemu/qemu_monitor.c
> +++ b/src/qemu/qemu_monitor.c
> @@ -906,7 +906,14 @@ int qemuMonitorSetCapabilities(qemuMonitorPtr mon)
>  
>      if (mon->json) {
>          ret = qemuMonitorJSONSetCapabilities(mon);
> -        mon->json_hmp = qemuMonitorJSONCheckHMP(mon);
> +        if (ret == 0) {
> +            mon->json_hmp = qemuMonitorJSONCheckHMP(mon);
> +            if (mon->json_hmp < 0) {
> +                /* qemu may quited unexpectedly when we call
> +                 * qemuMonitorJSONCheckHMP() */
> +                ret = -1;
> +            }
> +        }

This shouldn't really work since mon->json_hmp is declared as
    unsigned json_hmp: 1;

I think we need something like

    if (ret == 0) {
        int hmp = qemuMonitorJSONCheckHMP(mon);
        if (hmp < 0) {
            ...
        } else {
            mon->json_hmp = hmp > 0;
        }
    }

Jirka


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