aboutsummaryrefslogtreecommitdiff
path: root/hw/core/qdev.c
diff options
context:
space:
mode:
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,