Remove arch_init SMBIOS and ACPI code
cover Remove arch_init SMBIOS and ACPI code
This creates stubs for SMBIOS and ACPI option parsing functions, so that we don't need arch-specific #ifdefs in arch_init just for calling the option parsers.
Eduardo Habkost (3):
stubs: Add smbios_entry_add() stub
stubs: acpi_table_add() stub
arch_init: Move acpi_table_add() call back to vl.c
include/sysemu/arch_init.h | 2 -- arch_init.c | 20 -------------------- stubs/acpi.c | 7 +++++++ stubs/smbios.c | 7 +++++++ vl.c | 9 +++++++-- stubs/Makefile.objs | 2 ++ 6 files changed, 23 insertions(+), 24 deletions(-) create mode 100644 stubs/acpi.c create mode 100644 stubs/smbios.c
Signature · 1 line
2.11.0.259.g40922b1
PATCH 1/3 stubs: Add smbios_entry_add() stub
Instead of using an #ifdef in arch_init.c, add a smbios_entry_add() stub. The stub will never be called because the -smbios option is defined as arch-specific in qemu-options.hx.
--- include/sysemu/arch_init.h | 1 - arch_init.c | 7 ------- stubs/smbios.c | 7 +++++++ vl.c | 2 +- stubs/Makefile.objs | 1 + 5 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 stubs/smbios.c
include/sysemu/arch_init.h +0 -1
@@ -29,7 +29,6 @@ extern const uint32_t arch_type;void select_soundhw (const char *optarg);void do_acpitable_option (const QemuOpts *opts); -void do_smbios_option (QemuOpts *opts);void audio_init (void );int kvm_available (void );int xen_available (void );
arch_init.c +0 -7
@@ -248,13 +248,6 @@ void do_acpitable_option(const QemuOpts *opts)#endif } -void do_smbios_option (QemuOpts *opts) -{ -#ifdef TARGET_I386 -smbios_entry_add (opts); -#endif -} -int kvm_available (void ) {#ifdef CONFIG_KVM
stubs/smbios.c new file +7 -0
@@ -0,0 +1,7 @@ +#include "qemu/osdep.h" +#include "hw/smbios/smbios.h" + +void smbios_entry_add (QemuOpts *opts) +{ +abort ();/* must never be called */ +}
vl.c +1 -1
@@ -3707,7 +3707,7 @@ int main(int argc, char **argv, char **envp)if (!opts) {exit (1 ); } -do_smbios_option (opts); +smbios_entry_add (opts);break ;case QEMU_OPTION_fwcfg: opts = qemu_opts_parse_noisily(qemu_find_opts("fw_cfg"),
stubs/Makefile.objs +1 -0
@@ -50,3 +50,4 @@ stub-obj-y += smbios_type_38.o stub-obj-y += ipmi.o stub-obj-y += pc_madt_cpu_entry.o stub-obj-y += migration-colo.o +stub-obj-y += smbios.o
Signature · 1 line
2.11.0.259.g40922b1
PATCH 2/3 stubs: acpi_table_add() stub
In reply to Eduardo HabkostCreate a stub to avoid an #ifdef in do_acpitable_option().
The stub should never be called because -acpitable is defined as arch-specific in qemu-options.hx.
--- arch_init.c | 2 -- stubs/acpi.c | 7 +++++++ stubs/Makefile.objs | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 stubs/acpi.c
arch_init.c +0 -2
@@ -237,7 +237,6 @@ void audio_init(void)void do_acpitable_option (const QemuOpts *opts) { -#ifdef TARGET_I386 Error *err =NULL ;acpi_table_add (opts, &err);
@@ -245,7 +244,6 @@ void do_acpitable_option(const QemuOpts *opts)error_reportf_err (err,"Wrong acpi table provided: " );exit (1 ); } -#endif }int kvm_available (void )
stubs/acpi.c new file +7 -0
@@ -0,0 +1,7 @@ +#include "qemu/osdep.h" +#include "hw/acpi/acpi.h" + +void acpi_table_add (const QemuOpts *opts,Error **errp) +{ +abort ();/* must never be called */ +}
stubs/Makefile.objs +1 -0
@@ -51,3 +51,4 @@ stub-obj-y += ipmi.o stub-obj-y += pc_madt_cpu_entry.o stub-obj-y += migration-colo.o stub-obj-y += smbios.o +stub-obj-y += acpi.o
Signature · 1 line
2.11.0.259.g40922b1
PATCH 3/3 arch_init: Move acpi_table_add() call back to vl.c
In reply to Eduardo HabkostNow that the code is not arch-dependent anymore, it can be moved back to vl.c.
--- include/sysemu/arch_init.h | 1 - arch_init.c | 11 ----------- vl.c | 7 ++++++- 3 files changed, 6 insertions(+), 13 deletions(-)
include/sysemu/arch_init.h +0 -1
@@ -28,7 +28,6 @@ enum {extern const uint32_t arch_type;void select_soundhw (const char *optarg); -void do_acpitable_option (const QemuOpts *opts);void audio_init (void );int kvm_available (void );int xen_available (void );
arch_init.c +0 -11
@@ -235,17 +235,6 @@ void audio_init(void) } } -void do_acpitable_option (const QemuOpts *opts) -{ -Error *err =NULL ; - -acpi_table_add (opts, &err); -if (err) { -error_reportf_err (err,"Wrong acpi table provided: " ); -exit (1 ); - } -} -int kvm_available (void ) {#ifdef CONFIG_KVM
vl.c +6 -1
@@ -65,6 +65,7 @@ int main(int argc, char **argv)#include "hw/bt.h" #include "sysemu/watchdog.h" #include "hw/smbios/smbios.h" +#include "hw/acpi/acpi.h" #include "hw/xen/xen.h" #include "hw/qdev.h" #include "hw/loader.h"
@@ -3699,7 +3700,11 @@ int main(int argc, char **argv, char **envp)if (!opts) {exit (1 ); } -do_acpitable_option (opts); +acpi_table_add (opts, &err); +if (err) { +error_reportf_err (err,"Wrong acpi table provided: " ); +exit (1 ); + }break ;case QEMU_OPTION_smbios: opts = qemu_opts_parse_noisily(qemu_find_opts("smbios"),
Signature · 1 line
2.11.0.259.g40922b1
Quoted 9 lines · Eduardo Habkost
This creates stubs for SMBIOS and ACPI option parsing functions, so that we don't need arch-specific #ifdefs in
arch_initjust for calling the option parsers.Eduardo Habkost (3):
stubs: Addsmbios_entry_add()stub
stubs:acpi_table_add()stub
arch_init: Moveacpi_table_add()call back tovl.c
Quoted 10 lines
include/sysemu/arch_init.h | 2 -- arch_init.c | 20 -------------------- stubs/acpi.c | 7 +++++++ stubs/smbios.c | 7 +++++++ vl.c | 9 +++++++-- stubs/Makefile.objs | 2 ++ 6 files changed, 23 insertions(+), 24 deletions(-) create mode 100644 stubs/acpi.c create mode 100644 stubs/smbios.c
Pretty much the same patches are in my pending pull request.
Paolo