The definition object will be later used to access the qemu namespace
definition used to override device properties.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_command.c | 101 +++++++++++++++++++++-------------------
1 file changed, 53 insertions(+), 48 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index c836799888..8af6179b5c 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -235,6 +235,7 @@ qemuBuildNetdevCommandlineFromJSON(virCommand *cmd,
static int
qemuBuildDeviceCommandlineFromJSON(virCommand *cmd,
virJSONValue *props,
+ const virDomainDef *def G_GNUC_UNUSED,
virQEMUCaps *qemuCaps)
{
g_autofree char *arg = NULL;
@@ -2327,6 +2328,7 @@ qemuBuildZPCIDevProps(virDomainDeviceInfo *dev)
static int
qemuCommandAddExtDevice(virCommand *cmd,
virDomainDeviceInfo *dev,
+ const virDomainDef *def,
virQEMUCaps *qemuCaps)
{
if (dev->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI ||
@@ -2340,7 +2342,7 @@ qemuCommandAddExtDevice(virCommand *cmd,
if (!(devprops = qemuBuildZPCIDevProps(dev)))
return -1;
- if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, qemuCaps) < 0)
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, def, qemuCaps) < 0)
return -1;
}
@@ -2383,6 +2385,7 @@ qemuBuildFloppyCommandLineControllerOptionsExplicit(virCommand
*cmd,
unsigned int bootindexB,
const char *backendA,
const char *backendB,
+ const virDomainDef *def,
virQEMUCaps *qemuCaps)
{
g_autoptr(virJSONValue) props = NULL;
@@ -2396,7 +2399,7 @@ qemuBuildFloppyCommandLineControllerOptionsExplicit(virCommand
*cmd,
NULL) < 0)
return -1;
- if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0)
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, props, def, qemuCaps) < 0)
return -1;
return 0;
@@ -2447,6 +2450,7 @@ qemuBuildFloppyCommandLineControllerOptions(virCommand *cmd,
bootindexB,
backendA,
backendB,
+ def,
qemuCaps) < 0)
return -1;
} else {
@@ -2596,13 +2600,13 @@ qemuBuildDiskCommandLine(virCommand *cmd,
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV))
return 0;
- if (qemuCommandAddExtDevice(cmd, &disk->info, qemuCaps) < 0)
+ if (qemuCommandAddExtDevice(cmd, &disk->info, def, qemuCaps) < 0)
return -1;
if (!(devprops = qemuBuildDiskDeviceProps(def, disk, qemuCaps)))
return -1;
- if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, qemuCaps) < 0)
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, def, qemuCaps) < 0)
return -1;
return 0;
@@ -2690,13 +2694,13 @@ qemuBuildVHostUserFsCommandLine(virCommand *cmd,
if (qemuBuildChardevCommand(cmd, chrsrc, chardev_alias, priv->qemuCaps) < 0)
return -1;
- if (qemuCommandAddExtDevice(cmd, &fs->info, priv->qemuCaps) < 0)
+ if (qemuCommandAddExtDevice(cmd, &fs->info, def, priv->qemuCaps) < 0)
return -1;
if (!(devprops = qemuBuildVHostUserFsDevProps(fs, def, chardev_alias, priv)))
return -1;
- if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, priv->qemuCaps) < 0)
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, def, priv->qemuCaps) <
0)
return -1;
return 0;
@@ -2773,7 +2777,7 @@ qemuBuildFSDevCmd(virCommand *cmd,
if (qemuBuildDeviceAddressProps(devprops, def, &fs->info) < 0)
return -1;
- if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, qemuCaps) < 0)
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, def, qemuCaps) < 0)
return -1;
return 0;
@@ -2793,7 +2797,7 @@ qemuBuildFSDevCommandLine(virCommand *cmd,
return -1;
virCommandAddArg(cmd, fsdevstr);
- if (qemuCommandAddExtDevice(cmd, &fs->info, qemuCaps) < 0)
+ if (qemuCommandAddExtDevice(cmd, &fs->info, def, qemuCaps) < 0)
return -1;
if (qemuBuildFSDevCmd(cmd, def, fs, qemuCaps) < 0)
@@ -3421,10 +3425,10 @@ qemuBuildControllersByTypeCommandLine(virCommand *cmd,
if (!props)
continue;
- if (qemuCommandAddExtDevice(cmd, &cont->info, qemuCaps) < 0)
+ if (qemuCommandAddExtDevice(cmd, &cont->info, def, qemuCaps) < 0)
return -1;
- if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0)
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, props, def, qemuCaps) < 0)
return -1;
}
@@ -4382,13 +4386,13 @@ qemuBuildWatchdogCommandLine(virCommand *cmd,
if (!def->watchdog)
return 0;
- if (qemuCommandAddExtDevice(cmd, &def->watchdog->info, qemuCaps) < 0)
+ if (qemuCommandAddExtDevice(cmd, &def->watchdog->info, def, qemuCaps) <
0)
return -1;
if (!(props = qemuBuildWatchdogDevProps(def, watchdog)))
return -1;
- if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps))
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, props, def, qemuCaps))
return -1;
/* qemu doesn't have a 'dump' action; we tell qemu to 'pause',
then
@@ -4434,10 +4438,10 @@ qemuBuildMemballoonCommandLine(virCommand *cmd,
if (qemuBuildDeviceAddressProps(props, def, &def->memballoon->info) <
0)
return -1;
- if (qemuCommandAddExtDevice(cmd, &def->memballoon->info, qemuCaps) < 0)
+ if (qemuCommandAddExtDevice(cmd, &def->memballoon->info, def, qemuCaps)
< 0)
return -1;
- if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0)
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, props, def, qemuCaps) < 0)
return -1;
return 0;
@@ -4583,7 +4587,7 @@ qemuBuildInputCommandLine(virCommand *cmd,
for (i = 0; i < def->ninputs; i++) {
virDomainInputDef *input = def->inputs[i];
- if (qemuCommandAddExtDevice(cmd, &input->info, qemuCaps) < 0)
+ if (qemuCommandAddExtDevice(cmd, &input->info, def, qemuCaps) < 0)
return -1;
if (input->type == VIR_DOMAIN_INPUT_TYPE_EVDEV) {
@@ -4616,7 +4620,7 @@ qemuBuildInputCommandLine(virCommand *cmd,
}
if (props &&
- qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0)
+ qemuBuildDeviceCommandlineFromJSON(cmd, props, def, qemuCaps) < 0)
return -1;
}
}
@@ -4687,7 +4691,7 @@ qemuBuildSoundDevCmd(virCommand *cmd,
if (qemuBuildDeviceAddressProps(props, def, &sound->info) < 0)
return -1;
- if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0)
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, props, def, qemuCaps) < 0)
return -1;
return 0;
@@ -4720,7 +4724,7 @@ qemuBuildSoundCodecCmd(virCommand *cmd,
NULL) < 0)
return -1;
- if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0)
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, props, def, qemuCaps) < 0)
return -1;
return 0;
@@ -4743,7 +4747,7 @@ qemuBuildSoundCommandLine(virCommand *cmd,
if (sound->model == VIR_DOMAIN_SOUND_MODEL_PCSPK) {
virCommandAddArgList(cmd, "-soundhw", "pcspk", NULL);
} else {
- if (qemuCommandAddExtDevice(cmd, &sound->info, qemuCaps) < 0)
+ if (qemuCommandAddExtDevice(cmd, &sound->info, def, qemuCaps) < 0)
return -1;
if (qemuBuildSoundDevCmd(cmd, def, sound, qemuCaps) < 0)
@@ -4867,7 +4871,7 @@ qemuBuildDeviceVideoCmd(virCommand *cmd,
if (qemuBuildDeviceAddressProps(props, def, &video->info) < 0)
return -1;
- if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0)
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, props, def, qemuCaps) < 0)
return -1;
return 0;
@@ -4905,7 +4909,7 @@ qemuBuildVideoCommandLine(virCommand *cmd,
return -1;
}
- if (qemuCommandAddExtDevice(cmd, &def->videos[i]->info,
priv->qemuCaps) < 0)
+ if (qemuCommandAddExtDevice(cmd, &def->videos[i]->info, def,
priv->qemuCaps) < 0)
return -1;
if (qemuBuildDeviceVideoCmd(cmd, def, video, priv->qemuCaps) < 0)
@@ -5035,7 +5039,7 @@ qemuBuildHubDevCmd(virCommand *cmd,
if (qemuBuildDeviceAddressProps(props, def, &dev->info) < 0)
return -1;
- if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0)
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, props, def, qemuCaps) < 0)
return -1;
return 0;
@@ -5360,7 +5364,7 @@ qemuBuildHostdevSCSICommandLine(virCommand *cmd,
if (!(devprops = qemuBuildSCSIHostdevDevProps(def, hostdev, backendAlias)))
return -1;
- if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, qemuCaps) < 0)
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, def, qemuCaps) < 0)
return -1;
return 0;
@@ -5391,7 +5395,7 @@ qemuBuildHostdevCommandLine(virCommand *cmd,
if (!(devprops = qemuBuildUSBHostdevDevProps(def, hostdev, qemuCaps)))
return -1;
- if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, qemuCaps) < 0)
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, def, qemuCaps) < 0)
return -1;
break;
@@ -5401,13 +5405,13 @@ qemuBuildHostdevCommandLine(virCommand *cmd,
if (hostdev->info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_UNASSIGNED)
continue;
- if (qemuCommandAddExtDevice(cmd, hostdev->info, qemuCaps) < 0)
+ if (qemuCommandAddExtDevice(cmd, hostdev->info, def, qemuCaps) < 0)
return -1;
if (!(devprops = qemuBuildPCIHostdevDevProps(def, hostdev)))
return -1;
- if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, qemuCaps) < 0)
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, def, qemuCaps) < 0)
return -1;
break;
@@ -5436,7 +5440,7 @@ qemuBuildHostdevCommandLine(virCommand *cmd,
vhostfdName)))
return -1;
- if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, qemuCaps) < 0)
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, def, qemuCaps) <
0)
return -1;
}
@@ -5459,7 +5463,7 @@ qemuBuildHostdevCommandLine(virCommand *cmd,
if (!(devprops = qemuBuildHostdevMediatedDevProps(def, hostdev)))
return -1;
- if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, qemuCaps) < 0)
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, def, qemuCaps) < 0)
return -1;
break;
@@ -5732,13 +5736,13 @@ qemuBuildRNGCommandLine(virCommand *cmd,
return -1;
/* add the device */
- if (qemuCommandAddExtDevice(cmd, &rng->info, qemuCaps) < 0)
+ if (qemuCommandAddExtDevice(cmd, &rng->info, def, qemuCaps) < 0)
return -1;
if (!(devprops = qemuBuildRNGDevProps(def, rng, qemuCaps)))
return -1;
- if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, qemuCaps) < 0)
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, def, qemuCaps) < 0)
return -1;
}
@@ -6078,7 +6082,7 @@ qemuBuildVMGenIDCommandLine(virCommand *cmd,
NULL) < 0)
return -1;
- if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0)
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, props, def, qemuCaps) < 0)
return -1;
return 0;
@@ -6404,7 +6408,7 @@ qemuBuildIOMMUCommandLine(virCommand *cmd,
NULL) < 0)
return -1;
- if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0)
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, props, def, qemuCaps) < 0)
return -1;
return 0;
@@ -7730,7 +7734,7 @@ qemuBuildMemoryDeviceCommandLine(virCommand *cmd,
if (!(props = qemuBuildMemoryDeviceProps(cfg, priv, def, def->mems[i])))
return -1;
- if (qemuBuildDeviceCommandlineFromJSON(cmd, props, priv->qemuCaps) < 0)
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, props, def, priv->qemuCaps) <
0)
return -1;
}
@@ -8884,15 +8888,15 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver,
* New way: -netdev type=tap,id=netdev1 -device e1000,id=netdev1
*/
if (qemuDomainSupportsNicdev(def, net)) {
- if (qemuCommandAddExtDevice(cmd, &net->info, qemuCaps) < 0)
+ if (qemuCommandAddExtDevice(cmd, &net->info, def, qemuCaps) < 0)
goto cleanup;
if (!(nicprops = qemuBuildNicDevProps(def, net, net->driver.virtio.queues,
qemuCaps)))
goto cleanup;
- if (qemuBuildDeviceCommandlineFromJSON(cmd, nicprops, qemuCaps) < 0)
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, nicprops, def, qemuCaps) < 0)
goto cleanup;
} else if (!requireNicdev) {
- if (qemuCommandAddExtDevice(cmd, &net->info, qemuCaps) < 0)
+ if (qemuCommandAddExtDevice(cmd, &net->info, def, qemuCaps) < 0)
goto cleanup;
if (!(nic = qemuBuildLegacyNicStr(net)))
@@ -9055,7 +9059,7 @@ qemuBuildSmartcardCommandLine(virCommand *cmd,
NULL) < 0)
return -1;
- if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0)
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, props, def, qemuCaps) < 0)
return -1;
return 0;
@@ -9225,10 +9229,10 @@ qemuBuildShmemCommandLine(virCommand *cmd,
if (!devProps)
return -1;
- if (qemuCommandAddExtDevice(cmd, &shmem->info, qemuCaps) < 0)
+ if (qemuCommandAddExtDevice(cmd, &shmem->info, def, qemuCaps) < 0)
return -1;
- if (qemuBuildDeviceCommandlineFromJSON(cmd, devProps, qemuCaps) < 0)
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, devProps, def, qemuCaps) < 0)
return -1;
if (shmem->server.enabled) {
@@ -9285,7 +9289,7 @@ qemuBuildChrDeviceCommandLine(virCommand *cmd,
if (!(props = qemuBuildChrDeviceProps(def, chr, qemuCaps)))
return -1;
- if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0)
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, props, def, qemuCaps) < 0)
return -1;
return 0;
@@ -9569,7 +9573,7 @@ qemuBuildRedirdevCommandLine(virCommand *cmd,
if (!(devprops = qemuBuildRedirdevDevProps(def, redirdev)))
return -1;
- if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, qemuCaps) < 0)
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, def, qemuCaps) < 0)
return -1;
}
@@ -9671,7 +9675,7 @@ qemuBuildTPMDevCmd(virCommand *cmd,
if (qemuBuildDeviceAddressProps(props, def, &tpm->info) < 0)
return -1;
- if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0)
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, props, def, qemuCaps) < 0)
return -1;
return 0;
@@ -9792,6 +9796,7 @@ qemuBuildTPMCommandLine(virCommand *cmd,
static int
qemuBuildTPMProxyCommandLine(virCommand *cmd,
virDomainTPMDef *tpm,
+ const virDomainDef *def,
virQEMUCaps *qemuCaps)
{
g_autoptr(virJSONValue) props = NULL;
@@ -9803,7 +9808,7 @@ qemuBuildTPMProxyCommandLine(virCommand *cmd,
NULL) < 0)
return -1;
- if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0)
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, props, def, qemuCaps) < 0)
return -1;
return 0;
@@ -9819,7 +9824,7 @@ qemuBuildTPMsCommandLine(virCommand *cmd,
for (i = 0; i < def->ntpms; i++) {
if (def->tpms[i]->model == VIR_DOMAIN_TPM_MODEL_SPAPR_PROXY) {
- if (qemuBuildTPMProxyCommandLine(cmd, def->tpms[i], priv->qemuCaps)
< 0)
+ if (qemuBuildTPMProxyCommandLine(cmd, def->tpms[i], def,
priv->qemuCaps) < 0)
return -1;
} else if (qemuBuildTPMCommandLine(cmd, def, def->tpms[i], priv) < 0) {
return -1;
@@ -9921,7 +9926,7 @@ qemuBuildVMCoreInfoCommandLine(virCommand *cmd,
NULL) < 0)
return -1;
- if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0)
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, props, def, qemuCaps) < 0)
return -1;
return 0;
@@ -9954,7 +9959,7 @@ qemuBuildPanicCommandLine(virCommand *cmd,
return -1;
}
- if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0)
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, props, def, qemuCaps) < 0)
return -1;
break;
@@ -10283,10 +10288,10 @@ qemuBuildVsockCommandLine(virCommand *cmd,
virCommandPassFD(cmd, priv->vhostfd, VIR_COMMAND_PASS_FD_CLOSE_PARENT);
priv->vhostfd = -1;
- if (qemuCommandAddExtDevice(cmd, &vsock->info, qemuCaps) < 0)
+ if (qemuCommandAddExtDevice(cmd, &vsock->info, def, qemuCaps) < 0)
return -1;
- if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, qemuCaps) < 0)
+ if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, def, qemuCaps) < 0)
return -1;
return 0;
--
2.35.1