All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [PATCH 36/36] vl: move all generic initialization out of vl.c
Date: Mon, 23 Nov 2020 09:14:35 -0500	[thread overview]
Message-ID: <20201123141435.2726558-37-pbonzini@redhat.com> (raw)
In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com>

qdev_machine_creation_done is only setting a flag now.  Extend it to
move more code out of vl.c.  Leave only consistency checks and gdbserver
processing in qemu_machine_creation_done.

gdbserver_start can be moved after qdev_machine_creation_done because
it only does listen on the socket and creates some internal data
structures; it does not send any data (e.g. guest state) over the socket.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/core/machine.c      | 47 +++++++++++++++++++++++++++++++++++++++++-
 hw/core/qdev.c         | 12 +++--------
 include/hw/qdev-core.h |  1 +
 softmmu/vl.c           | 37 +--------------------------------
 4 files changed, 51 insertions(+), 46 deletions(-)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index 5659b1f49c..025c4f9749 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -16,16 +16,21 @@
 #include "sysemu/replay.h"
 #include "qemu/units.h"
 #include "hw/boards.h"
+#include "hw/loader.h"
 #include "qapi/error.h"
 #include "qapi/qapi-visit-common.h"
 #include "qapi/visitor.h"
 #include "hw/sysbus.h"
+#include "sysemu/cpus.h"
 #include "sysemu/sysemu.h"
+#include "sysemu/reset.h"
+#include "sysemu/runstate.h"
 #include "sysemu/numa.h"
 #include "qemu/error-report.h"
 #include "sysemu/qtest.h"
 #include "hw/pci/pci.h"
 #include "hw/mem/nvdimm.h"
+#include "migration/global_state.h"
 #include "migration/vmstate.h"
 
 GlobalProperty hw_compat_5_1[] = {
@@ -1186,10 +1191,50 @@ void qemu_remove_machine_init_done_notifier(Notifier *notify)
     notifier_remove(notify);
 }
 
-void qemu_run_machine_init_done_notifiers(void)
+void qdev_machine_creation_done(void)
 {
+    cpu_synchronize_all_post_init();
+
+    if (current_machine->boot_once) {
+        qemu_boot_set(current_machine->boot_once, &error_fatal);
+        qemu_register_reset(restore_boot_order, g_strdup(current_machine->boot_order));
+    }
+
+    /*
+     * ok, initial machine setup is done, starting from now we can
+     * only create hotpluggable devices
+     */
+    qdev_hotplug = true;
+    qdev_assert_realized_properly();
+
+    /* TODO: once all bus devices are qdevified, this should be done
+     * when bus is created by qdev.c */
+    /*
+     * TODO: If we had a main 'reset container' that the whole system
+     * lived in, we could reset that using the multi-phase reset
+     * APIs. For the moment, we just reset the sysbus, which will cause
+     * all devices hanging off it (and all their child buses, recursively)
+     * to be reset. Note that this will *not* reset any Device objects
+     * which are not attached to some part of the qbus tree!
+     */
+    qemu_register_reset(resettable_cold_reset_fn, sysbus_get_default());
+
     machine_init_done = true;
     notifier_list_notify(&machine_init_done_notifiers, NULL);
+
+    if (rom_check_and_register_reset() != 0) {
+        error_report("rom check and register reset failed");
+        exit(1);
+    }
+
+    replay_start();
+
+    /* This checkpoint is required by replay to separate prior clock
+       reading from the other reads, because timer polling functions query
+       clock values from the log. */
+    replay_checkpoint(CHECKPOINT_RESET);
+    qemu_system_reset(SHUTDOWN_CAUSE_NONE);
+    register_global_state();
 }
 
 static const TypeInfo machine_info = {
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 262bca716f..bc5df8ce69 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -413,7 +413,7 @@ void qdev_unrealize(DeviceState *dev)
     object_property_set_bool(OBJECT(dev), "realized", false, &error_abort);
 }
 
-static int qdev_assert_realized_properly(Object *obj, void *opaque)
+static int qdev_assert_realized_properly_cb(Object *obj, void *opaque)
 {
     DeviceState *dev = DEVICE(object_dynamic_cast(obj, TYPE_DEVICE));
     DeviceClass *dc;
@@ -426,16 +426,10 @@ static int qdev_assert_realized_properly(Object *obj, void *opaque)
     return 0;
 }
 
-void qdev_machine_creation_done(void)
+void qdev_assert_realized_properly(void)
 {
-    /*
-     * ok, initial machine setup is done, starting from now we can
-     * only create hotpluggable devices
-     */
-    qdev_hotplug = true;
-
     object_child_foreach_recursive(object_get_root(),
-                                   qdev_assert_realized_properly, NULL);
+                                   qdev_assert_realized_properly_cb, NULL);
 }
 
 bool qdev_machine_modified(void)
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index b77a2f1da7..6446846752 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -815,6 +815,7 @@ const VMStateDescription *qdev_get_vmsd(DeviceState *dev);
 
 const char *qdev_fw_name(DeviceState *dev);
 
