Patchwork [2/3] block: drive_init(): Simplify interface type setting

login
register
mail settings
Submitter Luiz Capitulino
Date June 30, 2011, 6:33 p.m.
Message ID <1309458783-12661-3-git-send-email-lcapitulino@redhat.com>
Download mbox | patch
Permalink /patch/102808/
State New
Headers show

Comments

Luiz Capitulino - June 30, 2011, 6:33 p.m.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 blockdev.c |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)
Markus Armbruster - July 1, 2011, 7:18 a.m.
Reviewed-by: Markus Armbruster <armbru@redhat.com>

Patch

diff --git a/blockdev.c b/blockdev.c
index 27bf68a..0a90ae8 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -241,13 +241,6 @@  DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)
 
     translation = BIOS_ATA_TRANSLATION_AUTO;
 
-    if (default_to_scsi) {
-        type = IF_SCSI;
-        pstrcpy(devname, sizeof(devname), "scsi");
-    } else {
-        type = IF_IDE;
-        pstrcpy(devname, sizeof(devname), "ide");
-    }
     media = MEDIA_DISK;
 
     /* extract parameters */
@@ -273,7 +266,11 @@  DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)
             error_report("unsupported bus type '%s'", buf);
             return NULL;
 	    }
+    } else {
+        type = default_to_scsi ? IF_SCSI : IF_IDE;
+        pstrcpy(devname, sizeof(devname), if_name[type]);
     }
+
     max_devs = if_max_devs[type];
 
     if (cyls || heads || secs) {