yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-blockdev-Move-parsing-of-if-option-to-drive_init.patch

218e99
From d3346d7e6dea698bc00eb18be4e174e9036ebeee Mon Sep 17 00:00:00 2001
218e99
From: Kevin Wolf <kwolf@redhat.com>
218e99
Date: Tue, 5 Nov 2013 14:09:05 +0100
218e99
Subject: [PATCH 52/87] blockdev: Move parsing of 'if' option to drive_init
218e99
218e99
RH-Author: Kevin Wolf <kwolf@redhat.com>
218e99
Message-id: <1383660558-32096-12-git-send-email-kwolf@redhat.com>
218e99
Patchwork-id: 55390
218e99
O-Subject: [RHEL-7.0 qemu-kvm PATCH 11/24] blockdev: Move parsing of 'if' option to drive_init
218e99
Bugzilla: 978402
218e99
RH-Acked-by: Fam Zheng <famz@redhat.com>
218e99
RH-Acked-by: Max Reitz <mreitz@redhat.com>
218e99
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
218e99
218e99
It's always IF_NONE for blockdev-add.
218e99
218e99
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
218e99
Reviewed-by: Benoit Canet <benoit@irqsave.net>
218e99
Reviewed-by: Eric Blake <eblake@redhat.com>
218e99
(cherry picked from commit 593d464bd43900c2a0c8800b76212f6a93e99a0d)
218e99
218e99
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
218e99
---
218e99
 blockdev.c | 40 ++++++++++++++++++++++------------------
218e99
 1 file changed, 22 insertions(+), 18 deletions(-)
218e99
218e99
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
---
218e99
 blockdev.c |   40 ++++++++++++++++++++++------------------
218e99
 1 files changed, 22 insertions(+), 18 deletions(-)
218e99
218e99
diff --git a/blockdev.c b/blockdev.c
218e99
index e6d3c15..9bc3417 100644
218e99
--- a/blockdev.c
218e99
+++ b/blockdev.c
218e99
@@ -328,14 +328,13 @@ typedef enum { MEDIA_DISK, MEDIA_CDROM } DriveMediaType;
218e99
 
218e99
 /* Takes the ownership of bs_opts */
218e99
 static DriveInfo *blockdev_init(QDict *bs_opts,
218e99
-                                BlockInterfaceType block_default_type,
218e99
+                                BlockInterfaceType type,
218e99
                                 DriveMediaType media)
218e99
 {
218e99
     const char *buf;
218e99
     const char *file = NULL;
218e99
     const char *serial;
218e99
     const char *mediastr = "";
218e99
-    BlockInterfaceType type;
218e99
     int bus_id, unit_id;
218e99
     int cyls, heads, secs, translation;
218e99
     int max_devs;
218e99
@@ -396,17 +395,6 @@ static DriveInfo *blockdev_init(QDict *bs_opts,
218e99
     file = qemu_opt_get(opts, "file");
218e99
     serial = qemu_opt_get(opts, "serial");
218e99
 
218e99
-    if ((buf = qemu_opt_get(opts, "if")) != NULL) {
218e99
-        for (type = 0; type < IF_COUNT && strcmp(buf, if_name[type]); type++)
218e99
-            ;
218e99
-        if (type == IF_COUNT) {
218e99
-            error_report("unsupported bus type '%s'", buf);
218e99
-            return NULL;
218e99
-	}
218e99
-    } else {
218e99
-        type = block_default_type;
218e99
-    }
218e99
-
218e99
     max_devs = if_max_devs[type];
218e99
 
218e99
     if (cyls || heads || secs) {
218e99
@@ -753,6 +741,10 @@ QemuOptsList qemu_legacy_drive_opts = {
218e99
             .name = "media",
218e99
             .type = QEMU_OPT_STRING,
218e99
             .help = "media type (disk, cdrom)",
218e99
+        },{
218e99
+            .name = "if",
218e99
+            .type = QEMU_OPT_STRING,
218e99
+            .help = "interface (ide, scsi, sd, mtd, floppy, pflash, virtio)",
218e99
         },
218e99
         { /* end of list */ }
218e99
     },
218e99
@@ -765,6 +757,7 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type)
218e99
     QDict *bs_opts;
218e99
     QemuOpts *legacy_opts;
218e99
     DriveMediaType media = MEDIA_DISK;
218e99
+    BlockInterfaceType type;
218e99
     Error *local_err = NULL;
218e99
 
218e99
     /* Change legacy command line options into QMP ones */
218e99
@@ -828,8 +821,23 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type)
218e99
         }
218e99
     }
218e99
 
218e99
+    /* Controller type */
218e99
+    value = qemu_opt_get(legacy_opts, "if");
218e99
+    if (value) {
218e99
+        for (type = 0;
218e99
+             type < IF_COUNT && strcmp(value, if_name[type]);
218e99
+             type++) {
218e99
+        }
218e99
+        if (type == IF_COUNT) {
218e99
+            error_report("unsupported bus type '%s'", value);
218e99
+            goto fail;
218e99
+        }
218e99
+    } else {
218e99
+        type = block_default_type;
218e99
+    }
218e99
+
218e99
     /* Actual block device init: Functionality shared with blockdev-add */
218e99
-    dinfo = blockdev_init(bs_opts, block_default_type, media);
218e99
+    dinfo = blockdev_init(bs_opts, type, media);
218e99
     if (dinfo == NULL) {
218e99
         goto fail;
218e99
     }
218e99
@@ -1781,10 +1789,6 @@ QemuOptsList qemu_common_drive_opts = {
218e99
             .type = QEMU_OPT_NUMBER,
218e99
             .help = "unit number (i.e. lun for scsi)",
218e99
         },{
218e99
-            .name = "if",
218e99
-            .type = QEMU_OPT_STRING,
218e99
-            .help = "interface (ide, scsi, sd, mtd, floppy, pflash, virtio)",
218e99
-        },{
218e99
             .name = "index",
218e99
             .type = QEMU_OPT_NUMBER,
218e99
             .help = "index number",
218e99
-- 
218e99
1.7.1
218e99