[libvirt] [PATCH 18/20] qemuagenttest: Introduce testing of shutdown commands
Peter Krempa
pkrempa at redhat.com
Thu Aug 1 13:30:27 UTC 2013
On 08/01/13 13:39, John Ferlan wrote:
> 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");
Oh right, I was intending to do that check but forgot to write the
condition. I'll post a fix in a while.
>
>
>> + 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;
>> +
>> +}
>>
Peter
More information about the libvir-list
mailing list