Skip to contentSkip to conversation

softmmu: Clean up arch_init.c

PATCH In review Peter Maydell 7 participants 25 messages Jul 30, 2021 – Aug 26, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover softmmu: Clean up arch_init.c

This patchset does some cleanups of arch_init.c. The bit I started out caring about was getting rid of the TARGET_* ifdef ladder (in patch 4 we make meson.build define QEMU_ARCH in config-target.h instead) -- this kind of ifdef ladder is nasty because it's always another place in the code that needs updating when we add or remove a target. I think this was one of the last remaining "every single arch touches this" ones. The rest of the patchset is stuff I noticed when I started looking at what else arch_init.c was doing.

The graphic_width/height/depth target-specific defaults that arch_init.c does also look like they could use cleanup. My guess is that we should instead have a per-machine default graphics width/height/depth. But that's a separate thing and more work than I felt like doing this morning :-)

-- PMM

Peter Maydell (8):
softmmu: Use accel_find("xen") instead of xen_available()
monitor: Use accel_find("kvm") instead of kvm_available() softmmu/arch_init.c: Trim down include list meson.build: Define QEMU_ARCH in config-target.h arch_init.h: Add QEMU_ARCH_HEXAGON
arch_init.h: Move QEMU_ARCH_VIRTIO_* to qdev-monitor.c arch_init.h: Don't include arch_init.h unnecessarily
stubs: Remove unused arch_type.c stub

 meson.build                |  2 ++
 include/sysemu/arch_init.h | 15 +--------
 blockdev.c                 |  1 -
 hw/i386/pc.c               |  1 -
 hw/i386/pc_piix.c          |  1 -
 hw/i386/pc_q35.c           |  1 -
 hw/mips/jazz.c             |  1 -
 hw/mips/malta.c            |  1 -
 hw/ppc/prep.c              |  1 -
 hw/riscv/sifive_e.c        |  1 -
 hw/riscv/sifive_u.c        |  1 -
 hw/riscv/spike.c           |  1 -
 hw/riscv/virt.c            |  1 -
 monitor/qmp-cmds.c         |  3 +-
 softmmu/arch_init.c        | 66 --------------------------------------
 softmmu/qdev-monitor.c     |  9 ++++++
 softmmu/vl.c               |  6 ++--
 stubs/arch_type.c          |  4 ---
 target/ppc/cpu_init.c      |  1 -
 target/s390x/cpu-sysemu.c  |  1 -
 stubs/meson.build          |  1 -
 21 files changed, 16 insertions(+), 103 deletions(-)
 delete mode 100644 stubs/arch_type.c
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/8 softmmu: Use accel_find("xen") instead of xen_available()

The xen_available() function is used only to produce an error for some Xen-specific command line options in QEMU binaries where Xen support was not compiled in: it just returns the value of the CONFIG_XEN define.

Now that accelerators are QOM classes, we can check for "does this binary have Xen compiled in" with accel_find("xen"), and drop the xen_available() function.

---
 include/sysemu/arch_init.h | 1 -
 softmmu/arch_init.c        | 9 ---------
 softmmu/vl.c               | 6 +++---
 3 files changed, 3 insertions(+), 13 deletions(-)
include/sysemu/arch_init.h +0 -1
index e723c467eb2..7acfc62418f 100644
@@ -30,7 +30,6 @@ enum {
 extern const uint32_t arch_type;
 
 int kvm_available(void);
-int xen_available(void);
 
 /* default virtio transport per architecture */
 #define QEMU_ARCH_VIRTIO_PCI (QEMU_ARCH_ALPHA | QEMU_ARCH_ARM | \
softmmu/arch_init.c +0 -9
index 6ff9f30badd..3f4d7c1b1cd 100644
@@ -96,12 +96,3 @@ int kvm_available(void)
     return 0;
 #endif
 }
-
-int xen_available(void)
-{
-#ifdef CONFIG_XEN
-    return 1;
-#else
-    return 0;
-#endif
-}
softmmu/vl.c +3 -3
index 4dee472c794..a32d15b6a1f 100644
@@ -3429,21 +3429,21 @@ void qemu_init(int argc, char **argv, char **envp)
                 has_defaults = 0;
                 break;
             case QEMU_OPTION_xen_domid:
