mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemu: command: Introduce helper for building JSON props of -device into commandline
The helper converts the JSON object to a string and adds it to the current command as arguments of '-device'. The helper also prepares for '-device' taking JSON directly. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
89b5bc626a
commit
feaeab09ea
@ -221,6 +221,33 @@ qemuBuildNetdevCommandlineFromJSON(virCommand *cmd,
|
||||
}
|
||||
|
||||
|
||||
static G_GNUC_UNUSED int
|
||||
qemuBuildDeviceCommandlineFromJSON(virCommand *cmd,
|
||||
virJSONValue *props,
|
||||
virQEMUCaps *qemuCaps)
|
||||
{
|
||||
g_autofree char *arg = NULL;
|
||||
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_JSON)) {
|
||||
if (!(arg = virJSONValueToString(props, false)))
|
||||
return -1;
|
||||
} else {
|
||||
const char *driver = virJSONValueObjectGetString(props, "driver");
|
||||
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||
|
||||
virBufferAsprintf(&buf, "%s,", driver);
|
||||
|
||||
if (virQEMUBuildCommandLineJSON(props, &buf, "driver", NULL) < 0)
|
||||
return -1;
|
||||
|
||||
arg = virBufferContentAndReset(&buf);
|
||||
}
|
||||
|
||||
virCommandAddArgList(cmd, "-device", arg, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* qemuBuildMasterKeyCommandLine:
|
||||
* @cmd: the command to modify
|
||||
|
Loading…
x
Reference in New Issue
Block a user