From: Andrea Bolognani Date: Tue, 28 May 2019 10:49:32 +0000 (+0200) Subject: qemu: Move capability checks inside switch() statements X-Git-Tag: v5.5.0-rc1~364 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=21bb887abc5e4f057dc7ed0d25e7762bf9335208;p=thirdparty%2Flibvirt.git qemu: Move capability checks inside switch() statements Current capability checks are specific to Intel IOMMU, so we need to move them inside the switch() statement before we can introduce more virDomainIOMMUModel values. Signed-off-by: Andrea Bolognani Reviewed-by: Ján Tomko --- diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index d5016cc99c..b2b9bef772 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6933,17 +6933,17 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd, if (!iommu) return 0; - /* qemuDomainDeviceDefValidate() already made sure we have one of - * QEMU_CAPS_DEVICE_INTEL_IOMMU or QEMU_CAPS_MACHINE_IOMMU: here we - * handle the former case, while the latter is taken care of in - * qemuBuildMachineCommandLine() */ - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_INTEL_IOMMU)) - return 0; - switch (iommu->model) { case VIR_DOMAIN_IOMMU_MODEL_INTEL: { VIR_AUTOCLEAN(virBuffer) opts = VIR_BUFFER_INITIALIZER; + /* qemuDomainDeviceDefValidateIOMMU() already made sure we have + * one of QEMU_CAPS_DEVICE_INTEL_IOMMU or QEMU_CAPS_MACHINE_IOMMU: + * here we handle the former case, while the latter is taken care + * of in qemuBuildMachineCommandLine() */ + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_INTEL_IOMMU)) + return 0; + virBufferAddLit(&opts, "intel-iommu"); if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT) { virBufferAsprintf(&opts, ",intremap=%s", @@ -7602,15 +7602,15 @@ qemuBuildMachineCommandLine(virCommandPtr cmd, } } - /* qemuDomainDeviceDefValidate() already made sure we have one of - * QEMU_CAPS_DEVICE_INTEL_IOMMU or QEMU_CAPS_MACHINE_IOMMU: here we - * handle the latter case, while the former is taken care of in - * qemuBuildIOMMUCommandLine() */ - if (def->iommu && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_IOMMU)) { + if (def->iommu) { switch (def->iommu->model) { case VIR_DOMAIN_IOMMU_MODEL_INTEL: - virBufferAddLit(&buf, ",iommu=on"); + /* qemuDomainDeviceDefValidateIOMMU() already made sure we have + * one of QEMU_CAPS_DEVICE_INTEL_IOMMU or QEMU_CAPS_MACHINE_IOMMU: + * here we handle the latter case, while the former is taken care + * of in qemuBuildIOMMUCommandLine() */ + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_IOMMU)) + virBufferAddLit(&buf, ",iommu=on"); break; case VIR_DOMAIN_IOMMU_MODEL_LAST: default: