diff mbox series

[v2,1/1] hw/nvram: Always register FW_CFG_DATA_GENERATOR_INTERFACE

Message ID 20201006111909.2302081-2-philmd@redhat.com
State Superseded
Headers show
Series qom: Fix missing interface in qemu-storage-daemon | expand

Commit Message

Philippe Mathieu-Daudé Oct. 6, 2020, 11:19 a.m. UTC
While the FW_CFG_DATA_GENERATOR_INTERFACE is only consumed
by a device only available using system-mode (fw_cfg), it is
implemented by a crypto component (tls-cipher-suites) which
is always available when crypto is used.

Commit 69699f3055 introduced the following error in the
qemu-storage-daemon binary:

  $ echo -e \
    '{"execute": "qmp_capabilities"}\r\n{"execute": "qom-list-types"}\r\n{"execute": "quit"}\r\n' \
    | storage-daemon/qemu-storage-daemon --chardev stdio,id=qmp0  --monitor qmp0
  {"QMP": {"version": {"qemu": {"micro": 50, "minor": 1, "major": 5}, "package": ""}, "capabilities": ["oob"]}}
  {"return": {}}
  missing interface 'fw_cfg-data-generator' for object 'tls-creds'
  Aborted (core dumped)

Since QOM dependencies are resolved at runtime, this issue
could not be triggered at linktime, and we don't have test
running the qemu-storage-daemon binary.

Fix by always registering the QOM interface.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Fixes: 69699f3055 ("crypto/tls-cipher-suites: Produce fw_cfg consumable blob")
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/nvram/fw_cfg-interface.c | 15 +++++++++++++++
 hw/nvram/fw_cfg.c           |  7 -------
 MAINTAINERS                 |  2 +-
 hw/nvram/meson.build        |  3 +++
 4 files changed, 19 insertions(+), 8 deletions(-)
 create mode 100644 hw/nvram/fw_cfg-interface.c

Comments

Paolo Bonzini Oct. 6, 2020, 11:31 a.m. UTC | #1
On 06/10/20 13:19, Philippe Mathieu-Daudé wrote:
> While the FW_CFG_DATA_GENERATOR_INTERFACE is only consumed

> by a device only available using system-mode (fw_cfg), it is

> implemented by a crypto component (tls-cipher-suites) which

> is always available when crypto is used.

> 

> Commit 69699f3055 introduced the following error in the

> qemu-storage-daemon binary:

> 

>   $ echo -e \

>     '{"execute": "qmp_capabilities"}\r\n{"execute": "qom-list-types"}\r\n{"execute": "quit"}\r\n' \

>     | storage-daemon/qemu-storage-daemon --chardev stdio,id=qmp0  --monitor qmp0

>   {"QMP": {"version": {"qemu": {"micro": 50, "minor": 1, "major": 5}, "package": ""}, "capabilities": ["oob"]}}

>   {"return": {}}

>   missing interface 'fw_cfg-data-generator' for object 'tls-creds'

>   Aborted (core dumped)

> 

> Since QOM dependencies are resolved at runtime, this issue

> could not be triggered at linktime, and we don't have test

> running the qemu-storage-daemon binary.

> 

> Fix by always registering the QOM interface.

> 

> Reported-by: Kevin Wolf <kwolf@redhat.com>

> Fixes: 69699f3055 ("crypto/tls-cipher-suites: Produce fw_cfg consumable blob")

> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> ---

>  hw/nvram/fw_cfg-interface.c | 15 +++++++++++++++

>  hw/nvram/fw_cfg.c           |  7 -------

>  MAINTAINERS                 |  2 +-

>  hw/nvram/meson.build        |  3 +++

>  4 files changed, 19 insertions(+), 8 deletions(-)

>  create mode 100644 hw/nvram/fw_cfg-interface.c

> 

> diff --git a/hw/nvram/fw_cfg-interface.c b/hw/nvram/fw_cfg-interface.c

> new file mode 100644

> index 0000000000..2b19502ffe

> --- /dev/null

> +++ b/hw/nvram/fw_cfg-interface.c

> @@ -0,0 +1,15 @@

> +#include "qemu/osdep.h"

> +#include "hw/nvram/fw_cfg.h"

> +

> +static const TypeInfo fw_cfg_data_generator_interface_info = {

> +    .parent = TYPE_INTERFACE,

> +    .name = TYPE_FW_CFG_DATA_GENERATOR_INTERFACE,

> +    .class_size = sizeof(FWCfgDataGeneratorClass),

> +};

> +

> +static void fw_cfg_register_types(void)

> +{

> +    type_register_static(&fw_cfg_data_generator_interface_info);

> +}

> +

> +type_init(fw_cfg_register_types)

> diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c

> index 0e95d057fd..08539a1aab 100644

> --- a/hw/nvram/fw_cfg.c

> +++ b/hw/nvram/fw_cfg.c

> @@ -1360,18 +1360,11 @@ static const TypeInfo fw_cfg_mem_info = {

>      .class_init    = fw_cfg_mem_class_init,

>  };

>  

> -static const TypeInfo fw_cfg_data_generator_interface_info = {

> -    .parent = TYPE_INTERFACE,

> -    .name = TYPE_FW_CFG_DATA_GENERATOR_INTERFACE,

> -    .class_size = sizeof(FWCfgDataGeneratorClass),

> -};

> -

>  static void fw_cfg_register_types(void)

>  {

>      type_register_static(&fw_cfg_info);

>      type_register_static(&fw_cfg_io_info);

>      type_register_static(&fw_cfg_mem_info);

> -    type_register_static(&fw_cfg_data_generator_interface_info);

>  }

>  

>  type_init(fw_cfg_register_types)

> diff --git a/MAINTAINERS b/MAINTAINERS

> index b76fb31861..a45d908ebd 100644

> --- a/MAINTAINERS

> +++ b/MAINTAINERS

> @@ -2054,7 +2054,7 @@ R: Laszlo Ersek <lersek@redhat.com>

>  R: Gerd Hoffmann <kraxel@redhat.com>

>  S: Supported

>  F: docs/specs/fw_cfg.txt

> -F: hw/nvram/fw_cfg.c

> +F: hw/nvram/fw_cfg*.c

>  F: stubs/fw_cfg.c

>  F: include/hw/nvram/fw_cfg.h

>  F: include/standard-headers/linux/qemu_fw_cfg.h

> diff --git a/hw/nvram/meson.build b/hw/nvram/meson.build

> index 1f2ed013b2..fd2951a860 100644

> --- a/hw/nvram/meson.build

> +++ b/hw/nvram/meson.build

> @@ -1,3 +1,6 @@

> +# QOM interfaces must be available anytime QOM is used.

> +qom_ss.add(files('fw_cfg-interface.c'))

> +

>  softmmu_ss.add(files('fw_cfg.c'))

>  softmmu_ss.add(when: 'CONFIG_CHRP_NVRAM', if_true: files('chrp_nvram.c'))

>  softmmu_ss.add(when: 'CONFIG_DS1225Y', if_true: files('ds1225y.c'))

> 


Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Kevin Wolf Oct. 6, 2020, 12:15 p.m. UTC | #2
Am 06.10.2020 um 13:19 hat Philippe Mathieu-Daudé geschrieben:
> While the FW_CFG_DATA_GENERATOR_INTERFACE is only consumed

> by a device only available using system-mode (fw_cfg), it is

> implemented by a crypto component (tls-cipher-suites) which

> is always available when crypto is used.

> 

> Commit 69699f3055 introduced the following error in the

> qemu-storage-daemon binary:

> 

>   $ echo -e \

>     '{"execute": "qmp_capabilities"}\r\n{"execute": "qom-list-types"}\r\n{"execute": "quit"}\r\n' \

>     | storage-daemon/qemu-storage-daemon --chardev stdio,id=qmp0  --monitor qmp0

