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

qemu: monitor: Add implementation for blockdev-add and blockdev-del

Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
上级 a6178a66
...@@ -4412,3 +4412,40 @@ qemuMonitorSetWatchdogAction(qemuMonitorPtr mon, ...@@ -4412,3 +4412,40 @@ qemuMonitorSetWatchdogAction(qemuMonitorPtr mon,
return qemuMonitorJSONSetWatchdogAction(mon, action); return qemuMonitorJSONSetWatchdogAction(mon, action);
} }
/**
* qemuMonitorBlockdevAdd:
* @mon: monitor object
* @props: JSON object describing the blockdev to add
*
* Adds a new block device (BDS) to qemu. Note that @props is always consumed
* by this function and should not be accessed after calling this function.
*/
int
qemuMonitorBlockdevAdd(qemuMonitorPtr mon,
virJSONValuePtr props)
{
VIR_DEBUG("props=%p (node-name=%s)", props,
NULLSTR(virJSONValueObjectGetString(props, "node-name")));
QEMU_CHECK_MONITOR_JSON_GOTO(mon, error);
return qemuMonitorJSONBlockdevAdd(mon, props);
error:
virJSONValueFree(props);
return -1;
}
int
qemuMonitorBlockdevDel(qemuMonitorPtr mon,
const char *nodename)
{
VIR_DEBUG("nodename=%s", nodename);
QEMU_CHECK_MONITOR_JSON(mon);
return qemuMonitorJSONBlockdevDel(mon, nodename);
}
...@@ -1142,4 +1142,11 @@ virJSONValuePtr qemuMonitorQueryNamedBlockNodes(qemuMonitorPtr mon); ...@@ -1142,4 +1142,11 @@ virJSONValuePtr qemuMonitorQueryNamedBlockNodes(qemuMonitorPtr mon);
int qemuMonitorSetWatchdogAction(qemuMonitorPtr mon, int qemuMonitorSetWatchdogAction(qemuMonitorPtr mon,
const char *action); const char *action);
int qemuMonitorBlockdevAdd(qemuMonitorPtr mon,
virJSONValuePtr props);
int qemuMonitorBlockdevDel(qemuMonitorPtr mon,
const char *nodename);
#endif /* QEMU_MONITOR_H */ #endif /* QEMU_MONITOR_H */
...@@ -7889,3 +7889,58 @@ qemuMonitorJSONSetWatchdogAction(qemuMonitorPtr mon, ...@@ -7889,3 +7889,58 @@ qemuMonitorJSONSetWatchdogAction(qemuMonitorPtr mon,
virJSONValueFree(reply); virJSONValueFree(reply);
return ret; return ret;
} }
int
qemuMonitorJSONBlockdevAdd(qemuMonitorPtr mon,
virJSONValuePtr props)
{
virJSONValuePtr cmd;
virJSONValuePtr reply = NULL;
int ret = -1;
if (!(cmd = qemuMonitorJSONMakeCommandInternal("blockdev-add",
props, false)))
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
goto cleanup;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
goto cleanup;
ret = 0;
cleanup:
virJSONValueFree(cmd);
virJSONValueFree(reply);
return ret;
}
int
qemuMonitorJSONBlockdevDel(qemuMonitorPtr mon,
const char *nodename)
{
virJSONValuePtr cmd;
virJSONValuePtr reply = NULL;
int ret = -1;
if (!(cmd = qemuMonitorJSONMakeCommand("blockdev-del",
"s:node-name", nodename,
NULL)))
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
goto cleanup;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
goto cleanup;
ret = 0;
cleanup:
virJSONValueFree(cmd);
virJSONValueFree(reply);
return ret;
}
...@@ -537,4 +537,13 @@ virJSONValuePtr qemuMonitorJSONQueryNamedBlockNodes(qemuMonitorPtr mon) ...@@ -537,4 +537,13 @@ virJSONValuePtr qemuMonitorJSONQueryNamedBlockNodes(qemuMonitorPtr mon)
int qemuMonitorJSONSetWatchdogAction(qemuMonitorPtr mon, int qemuMonitorJSONSetWatchdogAction(qemuMonitorPtr mon,
const char *action) const char *action)
ATTRIBUTE_NONNULL(1); ATTRIBUTE_NONNULL(1);
int qemuMonitorJSONBlockdevAdd(qemuMonitorPtr mon,
virJSONValuePtr props)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
int qemuMonitorJSONBlockdevDel(qemuMonitorPtr mon,
const char *nodename)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
#endif /* QEMU_MONITOR_JSON_H */ #endif /* QEMU_MONITOR_JSON_H */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册