* [PULL v2 00/55] Misc HW patches for 2025-01-12
@ 2025-01-13 17:35 Philippe Mathieu-Daudé
2025-01-13 17:35 ` [PULL v2 06/55] hw/qdev: Pass bus argument to qdev_hotplug_allowed() Philippe Mathieu-Daudé
` (7 more replies)
0 siblings, 8 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-13 17:35 UTC (permalink / raw)
To: qemu-devel; +Cc: Philippe Mathieu-Daudé
The following changes since commit e8aa7fdcddfc8589bdc7c973a052e76e8f999455:
Merge tag 'pull-target-arm-20250113' of https://git.linaro.org/people/pmaydell/qemu-arm into staging (2025-01-13 09:43:48 -0500)
are available in the Git repository at:
https://github.com/philmd/qemu.git tags/hw-misc-20250113
for you to fetch changes up to 838cf72b5d2cd875897d8bdfea4b23f6d9fdc602:
Add a b4 configuration file (2025-01-13 17:21:46 +0100)
----------------------------------------------------------------
Misc HW patches queue
- Silent unuseful DTC warnings (Philippe)
- Unify QDev hotplug decision logic (Akihiko)
- Rework XilinX EthLite RAM buffers (Philippe)
- Convert vmcoreinfo to 3-phase reset (Philippe)
- Convert HPPA CPUs to 3-phase reset (Helge)
- Fix UFS endianness issue (Keoseong)
- Introduce pci_set_enabled (Akihiko)
- Clarify Enclave and Firecracker relationship (Alexander)
- Set SDHCI DMA interrupt status bit in correct place (Bernhard)
- Fix leak in cryptodev-vhost-user backend (Gabriel)
- Fixes on PCI USB XHCI (Phil)
- Convert DPRINTF to trace events (Nikita, Bernhard)
- Remove &first_cpu in TriCore machine (Philippe)
- Checkpatch style cleanups (Bibo)
- MAINTAINERS updates (Marcin, Gustavo, Akihiko)
- Add default configuration for b4 tool (Jiaxun)
----------------------------------------------------------------
Akihiko Odaki (8):
hw/qdev: Pass bus argument to qdev_hotplug_allowed()
hw/qdev: Factor qdev_hotunplug_allowed() out
hw/qdev: Introduce qdev_hotplug_unplug_allowed_common()
hw/qdev: Check DevClass::hotpluggable in hotplug_unplug_allowed_common
hw/qdev: Check qbus_is_hotpluggable in hotplug_unplug_allowed_common
hw/qdev: Check machine_hotplug_handler in
hotplug_unplug_allowed_common
hw/pci: Rename has_power to enabled
MAINTAINERS: Update path to coreaudio.m
Alexander Graf (1):
docs/nitro-enclave: Clarify Enclave and Firecracker relationship
Bernhard Beschow (7):
hw/sd/sdhci: Set SDHC_NIS_DMA bit when appropriate
hw/timer/imx_gpt: Remove unused define
tests/qtest/libqos: Reuse TYPE_IMX_I2C define
hw/misc/imx6_src: Convert DPRINTF() to trace events
hw/char/imx_serial: Turn some DPRINTF() statements into trace events
hw/i2c/imx_i2c: Convert DPRINTF() to trace events
hw/gpio/imx_gpio: Turn DPRINTF() into trace events
Bibo Mao (1):
hw/loongarch/virt: Checkpatch cleanup
Gabriel Barrantes (1):
backends/cryptodev-vhost-user: Fix local_error leaks
Gustavo Romero (1):
MAINTAINERS: Add me as the maintainer for ivshmem-flat
Helge Deller (4):
target/hppa: Convert hppa_cpu_init() to ResetHold handler
hw/hppa: Reset vCPUs calling resettable_reset()
target/hppa: Set PC on vCPU reset
target/hppa: Speed up hppa_is_pa20()
Jiaxun Yang (1):
Add a b4 configuration file
Keoseong Park (1):
hw/ufs: Adjust value to match CPU's endian format
Marcin Juszkiewicz (1):
MAINTAINERS: remove myself from sbsa-ref
Nikita Shubin (1):
hw/char/stm32f2xx_usart: replace print with trace
Phil Dennis-Jordan (2):
hw/usb/hcd-xhci-pci: Use modulo to select MSI vector as per spec
hw/usb/hcd-xhci-pci: Use event ring 0 if mapping unsupported
Philippe Mathieu-Daudé (26):
pc-bios/meson.build: Silent unuseful DTC warnings
target: Replace DEVICE(object_new) -> qdev_new()
hw: Replace DEVICE(object_new) -> qdev_new()
hw/usb: Inline usb_try_new()
hw/usb: Inline usb_new()
hw/microblaze: Restrict MemoryRegionOps are implemented as 32-bit
hw/net/xilinx_ethlite: Map MDIO registers (as unimplemented)
hw/net/xilinx_ethlite: Introduce txbuf_ptr() helper
hw/net/xilinx_ethlite: Introduce rxbuf_ptr() helper
hw/net/xilinx_ethlite: Access TX_GIE register for each port
hw/net/xilinx_ethlite: Access TX_LEN register for each port
hw/net/xilinx_ethlite: Access TX_CTRL register for each port
hw/net/xilinx_ethlite: Map RX_CTRL as MMIO
hw/net/xilinx_ethlite: Map TX_LEN as MMIO
hw/net/xilinx_ethlite: Map TX_GIE as MMIO
hw/net/xilinx_ethlite: Map TX_CTRL as MMIO
hw/net/xilinx_ethlite: Map the RAM buffer as RAM memory region
hw/net/xilinx_ethlite: Rename 'mmio' MR as 'container'
hw/net/xilinx_ethlite: Map RESERVED I/O as unimplemented
hw/misc/vmcoreinfo: Rename VMCOREINFO_DEVICE -> TYPE_VMCOREINFO
hw/misc/vmcoreinfo: Convert to three-phase reset interface
hw/sd/sdhci: Factor sdhci_sdma_transfer() out
tests/qtest/boot-serial-test: Correct HPPA machine name
tests: Add functional tests for HPPA machines
target/hppa: Only set PSW 'M' bit on reset
hw/tricore/triboard: Remove unnecessary use of &first_cpu
MAINTAINERS | 13 +-
docs/system/i386/nitro-enclave.rst | 2 +-
include/hw/misc/vmcoreinfo.h | 7 +-
include/hw/pci/pci.h | 1 +
include/hw/pci/pci_device.h | 2 +-
include/hw/qdev-core.h | 3 +-
include/hw/usb.h | 12 +-
target/hppa/cpu.h | 11 +-
backends/cryptodev-vhost-user.c | 3 +-
hw/arm/musicpal.c | 2 +-
hw/char/imx_serial.c | 58 ++--
hw/char/stm32f2xx_usart.c | 49 ++--
hw/core/qdev-hotplug.c | 45 ++-
hw/gpio/imx_gpio.c | 18 +-
hw/hppa/machine.c | 6 +-
hw/i2c/imx_i2c.c | 21 +-
hw/intc/xilinx_intc.c | 4 +
hw/loongarch/acpi-build.c | 3 +-
hw/loongarch/boot.c | 4 +-
hw/loongarch/virt.c | 8 +-
hw/misc/imx6_src.c | 23 +-
hw/misc/vmcoreinfo.c | 14 +-
hw/net/xilinx_ethlite.c | 312 ++++++++++++++-------
hw/pci/pci.c | 17 +-
hw/pci/pci_host.c | 4 +-
hw/sd/sdhci.c | 33 ++-
hw/sparc/sun4m.c | 4 +-
hw/timer/imx_gpt.c | 4 -
hw/timer/xilinx_timer.c | 4 +
hw/tricore/triboard.c | 6 +-
hw/ufs/ufs.c | 2 +-
hw/usb/bus.c | 5 +-
hw/usb/dev-serial.c | 2 +-
hw/usb/hcd-xhci-pci.c | 1 +
hw/usb/hcd-xhci.c | 4 +
system/qdev-monitor.c | 37 +--
target/hppa/cpu.c | 22 +-
target/mips/cpu.c | 2 +-
target/xtensa/cpu.c | 2 +-
tests/qtest/boot-serial-test.c | 2 -
tests/qtest/libqos/arm-imx25-pdk-machine.c | 5 +-
tests/qtest/libqos/i2c-imx.c | 4 +-
tests/qtest/ufs-test.c | 2 +-
.b4-config | 14 +
hw/char/trace-events | 11 +
hw/gpio/trace-events | 5 +
hw/i2c/trace-events | 5 +
hw/misc/trace-events | 6 +
pc-bios/meson.build | 3 +-
tests/functional/meson.build | 4 +
tests/functional/test_hppa_seabios.py | 35 +++
tests/qtest/meson.build | 2 +-
52 files changed, 558 insertions(+), 310 deletions(-)
create mode 100644 .b4-config
create mode 100755 tests/functional/test_hppa_seabios.py
--
2.47.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PULL v2 06/55] hw/qdev: Pass bus argument to qdev_hotplug_allowed()
2025-01-13 17:35 [PULL v2 00/55] Misc HW patches for 2025-01-12 Philippe Mathieu-Daudé
@ 2025-01-13 17:35 ` Philippe Mathieu-Daudé
2025-01-13 17:35 ` [PULL v2 07/55] hw/qdev: Factor qdev_hotunplug_allowed() out Philippe Mathieu-Daudé
` (6 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-13 17:35 UTC (permalink / raw)
To: qemu-devel; +Cc: Akihiko Odaki, Philippe Mathieu-Daudé, Igor Mammedov
From: Akihiko Odaki <akihiko.odaki@daynix.com>
In preparation of checking the parent bus is hot(un)pluggable
in a few commits, pass a 'bus' argument to qdev_hotplug_allowed().
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
[PMD: Split from bigger patch, part 1/6]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <20250110091908.64454-2-philmd@linaro.org>
---
include/hw/qdev-core.h | 2 +-
hw/core/qdev-hotplug.c | 2 +-
system/qdev-monitor.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 89575e74e27..930b00fb09a 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -540,7 +540,7 @@ void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id,
int required_for_version);
HotplugHandler *qdev_get_bus_hotplug_handler(DeviceState *dev);
HotplugHandler *qdev_get_machine_hotplug_handler(DeviceState *dev);
-bool qdev_hotplug_allowed(DeviceState *dev, Error **errp);
+bool qdev_hotplug_allowed(DeviceState *dev, BusState *bus, Error **errp);
/**
* qdev_get_hotplug_handler() - Get handler responsible for device wiring
diff --git a/hw/core/qdev-hotplug.c b/hw/core/qdev-hotplug.c
index d495d0e9c70..19fbb11a316 100644
--- a/hw/core/qdev-hotplug.c
+++ b/hw/core/qdev-hotplug.c
@@ -30,7 +30,7 @@ HotplugHandler *qdev_get_machine_hotplug_handler(DeviceState *dev)
return NULL;
}
-bool qdev_hotplug_allowed(DeviceState *dev, Error **errp)
+bool qdev_hotplug_allowed(DeviceState *dev, BusState *bus, Error **errp)
{
MachineState *machine;
MachineClass *mc;
diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c
index 23043b1e0d5..83388dc0c4a 100644
--- a/system/qdev-monitor.c
+++ b/system/qdev-monitor.c
@@ -691,7 +691,7 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts,
/* Check whether the hotplug is allowed by the machine */
if (phase_check(PHASE_MACHINE_READY)) {
- if (!qdev_hotplug_allowed(dev, errp)) {
+ if (!qdev_hotplug_allowed(dev, bus, errp)) {
goto err_del_dev;
}
--
2.47.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL v2 07/55] hw/qdev: Factor qdev_hotunplug_allowed() out
2025-01-13 17:35 [PULL v2 00/55] Misc HW patches for 2025-01-12 Philippe Mathieu-Daudé
2025-01-13 17:35 ` [PULL v2 06/55] hw/qdev: Pass bus argument to qdev_hotplug_allowed() Philippe Mathieu-Daudé
@ 2025-01-13 17:35 ` Philippe Mathieu-Daudé
2025-01-13 17:36 ` [PULL v2 08/55] hw/qdev: Introduce qdev_hotplug_unplug_allowed_common() Philippe Mathieu-Daudé
` (5 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-13 17:35 UTC (permalink / raw)
To: qemu-devel; +Cc: Akihiko Odaki, Philippe Mathieu-Daudé, Igor Mammedov
From: Akihiko Odaki <akihiko.odaki@daynix.com>
Factor qdev_hotunplug_allowed() out of qdev_unplug().
Start checking the device is not blocked.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
[PMD: Split from bigger patch, part 2/6]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <20250110091908.64454-3-philmd@linaro.org>
---
include/hw/qdev-core.h | 1 +
hw/core/qdev-hotplug.c | 5 +++++
system/qdev-monitor.c | 2 +-
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 930b00fb09a..530f3da7021 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -541,6 +541,7 @@ void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id,
HotplugHandler *qdev_get_bus_hotplug_handler(DeviceState *dev);
HotplugHandler *qdev_get_machine_hotplug_handler(DeviceState *dev);
bool qdev_hotplug_allowed(DeviceState *dev, BusState *bus, Error **errp);
+bool qdev_hotunplug_allowed(DeviceState *dev, Error **errp);
/**
* qdev_get_hotplug_handler() - Get handler responsible for device wiring
diff --git a/hw/core/qdev-hotplug.c b/hw/core/qdev-hotplug.c
index 19fbb11a316..dc35110e735 100644
--- a/hw/core/qdev-hotplug.c
+++ b/hw/core/qdev-hotplug.c
@@ -47,6 +47,11 @@ bool qdev_hotplug_allowed(DeviceState *dev, BusState *bus, Error **errp)
return true;
}
+bool qdev_hotunplug_allowed(DeviceState *dev, Error **errp)
+{
+ return !qdev_unplug_blocked(dev, errp);
+}
+
HotplugHandler *qdev_get_bus_hotplug_handler(DeviceState *dev)
{
if (dev->parent_bus) {
diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c
index 83388dc0c4a..511d1aa83c2 100644
--- a/system/qdev-monitor.c
+++ b/system/qdev-monitor.c
@@ -909,7 +909,7 @@ void qdev_unplug(DeviceState *dev, Error **errp)
HotplugHandlerClass *hdc;
Error *local_err = NULL;
- if (qdev_unplug_blocked(dev, errp)) {
+ if (!qdev_hotunplug_allowed(dev, errp)) {
return;
}
--
2.47.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL v2 08/55] hw/qdev: Introduce qdev_hotplug_unplug_allowed_common()
2025-01-13 17:35 [PULL v2 00/55] Misc HW patches for 2025-01-12 Philippe Mathieu-Daudé
2025-01-13 17:35 ` [PULL v2 06/55] hw/qdev: Pass bus argument to qdev_hotplug_allowed() Philippe Mathieu-Daudé
2025-01-13 17:35 ` [PULL v2 07/55] hw/qdev: Factor qdev_hotunplug_allowed() out Philippe Mathieu-Daudé
@ 2025-01-13 17:36 ` Philippe Mathieu-Daudé
2025-01-13 17:36 ` [PULL v2 09/55] hw/qdev: Check DevClass::hotpluggable in hotplug_unplug_allowed_common Philippe Mathieu-Daudé
` (4 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-13 17:36 UTC (permalink / raw)
To: qemu-devel; +Cc: Akihiko Odaki, Philippe Mathieu-Daudé, Igor Mammedov
From: Akihiko Odaki <akihiko.odaki@daynix.com>
Introduce qdev_hotplug_unplug_allowed_common() to hold
common code between checking hot-plug/unplug is allowed.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
[PMD: Split from bigger patch, part 3/6]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <20250110091908.64454-4-philmd@linaro.org>
---
hw/core/qdev-hotplug.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/hw/core/qdev-hotplug.c b/hw/core/qdev-hotplug.c
index dc35110e735..168d7964740 100644
--- a/hw/core/qdev-hotplug.c
+++ b/hw/core/qdev-hotplug.c
@@ -30,12 +30,22 @@ HotplugHandler *qdev_get_machine_hotplug_handler(DeviceState *dev)
return NULL;
}
+static bool qdev_hotplug_unplug_allowed_common(DeviceState *dev, BusState *bus,
+ Error **errp)
+{
+ return true;
+}
+
bool qdev_hotplug_allowed(DeviceState *dev, BusState *bus, Error **errp)
{
MachineState *machine;
MachineClass *mc;
Object *m_obj = qdev_get_machine();
+ if (!qdev_hotplug_unplug_allowed_common(dev, bus, errp)) {
+ return false;
+ }
+
if (object_dynamic_cast(m_obj, TYPE_MACHINE)) {
machine = MACHINE(m_obj);
mc = MACHINE_GET_CLASS(machine);
@@ -49,7 +59,8 @@ bool qdev_hotplug_allowed(DeviceState *dev, BusState *bus, Error **errp)
bool qdev_hotunplug_allowed(DeviceState *dev, Error **errp)
{
- return !qdev_unplug_blocked(dev, errp);
+ return !qdev_unplug_blocked(dev, errp) &&
+ qdev_hotplug_unplug_allowed_common(dev, dev->parent_bus, errp);
}
HotplugHandler *qdev_get_bus_hotplug_handler(DeviceState *dev)
--
2.47.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL v2 09/55] hw/qdev: Check DevClass::hotpluggable in hotplug_unplug_allowed_common
2025-01-13 17:35 [PULL v2 00/55] Misc HW patches for 2025-01-12 Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2025-01-13 17:36 ` [PULL v2 08/55] hw/qdev: Introduce qdev_hotplug_unplug_allowed_common() Philippe Mathieu-Daudé
@ 2025-01-13 17:36 ` Philippe Mathieu-Daudé
2025-01-13 17:36 ` [PULL v2 10/55] hw/qdev: Check qbus_is_hotpluggable " Philippe Mathieu-Daudé
` (3 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-13 17:36 UTC (permalink / raw)
To: qemu-devel; +Cc: Akihiko Odaki, Philippe Mathieu-Daudé, Igor Mammedov
From: Akihiko Odaki <akihiko.odaki@daynix.com>
Check the same code once in the common helper.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
[PMD: Split from bigger patch, part 4/6]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <20250110091908.64454-5-philmd@linaro.org>
---
hw/core/qdev-hotplug.c | 9 +++++++++
system/qdev-monitor.c | 10 +---------
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/hw/core/qdev-hotplug.c b/hw/core/qdev-hotplug.c
index 168d7964740..1d77fffb5e0 100644
--- a/hw/core/qdev-hotplug.c
+++ b/hw/core/qdev-hotplug.c
@@ -12,6 +12,7 @@
#include "qemu/osdep.h"
#include "hw/qdev-core.h"
#include "hw/boards.h"
+#include "qapi/error.h"
HotplugHandler *qdev_get_machine_hotplug_handler(DeviceState *dev)
{
@@ -33,6 +34,14 @@ HotplugHandler *qdev_get_machine_hotplug_handler(DeviceState *dev)
static bool qdev_hotplug_unplug_allowed_common(DeviceState *dev, BusState *bus,
Error **errp)
{
+ DeviceClass *dc = DEVICE_GET_CLASS(dev);
+
+ if (!dc->hotpluggable) {
+ error_setg(errp, "Device '%s' does not support hotplugging",
+ object_get_typename(OBJECT(dev)));
+ return false;
+ }
+
return true;
}
diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c
index 511d1aa83c2..81f747b38fa 100644
--- a/system/qdev-monitor.c
+++ b/system/qdev-monitor.c
@@ -263,8 +263,7 @@ static DeviceClass *qdev_get_device_class(const char **driver, Error **errp)
}
dc = DEVICE_CLASS(oc);
- if (!dc->user_creatable ||
- (phase_check(PHASE_MACHINE_READY) && !dc->hotpluggable)) {
+ if (!dc->user_creatable) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "driver",
"a pluggable device type");
return NULL;
@@ -904,7 +903,6 @@ static DeviceState *find_device_state(const char *id, bool use_generic_error,
void qdev_unplug(DeviceState *dev, Error **errp)
{
- DeviceClass *dc = DEVICE_GET_CLASS(dev);
HotplugHandler *hotplug_ctrl;
HotplugHandlerClass *hdc;
Error *local_err = NULL;
@@ -919,12 +917,6 @@ void qdev_unplug(DeviceState *dev, Error **errp)
return;
}
- if (!dc->hotpluggable) {
- error_setg(errp, "Device '%s' does not support hotplugging",
- object_get_typename(OBJECT(dev)));
- return;
- }
-
if (migration_is_running() && !dev->allow_unplug_during_migration) {
error_setg(errp, "device_del not allowed while migrating");
return;
--
2.47.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL v2 10/55] hw/qdev: Check qbus_is_hotpluggable in hotplug_unplug_allowed_common
2025-01-13 17:35 [PULL v2 00/55] Misc HW patches for 2025-01-12 Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2025-01-13 17:36 ` [PULL v2 09/55] hw/qdev: Check DevClass::hotpluggable in hotplug_unplug_allowed_common Philippe Mathieu-Daudé
@ 2025-01-13 17:36 ` Philippe Mathieu-Daudé
2025-01-13 17:36 ` [PULL v2 11/55] hw/qdev: Check machine_hotplug_handler " Philippe Mathieu-Daudé
` (2 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-13 17:36 UTC (permalink / raw)
To: qemu-devel; +Cc: Akihiko Odaki, Philippe Mathieu-Daudé, Igor Mammedov
From: Akihiko Odaki <akihiko.odaki@daynix.com>
Check the same code once in the common helper.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
[PMD: Split from bigger patch, part 5/6]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <20250110091908.64454-6-philmd@linaro.org>
---
hw/core/qdev-hotplug.c | 8 ++++++++
system/qdev-monitor.c | 11 -----------
2 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/hw/core/qdev-hotplug.c b/hw/core/qdev-hotplug.c
index 1d77fffb5e0..f6422cd0e4e 100644
--- a/hw/core/qdev-hotplug.c
+++ b/hw/core/qdev-hotplug.c
@@ -42,6 +42,14 @@ static bool qdev_hotplug_unplug_allowed_common(DeviceState *dev, BusState *bus,
return false;
}
+ if (bus) {
+ if (!qbus_is_hotpluggable(bus)) {
+ error_setg(errp, "Bus '%s' does not support hotplugging",
+ bus->name);
+ return false;
+ }
+ }
+
return true;
}
diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c
index 81f747b38fa..e27d25c5859 100644
--- a/system/qdev-monitor.c
+++ b/system/qdev-monitor.c
@@ -675,11 +675,6 @@ DeviceState *qdev_device_add_from_qdict(const QDict *opts,
return NULL;
}
- if (phase_check(PHASE_MACHINE_READY) && bus && !qbus_is_hotpluggable(bus)) {
- error_setg(errp, "Bus '%s' does not support hotplugging", bus->name);
- return NULL;
- }
-
if (migration_is_running()) {
error_setg(errp, "device_add not allowed while migrating");
return NULL;
@@ -911,12 +906,6 @@ void qdev_unplug(DeviceState *dev, Error **errp)
return;
}
- if (dev->parent_bus && !qbus_is_hotpluggable(dev->parent_bus)) {
- error_setg(errp, "Bus '%s' does not support hotplugging",
- dev->parent_bus->name);
- return;
- }
-
if (migration_is_running() && !dev->allow_unplug_during_migration) {
error_setg(errp, "device_del not allowed while migrating");
return;
--
2.47.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL v2 11/55] hw/qdev: Check machine_hotplug_handler in hotplug_unplug_allowed_common
2025-01-13 17:35 [PULL v2 00/55] Misc HW patches for 2025-01-12 Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2025-01-13 17:36 ` [PULL v2 10/55] hw/qdev: Check qbus_is_hotpluggable " Philippe Mathieu-Daudé
@ 2025-01-13 17:36 ` Philippe Mathieu-Daudé
2025-02-04 13:58 ` Peter Maydell
2025-01-13 17:36 ` [PULL v2 55/55] Add a b4 configuration file Philippe Mathieu-Daudé
2025-01-14 20:53 ` [PULL v2 00/55] Misc HW patches for 2025-01-12 Stefan Hajnoczi
7 siblings, 1 reply; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-13 17:36 UTC (permalink / raw)
To: qemu-devel; +Cc: Akihiko Odaki, Philippe Mathieu-Daudé, Igor Mammedov
From: Akihiko Odaki <akihiko.odaki@daynix.com>
Commit 03fcbd9dc508 ("qdev: Check for the availability of a hotplug
controller before adding a device") says:
> The qdev_unplug() function contains a g_assert(hotplug_ctrl)
> statement, so QEMU crashes when the user tries to device_add +
> device_del a device that does not have a corresponding hotplug
> controller.
> The code in qdev_device_add() already checks whether the bus has a
> proper hotplug controller, but for devices that do not have a
> corresponding bus, here is no appropriate check available yet. In that
> case we should check whether the machine itself provides a suitable
> hotplug controller and refuse to plug the device if none is available.
However, it forgot to add the corresponding check to qdev_unplug().
Check the machine hotplug handler once in the common
qdev_hotplug_unplug_allowed_common() helper so both hotplug
and hot-unplug path are covered.
Fixes: 7716b8ca74 ("qdev: HotplugHandler: Add support for unplugging BUS-less devices")
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
[PMD: Split from bigger patch, part 6/6]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <20250110091908.64454-7-philmd@linaro.org>
---
hw/core/qdev-hotplug.c | 10 ++++++++++
system/qdev-monitor.c | 14 +++-----------
2 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/hw/core/qdev-hotplug.c b/hw/core/qdev-hotplug.c
index f6422cd0e4e..ff176dc1bb3 100644
--- a/hw/core/qdev-hotplug.c
+++ b/hw/core/qdev-hotplug.c
@@ -48,6 +48,16 @@ static bool qdev_hotplug_unplug_allowed_common(DeviceState *dev, BusState *bus,
bus->name);
return false;
}
+ } else {
+ if (!qdev_get_machine_hotplug_handler(dev)) {
+ /*
+ * No bus, no machine hotplug handler --> device is not hotpluggable
+ */
+ error_setg(errp,
+ "Device '%s' can not be hotplugged on this machine",
+ object_get_typename(OBJECT(dev)));
+ return false;
+ }
}
return true;
diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c
index e27d25c5859..861c25c855f 100644
--- a/system/qdev-monitor.c
+++ b/system/qdev-monitor.c
@@ -684,17 +684,9 @@ 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 (!qdev_hotplug_allowed(dev, bus, errp)) {
- goto err_del_dev;
- }
-
- if (!bus && !qdev_get_machine_hotplug_handler(dev)) {
- /* No bus, no machine hotplug handler --> device is not hotpluggable */
- error_setg(errp, "Device '%s' can not be hotplugged on this machine",
- driver);
- goto err_del_dev;
- }
+ if (phase_check(PHASE_MACHINE_READY) &&
+ !qdev_hotplug_allowed(dev, bus, errp)) {
+ goto err_del_dev;
}
/*
--
2.47.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL v2 55/55] Add a b4 configuration file
2025-01-13 17:35 [PULL v2 00/55] Misc HW patches for 2025-01-12 Philippe Mathieu-Daudé
` (5 preceding siblings ...)
2025-01-13 17:36 ` [PULL v2 11/55] hw/qdev: Check machine_hotplug_handler " Philippe Mathieu-Daudé
@ 2025-01-13 17:36 ` Philippe Mathieu-Daudé
2025-01-14 20:53 ` [PULL v2 00/55] Misc HW patches for 2025-01-12 Stefan Hajnoczi
7 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-01-13 17:36 UTC (permalink / raw)
To: qemu-devel; +Cc: Jiaxun Yang, Signed-off-by: Philippe Mathieu-Daudé
From: Jiaxun Yang <jiaxun.yang@flygoat.com>
b4 [1] is a convenient tool to manage patch series with mailing list
working flow.
Add a project default config file to match QEMU's mailing list conventions
as well as adopting differences on scripting.
Examples of b4:
```
$ b4 prep --check
Checking patches using:
scripts/checkpatch.pl -q --terse --no-summary --mailback -
---
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
Changes in v2:
- Add lore masks (philmd) from:
https://lore.kernel.org/qemu-devel/20241224135054.10243-1-philmd@linaro.org/
- Link to v1: https://lore.kernel.org/r/20241222-b4-config-v1-1-b3667beb30a4@flygoat.com
---
● cc5a4c890fed: Add a b4 configuration file
● checkpatch.pl: 27: WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
---
Success: 0, Warning: 1, Error: 0
```
```
$ b4 prep -c
Will collect To: addresses using echo
Will collect Cc: addresses using get_maintainer.pl
Collecting To/Cc addresses
+ To: qemu-devel@nongnu.org
---
You can trim/expand this list with: b4 prep --edit-cover
Invoking git-filter-repo to update the cover letter.
New history written in 0.02 seconds...
Completely finished after 0.06 seconds
```
[1]: https://b4.docs.kernel.org/
Co-developed-by: Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Message-ID: <20250102-b4-config-v2-1-cc7299e399bb@flygoat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
.b4-config | 14 ++++++++++++++
1 file changed, 14 insertions(+)
create mode 100644 .b4-config
diff --git a/.b4-config b/.b4-config
new file mode 100644
index 00000000000..4b9b2fe290f
--- /dev/null
+++ b/.b4-config
@@ -0,0 +1,14 @@
+#
+# Common b4 settings that can be used to send patches to QEMU upstream.
+# https://b4.docs.kernel.org/
+#
+
+[b4]
+ send-series-to = qemu-devel@nongnu.org
+ send-auto-to-cmd = echo
+ send-auto-cc-cmd = scripts/get_maintainer.pl --noroles --norolestats --nogit --nogit-fallback
+ am-perpatch-check-cmd = scripts/checkpatch.pl -q --terse --no-summary --mailback -
+ prep-perpatch-check-cmd = scripts/checkpatch.pl -q --terse --no-summary --mailback -
+ searchmask = https://lore.kernel.org/qemu-devel/?x=m&t=1&q=%s
+ linkmask = https://lore.kernel.org/qemu-devel/%s
+ linktrailermask = Message-ID: <%s>
--
2.47.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PULL v2 00/55] Misc HW patches for 2025-01-12
2025-01-13 17:35 [PULL v2 00/55] Misc HW patches for 2025-01-12 Philippe Mathieu-Daudé
` (6 preceding siblings ...)
2025-01-13 17:36 ` [PULL v2 55/55] Add a b4 configuration file Philippe Mathieu-Daudé
@ 2025-01-14 20:53 ` Stefan Hajnoczi
7 siblings, 0 replies; 10+ messages in thread
From: Stefan Hajnoczi @ 2025-01-14 20:53 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel, Philippe Mathieu-Daudé
[-- Attachment #1: Type: text/plain, Size: 116 bytes --]
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/10.0 for any user-visible changes.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PULL v2 11/55] hw/qdev: Check machine_hotplug_handler in hotplug_unplug_allowed_common
2025-01-13 17:36 ` [PULL v2 11/55] hw/qdev: Check machine_hotplug_handler " Philippe Mathieu-Daudé
@ 2025-02-04 13:58 ` Peter Maydell
0 siblings, 0 replies; 10+ messages in thread
From: Peter Maydell @ 2025-02-04 13:58 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel, Akihiko Odaki, Igor Mammedov
On Mon, 13 Jan 2025 at 17:38, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> From: Akihiko Odaki <akihiko.odaki@daynix.com>
>
> Commit 03fcbd9dc508 ("qdev: Check for the availability of a hotplug
> controller before adding a device") says:
>
> > The qdev_unplug() function contains a g_assert(hotplug_ctrl)
> > statement, so QEMU crashes when the user tries to device_add +
> > device_del a device that does not have a corresponding hotplug
> > controller.
>
> > The code in qdev_device_add() already checks whether the bus has a
> > proper hotplug controller, but for devices that do not have a
> > corresponding bus, here is no appropriate check available yet. In that
> > case we should check whether the machine itself provides a suitable
> > hotplug controller and refuse to plug the device if none is available.
>
> However, it forgot to add the corresponding check to qdev_unplug().
>
> Check the machine hotplug handler once in the common
> qdev_hotplug_unplug_allowed_common() helper so both hotplug
> and hot-unplug path are covered.
> diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c
> index e27d25c5859..861c25c855f 100644
> --- a/system/qdev-monitor.c
> +++ b/system/qdev-monitor.c
> @@ -684,17 +684,9 @@ 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 (!qdev_hotplug_allowed(dev, bus, errp)) {
> - goto err_del_dev;
> - }
> -
> - if (!bus && !qdev_get_machine_hotplug_handler(dev)) {
> - /* No bus, no machine hotplug handler --> device is not hotpluggable */
> - error_setg(errp, "Device '%s' can not be hotplugged on this machine",
> - driver);
> - goto err_del_dev;
> - }
> + if (phase_check(PHASE_MACHINE_READY) &&
> + !qdev_hotplug_allowed(dev, bus, errp)) {
> + goto err_del_dev;
> }
>
Hi; Coverity notices a NULL-check related issue as a
result of this change. Here we add a call to
qdev_hotplug_allowed() that assumes that dev is not NULL.
But in the code at err_del_dev we do check whether
dev is NULL. So either this code is wrong (and could be
dereferencing NULL) or the code at err_del_dev is
doing a pointless NULL check.
Since qdev_new() can't fail, it's the err_del_dev
code that's wrong, I think.
thanks
-- PMM
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2025-02-04 13:59 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-13 17:35 [PULL v2 00/55] Misc HW patches for 2025-01-12 Philippe Mathieu-Daudé
2025-01-13 17:35 ` [PULL v2 06/55] hw/qdev: Pass bus argument to qdev_hotplug_allowed() Philippe Mathieu-Daudé
2025-01-13 17:35 ` [PULL v2 07/55] hw/qdev: Factor qdev_hotunplug_allowed() out Philippe Mathieu-Daudé
2025-01-13 17:36 ` [PULL v2 08/55] hw/qdev: Introduce qdev_hotplug_unplug_allowed_common() Philippe Mathieu-Daudé
2025-01-13 17:36 ` [PULL v2 09/55] hw/qdev: Check DevClass::hotpluggable in hotplug_unplug_allowed_common Philippe Mathieu-Daudé
2025-01-13 17:36 ` [PULL v2 10/55] hw/qdev: Check qbus_is_hotpluggable " Philippe Mathieu-Daudé
2025-01-13 17:36 ` [PULL v2 11/55] hw/qdev: Check machine_hotplug_handler " Philippe Mathieu-Daudé
2025-02-04 13:58 ` Peter Maydell
2025-01-13 17:36 ` [PULL v2 55/55] Add a b4 configuration file Philippe Mathieu-Daudé
2025-01-14 20:53 ` [PULL v2 00/55] Misc HW patches for 2025-01-12 Stefan Hajnoczi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).