[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 04/14] qapi/device_add: compute is_hotplug flag
From: |
Damien Hedde |
Subject: |
[PATCH v4 04/14] qapi/device_add: compute is_hotplug flag |
Date: |
Wed, 23 Feb 2022 10:06:56 +0100 |
Instead of checking the phase everytime, just store the result
in a flag. We will use more of it in the following commit.
Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
---
softmmu/qdev-monitor.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
index 01f3834db5..47a89aee20 100644
--- a/softmmu/qdev-monitor.c
+++ b/softmmu/qdev-monitor.c
@@ -617,6 +617,7 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts,
char *id;
DeviceState *dev = NULL;
BusState *bus = NULL;
+ bool is_hotplug = phase_check(PHASE_MACHINE_READY);
driver = qdict_get_try_str(opts, "driver");
if (!driver) {
@@ -660,7 +661,7 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts,
return NULL;
}
- if (phase_check(PHASE_MACHINE_READY) && bus && !qbus_is_hotpluggable(bus))
{
+ if (is_hotplug && bus && !qbus_is_hotpluggable(bus)) {
error_setg(errp, QERR_BUS_NO_HOTPLUG, bus->name);
return NULL;
}
@@ -674,7 +675,7 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts,
dev = qdev_new(driver);
/* Check whether the hotplug is allowed by the machine */
- if (phase_check(PHASE_MACHINE_READY)) {
+ if (is_hotplug) {
if (!qdev_hotplug_allowed(dev, errp)) {
goto err_del_dev;
}
--
2.35.1
- [PATCH v4 00/14] Initial support for machine creation via QMP, Damien Hedde, 2022/02/23
- [PATCH v4 05/14] qapi/device_add: handle the rom_order_override when cold-plugging, Damien Hedde, 2022/02/23
- [PATCH v4 10/14] none-machine: allow several cpus, Damien Hedde, 2022/02/23
- [PATCH v4 08/14] none-machine: add 'ram-addr' property, Damien Hedde, 2022/02/23
- [PATCH v4 02/14] machine&vl: introduce phase_until() to handle phase transitions, Damien Hedde, 2022/02/23
- [PATCH v4 06/14] qapi/device_add: Allow execution in machine initialized phase, Damien Hedde, 2022/02/23
- [PATCH v4 07/14] none-machine: add the NoneMachineState structure, Damien Hedde, 2022/02/23
- [PATCH v4 01/14] machine: add phase_get() and document phase_check()/advance(), Damien Hedde, 2022/02/23
- [PATCH v4 03/14] vl: support machine-initialized target in phase_until(), Damien Hedde, 2022/02/23
- [PATCH v4 12/14] add sysbus-mmio-map qapi command, Damien Hedde, 2022/02/23
- [PATCH v4 04/14] qapi/device_add: compute is_hotplug flag,
Damien Hedde <=
- [PATCH v4 09/14] none-machine: allow cold plugging sysbus devices, Damien Hedde, 2022/02/23
- [PATCH v4 13/14] hw/mem/system-memory: add a memory sysbus device, Damien Hedde, 2022/02/23
- Re: [PATCH v4 13/14] hw/mem/system-memory: add a memory sysbus device, Igor Mammedov, 2022/02/23
- Re: [PATCH v4 13/14] hw/mem/system-memory: add a memory sysbus device, Damien Hedde, 2022/02/23
- Re: [PATCH v4 13/14] hw/mem/system-memory: add a memory sysbus device, Igor Mammedov, 2022/02/24
- Re: [PATCH v4 13/14] hw/mem/system-memory: add a memory sysbus device, Damien Hedde, 2022/02/24
- Re: [PATCH v4 13/14] hw/mem/system-memory: add a memory sysbus device, Igor Mammedov, 2022/02/25
- Re: [PATCH v4 13/14] hw/mem/system-memory: add a memory sysbus device, Damien Hedde, 2022/02/25
[PATCH v4 11/14] softmmu/memory: add memory_region_try_add_subregion function, Damien Hedde, 2022/02/23