mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-23 04:55: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;
|
virQEMUBuildCommandLineJSONArrayBitmap;
|
||||||
virQEMUBuildCommandLineJSONArrayNumbered;
|
virQEMUBuildCommandLineJSONArrayNumbered;
|
||||||
virQEMUBuildDriveCommandlineFromJSON;
|
virQEMUBuildDriveCommandlineFromJSON;
|
||||||
|
virQEMUBuildObjectCommandlineFromJSON;
|
||||||
virQEMUBuildObjectCommandlineFromJSONType;
|
virQEMUBuildObjectCommandlineFromJSONType;
|
||||||
virQEMUBuildQemuImgKeySecretOpts;
|
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 *
|
char *
|
||||||
virQEMUBuildObjectCommandlineFromJSONType(const char *type,
|
virQEMUBuildObjectCommandlineFromJSONType(const char *type,
|
||||||
const char *alias,
|
const char *alias,
|
||||||
@ -249,10 +272,7 @@ virQEMUBuildObjectCommandlineFromJSONType(const char *type,
|
|||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||||
char *ret = NULL;
|
char *ret = NULL;
|
||||||
|
|
||||||
virBufferAsprintf(&buf, "%s,id=%s,", type, alias);
|
if (virQEMUBuildObjectCommandlineFromJSONInternal(&buf, type, alias, props) < 0)
|
||||||
|
|
||||||
if (virQEMUBuildCommandLineJSON(props, &buf,
|
|
||||||
virQEMUBuildCommandLineJSONArrayBitmap) < 0)
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virBufferCheckError(&buf) < 0)
|
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 *
|
char *
|
||||||
virQEMUBuildDriveCommandlineFromJSON(virJSONValuePtr srcdef)
|
virQEMUBuildDriveCommandlineFromJSON(virJSONValuePtr srcdef)
|
||||||
{
|
{
|
||||||
|
@ -47,6 +47,9 @@ char *virQEMUBuildObjectCommandlineFromJSONType(const char *type,
|
|||||||
const char *alias,
|
const char *alias,
|
||||||
virJSONValuePtr props);
|
virJSONValuePtr props);
|
||||||
|
|
||||||
|
int virQEMUBuildObjectCommandlineFromJSON(virBufferPtr buf,
|
||||||
|
virJSONValuePtr objprops);
|
||||||
|
|
||||||
char *virQEMUBuildDriveCommandlineFromJSON(virJSONValuePtr src);
|
char *virQEMUBuildDriveCommandlineFromJSON(virJSONValuePtr src);
|
||||||
|
|
||||||
void virQEMUBuildBufferEscapeComma(virBufferPtr buf, const char *str);
|
void virQEMUBuildBufferEscapeComma(virBufferPtr buf, const char *str);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user