]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Move virBuffer inside switch() statement
authorAndrea Bolognani <abologna@redhat.com>
Tue, 28 May 2019 10:45:26 +0000 (12:45 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Mon, 3 Jun 2019 15:40:41 +0000 (17:40 +0200)
This doesn't make a whole lot of difference now, but once
we introduce more virDomainIOMMUModel values the current
structure will no longer work.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_command.c

index dd7ea0941d4689a56a2e76e7d1175554850bedb5..d5016cc99c37820867533e190a188882eed70aa5 100644 (file)
@@ -6928,7 +6928,6 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
                           const virDomainDef *def,
                           virQEMUCapsPtr qemuCaps)
 {
-    VIR_AUTOCLEAN(virBuffer) opts = VIR_BUFFER_INITIALIZER;
     const virDomainIOMMUDef *iommu = def->iommu;
 
     if (!iommu)
@@ -6942,7 +6941,9 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
         return 0;
 
     switch (iommu->model) {
-    case VIR_DOMAIN_IOMMU_MODEL_INTEL:
+    case VIR_DOMAIN_IOMMU_MODEL_INTEL: {
+        VIR_AUTOCLEAN(virBuffer) opts = VIR_BUFFER_INITIALIZER;
+
         virBufferAddLit(&opts, "intel-iommu");
         if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT) {
             virBufferAsprintf(&opts, ",intremap=%s",
@@ -6960,15 +6961,17 @@ qemuBuildIOMMUCommandLine(virCommandPtr cmd,
             virBufferAsprintf(&opts, ",device-iotlb=%s",
                               virTristateSwitchTypeToString(iommu->iotlb));
         }
+
+        virCommandAddArg(cmd, "-device");
+        virCommandAddArgBuffer(cmd, &opts);
         break;
+    }
 
     case VIR_DOMAIN_IOMMU_MODEL_LAST:
     default:
         virReportEnumRangeError(virDomainIOMMUModel, iommu->model);
         return -1;
     }
-    virCommandAddArg(cmd, "-device");
-    virCommandAddArgBuffer(cmd, &opts);
 
     return 0;
 }