mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 08:43:55 -06:00
hw/nvram/fw_cfg: Pass QOM parent to fw_cfg_add_file_from_generator()
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>
This commit is contained in:
parent
e20a4425ca
commit
51680269fe
3 changed files with 14 additions and 10 deletions
|
@ -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);
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue