The qemu commandline builder's QEMU_BUILD_COMMANDLINE_VALIDATE_KEEP_JSON
flag disables JSON->commandline conversion so that our qemuxml2argvtest
can use the commandline test repostitory for validating our JSON props
generators which are in many cases used on the montitor where we need to
conform to the schema.
Wire this up for the -object/object-add pair by adding a flag to
virQEMUBuildObjectCommandlineFromJSON to pass through JSON and pipe
through the 'flags' variable where necessary.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_command.c | 264 ++++++++++++++++++++++++----------------
src/util/virqemu.c | 16 ++-
src/util/virqemu.h | 3 +-
3 files changed, 176 insertions(+), 107 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 4dde946e82..4050e1e7af 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -189,7 +189,8 @@ VIR_ENUM_IMPL(qemuNumaPolicy,
*/
static int
qemuBuildMasterKeyCommandLine(virCommandPtr cmd,
- qemuDomainObjPrivatePtr priv)
+ qemuDomainObjPrivatePtr priv,
+ unsigned int flags)
{
g_autofree char *alias = NULL;
g_autofree char *path = NULL;
@@ -222,7 +223,8 @@ qemuBuildMasterKeyCommandLine(virCommandPtr cmd,
NULL) < 0)
return -1;
- if (virQEMUBuildObjectCommandlineFromJSON(&buf, props) < 0)
+ if (virQEMUBuildObjectCommandlineFromJSON(&buf, props,
+ (flags &
QEMU_BUILD_COMMANDLINE_VALIDATE_KEEP_JSON)) < 0)
return -1;
virCommandAddArg(cmd, "-object");
@@ -677,6 +679,7 @@ qemuBuildSecretInfoProps(qemuDomainSecretInfoPtr secinfo,
* qemuBuildObjectSecretCommandLine:
* @cmd: the command to modify
* @secinfo: pointer to the secret info object
+ * @flags: commandline builder flags
*
* If the secinfo is available and associated with an AES secret,
* then format the command line for the secret object. This object
@@ -687,7 +690,8 @@ qemuBuildSecretInfoProps(qemuDomainSecretInfoPtr secinfo,
*/
static int
qemuBuildObjectSecretCommandLine(virCommandPtr cmd,
- qemuDomainSecretInfoPtr secinfo)
+ qemuDomainSecretInfoPtr secinfo,
+ unsigned int flags)
{
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
g_autoptr(virJSONValue) props = NULL;
@@ -695,7 +699,8 @@ qemuBuildObjectSecretCommandLine(virCommandPtr cmd,
if (qemuBuildSecretInfoProps(secinfo, &props) < 0)
return -1;
- if (virQEMUBuildObjectCommandlineFromJSON(&buf, props) < 0)
+ if (virQEMUBuildObjectCommandlineFromJSON(&buf, props,
+ (flags &
QEMU_BUILD_COMMANDLINE_VALIDATE_KEEP_JSON)) < 0)
return -1;
virCommandAddArg(cmd, "-object");
@@ -842,6 +847,7 @@ qemuBuildTLSx509BackendProps(const char *tlspath,
* (optional)
* @alias: TLS object alias
* @qemuCaps: capabilities
+ * @flags: commandline builder flags
*
* Create the command line for a TLS object
*
@@ -854,7 +860,8 @@ qemuBuildTLSx509CommandLine(virCommandPtr cmd,
bool verifypeer,
const char *certEncSecretAlias,
const char *alias,
- virQEMUCapsPtr qemuCaps)
+ virQEMUCapsPtr qemuCaps,
+ unsigned int flags)
{
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
g_autoptr(virJSONValue) props = NULL;
@@ -863,7 +870,8 @@ qemuBuildTLSx509CommandLine(virCommandPtr cmd,
certEncSecretAlias, qemuCaps, &props) < 0)
return -1;
- if (virQEMUBuildObjectCommandlineFromJSON(&buf, props) < 0)
+ if (virQEMUBuildObjectCommandlineFromJSON(&buf, props,
+ (flags &
QEMU_BUILD_COMMANDLINE_VALIDATE_KEEP_JSON)) < 0)
return -1;
virCommandAddArg(cmd, "-object");
@@ -1938,14 +1946,16 @@ qemuBuildFloppyCommandLineControllerOptions(virCommandPtr cmd,
static int
qemuBuildObjectCommandline(virCommandPtr cmd,
- virJSONValuePtr objProps)
+ virJSONValuePtr objProps,
+ unsigned int flags)
{
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
if (!objProps)
return 0;
- if (virQEMUBuildObjectCommandlineFromJSON(&buf, objProps) < 0)
+ if (virQEMUBuildObjectCommandlineFromJSON(&buf, objProps,
+ (flags &
QEMU_BUILD_COMMANDLINE_VALIDATE_KEEP_JSON)) < 0)
return -1;
virCommandAddArg(cmd, "-object");
@@ -1957,16 +1967,17 @@ qemuBuildObjectCommandline(virCommandPtr cmd,
static int
qemuBuildBlockStorageSourceAttachDataCommandline(virCommandPtr cmd,
- qemuBlockStorageSourceAttachDataPtr
data)
+ qemuBlockStorageSourceAttachDataPtr
data,
+ unsigned int flags)
{
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, flags) < 0 ||
+ qemuBuildObjectCommandline(cmd, data->authsecretProps, flags) < 0 ||
+ qemuBuildObjectCommandline(cmd, data->encryptsecretProps, flags) < 0 ||
+ qemuBuildObjectCommandline(cmd, data->httpcookiesecretProps, flags) < 0 ||
+ qemuBuildObjectCommandline(cmd, data->tlsKeySecretProps, flags) < 0 ||
+ qemuBuildObjectCommandline(cmd, data->tlsProps, flags) < 0)
return -1;
if (data->driveCmd)
@@ -2003,7 +2014,8 @@ qemuBuildBlockStorageSourceAttachDataCommandline(virCommandPtr cmd,
static int
qemuBuildDiskSourceCommandLine(virCommandPtr cmd,
virDomainDiskDefPtr disk,
- virQEMUCapsPtr qemuCaps)
+ virQEMUCapsPtr qemuCaps,
+ unsigned int flags)
{
g_autoptr(qemuBlockStorageSourceChainData) data = NULL;
g_autoptr(virJSONValue) copyOnReadProps = NULL;
@@ -2029,7 +2041,8 @@ qemuBuildDiskSourceCommandLine(virCommandPtr cmd,
for (i = data->nsrcdata; i > 0; i--) {
if (qemuBuildBlockStorageSourceAttachDataCommandline(cmd,
- data->srcdata[i - 1])
< 0)
+ data->srcdata[i - 1],
+ flags) < 0)
return -1;
}
@@ -2049,11 +2062,12 @@ qemuBuildDiskCommandLine(virCommandPtr cmd,
const virDomainDef *def,
virDomainDiskDefPtr disk,
virQEMUCapsPtr qemuCaps,
- unsigned int bootindex)
+ unsigned int bootindex,
+ unsigned int flags)
{
g_autofree char *optstr = NULL;
- if (qemuBuildDiskSourceCommandLine(cmd, disk, qemuCaps) < 0)
+ if (qemuBuildDiskSourceCommandLine(cmd, disk, qemuCaps, flags) < 0)
return -1;
/* SD cards are currently instantiated via -drive if=sd, so the -device
@@ -2084,7 +2098,8 @@ qemuBuildDiskCommandLine(virCommandPtr cmd,
static int
qemuBuildDisksCommandLine(virCommandPtr cmd,
const virDomainDef *def,
- virQEMUCapsPtr qemuCaps)
+ virQEMUCapsPtr qemuCaps,
+ unsigned int flags)
{
size_t i;
unsigned int bootCD = 0;
@@ -2137,7 +2152,7 @@ qemuBuildDisksCommandLine(virCommandPtr cmd,
if (disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY)
bootindex = 0;
- if (qemuBuildDiskCommandLine(cmd, def, disk, qemuCaps, bootindex) < 0)
+ if (qemuBuildDiskCommandLine(cmd, def, disk, qemuCaps, bootindex, flags) < 0)
return -1;
}
@@ -3204,7 +3219,8 @@ qemuBuildMemoryCellBackendStr(virDomainDefPtr def,
virQEMUDriverConfigPtr cfg,
size_t cell,
qemuDomainObjPrivatePtr priv,
- virBufferPtr buf)
+ virBufferPtr buf,
+ unsigned int flags)
{
g_autoptr(virJSONValue) props = NULL;
g_autofree char *alias = NULL;
@@ -3223,7 +3239,8 @@ qemuBuildMemoryCellBackendStr(virDomainDefPtr def,
priv, def, &mem, false)) < 0)
return -1;
- if (virQEMUBuildObjectCommandlineFromJSON(buf, props) < 0)
+ if (virQEMUBuildObjectCommandlineFromJSON(buf, props,
+ (flags &
QEMU_BUILD_COMMANDLINE_VALIDATE_KEEP_JSON)) < 0)
return -1;
return rc;
@@ -3235,7 +3252,8 @@ qemuBuildMemoryDimmBackendStr(virBufferPtr buf,
virDomainMemoryDefPtr mem,
virDomainDefPtr def,
virQEMUDriverConfigPtr cfg,
- qemuDomainObjPrivatePtr priv)
+ qemuDomainObjPrivatePtr priv,
+ unsigned int flags)
{
g_autoptr(virJSONValue) props = NULL;
g_autofree char *alias = NULL;
@@ -3252,7 +3270,8 @@ qemuBuildMemoryDimmBackendStr(virBufferPtr buf,
priv, def, mem, true) < 0)
return -1;
- if (virQEMUBuildObjectCommandlineFromJSON(buf, props) < 0)
+ if (virQEMUBuildObjectCommandlineFromJSON(buf, props,
+ (flags &
QEMU_BUILD_COMMANDLINE_VALIDATE_KEEP_JSON)) < 0)
return -1;
return 0;
@@ -4746,7 +4765,8 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager,
const virDomainChrSourceDef *dev,
const char *alias,
virQEMUCapsPtr qemuCaps,
- unsigned int cdevflags)
+ unsigned int cdevflags,
+ unsigned int flags)
{
qemuDomainChrSourcePrivatePtr chrSourcePriv = QEMU_DOMAIN_CHR_SOURCE_PRIVATE(dev);
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
@@ -4844,7 +4864,7 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager,
* functions can just check the config fields */
if (chrSourcePriv && chrSourcePriv->secinfo) {
if (qemuBuildObjectSecretCommandLine(cmd,
- chrSourcePriv->secinfo) < 0)
+ chrSourcePriv->secinfo, flags)
< 0)
return NULL;
tlsCertEncSecAlias = chrSourcePriv->secinfo->s.aes.alias;
@@ -4857,7 +4877,7 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager,
dev->data.tcp.listen,
cfg->chardevTLSx509verify,
tlsCertEncSecAlias,
- objalias, qemuCaps) < 0) {
+ objalias, qemuCaps, flags) < 0) {
return NULL;
}
@@ -5073,7 +5093,8 @@ static int
qemuBuildHostdevSCSICommandLine(virCommandPtr cmd,
const virDomainDef *def,
virDomainHostdevDefPtr hostdev,
- virQEMUCapsPtr qemuCaps)
+ virQEMUCapsPtr qemuCaps,
+ unsigned int flags)
{
g_autoptr(qemuBlockStorageSourceAttachData) data = NULL;
g_autofree char *devstr = NULL;
@@ -5082,7 +5103,7 @@ qemuBuildHostdevSCSICommandLine(virCommandPtr cmd,
if (!(data = qemuBuildHostdevSCSIAttachPrepare(hostdev, &backendAlias,
qemuCaps)))
return -1;
- if (qemuBuildBlockStorageSourceAttachDataCommandline(cmd, data) < 0)
+ if (qemuBuildBlockStorageSourceAttachDataCommandline(cmd, data, flags) < 0)
return -1;
virCommandAddArg(cmd, "-device");
@@ -5098,7 +5119,8 @@ static int
qemuBuildHostdevCommandLine(virCommandPtr cmd,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps,
- unsigned int *bootHostdevNet)
+ unsigned int *bootHostdevNet,
+ unsigned int flags)
{
size_t i;
@@ -5152,7 +5174,7 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd,
/* SCSI */
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
- if (qemuBuildHostdevSCSICommandLine(cmd, def, hostdev, qemuCaps) < 0)
+ if (qemuBuildHostdevSCSICommandLine(cmd, def, hostdev, qemuCaps, flags) <
0)
return -1;
break;
@@ -5218,7 +5240,8 @@ qemuBuildMonitorCommandLine(virLogManagerPtr logManager,
virCommandPtr cmd,
virQEMUDriverConfigPtr cfg,
virDomainDefPtr def,
- qemuDomainObjPrivatePtr priv)
+ qemuDomainObjPrivatePtr priv,
+ unsigned int flags)
{
g_autofree char *chrdev = NULL;
unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT |
@@ -5232,7 +5255,7 @@ qemuBuildMonitorCommandLine(virLogManagerPtr logManager,
if (!(chrdev = qemuBuildChrChardevStr(logManager, secManager,
cmd, cfg, def,
priv->monConfig, "monitor",
- priv->qemuCaps, cdevflags)))
+ priv->qemuCaps, cdevflags, flags)))
return -1;
virCommandAddArg(cmd, "-chardev");
virCommandAddArg(cmd, chrdev);
@@ -5340,7 +5363,8 @@ qemuBuildRNGBackendChrdevStr(virLogManagerPtr logManager,
virDomainRNGDefPtr rng,
virQEMUCapsPtr qemuCaps,
char **chr,
- bool chardevStdioLogd)
+ bool chardevStdioLogd,
+ unsigned int flags)
{
unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT |
QEMU_BUILD_CHARDEV_UNIX_FD_PASS;
@@ -5362,7 +5386,7 @@ qemuBuildRNGBackendChrdevStr(virLogManagerPtr logManager,
cmd, cfg, def,
rng->source.chardev,
rng->info.alias, qemuCaps,
- cdevflags)))
+ cdevflags, flags)))
return -1;
break;
}
@@ -5458,7 +5482,8 @@ qemuBuildRNGCommandLine(virLogManagerPtr logManager,
virQEMUDriverConfigPtr cfg,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps,
- bool chardevStdioLogd)
+ bool chardevStdioLogd,
+ unsigned int flags)
{
size_t i;
@@ -5479,7 +5504,7 @@ qemuBuildRNGCommandLine(virLogManagerPtr logManager,
/* possibly add character device for backend */
if (qemuBuildRNGBackendChrdevStr(logManager, secManager, cmd, cfg, def,
rng, qemuCaps, &chardev,
- chardevStdioLogd) < 0)
+ chardevStdioLogd, flags) < 0)
return -1;
if (chardev)
@@ -5488,7 +5513,8 @@ qemuBuildRNGCommandLine(virLogManagerPtr logManager,
if (qemuBuildRNGBackendProps(rng, &props) < 0)
return -1;
- rc = virQEMUBuildObjectCommandlineFromJSON(&buf, props);
+ rc = virQEMUBuildObjectCommandlineFromJSON(&buf, props,
+ (flags &
QEMU_BUILD_COMMANDLINE_VALIDATE_KEEP_JSON));
if (rc < 0)
return -1;
@@ -7042,7 +7068,8 @@ static int
qemuBuildMemCommandLineMemoryDefaultBackend(virCommandPtr cmd,
const virDomainDef *def,
qemuDomainObjPrivatePtr priv,
- const char *defaultRAMid)
+ const char *defaultRAMid,
+ unsigned int flags)
{
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(priv->driver);
g_autoptr(virJSONValue) props = NULL;
@@ -7057,7 +7084,8 @@ qemuBuildMemCommandLineMemoryDefaultBackend(virCommandPtr cmd,
priv, def, &mem, false) < 0)
return -1;
- if (virQEMUBuildObjectCommandlineFromJSON(&buf, props) < 0)
+ if (virQEMUBuildObjectCommandlineFromJSON(&buf, props,
+ (flags &
QEMU_BUILD_COMMANDLINE_VALIDATE_KEEP_JSON)) < 0)
return -1;
virCommandAddArg(cmd, "-object");
@@ -7070,7 +7098,8 @@ static int
qemuBuildMemCommandLine(virCommandPtr cmd,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps,
- qemuDomainObjPrivatePtr priv)
+ qemuDomainObjPrivatePtr priv,
+ unsigned int flags)
{
const char *defaultRAMid = NULL;
@@ -7099,7 +7128,7 @@ qemuBuildMemCommandLine(virCommandPtr cmd,
* However, if domain has one or more NUMA nodes then there is no
* default RAM and we mustn't generate the memory object. */
if (!virDomainNumaGetNodeCount(def->numa))
- qemuBuildMemCommandLineMemoryDefaultBackend(cmd, def, priv, defaultRAMid);
+ qemuBuildMemCommandLineMemoryDefaultBackend(cmd, def, priv, defaultRAMid,
flags);
} else {
if (def->mem.allocation == VIR_DOMAIN_MEMORY_ALLOCATION_IMMEDIATE) {
virCommandAddArgList(cmd, "-mem-prealloc", NULL);
@@ -7130,7 +7159,8 @@ qemuBuildMemCommandLine(virCommandPtr cmd,
static int
qemuBuildIOThreadCommandLine(virCommandPtr cmd,
- const virDomainDef *def)
+ const virDomainDef *def,
+ unsigned int flags)
{
size_t i;
@@ -7145,7 +7175,8 @@ qemuBuildIOThreadCommandLine(virCommandPtr cmd,
if (qemuMonitorCreateObjectProps(&props, "iothread", alias, NULL)
< 0)
return -1;
- if (virQEMUBuildObjectCommandlineFromJSON(&buf, props) < 0)
+ if (virQEMUBuildObjectCommandlineFromJSON(&buf, props,
+ (flags &
QEMU_BUILD_COMMANDLINE_VALIDATE_KEEP_JSON)) < 0)
return -1;
virCommandAddArg(cmd, "-object");
@@ -7288,7 +7319,8 @@ static int
qemuBuildNumaCommandLine(virQEMUDriverConfigPtr cfg,
virDomainDefPtr def,
virCommandPtr cmd,
- qemuDomainObjPrivatePtr priv)
+ qemuDomainObjPrivatePtr priv,
+ unsigned int flags)
{
size_t i, j;
virQEMUCapsPtr qemuCaps = priv->qemuCaps;
@@ -7325,7 +7357,7 @@ qemuBuildNumaCommandLine(virQEMUDriverConfigPtr cfg,
for (i = 0; i < ncells; i++) {
if ((rc = qemuBuildMemoryCellBackendStr(def, cfg, i, priv,
- &nodeBackends[i])) < 0)
+ &nodeBackends[i], flags)) <
0)
goto cleanup;
if (rc == 0)
@@ -7439,7 +7471,8 @@ static int
qemuBuildMemoryDeviceCommandLine(virCommandPtr cmd,
virQEMUDriverConfigPtr cfg,
virDomainDefPtr def,
- qemuDomainObjPrivatePtr priv)
+ qemuDomainObjPrivatePtr priv,
+ unsigned int flags)
{
size_t i;
@@ -7449,7 +7482,7 @@ qemuBuildMemoryDeviceCommandLine(virCommandPtr cmd,
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
char *dimmStr;
- if (qemuBuildMemoryDimmBackendStr(&buf, def->mems[i], def, cfg, priv) <
0)
+ if (qemuBuildMemoryDimmBackendStr(&buf, def->mems[i], def, cfg, priv,
flags) < 0)
return -1;
virCommandAddArg(cmd, "-object");
@@ -7506,7 +7539,8 @@ static int
qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg,
virCommandPtr cmd,
virQEMUCapsPtr qemuCaps,
- virDomainGraphicsDefPtr graphics)
+ virDomainGraphicsDefPtr graphics,
+ unsigned int flags)
{
g_auto(virBuffer) opt = VIR_BUFFER_INITIALIZER;
virDomainGraphicsListenDefPtr glisten = NULL;
@@ -7575,7 +7609,7 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg,
if (gfxPriv->secinfo) {
if (qemuBuildObjectSecretCommandLine(cmd,
- gfxPriv->secinfo) < 0)
+ gfxPriv->secinfo, flags) < 0)
return -1;
secretAlias = gfxPriv->secinfo->s.aes.alias;
}
@@ -7586,7 +7620,8 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg,
cfg->vncTLSx509verify,
secretAlias,
gfxPriv->tlsAlias,
- qemuCaps) < 0)
+ qemuCaps,
+ flags) < 0)
return -1;
virBufferAsprintf(&opt, ",tls-creds=%s",
gfxPriv->tlsAlias);
@@ -7864,7 +7899,8 @@ static int
qemuBuildGraphicsCommandLine(virQEMUDriverConfigPtr cfg,
virCommandPtr cmd,
virDomainDefPtr def,
- virQEMUCapsPtr qemuCaps)
+ virQEMUCapsPtr qemuCaps,
+ unsigned int flags)
{
size_t i;
@@ -7880,7 +7916,7 @@ qemuBuildGraphicsCommandLine(virQEMUDriverConfigPtr cfg,
break;
case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
if (qemuBuildGraphicsVNCCommandLine(cfg, cmd,
- qemuCaps, graphics) < 0)
+ qemuCaps, graphics, flags) < 0)
return -1;
break;
@@ -7917,7 +7953,8 @@ qemuInterfaceVhostuserConnect(virQEMUDriverPtr driver,
virDomainDefPtr def,
virDomainNetDefPtr net,
virQEMUCapsPtr qemuCaps,
- char **chardev)
+ char **chardev,
+ unsigned int flags)
{
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
@@ -7926,7 +7963,7 @@ qemuInterfaceVhostuserConnect(virQEMUDriverPtr driver,
if (!(*chardev = qemuBuildChrChardevStr(logManager, secManager,
cmd, cfg, def,
net->data.vhostuser,
- net->info.alias, qemuCaps, 0)))
+ net->info.alias, qemuCaps, 0,
flags)))
return -1;
break;
@@ -8054,7 +8091,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
requireNicdev = true;
if (qemuInterfaceVhostuserConnect(driver, logManager, secManager,
- cmd, def, net, qemuCaps, &chardev) < 0)
+ cmd, def, net, qemuCaps, &chardev, flags)
< 0)
goto cleanup;
if
(virNetDevOpenvswitchGetVhostuserIfname(net->data.vhostuser->data.nix.path,
@@ -8384,7 +8421,8 @@ qemuBuildSmartcardCommandLine(virLogManagerPtr logManager,
virQEMUDriverConfigPtr cfg,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps,
- bool chardevStdioLogd)
+ bool chardevStdioLogd,
+ unsigned int flags)
{
size_t i;
virDomainSmartcardDefPtr smartcard;
@@ -8439,7 +8477,7 @@ qemuBuildSmartcardCommandLine(virLogManagerPtr logManager,
cmd, cfg, def,
smartcard->data.passthru,
smartcard->info.alias,
- qemuCaps, cdevflags))) {
+ qemuCaps, cdevflags, flags))) {
return -1;
}
virCommandAddArg(cmd, "-chardev");
@@ -8574,7 +8612,8 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManager,
virDomainDefPtr def,
virDomainShmemDefPtr shmem,
virQEMUCapsPtr qemuCaps,
- bool chardevStdioLogd)
+ bool chardevStdioLogd,
+ unsigned int flags)
{
g_autoptr(virJSONValue) memProps = NULL;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
@@ -8621,7 +8660,8 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManager,
if (!(memProps = qemuBuildShmemBackendMemProps(shmem)))
return -1;
- rc = virQEMUBuildObjectCommandlineFromJSON(&buf, memProps);
+ rc = virQEMUBuildObjectCommandlineFromJSON(&buf, memProps,
+ (flags &
QEMU_BUILD_COMMANDLINE_VALIDATE_KEEP_JSON));
if (rc < 0)
return -1;
@@ -8651,7 +8691,7 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManager,
cmd, cfg, def,
&shmem->server.chr,
shmem->info.alias, qemuCaps,
- cdevflags);
+ cdevflags, flags);
if (!chardev)
return -1;
@@ -8751,7 +8791,8 @@ qemuBuildSerialCommandLine(virLogManagerPtr logManager,
virQEMUDriverConfigPtr cfg,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps,
- bool chardevStdioLogd)
+ bool chardevStdioLogd,
+ unsigned int flags)
{
size_t i;
bool havespice = false;
@@ -8778,7 +8819,7 @@ qemuBuildSerialCommandLine(virLogManagerPtr logManager,
cmd, cfg, def,
serial->source,
serial->info.alias,
- qemuCaps, cdevflags)))
+ qemuCaps, cdevflags, flags)))
return -1;
virCommandAddArg(cmd, "-chardev");
virCommandAddArg(cmd, devstr);
@@ -8815,7 +8856,8 @@ qemuBuildParallelsCommandLine(virLogManagerPtr logManager,
virQEMUDriverConfigPtr cfg,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps,
- bool chardevStdioLogd)
+ bool chardevStdioLogd,
+ unsigned int flags)
{
size_t i;
unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT |
@@ -8831,7 +8873,7 @@ qemuBuildParallelsCommandLine(virLogManagerPtr logManager,
cmd, cfg, def,
parallel->source,
parallel->info.alias,
- qemuCaps, cdevflags)))
+ qemuCaps, cdevflags, flags)))
return -1;
virCommandAddArg(cmd, "-chardev");
virCommandAddArg(cmd, devstr);
@@ -8871,7 +8913,7 @@ qemuBuildChannelsCommandLine(virLogManagerPtr logManager,
cmd, cfg, def,
channel->source,
channel->info.alias,
- qemuCaps, cdevflags)))
+ qemuCaps, cdevflags, flags)))
return -1;
virCommandAddArg(cmd, "-chardev");
@@ -8912,7 +8954,8 @@ qemuBuildConsoleCommandLine(virLogManagerPtr logManager,
virQEMUDriverConfigPtr cfg,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps,
- bool chardevStdioLogd)
+ bool chardevStdioLogd,
+ unsigned int flags)
{
size_t i;
unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT |
@@ -8931,7 +8974,7 @@ qemuBuildConsoleCommandLine(virLogManagerPtr logManager,
cmd, cfg, def,
console->source,
console->info.alias,
- qemuCaps, cdevflags)))
+ qemuCaps, cdevflags, flags)))
return -1;
virCommandAddArg(cmd, "-chardev");
virCommandAddArg(cmd, devstr);
@@ -8946,7 +8989,7 @@ qemuBuildConsoleCommandLine(virLogManagerPtr logManager,
cmd, cfg, def,
console->source,
console->info.alias,
- qemuCaps, cdevflags)))
+ qemuCaps, cdevflags, flags)))
return -1;
virCommandAddArg(cmd, "-chardev");
virCommandAddArg(cmd, devstr);
@@ -8961,7 +9004,7 @@ qemuBuildConsoleCommandLine(virLogManagerPtr logManager,
cmd, cfg, def,
console->source,
console->info.alias,
- qemuCaps, cdevflags)))
+ qemuCaps, cdevflags, flags)))
return -1;
virCommandAddArg(cmd, "-chardev");
virCommandAddArg(cmd, devstr);
@@ -9043,7 +9086,8 @@ qemuBuildRedirdevCommandLine(virLogManagerPtr logManager,
virQEMUDriverConfigPtr cfg,
const virDomainDef *def,
virQEMUCapsPtr qemuCaps,
- bool chardevStdioLogd)
+ bool chardevStdioLogd,
+ unsigned int flags)
{
size_t i;
unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT |
@@ -9059,7 +9103,7 @@ qemuBuildRedirdevCommandLine(virLogManagerPtr logManager,
cmd, cfg, def,
redirdev->source,
redirdev->info.alias,
- qemuCaps, cdevflags))) {
+ qemuCaps, cdevflags, flags))) {
return -1;
}
@@ -9342,8 +9386,10 @@ qemuBuildTPMsCommandLine(virCommandPtr cmd,
static int
-qemuBuildSEVCommandLine(virDomainObjPtr vm, virCommandPtr cmd,
- virDomainSEVDefPtr sev)
+qemuBuildSEVCommandLine(virDomainObjPtr vm,
+ virCommandPtr cmd,
+ virDomainSEVDefPtr sev,
+ unsigned int flags)
{
g_autoptr(virJSONValue) props = NULL;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
@@ -9372,7 +9418,8 @@ qemuBuildSEVCommandLine(virDomainObjPtr vm, virCommandPtr cmd,
NULL) < 0)
return -1;
- if (virQEMUBuildObjectCommandlineFromJSON(&buf, props) < 0)
+ if (virQEMUBuildObjectCommandlineFromJSON(&buf, props,
+ (flags &
QEMU_BUILD_COMMANDLINE_VALIDATE_KEEP_JSON)) < 0)
return -1;
virCommandAddArg(cmd, "-object");
@@ -9479,7 +9526,8 @@ qemuBuildPRManagerInfoProps(virStorageSourcePtr src)
static int
qemuBuildManagedPRCommandLine(virCommandPtr cmd,
const virDomainDef *def,
- qemuDomainObjPrivatePtr priv)
+ qemuDomainObjPrivatePtr priv,
+ unsigned int flags)
{
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
g_autoptr(virJSONValue) props = NULL;
@@ -9490,7 +9538,8 @@ qemuBuildManagedPRCommandLine(virCommandPtr cmd,
if (!(props = qemuBuildPRManagedManagerInfoProps(priv)))
return -1;
- if (virQEMUBuildObjectCommandlineFromJSON(&buf, props) < 0)
+ if (virQEMUBuildObjectCommandlineFromJSON(&buf, props,
+ (flags &
QEMU_BUILD_COMMANDLINE_VALIDATE_KEEP_JSON)) < 0)
return -1;
virCommandAddArg(cmd, "-object");
@@ -9503,7 +9552,8 @@ qemuBuildManagedPRCommandLine(virCommandPtr cmd,
static int
qemuBuildPflashBlockdevOne(virCommandPtr cmd,
virStorageSourcePtr src,
- virQEMUCapsPtr qemuCaps)
+ virQEMUCapsPtr qemuCaps,
+ unsigned int flags)
{
g_autoptr(qemuBlockStorageSourceChainData) data = NULL;
size_t i;
@@ -9514,7 +9564,8 @@ qemuBuildPflashBlockdevOne(virCommandPtr cmd,
for (i = data->nsrcdata; i > 0; i--) {
if (qemuBuildBlockStorageSourceAttachDataCommandline(cmd,
- data->srcdata[i - 1])
< 0)
+ data->srcdata[i - 1],
+ flags) < 0)
return -1;
}
@@ -9524,17 +9575,18 @@ qemuBuildPflashBlockdevOne(virCommandPtr cmd,
static int
qemuBuildPflashBlockdevCommandLine(virCommandPtr cmd,
- qemuDomainObjPrivatePtr priv)
+ qemuDomainObjPrivatePtr priv,
+ unsigned int flags)
{
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV))
return 0;
if (priv->pflash0 &&
- qemuBuildPflashBlockdevOne(cmd, priv->pflash0, priv->qemuCaps) < 0)
+ qemuBuildPflashBlockdevOne(cmd, priv->pflash0, priv->qemuCaps, flags) <
0)
return -1;
if (priv->pflash1 &&
- qemuBuildPflashBlockdevOne(cmd, priv->pflash1, priv->qemuCaps) < 0)
+ qemuBuildPflashBlockdevOne(cmd, priv->pflash1, priv->qemuCaps, flags) <
0)
return -1;
return 0;
@@ -9562,7 +9614,8 @@ qemuBuildDBusVMStateInfoProps(virQEMUDriverPtr driver,
static int
qemuBuildDBusVMStateCommandLine(virCommandPtr cmd,
virQEMUDriverPtr driver,
- virDomainObjPtr vm)
+ virDomainObjPtr vm,
+ unsigned int flags)
{
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
g_autoptr(virJSONValue) props = NULL;
@@ -9579,7 +9632,8 @@ qemuBuildDBusVMStateCommandLine(virCommandPtr cmd,
if (!(props = qemuBuildDBusVMStateInfoProps(driver, vm)))
return -1;
- if (virQEMUBuildObjectCommandlineFromJSON(&buf, props) < 0)
+ if (virQEMUBuildObjectCommandlineFromJSON(&buf, props,
+ (flags &
QEMU_BUILD_COMMANDLINE_VALIDATE_KEEP_JSON)) < 0)
return -1;
virCommandAddArg(cmd, "-object");
@@ -9820,16 +9874,16 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
if (!standalone)
virCommandAddArg(cmd, "-S"); /* freeze CPU */
- if (qemuBuildMasterKeyCommandLine(cmd, priv) < 0)
+ if (qemuBuildMasterKeyCommandLine(cmd, priv, flags) < 0)
return NULL;
- if (qemuBuildDBusVMStateCommandLine(cmd, driver, vm) < 0)
+ if (qemuBuildDBusVMStateCommandLine(cmd, driver, vm, flags) < 0)
return NULL;
- if (qemuBuildManagedPRCommandLine(cmd, def, priv) < 0)
+ if (qemuBuildManagedPRCommandLine(cmd, def, priv, flags) < 0)
return NULL;
- if (qemuBuildPflashBlockdevCommandLine(cmd, priv) < 0)
+ if (qemuBuildPflashBlockdevCommandLine(cmd, priv, flags) < 0)
return NULL;
if (enableFips)
@@ -9848,20 +9902,20 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
if (!migrateURI && !snapshot && qemuDomainAlignMemorySizes(def) <
0)
return NULL;
- if (qemuBuildMemCommandLine(cmd, def, qemuCaps, priv) < 0)
+ if (qemuBuildMemCommandLine(cmd, def, qemuCaps, priv, flags) < 0)
return NULL;
if (qemuBuildSmpCommandLine(cmd, def, qemuCaps) < 0)
return NULL;
- if (qemuBuildIOThreadCommandLine(cmd, def) < 0)
+ if (qemuBuildIOThreadCommandLine(cmd, def, flags) < 0)
return NULL;
if (virDomainNumaGetNodeCount(def->numa) &&
- qemuBuildNumaCommandLine(cfg, def, cmd, priv) < 0)
+ qemuBuildNumaCommandLine(cfg, def, cmd, priv, flags) < 0)
return NULL;
- if (qemuBuildMemoryDeviceCommandLine(cmd, cfg, def, priv) < 0)
+ if (qemuBuildMemoryDeviceCommandLine(cmd, cfg, def, priv, flags) < 0)
return NULL;
virUUIDFormat(def->uuid, uuid);
@@ -9900,7 +9954,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
if (qemuBuildSgaCommandLine(cmd, def) < 0)
return NULL;
- if (qemuBuildMonitorCommandLine(logManager, secManager, cmd, cfg, def, priv) < 0)
+ if (qemuBuildMonitorCommandLine(logManager, secManager, cmd, cfg, def, priv, flags)
< 0)
return NULL;
if (qemuBuildClockCommandLine(cmd, def, qemuCaps) < 0)
@@ -9928,7 +9982,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
VIR_DOMAIN_CONTROLLER_TYPE_CCID) < 0)
return NULL;
- if (qemuBuildDisksCommandLine(cmd, def, qemuCaps) < 0)
+ if (qemuBuildDisksCommandLine(cmd, def, qemuCaps, flags) < 0)
return NULL;
if (qemuBuildFilesystemCommandLine(cmd, def, qemuCaps, priv) < 0)
@@ -9940,15 +9994,15 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
return NULL;
if (qemuBuildSmartcardCommandLine(logManager, secManager, cmd, cfg, def, qemuCaps,
- chardevStdioLogd) < 0)
+ chardevStdioLogd, flags) < 0)
return NULL;
if (qemuBuildSerialCommandLine(logManager, secManager, cmd, cfg, def, qemuCaps,
- chardevStdioLogd) < 0)
+ chardevStdioLogd, flags) < 0)
return NULL;
if (qemuBuildParallelsCommandLine(logManager, secManager, cmd, cfg, def, qemuCaps,
- chardevStdioLogd) < 0)
+ chardevStdioLogd, flags) < 0)
return NULL;
if (qemuBuildChannelsCommandLine(logManager, secManager, cmd, cfg, def, qemuCaps,
@@ -9956,7 +10010,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
return NULL;
if (qemuBuildConsoleCommandLine(logManager, secManager, cmd, cfg, def, qemuCaps,
- chardevStdioLogd) < 0)
+ chardevStdioLogd, flags) < 0)
return NULL;
if (qemuBuildTPMsCommandLine(cmd, def, qemuCaps) < 0)
@@ -9965,7 +10019,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
if (qemuBuildInputCommandLine(cmd, def, qemuCaps) < 0)
return NULL;
- if (qemuBuildGraphicsCommandLine(cfg, cmd, def, qemuCaps) < 0)
+ if (qemuBuildGraphicsCommandLine(cfg, cmd, def, qemuCaps, flags) < 0)
return NULL;
if (qemuBuildVideoCommandLine(cmd, def, qemuCaps) < 0)
@@ -9978,10 +10032,10 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
return NULL;
if (qemuBuildRedirdevCommandLine(logManager, secManager, cmd, cfg, def, qemuCaps,
- chardevStdioLogd) < 0)
+ chardevStdioLogd, flags) < 0)
return NULL;
- if (qemuBuildHostdevCommandLine(cmd, def, qemuCaps, &bootHostdevNet) < 0)
+ if (qemuBuildHostdevCommandLine(cmd, def, qemuCaps, &bootHostdevNet, flags) <
0)
return NULL;
if (migrateURI)
@@ -9991,7 +10045,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
return NULL;
if (qemuBuildRNGCommandLine(logManager, secManager, cmd, cfg, def, qemuCaps,
- chardevStdioLogd) < 0)
+ chardevStdioLogd, flags) < 0)
return NULL;
if (qemuBuildNVRAMCommandLine(cmd, def) < 0)
@@ -10000,7 +10054,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
if (qemuBuildVMCoreInfoCommandLine(cmd, def) < 0)
return NULL;
- if (qemuBuildSEVCommandLine(vm, cmd, def->sev) < 0)
+ if (qemuBuildSEVCommandLine(vm, cmd, def->sev, flags) < 0)
return NULL;
if (snapshot)
@@ -10026,7 +10080,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
for (i = 0; i < def->nshmems; i++) {
if (qemuBuildShmemCommandLine(logManager, secManager, cmd, cfg,
def, def->shmems[i], qemuCaps,
- chardevStdioLogd))
+ chardevStdioLogd, flags))
return NULL;
}
diff --git a/src/util/virqemu.c b/src/util/virqemu.c
index 5405c9eac9..fd8661951a 100644
--- a/src/util/virqemu.c
+++ b/src/util/virqemu.c
@@ -346,14 +346,28 @@ virQEMUBuildObjectCommandlineFromJSONInternal(virBufferPtr buf,
}
+/**
+ * virQEMUBuildObjectCommandlineFromJSON:
+ * @buf: buffer to format output to
+ * @objprops: JSON object describing a qemu 'object'
+ * @rawjson: don't transform to commandline args, just stringify json
+ *
+ * Converts @objprops into arguments for -object.
+ *
+ * @rawjson is meant for testing of the schema in the xml2argvtest
+ */
int
virQEMUBuildObjectCommandlineFromJSON(virBufferPtr buf,
- virJSONValuePtr objprops)
+ virJSONValuePtr objprops,
+ bool rawjson)
{
const char *type = virJSONValueObjectGetString(objprops, "qom-type");
const char *alias = virJSONValueObjectGetString(objprops, "id");
virJSONValuePtr props = virJSONValueObjectGetObject(objprops, "props");
+ if (rawjson)
+ return virJSONValueToBuffer(objprops, buf, false);
+
return virQEMUBuildObjectCommandlineFromJSONInternal(buf, type, alias, props);
}
diff --git a/src/util/virqemu.h b/src/util/virqemu.h
index 2b33968158..ef51dcd111 100644
--- a/src/util/virqemu.h
+++ b/src/util/virqemu.h
@@ -54,7 +54,8 @@ virQEMUBuildNetdevCommandlineFromJSON(virJSONValuePtr props,
bool rawjson);
int virQEMUBuildObjectCommandlineFromJSON(virBufferPtr buf,
- virJSONValuePtr objprops);
+ virJSONValuePtr objprops,
+ bool rawjson);
char *virQEMUBuildDriveCommandlineFromJSON(virJSONValuePtr src);
--
2.28.0