[libvirt] [PATCH 18/20] qemuagenttest: Introduce testing of shutdown commands

John Ferlan jferlan at redhat.com
Thu Aug 1 11:39:57 UTC 2013


On 07/30/2013 09:05 AM, Peter Krempa wrote:
> This patch exports a few utility functions and adds testing of shutdown
> commands of the guest agent.
> ---

<...snip...>
> +
> +static int
> +qemuAgentShutdownTestMonitorHandler(qemuMonitorTestPtr test,
> +                                    qemuMonitorTestItemPtr item,
> +                                    const char *cmdstr)
> +{
> +    struct qemuAgentShutdownTestData *data;
> +    virJSONValuePtr val = NULL;
> +    virJSONValuePtr args;
> +    const char *cmdname;
> +    const char *mode;
> +    int ret = -1;
> +
> +    data = qemuMonitorTestItemGetPrivateData(item);
> +
> +    if (!(val = virJSONValueFromString(cmdstr)))
> +        return -1;
> +
> +    if (!(cmdname = virJSONValueObjectGetString(val, "execute"))) {
> +        ret = qemuMonitorReportError(test, "Missing command name in %s", cmdstr);
> +        goto cleanup;
> +    }
> +
> +    if (STRNEQ(cmdname, "guest-shutdown")) {
> +        ret = qemuMonitorTestAddUnexpectedErrorResponse(test);
> +        goto cleanup;
> +    }
> +
> +    if (!(args = virJSONValueObjectGet(val, "arguments"))) {
> +        ret = qemuMonitorReportError(test,
> +                                     "Missing arguments section");
> +        goto cleanup;
> +    }
> +

Coverity complains that 'mode' isn't used - while a silly complaint is
there anything that could be done to just compare "mode" against an
"expected" (or perhaps unexpected value)?


247  	    }
248  	

(1) Event returned_pointer: 	Pointer "mode" returned by
"virJSONValueObjectGetString(args, "mode")" is never used.

249  	    if (!(mode = virJSONValueObjectGetString(args, "mode"))) {
250  	        ret = qemuMonitorReportError(test, "Missing shutdown mode");


> +    if (!(mode = virJSONValueObjectGetString(args, "mode"))) {
> +        ret = qemuMonitorReportError(test, "Missing shutdown mode");
> +        goto cleanup;
> +    }
> +
> +    /* now don't reply but return a qemu agent event */
> +    qemuAgentNotifyEvent(qemuMonitorTestGetAgent(test),
> +                         data->event);
> +
> +    ret = 0;
> +
> +cleanup:
> +    virJSONValueFree(val);
> +    return ret;
> +
> +}
>




More information about the libvir-list mailing list