[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCHv7 4/6] fw_cfg: add assert() to ensure the fw_cfg dev
From: |
Mark Cave-Ayland |
Subject: |
[Qemu-devel] [PATCHv7 4/6] fw_cfg: add assert() to ensure the fw_cfg device has been added as a child property |
Date: |
Thu, 29 Jun 2017 15:07:18 +0100 |
This will currently always succeed until the check is moved from init to
realize.
Signed-off-by: Mark Cave-Ayland <address@hidden>
---
hw/nvram/fw_cfg.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index 0fe7404..2291121 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -907,6 +907,17 @@ static void fw_cfg_machine_ready(struct Notifier *n, void
*data)
qemu_register_reset(fw_cfg_machine_reset, s);
}
+static int fw_cfg_unattached_foreach(Object *obj, void *opaque)
+{
+ return (object_dynamic_cast(obj, TYPE_FW_CFG) != NULL);
+}
+
+static int fw_cfg_unattached_at_realize(void)
+{
+ Object *obj = container_get(qdev_get_machine(), "/unattached");
+
+ return object_child_foreach(obj, fw_cfg_unattached_foreach, NULL);
+}
static void fw_cfg_init1(DeviceState *dev)
@@ -921,6 +932,8 @@ static void fw_cfg_init1(DeviceState *dev)
qdev_init_nofail(dev);
+ assert(!fw_cfg_unattached_at_realize());
+
fw_cfg_add_bytes(s, FW_CFG_SIGNATURE, (char *)"QEMU", 4);
fw_cfg_add_bytes(s, FW_CFG_UUID, &qemu_uuid, 16);
fw_cfg_add_i16(s, FW_CFG_NOGRAPHIC, (uint16_t)!machine->enable_graphics);
--
1.7.10.4
- [Qemu-devel] [PATCHv7 0/6] fw_cfg: qdev-related tidy-ups, Mark Cave-Ayland, 2017/06/29
- [Qemu-devel] [PATCHv7 3/6] fw_cfg: switch fw_cfg_find() to locate the fw_cfg device by type rather than path, Mark Cave-Ayland, 2017/06/29
- [Qemu-devel] [PATCHv7 1/6] fw_cfg: don't map the fw_cfg IO ports in fw_cfg_io_realize(), Mark Cave-Ayland, 2017/06/29
- [Qemu-devel] [PATCHv7 2/6] fw_cfg: move setting of FW_CFG_VERSION_DMA bit to fw_cfg_init1(), Mark Cave-Ayland, 2017/06/29
- [Qemu-devel] [PATCHv7 4/6] fw_cfg: add assert() to ensure the fw_cfg device has been added as a child property,
Mark Cave-Ayland <=
- [Qemu-devel] [PATCHv7 5/6] fw_cfg: move qdev_init_nofail() from fw_cfg_init1() to callers, Mark Cave-Ayland, 2017/06/29
- [Qemu-devel] [PATCHv7 6/6] fw_cfg: move QOM type defines and fw_cfg types into fw_cfg.h, Mark Cave-Ayland, 2017/06/29
- Re: [Qemu-devel] [PATCHv7 0/6] fw_cfg: qdev-related tidy-ups, Gabriel L. Somlo, 2017/06/29