提交 78806cd2 编写于 作者: P Peter Krempa

qemu: monitor: Add monitor API for device_add supporting JSON objects

Rather than formatting a string and splitting it back to a JSON object
add API that will take a JSON object directly.
上级 e584615b
......@@ -2770,6 +2770,24 @@ qemuMonitorAddDevice(qemuMonitorPtr mon,
}
/**
* qemuMonitorAddDeviceArgs:
* @mon: monitor object
* @args: arguments for device add, consumed on success or failure
*
* Adds a device described by @args. Requires JSON monitor.
* Returns 0 on success -1 on error.
*/
int
qemuMonitorAddDeviceArgs(qemuMonitorPtr mon,
virJSONValuePtr args)
{
QEMU_CHECK_MONITOR_JSON(mon);
return qemuMonitorJSONAddDeviceArgs(mon, args);
}
/**
* qemuMonitorAddObject:
* @mon: Pointer to monitor object
......
......@@ -685,6 +685,8 @@ int qemuMonitorAttachPCIDiskController(qemuMonitorPtr mon,
const char *bus,
virPCIDeviceAddress *guestAddr);
int qemuMonitorAddDeviceArgs(qemuMonitorPtr mon,
virJSONValuePtr args);
int qemuMonitorAddDevice(qemuMonitorPtr mon,
const char *devicestr);
......
......@@ -3583,20 +3583,15 @@ int qemuMonitorJSONDelDevice(qemuMonitorPtr mon,
}
int qemuMonitorJSONAddDevice(qemuMonitorPtr mon,
const char *devicestr)
int
qemuMonitorJSONAddDeviceArgs(qemuMonitorPtr mon,
virJSONValuePtr args)
{
int ret = -1;
virJSONValuePtr cmd;
virJSONValuePtr cmd = NULL;
virJSONValuePtr reply = NULL;
virJSONValuePtr args;
cmd = qemuMonitorJSONMakeCommand("device_add", NULL);
if (!cmd)
return -1;
args = qemuMonitorJSONKeywordStringToJSON(devicestr, "driver");
if (!args)
if (!(cmd = qemuMonitorJSONMakeCommand("device_add", NULL)))
goto cleanup;
if (virJSONValueObjectAppend(cmd, "arguments", args) < 0)
......@@ -3618,6 +3613,19 @@ int qemuMonitorJSONAddDevice(qemuMonitorPtr mon,
}
int
qemuMonitorJSONAddDevice(qemuMonitorPtr mon,
const char *devicestr)
{
virJSONValuePtr args;
if (!(args = qemuMonitorJSONKeywordStringToJSON(devicestr, "driver")))
return -1;
return qemuMonitorJSONAddDeviceArgs(mon, args);
}
int qemuMonitorJSONAddObject(qemuMonitorPtr mon,
const char *type,
const char *objalias,
......
......@@ -215,6 +215,8 @@ int qemuMonitorJSONAttachPCIDiskController(qemuMonitorPtr mon,
const char *bus,
virPCIDeviceAddress *guestAddr);
int qemuMonitorJSONAddDeviceArgs(qemuMonitorPtr mon,
virJSONValuePtr args);
int qemuMonitorJSONAddDevice(qemuMonitorPtr mon,
const char *devicestr);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册