summaryrefslogtreecommitdiffstats
path: root/hw/core/qdev.c
diff options
context:
space:
mode:
authorPaolo Bonzini2020-11-12 15:38:36 +0100
committerPaolo Bonzini2020-12-15 18:51:52 +0100
commit2f181fbd5a9d456d1da291bea61d7e3ad10ec7d1 (patch)
treef6be4e559a9b9a95a2870caf0fc323e7ca6778e7 /hw/core/qdev.c
parentchardev: do not use machine_init_done (diff)
downloadqemu-2f181fbd5a9d456d1da291bea61d7e3ad10ec7d1.tar.gz
qemu-2f181fbd5a9d456d1da291bea61d7e3ad10ec7d1.tar.xz
qemu-2f181fbd5a9d456d1da291bea61d7e3ad10ec7d1.zip
machine: introduce MachineInitPhase
Generalize the qdev_hotplug variable to the different phases of machine initialization. We would like to allow different monitor commands depending on the phase. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/core/qdev.c')
-rw-r--r--hw/core/qdev.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index dddb0b2d69..cefc5eaa0a 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -41,7 +41,6 @@
#include "migration/vmstate.h"
#include "trace.h"
-bool qdev_hotplug = false;
static bool qdev_hot_added = false;
bool qdev_hot_removed = false;
@@ -905,7 +904,7 @@ static void device_initfn(Object *obj)
{
DeviceState *dev = DEVICE(obj);
- if (qdev_hotplug) {
+ if (phase_check(PHASE_MACHINE_READY)) {
dev->hotplugged = 1;
qdev_hot_added = true;
}
@@ -1138,6 +1137,19 @@ Object *qdev_get_machine(void)
return dev;
}
+static MachineInitPhase machine_phase;
+
+bool phase_check(MachineInitPhase phase)
+{
+ return machine_phase >= phase;
+}
+
+void phase_advance(MachineInitPhase phase)
+{
+ assert(machine_phase == phase - 1);
+ machine_phase = phase;
+}
+
static const TypeInfo device_type_info = {
.name = TYPE_DEVICE,
.parent = TYPE_OBJECT,