[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 21/27] vl: Factor configure_blockdev() out of main()
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PULL 21/27] vl: Factor configure_blockdev() out of main() |
Date: |
Mon, 11 Mar 2019 23:08:37 +0100 |
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
---
vl.c | 74 ++++++++++++++++++++++++++++++++++--------------------------
1 file changed, 42 insertions(+), 32 deletions(-)
diff --git a/vl.c b/vl.c
index ef7f8c36b6..c22ca447fa 100644
--- a/vl.c
+++ b/vl.c
@@ -1199,6 +1199,47 @@ typedef struct BlockdevOptionsQueueEntry {
typedef QSIMPLEQ_HEAD(, BlockdevOptionsQueueEntry) BlockdevOptionsQueue;
+static void configure_blockdev(BlockdevOptionsQueue *bdo_queue,
+ MachineClass *machine_class, int snapshot)
+{
+ /*
+ * If the currently selected machine wishes to override the
+ * units-per-bus property of its default HBA interface type, do so
+ * now.
+ */
+ if (machine_class->units_per_default_bus) {
+ override_max_devs(machine_class->block_default_type,
+ machine_class->units_per_default_bus);
+ }
+
+ /* open the virtual block devices */
+ while (!QSIMPLEQ_EMPTY(bdo_queue)) {
+ BlockdevOptionsQueueEntry *bdo = QSIMPLEQ_FIRST(bdo_queue);
+
+ QSIMPLEQ_REMOVE_HEAD(bdo_queue, entry);
+ loc_push_restore(&bdo->loc);
+ qmp_blockdev_add(bdo->bdo, &error_fatal);
+ loc_pop(&bdo->loc);
+ qapi_free_BlockdevOptions(bdo->bdo);
+ g_free(bdo);
+ }
+ if (snapshot || replay_mode != REPLAY_MODE_NONE) {
+ qemu_opts_foreach(qemu_find_opts("drive"), drive_enable_snapshot,
+ NULL, NULL);
+ }
+ if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func,
+ &machine_class->block_default_type, &error_fatal)) {
+ /* We printed help */
+ exit(0);
+ }
+
+ default_drive(default_cdrom, snapshot, machine_class->block_default_type,
2,
+ CDROM_OPTS);
+ default_drive(default_floppy, snapshot, IF_FLOPPY, 0, FD_OPTS);
+ default_drive(default_sdcard, snapshot, IF_SD, 0, SD_OPTS);
+
+}
+
static QemuOptsList qemu_smp_opts = {
.name = "smp-opts",
.implied_opt_name = "cpus",
@@ -4359,38 +4400,7 @@ int main(int argc, char **argv, char **envp)
ram_mig_init();
dirty_bitmap_mig_init();
- /* If the currently selected machine wishes to override the units-per-bus
- * property of its default HBA interface type, do so now. */
- if (machine_class->units_per_default_bus) {
- override_max_devs(machine_class->block_default_type,
- machine_class->units_per_default_bus);
- }
-
- /* open the virtual block devices */
- while (!QSIMPLEQ_EMPTY(&bdo_queue)) {
- BlockdevOptionsQueueEntry *bdo = QSIMPLEQ_FIRST(&bdo_queue);
-
- QSIMPLEQ_REMOVE_HEAD(&bdo_queue, entry);
- loc_push_restore(&bdo->loc);
- qmp_blockdev_add(bdo->bdo, &error_fatal);
- loc_pop(&bdo->loc);
- qapi_free_BlockdevOptions(bdo->bdo);
- g_free(bdo);
- }
- if (snapshot || replay_mode != REPLAY_MODE_NONE) {
- qemu_opts_foreach(qemu_find_opts("drive"), drive_enable_snapshot,
- NULL, NULL);
- }
- if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func,
- &machine_class->block_default_type, &error_fatal)) {
- /* We printed help */
- exit(0);
- }
-
- default_drive(default_cdrom, snapshot, machine_class->block_default_type,
2,
- CDROM_OPTS);
- default_drive(default_floppy, snapshot, IF_FLOPPY, 0, FD_OPTS);
- default_drive(default_sdcard, snapshot, IF_SD, 0, SD_OPTS);
+ configure_blockdev(&bdo_queue, machine_class, snapshot);
qemu_opts_foreach(qemu_find_opts("mon"),
mon_init_func, NULL, &error_fatal);
--
2.17.2
- [Qemu-devel] [PULL 20/27] vl: Improve legibility of BlockdevOptions queue, (continued)
- [Qemu-devel] [PULL 20/27] vl: Improve legibility of BlockdevOptions queue, Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 16/27] qdev: Fix latent bug with compat_props and onboard devices, Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 05/27] hw: Use PFLASH_CFI0{1, 2} and TYPE_PFLASH_CFI0{1, 2}, Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 24/27] pc_sysfw: Remove unused PcSysFwDevice, Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 17/27] qom: Move compat_props machinery from qdev to QOM, Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 04/27] pflash: Rename *CFI_PFLASH* to *PFLASH_CFI*, Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 11/27] hw/mips/malta: Remove fl_sectors variable, Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 19/27] sysbus: Fix latent bug with onboard devices, Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 12/27] hw/mips/malta: Restrict 'bios_size' variable scope, Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 07/27] ppc405_boards: Delete stale, disabled DEBUG_BOARD_INIT code, Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 21/27] vl: Factor configure_blockdev() out of main(),
Markus Armbruster <=
- [Qemu-devel] [PULL 26/27] pc: Support firmware configuration with -blockdev, Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 13/27] mips_malta: Clean up definition of flash memory size somewhat, Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 25/27] pc_sysfw: Pass PCMachineState to pc_system_firmware_init(), Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 27/27] docs/interop/firmware.json: Prefer -machine to if=pflash, Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 15/27] pflash: Clean up after commit 368a354f02b, part 2, Markus Armbruster, 2019/03/11
- [Qemu-devel] [PULL 22/27] vl: Create block backends before setting machine properties, Markus Armbruster, 2019/03/11