This will currently always succeed until the check is moved from init to 
realize.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayl...@ilande.co.uk>
---
 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


Reply via email to