hw/nvram/fw_cfg: Move PCI bus methods out
cover hw/nvram/fw_cfg: Move PCI bus methods out
In order to keep fw_cfg device model clean, remove the PCI bus specific code. Instead, the equivalent functionality is implemented within the PCI_BUS object in hw/pci/, implementing TYPE_FW_CFG_DATA_GENERATOR_INTERFACE.
Philippe Mathieu-Daudé (6):
hw/nvram/fw_cfg: Rename fw_cfg_add_[file]_from_generator() hw/nvram/fw_cfg: Pass QOM parent to fw_cfg_add_file_from_generator() hw/pci: Have PCI_BUS implement TYPE_FW_CFG_DATA_GENERATOR_INTERFACE hw/pci: Add pci_bus_add_fw_cfg_extra_pci_roots() helper
hw: Use pci_bus_add_fw_cfg_extra_pci_roots() hw/nvram/fw_cfg: Remove fw_cfg_add_extra_pci_roots()
include/hw/nvram/fw_cfg.h | 21 ++++++---------- include/hw/pci/pci.h | 3 +++ hw/arm/virt.c | 3 ++- hw/hppa/machine.c | 2 +- hw/i386/pc.c | 3 ++- hw/nvram/fw_cfg.c | 34 +++++-------------------- hw/pci/pci.c | 53 +++++++++++++++++++++++++++++++++++++++ system/vl.c | 3 ++- 8 files changed, 76 insertions(+), 46 deletions(-)
Signature · 1 line
2.45.2
PATCH 1/6 hw/nvram/fw_cfg: Rename fw_cfg_add_[file]_from_generator()
fw_cfg_add_from_generator() is adding a 'file' entry, so rename as fw_cfg_add_file_from_generator() for clarity. Besides, we might introduce generators for other entry types.
--- include/hw/nvram/fw_cfg.h | 6 +++--- hw/nvram/fw_cfg.c | 4 ++-- system/vl.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-)
include/hw/nvram/fw_cfg.h +3 -3
@@ -291,7 +291,7 @@ void *fw_cfg_modify_file(FWCfgState *s, const char *filename, void *data, size_t len);/** -* fw_cfg_add_from_generator: +* 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
@@ -307,8 +307,8 @@ void *fw_cfg_modify_file(FWCfgState *s, const char *filename, void *data,* * Returns: %true on success, %false on error. */ -bool fw_cfg_add_from_generator (FWCfgState *s,const char *filename, -const char *gen_id,Error **errp); +bool fw_cfg_add_file_from_generator (FWCfgState *s,const char *filename, +const char *gen_id,Error **errp);/** * fw_cfg_add_extra_pci_roots:
hw/nvram/fw_cfg.c +2 -2
@@ -1027,8 +1027,8 @@ void *fw_cfg_modify_file(FWCfgState *s, const char *filename,return NULL ; } -bool fw_cfg_add_from_generator (FWCfgState *s,const char *filename, -const char *gen_id,Error **errp) +bool fw_cfg_add_file_from_generator (FWCfgState *s,const char *filename, +const char *gen_id,Error **errp) {FWCfgDataGeneratorClass *klass;GByteArray *array;
system/vl.c +1 -1
@@ -1184,7 +1184,7 @@ 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_from_generator (fw_cfg, name, gen_id, errp)) { +if (!fw_cfg_add_file_from_generator (fw_cfg, name, gen_id, errp)) {return -1 ; }return 0 ;
Signature · 1 line
2.45.2
Re: [PATCH 1/6] hw/nvram/fw_cfg: Rename fw_cfg_add_[file]_from_generator()
Quoted 11 lines · Philippe Mathieu-Daudé
fw_cfg_add_from_generator()is adding a 'file' entry, so rename asfw_cfg_add_file_from_generator()for clarity. Besides, we might introduce generators for other entry types.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/hw/nvram/fw_cfg.h | 6 +++--- hw/nvram/fw_cfg.c | 4 ++-- system/vl.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-)
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
PATCH 2/6 hw/nvram/fw_cfg: Pass QOM parent to fw_cfg_add_file_from_generator()
In reply to Philippe Mathieu-Daudé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.
--- include/hw/nvram/fw_cfg.h | 10 ++++++---- hw/nvram/fw_cfg.c | 11 ++++++----- system/vl.c | 3 ++- 3 files changed, 14 insertions(+), 10 deletions(-)
include/hw/nvram/fw_cfg.h +6 -4
@@ -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:
hw/nvram/fw_cfg.c +6 -5
@@ -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);
system/vl.c +2 -1
@@ -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 ;
Signature · 1 line
2.45.2
Re: [PATCH 2/6] hw/nvram/fw_cfg: Pass QOM parent to fw_cfg_add_file_from_generator()
Quoted 11 lines · Philippe Mathieu-Daudé
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é <[email protected]>--- include/hw/nvram/fw_cfg.h | 10 ++++++---- hw/nvram/fw_cfg.c | 11 ++++++----- system/vl.c | 3 ++- 3 files changed, 14 insertions(+), 10 deletions(-)
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
PATCH 3/6 hw/pci: Have PCI_BUS implement TYPE_FW_CFG_DATA_GENERATOR_INTERFACE
In reply to Philippe Mathieu-DaudéThe FW_CFG_DATA_GENERATOR allows any object to produce blob of data consumable by the fw_cfg device. Implement that for PCI bus objects.
--- hw/pci/pci.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
hw/pci/pci.c +37 -0
@@ -46,6 +46,7 @@#include "hw/pci/msix.h" #include "hw/hotplug.h" #include "hw/boards.h" +#include "hw/nvram/fw_cfg.h" #include "qapi/error.h" #include "qemu/cutils.h" #include "pci-internal.h"
@@ -216,11 +217,41 @@ static uint16_t pcibus_numa_node(PCIBus *bus)return NUMA_NODE_UNASSIGNED ; } +static GByteArray *pci_bus_fw_cfg_gen_data (Object *obj,Error **errp) +{ +PCIBus *bus =PCI_BUS (obj); +GByteArray *byte_array; +uint64_t extra_hosts =0 ; + +if (!bus) { +return NULL ; + } + + QLIST_FOREACH(bus, &bus->child, sibling) { +/* look for expander root buses */ +if (pci_bus_is_root (bus)) { + extra_hosts++; + } + } + +if (!extra_hosts) { +return NULL ; + } + extra_hosts =cpu_to_le64 (extra_hosts); + + byte_array =g_byte_array_new (); +g_byte_array_append (byte_array, + (const void *)&extra_hosts,sizeof (extra_hosts)); + +return byte_array; +} +static void pci_bus_class_init (ObjectClass *klass,void *data) {BusClass *k =BUS_CLASS (klass);PCIBusClass *pbc =PCI_BUS_CLASS (klass);ResettableClass *rc =RESETTABLE_CLASS (klass); +FWCfgDataGeneratorClass *fwgc =FW_CFG_DATA_GENERATOR_CLASS (klass); k->print_dev = pcibus_dev_print; k->get_dev_path = pcibus_get_dev_path;
@@ -232,6 +263,8 @@ static void pci_bus_class_init(ObjectClass *klass, void *data) pbc->bus_num = pcibus_num; pbc->numa_node = pcibus_numa_node; + + fwgc->get_data = pci_bus_fw_cfg_gen_data; }static const TypeInfo pci_bus_info = {
@@ -240,6 +273,10 @@ static const TypeInfo pci_bus_info = { .instance_size = sizeof(PCIBus), .class_size = sizeof(PCIBusClass), .class_init = pci_bus_class_init, + .interfaces = (InterfaceInfo []) { + {TYPE_FW_CFG_DATA_GENERATOR_INTERFACE }, + { } + } };static const TypeInfo cxl_interface_info = {
Signature · 1 line
2.45.2
Re: [PATCH 3/6] hw/pci: Have PCI_BUS implement TYPE_FW_CFG_DATA_GENERATOR_INTERFACE
Quoted 1 line · Philippe Mathieu-Daudé
The
FW_CFG_DATA_GENERATORallows any object to produce
^
^^^
^^^^^ insert word 'interface'Quoted 1 line
blob of data consumable by the
fw_cfgdevice. Implement
^ 'a' as in 'a blob of...'
Quoted 22 lines
that for PCI bus objects.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/pci/pci.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)hw/pci/pci.c +1
-0@@ -46,6 +46,7 @@#include "hw/pci/msix.h" #include "hw/hotplug.h" #include "hw/boards.h" +#include "hw/nvram/fw_cfg.h" #include "qapi/error.h" #include "qemu/cutils.h" #include "pci-internal.h" @@ -216,11 +217,41 @@ static uint16_t pcibus_numa_node(PCIBus *bus)return NUMA_NODE_UNASSIGNED ; }
hw/pci/pci.c static uint16_t pcibus_numa_node(PCIBus *bus) · line 228
Quoted 10 lines
hw/pci/pci.c +9
-0+static GByteArray *pci_bus_fw_cfg_gen_data (Object *obj,Error **errp) +{ +PCIBus *bus =PCI_BUS (obj); +GByteArray *byte_array; +uint64_t extra_hosts =0 ; + +if (!bus) { +return NULL ; + }
Returning NULL without setting 'errp'.
On the one hand I could see returning NULL, without errp, as being useful semantics for "I have no data to add currently". THe callers don't appear to distinguish NULL without errp, from NULL with errp. They just propagate a failure return code up the stack.
The API docs for 'get_data' method don't say you can return NULL without setting errp either.
hw/pci/pci.c static uint16_t pcibus_numa_node(PCIBus *bus) · line 238
Quoted 10 lines
hw/pci/pci.c +10
-0+ + QLIST_FOREACH(bus, &bus->child, sibling) { +/* look for expander root buses */ +if (pci_bus_is_root (bus)) { + extra_hosts++; + } + } + +if (!extra_hosts) { +return NULL ;
Same.
Quoted 43 lines
hw/pci/pci.c +17
-0+ } + extra_hosts =cpu_to_le64 (extra_hosts); + + byte_array =g_byte_array_new (); +g_byte_array_append (byte_array, + (const void *)&extra_hosts,sizeof (extra_hosts)); + +return byte_array; +} +static void pci_bus_class_init (ObjectClass *klass,void *data) {BusClass *k =BUS_CLASS (klass);PCIBusClass *pbc =PCI_BUS_CLASS (klass);ResettableClass *rc =RESETTABLE_CLASS (klass); +FWCfgDataGeneratorClass *fwgc =FW_CFG_DATA_GENERATOR_CLASS (klass); k->print_dev = pcibus_dev_print; k->get_dev_path = pcibus_get_dev_path;@@ -232,6 +263,8 @@ static void pci_bus_class_init(ObjectClass *klass, void *data) pbc->bus_num = pcibus_num; pbc->numa_node = pcibus_numa_node; + + fwgc->get_data = pci_bus_fw_cfg_gen_data; }static const TypeInfo pci_bus_info = {@@ -240,6 +273,10 @@ static const TypeInfo pci_bus_info = { .instance_size = sizeof(PCIBus), .class_size = sizeof(PCIBusClass), .class_init = pci_bus_class_init, + .interfaces = (InterfaceInfo []) { + {TYPE_FW_CFG_DATA_GENERATOR_INTERFACE }, + { } + } };static const TypeInfo cxl_interface_info = {Signature · 1 line
2.45.2
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH 3/6] hw/pci: Have PCI_BUS implement TYPE_FW_CFG_DATA_GENERATOR_INTERFACE
Quoted 45 lines · Daniel P. Berrangé
Quoted 1 line · Philippe Mathieu-Daudé
The
FW_CFG_DATA_GENERATORallows any object to produce^ ^^^ ^^^^^ insert word 'interface'Quoted 1 line
blob of data consumable by the
fw_cfgdevice. Implement^ 'a' as in 'a blob of...'
Quoted 22 lines
that for PCI bus objects.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/pci/pci.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)hw/pci/pci.c +1
-0@@ -46,6 +46,7 @@#include "hw/pci/msix.h" #include "hw/hotplug.h" #include "hw/boards.h" +#include "hw/nvram/fw_cfg.h" #include "qapi/error.h" #include "qemu/cutils.h" #include "pci-internal.h" @@ -216,11 +217,41 @@ static uint16_t pcibus_numa_node(PCIBus *bus)return NUMA_NODE_UNASSIGNED ; }hw/pci/pci.c static uint16_t pcibus_numa_node(PCIBus *bus) · line 228
Quoted 10 lines
hw/pci/pci.c +9
-0+static GByteArray *pci_bus_fw_cfg_gen_data (Object *obj,Error **errp) +{ +PCIBus *bus =PCI_BUS (obj); +GByteArray *byte_array; +uint64_t extra_hosts =0 ; + +if (!bus) { +return NULL ; + }Returning NULL without setting 'errp'.
Quoted 7 lines
On the one hand I could see returning NULL, without errp, as being useful semantics for "I have no data to add currently". THe callers don't appear to distinguish NULL without errp, from NULL with errp. They just propagate a failure return code up the stack.
The API docs for '
get_data' method don't say you can return NULL without setting errp either.
Good catch. API updated here:
https://lore.kernel.org/qemu-devel/[email protected]/
Thanks,
Phil.
Quoted 23 lines
hw/pci/pci.c static uint16_t pcibus_numa_node(PCIBus *bus) · line 238
Quoted 11 lines
hw/pci/pci.c +10
-0+ + QLIST_FOREACH(bus, &bus->child, sibling) { +/* look for expander root buses */ +if (pci_bus_is_root (bus)) { + extra_hosts++; + } + } + +if (!extra_hosts) { +return NULL ;Same.
Quoted 9 lines
hw/pci/pci.c +9
-0+ } + extra_hosts =cpu_to_le64 (extra_hosts); + + byte_array =g_byte_array_new (); +g_byte_array_append (byte_array, + (const void *)&extra_hosts,sizeof (extra_hosts)); + +return byte_array; +}
PATCH 4/6 hw/pci: Add pci_bus_add_fw_cfg_extra_pci_roots() helper
In reply to Philippe Mathieu-Daudépci_bus_add_fw_cfg_extra_pci_roots() calls the fw_cfg API with PCI bus specific arguments.
--- include/hw/pci/pci.h | 3 +++ hw/pci/pci.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+)
include/hw/pci/pci.h +3 -0
@@ -297,6 +297,9 @@ int pci_bus_get_irq_level(PCIBus *bus, int irq_num);uint32_t pci_bus_get_slot_reserved_mask (PCIBus *bus);void pci_bus_set_slot_reserved_mask (PCIBus *bus,uint32_t mask);void pci_bus_clear_slot_reserved_mask (PCIBus *bus,uint32_t mask); +bool pci_bus_add_fw_cfg_extra_pci_roots (FWCfgState *fw_cfg, +PCIBus *bus, +Error **errp);/* 0 <= pin <= 3 0 = INTA, 1 = INTB, 2 = INTC, 3 = INTD */ static inline int pci_swizzle (int slot,int pin) {
hw/pci/pci.c +16 -0
@@ -217,6 +217,22 @@ static uint16_t pcibus_numa_node(PCIBus *bus)return NUMA_NODE_UNASSIGNED ; } +bool pci_bus_add_fw_cfg_extra_pci_roots (FWCfgState *fw_cfg, +PCIBus *bus, +Error **errp) +{ +Object *obj; + +if (!bus) { +return true; + } + obj =OBJECT (bus); + +return fw_cfg_add_file_from_generator (fw_cfg, obj->parent, +object_get_canonical_path_component (obj), +"etc/extra-pci-roots" , errp); +} +static GByteArray *pci_bus_fw_cfg_gen_data (Object *obj,Error **errp) {PCIBus *bus =PCI_BUS (obj);
Signature · 1 line
2.45.2
Re: [PATCH 4/6] hw/pci: Add pci_bus_add_fw_cfg_extra_pci_roots() helper
Quoted 8 lines · Philippe Mathieu-Daudé
pci_bus_add_fw_cfg_extra_pci_roots()calls thefw_cfgAPI with PCI bus specific arguments.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/hw/pci/pci.h | 3 +++ hw/pci/pci.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+)
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
PATCH 5/6 hw: Use pci_bus_add_fw_cfg_extra_pci_roots()
In reply to Philippe Mathieu-DaudéWe want to remove fw_cfg_add_extra_pci_roots() which introduced PCI bus knowledge within the generic hw/nvram/fw_cfg.c file. Replace the calls by the pci_bus_add_fw_cfg_extra_pci_roots() which is a 1:1 equivalent, but using correct API.
--- hw/arm/virt.c | 3 ++- hw/hppa/machine.c | 2 +- hw/i386/pc.c | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-)
hw/arm/virt.c +2 -1
@@ -1750,7 +1750,8 @@ void virt_machine_done(Notifier *notifier, void *data)exit (1 ); } -fw_cfg_add_extra_pci_roots (vms->bus, vms->fw_cfg); +pci_bus_add_fw_cfg_extra_pci_roots (vms->fw_cfg, vms->bus, + &error_abort);virt_acpi_setup (vms);virt_build_smbios (vms);
hw/hppa/machine.c +1 -1
@@ -240,7 +240,7 @@ static FWCfgState *create_fw_cfg(MachineState *ms, PCIBus *pci_bus,g_memdup2 (qemu_version,sizeof (qemu_version)), sizeof(qemu_version)); -fw_cfg_add_extra_pci_roots (pci_bus, fw_cfg); +pci_bus_add_fw_cfg_extra_pci_roots (fw_cfg, pci_bus, &error_abort);return fw_cfg; }
hw/i386/pc.c +2 -1
@@ -628,7 +628,8 @@ void pc_machine_done(Notifier *notifier, void *data)/* set the number of CPUs */ x86_rtc_set_cpus_count (x86ms->rtc, x86ms->boot_cpus); -fw_cfg_add_extra_pci_roots (pcms->pcibus, x86ms->fw_cfg); +pci_bus_add_fw_cfg_extra_pci_roots (x86ms->fw_cfg, pcms->pcibus, + &error_abort);acpi_setup ();if (x86ms->fw_cfg) {
Signature · 1 line
2.45.2
Re: [PATCH 5/6] hw: Use pci_bus_add_fw_cfg_extra_pci_roots()
Quoted 11 lines · Philippe Mathieu-Daudé
We want to remove
fw_cfg_add_extra_pci_roots()which introduced PCI bus knowledge within the generichw/nvram/fw_cfg.cfile. Replace the calls by thepci_bus_add_fw_cfg_extra_pci_roots()which is a 1:1 equivalent, but using correct API.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/arm/virt.c | 3 ++- hw/hppa/machine.c | 2 +- hw/i386/pc.c | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-)
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
PATCH 6/6 hw/nvram/fw_cfg: Remove fw_cfg_add_extra_pci_roots()
In reply to Philippe Mathieu-DaudéNow that all uses of fw_cfg_add_extra_pci_roots() have been converted to the newer pci_bus_add_fw_cfg_extra_pci_roots(), we can remove that bogus method. hw/nvram/fw_cfg must stay generic. Device specific entries have to be implemented using TYPE_FW_CFG_DATA_GENERATOR_INTERFACE.
This mostly reverts commit 0abd38885ac0fcdb08653922f339849cad387961 ("fw_cfg: Refactor extra pci roots addition").
--- include/hw/nvram/fw_cfg.h | 9 --------- hw/nvram/fw_cfg.c | 23 ----------------------- 2 files changed, 32 deletions(-)
include/hw/nvram/fw_cfg.h +0 -9
@@ -312,15 +312,6 @@ 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: -* @bus: main pci root bus to be scanned from -* @s: fw_cfg device being modified -* -* Add a new fw_cfg item... -*/ -void fw_cfg_add_extra_pci_roots (PCIBus *bus,FWCfgState *s); -FWCfgState *fw_cfg_init_io_dma (uint32_t iobase,uint32_t dma_iobase,AddressSpace *dma_as);FWCfgState *fw_cfg_init_mem (hwaddr ctl_addr,hwaddr data_addr);
hw/nvram/fw_cfg.c +0 -23
@@ -41,7 +41,6 @@#include "qemu/cutils.h" #include "qapi/error.h" #include "hw/acpi/aml-build.h" -#include "hw/pci/pci_bus.h" #include "hw/loader.h" #define FW_CFG_FILE_SLOTS_DFLT 0x20
@@ -1057,28 +1056,6 @@ bool fw_cfg_add_file_from_generator(FWCfgState *s,return true; } -void fw_cfg_add_extra_pci_roots (PCIBus *bus,FWCfgState *s) -{ -int extra_hosts =0 ; - -if (!bus) { -return ; - } - - QLIST_FOREACH(bus, &bus->child, sibling) { -/* look for expander root buses */ -if (pci_bus_is_root (bus)) { - extra_hosts++; - } - } - -if (extra_hosts && s) { -uint64_t *val =g_malloc (sizeof (*val)); - *val =cpu_to_le64 (extra_hosts); -fw_cfg_add_file (s,"etc/extra-pci-roots" , val,sizeof (*val)); - } -} -static void fw_cfg_machine_reset (void *opaque) {MachineClass *mc =MACHINE_GET_CLASS (qdev_get_machine ());
Signature · 1 line
2.45.2
Re: [PATCH 6/6] hw/nvram/fw_cfg: Remove fw_cfg_add_extra_pci_roots()
Quoted 6 lines · Philippe Mathieu-Daudé
Now that all uses of
fw_cfg_add_extra_pci_roots()have been converted to the newerpci_bus_add_fw_cfg_extra_pci_roots(), we can remove that bogus method. hw/nvram/fw_cfg must stay generic. Device specific entries have to be implemented usingTYPE_FW_CFG_DATA_GENERATOR_INTERFACE.
Quoted 8 lines
This mostly reverts commit
0abd38885ac0fcdb08653922f339849cad387961("fw_cfg: Refactor extra pci roots addition").Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/hw/nvram/fw_cfg.h | 9 --------- hw/nvram/fw_cfg.c | 23 ----------------------- 2 files changed, 32 deletions(-)
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 5 lines · Philippe Mathieu-Daudé
In order to keep
fw_cfgdevice model clean, remove the PCI bus specific code. Instead, the equivalent functionality is implemented within thePCI_BUSobject in hw/pci/, implementingTYPE_FW_CFG_DATA_GENERATOR_INTERFACE.
Quoted 7 lines
Philippe Mathieu-Daudé (6):
hw/nvram/fw_cfg: Rename fw_cfg_add_[file]_from_generator() hw/nvram/fw_cfg: Pass QOM parent tofw_cfg_add_file_from_generator()hw/pci: HavePCI_BUSimplementTYPE_FW_CFG_DATA_GENERATOR_INTERFACEhw/pci: Addpci_bus_add_fw_cfg_extra_pci_roots()helper
hw: Usepci_bus_add_fw_cfg_extra_pci_roots()hw/nvram/fw_cfg: Removefw_cfg_add_extra_pci_roots()
ping