-                if (!(xen_available())) {
+                if (!(accel_find("xen"))) {
                     error_report("Option not supported for this target");
                     exit(1);
                 }
                 xen_domid = atoi(optarg);
                 break;
             case QEMU_OPTION_xen_attach:
-                if (!(xen_available())) {
+                if (!(accel_find("xen"))) {
                     error_report("Option not supported for this target");
                     exit(1);
                 }
                 xen_mode = XEN_ATTACH;
                 break;
             case QEMU_OPTION_xen_domid_restrict:
-                if (!(xen_available())) {
+                if (!(accel_find("xen"))) {
                     error_report("Option not supported for this target");
                     exit(1);
                 }
Signature · 1 line
2.20.1
Reviewed-by on v1 1/8
#2 lore raw

Re: [PATCH for-6.2 1/8] softmmu: Use accel_find("xen") instead of xen_available()

Quoted 9 lines · Peter Maydell

The xen_available() function is used only to produce an error for some Xen-specific command line options in QEMU binaries where Xen support was not compiled in: it just returns the value of the CONFIG_XEN define.

Now that accelerators are QOM classes, we can check for "does this binary have Xen compiled in" with accel_find("xen"), and drop the xen_available() function.

Quoted 6 lines
---
  include/sysemu/arch_init.h | 1 -
  softmmu/arch_init.c        | 9 ---------
  softmmu/vl.c               | 6 +++---
  3 files changed, 3 insertions(+), 13 deletions(-)

r~

#3 lore raw

PATCH 2/8 monitor: Use accel_find("kvm") instead of kvm_available()

In reply to Peter Maydell

The kvm_available() function reports whether KVM support was compiled into the QEMU binary; it returns the value of the CONFIG_KVM define.

The only place in the codebase where we use this function is in qmp_query_kvm(). Now that accelerators are based on QOM classes we can instead use accel_find("kvm") and remove the kvm_available() function.

---
 include/sysemu/arch_init.h | 2 --
 monitor/qmp-cmds.c         | 2 +-
 softmmu/arch_init.c        | 9 ---------
 3 files changed, 1 insertion(+), 12 deletions(-)
include/sysemu/arch_init.h +0 -2
index 7acfc62418f..57caad1c675 100644
@@ -29,8 +29,6 @@ enum {
 
 extern const uint32_t arch_type;
 
-int kvm_available(void);
-
 /* default virtio transport per architecture */
 #define QEMU_ARCH_VIRTIO_PCI (QEMU_ARCH_ALPHA | QEMU_ARCH_ARM | \
                               QEMU_ARCH_HPPA | QEMU_ARCH_I386 | \
monitor/qmp-cmds.c +1 -1
index f7d64a64577..9ddb9352e65 100644
@@ -58,7 +58,7 @@ KvmInfo *qmp_query_kvm(Error **errp)
     KvmInfo *info = g_malloc0(sizeof(*info));
 
     info->enabled = kvm_enabled();
-    info->present = kvm_available();
+    info->present = accel_find("kvm");
 
     return info;
 }
softmmu/arch_init.c +0 -9
index 3f4d7c1b1cd..9011af74e4a 100644
@@ -87,12 +87,3 @@ int graphic_depth = 32;
 #endif
 
 const uint32_t arch_type = QEMU_ARCH;
-
-int kvm_available(void)
-{
-#ifdef CONFIG_KVM
-    return 1;
-#else
-    return 0;
-#endif
-}
Signature · 1 line
2.20.1
Reviewed-by on v1 2/8
#4 lore raw

Re: [PATCH for-6.2 2/8] monitor: Use accel_find("kvm") instead of kvm_available()

Quoted 9 lines · Peter Maydell

The kvm_available() function reports whether KVM support was compiled into the QEMU binary; it returns the value of the CONFIG_KVM define.

The only place in the codebase where we use this function is in qmp_query_kvm(). Now that accelerators are based on QOM classes we can instead use accel_find("kvm") and remove the kvm_available() function.

Quoted 6 lines
---
  include/sysemu/arch_init.h | 2 --
  monitor/qmp-cmds.c         | 2 +-
  softmmu/arch_init.c        | 9 ---------
  3 files changed, 1 insertion(+), 12 deletions(-)

r~

#5 lore raw

PATCH 3/8 softmmu/arch_init.c: Trim down include list

In reply to Peter Maydell

arch_init.c does very little but has a long list of #include lines. Remove all the unnecessary ones.

---
 softmmu/arch_init.c | 7 -------
 1 file changed, 7 deletions(-)
softmmu/arch_init.c +0 -7
index 9011af74e4a..91cbf883e28 100644
@@ -23,13 +23,6 @@
  */
 #include "qemu/osdep.h"
 #include "sysemu/arch_init.h"
-#include "hw/pci/pci.h"
-#include "hw/audio/soundhw.h"
-#include "qapi/error.h"
-#include "qemu/config-file.h"
-#include "qemu/error-report.h"
-#include "hw/acpi/acpi.h"
-#include "qemu/help_option.h"
 
 #ifdef TARGET_SPARC
 int graphic_width = 1024;
Signature · 1 line
2.20.1
#7 lore raw

PATCH 4/8 meson.build: Define QEMU_ARCH in config-target.h

In reply to Peter Maydell

Instead of using an ifdef ladder in arch_init.c (which we then have to manually update every time we add or remove a target architecture), have meson.build put "#define QEMU_ARCH QEMU_ARCH_FOO" in the config-target.h file.

---
 meson.build         |  2 ++
 softmmu/arch_init.c | 41 -----------------------------------------
 2 files changed, 2 insertions(+), 41 deletions(-)
meson.build +2 -0
index f2e148eaf98..861965c286b 100644
@@ -1625,6 +1625,8 @@ foreach target : target_dirs
       config_target_data.set(k, v)
     endif
   endforeach
+  config_target_data.set('QEMU_ARCH',
+                         'QEMU_ARCH_' + config_target['TARGET_BASE_ARCH'].to_upper())
   config_target_h += {target: configure_file(output: target + '-config-target.h',
                                                configuration: config_target_data)}
 
softmmu/arch_init.c +0 -41

45 lines not on this page · raw message

Signature · 1 line
2.20.1
Reviewed-by on v1 4/8
#8 lore raw

Re: [PATCH for-6.2 4/8] meson.build: Define QEMU_ARCH in config-target.h

Quoted 10 lines · Peter Maydell

Instead of using an ifdef ladder in arch_init.c (which we then have to manually update every time we add or remove a target architecture), have meson.build put "#define QEMU_ARCH QEMU_ARCH_FOO" in the config-target.h file.

---
 meson.build         |  2 ++
 softmmu/arch_init.c | 41 -----------------------------------------
 2 files changed, 2 insertions(+), 41 deletions(-)
Reviewed-by on v1 4/8
#9 lore raw

Re: [PATCH for-6.2 4/8] meson.build: Define QEMU_ARCH in config-target.h

In reply to Peter Maydell
Quoted 10 lines · Peter Maydell

Instead of using an ifdef ladder in arch_init.c (which we then have to manually update every time we add or remove a target architecture), have meson.build put "#define QEMU_ARCH QEMU_ARCH_FOO" in the config-target.h file.

---
  meson.build         |  2 ++
  softmmu/arch_init.c | 41 -----------------------------------------
  2 files changed, 2 insertions(+), 41 deletions(-)

r~

#10 lore raw

PATCH 5/8 arch_init.h: Add QEMU_ARCH_HEXAGON

In reply to Peter Maydell

When Hexagon was added we forgot to add it to the QEMU_ARCH_* enumeration. This doesn't cause a visible effect because at the moment Hexagon is linux-user only and the QEMU_ARCH_* constants are only used in softmmu, but we might as well add it in, since it's the only architecture currently missing from the list.

---
 include/sysemu/arch_init.h | 1 +
 1 file changed, 1 insertion(+)
include/sysemu/arch_init.h +1 -0
index 57caad1c675..60270c5ad15 100644
@@ -23,6 +23,7 @@ enum {
     QEMU_ARCH_RISCV = (1 << 19),
     QEMU_ARCH_RX = (1 << 20),
     QEMU_ARCH_AVR = (1 << 21),
+    QEMU_ARCH_HEXAGON = (1 << 22),
 
     QEMU_ARCH_NONE = (1 << 31),
 };
Signature · 1 line
2.20.1
Reviewed-by on v1 5/8
#11 lore raw

Re: [PATCH for-6.2 5/8] arch_init.h: Add QEMU_ARCH_HEXAGON

Quoted 10 lines · Peter Maydell

When Hexagon was added we forgot to add it to the QEMU_ARCH_* enumeration. This doesn't cause a visible effect because at the moment Hexagon is linux-user only and the QEMU_ARCH_* constants are only used in softmmu, but we might as well add it in, since it's the only architecture currently missing from the list.

---
 include/sysemu/arch_init.h | 1 +
 1 file changed, 1 insertion(+)
Reviewed-by on v1 5/8
#12 lore raw

Re: [PATCH for-6.2 5/8] arch_init.h: Add QEMU_ARCH_HEXAGON

In reply to Peter Maydell
Quoted 10 lines · Peter Maydell

When Hexagon was added we forgot to add it to the QEMU_ARCH_* enumeration. This doesn't cause a visible effect because at the moment Hexagon is linux-user only and the QEMU_ARCH_* constants are only used in softmmu, but we might as well add it in, since it's the only architecture currently missing from the list.

---
  include/sysemu/arch_init.h | 1 +
  1 file changed, 1 insertion(+)

r~

Reviewed-by on v1 5/8
#13 lore raw

RE: [PATCH for-6.2 5/8] arch_init.h: Add QEMU_ARCH_HEXAGON

In reply to Peter Maydell
Quoted 17 lines

-----Original Message-----
From: Qemu-devel <qemu-devel- [email protected]> On Behalf Of Peter Maydell
Sent: Friday, July 30, 2021 5:00 AM
To: [email protected]
Cc: Paolo Bonzini <[email protected]>; Markus Armbruster <[email protected]>; Eduardo Habkost <[email protected]>
Subject: [PATCH for-6.2 5/8] arch_init.h: Add QEMU_ARCH_HEXAGON

When Hexagon was added we forgot to add it to the QEMU_ARCH_* enumeration. This doesn't cause a visible effect because at the moment Hexagon is linux-user only and the QEMU_ARCH_* constants are only used in softmmu, but we might as well add it in, since it's the only architecture currently missing from the list.

Quoted 4 lines

+ QEMU_ARCH_HEXAGON = (1 << 22),

#14 lore raw

PATCH 6/8 arch_init.h: Move QEMU_ARCH_VIRTIO_* to qdev-monitor.c

In reply to Peter Maydell

The QEMU_ARCH_VIRTIO_* defines are used only in one file, qdev-monitor.c. Move them to that file.

---
 include/sysemu/arch_init.h | 9 ---------
 softmmu/qdev-monitor.c     | 9 +++++++++
 2 files changed, 9 insertions(+), 9 deletions(-)
include/sysemu/arch_init.h +0 -9
index 60270c5ad15..e7789399508 100644
@@ -30,13 +30,4 @@ enum {
 
 extern const uint32_t arch_type;
 
-/* default virtio transport per architecture */
-#define QEMU_ARCH_VIRTIO_PCI (QEMU_ARCH_ALPHA | QEMU_ARCH_ARM | \
-                              QEMU_ARCH_HPPA | QEMU_ARCH_I386 | \
-                              QEMU_ARCH_MIPS | QEMU_ARCH_PPC |  \
-                              QEMU_ARCH_RISCV | QEMU_ARCH_SH4 | \
-                              QEMU_ARCH_SPARC | QEMU_ARCH_XTENSA)
-#define QEMU_ARCH_VIRTIO_CCW (QEMU_ARCH_S390X)
-#define QEMU_ARCH_VIRTIO_MMIO (QEMU_ARCH_M68K)
-
 #endif
softmmu/qdev-monitor.c +9 -0
index 721dec2d820..a304754ab91 100644
@@ -52,6 +52,15 @@ typedef struct QDevAlias
     uint32_t arch_mask;
 } QDevAlias;
 
+/* default virtio transport per architecture */
+#define QEMU_ARCH_VIRTIO_PCI (QEMU_ARCH_ALPHA | QEMU_ARCH_ARM | \
+                              QEMU_ARCH_HPPA | QEMU_ARCH_I386 | \
+                              QEMU_ARCH_MIPS | QEMU_ARCH_PPC |  \
+                              QEMU_ARCH_RISCV | QEMU_ARCH_SH4 | \
+                              QEMU_ARCH_SPARC | QEMU_ARCH_XTENSA)
+#define QEMU_ARCH_VIRTIO_CCW (QEMU_ARCH_S390X)
+#define QEMU_ARCH_VIRTIO_MMIO (QEMU_ARCH_M68K)
+
 /* Please keep this table sorted by typename. */
 static const QDevAlias qdev_alias_table[] = {
     { "AC97", "ac97" }, /* -soundhw name */
Signature · 1 line
2.20.1
Reviewed-by on v1 6/8
#15 lore raw

Re: [PATCH for-6.2 6/8] arch_init.h: Move QEMU_ARCH_VIRTIO_* to qdev-monitor.c

Quoted 8 lines · Peter Maydell

The QEMU_ARCH_VIRTIO_* defines are used only in one file, qdev-monitor.c. Move them to that file.

---
  include/sysemu/arch_init.h | 9 ---------
  softmmu/qdev-monitor.c     | 9 +++++++++
  2 files changed, 9 insertions(+), 9 deletions(-)

r~

Reviewed-by on v1 6/8
#16 lore raw

Re: [PATCH for-6.2 6/8] arch_init.h: Move QEMU_ARCH_VIRTIO_* to qdev-monitor.c

In reply to Peter Maydell
Quoted 37 lines · Peter Maydell

The QEMU_ARCH_VIRTIO_* defines are used only in one file, qdev-monitor.c. Move them to that file.

---
 include/sysemu/arch_init.h | 9 ---------
 softmmu/qdev-monitor.c     | 9 +++++++++
 2 files changed, 9 insertions(+), 9 deletions(-)
include/sysemu/arch_init.h +0 -9
index 60270c5ad15..e7789399508 100644
@@ -30,13 +30,4 @@ enum {
 
 extern const uint32_t arch_type;
 
-/* default virtio transport per architecture */
-#define QEMU_ARCH_VIRTIO_PCI (QEMU_ARCH_ALPHA | QEMU_ARCH_ARM | \
-                              QEMU_ARCH_HPPA | QEMU_ARCH_I386 | \
-                              QEMU_ARCH_MIPS | QEMU_ARCH_PPC |  \
-                              QEMU_ARCH_RISCV | QEMU_ARCH_SH4 | \
-                              QEMU_ARCH_SPARC | QEMU_ARCH_XTENSA)
-#define QEMU_ARCH_VIRTIO_CCW (QEMU_ARCH_S390X)
-#define QEMU_ARCH_VIRTIO_MMIO (QEMU_ARCH_M68K)
-
 #endif
softmmu/qdev-monitor.c +2 -0
index 721dec2d820..a304754ab91 100644
@@ -52,6 +52,15 @@ typedef struct QDevAlias
     uint32_t arch_mask;
 } QDevAlias;
 
+/* default virtio transport per architecture */
+#define QEMU_ARCH_VIRTIO_PCI (QEMU_ARCH_ALPHA | QEMU_ARCH_ARM | \

softmmu/qdev-monitor.c typedef struct QDevAlias · line 66

Quoted 10 lines
softmmu/qdev-monitor.c +7 -0
+                              QEMU_ARCH_HPPA | QEMU_ARCH_I386 | \
+                              QEMU_ARCH_MIPS | QEMU_ARCH_PPC |  \
+                              QEMU_ARCH_RISCV | QEMU_ARCH_SH4 | \
+                              QEMU_ARCH_SPARC | QEMU_ARCH_XTENSA)
+#define QEMU_ARCH_VIRTIO_CCW (QEMU_ARCH_S390X)
+#define QEMU_ARCH_VIRTIO_MMIO (QEMU_ARCH_M68K)
+
 /* Please keep this table sorted by typename. */
 static const QDevAlias qdev_alias_table[] = {
     { "AC97", "ac97" }, /* -soundhw name */

qdev-monitor.c is perhaps less than ideal. It's better than arch_init.h, though.

#17 lore raw

PATCH 7/8 arch_init.h: Don't include arch_init.h unnecessarily

In reply to Peter Maydell

arch_init.h only defines the QEMU_ARCH_* enumeration and the arch_type global. Don't include it in files that don't use those.

---
 blockdev.c                | 1 -
 hw/i386/pc.c              | 1 -
 hw/i386/pc_piix.c         | 1 -
 hw/i386/pc_q35.c          | 1 -
 hw/mips/jazz.c            | 1 -
 hw/mips/malta.c           | 1 -
 hw/ppc/prep.c             | 1 -
 hw/riscv/sifive_e.c       | 1 -
 hw/riscv/sifive_u.c       | 1 -
 hw/riscv/spike.c          | 1 -
 hw/riscv/virt.c           | 1 -
 monitor/qmp-cmds.c        | 1 -
 target/ppc/cpu_init.c     | 1 -
 target/s390x/cpu-sysemu.c | 1 -
 14 files changed, 14 deletions(-)
blockdev.c +0 -1
index 3d8ac368a19..e79c5f3b5e8 100644
@@ -56,7 +56,6 @@
 #include "sysemu/iothread.h"
 #include "block/block_int.h"
 #include "block/trace.h"
-#include "sysemu/arch_init.h"
 #include "sysemu/runstate.h"
 #include "sysemu/replay.h"
 #include "qemu/cutils.h"
hw/i386/pc.c +0 -1
index c2b9d62a358..102b2239468 100644
@@ -65,7 +65,6 @@
 #include "hw/xen/start_info.h"
 #include "ui/qemu-spice.h"
 #include "exec/memory.h"
-#include "sysemu/arch_init.h"
 #include "qemu/bitmap.h"
 #include "qemu/config-file.h"
 #include "qemu/error-report.h"
hw/i386/pc_piix.c +0 -1
index 30b8bd6ea92..1bc30167acc 100644
@@ -43,7 +43,6 @@
 #include "sysemu/kvm.h"
 #include "hw/kvm/clock.h"
 #include "hw/sysbus.h"
-#include "sysemu/arch_init.h"
 #include "hw/i2c/smbus_eeprom.h"
 #include "hw/xen/xen-x86.h"
 #include "exec/memory.h"
hw/i386/pc_q35.c +0 -1
index 04b4a4788d7..eeb0b185b11 100644
@@ -31,7 +31,6 @@
 #include "qemu/osdep.h"
 #include "qemu/units.h"
 #include "hw/loader.h"
-#include "sysemu/arch_init.h"
 #include "hw/i2c/smbus_eeprom.h"
 #include "hw/rtc/mc146818rtc.h"
 #include "sysemu/kvm.h"
hw/mips/jazz.c +0 -1
index d6183e18821..f5a26e174d5 100644
@@ -35,7 +35,6 @@
 #include "hw/isa/isa.h"
 #include "hw/block/fdc.h"
 #include "sysemu/sysemu.h"
-#include "sysemu/arch_init.h"
 #include "hw/boards.h"
 #include "net/net.h"
 #include "hw/scsi/esp.h"
hw/mips/malta.c +0 -1
index 7dcf175d726..b770b8d3671 100644
@@ -38,7 +38,6 @@
 #include "hw/mips/mips.h"
 #include "hw/mips/cpudevs.h"
 #include "hw/pci/pci.h"
-#include "sysemu/arch_init.h"
 #include "qemu/log.h"
 #include "hw/mips/bios.h"
 #include "hw/ide.h"
hw/ppc/prep.c +0 -1
index acfc2a91d8e..25a2e86b421 100644
@@ -40,7 +40,6 @@
 #include "hw/rtc/mc146818rtc.h"
 #include "hw/isa/pc87312.h"
 #include "hw/qdev-properties.h"
-#include "sysemu/arch_init.h"
 #include "sysemu/kvm.h"
 #include "sysemu/reset.h"
 #include "trace.h"
hw/riscv/sifive_e.c +0 -1
index ddc658c8d68..5b7b245e1f3 100644
@@ -45,7 +45,6 @@
 #include "hw/intc/sifive_plic.h"
 #include "hw/misc/sifive_e_prci.h"
 #include "chardev/char.h"
-#include "sysemu/arch_init.h"
 #include "sysemu/sysemu.h"
 
 static const MemMapEntry sifive_e_memmap[] = {
hw/riscv/sifive_u.c +0 -1
index 87bbd10b211..6cc1a62b0f7 100644
@@ -55,7 +55,6 @@
 #include "hw/intc/sifive_plic.h"
 #include "chardev/char.h"
 #include "net/eth.h"
-#include "sysemu/arch_init.h"
 #include "sysemu/device_tree.h"
 #include "sysemu/runstate.h"
 #include "sysemu/sysemu.h"
hw/riscv/spike.c +0 -1
index fead77f0c48..aae36f2cb4d 100644
@@ -37,7 +37,6 @@
 #include "hw/char/riscv_htif.h"
 #include "hw/intc/sifive_clint.h"
 #include "chardev/char.h"
-#include "sysemu/arch_init.h"
 #include "sysemu/device_tree.h"
 #include "sysemu/sysemu.h"
 
hw/riscv/virt.c +0 -1
index 4a3cd2599a5..0e55411045a 100644
@@ -36,7 +36,6 @@
 #include "hw/intc/sifive_plic.h"
 #include "hw/misc/sifive_test.h"
 #include "chardev/char.h"
-#include "sysemu/arch_init.h"
 #include "sysemu/device_tree.h"
 #include "sysemu/sysemu.h"
 #include "hw/pci/pci.h"
monitor/qmp-cmds.c +0 -1
index 9ddb9352e65..5c0d5e116b9 100644
@@ -27,7 +27,6 @@
 #include "sysemu/kvm.h"
 #include "sysemu/runstate.h"
 #include "sysemu/runstate-action.h"
-#include "sysemu/arch_init.h"
 #include "sysemu/blockdev.h"
 #include "sysemu/block-backend.h"
 #include "qapi/error.h"
target/ppc/cpu_init.c +0 -1
index 505a0ed6ac0..319a272d4c9 100644
@@ -22,7 +22,6 @@
 #include "disas/dis-asm.h"
 #include "exec/gdbstub.h"
 #include "kvm_ppc.h"
-#include "sysemu/arch_init.h"
 #include "sysemu/cpus.h"
 #include "sysemu/hw_accel.h"
 #include "sysemu/tcg.h"
target/s390x/cpu-sysemu.c +0 -1
index df2c6bf6941..5471e01ee82 100644
@@ -34,7 +34,6 @@
 
 #include "hw/s390x/pv.h"
 #include "hw/boards.h"
-#include "sysemu/arch_init.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/tcg.h"
 #include "hw/core/sysemu-cpu-ops.h"
Signature · 1 line
2.20.1
Reviewed-by on v1 7/8
#18 lore raw

Re: [PATCH for-6.2 7/8] arch_init.h: Don't include arch_init.h unnecessarily

Quoted 4 lines · Peter Maydell

arch_init.h only defines the QEMU_ARCH_* enumeration and the arch_type global. Don't include it in files that don't use those.

Quoted 16 lines
---
 blockdev.c                | 1 -
 hw/i386/pc.c              | 1 -
 hw/i386/pc_piix.c         | 1 -
 hw/i386/pc_q35.c          | 1 -
 hw/mips/jazz.c            | 1 -
 hw/mips/malta.c           | 1 -
 hw/ppc/prep.c             | 1 -
 hw/riscv/sifive_e.c       | 1 -
 hw/riscv/sifive_u.c       | 1 -
 hw/riscv/spike.c          | 1 -
 hw/riscv/virt.c           | 1 -
 monitor/qmp-cmds.c        | 1 -
 target/ppc/cpu_init.c     | 1 -
 target/s390x/cpu-sysemu.c | 1 -
 14 files changed, 14 deletions(-)
Reviewed-by on v1 7/8
#20 lore raw

Re: [PATCH for-6.2 7/8] arch_init.h: Don't include arch_init.h unnecessarily

In reply to Peter Maydell
Quoted 5 lines · Peter Maydell

arch_init.h only defines the QEMU_ARCH_* enumeration and the arch_type global. Don't include it in files that don't use those.

Alistair

Quoted 189 lines
---
 blockdev.c                | 1 -
 hw/i386/pc.c              | 1 -
 hw/i386/pc_piix.c         | 1 -
 hw/i386/pc_q35.c          | 1 -
 hw/mips/jazz.c            | 1 -
 hw/mips/malta.c           | 1 -
 hw/ppc/prep.c             | 1 -
 hw/riscv/sifive_e.c       | 1 -
 hw/riscv/sifive_u.c       | 1 -
 hw/riscv/spike.c          | 1 -
 hw/riscv/virt.c           | 1 -
 monitor/qmp-cmds.c        | 1 -
 target/ppc/cpu_init.c     | 1 -
 target/s390x/cpu-sysemu.c | 1 -
 14 files changed, 14 deletions(-)
blockdev.c +0 -1
index 3d8ac368a19..e79c5f3b5e8 100644
@@ -56,7 +56,6 @@
 #include "sysemu/iothread.h"
 #include "block/block_int.h"
 #include "block/trace.h"
-#include "sysemu/arch_init.h"
 #include "sysemu/runstate.h"
 #include "sysemu/replay.h"
 #include "qemu/cutils.h"
hw/i386/pc.c +0 -1
index c2b9d62a358..102b2239468 100644
@@ -65,7 +65,6 @@
 #include "hw/xen/start_info.h"
 #include "ui/qemu-spice.h"
 #include "exec/memory.h"
-#include "sysemu/arch_init.h"
 #include "qemu/bitmap.h"
 #include "qemu/config-file.h"
 #include "qemu/error-report.h"
hw/i386/pc_piix.c +0 -1
index 30b8bd6ea92..1bc30167acc 100644
@@ -43,7 +43,6 @@
 #include "sysemu/kvm.h"
 #include "hw/kvm/clock.h"
 #include "hw/sysbus.h"
-#include "sysemu/arch_init.h"
 #include "hw/i2c/smbus_eeprom.h"
 #include "hw/xen/xen-x86.h"
 #include "exec/memory.h"
hw/i386/pc_q35.c +0 -1
index 04b4a4788d7..eeb0b185b11 100644
@@ -31,7 +31,6 @@
 #include "qemu/osdep.h"
 #include "qemu/units.h"
 #include "hw/loader.h"
-#include "sysemu/arch_init.h"
 #include "hw/i2c/smbus_eeprom.h"
 #include "hw/rtc/mc146818rtc.h"
 #include "sysemu/kvm.h"
hw/mips/jazz.c +0 -1
index d6183e18821..f5a26e174d5 100644
@@ -35,7 +35,6 @@
 #include "hw/isa/isa.h"
 #include "hw/block/fdc.h"
 #include "sysemu/sysemu.h"
-#include "sysemu/arch_init.h"
 #include "hw/boards.h"
 #include "net/net.h"
 #include "hw/scsi/esp.h"
hw/mips/malta.c +0 -1
index 7dcf175d726..b770b8d3671 100644
@@ -38,7 +38,6 @@
 #include "hw/mips/mips.h"
 #include "hw/mips/cpudevs.h"
 #include "hw/pci/pci.h"
-#include "sysemu/arch_init.h"
 #include "qemu/log.h"
 #include "hw/mips/bios.h"
 #include "hw/ide.h"
hw/ppc/prep.c +0 -1
index acfc2a91d8e..25a2e86b421 100644
@@ -40,7 +40,6 @@
 #include "hw/rtc/mc146818rtc.h"
 #include "hw/isa/pc87312.h"
 #include "hw/qdev-properties.h"
-#include "sysemu/arch_init.h"
 #include "sysemu/kvm.h"
 #include "sysemu/reset.h"
 #include "trace.h"
hw/riscv/sifive_e.c +0 -1
index ddc658c8d68..5b7b245e1f3 100644
@@ -45,7 +45,6 @@
 #include "hw/intc/sifive_plic.h"
 #include "hw/misc/sifive_e_prci.h"
 #include "chardev/char.h"
-#include "sysemu/arch_init.h"
 #include "sysemu/sysemu.h"
 
 static const MemMapEntry sifive_e_memmap[] = {
hw/riscv/sifive_u.c +0 -1
index 87bbd10b211..6cc1a62b0f7 100644
@@ -55,7 +55,6 @@
 #include "hw/intc/sifive_plic.h"
 #include "chardev/char.h"
 #include "net/eth.h"
-#include "sysemu/arch_init.h"
 #include "sysemu/device_tree.h"
 #include "sysemu/runstate.h"
 #include "sysemu/sysemu.h"
hw/riscv/spike.c +0 -1
index fead77f0c48..aae36f2cb4d 100644
@@ -37,7 +37,6 @@
 #include "hw/char/riscv_htif.h"
 #include "hw/intc/sifive_clint.h"
 #include "chardev/char.h"
-#include "sysemu/arch_init.h"
 #include "sysemu/device_tree.h"
 #include "sysemu/sysemu.h"
 
hw/riscv/virt.c +0 -1
index 4a3cd2599a5..0e55411045a 100644
@@ -36,7 +36,6 @@
 #include "hw/intc/sifive_plic.h"
 #include "hw/misc/sifive_test.h"
 #include "chardev/char.h"
-#include "sysemu/arch_init.h"
 #include "sysemu/device_tree.h"
 #include "sysemu/sysemu.h"
 #include "hw/pci/pci.h"
monitor/qmp-cmds.c +0 -1
index 9ddb9352e65..5c0d5e116b9 100644
@@ -27,7 +27,6 @@
 #include "sysemu/kvm.h"
 #include "sysemu/runstate.h"
 #include "sysemu/runstate-action.h"
-#include "sysemu/arch_init.h"
 #include "sysemu/blockdev.h"
 #include "sysemu/block-backend.h"
 #include "qapi/error.h"
target/ppc/cpu_init.c +0 -1
index 505a0ed6ac0..319a272d4c9 100644
@@ -22,7 +22,6 @@
 #include "disas/dis-asm.h"
 #include "exec/gdbstub.h"
 #include "kvm_ppc.h"
-#include "sysemu/arch_init.h"
 #include "sysemu/cpus.h"
 #include "sysemu/hw_accel.h"
 #include "sysemu/tcg.h"
target/s390x/cpu-sysemu.c +0 -2
index df2c6bf6941..5471e01ee82 100644
@@ -34,7 +34,6 @@
 
 #include "hw/s390x/pv.h"
 #include "hw/boards.h"
-#include "sysemu/arch_init.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/tcg.h"
 #include "hw/core/sysemu-cpu-ops.h"
--

2.20.1

#21 lore raw

PATCH 8/8 stubs: Remove unused arch_type.c stub

In reply to Peter Maydell

We added a stub for the arch_type global in commit 5964ed56d9a1 so that we could compile blockdev.c into the tools. However, in commit 9db1d3a2be9bf we removed the only use of arch_type from blockdev.c. The stub is therefore no longer needed, and we can delete it again, together with the QEMU_ARCH_NONE value that only the stub was using.

---
 include/sysemu/arch_init.h | 2 --
 stubs/arch_type.c          | 4 ----
 stubs/meson.build          | 1 -
 3 files changed, 7 deletions(-)
 delete mode 100644 stubs/arch_type.c
include/sysemu/arch_init.h +0 -2
index e7789399508..70c579560ad 100644
@@ -24,8 +24,6 @@ enum {
     QEMU_ARCH_RX = (1 << 20),
     QEMU_ARCH_AVR = (1 << 21),
     QEMU_ARCH_HEXAGON = (1 << 22),
-
-    QEMU_ARCH_NONE = (1 << 31),
 };
 
 extern const uint32_t arch_type;
stubs/arch_type.c deleted +0 -4
deleted file mode 100644
index fc5423bc98a..00000000000
@@ -1,4 +0,0 @@
-#include "qemu/osdep.h"
-#include "sysemu/arch_init.h"
-
-const uint32_t arch_type = QEMU_ARCH_NONE;
stubs/meson.build +0 -1
index d3fa8646b38..717bfa9a999 100644
@@ -1,4 +1,3 @@
-stub_ss.add(files('arch_type.c'))
 stub_ss.add(files('bdrv-next-monitor-owned.c'))
 stub_ss.add(files('blk-commit-all.c'))
 stub_ss.add(files('blk-exp-close-all.c'))
Signature · 1 line
2.20.1
Reviewed-by on v1 8/8
#22 lore raw

Re: [PATCH for-6.2 8/8] stubs: Remove unused arch_type.c stub

Quoted 6 lines · Peter Maydell

We added a stub for the arch_type global in commit 5964ed56d9a1 so that we could compile blockdev.c into the tools. However, in commit 9db1d3a2be9bf we removed the only use of arch_type from blockdev.c. The stub is therefore no longer needed, and we can delete it again, together with the QEMU_ARCH_NONE value that only the stub was using.

Quoted 7 lines
---
 include/sysemu/arch_init.h | 2 --
 stubs/arch_type.c          | 4 ----
 stubs/meson.build          | 1 -
 3 files changed, 7 deletions(-)
 delete mode 100644 stubs/arch_type.c
Reviewed-by on v1 8/8
#23 lore raw

Re: [PATCH for-6.2 8/8] stubs: Remove unused arch_type.c stub

In reply to Peter Maydell
Quoted 8 lines · Peter Maydell

We added a stub for the arch_type global in commit 5964ed56d9a1 so that we could compile blockdev.c into the tools. However, in commit 9db1d3a2be9bf we removed the only use of arch_type from blockdev.c. The stub is therefore no longer needed, and we can delete it again, together with the QEMU_ARCH_NONE value that only the stub was using.

---

r~

#24 lore raw
In reply to Peter Maydell
Quoted 10 lines · Peter Maydell

This patchset does some cleanups of arch_init.c. The bit I started out caring about was getting rid of the TARGET_* ifdef ladder (in patch 4 we make meson.build define QEMU_ARCH in config-target.h instead) -- this kind of ifdef ladder is nasty because it's always another place in the code that needs updating when we add or remove a target. I think this was one of the last remaining "every single arch touches this" ones. The rest of the patchset is stuff I noticed when I started looking at what else arch_init.c was doing.

Quoted 5 lines

The graphic_width/height/depth target-specific defaults that arch_init.c does also look like they could use cleanup. My guess is that we should instead have a per-machine default graphics width/height/depth. But that's a separate thing and more work than I felt like doing this morning :-)

I'll take this via target-arm.next unless anybody objects.

thanks
-- PMM