);
+static int
+qemuBuildObjectCommandlineFromJSON(virBuffer *buf,
+ virJSONValue *props,
+ virQEMUCaps *qemuCaps)
+{
+ const char *type = virJSONValueObjectGetString(props, "qom-type");
+ const char *alias = virJSONValueObjectGetString(props, "id");
+
+ if (!type || !alias) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("missing 'type'(%s) or 'alias'(%s) field of QOM 'object'"),
+ NULLSTR(type), NULLSTR(alias));
+ return -1;
+ }
+
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_QAPIFIED)) {
+ return virJSONValueToBuffer(props, buf, false);
+ } else {
+ virBufferAsprintf(buf, "%s,", type);
+
+ return virQEMUBuildCommandLineJSON(props, buf, "qom-type",
+ virQEMUBuildCommandLineJSONArrayBitmap);
+ }
+}
+
/**
* qemuBuildMasterKeyCommandLine:
NULL) < 0)
return -1;
- if (virQEMUBuildObjectCommandlineFromJSON(&buf, props) < 0)
+ if (qemuBuildObjectCommandlineFromJSON(&buf, props, priv->qemuCaps) < 0)
return -1;
virCommandAddArg(cmd, "-object");
* qemuBuildObjectSecretCommandLine:
* @cmd: the command to modify
* @secinfo: pointer to the secret info object
+ * @qemuCaps: qemu capabilities
*
* If the secinfo is available and associated with an AES secret,
* then format the command line for the secret object. This object
*/
static int
qemuBuildObjectSecretCommandLine(virCommandPtr cmd,
- qemuDomainSecretInfoPtr secinfo)
+ qemuDomainSecretInfoPtr secinfo,
+ virQEMUCaps *qemuCaps)
{
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
g_autoptr(virJSONValue) props = NULL;
if (qemuBuildSecretInfoProps(secinfo, &props) < 0)
return -1;
- if (virQEMUBuildObjectCommandlineFromJSON(&buf, props) < 0)
+ if (qemuBuildObjectCommandlineFromJSON(&buf, props, qemuCaps) < 0)
return -1;
virCommandAddArg(cmd, "-object");
certEncSecretAlias, qemuCaps, &props) < 0)
return -1;
- if (virQEMUBuildObjectCommandlineFromJSON(&buf, props) < 0)
+ if (qemuBuildObjectCommandlineFromJSON(&buf, props, qemuCaps) < 0)
return -1;
virCommandAddArg(cmd, "-object");
static int
qemuBuildObjectCommandline(virCommandPtr cmd,
- virJSONValuePtr objProps)
+ virJSONValuePtr objProps,
+ virQEMUCaps *qemuCaps)
{
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
if (!objProps)
return 0;
- if (virQEMUBuildObjectCommandlineFromJSON(&buf, objProps) < 0)
+ if (qemuBuildObjectCommandlineFromJSON(&buf, objProps, qemuCaps) < 0)
return -1;
virCommandAddArg(cmd, "-object");
static int
qemuBuildBlockStorageSourceAttachDataCommandline(virCommandPtr cmd,
- qemuBlockStorageSourceAttachDataPtr data)
+ qemuBlockStorageSourceAttachDataPtr data,
+ virQEMUCaps *qemuCaps)
{
char *tmp;
- if (qemuBuildObjectCommandline(cmd, data->prmgrProps) < 0 ||
- qemuBuildObjectCommandline(cmd, data->authsecretProps) < 0 ||
- qemuBuildObjectCommandline(cmd, data->encryptsecretProps) < 0 ||
- qemuBuildObjectCommandline(cmd, data->httpcookiesecretProps) < 0 ||
- qemuBuildObjectCommandline(cmd, data->tlsKeySecretProps) < 0 ||
- qemuBuildObjectCommandline(cmd, data->tlsProps) < 0)
+ if (qemuBuildObjectCommandline(cmd, data->prmgrProps, qemuCaps) < 0 ||
+ qemuBuildObjectCommandline(cmd, data->authsecretProps, qemuCaps) < 0 ||
+ qemuBuildObjectCommandline(cmd, data->encryptsecretProps, qemuCaps) < 0 ||
+ qemuBuildObjectCommandline(cmd, data->httpcookiesecretProps, qemuCaps) < 0 ||
+ qemuBuildObjectCommandline(cmd, data->tlsKeySecretProps, qemuCaps) < 0 ||
+ qemuBuildObjectCommandline(cmd, data->tlsProps, qemuCaps) < 0)
return -1;
if (data->driveCmd)
for (i = data->nsrcdata; i > 0; i--) {
if (qemuBuildBlockStorageSourceAttachDataCommandline(cmd,
- data->srcdata[i - 1]) < 0)
+ data->srcdata[i - 1],
+ qemuCaps) < 0)
return -1;
}
priv, def, &mem, false, false)) < 0)
return -1;
- if (virQEMUBuildObjectCommandlineFromJSON(buf, props) < 0)
+ if (qemuBuildObjectCommandlineFromJSON(buf, props, priv->qemuCaps) < 0)
return -1;
return rc;
priv, def, mem, true, false) < 0)
return -1;
- if (virQEMUBuildObjectCommandlineFromJSON(buf, props) < 0)
+ if (qemuBuildObjectCommandlineFromJSON(buf, props, priv->qemuCaps) < 0)
return -1;
return 0;
* functions can just check the config fields */
if (chrSourcePriv && chrSourcePriv->secinfo) {
if (qemuBuildObjectSecretCommandLine(cmd,
- chrSourcePriv->secinfo) < 0)
+ chrSourcePriv->secinfo,
+ qemuCaps) < 0)
return NULL;
tlsCertEncSecAlias = chrSourcePriv->secinfo->s.aes.alias;
if (!(data = qemuBuildHostdevSCSIAttachPrepare(hostdev, &backendAlias, qemuCaps)))
return -1;
- if (qemuBuildBlockStorageSourceAttachDataCommandline(cmd, data) < 0)
+ if (qemuBuildBlockStorageSourceAttachDataCommandline(cmd, data, qemuCaps) < 0)
return -1;
virCommandAddArg(cmd, "-device");
if (qemuBuildRNGBackendProps(rng, &props) < 0)
return -1;
- rc = virQEMUBuildObjectCommandlineFromJSON(&buf, props);
+ rc = qemuBuildObjectCommandlineFromJSON(&buf, props, qemuCaps);
if (rc < 0)
return -1;
priv, def, &mem, false, true) < 0)
return -1;
- if (virQEMUBuildObjectCommandlineFromJSON(&buf, props) < 0)
+ if (qemuBuildObjectCommandlineFromJSON(&buf, props, priv->qemuCaps) < 0)
return -1;
virCommandAddArg(cmd, "-object");
static int
qemuBuildIOThreadCommandLine(virCommandPtr cmd,
- const virDomainDef *def)
+ const virDomainDef *def,
+ virQEMUCaps *qemuCaps)
{
size_t i;
if (qemuMonitorCreateObjectProps(&props, "iothread", alias, NULL) < 0)
return -1;
- if (virQEMUBuildObjectCommandlineFromJSON(&buf, props) < 0)
+ if (qemuBuildObjectCommandlineFromJSON(&buf, props, qemuCaps) < 0)
return -1;
virCommandAddArg(cmd, "-object");
if (gfxPriv->secinfo) {
if (qemuBuildObjectSecretCommandLine(cmd,
- gfxPriv->secinfo) < 0)
+ gfxPriv->secinfo,
+ qemuCaps) < 0)
return -1;
secretAlias = gfxPriv->secinfo->s.aes.alias;
}
if (!(memProps = qemuBuildShmemBackendMemProps(shmem)))
return -1;
- rc = virQEMUBuildObjectCommandlineFromJSON(&buf, memProps);
+ rc = qemuBuildObjectCommandlineFromJSON(&buf, memProps, qemuCaps);
if (rc < 0)
return -1;
NULL) < 0)
return -1;
- if (virQEMUBuildObjectCommandlineFromJSON(&buf, props) < 0)
+ if (qemuBuildObjectCommandlineFromJSON(&buf, props, priv->qemuCaps) < 0)
return -1;
virCommandAddArg(cmd, "-object");
if (!(props = qemuBuildPRManagedManagerInfoProps(priv)))
return -1;
- if (virQEMUBuildObjectCommandlineFromJSON(&buf, props) < 0)
+ if (qemuBuildObjectCommandlineFromJSON(&buf, props, priv->qemuCaps) < 0)
return -1;
virCommandAddArg(cmd, "-object");
for (i = data->nsrcdata; i > 0; i--) {
if (qemuBuildBlockStorageSourceAttachDataCommandline(cmd,
- data->srcdata[i - 1]) < 0)
+ data->srcdata[i - 1],
+ qemuCaps) < 0)
return -1;
}
if (!(props = qemuBuildDBusVMStateInfoProps(driver, vm)))
return -1;
- if (virQEMUBuildObjectCommandlineFromJSON(&buf, props) < 0)
+ if (qemuBuildObjectCommandlineFromJSON(&buf, props, priv->qemuCaps) < 0)
return -1;
virCommandAddArg(cmd, "-object");
if (qemuBuildSmpCommandLine(cmd, def, qemuCaps) < 0)
return NULL;
- if (qemuBuildIOThreadCommandLine(cmd, def) < 0)
+ if (qemuBuildIOThreadCommandLine(cmd, def, qemuCaps) < 0)
return NULL;
if (virDomainNumaGetNodeCount(def->numa) &&