mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 20:45:18 +00:00
util: qemu: Introduce helper for formatting command line from new object props
Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
f0a23c0c35
commit
efd32528d0
@ -2601,6 +2601,7 @@ virQEMUBuildCommandLineJSON;
|
||||
virQEMUBuildCommandLineJSONArrayBitmap;
|
||||
virQEMUBuildCommandLineJSONArrayNumbered;
|
||||
virQEMUBuildDriveCommandlineFromJSON;
|
||||
virQEMUBuildObjectCommandlineFromJSON;
|
||||
virQEMUBuildObjectCommandlineFromJSONType;
|
||||
virQEMUBuildQemuImgKeySecretOpts;
|
||||
|
||||
|
@ -241,6 +241,29 @@ virQEMUBuildCommandLineJSON(virJSONValuePtr value,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
virQEMUBuildObjectCommandlineFromJSONInternal(virBufferPtr buf,
|
||||
const char *type,
|
||||
const char *alias,
|
||||
virJSONValuePtr props)
|
||||
{
|
||||
if (!type || !alias) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("missing 'type' or 'alias' field of QOM 'object'"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
virBufferAsprintf(buf, "%s,id=%s,", type, alias);
|
||||
|
||||
if (props &&
|
||||
virQEMUBuildCommandLineJSON(props, buf,
|
||||
virQEMUBuildCommandLineJSONArrayBitmap) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
virQEMUBuildObjectCommandlineFromJSONType(const char *type,
|
||||
const char *alias,
|
||||
@ -249,10 +272,7 @@ virQEMUBuildObjectCommandlineFromJSONType(const char *type,
|
||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||
char *ret = NULL;
|
||||
|
||||
virBufferAsprintf(&buf, "%s,id=%s,", type, alias);
|
||||
|
||||
if (virQEMUBuildCommandLineJSON(props, &buf,
|
||||
virQEMUBuildCommandLineJSONArrayBitmap) < 0)
|
||||
if (virQEMUBuildObjectCommandlineFromJSONInternal(&buf, type, alias, props) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virBufferCheckError(&buf) < 0)
|
||||
@ -266,6 +286,18 @@ virQEMUBuildObjectCommandlineFromJSONType(const char *type,
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
virQEMUBuildObjectCommandlineFromJSON(virBufferPtr buf,
|
||||
virJSONValuePtr objprops)
|
||||
{
|
||||
const char *type = virJSONValueObjectGetString(objprops, "qom-type");
|
||||
const char *alias = virJSONValueObjectGetString(objprops, "id");
|
||||
virJSONValuePtr props = virJSONValueObjectGetObject(objprops, "props");
|
||||
|
||||
return virQEMUBuildObjectCommandlineFromJSONInternal(buf, type, alias, props);
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
virQEMUBuildDriveCommandlineFromJSON(virJSONValuePtr srcdef)
|
||||
{
|
||||
|
@ -47,6 +47,9 @@ char *virQEMUBuildObjectCommandlineFromJSONType(const char *type,
|
||||
const char *alias,
|
||||
virJSONValuePtr props);
|
||||
|
||||
int virQEMUBuildObjectCommandlineFromJSON(virBufferPtr buf,
|
||||
virJSONValuePtr objprops);
|
||||
|
||||
char *virQEMUBuildDriveCommandlineFromJSON(virJSONValuePtr src);
|
||||
|
||||
void virQEMUBuildBufferEscapeComma(virBufferPtr buf, const char *str);
|
||||
|
Loading…
x
Reference in New Issue
Block a user