Skip to contentSkip to conversation

Remove arch_init SMBIOS and ACPI code

PATCH In review Eduardo Habkost 2 participants 5 messages Jan 17, 2017 – Jan 18, 2017

lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index 1c9dad1b72..88dcf77a62 100644
@@ -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
index 5cc58b2c35..9647c8d337 100644
@@ -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
new file mode 100644
index 0000000000..e86e8f821c
@@ -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
index c643d3ff3a..38d812286a 100644
@@ -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
index 2b5bb74fce..83ddcad3c3 100644
@@ -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
#2 lore raw

PATCH 2/3 stubs: acpi_table_add() stub

In reply to Eduardo Habkost

Create 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
index 9647c8d337..0416d84211 100644
@@ -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
new file mode 100644
index 0000000000..65ef2d7086
@@ -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
index 83ddcad3c3..18236935d5 100644
@@ -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
#3 lore raw

PATCH 3/3 arch_init: Move acpi_table_add() call back to vl.c

In reply to Eduardo Habkost

Now 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
index 88dcf77a62..20b01e3004 100644
@@ -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
index 0416d84211..591afe6e2c 100644
@@ -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
index 38d812286a..9571b17eb6 100644
@@ -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
#4 lore raw
In reply to Eduardo Habkost
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_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

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