qemu: Tweak Intel IOMMU command line generation

Mostly add comments explaining why there are two capabilites
for the same feature and how they interact.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Andrea Bolognani 2019-05-20 12:48:01 +02:00
parent a7a78c273e
commit 435330d084

View File

@ -6935,8 +6935,12 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
if (!iommu) if (!iommu)
return 0; return 0;
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_IOMMU)) /* qemuDomainDeviceDefValidate() already made sure we have one of
return 0; /* Already handled via -machine */ * 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) { switch (iommu->model) {
case VIR_DOMAIN_IOMMU_MODEL_INTEL: case VIR_DOMAIN_IOMMU_MODEL_INTEL:
@ -7594,7 +7598,10 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
} }
} }
/* We don't report errors on missing cap here - -device code will do that */ /* 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 && if (def->iommu &&
virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_IOMMU)) { virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_IOMMU)) {
switch (def->iommu->model) { switch (def->iommu->model) {