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

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

 



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;
> +
> +}
>

--
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]