qemuMonitorBlockdevCreate: Use double pointer instead of always consuming '@props'

We use this approach for other APIs which take a virJSONValue as
argument and the logic is also simpler.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2021-12-01 09:10:40 +01:00
parent 40a79d52b6
commit 19c7be9ad6
5 changed files with 8 additions and 17 deletions

View File

@ -2710,8 +2710,7 @@ qemuBlockStorageSourceCreateGeneric(virDomainObj *vm,
if (qemuDomainObjEnterMonitorAsync(priv->driver, vm, asyncJob) < 0)
goto cleanup;
rc = qemuMonitorBlockdevCreate(priv->mon, job->name, props);
props = NULL;
rc = qemuMonitorBlockdevCreate(priv->mon, job->name, &props);
qemuDomainObjExitMonitor(priv->driver, vm);
if (rc < 0)

View File

@ -4242,30 +4242,23 @@ qemuMonitorSetWatchdogAction(qemuMonitor *mon,
* qemuMonitorBlockdevCreate:
* @mon: monitor object
* @jobname: name of the job
* @props: JSON object describing the blockdev to add
* @props: JSON object describing the blockdev to add (consumed on success)
*
* Instructs qemu to create/format a new storage or format layer. Note that
* the job does not add the created/formatted image into qemu and
* qemuMonitorBlockdevAdd needs to be called separately with corresponding
* arguments. Note that the arguments for creating and adding are different.
*
* Note that @props is always consumed by this function and should not be
* accessed after calling this function.
*/
int
qemuMonitorBlockdevCreate(qemuMonitor *mon,
const char *jobname,
virJSONValue *props)
virJSONValue **props)
{
VIR_DEBUG("jobname=%s props=%p", jobname, props);
QEMU_CHECK_MONITOR_GOTO(mon, error);
QEMU_CHECK_MONITOR(mon);
return qemuMonitorJSONBlockdevCreate(mon, jobname, props);
error:
virJSONValueFree(props);
return -1;
}
/**

View File

@ -1416,7 +1416,7 @@ int qemuMonitorSetWatchdogAction(qemuMonitor *mon,
int qemuMonitorBlockdevCreate(qemuMonitor *mon,
const char *jobname,
virJSONValue *props);
virJSONValue **props);
int qemuMonitorBlockdevAdd(qemuMonitor *mon,
virJSONValue **props);

View File

@ -7964,16 +7964,15 @@ qemuMonitorJSONSetWatchdogAction(qemuMonitor *mon,
int
qemuMonitorJSONBlockdevCreate(qemuMonitor *mon,
const char *jobname,
virJSONValue *props)
virJSONValue **props)
{
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
cmd = qemuMonitorJSONMakeCommand("blockdev-create",
"s:job-id", jobname,
"a:options", &props,
"a:options", props,
NULL);
virJSONValueFree(props);
if (!cmd)
return -1;

View File

@ -586,7 +586,7 @@ int qemuMonitorJSONSetWatchdogAction(qemuMonitor *mon,
int qemuMonitorJSONBlockdevCreate(qemuMonitor *mon,
const char *jobname,
virJSONValue *props)
virJSONValue **props)
ATTRIBUTE_NONNULL(1);
int qemuMonitorJSONBlockdevAdd(qemuMonitor *mon,