mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-20 19:45:22 +00:00
qemu: Tweak some code
The altered code is functionally equivalent to the previous one, but it's already laid down in a way that will make further changes easier and less messy. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
afd03c21e4
commit
99a042ea13
@ -6428,15 +6428,14 @@ qemuBuildIOMMUCommandLine(virCommand *cmd,
|
|||||||
const virDomainDef *def,
|
const virDomainDef *def,
|
||||||
virQEMUCaps *qemuCaps)
|
virQEMUCaps *qemuCaps)
|
||||||
{
|
{
|
||||||
|
g_autoptr(virJSONValue) props = NULL;
|
||||||
const virDomainIOMMUDef *iommu = def->iommu;
|
const virDomainIOMMUDef *iommu = def->iommu;
|
||||||
|
|
||||||
if (!iommu)
|
if (!iommu)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
switch (iommu->model) {
|
switch (iommu->model) {
|
||||||
case VIR_DOMAIN_IOMMU_MODEL_INTEL: {
|
case VIR_DOMAIN_IOMMU_MODEL_INTEL:
|
||||||
g_autoptr(virJSONValue) props = NULL;
|
|
||||||
|
|
||||||
if (virJSONValueObjectAdd(&props,
|
if (virJSONValueObjectAdd(&props,
|
||||||
"s:driver", "intel-iommu",
|
"s:driver", "intel-iommu",
|
||||||
"S:intremap", qemuOnOffAuto(iommu->intremap),
|
"S:intremap", qemuOnOffAuto(iommu->intremap),
|
||||||
@ -6451,7 +6450,6 @@ qemuBuildIOMMUCommandLine(virCommand *cmd,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
case VIR_DOMAIN_IOMMU_MODEL_SMMUV3:
|
case VIR_DOMAIN_IOMMU_MODEL_SMMUV3:
|
||||||
/* There is no -device for SMMUv3, so nothing to be done here */
|
/* There is no -device for SMMUv3, so nothing to be done here */
|
||||||
@ -7034,14 +7032,14 @@ qemuBuildMachineCommandLine(virCommand *cmd,
|
|||||||
|
|
||||||
if (def->iommu) {
|
if (def->iommu) {
|
||||||
switch (def->iommu->model) {
|
switch (def->iommu->model) {
|
||||||
case VIR_DOMAIN_IOMMU_MODEL_INTEL:
|
|
||||||
/* The 'intel' IOMMu is formatted in qemuBuildIOMMUCommandLine */
|
|
||||||
break;
|
|
||||||
|
|
||||||
case VIR_DOMAIN_IOMMU_MODEL_SMMUV3:
|
case VIR_DOMAIN_IOMMU_MODEL_SMMUV3:
|
||||||
virBufferAddLit(&buf, ",iommu=smmuv3");
|
virBufferAddLit(&buf, ",iommu=smmuv3");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_IOMMU_MODEL_INTEL:
|
||||||
|
/* These IOMMUs are formatted in qemuBuildIOMMUCommandLine */
|
||||||
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_IOMMU_MODEL_LAST:
|
case VIR_DOMAIN_IOMMU_MODEL_LAST:
|
||||||
default:
|
default:
|
||||||
virReportEnumRangeError(virDomainIOMMUModel, def->iommu->model);
|
virReportEnumRangeError(virDomainIOMMUModel, def->iommu->model);
|
||||||
|
@ -1002,6 +1002,16 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDef *dev,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_DEVICE_IOMMU:
|
||||||
|
switch ((virDomainIOMMUModel) dev->data.iommu->model) {
|
||||||
|
case VIR_DOMAIN_IOMMU_MODEL_INTEL:
|
||||||
|
case VIR_DOMAIN_IOMMU_MODEL_SMMUV3:
|
||||||
|
case VIR_DOMAIN_IOMMU_MODEL_LAST:
|
||||||
|
/* These are not PCI devices */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_DEVICE_VSOCK:
|
case VIR_DOMAIN_DEVICE_VSOCK:
|
||||||
switch ((virDomainVsockModel) dev->data.vsock->model) {
|
switch ((virDomainVsockModel) dev->data.vsock->model) {
|
||||||
case VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL:
|
case VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL:
|
||||||
@ -1041,7 +1051,6 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDef *dev,
|
|||||||
/* These devices don't even have a DeviceInfo */
|
/* These devices don't even have a DeviceInfo */
|
||||||
case VIR_DOMAIN_DEVICE_LEASE:
|
case VIR_DOMAIN_DEVICE_LEASE:
|
||||||
case VIR_DOMAIN_DEVICE_GRAPHICS:
|
case VIR_DOMAIN_DEVICE_GRAPHICS:
|
||||||
case VIR_DOMAIN_DEVICE_IOMMU:
|
|
||||||
case VIR_DOMAIN_DEVICE_AUDIO:
|
case VIR_DOMAIN_DEVICE_AUDIO:
|
||||||
case VIR_DOMAIN_DEVICE_LAST:
|
case VIR_DOMAIN_DEVICE_LAST:
|
||||||
case VIR_DOMAIN_DEVICE_NONE:
|
case VIR_DOMAIN_DEVICE_NONE:
|
||||||
@ -2369,6 +2378,18 @@ qemuDomainAssignDevicePCISlots(virDomainDef *def,
|
|||||||
/* Nada - none are PCI based (yet) */
|
/* Nada - none are PCI based (yet) */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (def->iommu) {
|
||||||
|
virDomainIOMMUDef *iommu = def->iommu;
|
||||||
|
|
||||||
|
switch ((virDomainIOMMUModel) iommu->model) {
|
||||||
|
case VIR_DOMAIN_IOMMU_MODEL_INTEL:
|
||||||
|
case VIR_DOMAIN_IOMMU_MODEL_SMMUV3:
|
||||||
|
case VIR_DOMAIN_IOMMU_MODEL_LAST:
|
||||||
|
/* These are not PCI devices */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (def->vsock &&
|
if (def->vsock &&
|
||||||
virDeviceInfoPCIAddressIsWanted(&def->vsock->info)) {
|
virDeviceInfoPCIAddressIsWanted(&def->vsock->info)) {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user