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

login
register
mail settings
Submitter Luiz Capitulino
Date July 1, 2011, 1:46 p.m.
Message ID <1309527973-11127-2-git-send-email-lcapitulino@redhat.com>
Download mbox | patch
Permalink /patch/102907/
State New
Headers show

Comments

Luiz Capitulino - July 1, 2011, 1:46 p.m.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 blockdev.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

Patch

diff --git a/blockdev.c b/blockdev.c
index 7d579d6..470be71 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -240,14 +240,6 @@  DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)
     int ret;
 
     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 +265,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) {