+void qdev_assert_realized_properly(void);
 Object *qdev_get_machine(void);
 
 /* FIXME: make this a link<> */
diff --git a/softmmu/vl.c b/softmmu/vl.c
index aeb988bcad..1fde4a17a9 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -72,7 +72,6 @@
 #include "hw/i386/pc.h"
 #include "migration/misc.h"
 #include "migration/snapshot.h"
-#include "migration/global_state.h"
 #include "sysemu/tpm.h"
 #include "sysemu/dma.h"
 #include "hw/audio/soundhw.h"
@@ -2426,8 +2425,6 @@ static void qemu_create_cli_devices(void)
 
 static void qemu_machine_creation_done(void)
 {
-    cpu_synchronize_all_post_init();
-
     /* Did we create any drives that we failed to create a device for? */
     drive_check_orphaned();
 
@@ -2445,43 +2442,11 @@ static void qemu_machine_creation_done(void)
 
     qdev_prop_check_globals();
 
-    if (current_machine->boot_once) {
-        qemu_boot_set(current_machine->boot_once, &error_fatal);
-        qemu_register_reset(restore_boot_order, g_strdup(current_machine->boot_order));
-    }
-
-    if (foreach_device_config(DEV_GDB, gdbserver_start) < 0) {
-        exit(1);
-    }
-
     qdev_machine_creation_done();
 
-    /* TODO: once all bus devices are qdevified, this should be done
-     * when bus is created by qdev.c */
-    /*
-     * TODO: If we had a main 'reset container' that the whole system
-     * lived in, we could reset that using the multi-phase reset
-     * APIs. For the moment, we just reset the sysbus, which will cause
-     * all devices hanging off it (and all their child buses, recursively)
-     * to be reset. Note that this will *not* reset any Device objects
-     * which are not attached to some part of the qbus tree!
-     */
-    qemu_register_reset(resettable_cold_reset_fn, sysbus_get_default());
-    qemu_run_machine_init_done_notifiers();
-
-    if (rom_check_and_register_reset() != 0) {
-        error_report("rom check and register reset failed");
+    if (foreach_device_config(DEV_GDB, gdbserver_start) < 0) {
         exit(1);
     }
-
-    replay_start();
-
-    /* This checkpoint is required by replay to separate prior clock
-       reading from the other reads, because timer polling functions query
-       clock values from the log. */
-    replay_checkpoint(CHECKPOINT_RESET);
-    qemu_system_reset(SHUTDOWN_CAUSE_NONE);
-    register_global_state();
 }
 
 void qmp_x_exit_preconfig(Error **errp)
-- 
2.26.2



  parent reply	other threads:[~2020-11-23 14:36 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-23 14:13 [PATCH v3 00/36] cleanup qemu_init and make sense of command line processing Paolo Bonzini
2020-11-23 14:14 ` [PATCH 01/36] vl: extract validation of -smp to machine.c Paolo Bonzini
2020-11-23 14:14 ` [PATCH 02/36] vl: remove bogus check Paolo Bonzini
2020-11-23 14:14 ` [PATCH 03/36] vl: split various early command line options to a separate function Paolo Bonzini
2020-11-26 16:47   ` Igor Mammedov
2020-11-23 14:14 ` [PATCH 04/36] vl: move various initialization routines out of qemu_init Paolo Bonzini
2020-11-23 14:14 ` [PATCH 05/36] vl: extract qemu_init_subsystems Paolo Bonzini
2020-11-23 14:14 ` [PATCH 06/36] vl: move prelaunch part of qemu_init to new functions Paolo Bonzini
2020-11-23 14:14 ` [PATCH 07/36] vl: extract various command line validation snippets to a new function Paolo Bonzini
2020-11-23 14:14 ` [PATCH 08/36] vl: preconfig and loadvm are mutually exclusive Paolo Bonzini
2020-11-23 14:14 ` [PATCH 09/36] vl: extract various command line desugaring snippets to a new function Paolo Bonzini
2020-11-23 14:14 ` [PATCH 10/36] qemu-option: restrict qemu_opts_set to merge-lists QemuOpts Paolo Bonzini
2020-11-23 14:14 ` [PATCH 11/36] vl: create "-net nic -net user" default earlier Paolo Bonzini
2020-11-23 14:14 ` [PATCH 12/36] vl: load plugins as late as possible Paolo Bonzini
2020-11-26 16:54   ` Igor Mammedov
2020-11-23 14:14 ` [PATCH 13/36] vl: move semihosting command line fallback to qemu_init_board Paolo Bonzini
2020-11-26 17:10   ` Igor Mammedov
2020-11-27  5:03     ` Paolo Bonzini
2020-11-27 10:31       ` Igor Mammedov
2020-11-27 11:22         ` Paolo Bonzini
2020-11-27 12:12           ` Igor Mammedov
2020-11-27 12:22             ` Paolo Bonzini
2020-11-23 14:14 ` [PATCH 14/36] vl: extract default devices to separate functions Paolo Bonzini
2020-11-26 17:29   ` Igor Mammedov
2020-11-23 14:14 ` [PATCH 15/36] vl: move CHECKPOINT_INIT after preconfig Paolo Bonzini
2020-11-26 17:36   ` Igor Mammedov
2020-11-23 14:14 ` [PATCH 16/36] vl: separate qemu_create_early_backends Paolo Bonzini
2020-11-23 14:14 ` [PATCH 17/36] vl: separate qemu_create_late_backends Paolo Bonzini
2020-11-23 14:14 ` [PATCH 18/36] vl: separate qemu_create_machine Paolo Bonzini
2020-11-23 14:14 ` [PATCH 19/36] vl: separate qemu_apply_machine_options Paolo Bonzini
2020-11-23 14:14 ` [PATCH 20/36] vl: separate qemu_resolve_machine_memdev Paolo Bonzini
2020-11-26 17:39   ` Igor Mammedov
2020-11-23 14:14 ` [PATCH 21/36] vl: initialize displays before preconfig loop Paolo Bonzini
2020-11-26 17:51   ` Igor Mammedov
2020-11-23 14:14 ` [PATCH 22/36] vl: move -global check earlier Paolo Bonzini
2020-11-26 17:55   ` Igor Mammedov
2020-11-23 14:14 ` [PATCH 23/36] migration, vl: start migration via qmp_migrate_incoming Paolo Bonzini
2020-11-26 18:04   ` Igor Mammedov
2020-11-23 14:14 ` [PATCH 24/36] vl: start VM via qmp_cont Paolo Bonzini
2020-11-23 14:14 ` [PATCH 25/36] hmp: introduce cmd_available Paolo Bonzini
2020-11-23 14:14 ` [PATCH 26/36] remove preconfig state Paolo Bonzini
2020-11-26 18:55   ` Igor Mammedov
2020-11-27  5:19     ` Paolo Bonzini
2020-11-27 10:50       ` Igor Mammedov
2020-11-27 11:50         ` Paolo Bonzini
2020-11-30 12:41           ` Igor Mammedov
2020-11-23 14:14 ` [PATCH 27/36] vl: remove separate preconfig main_loop Paolo Bonzini
2020-11-30 12:46   ` Igor Mammedov
2020-11-23 14:14 ` [PATCH 28/36] vl: allow -incoming defer with -preconfig Paolo Bonzini
2020-11-27 10:51   ` Igor Mammedov
2020-11-23 14:14 ` [PATCH 29/36] vl: extract softmmu/datadir.c Paolo Bonzini
2020-11-27 12:06   ` Igor Mammedov
2020-11-23 14:14 ` [PATCH 30/36] vl: extract machine done notifiers Paolo Bonzini
2020-11-27 12:14   ` Igor Mammedov
2020-11-23 14:14 ` [PATCH 31/36] vl: extract softmmu/rtc.c Paolo Bonzini
2020-11-27 12:43   ` Igor Mammedov
2020-11-23 14:14 ` [PATCH 32/36] vl: extract softmmu/runstate.c Paolo Bonzini
2020-11-27 12:59   ` Igor Mammedov
2020-11-23 14:14 ` [PATCH 33/36] vl: extract softmmu/globals.c Paolo Bonzini
2020-11-27 13:19   ` Igor Mammedov
2020-11-23 14:14 ` [PATCH 34/36] vl: remove serial_max_hds Paolo Bonzini
2020-11-27 13:11   ` Igor Mammedov
2020-11-23 14:14 ` [PATCH 35/36] vl: clean up -boot variables Paolo Bonzini
2020-11-27 13:12   ` Igor Mammedov
2020-11-23 14:14 ` Paolo Bonzini [this message]
2020-11-27 13:30   ` [PATCH 36/36] vl: move all generic initialization out of vl.c Igor Mammedov
2020-11-27 12:00 ` [PATCH 37/36] machine: introduce MachineInitPhase Paolo Bonzini
2020-11-27 13:29   ` Igor Mammedov
2020-11-27 15:29     ` Paolo Bonzini
2020-11-30 12:50 ` [PATCH v3 00/36] cleanup qemu_init and make sense of command line processing Igor Mammedov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201123141435.2726558-37-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.