From: Peter Krempa Date: Mon, 4 May 2020 17:32:37 +0000 (+0200) Subject: qemuBuildDriveStr: Refactor formatting of command line for 'sd' cards X-Git-Tag: v6.4.0-rc1~132 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7824bb8548b3bdc3931252c055e83edae115be88;p=thirdparty%2Flibvirt.git qemuBuildDriveStr: Refactor formatting of command line for 'sd' cards 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 Reviewed-by: Michal Privoznik --- diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 3f3e3b69a8..9836972234 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -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