1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-01-12 13:17:58 +03:00

qemu: monitor: Add APIs for 'blockdev-create'

The 'blockdev-create' starts a job which creates a storage volume using
the given protocol or formats an existing (added) volume with one of the
supported storage formats.

This patch adds the monitor interaction bits.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2018-09-03 14:45:16 +02:00
parent 587c0ed12a
commit aa7d73134f
4 changed files with 65 additions and 0 deletions

View File

@ -4419,6 +4419,36 @@ qemuMonitorSetWatchdogAction(qemuMonitorPtr mon,
}
/**
* qemuMonitorBlockdevCreate:
* @mon: monitor object
* @jobname: name of the job
* @props: JSON object describing the blockdev to add
*
* Instructs qemu to create/format a new stroage 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(qemuMonitorPtr mon,
const char *jobname,
virJSONValuePtr props)
{
VIR_DEBUG("jobname=%s props=%p", jobname, props);
QEMU_CHECK_MONITOR_GOTO(mon, error);
return qemuMonitorJSONBlockdevCreate(mon, jobname, props);
error:
virJSONValueFree(props);
return -1;
}
/**
* qemuMonitorBlockdevAdd:
* @mon: monitor object

View File

@ -1290,6 +1290,10 @@ virJSONValuePtr qemuMonitorQueryNamedBlockNodes(qemuMonitorPtr mon);
int qemuMonitorSetWatchdogAction(qemuMonitorPtr mon,
const char *action);
int qemuMonitorBlockdevCreate(qemuMonitorPtr mon,
const char *jobname,
virJSONValuePtr props);
int qemuMonitorBlockdevAdd(qemuMonitorPtr mon,
virJSONValuePtr props);

View File

@ -8638,6 +8638,32 @@ qemuMonitorJSONSetWatchdogAction(qemuMonitorPtr mon,
}
int
qemuMonitorJSONBlockdevCreate(qemuMonitorPtr mon,
const char *jobname,
virJSONValuePtr props)
{
VIR_AUTOPTR(virJSONValue) cmd = NULL;
VIR_AUTOPTR(virJSONValue) reply = NULL;
cmd = qemuMonitorJSONMakeCommand("blockdev-create",
"s:job-id", jobname,
"a:options", &props,
NULL);
virJSONValueFree(props);
if (!cmd)
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
return -1;
return 0;
}
int
qemuMonitorJSONBlockdevAdd(qemuMonitorPtr mon,
virJSONValuePtr props)

View File

@ -581,6 +581,11 @@ int qemuMonitorJSONSetWatchdogAction(qemuMonitorPtr mon,
const char *action)
ATTRIBUTE_NONNULL(1);
int qemuMonitorJSONBlockdevCreate(qemuMonitorPtr mon,
const char *jobname,
virJSONValuePtr props)
ATTRIBUTE_NONNULL(1);
int qemuMonitorJSONBlockdevAdd(qemuMonitorPtr mon,
virJSONValuePtr props)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);