提交 aa7d7313 编写于 作者: P Peter Krempa

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: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 587c0ed1
......@@ -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
......
......@@ -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);
......
......@@ -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)
......
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册