return -1;
cmd = qemuAgentMakeCommand("guest-fsfreeze-freeze-list",
- "a:mountpoints", arg, NULL);
+ "a:mountpoints", &arg, NULL);
} else {
cmd = qemuAgentMakeCommand("guest-fsfreeze-freeze", NULL);
}
if (!cmd)
goto cleanup;
- arg = NULL;
if (qemuAgentCommand(mon, cmd, &reply, true,
VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0)
}
if (!(cmd = qemuAgentMakeCommand("guest-set-vcpus",
- "a:vcpus", cpus,
+ "a:vcpus", &cpus,
NULL)))
goto cleanup;
- cpus = NULL;
-
if (qemuAgentCommand(mon, cmd, &reply, true,
VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0)
goto cleanup;
"s:driver", "gluster",
"s:volume", src->volume,
"s:path", src->path,
- "a:server", servers, NULL) < 0)
+ "a:server", &servers, NULL) < 0)
goto cleanup;
- servers = NULL;
-
if (src->debug &&
virJSONValueObjectAdd(props, "u:debug", src->debugLevel, NULL) < 0)
goto cleanup;
"s:driver", protocol,
"S:tls-creds", src->tlsAlias,
"s:vdisk-id", src->path,
- "a:server", server, NULL) < 0)
+ "a:server", &server, NULL) < 0)
virJSONValueFree(server);
return ret;
if (virJSONValueObjectCreate(&ret,
"s:driver", "nbd",
- "a:server", serverprops,
+ "a:server", &serverprops,
"S:export", src->path,
"S:tls-creds", src->tlsAlias,
NULL) < 0)
goto cleanup;
- serverprops = NULL;
-
cleanup:
virJSONValueFree(serverprops);
return ret;
"s:image", src->path,
"S:snapshot", src->snapshot,
"S:conf", src->configFile,
- "A:server", servers,
+ "A:server", &servers,
"S:user", username,
NULL) < 0)
goto cleanup;
- servers = NULL;
-
cleanup:
virJSONValueFree(servers);
return ret;
/* libvirt does not support the 'snap-id' and 'tag' properties */
if (virJSONValueObjectCreate(&ret,
"s:driver", "sheepdog",
- "a:server", serverprops,
+ "a:server", &serverprops,
"s:vdi", src->path,
NULL) < 0)
goto cleanup;
- serverprops = NULL;
-
cleanup:
virJSONValueFree(serverprops);
return ret;
if (virJSONValueObjectCreate(&ret,
"s:driver", "ssh",
"s:path", src->path,
- "a:server", serverprops,
+ "a:server", &serverprops,
"S:user", username,
NULL) < 0)
goto cleanup;
- serverprops = NULL;
-
cleanup:
virJSONValueFree(serverprops);
return ret;
if (!(props = qemuBlockStorageSourceGetBackendProps(src)))
return NULL;
- if (virJSONValueObjectCreate(&ret, "a:file", props, NULL) < 0) {
+ if (virJSONValueObjectCreate(&ret, "a:file", &props, NULL) < 0) {
virJSONValueFree(props);
return NULL;
}
cmd = qemuMonitorJSONMakeCommand("object-add",
"s:qom-type", type,
"s:id", objalias,
- "A:props", props,
+ "A:props", &props,
NULL);
if (!cmd)
goto cleanup;
- /* @props is part of @cmd now. Avoid double free */
- props = NULL;
-
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
goto cleanup;
int ret = -1;
virJSONValuePtr cmd;
virJSONValuePtr reply = NULL;
+ virJSONValuePtr act = actions;
bool protect = actions->protect;
/* We do NOT want to free actions when recursively freeing cmd. */
actions->protect = true;
cmd = qemuMonitorJSONMakeCommand("transaction",
- "a:actions", actions,
+ "a:actions", &act,
NULL);
if (!cmd)
goto cleanup;
}
cmd = qemuMonitorJSONMakeCommand("send-key",
- "a:keys", keys,
+ "a:keys", &keys,
"p:hold-time", holdtime,
NULL);
if (!cmd)
goto cleanup;
- /* @keys is part of @cmd now. Avoid double free */
- keys = NULL;
-
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
goto cleanup;
if (!(cmd = qemuMonitorJSONMakeCommand("query-cpu-model-expansion",
"s:type", typeStr,
- "a:model", model,
+ "a:model", &model,
NULL)))
goto cleanup;
- /* model will be freed when cmd is freed. we set model
- * to NULL to avoid double freeing.
- */
- model = NULL;
-
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
goto cleanup;
cap = NULL;
cmd = qemuMonitorJSONMakeCommand("migrate-set-capabilities",
- "a:capabilities", caps,
+ "a:capabilities", &caps,
NULL);
if (!cmd)
goto cleanup;
- caps = NULL;
-
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
goto cleanup;
return NULL;
if (virJSONValueObjectCreate(&addr, "s:type", "inet",
- "a:data", data, NULL) < 0) {
+ "a:data", &data, NULL) < 0) {
virJSONValueFree(data);
return NULL;
}
return NULL;
if (virJSONValueObjectCreate(&addr, "s:type", "unix",
- "a:data", data, NULL) < 0) {
+ "a:data", &data, NULL) < 0) {
virJSONValueFree(data);
return NULL;
}
return ret;
if (!(cmd = qemuMonitorJSONMakeCommand("nbd-server-start",
- "a:addr", addr,
+ "a:addr", &addr,
NULL)))
goto cleanup;
- /* From now on, @addr is part of @cmd */
- addr = NULL;
-
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
goto cleanup;
if (!(ret = qemuMonitorJSONMakeCommand("chardev-add",
"s:id", chrID,
- "a:backend", backend,
+ "a:backend", &backend,
NULL)))
goto cleanup;
- backend = NULL;
cleanup:
VIR_FREE(tlsalias);
* d: double precision floating point number
* n: json null value
*
+ * The following two cases take a pointer to a pointer to a virJSONValuePtr. The
+ * pointer is cleared when the virJSONValuePtr is stolen into the object.
* a: json object, must be non-NULL
* A: json object, omitted if NULL
+ *
* m: a bitmap represented as a JSON array, must be non-NULL
* M: a bitmap represented as a JSON array, omitted if NULL
*
case 'A':
case 'a': {
- virJSONValuePtr val = va_arg(args, virJSONValuePtr);
+ virJSONValuePtr *val = va_arg(args, virJSONValuePtr *);
- if (!val) {
+ if (!(*val)) {
if (type == 'A')
continue;
goto cleanup;
}
- rc = virJSONValueObjectAppend(obj, key, val);
+ if ((rc = virJSONValueObjectAppend(obj, key, *val)) == 0)
+ *val = NULL;
} break;
case 'M':
goto cleanup;
}
- if (virJSONValueObjectCreate(&wrapper, "a:file", backendprops, NULL) < 0)
+ if (virJSONValueObjectCreate(&wrapper, "a:file", &backendprops, NULL) < 0)
goto cleanup;
- backendprops = NULL;
-
if (!(propsstr = virJSONValueToString(wrapper, false)))
goto cleanup;