[libvirt PATCH 07/21] qemu: Tweak some code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 src/qemu/qemu_command.c        | 14 ++++++--------
 src/qemu/qemu_domain_address.c | 23 ++++++++++++++++++++++-
 2 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 28bca1519c..bb743e3d84 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6206,15 +6206,14 @@ static int
 qemuBuildIOMMUCommandLine(virCommand *cmd,
                           const virDomainDef *def)
 {
+    g_auto(virBuffer) opts = VIR_BUFFER_INITIALIZER;
     const virDomainIOMMUDef *iommu = def->iommu;
 
     if (!iommu)
         return 0;
 
     switch (iommu->model) {
-    case VIR_DOMAIN_IOMMU_MODEL_INTEL: {
-        g_auto(virBuffer) opts = VIR_BUFFER_INITIALIZER;
-
+    case VIR_DOMAIN_IOMMU_MODEL_INTEL:
         virBufferAddLit(&opts, "intel-iommu");
         if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT) {
             virBufferAsprintf(&opts, ",intremap=%s",
@@ -6238,7 +6237,6 @@ qemuBuildIOMMUCommandLine(virCommand *cmd,
         virCommandAddArg(cmd, "-device");
         virCommandAddArgBuffer(cmd, &opts);
         break;
-    }
 
     case VIR_DOMAIN_IOMMU_MODEL_SMMUV3:
         /* There is no -device for SMMUv3, so nothing to be done here */
@@ -6848,14 +6846,14 @@ qemuBuildMachineCommandLine(virCommand *cmd,
 
     if (def->iommu) {
         switch (def->iommu->model) {
-        case VIR_DOMAIN_IOMMU_MODEL_INTEL:
-            /* The 'intel' IOMMu is formatted in qemuBuildIOMMUCommandLine */
-            break;
-
         case VIR_DOMAIN_IOMMU_MODEL_SMMUV3:
             virBufferAddLit(&buf, ",iommu=smmuv3");
             break;
 
+        case VIR_DOMAIN_IOMMU_MODEL_INTEL:
+            /* These IOMMUs are formatted in qemuBuildIOMMUCommandLine */
+            break;
+
         case VIR_DOMAIN_IOMMU_MODEL_LAST:
         default:
             virReportEnumRangeError(virDomainIOMMUModel, def->iommu->model);
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index c43ad23cf5..733fa35444 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -1001,6 +1001,16 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDef *dev,
         }
         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:
         switch ((virDomainVsockModel) dev->data.vsock->model) {
         case VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL:
@@ -1040,7 +1050,6 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDef *dev,
         /* These devices don't even have a DeviceInfo */
     case VIR_DOMAIN_DEVICE_LEASE:
     case VIR_DOMAIN_DEVICE_GRAPHICS:
-    case VIR_DOMAIN_DEVICE_IOMMU:
     case VIR_DOMAIN_DEVICE_AUDIO:
     case VIR_DOMAIN_DEVICE_LAST:
     case VIR_DOMAIN_DEVICE_NONE:
@@ -2369,6 +2378,18 @@ qemuDomainAssignDevicePCISlots(virDomainDef *def,
         /* 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 &&
         virDeviceInfoPCIAddressIsWanted(&def->vsock->info)) {
 
-- 
2.31.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux