mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 07:17:44 +00:00
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:
parent
40a79d52b6
commit
19c7be9ad6
@ -2710,8 +2710,7 @@ qemuBlockStorageSourceCreateGeneric(virDomainObj *vm,
|
|||||||
if (qemuDomainObjEnterMonitorAsync(priv->driver, vm, asyncJob) < 0)
|
if (qemuDomainObjEnterMonitorAsync(priv->driver, vm, asyncJob) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
rc = qemuMonitorBlockdevCreate(priv->mon, job->name, props);
|
rc = qemuMonitorBlockdevCreate(priv->mon, job->name, &props);
|
||||||
props = NULL;
|
|
||||||
|
|
||||||
qemuDomainObjExitMonitor(priv->driver, vm);
|
qemuDomainObjExitMonitor(priv->driver, vm);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
|
@ -4242,30 +4242,23 @@ qemuMonitorSetWatchdogAction(qemuMonitor *mon,
|
|||||||
* qemuMonitorBlockdevCreate:
|
* qemuMonitorBlockdevCreate:
|
||||||
* @mon: monitor object
|
* @mon: monitor object
|
||||||
* @jobname: name of the job
|
* @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
|
* 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
|
* the job does not add the created/formatted image into qemu and
|
||||||
* qemuMonitorBlockdevAdd needs to be called separately with corresponding
|
* qemuMonitorBlockdevAdd needs to be called separately with corresponding
|
||||||
* arguments. Note that the arguments for creating and adding are different.
|
* 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
|
int
|
||||||
qemuMonitorBlockdevCreate(qemuMonitor *mon,
|
qemuMonitorBlockdevCreate(qemuMonitor *mon,
|
||||||
const char *jobname,
|
const char *jobname,
|
||||||
virJSONValue *props)
|
virJSONValue **props)
|
||||||
{
|
{
|
||||||
VIR_DEBUG("jobname=%s props=%p", jobname, props);
|
VIR_DEBUG("jobname=%s props=%p", jobname, props);
|
||||||
|
|
||||||
QEMU_CHECK_MONITOR_GOTO(mon, error);
|
QEMU_CHECK_MONITOR(mon);
|
||||||
|
|
||||||
return qemuMonitorJSONBlockdevCreate(mon, jobname, props);
|
return qemuMonitorJSONBlockdevCreate(mon, jobname, props);
|
||||||
|
|
||||||
error:
|
|
||||||
virJSONValueFree(props);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1416,7 +1416,7 @@ int qemuMonitorSetWatchdogAction(qemuMonitor *mon,
|
|||||||
|
|
||||||
int qemuMonitorBlockdevCreate(qemuMonitor *mon,
|
int qemuMonitorBlockdevCreate(qemuMonitor *mon,
|
||||||
const char *jobname,
|
const char *jobname,
|
||||||
virJSONValue *props);
|
virJSONValue **props);
|
||||||
|
|
||||||
int qemuMonitorBlockdevAdd(qemuMonitor *mon,
|
int qemuMonitorBlockdevAdd(qemuMonitor *mon,
|
||||||
virJSONValue **props);
|
virJSONValue **props);
|
||||||
|
@ -7964,16 +7964,15 @@ qemuMonitorJSONSetWatchdogAction(qemuMonitor *mon,
|
|||||||
int
|
int
|
||||||
qemuMonitorJSONBlockdevCreate(qemuMonitor *mon,
|
qemuMonitorJSONBlockdevCreate(qemuMonitor *mon,
|
||||||
const char *jobname,
|
const char *jobname,
|
||||||
virJSONValue *props)
|
virJSONValue **props)
|
||||||
{
|
{
|
||||||
g_autoptr(virJSONValue) cmd = NULL;
|
g_autoptr(virJSONValue) cmd = NULL;
|
||||||
g_autoptr(virJSONValue) reply = NULL;
|
g_autoptr(virJSONValue) reply = NULL;
|
||||||
|
|
||||||
cmd = qemuMonitorJSONMakeCommand("blockdev-create",
|
cmd = qemuMonitorJSONMakeCommand("blockdev-create",
|
||||||
"s:job-id", jobname,
|
"s:job-id", jobname,
|
||||||
"a:options", &props,
|
"a:options", props,
|
||||||
NULL);
|
NULL);
|
||||||
virJSONValueFree(props);
|
|
||||||
if (!cmd)
|
if (!cmd)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -586,7 +586,7 @@ int qemuMonitorJSONSetWatchdogAction(qemuMonitor *mon,
|
|||||||
|
|
||||||
int qemuMonitorJSONBlockdevCreate(qemuMonitor *mon,
|
int qemuMonitorJSONBlockdevCreate(qemuMonitor *mon,
|
||||||
const char *jobname,
|
const char *jobname,
|
||||||
virJSONValue *props)
|
virJSONValue **props)
|
||||||
ATTRIBUTE_NONNULL(1);
|
ATTRIBUTE_NONNULL(1);
|
||||||
|
|
||||||
int qemuMonitorJSONBlockdevAdd(qemuMonitor *mon,
|
int qemuMonitorJSONBlockdevAdd(qemuMonitor *mon,
|
||||||
|
Loading…
Reference in New Issue
Block a user