[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 06/20] hw/nvram/fw_cfg: Pass QOM parent to fw_cfg_add_file_from_ge
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 06/20] hw/nvram/fw_cfg: Pass QOM parent to fw_cfg_add_file_from_generator() |
Date: |
Sat, 14 Dec 2024 00:30:41 +0100 |
Currently fw_cfg_add_file_from_generator() is restricted
to command line created objects which reside in the
'/objects' QOM container. In order to extend to other
types of containers, pass the QOM parent by argument.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20241206181352.6836-3-philmd@linaro.org>
---
include/hw/nvram/fw_cfg.h | 10 ++++++----
hw/nvram/fw_cfg.c | 11 ++++++-----
system/vl.c | 3 ++-
3 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h
index 14e68966c59..fcb06f18cc3 100644
--- a/include/hw/nvram/fw_cfg.h
+++ b/include/hw/nvram/fw_cfg.h
@@ -294,11 +294,12 @@ void *fw_cfg_modify_file(FWCfgState *s, const char
*filename, void *data,
* fw_cfg_add_file_from_generator:
* @s: fw_cfg device being modified
* @filename: name of new fw_cfg file item
- * @gen_id: name of object implementing FW_CFG_DATA_GENERATOR interface
+ * @part: name of object implementing FW_CFG_DATA_GENERATOR interface
+ * @parent: the object in which to resolve the @part
* @errp: pointer to a NULL initialized error object
*
* Add a new NAMED fw_cfg item with the content generated from the
- * @gen_id object. The data generated by the @gen_id object is copied
+ * @part object. The data generated by the @part object is copied
* into the data structure of the fw_cfg device.
* The next available (unused) selector key starting at FW_CFG_FILE_FIRST
* will be used; also, a new entry will be added to the file directory
@@ -307,8 +308,9 @@ void *fw_cfg_modify_file(FWCfgState *s, const char
*filename, void *data,
*
* Returns: %true on success, %false on error.
*/
-bool fw_cfg_add_file_from_generator(FWCfgState *s, const char *filename,
- const char *gen_id, Error **errp);
+bool fw_cfg_add_file_from_generator(FWCfgState *s,
+ Object *parent, const char *part,
+ const char *filename, Error **errp);
/**
* fw_cfg_add_extra_pci_roots:
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index fe3b86135a7..b94cd27bd85 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -1027,22 +1027,23 @@ void *fw_cfg_modify_file(FWCfgState *s, const char
*filename,
return NULL;
}
-bool fw_cfg_add_file_from_generator(FWCfgState *s, const char *filename,
- const char *gen_id, Error **errp)
+bool fw_cfg_add_file_from_generator(FWCfgState *s,
+ Object *parent, const char *part,
+ const char *filename, Error **errp)
{
FWCfgDataGeneratorClass *klass;
GByteArray *array;
Object *obj;
gsize size;
- obj = object_resolve_path_component(object_get_objects_root(), gen_id);
+ obj = object_resolve_path_component(parent, part);
if (!obj) {
- error_setg(errp, "Cannot find object ID '%s'", gen_id);
+ error_setg(errp, "Cannot find object ID '%s'", part);
return false;
}
if (!object_dynamic_cast(obj, TYPE_FW_CFG_DATA_GENERATOR_INTERFACE)) {
error_setg(errp, "Object ID '%s' is not a '%s' subclass",
- gen_id, TYPE_FW_CFG_DATA_GENERATOR_INTERFACE);
+ part, TYPE_FW_CFG_DATA_GENERATOR_INTERFACE);
return false;
}
klass = FW_CFG_DATA_GENERATOR_GET_CLASS(obj);
diff --git a/system/vl.c b/system/vl.c
index f103532a9a1..4a370da624a 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -1184,7 +1184,8 @@ static int parse_fw_cfg(void *opaque, QemuOpts *opts,
Error **errp)
size = strlen(str); /* NUL terminator NOT included in fw_cfg blob */
buf = g_memdup(str, size);
} else if (nonempty_str(gen_id)) {
- if (!fw_cfg_add_file_from_generator(fw_cfg, name, gen_id, errp)) {
+ if (!fw_cfg_add_file_from_generator(fw_cfg, object_get_objects_root(),
+ gen_id, name, errp)) {
return -1;
}
return 0;
--
2.45.2
- [PULL 00/20] Misc HW patches for 2024-12-14, Philippe Mathieu-Daudé, 2024/12/13
- [PULL 01/20] docs/nitro-enclave: Fix terminal commands formatting, Philippe Mathieu-Daudé, 2024/12/13
- [PULL 02/20] hw/core/eif: Use stateful qcrypto apis, Philippe Mathieu-Daudé, 2024/12/13
- [PULL 03/20] hw/virtio/virtio-nsm: Support string data for extendPCR, Philippe Mathieu-Daudé, 2024/12/13
- [PULL 04/20] hw/riscv/virt: Remove pointless GPEX_HOST() cast, Philippe Mathieu-Daudé, 2024/12/13
- [PULL 06/20] hw/nvram/fw_cfg: Pass QOM parent to fw_cfg_add_file_from_generator(),
Philippe Mathieu-Daudé <=
- [PULL 07/20] hw/nvram/fw_cfg: Skip FW_CFG_DATA_GENERATOR when no data to generate, Philippe Mathieu-Daudé, 2024/12/13
- [PULL 05/20] hw/nvram/fw_cfg: Rename fw_cfg_add_[file]_from_generator(), Philippe Mathieu-Daudé, 2024/12/13
- [PULL 08/20] hw/pci: Have PCI_BUS implement TYPE_FW_CFG_DATA_GENERATOR_INTERFACE, Philippe Mathieu-Daudé, 2024/12/13
- [PULL 10/20] hw: Use pci_bus_add_fw_cfg_extra_pci_roots(), Philippe Mathieu-Daudé, 2024/12/13
- [PULL 09/20] hw/pci: Add pci_bus_add_fw_cfg_extra_pci_roots() helper, Philippe Mathieu-Daudé, 2024/12/13
- [PULL 12/20] hw/net/can: clean-up unnecessary includes, Philippe Mathieu-Daudé, 2024/12/13
- [PULL 15/20] hw/usb/hcd-xhci-pci: Indentation fix, Philippe Mathieu-Daudé, 2024/12/13
- [PULL 11/20] hw/nvram/fw_cfg: Remove fw_cfg_add_extra_pci_roots(), Philippe Mathieu-Daudé, 2024/12/13
- [PULL 17/20] hw/ide/ahci: Extract TYPE_SYSBUS_AHCI into dedicated file, Philippe Mathieu-Daudé, 2024/12/13
- [PULL 14/20] hw/usb/hcd-xhci-nec: Remove unused XHCINecState::flags field, Philippe Mathieu-Daudé, 2024/12/13