1 | Missing review: 3 & 4 | ||
---|---|---|---|
2 | |||
3 | Since v1: | ||
4 | - Patch 3 is new | ||
5 | - Added danpb R-b tags | ||
6 | |||
1 | In order to keep fw_cfg device model clean, remove the PCI | 7 | In order to keep fw_cfg device model clean, remove the PCI |
2 | bus specific code. Instead, the equivalent functionality is | 8 | bus specific code. Instead, the equivalent functionality is |
3 | implemented within the PCI_BUS object in hw/pci/, | 9 | implemented within the PCI_BUS object in hw/pci/, |
4 | implementing TYPE_FW_CFG_DATA_GENERATOR_INTERFACE. | 10 | implementing TYPE_FW_CFG_DATA_GENERATOR_INTERFACE. |
5 | 11 | ||
6 | Philippe Mathieu-Daudé (6): | 12 | Philippe Mathieu-Daudé (7): |
7 | hw/nvram/fw_cfg: Rename fw_cfg_add_[file]_from_generator() | 13 | hw/nvram/fw_cfg: Rename fw_cfg_add_[file]_from_generator() |
8 | hw/nvram/fw_cfg: Pass QOM parent to fw_cfg_add_file_from_generator() | 14 | hw/nvram/fw_cfg: Pass QOM parent to fw_cfg_add_file_from_generator() |
15 | hw/nvram/fw_cfg: Skip FW_CFG_DATA_GENERATOR when no data to generate | ||
9 | hw/pci: Have PCI_BUS implement TYPE_FW_CFG_DATA_GENERATOR_INTERFACE | 16 | hw/pci: Have PCI_BUS implement TYPE_FW_CFG_DATA_GENERATOR_INTERFACE |
10 | hw/pci: Add pci_bus_add_fw_cfg_extra_pci_roots() helper | 17 | hw/pci: Add pci_bus_add_fw_cfg_extra_pci_roots() helper |
11 | hw: Use pci_bus_add_fw_cfg_extra_pci_roots() | 18 | hw: Use pci_bus_add_fw_cfg_extra_pci_roots() |
12 | hw/nvram/fw_cfg: Remove fw_cfg_add_extra_pci_roots() | 19 | hw/nvram/fw_cfg: Remove fw_cfg_add_extra_pci_roots() |
13 | 20 | ||
14 | include/hw/nvram/fw_cfg.h | 21 ++++++---------- | 21 | include/hw/nvram/fw_cfg.h | 32 +++++++++++------------ |
15 | include/hw/pci/pci.h | 3 +++ | 22 | include/hw/pci/pci.h | 3 +++ |
16 | hw/arm/virt.c | 3 ++- | 23 | hw/arm/virt.c | 3 ++- |
17 | hw/hppa/machine.c | 2 +- | 24 | hw/hppa/machine.c | 2 +- |
18 | hw/i386/pc.c | 3 ++- | 25 | hw/i386/pc.c | 3 ++- |
19 | hw/nvram/fw_cfg.c | 34 +++++-------------------- | 26 | hw/nvram/fw_cfg.c | 44 +++++++++----------------------- |
20 | hw/pci/pci.c | 53 +++++++++++++++++++++++++++++++++++++++ | 27 | hw/pci/pci.c | 53 +++++++++++++++++++++++++++++++++++++++ |
21 | system/vl.c | 3 ++- | 28 | system/vl.c | 3 ++- |
22 | 8 files changed, 76 insertions(+), 46 deletions(-) | 29 | 8 files changed, 89 insertions(+), 54 deletions(-) |
23 | 30 | ||
24 | -- | 31 | -- |
25 | 2.45.2 | 32 | 2.45.2 |
26 | 33 | ||
27 | 34 | diff view generated by jsdifflib |
1 | fw_cfg_add_from_generator() is adding a 'file' entry, | 1 | fw_cfg_add_from_generator() is adding a 'file' entry, |
---|---|---|---|
2 | so rename as fw_cfg_add_file_from_generator() for | 2 | so rename as fw_cfg_add_file_from_generator() for |
3 | clarity. Besides, we might introduce generators for | 3 | clarity. Besides, we might introduce generators for |
4 | other entry types. | 4 | other entry types. |
5 | 5 | ||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
7 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | ||
7 | --- | 8 | --- |
8 | include/hw/nvram/fw_cfg.h | 6 +++--- | 9 | include/hw/nvram/fw_cfg.h | 6 +++--- |
9 | hw/nvram/fw_cfg.c | 4 ++-- | 10 | hw/nvram/fw_cfg.c | 4 ++-- |
10 | system/vl.c | 2 +- | 11 | system/vl.c | 2 +- |
11 | 3 files changed, 6 insertions(+), 6 deletions(-) | 12 | 3 files changed, 6 insertions(+), 6 deletions(-) |
... | ... | diff view generated by jsdifflib |
1 | Currently fw_cfg_add_file_from_generator() is restricted | 1 | Currently fw_cfg_add_file_from_generator() is restricted |
---|---|---|---|
2 | to command line created objects which reside in the | 2 | to command line created objects which reside in the |
3 | '/objects' QOM container. In order to extend to other | 3 | '/objects' QOM container. In order to extend to other |
4 | types of containers, pass the QOM parent by argument. | 4 | types of containers, pass the QOM parent by argument. |
5 | 5 | ||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
7 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | ||
7 | --- | 8 | --- |
8 | include/hw/nvram/fw_cfg.h | 10 ++++++---- | 9 | include/hw/nvram/fw_cfg.h | 10 ++++++---- |
9 | hw/nvram/fw_cfg.c | 11 ++++++----- | 10 | hw/nvram/fw_cfg.c | 11 ++++++----- |
10 | system/vl.c | 3 ++- | 11 | system/vl.c | 3 ++- |
11 | 3 files changed, 14 insertions(+), 10 deletions(-) | 12 | 3 files changed, 14 insertions(+), 10 deletions(-) |
... | ... | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Allow the FW_CFG_DATA_GENERATOR interface get_data() handler to | ||
2 | return NULL when there is nothing to generate. In that case | ||
3 | fw_cfg_add_file_from_generator() will not add any item and | ||
4 | return %true. | ||
1 | 5 | ||
6 | Reported-by: Daniel P. Berrangé <berrange@redhat.com> | ||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | --- | ||
9 | include/hw/nvram/fw_cfg.h | 13 ++++++++----- | ||
10 | hw/nvram/fw_cfg.c | 10 ++++++---- | ||
11 | 2 files changed, 14 insertions(+), 9 deletions(-) | ||
12 | |||
13 | diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/include/hw/nvram/fw_cfg.h | ||
16 | +++ b/include/hw/nvram/fw_cfg.h | ||
17 | @@ -XXX,XX +XXX,XX @@ struct FWCfgDataGeneratorClass { | ||
18 | * @obj: the object implementing this interface | ||
19 | * @errp: pointer to a NULL-initialized error object | ||
20 | * | ||
21 | - * Returns: reference to a byte array containing the data on success, | ||
22 | - * or NULL on error. | ||
23 | + * Returns: NULL on failure (errp set if not NULL). | ||
24 | + * A byte array containing the data (if any, | ||
25 | + * otherwise NULL) on success. | ||
26 | * | ||
27 | * The caller should release the reference when no longer | ||
28 | * required. | ||
29 | @@ -XXX,XX +XXX,XX @@ void *fw_cfg_modify_file(FWCfgState *s, const char *filename, void *data, | ||
30 | * @parent: the object in which to resolve the @part | ||
31 | * @errp: pointer to a NULL initialized error object | ||
32 | * | ||
33 | - * Add a new NAMED fw_cfg item with the content generated from the | ||
34 | - * @part object. The data generated by the @part object is copied | ||
35 | - * into the data structure of the fw_cfg device. | ||
36 | + * If the @part object generates content, add a new NAMED fw_cfg item with it. | ||
37 | + * The data generated by the @part object is copied into the data structure of | ||
38 | + * the fw_cfg device. | ||
39 | * The next available (unused) selector key starting at FW_CFG_FILE_FIRST | ||
40 | * will be used; also, a new entry will be added to the file directory | ||
41 | * structure residing at key value FW_CFG_FILE_DIR, containing the item name, | ||
42 | * data size, and assigned selector key value. | ||
43 | * | ||
44 | + * If the @part object does not generate content, no fw_cfg item is added. | ||
45 | + * | ||
46 | * Returns: %true on success, %false on error. | ||
47 | */ | ||
48 | bool fw_cfg_add_file_from_generator(FWCfgState *s, | ||
49 | diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/hw/nvram/fw_cfg.c | ||
52 | +++ b/hw/nvram/fw_cfg.c | ||
53 | @@ -XXX,XX +XXX,XX @@ bool fw_cfg_add_file_from_generator(FWCfgState *s, | ||
54 | Object *parent, const char *part, | ||
55 | const char *filename, Error **errp) | ||
56 | { | ||
57 | + ERRP_GUARD(); | ||
58 | FWCfgDataGeneratorClass *klass; | ||
59 | GByteArray *array; | ||
60 | Object *obj; | ||
61 | - gsize size; | ||
62 | |||
63 | obj = object_resolve_path_component(parent, part); | ||
64 | if (!obj) { | ||
65 | @@ -XXX,XX +XXX,XX @@ bool fw_cfg_add_file_from_generator(FWCfgState *s, | ||
66 | } | ||
67 | klass = FW_CFG_DATA_GENERATOR_GET_CLASS(obj); | ||
68 | array = klass->get_data(obj, errp); | ||
69 | - if (!array) { | ||
70 | + if (*errp) { | ||
71 | return false; | ||
72 | } | ||
73 | - size = array->len; | ||
74 | - fw_cfg_add_file(s, filename, g_byte_array_free(array, FALSE), size); | ||
75 | + if (array) { | ||
76 | + fw_cfg_add_file(s, filename, g_byte_array_free(array, FALSE), | ||
77 | + array->len); | ||
78 | + } | ||
79 | |||
80 | return true; | ||
81 | } | ||
82 | -- | ||
83 | 2.45.2 | ||
84 | |||
85 | diff view generated by jsdifflib |
1 | The FW_CFG_DATA_GENERATOR allows any object to produce | 1 | The FW_CFG_DATA_GENERATOR interface allows any object to |
---|---|---|---|
2 | blob of data consumable by the fw_cfg device. Implement | 2 | produce a blob of data consumable by the fw_cfg device. |
3 | that for PCI bus objects. | 3 | Implement that for PCI bus objects. |
4 | 4 | ||
5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
6 | --- | 6 | --- |
7 | hw/pci/pci.c | 37 +++++++++++++++++++++++++++++++++++++ | 7 | hw/pci/pci.c | 37 +++++++++++++++++++++++++++++++++++++ |
8 | 1 file changed, 37 insertions(+) | 8 | 1 file changed, 37 insertions(+) |
... | ... | diff view generated by jsdifflib |
1 | pci_bus_add_fw_cfg_extra_pci_roots() calls the fw_cfg | 1 | pci_bus_add_fw_cfg_extra_pci_roots() calls the fw_cfg |
---|---|---|---|
2 | API with PCI bus specific arguments. | 2 | API with PCI bus specific arguments. |
3 | 3 | ||
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
5 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | ||
5 | --- | 6 | --- |
6 | include/hw/pci/pci.h | 3 +++ | 7 | include/hw/pci/pci.h | 3 +++ |
7 | hw/pci/pci.c | 16 ++++++++++++++++ | 8 | hw/pci/pci.c | 16 ++++++++++++++++ |
8 | 2 files changed, 19 insertions(+) | 9 | 2 files changed, 19 insertions(+) |
9 | 10 | ||
... | ... | diff view generated by jsdifflib |
1 | We want to remove fw_cfg_add_extra_pci_roots() which introduced | 1 | We want to remove fw_cfg_add_extra_pci_roots() which introduced |
---|---|---|---|
2 | PCI bus knowledge within the generic hw/nvram/fw_cfg.c file. | 2 | PCI bus knowledge within the generic hw/nvram/fw_cfg.c file. |
3 | Replace the calls by the pci_bus_add_fw_cfg_extra_pci_roots() | 3 | Replace the calls by the pci_bus_add_fw_cfg_extra_pci_roots() |
4 | which is a 1:1 equivalent, but using correct API. | 4 | which is a 1:1 equivalent, but using correct API. |
5 | 5 | ||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
7 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | ||
7 | --- | 8 | --- |
8 | hw/arm/virt.c | 3 ++- | 9 | hw/arm/virt.c | 3 ++- |
9 | hw/hppa/machine.c | 2 +- | 10 | hw/hppa/machine.c | 2 +- |
10 | hw/i386/pc.c | 3 ++- | 11 | hw/i386/pc.c | 3 ++- |
11 | 3 files changed, 5 insertions(+), 3 deletions(-) | 12 | 3 files changed, 5 insertions(+), 3 deletions(-) |
... | ... | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
6 | 6 | ||
7 | This mostly reverts commit 0abd38885ac0fcdb08653922f339849cad387961 | 7 | This mostly reverts commit 0abd38885ac0fcdb08653922f339849cad387961 |
8 | ("fw_cfg: Refactor extra pci roots addition"). | 8 | ("fw_cfg: Refactor extra pci roots addition"). |
9 | 9 | ||
10 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 10 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
11 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | ||
11 | --- | 12 | --- |
12 | include/hw/nvram/fw_cfg.h | 9 --------- | 13 | include/hw/nvram/fw_cfg.h | 9 --------- |
13 | hw/nvram/fw_cfg.c | 23 ----------------------- | 14 | hw/nvram/fw_cfg.c | 23 ----------------------- |
14 | 2 files changed, 32 deletions(-) | 15 | 2 files changed, 32 deletions(-) |
15 | 16 | ||
... | ... | diff view generated by jsdifflib |