@@ -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:
@@ -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);
@@ -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;
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> --- include/hw/nvram/fw_cfg.h | 10 ++++++---- hw/nvram/fw_cfg.c | 11 ++++++----- system/vl.c | 3 ++- 3 files changed, 14 insertions(+), 10 deletions(-)