>   {"QMP": {"version": {"qemu": {"micro": 50, "minor": 1, "major": 5}, "package": ""}, "capabilities": ["oob"]}}

>   {"return": {}}

>   missing interface 'fw_cfg-data-generator' for object 'tls-creds'

>   Aborted (core dumped)

> 

> Since QOM dependencies are resolved at runtime, this issue

> could not be triggered at linktime, and we don't have test

> running the qemu-storage-daemon binary.

> 

> Fix by always registering the QOM interface.

> 

> Reported-by: Kevin Wolf <kwolf@redhat.com>

> Fixes: 69699f3055 ("crypto/tls-cipher-suites: Produce fw_cfg consumable blob")

> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>


This fails to build for me:

../hw/nvram/meson.build:2:7: ERROR: Unknown method "add" in object.

Kevin
Paolo Bonzini Oct. 6, 2020, 12:20 p.m. UTC | #3
On 06/10/20 14:15, Kevin Wolf wrote:
> Am 06.10.2020 um 13:19 hat Philippe Mathieu-Daudé geschrieben:

>> While the FW_CFG_DATA_GENERATOR_INTERFACE is only consumed

>> by a device only available using system-mode (fw_cfg), it is

>> implemented by a crypto component (tls-cipher-suites) which

>> is always available when crypto is used.

>>

>> Commit 69699f3055 introduced the following error in the

>> qemu-storage-daemon binary:

>>

>>   $ echo -e \

>>     '{"execute": "qmp_capabilities"}\r\n{"execute": "qom-list-types"}\r\n{"execute": "quit"}\r\n' \

>>     | storage-daemon/qemu-storage-daemon --chardev stdio,id=qmp0  --monitor qmp0

>>   {"QMP": {"version": {"qemu": {"micro": 50, "minor": 1, "major": 5}, "package": ""}, "capabilities": ["oob"]}}

>>   {"return": {}}

>>   missing interface 'fw_cfg-data-generator' for object 'tls-creds'

>>   Aborted (core dumped)

>>

>> Since QOM dependencies are resolved at runtime, this issue

>> could not be triggered at linktime, and we don't have test

>> running the qemu-storage-daemon binary.

>>

>> Fix by always registering the QOM interface.

>>

>> Reported-by: Kevin Wolf <kwolf@redhat.com>

>> Fixes: 69699f3055 ("crypto/tls-cipher-suites: Produce fw_cfg consumable blob")

>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> 

> This fails to build for me:

> 

> ../hw/nvram/meson.build:2:7: ERROR: Unknown method "add" in object.


It's

  Based-on: <20201006111219.2300921-1-philmd@redhat.com>

(which won't be applied in exactly that shape, but more or less it will
be the same).

Paolo
Kevin Wolf Oct. 6, 2020, 12:38 p.m. UTC | #4
Am 06.10.2020 um 14:20 hat Paolo Bonzini geschrieben:
> On 06/10/20 14:15, Kevin Wolf wrote:
> > Am 06.10.2020 um 13:19 hat Philippe Mathieu-Daudé geschrieben:
> >> While the FW_CFG_DATA_GENERATOR_INTERFACE is only consumed
> >> by a device only available using system-mode (fw_cfg), it is
> >> implemented by a crypto component (tls-cipher-suites) which
> >> is always available when crypto is used.
> >>
> >> Commit 69699f3055 introduced the following error in the
> >> qemu-storage-daemon binary:
> >>
> >>   $ echo -e \
> >>     '{"execute": "qmp_capabilities"}\r\n{"execute": "qom-list-types"}\r\n{"execute": "quit"}\r\n' \
> >>     | storage-daemon/qemu-storage-daemon --chardev stdio,id=qmp0  --monitor qmp0
> >>   {"QMP": {"version": {"qemu": {"micro": 50, "minor": 1, "major": 5}, "package": ""}, "capabilities": ["oob"]}}
> >>   {"return": {}}
> >>   missing interface 'fw_cfg-data-generator' for object 'tls-creds'
> >>   Aborted (core dumped)
> >>
> >> Since QOM dependencies are resolved at runtime, this issue
> >> could not be triggered at linktime, and we don't have test
> >> running the qemu-storage-daemon binary.
> >>
> >> Fix by always registering the QOM interface.
> >>
> >> Reported-by: Kevin Wolf <kwolf@redhat.com>
> >> Fixes: 69699f3055 ("crypto/tls-cipher-suites: Produce fw_cfg consumable blob")
> >> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> > 
> > This fails to build for me:
> > 
> > ../hw/nvram/meson.build:2:7: ERROR: Unknown method "add" in object.
> 
> It's
> 
>   Based-on: <20201006111219.2300921-1-philmd@redhat.com>
> 
> (which won't be applied in exactly that shape, but more or less it will
> be the same).

