]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuBuildDriveStr: Refactor formatting of command line for 'sd' cards
authorPeter Krempa <pkrempa@redhat.com>
Mon, 4 May 2020 17:32:37 +0000 (19:32 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 12 May 2020 04:54:59 +0000 (06:54 +0200)
Remove all the universal code since the 'else' part formats commandline
only for the SD card based disk. Note that we can use virDiskNameToIndex
without the check as we already validate that 'disk->dst' contains a
properly formatted string in the validation code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_command.c

index 3f3e3b69a8af7062fc81f631ebe781c6e5a883a0..9836972234d929a7b98b731073b22278e19f86d0 100644 (file)
@@ -1449,17 +1449,8 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
         virBufferAddLit(&opt, "if=none");
         virBufferAsprintf(&opt, ",id=%s", drivealias);
     } else {
-        int idx = virDiskNameToIndex(disk->dst);
-
-        if (idx < 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("unsupported disk type '%s'"), disk->dst);
-            return NULL;
-        }
-
-        virBufferAsprintf(&opt, "if=%s",
-                          virDomainDiskQEMUBusTypeToString(disk->bus));
-        virBufferAsprintf(&opt, ",index=%d", idx);
+        virBufferAsprintf(&opt, "if=sd,index=%d",
+                          virDiskNameToIndex(disk->dst));
     }
 
     /* werror/rerror are really frontend attributes, but older