mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
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.
This commit is contained in:
parent
e584615b81
commit
78806cd21b
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user