fw_cfg: switch fw_cfg_find() to locate the fw_cfg device by type rather than path
authorMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Fri, 14 Jul 2017 09:40:06 +0000 (10:40 +0100)
committerEduardo Habkost <ehabkost@redhat.com>
Mon, 17 Jul 2017 18:41:30 +0000 (15:41 -0300)
This will enable the fw_cfg device to be placed anywhere within the QOM tree
regardless of its machine location.

Note that we also add a comment to document the behaviour that we return NULL to
indicate failure where either no fw_cfg device or multiple fw_cfg devices are
found.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Message-Id: <1500025208-14827-2-git-send-email-mark.cave-ayland@ilande.co.uk>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
hw/nvram/fw_cfg.c

index e881e3b812fbc6fe2b62b831c78a9ebe3701d7cd..3a988b669bc4b6af1bb344750cae127d50640fdd 100644 (file)
@@ -1017,7 +1017,8 @@ FWCfgState *fw_cfg_init_mem(hwaddr ctl_addr, hwaddr data_addr)
 
 FWCfgState *fw_cfg_find(void)
 {
-    return FW_CFG(object_resolve_path(FW_CFG_PATH, NULL));
+    /* Returns NULL unless there is exactly one fw_cfg device */
+    return FW_CFG(object_resolve_path_type("", TYPE_FW_CFG, NULL));
 }
 
 static void fw_cfg_class_init(ObjectClass *klass, void *data)