Oh, I see. Then I guess it's not supposed to be merged through my tree.

Kevin
Paolo Bonzini Oct. 6, 2020, 12:51 p.m. UTC | #5
On 06/10/20 14:38, Kevin Wolf wrote:
> Am 06.10.2020 um 14:20 hat Paolo Bonzini geschrieben:

>> It's

>>

>>   Based-on: <20201006111219.2300921-1-philmd@redhat.com>

>>

>> (which won't be applied in exactly that shape, but more or less it will

>> be the same).

> 

> Oh, I see. Then I guess it's not supposed to be merged through my tree.


As you prefer; feel free to take that one when Phil sends the final version.

Paolo
Laszlo Ersek Oct. 6, 2020, 12:55 p.m. UTC | #6
On 10/06/20 13:19, Philippe Mathieu-Daudé wrote:
> While the FW_CFG_DATA_GENERATOR_INTERFACE is only consumed
> by a device only available using system-mode (fw_cfg), it is
> implemented by a crypto component (tls-cipher-suites) which
> is always available when crypto is used.
> 
> Commit 69699f3055 introduced the following error in the
> qemu-storage-daemon binary:
> 
>   $ echo -e \
>     '{"execute": "qmp_capabilities"}\r\n{"execute": "qom-list-types"}\r\n{"execute": "quit"}\r\n' \
>     | storage-daemon/qemu-storage-daemon --chardev stdio,id=qmp0  --monitor qmp0
>   {"QMP": {"version": {"qemu": {"micro": 50, "minor": 1, "major": 5}, "package": ""}, "capabilities": ["oob"]}}
>   {"return": {}}
>   missing interface 'fw_cfg-data-generator' for object 'tls-creds'
>   Aborted (core dumped)
> 
> Since QOM dependencies are resolved at runtime, this issue
> could not be triggered at linktime, and we don't have test
> running the qemu-storage-daemon binary.
> 
> Fix by always registering the QOM interface.
> 
> Reported-by: Kevin Wolf <kwolf@redhat.com>
> Fixes: 69699f3055 ("crypto/tls-cipher-suites: Produce fw_cfg consumable blob")
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  hw/nvram/fw_cfg-interface.c | 15 +++++++++++++++
>  hw/nvram/fw_cfg.c           |  7 -------
>  MAINTAINERS                 |  2 +-
>  hw/nvram/meson.build        |  3 +++
>  4 files changed, 19 insertions(+), 8 deletions(-)
>  create mode 100644 hw/nvram/fw_cfg-interface.c
> 
> diff --git a/hw/nvram/fw_cfg-interface.c b/hw/nvram/fw_cfg-interface.c
> new file mode 100644
> index 0000000000..2b19502ffe
> --- /dev/null
> +++ b/hw/nvram/fw_cfg-interface.c
> @@ -0,0 +1,15 @@
> +#include "qemu/osdep.h"
> +#include "hw/nvram/fw_cfg.h"
> +
> +static const TypeInfo fw_cfg_data_generator_interface_info = {
> +    .parent = TYPE_INTERFACE,
> +    .name = TYPE_FW_CFG_DATA_GENERATOR_INTERFACE,
> +    .class_size = sizeof(FWCfgDataGeneratorClass),
> +};
> +
> +static void fw_cfg_register_types(void)
> +{
> +    type_register_static(&fw_cfg_data_generator_interface_info);
> +}
> +
> +type_init(fw_cfg_register_types)

