Blame SOURCES/kvm-vl-Factor-configure_blockdev-out-of-main.patch

383d26
From 8278c1cf3ba3ad55f42ab690a83de66a76ec9316 Mon Sep 17 00:00:00 2001
383d26
From: Markus Armbruster <armbru@redhat.com>
383d26
Date: Fri, 17 May 2019 06:51:12 +0200
383d26
Subject: [PATCH 45/53] vl: Factor configure_blockdev() out of main()
383d26
MIME-Version: 1.0
383d26
Content-Type: text/plain; charset=UTF-8
383d26
Content-Transfer-Encoding: 8bit
383d26
383d26
RH-Author: Markus Armbruster <armbru@redhat.com>
383d26
Message-id: <20190517065120.12028-24-armbru@redhat.com>
383d26
Patchwork-id: 88008
383d26
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH v3 23/31] vl: Factor configure_blockdev() out of main()
383d26
Bugzilla: 1624009
383d26
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
383d26
RH-Acked-by: Thomas Huth <thuth@redhat.com>
383d26
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
383d26
383d26
Signed-off-by: Markus Armbruster <armbru@redhat.com>
383d26
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
383d26
Message-Id: <20190308131445.17502-7-armbru@redhat.com>
383d26
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
383d26
(cherry picked from commit d11bf9bf0fd66057aa5e8acb1bbc797419d5a4e6)
383d26
[Conflict in vl.c due to lack of commit c4f26c9f37c and 7c89fcbac86]
383d26
383d26
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
383d26
---
383d26
 vl.c | 72 +++++++++++++++++++++++++++++++++++++++-----------------------------
383d26
 1 file changed, 41 insertions(+), 31 deletions(-)
383d26
383d26
diff --git a/vl.c b/vl.c
383d26
index a5c17a0..e0e60fb 100644
383d26
--- a/vl.c
383d26
+++ b/vl.c
383d26
@@ -1279,6 +1279,46 @@ typedef struct BlockdevOptionsQueueEntry {
383d26
 
383d26
 typedef QSIMPLEQ_HEAD(, BlockdevOptionsQueueEntry) BlockdevOptionsQueue;
383d26
 
383d26
+static void configure_blockdev(BlockdevOptionsQueue *bdo_queue,
383d26
+                               MachineClass *machine_class, int snapshot)
383d26
+{
383d26
+    /*
383d26
+     * If the currently selected machine wishes to override the
383d26
+     * units-per-bus property of its default HBA interface type, do so
383d26
+     * now.
383d26
+     */
383d26
+    if (machine_class->units_per_default_bus) {
383d26
+        override_max_devs(machine_class->block_default_type,
383d26
+                          machine_class->units_per_default_bus);
383d26
+    }
383d26
+
383d26
+    /* open the virtual block devices */
383d26
+    while (!QSIMPLEQ_EMPTY(bdo_queue)) {
383d26
+        BlockdevOptionsQueueEntry *bdo = QSIMPLEQ_FIRST(bdo_queue);
383d26
+
383d26
+        QSIMPLEQ_REMOVE_HEAD(bdo_queue, entry);
383d26
+        loc_push_restore(&bdo->loc);
383d26
+        qmp_blockdev_add(bdo->bdo, &error_fatal);
383d26
+        loc_pop(&bdo->loc);
383d26
+        qapi_free_BlockdevOptions(bdo->bdo);
383d26
+        g_free(bdo);
383d26
+    }
383d26
+    if (snapshot || replay_mode != REPLAY_MODE_NONE) {
383d26
+        qemu_opts_foreach(qemu_find_opts("drive"), drive_enable_snapshot,
383d26
+                          NULL, NULL);
383d26
+    }
383d26
+    if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func,
383d26
+                          &machine_class->block_default_type, NULL)) {
383d26
+        exit(1);
383d26
+    }
383d26
+
383d26
+    default_drive(default_cdrom, snapshot, machine_class->block_default_type, 2,
383d26
+                  CDROM_OPTS);
383d26
+    default_drive(default_floppy, snapshot, IF_FLOPPY, 0, FD_OPTS);
383d26
+    default_drive(default_sdcard, snapshot, IF_SD, 0, SD_OPTS);
383d26
+
383d26
+}
383d26
+
383d26
 static QemuOptsList qemu_smp_opts = {
383d26
     .name = "smp-opts",
383d26
     .implied_opt_name = "cpus",
383d26
@@ -4550,37 +4590,7 @@ int main(int argc, char **argv, char **envp)
383d26
     ram_mig_init();
383d26
     dirty_bitmap_mig_init();
383d26
 
383d26
-    /* If the currently selected machine wishes to override the units-per-bus
383d26
-     * property of its default HBA interface type, do so now. */
383d26
-    if (machine_class->units_per_default_bus) {
383d26
-        override_max_devs(machine_class->block_default_type,
383d26
-                          machine_class->units_per_default_bus);
383d26
-    }
383d26
-
383d26
-    /* open the virtual block devices */
383d26
-    while (!QSIMPLEQ_EMPTY(&bdo_queue)) {
383d26
-        BlockdevOptionsQueueEntry *bdo = QSIMPLEQ_FIRST(&bdo_queue);
383d26
-
383d26
-        QSIMPLEQ_REMOVE_HEAD(&bdo_queue, entry);
383d26
-        loc_push_restore(&bdo->loc);
383d26
-        qmp_blockdev_add(bdo->bdo, &error_fatal);
383d26
-        loc_pop(&bdo->loc);
383d26
-        qapi_free_BlockdevOptions(bdo->bdo);
383d26
-        g_free(bdo);
383d26
-    }
383d26
-    if (snapshot || replay_mode != REPLAY_MODE_NONE) {
383d26
-        qemu_opts_foreach(qemu_find_opts("drive"), drive_enable_snapshot,
383d26
-                          NULL, NULL);
383d26
-    }
383d26
-    if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func,
383d26
-                          &machine_class->block_default_type, NULL)) {
383d26
-        exit(1);
383d26
-    }
383d26
-
383d26
-    default_drive(default_cdrom, snapshot, machine_class->block_default_type, 2,
383d26
-                  CDROM_OPTS);
383d26
-    default_drive(default_floppy, snapshot, IF_FLOPPY, 0, FD_OPTS);
383d26
-    default_drive(default_sdcard, snapshot, IF_SD, 0, SD_OPTS);
383d26
+    configure_blockdev(&bdo_queue, machine_class, snapshot);
383d26
 
383d26
     if (qemu_opts_foreach(qemu_find_opts("mon"),
383d26
                           mon_init_func, NULL, NULL)) {
383d26
-- 
383d26
1.8.3.1
383d26