Can you rename *this* instance of "fw_cfg_register_types" to
"fw_cfg_register_interfaces"?

While the code is correct from the C lang perspective, duplicate
function names are not convenient when debugging with gdb, or when
jumping to tags in an editor.

With the rename:

Reviewed-by: Laszlo Ersek <lersek@redhat.com>

(If you strongly disagree, I'm OK to R-b v2 as well.)

Thanks,
Laszlo

> diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
> index 0e95d057fd..08539a1aab 100644
> --- a/hw/nvram/fw_cfg.c
> +++ b/hw/nvram/fw_cfg.c
> @@ -1360,18 +1360,11 @@ static const TypeInfo fw_cfg_mem_info = {
>      .class_init    = fw_cfg_mem_class_init,
>  };
>  
> -static const TypeInfo fw_cfg_data_generator_interface_info = {
> -    .parent = TYPE_INTERFACE,
> -    .name = TYPE_FW_CFG_DATA_GENERATOR_INTERFACE,
> -    .class_size = sizeof(FWCfgDataGeneratorClass),
> -};
> -
>  static void fw_cfg_register_types(void)
>  {
>      type_register_static(&fw_cfg_info);
>      type_register_static(&fw_cfg_io_info);
>      type_register_static(&fw_cfg_mem_info);
> -    type_register_static(&fw_cfg_data_generator_interface_info);
>  }
>  
>  type_init(fw_cfg_register_types)
> diff --git a/MAINTAINERS b/MAINTAINERS
> index b76fb31861..a45d908ebd 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -2054,7 +2054,7 @@ R: Laszlo Ersek <lersek@redhat.com>
>  R: Gerd Hoffmann <kraxel@redhat.com>
>  S: Supported
>  F: docs/specs/fw_cfg.txt
> -F: hw/nvram/fw_cfg.c
> +F: hw/nvram/fw_cfg*.c
>  F: stubs/fw_cfg.c
>  F: include/hw/nvram/fw_cfg.h
>  F: include/standard-headers/linux/qemu_fw_cfg.h
> diff --git a/hw/nvram/meson.build b/hw/nvram/meson.build
> index 1f2ed013b2..fd2951a860 100644
> --- a/hw/nvram/meson.build
> +++ b/hw/nvram/meson.build
> @@ -1,3 +1,6 @@
> +# QOM interfaces must be available anytime QOM is used.
> +qom_ss.add(files('fw_cfg-interface.c'))
> +
>  softmmu_ss.add(files('fw_cfg.c'))
>  softmmu_ss.add(when: 'CONFIG_CHRP_NVRAM', if_true: files('chrp_nvram.c'))
>  softmmu_ss.add(when: 'CONFIG_DS1225Y', if_true: files('ds1225y.c'))
>
Philippe Mathieu-Daudé Oct. 6, 2020, 1:03 p.m. UTC | #7
On 10/6/20 2:55 PM, Laszlo Ersek wrote:
> On 10/06/20 13:19, Philippe Mathieu-Daudé wrote:

>> While the FW_CFG_DATA_GENERATOR_INTERFACE is only consumed

>> by a device only available using system-mode (fw_cfg), it is

>> implemented by a crypto component (tls-cipher-suites) which

>> is always available when crypto is used.

>>

>> Commit 69699f3055 introduced the following error in the

>> qemu-storage-daemon binary:

>>

>>   $ echo -e \

>>     '{"execute": "qmp_capabilities"}\r\n{"execute": "qom-list-types"}\r\n{"execute": "quit"}\r\n' \

>>     | storage-daemon/qemu-storage-daemon --chardev stdio,id=qmp0  --monitor qmp0

>>   {"QMP": {"version": {"qemu": {"micro": 50, "minor": 1, "major": 5}, "package": ""}, "capabilities": ["oob"]}}

>>   {"return": {}}

>>   missing interface 'fw_cfg-data-generator' for object 'tls-creds'

>>   Aborted (core dumped)

>>

>> Since QOM dependencies are resolved at runtime, this issue

>> could not be triggered at linktime, and we don't have test

>> running the qemu-storage-daemon binary.

>>

>> Fix by always registering the QOM interface.

>>

>> Reported-by: Kevin Wolf <kwolf@redhat.com>

>> Fixes: 69699f3055 ("crypto/tls-cipher-suites: Produce fw_cfg consumable blob")

>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>

>> ---

>>  hw/nvram/fw_cfg-interface.c | 15 +++++++++++++++

>>  hw/nvram/fw_cfg.c           |  7 -------

>>  MAINTAINERS                 |  2 +-

>>  hw/nvram/meson.build        |  3 +++

>>  4 files changed, 19 insertions(+), 8 deletions(-)

>>  create mode 100644 hw/nvram/fw_cfg-interface.c

>>

>> diff --git a/hw/nvram/fw_cfg-interface.c b/hw/nvram/fw_cfg-interface.c

>> new file mode 100644

>> index 0000000000..2b19502ffe

>> --- /dev/null

>> +++ b/hw/nvram/fw_cfg-interface.c

>> @@ -0,0 +1,15 @@

>> +#include "qemu/osdep.h"

>> +#include "hw/nvram/fw_cfg.h"

>> +

>> +static const TypeInfo fw_cfg_data_generator_interface_info = {

>> +    .parent = TYPE_INTERFACE,

>> +    .name = TYPE_FW_CFG_DATA_GENERATOR_INTERFACE,

>> +    .class_size = sizeof(FWCfgDataGeneratorClass),

>> +};

>> +

>> +static void fw_cfg_register_types(void)

>> +{

>> +    type_register_static(&fw_cfg_data_generator_interface_info);

>> +}

>> +

>> +type_init(fw_cfg_register_types)

> 

> Can you rename *this* instance of "fw_cfg_register_types" to

> "fw_cfg_register_interfaces"?

> 

> While the code is correct from the C lang perspective, duplicate

> function names are not convenient when debugging with gdb, or when

> jumping to tags in an editor.


Sure.

> 

> With the rename:

> 

> Reviewed-by: Laszlo Ersek <lersek@redhat.com>


Thanks!

> 

> (If you strongly disagree, I'm OK to R-b v2 as well.)

> 

> Thanks,

> Laszlo

> 

>> diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c

>> index 0e95d057fd..08539a1aab 100644

>> --- a/hw/nvram/fw_cfg.c

>> +++ b/hw/nvram/fw_cfg.c

>> @@ -1360,18 +1360,11 @@ static const TypeInfo fw_cfg_mem_info = {

>>      .class_init    = fw_cfg_mem_class_init,

>>  };

>>  

>> -static const TypeInfo fw_cfg_data_generator_interface_info = {

>> -    .parent = TYPE_INTERFACE,

>> -    .name = TYPE_FW_CFG_DATA_GENERATOR_INTERFACE,

>> -    .class_size = sizeof(FWCfgDataGeneratorClass),

>> -};

>> -

>>  static void fw_cfg_register_types(void)

>>  {

>>      type_register_static(&fw_cfg_info);

>>      type_register_static(&fw_cfg_io_info);

>>      type_register_static(&fw_cfg_mem_info);

>> -    type_register_static(&fw_cfg_data_generator_interface_info);

>>  }

>>  

>>  type_init(fw_cfg_register_types)

>> diff --git a/MAINTAINERS b/MAINTAINERS

>> index b76fb31861..a45d908ebd 100644

>> --- a/MAINTAINERS

>> +++ b/MAINTAINERS

>> @@ -2054,7 +2054,7 @@ R: Laszlo Ersek <lersek@redhat.com>

>>  R: Gerd Hoffmann <kraxel@redhat.com>

>>  S: Supported

>>  F: docs/specs/fw_cfg.txt

>> -F: hw/nvram/fw_cfg.c

>> +F: hw/nvram/fw_cfg*.c

>>  F: stubs/fw_cfg.c

>>  F: include/hw/nvram/fw_cfg.h

>>  F: include/standard-headers/linux/qemu_fw_cfg.h

>> diff --git a/hw/nvram/meson.build b/hw/nvram/meson.build

>> index 1f2ed013b2..fd2951a860 100644

>> --- a/hw/nvram/meson.build

>> +++ b/hw/nvram/meson.build

>> @@ -1,3 +1,6 @@

>> +# QOM interfaces must be available anytime QOM is used.

>> +qom_ss.add(files('fw_cfg-interface.c'))

>> +

>>  softmmu_ss.add(files('fw_cfg.c'))

>>  softmmu_ss.add(when: 'CONFIG_CHRP_NVRAM', if_true: files('chrp_nvram.c'))

>>  softmmu_ss.add(when: 'CONFIG_DS1225Y', if_true: files('ds1225y.c'))

>>

>
diff mbox series

Patch

diff --git a/hw/nvram/fw_cfg-interface.c b/hw/nvram/fw_cfg-interface.c
new file mode 100644
index 0000000000..2b19502ffe
--- /dev/null
+++ b/hw/nvram/fw_cfg-interface.c
@@ -0,0 +1,15 @@ 
+#include "qemu/osdep.h"
+#include "hw/nvram/fw_cfg.h"
+
+static const TypeInfo fw_cfg_data_generator_interface_info = {
+    .parent = TYPE_INTERFACE,
+    .name = TYPE_FW_CFG_DATA_GENERATOR_INTERFACE,
+    .class_size = sizeof(FWCfgDataGeneratorClass),
+};
+
+static void fw_cfg_register_types(void)
+{
+    type_register_static(&fw_cfg_data_generator_interface_info);
+}
+
+type_init(fw_cfg_register_types)
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index 0e95d057fd..08539a1aab 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -1360,18 +1360,11 @@  static const TypeInfo fw_cfg_mem_info = {
     .class_init    = fw_cfg_mem_class_init,
 };
 
-static const TypeInfo fw_cfg_data_generator_interface_info = {
-    .parent = TYPE_INTERFACE,
-    .name = TYPE_FW_CFG_DATA_GENERATOR_INTERFACE,
-    .class_size = sizeof(FWCfgDataGeneratorClass),
-};
-
 static void fw_cfg_register_types(void)
 {
     type_register_static(&fw_cfg_info);
     type_register_static(&fw_cfg_io_info);
     type_register_static(&fw_cfg_mem_info);
-    type_register_static(&fw_cfg_data_generator_interface_info);
 }
 
 type_init(fw_cfg_register_types)
diff --git a/MAINTAINERS b/MAINTAINERS
index b76fb31861..a45d908ebd 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2054,7 +2054,7 @@  R: Laszlo Ersek <lersek@redhat.com>
 R: Gerd Hoffmann <kraxel@redhat.com>
 S: Supported
 F: docs/specs/fw_cfg.txt
-F: hw/nvram/fw_cfg.c
+F: hw/nvram/fw_cfg*.c
 F: stubs/fw_cfg.c
 F: include/hw/nvram/fw_cfg.h
 F: include/standard-headers/linux/qemu_fw_cfg.h
diff --git a/hw/nvram/meson.build b/hw/nvram/meson.build
index 1f2ed013b2..fd2951a860 100644
--- a/hw/nvram/meson.build
+++ b/hw/nvram/meson.build
@@ -1,3 +1,6 @@ 
+# QOM interfaces must be available anytime QOM is used.
+qom_ss.add(files('fw_cfg-interface.c'))
+
 softmmu_ss.add(files('fw_cfg.c'))
 softmmu_ss.add(when: 'CONFIG_CHRP_NVRAM', if_true: files('chrp_nvram.c'))
 softmmu_ss.add(when: 'CONFIG_DS1225Y', if_true: files('ds1225y.c'))