All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/6] arch_init.c cleanup
@ 2020-11-25 20:56 Eduardo Habkost
  2020-11-25 20:56   ` Eduardo Habkost
                   ` (6 more replies)
  0 siblings, 7 replies; 37+ messages in thread
From: Eduardo Habkost @ 2020-11-25 20:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth, Gerd Hoffmann

This series gets rid of most of the code in arch_init.c.  It
moves the QEMU_ARCH macro definitions to corresponding cpu.h
files, and gets rid of kvm_available() and xen_available().

After this series, only two things remain in arch_init.c:
- the arch_type variable, which seems to be a useful feature; and
- the initialization of graphic_width/graphic_height/graphic_depth,
  which is a hack we must eventually get rid of.

Gerd got rid of the graphic_* initialization hack once (in 2017),
but the series was never merged:
https://lore.kernel.org/qemu-devel/1487715299-21102-5-git-send-email-kraxel@redhat.com

Eduardo Habkost (6):
  arch_init: Move QEMU_ARCH definitions to cpu.h
  accel: accel_available() function
  kvm: Remove kvm_available() function
  xen: Delete xen_available() function
  Remove unnecessary usage of arch_init.h
  Rename arch_init.h to arch_type.h

 include/sysemu/accel.h                      |  1 +
 include/sysemu/{arch_init.h => arch_type.h} |  3 -
 target/alpha/cpu.h                          |  1 +
 target/arm/cpu.h                            |  1 +
 target/avr/cpu.h                            |  1 +
 target/cris/cpu.h                           |  1 +
 target/hppa/cpu.h                           |  1 +
 target/i386/cpu.h                           |  1 +
 target/lm32/cpu.h                           |  1 +
 target/m68k/cpu.h                           |  1 +
 target/microblaze/cpu.h                     |  1 +
 target/mips/cpu.h                           |  1 +
 target/moxie/cpu.h                          |  1 +
 target/nios2/cpu.h                          |  1 +
 target/openrisc/cpu.h                       |  1 +
 target/ppc/cpu.h                            |  1 +
 target/riscv/cpu.h                          |  1 +
 target/rx/cpu.h                             |  1 +
 target/s390x/cpu.h                          |  1 +
 target/sh4/cpu.h                            |  1 +
 target/sparc/cpu.h                          |  1 +
 target/tricore/cpu.h                        |  1 +
 target/unicore32/cpu.h                      |  1 +
 target/xtensa/cpu.h                         |  1 +
 accel/accel.c                               |  6 +-
 blockdev.c                                  |  2 +-
 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                      |  2 +-
 softmmu/vl.c                                |  8 +--
 stubs/arch_type.c                           |  2 +-
 target/i386/cpu.c                           |  1 -
 target/s390x/cpu.c                          |  1 -
 target/s390x/cpu_models.c                   |  1 -
 target/ppc/translate_init.c.inc             |  1 -
 45 files changed, 37 insertions(+), 92 deletions(-)
 rename include/sysemu/{arch_init.h => arch_type.h} (94%)

-- 
2.28.0




^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCH v2 1/6] arch_init: Move QEMU_ARCH definitions to cpu.h
  2020-11-25 20:56 [PATCH v2 0/6] arch_init.c cleanup Eduardo Habkost
@ 2020-11-25 20:56   ` Eduardo Habkost
  2020-11-25 20:56 ` [PATCH v2 2/6] accel: accel_available() function Eduardo Habkost
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 37+ messages in thread
From: Eduardo Habkost @ 2020-11-25 20:56 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Sarah Harris, Cornelia Huck, Sagar Karandikar,
	David Hildenbrand, Anthony Green, Mark Cave-Ayland,
	Aleksandar Rikalo, Philippe Mathieu-Daudé,
	Max Filippov, Alistair Francis, Gerd Hoffmann, Edgar E. Iglesias,
	Guan Xuetao, Marek Vasut, Yoshinori Sato, qemu-ppc,
	Artyom Tarasenko, Thomas Huth, Richard Henderson, qemu-s390x,
	qemu-arm, Michael Rolnik, Stafford Horne, David Gibson,
	qemu-riscv, Bastian Koppelmann, Chris Wulff, Laurent Vivier,
	Michael Walle, Palmer Dabbelt, Paolo Bonzini, Aurelien Jarno

Instead of a collection of #ifdefs on arch_init.c, define
QEMU_ARCH inside each cpu.h file.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Michael Rolnik <mrolnik@gmail.com>
Cc: Sarah Harris <S.E.Harris@kent.ac.uk>
Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Michael Walle <michael@walle.cc>
Cc: Laurent Vivier <laurent@vivier.eu>
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
Cc: Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>
Cc: Anthony Green <green@moxielogic.com>
Cc: Chris Wulff <crwulff@gmail.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Stafford Horne <shorne@gmail.com>
Cc: David Gibson <david@gibson.dropbear.id.au>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Alistair Francis <Alistair.Francis@wdc.com>
Cc: Sagar Karandikar <sagark@eecs.berkeley.edu>
Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: David Hildenbrand <david@redhat.com>
Cc: Cornelia Huck <cohuck@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>
Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Cc: Artyom Tarasenko <atar4qemu@gmail.com>
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: qemu-devel@nongnu.org
Cc: qemu-arm@nongnu.org
Cc: qemu-ppc@nongnu.org
Cc: qemu-riscv@nongnu.org
Cc: qemu-s390x@nongnu.org
---
 target/alpha/cpu.h      |  1 +
 target/arm/cpu.h        |  1 +
 target/avr/cpu.h        |  1 +
 target/cris/cpu.h       |  1 +
 target/hppa/cpu.h       |  1 +
 target/i386/cpu.h       |  1 +
 target/lm32/cpu.h       |  1 +
 target/m68k/cpu.h       |  1 +
 target/microblaze/cpu.h |  1 +
 target/mips/cpu.h       |  1 +
 target/moxie/cpu.h      |  1 +
 target/nios2/cpu.h      |  1 +
 target/openrisc/cpu.h   |  1 +
 target/ppc/cpu.h        |  1 +
 target/riscv/cpu.h      |  1 +
 target/rx/cpu.h         |  1 +
 target/s390x/cpu.h      |  1 +
 target/sh4/cpu.h        |  1 +
 target/sparc/cpu.h      |  1 +
 target/tricore/cpu.h    |  1 +
 target/unicore32/cpu.h  |  1 +
 target/xtensa/cpu.h     |  1 +
 softmmu/arch_init.c     | 46 -----------------------------------------
 23 files changed, 22 insertions(+), 46 deletions(-)

diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h
index 82df108967..313a4e456e 100644
--- a/target/alpha/cpu.h
+++ b/target/alpha/cpu.h
@@ -438,6 +438,7 @@ void alpha_translate_init(void);
 #define ALPHA_CPU_TYPE_SUFFIX "-" TYPE_ALPHA_CPU
 #define ALPHA_CPU_TYPE_NAME(model) model ALPHA_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_ALPHA_CPU
+#define QEMU_ARCH QEMU_ARCH_ALPHA
 
 void alpha_cpu_list(void);
 /* you can call this signal handler from your SIGBUS and SIGSEGV
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index e5514c8286..3f469a6485 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -2822,6 +2822,7 @@ bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync);
 #define ARM_CPU_TYPE_SUFFIX "-" TYPE_ARM_CPU
 #define ARM_CPU_TYPE_NAME(name) (name ARM_CPU_TYPE_SUFFIX)
 #define CPU_RESOLVING_TYPE TYPE_ARM_CPU
+#define QEMU_ARCH QEMU_ARCH_ARM
 
 #define cpu_signal_handler cpu_arm_signal_handler
 #define cpu_list arm_cpu_list
diff --git a/target/avr/cpu.h b/target/avr/cpu.h
index d148e8c75a..98f5df0ad7 100644
--- a/target/avr/cpu.h
+++ b/target/avr/cpu.h
@@ -31,6 +31,7 @@
 #define AVR_CPU_TYPE_SUFFIX "-" TYPE_AVR_CPU
 #define AVR_CPU_TYPE_NAME(name) (name AVR_CPU_TYPE_SUFFIX)
 #define CPU_RESOLVING_TYPE TYPE_AVR_CPU
+#define QEMU_ARCH QEMU_ARCH_AVR
 
 #define TCG_GUEST_DEFAULT_MO 0
 
diff --git a/target/cris/cpu.h b/target/cris/cpu.h
index d3b6492909..2482915699 100644
--- a/target/cris/cpu.h
+++ b/target/cris/cpu.h
@@ -249,6 +249,7 @@ enum {
 #define CRIS_CPU_TYPE_SUFFIX "-" TYPE_CRIS_CPU
 #define CRIS_CPU_TYPE_NAME(name) (name CRIS_CPU_TYPE_SUFFIX)
 #define CPU_RESOLVING_TYPE TYPE_CRIS_CPU
+#define QEMU_ARCH QEMU_ARCH_CRIS
 
 #define cpu_signal_handler cpu_cris_signal_handler
 
diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h
index 61178fa6a2..74d813289b 100644
--- a/target/hppa/cpu.h
+++ b/target/hppa/cpu.h
@@ -242,6 +242,7 @@ static inline int cpu_mmu_index(CPUHPPAState *env, bool ifetch)
 void hppa_translate_init(void);
 
 #define CPU_RESOLVING_TYPE TYPE_HPPA_CPU
+#define QEMU_ARCH QEMU_ARCH_HPPA
 
 static inline target_ulong hppa_form_gva_psw(target_ureg psw, uint64_t spc,
                                              target_ureg off)
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 88e8586f8f..03202f610c 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1971,6 +1971,7 @@ uint64_t cpu_get_tsc(CPUX86State *env);
 #define X86_CPU_TYPE_SUFFIX "-" TYPE_X86_CPU
 #define X86_CPU_TYPE_NAME(name) (name X86_CPU_TYPE_SUFFIX)
 #define CPU_RESOLVING_TYPE TYPE_X86_CPU
+#define QEMU_ARCH QEMU_ARCH_I386
 
 #ifdef TARGET_X86_64
 #define TARGET_DEFAULT_CPU_TYPE X86_CPU_TYPE_NAME("qemu64")
diff --git a/target/lm32/cpu.h b/target/lm32/cpu.h
index ea7c01ca8b..169c0ff19d 100644
--- a/target/lm32/cpu.h
+++ b/target/lm32/cpu.h
@@ -238,6 +238,7 @@ bool lm32_cpu_do_semihosting(CPUState *cs);
 #define LM32_CPU_TYPE_SUFFIX "-" TYPE_LM32_CPU
 #define LM32_CPU_TYPE_NAME(model) model LM32_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_LM32_CPU
+#define QEMU_ARCH QEMU_ARCH_LM32
 
 #define cpu_list lm32_cpu_list
 #define cpu_signal_handler cpu_lm32_signal_handler
diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h
index 521ac67cdd..87b5324b2c 100644
--- a/target/m68k/cpu.h
+++ b/target/m68k/cpu.h
@@ -514,6 +514,7 @@ enum {
 #define M68K_CPU_TYPE_SUFFIX "-" TYPE_M68K_CPU
 #define M68K_CPU_TYPE_NAME(model) model M68K_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_M68K_CPU
+#define QEMU_ARCH QEMU_ARCH_M68K
 
 #define cpu_signal_handler cpu_m68k_signal_handler
 #define cpu_list m68k_cpu_list
diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h
index c1c264199f..cbe60fbf58 100644
--- a/target/microblaze/cpu.h
+++ b/target/microblaze/cpu.h
@@ -378,6 +378,7 @@ int cpu_mb_signal_handler(int host_signum, void *pinfo,
                           void *puc);
 
 #define CPU_RESOLVING_TYPE TYPE_MICROBLAZE_CPU
+#define QEMU_ARCH QEMU_ARCH_MICROBLAZE
 
 #define cpu_signal_handler cpu_mb_signal_handler
 
diff --git a/target/mips/cpu.h b/target/mips/cpu.h
index 23f8c6f96c..8a6707aa81 100644
--- a/target/mips/cpu.h
+++ b/target/mips/cpu.h
@@ -1285,6 +1285,7 @@ int cpu_mips_signal_handler(int host_signum, void *pinfo, void *puc);
 #define MIPS_CPU_TYPE_SUFFIX "-" TYPE_MIPS_CPU
 #define MIPS_CPU_TYPE_NAME(model) model MIPS_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_MIPS_CPU
+#define QEMU_ARCH QEMU_ARCH_MIPS
 
 bool cpu_supports_cps_smp(const char *cpu_type);
 bool cpu_supports_isa(const char *cpu_type, uint64_t isa);
diff --git a/target/moxie/cpu.h b/target/moxie/cpu.h
index bd6ab66084..f638509381 100644
--- a/target/moxie/cpu.h
+++ b/target/moxie/cpu.h
@@ -95,6 +95,7 @@ int cpu_moxie_signal_handler(int host_signum, void *pinfo,
 #define MOXIE_CPU_TYPE_SUFFIX "-" TYPE_MOXIE_CPU
 #define MOXIE_CPU_TYPE_NAME(model) model MOXIE_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_MOXIE_CPU
+#define QEMU_ARCH QEMU_ARCH_MOXIE
 
 #define cpu_signal_handler cpu_moxie_signal_handler
 
diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h
index 86bbe1d867..b8fabdfb60 100644
--- a/target/nios2/cpu.h
+++ b/target/nios2/cpu.h
@@ -207,6 +207,7 @@ void nios2_check_interrupts(CPUNios2State *env);
 void do_nios2_semihosting(CPUNios2State *env);
 
 #define CPU_RESOLVING_TYPE TYPE_NIOS2_CPU
+#define QEMU_ARCH QEMU_ARCH_NIOS2
 
 #define cpu_gen_code cpu_nios2_gen_code
 #define cpu_signal_handler cpu_nios2_signal_handler
diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h
index bd42faf144..68ff1d06c9 100644
--- a/target/openrisc/cpu.h
+++ b/target/openrisc/cpu.h
@@ -348,6 +348,7 @@ void cpu_openrisc_count_stop(OpenRISCCPU *cpu);
 #define OPENRISC_CPU_TYPE_SUFFIX "-" TYPE_OPENRISC_CPU
 #define OPENRISC_CPU_TYPE_NAME(model) model OPENRISC_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_OPENRISC_CPU
+#define QEMU_ARCH QEMU_ARCH_OPENRISC
 
 typedef CPUOpenRISCState CPUArchState;
 typedef OpenRISCCPU ArchCPU;
diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
index 2609e4082e..fd870c4cf4 100644
--- a/target/ppc/cpu.h
+++ b/target/ppc/cpu.h
@@ -1334,6 +1334,7 @@ int ppc_dcr_write(ppc_dcr_t *dcr_env, int dcrn, uint32_t val);
 #define POWERPC_CPU_TYPE_SUFFIX "-" TYPE_POWERPC_CPU
 #define POWERPC_CPU_TYPE_NAME(model) model POWERPC_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_POWERPC_CPU
+#define QEMU_ARCH QEMU_ARCH_PPC
 
 #define cpu_signal_handler cpu_ppc_signal_handler
 #define cpu_list ppc_cpu_list
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
index c0a326c843..3f566b1c7f 100644
--- a/target/riscv/cpu.h
+++ b/target/riscv/cpu.h
@@ -33,6 +33,7 @@
 #define RISCV_CPU_TYPE_SUFFIX "-" TYPE_RISCV_CPU
 #define RISCV_CPU_TYPE_NAME(name) (name RISCV_CPU_TYPE_SUFFIX)
 #define CPU_RESOLVING_TYPE TYPE_RISCV_CPU
+#define QEMU_ARCH QEMU_ARCH_RISCV
 
 #define TYPE_RISCV_CPU_ANY              RISCV_CPU_TYPE_NAME("any")
 #define TYPE_RISCV_CPU_BASE32           RISCV_CPU_TYPE_NAME("rv32")
diff --git a/target/rx/cpu.h b/target/rx/cpu.h
index 0b4b998c7b..05c195962a 100644
--- a/target/rx/cpu.h
+++ b/target/rx/cpu.h
@@ -122,6 +122,7 @@ typedef RXCPU ArchCPU;
 #define RX_CPU_TYPE_SUFFIX "-" TYPE_RX_CPU
 #define RX_CPU_TYPE_NAME(model) model RX_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_RX_CPU
+#define QEMU_ARCH QEMU_ARCH_RX
 
 const char *rx_crname(uint8_t cr);
 void rx_cpu_do_interrupt(CPUState *cpu);
diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
index 60d434d5ed..d528d18b6d 100644
--- a/target/s390x/cpu.h
+++ b/target/s390x/cpu.h
@@ -797,6 +797,7 @@ void s390_set_qemu_cpu_model(uint16_t type, uint8_t gen, uint8_t ec_ga,
 #define S390_CPU_TYPE_SUFFIX "-" TYPE_S390_CPU
 #define S390_CPU_TYPE_NAME(name) (name S390_CPU_TYPE_SUFFIX)
 #define CPU_RESOLVING_TYPE TYPE_S390_CPU
+#define QEMU_ARCH QEMU_ARCH_S390X
 
 /* you can call this signal handler from your SIGBUS and SIGSEGV
    signal handlers to inform the virtual CPU of exceptions. non zero
diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h
index 714e3b5641..f0314774f8 100644
--- a/target/sh4/cpu.h
+++ b/target/sh4/cpu.h
@@ -249,6 +249,7 @@ void cpu_load_tlb(CPUSH4State * env);
 #define SUPERH_CPU_TYPE_SUFFIX "-" TYPE_SUPERH_CPU
 #define SUPERH_CPU_TYPE_NAME(model) model SUPERH_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_SUPERH_CPU
+#define QEMU_ARCH QEMU_ARCH_SH4
 
 #define cpu_signal_handler cpu_sh4_signal_handler
 #define cpu_list sh4_cpu_list
diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h
index b9369398f2..9d80f8b500 100644
--- a/target/sparc/cpu.h
+++ b/target/sparc/cpu.h
@@ -662,6 +662,7 @@ int cpu_sparc_signal_handler(int host_signum, void *pinfo, void *puc);
 #define SPARC_CPU_TYPE_SUFFIX "-" TYPE_SPARC_CPU
 #define SPARC_CPU_TYPE_NAME(model) model SPARC_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_SPARC_CPU
+#define QEMU_ARCH QEMU_ARCH_SPARC
 
 #define cpu_signal_handler cpu_sparc_signal_handler
 #define cpu_list sparc_cpu_list
diff --git a/target/tricore/cpu.h b/target/tricore/cpu.h
index b82349d1b1..28c86f77b0 100644
--- a/target/tricore/cpu.h
+++ b/target/tricore/cpu.h
@@ -402,6 +402,7 @@ static inline void cpu_get_tb_cpu_state(CPUTriCoreState *env, target_ulong *pc,
 #define TRICORE_CPU_TYPE_SUFFIX "-" TYPE_TRICORE_CPU
 #define TRICORE_CPU_TYPE_NAME(model) model TRICORE_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_TRICORE_CPU
+#define QEMU_ARCH QEMU_ARCH_TRICORE
 
 /* helpers.c */
 bool tricore_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
diff --git a/target/unicore32/cpu.h b/target/unicore32/cpu.h
index 7a32e086ed..6c0d88aa9b 100644
--- a/target/unicore32/cpu.h
+++ b/target/unicore32/cpu.h
@@ -147,6 +147,7 @@ typedef UniCore32CPU ArchCPU;
 #define UNICORE32_CPU_TYPE_SUFFIX "-" TYPE_UNICORE32_CPU
 #define UNICORE32_CPU_TYPE_NAME(model) model UNICORE32_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_UNICORE32_CPU
+#define QEMU_ARCH QEMU_ARCH_UNICORE32
 
 static inline void cpu_get_tb_cpu_state(CPUUniCore32State *env, target_ulong *pc,
                                         target_ulong *cs_base, uint32_t *flags)
diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h
index 3bd4f691c1..c7a503b01d 100644
--- a/target/xtensa/cpu.h
+++ b/target/xtensa/cpu.h
@@ -589,6 +589,7 @@ void xtensa_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
 #define XTENSA_CPU_TYPE_SUFFIX "-" TYPE_XTENSA_CPU
 #define XTENSA_CPU_TYPE_NAME(model) model XTENSA_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_XTENSA_CPU
+#define QEMU_ARCH QEMU_ARCH_XTENSA
 
 #ifdef TARGET_WORDS_BIGENDIAN
 #define XTENSA_DEFAULT_CPU_MODEL "fsf"
diff --git a/softmmu/arch_init.c b/softmmu/arch_init.c
index 7fd5c09b2b..7ef32a98b9 100644
--- a/softmmu/arch_init.c
+++ b/softmmu/arch_init.c
@@ -48,52 +48,6 @@ int graphic_depth = 32;
 #endif
 
 
-#if defined(TARGET_ALPHA)
-#define QEMU_ARCH QEMU_ARCH_ALPHA
-#elif defined(TARGET_ARM)
-#define QEMU_ARCH QEMU_ARCH_ARM
-#elif defined(TARGET_CRIS)
-#define QEMU_ARCH QEMU_ARCH_CRIS
-#elif defined(TARGET_HPPA)
-#define QEMU_ARCH QEMU_ARCH_HPPA
-#elif defined(TARGET_I386)
-#define QEMU_ARCH QEMU_ARCH_I386
-#elif defined(TARGET_LM32)
-#define QEMU_ARCH QEMU_ARCH_LM32
-#elif defined(TARGET_M68K)
-#define QEMU_ARCH QEMU_ARCH_M68K
-#elif defined(TARGET_MICROBLAZE)
-#define QEMU_ARCH QEMU_ARCH_MICROBLAZE
-#elif defined(TARGET_MIPS)
-#define QEMU_ARCH QEMU_ARCH_MIPS
-#elif defined(TARGET_MOXIE)
-#define QEMU_ARCH QEMU_ARCH_MOXIE
-#elif defined(TARGET_NIOS2)
-#define QEMU_ARCH QEMU_ARCH_NIOS2
-#elif defined(TARGET_OPENRISC)
-#define QEMU_ARCH QEMU_ARCH_OPENRISC
-#elif defined(TARGET_PPC)
-#define QEMU_ARCH QEMU_ARCH_PPC
-#elif defined(TARGET_RISCV)
-#define QEMU_ARCH QEMU_ARCH_RISCV
-#elif defined(TARGET_RX)
-#define QEMU_ARCH QEMU_ARCH_RX
-#elif defined(TARGET_S390X)
-#define QEMU_ARCH QEMU_ARCH_S390X
-#elif defined(TARGET_SH4)
-#define QEMU_ARCH QEMU_ARCH_SH4
-#elif defined(TARGET_SPARC)
-#define QEMU_ARCH QEMU_ARCH_SPARC
-#elif defined(TARGET_TRICORE)
-#define QEMU_ARCH QEMU_ARCH_TRICORE
-#elif defined(TARGET_UNICORE32)
-#define QEMU_ARCH QEMU_ARCH_UNICORE32
-#elif defined(TARGET_XTENSA)
-#define QEMU_ARCH QEMU_ARCH_XTENSA
-#elif defined(TARGET_AVR)
-#define QEMU_ARCH QEMU_ARCH_AVR
-#endif
-
 const uint32_t arch_type = QEMU_ARCH;
 
 int kvm_available(void)
-- 
2.28.0



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 1/6] arch_init: Move QEMU_ARCH definitions to cpu.h
@ 2020-11-25 20:56   ` Eduardo Habkost
  0 siblings, 0 replies; 37+ messages in thread
From: Eduardo Habkost @ 2020-11-25 20:56 UTC (permalink / raw)
  To: qemu-devel
  Cc: Gerd Hoffmann, Thomas Huth, Richard Henderson, Peter Maydell,
	Michael Rolnik, Sarah Harris, Edgar E. Iglesias, Paolo Bonzini,
	Michael Walle, Laurent Vivier, Philippe Mathieu-Daudé,
	Aurelien Jarno, Jiaxun Yang, Aleksandar Rikalo, Anthony Green,
	Chris Wulff, Marek Vasut, Stafford Horne, David Gibson,
	Palmer Dabbelt, Alistair Francis, Sagar Karandikar,
	Bastian Koppelmann, Yoshinori Sato, David Hildenbrand,
	Cornelia Huck, Mark Cave-Ayland, Artyom Tarasenko, Guan Xuetao,
	Max Filippov, qemu-arm, qemu-ppc, qemu-riscv, qemu-s390x

Instead of a collection of #ifdefs on arch_init.c, define
QEMU_ARCH inside each cpu.h file.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Michael Rolnik <mrolnik@gmail.com>
Cc: Sarah Harris <S.E.Harris@kent.ac.uk>
Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Michael Walle <michael@walle.cc>
Cc: Laurent Vivier <laurent@vivier.eu>
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
Cc: Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>
Cc: Anthony Green <green@moxielogic.com>
Cc: Chris Wulff <crwulff@gmail.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Stafford Horne <shorne@gmail.com>
Cc: David Gibson <david@gibson.dropbear.id.au>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Alistair Francis <Alistair.Francis@wdc.com>
Cc: Sagar Karandikar <sagark@eecs.berkeley.edu>
Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: David Hildenbrand <david@redhat.com>
Cc: Cornelia Huck <cohuck@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>
Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Cc: Artyom Tarasenko <atar4qemu@gmail.com>
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: qemu-devel@nongnu.org
Cc: qemu-arm@nongnu.org
Cc: qemu-ppc@nongnu.org
Cc: qemu-riscv@nongnu.org
Cc: qemu-s390x@nongnu.org
---
 target/alpha/cpu.h      |  1 +
 target/arm/cpu.h        |  1 +
 target/avr/cpu.h        |  1 +
 target/cris/cpu.h       |  1 +
 target/hppa/cpu.h       |  1 +
 target/i386/cpu.h       |  1 +
 target/lm32/cpu.h       |  1 +
 target/m68k/cpu.h       |  1 +
 target/microblaze/cpu.h |  1 +
 target/mips/cpu.h       |  1 +
 target/moxie/cpu.h      |  1 +
 target/nios2/cpu.h      |  1 +
 target/openrisc/cpu.h   |  1 +
 target/ppc/cpu.h        |  1 +
 target/riscv/cpu.h      |  1 +
 target/rx/cpu.h         |  1 +
 target/s390x/cpu.h      |  1 +
 target/sh4/cpu.h        |  1 +
 target/sparc/cpu.h      |  1 +
 target/tricore/cpu.h    |  1 +
 target/unicore32/cpu.h  |  1 +
 target/xtensa/cpu.h     |  1 +
 softmmu/arch_init.c     | 46 -----------------------------------------
 23 files changed, 22 insertions(+), 46 deletions(-)

diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h
index 82df108967..313a4e456e 100644
--- a/target/alpha/cpu.h
+++ b/target/alpha/cpu.h
@@ -438,6 +438,7 @@ void alpha_translate_init(void);
 #define ALPHA_CPU_TYPE_SUFFIX "-" TYPE_ALPHA_CPU
 #define ALPHA_CPU_TYPE_NAME(model) model ALPHA_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_ALPHA_CPU
+#define QEMU_ARCH QEMU_ARCH_ALPHA
 
 void alpha_cpu_list(void);
 /* you can call this signal handler from your SIGBUS and SIGSEGV
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index e5514c8286..3f469a6485 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -2822,6 +2822,7 @@ bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync);
 #define ARM_CPU_TYPE_SUFFIX "-" TYPE_ARM_CPU
 #define ARM_CPU_TYPE_NAME(name) (name ARM_CPU_TYPE_SUFFIX)
 #define CPU_RESOLVING_TYPE TYPE_ARM_CPU
+#define QEMU_ARCH QEMU_ARCH_ARM
 
 #define cpu_signal_handler cpu_arm_signal_handler
 #define cpu_list arm_cpu_list
diff --git a/target/avr/cpu.h b/target/avr/cpu.h
index d148e8c75a..98f5df0ad7 100644
--- a/target/avr/cpu.h
+++ b/target/avr/cpu.h
@@ -31,6 +31,7 @@
 #define AVR_CPU_TYPE_SUFFIX "-" TYPE_AVR_CPU
 #define AVR_CPU_TYPE_NAME(name) (name AVR_CPU_TYPE_SUFFIX)
 #define CPU_RESOLVING_TYPE TYPE_AVR_CPU
+#define QEMU_ARCH QEMU_ARCH_AVR
 
 #define TCG_GUEST_DEFAULT_MO 0
 
diff --git a/target/cris/cpu.h b/target/cris/cpu.h
index d3b6492909..2482915699 100644
--- a/target/cris/cpu.h
+++ b/target/cris/cpu.h
@@ -249,6 +249,7 @@ enum {
 #define CRIS_CPU_TYPE_SUFFIX "-" TYPE_CRIS_CPU
 #define CRIS_CPU_TYPE_NAME(name) (name CRIS_CPU_TYPE_SUFFIX)
 #define CPU_RESOLVING_TYPE TYPE_CRIS_CPU
+#define QEMU_ARCH QEMU_ARCH_CRIS
 
 #define cpu_signal_handler cpu_cris_signal_handler
 
diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h
index 61178fa6a2..74d813289b 100644
--- a/target/hppa/cpu.h
+++ b/target/hppa/cpu.h
@@ -242,6 +242,7 @@ static inline int cpu_mmu_index(CPUHPPAState *env, bool ifetch)
 void hppa_translate_init(void);
 
 #define CPU_RESOLVING_TYPE TYPE_HPPA_CPU
+#define QEMU_ARCH QEMU_ARCH_HPPA
 
 static inline target_ulong hppa_form_gva_psw(target_ureg psw, uint64_t spc,
                                              target_ureg off)
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 88e8586f8f..03202f610c 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1971,6 +1971,7 @@ uint64_t cpu_get_tsc(CPUX86State *env);
 #define X86_CPU_TYPE_SUFFIX "-" TYPE_X86_CPU
 #define X86_CPU_TYPE_NAME(name) (name X86_CPU_TYPE_SUFFIX)
 #define CPU_RESOLVING_TYPE TYPE_X86_CPU
+#define QEMU_ARCH QEMU_ARCH_I386
 
 #ifdef TARGET_X86_64
 #define TARGET_DEFAULT_CPU_TYPE X86_CPU_TYPE_NAME("qemu64")
diff --git a/target/lm32/cpu.h b/target/lm32/cpu.h
index ea7c01ca8b..169c0ff19d 100644
--- a/target/lm32/cpu.h
+++ b/target/lm32/cpu.h
@@ -238,6 +238,7 @@ bool lm32_cpu_do_semihosting(CPUState *cs);
 #define LM32_CPU_TYPE_SUFFIX "-" TYPE_LM32_CPU
 #define LM32_CPU_TYPE_NAME(model) model LM32_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_LM32_CPU
+#define QEMU_ARCH QEMU_ARCH_LM32
 
 #define cpu_list lm32_cpu_list
 #define cpu_signal_handler cpu_lm32_signal_handler
diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h
index 521ac67cdd..87b5324b2c 100644
--- a/target/m68k/cpu.h
+++ b/target/m68k/cpu.h
@@ -514,6 +514,7 @@ enum {
 #define M68K_CPU_TYPE_SUFFIX "-" TYPE_M68K_CPU
 #define M68K_CPU_TYPE_NAME(model) model M68K_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_M68K_CPU
+#define QEMU_ARCH QEMU_ARCH_M68K
 
 #define cpu_signal_handler cpu_m68k_signal_handler
 #define cpu_list m68k_cpu_list
diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h
index c1c264199f..cbe60fbf58 100644
--- a/target/microblaze/cpu.h
+++ b/target/microblaze/cpu.h
@@ -378,6 +378,7 @@ int cpu_mb_signal_handler(int host_signum, void *pinfo,
                           void *puc);
 
 #define CPU_RESOLVING_TYPE TYPE_MICROBLAZE_CPU
+#define QEMU_ARCH QEMU_ARCH_MICROBLAZE
 
 #define cpu_signal_handler cpu_mb_signal_handler
 
diff --git a/target/mips/cpu.h b/target/mips/cpu.h
index 23f8c6f96c..8a6707aa81 100644
--- a/target/mips/cpu.h
+++ b/target/mips/cpu.h
@@ -1285,6 +1285,7 @@ int cpu_mips_signal_handler(int host_signum, void *pinfo, void *puc);
 #define MIPS_CPU_TYPE_SUFFIX "-" TYPE_MIPS_CPU
 #define MIPS_CPU_TYPE_NAME(model) model MIPS_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_MIPS_CPU
+#define QEMU_ARCH QEMU_ARCH_MIPS
 
 bool cpu_supports_cps_smp(const char *cpu_type);
 bool cpu_supports_isa(const char *cpu_type, uint64_t isa);
diff --git a/target/moxie/cpu.h b/target/moxie/cpu.h
index bd6ab66084..f638509381 100644
--- a/target/moxie/cpu.h
+++ b/target/moxie/cpu.h
@@ -95,6 +95,7 @@ int cpu_moxie_signal_handler(int host_signum, void *pinfo,
 #define MOXIE_CPU_TYPE_SUFFIX "-" TYPE_MOXIE_CPU
 #define MOXIE_CPU_TYPE_NAME(model) model MOXIE_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_MOXIE_CPU
+#define QEMU_ARCH QEMU_ARCH_MOXIE
 
 #define cpu_signal_handler cpu_moxie_signal_handler
 
diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h
index 86bbe1d867..b8fabdfb60 100644
--- a/target/nios2/cpu.h
+++ b/target/nios2/cpu.h
@@ -207,6 +207,7 @@ void nios2_check_interrupts(CPUNios2State *env);
 void do_nios2_semihosting(CPUNios2State *env);
 
 #define CPU_RESOLVING_TYPE TYPE_NIOS2_CPU
+#define QEMU_ARCH QEMU_ARCH_NIOS2
 
 #define cpu_gen_code cpu_nios2_gen_code
 #define cpu_signal_handler cpu_nios2_signal_handler
diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h
index bd42faf144..68ff1d06c9 100644
--- a/target/openrisc/cpu.h
+++ b/target/openrisc/cpu.h
@@ -348,6 +348,7 @@ void cpu_openrisc_count_stop(OpenRISCCPU *cpu);
 #define OPENRISC_CPU_TYPE_SUFFIX "-" TYPE_OPENRISC_CPU
 #define OPENRISC_CPU_TYPE_NAME(model) model OPENRISC_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_OPENRISC_CPU
+#define QEMU_ARCH QEMU_ARCH_OPENRISC
 
 typedef CPUOpenRISCState CPUArchState;
 typedef OpenRISCCPU ArchCPU;
diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
index 2609e4082e..fd870c4cf4 100644
--- a/target/ppc/cpu.h
+++ b/target/ppc/cpu.h
@@ -1334,6 +1334,7 @@ int ppc_dcr_write(ppc_dcr_t *dcr_env, int dcrn, uint32_t val);
 #define POWERPC_CPU_TYPE_SUFFIX "-" TYPE_POWERPC_CPU
 #define POWERPC_CPU_TYPE_NAME(model) model POWERPC_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_POWERPC_CPU
+#define QEMU_ARCH QEMU_ARCH_PPC
 
 #define cpu_signal_handler cpu_ppc_signal_handler
 #define cpu_list ppc_cpu_list
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
index c0a326c843..3f566b1c7f 100644
--- a/target/riscv/cpu.h
+++ b/target/riscv/cpu.h
@@ -33,6 +33,7 @@
 #define RISCV_CPU_TYPE_SUFFIX "-" TYPE_RISCV_CPU
 #define RISCV_CPU_TYPE_NAME(name) (name RISCV_CPU_TYPE_SUFFIX)
 #define CPU_RESOLVING_TYPE TYPE_RISCV_CPU
+#define QEMU_ARCH QEMU_ARCH_RISCV
 
 #define TYPE_RISCV_CPU_ANY              RISCV_CPU_TYPE_NAME("any")
 #define TYPE_RISCV_CPU_BASE32           RISCV_CPU_TYPE_NAME("rv32")
diff --git a/target/rx/cpu.h b/target/rx/cpu.h
index 0b4b998c7b..05c195962a 100644
--- a/target/rx/cpu.h
+++ b/target/rx/cpu.h
@@ -122,6 +122,7 @@ typedef RXCPU ArchCPU;
 #define RX_CPU_TYPE_SUFFIX "-" TYPE_RX_CPU
 #define RX_CPU_TYPE_NAME(model) model RX_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_RX_CPU
+#define QEMU_ARCH QEMU_ARCH_RX
 
 const char *rx_crname(uint8_t cr);
 void rx_cpu_do_interrupt(CPUState *cpu);
diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
index 60d434d5ed..d528d18b6d 100644
--- a/target/s390x/cpu.h
+++ b/target/s390x/cpu.h
@@ -797,6 +797,7 @@ void s390_set_qemu_cpu_model(uint16_t type, uint8_t gen, uint8_t ec_ga,
 #define S390_CPU_TYPE_SUFFIX "-" TYPE_S390_CPU
 #define S390_CPU_TYPE_NAME(name) (name S390_CPU_TYPE_SUFFIX)
 #define CPU_RESOLVING_TYPE TYPE_S390_CPU
+#define QEMU_ARCH QEMU_ARCH_S390X
 
 /* you can call this signal handler from your SIGBUS and SIGSEGV
    signal handlers to inform the virtual CPU of exceptions. non zero
diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h
index 714e3b5641..f0314774f8 100644
--- a/target/sh4/cpu.h
+++ b/target/sh4/cpu.h
@@ -249,6 +249,7 @@ void cpu_load_tlb(CPUSH4State * env);
 #define SUPERH_CPU_TYPE_SUFFIX "-" TYPE_SUPERH_CPU
 #define SUPERH_CPU_TYPE_NAME(model) model SUPERH_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_SUPERH_CPU
+#define QEMU_ARCH QEMU_ARCH_SH4
 
 #define cpu_signal_handler cpu_sh4_signal_handler
 #define cpu_list sh4_cpu_list
diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h
index b9369398f2..9d80f8b500 100644
--- a/target/sparc/cpu.h
+++ b/target/sparc/cpu.h
@@ -662,6 +662,7 @@ int cpu_sparc_signal_handler(int host_signum, void *pinfo, void *puc);
 #define SPARC_CPU_TYPE_SUFFIX "-" TYPE_SPARC_CPU
 #define SPARC_CPU_TYPE_NAME(model) model SPARC_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_SPARC_CPU
+#define QEMU_ARCH QEMU_ARCH_SPARC
 
 #define cpu_signal_handler cpu_sparc_signal_handler
 #define cpu_list sparc_cpu_list
diff --git a/target/tricore/cpu.h b/target/tricore/cpu.h
index b82349d1b1..28c86f77b0 100644
--- a/target/tricore/cpu.h
+++ b/target/tricore/cpu.h
@@ -402,6 +402,7 @@ static inline void cpu_get_tb_cpu_state(CPUTriCoreState *env, target_ulong *pc,
 #define TRICORE_CPU_TYPE_SUFFIX "-" TYPE_TRICORE_CPU
 #define TRICORE_CPU_TYPE_NAME(model) model TRICORE_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_TRICORE_CPU
+#define QEMU_ARCH QEMU_ARCH_TRICORE
 
 /* helpers.c */
 bool tricore_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
diff --git a/target/unicore32/cpu.h b/target/unicore32/cpu.h
index 7a32e086ed..6c0d88aa9b 100644
--- a/target/unicore32/cpu.h
+++ b/target/unicore32/cpu.h
@@ -147,6 +147,7 @@ typedef UniCore32CPU ArchCPU;
 #define UNICORE32_CPU_TYPE_SUFFIX "-" TYPE_UNICORE32_CPU
 #define UNICORE32_CPU_TYPE_NAME(model) model UNICORE32_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_UNICORE32_CPU
+#define QEMU_ARCH QEMU_ARCH_UNICORE32
 
 static inline void cpu_get_tb_cpu_state(CPUUniCore32State *env, target_ulong *pc,
                                         target_ulong *cs_base, uint32_t *flags)
diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h
index 3bd4f691c1..c7a503b01d 100644
--- a/target/xtensa/cpu.h
+++ b/target/xtensa/cpu.h
@@ -589,6 +589,7 @@ void xtensa_cpu_do_unaligned_access(CPUState *cpu, vaddr addr,
 #define XTENSA_CPU_TYPE_SUFFIX "-" TYPE_XTENSA_CPU
 #define XTENSA_CPU_TYPE_NAME(model) model XTENSA_CPU_TYPE_SUFFIX
 #define CPU_RESOLVING_TYPE TYPE_XTENSA_CPU
+#define QEMU_ARCH QEMU_ARCH_XTENSA
 
 #ifdef TARGET_WORDS_BIGENDIAN
 #define XTENSA_DEFAULT_CPU_MODEL "fsf"
diff --git a/softmmu/arch_init.c b/softmmu/arch_init.c
index 7fd5c09b2b..7ef32a98b9 100644
--- a/softmmu/arch_init.c
+++ b/softmmu/arch_init.c
@@ -48,52 +48,6 @@ int graphic_depth = 32;
 #endif
 
 
-#if defined(TARGET_ALPHA)
-#define QEMU_ARCH QEMU_ARCH_ALPHA
-#elif defined(TARGET_ARM)
-#define QEMU_ARCH QEMU_ARCH_ARM
-#elif defined(TARGET_CRIS)
-#define QEMU_ARCH QEMU_ARCH_CRIS
-#elif defined(TARGET_HPPA)
-#define QEMU_ARCH QEMU_ARCH_HPPA
-#elif defined(TARGET_I386)
-#define QEMU_ARCH QEMU_ARCH_I386
-#elif defined(TARGET_LM32)
-#define QEMU_ARCH QEMU_ARCH_LM32
-#elif defined(TARGET_M68K)
-#define QEMU_ARCH QEMU_ARCH_M68K
-#elif defined(TARGET_MICROBLAZE)
-#define QEMU_ARCH QEMU_ARCH_MICROBLAZE
-#elif defined(TARGET_MIPS)
-#define QEMU_ARCH QEMU_ARCH_MIPS
-#elif defined(TARGET_MOXIE)
-#define QEMU_ARCH QEMU_ARCH_MOXIE
-#elif defined(TARGET_NIOS2)
-#define QEMU_ARCH QEMU_ARCH_NIOS2
-#elif defined(TARGET_OPENRISC)
-#define QEMU_ARCH QEMU_ARCH_OPENRISC
-#elif defined(TARGET_PPC)
-#define QEMU_ARCH QEMU_ARCH_PPC
-#elif defined(TARGET_RISCV)
-#define QEMU_ARCH QEMU_ARCH_RISCV
-#elif defined(TARGET_RX)
-#define QEMU_ARCH QEMU_ARCH_RX
-#elif defined(TARGET_S390X)
-#define QEMU_ARCH QEMU_ARCH_S390X
-#elif defined(TARGET_SH4)
-#define QEMU_ARCH QEMU_ARCH_SH4
-#elif defined(TARGET_SPARC)
-#define QEMU_ARCH QEMU_ARCH_SPARC
-#elif defined(TARGET_TRICORE)
-#define QEMU_ARCH QEMU_ARCH_TRICORE
-#elif defined(TARGET_UNICORE32)
-#define QEMU_ARCH QEMU_ARCH_UNICORE32
-#elif defined(TARGET_XTENSA)
-#define QEMU_ARCH QEMU_ARCH_XTENSA
-#elif defined(TARGET_AVR)
-#define QEMU_ARCH QEMU_ARCH_AVR
-#endif
-
 const uint32_t arch_type = QEMU_ARCH;
 
 int kvm_available(void)
-- 
2.28.0



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 2/6] accel: accel_available() function
  2020-11-25 20:56 [PATCH v2 0/6] arch_init.c cleanup Eduardo Habkost
  2020-11-25 20:56   ` Eduardo Habkost
@ 2020-11-25 20:56 ` Eduardo Habkost
  2020-11-26  9:14   ` Claudio Fontana
  2020-11-27 12:08   ` Cornelia Huck
  2020-11-25 20:56   ` Eduardo Habkost
                   ` (4 subsequent siblings)
  6 siblings, 2 replies; 37+ messages in thread
From: Eduardo Habkost @ 2020-11-25 20:56 UTC (permalink / raw)
  To: qemu-devel
  Cc: Thomas Huth, Richard Henderson, Roman Bolshakov, Gerd Hoffmann,
	Paolo Bonzini, Claudio Fontana

This function will be used to replace the xen_available() and
kvm_available() functions from arch_init.c.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Claudio Fontana <cfontana@suse.de>
Cc: Roman Bolshakov <r.bolshakov@yadro.com>
---
 include/sysemu/accel.h | 1 +
 accel/accel.c          | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h
index e08b8ab8fa..a4a00c75c8 100644
--- a/include/sysemu/accel.h
+++ b/include/sysemu/accel.h
@@ -67,6 +67,7 @@ typedef struct AccelClass {
     OBJECT_GET_CLASS(AccelClass, (obj), TYPE_ACCEL)
 
 AccelClass *accel_find(const char *opt_name);
+bool accel_available(const char *name);
 int accel_init_machine(AccelState *accel, MachineState *ms);
 
 /* Called just before os_setup_post (ie just before drop OS privs) */
diff --git a/accel/accel.c b/accel/accel.c
index cb555e3b06..4a64a2b38a 100644
--- a/accel/accel.c
+++ b/accel/accel.c
@@ -46,6 +46,11 @@ AccelClass *accel_find(const char *opt_name)
     return ac;
 }
 
+bool accel_available(const char *name)
+{
+    return accel_find(name) != NULL;
+}
+
 int accel_init_machine(AccelState *accel, MachineState *ms)
 {
     AccelClass *acc = ACCEL_GET_CLASS(accel);
-- 
2.28.0



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 3/6] kvm: Remove kvm_available() function
  2020-11-25 20:56 [PATCH v2 0/6] arch_init.c cleanup Eduardo Habkost
@ 2020-11-25 20:56   ` Eduardo Habkost
  2020-11-25 20:56 ` [PATCH v2 2/6] accel: accel_available() function Eduardo Habkost
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 37+ messages in thread
From: Eduardo Habkost @ 2020-11-25 20:56 UTC (permalink / raw)
  To: qemu-devel
  Cc: Gerd Hoffmann, Thomas Huth, Markus Armbruster, Paolo Bonzini,
	kvm, Richard Henderson, Claudio Fontana, Roman Bolshakov

The only caller can use accel_available("kvm") instead.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Claudio Fontana <cfontana@suse.de>
Cc: Roman Bolshakov <r.bolshakov@yadro.com>
---
 include/sysemu/arch_init.h | 1 -
 monitor/qmp-cmds.c         | 2 +-
 softmmu/arch_init.c        | 9 ---------
 3 files changed, 1 insertion(+), 11 deletions(-)

diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h
index 54f069d491..b32ce1afa9 100644
--- a/include/sysemu/arch_init.h
+++ b/include/sysemu/arch_init.h
@@ -32,7 +32,6 @@ enum {
 
 extern const uint32_t arch_type;
 
-int kvm_available(void);
 int xen_available(void);
 
 #endif
diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
index a08143b323..ac5b8a97d7 100644
--- a/monitor/qmp-cmds.c
+++ b/monitor/qmp-cmds.c
@@ -57,7 +57,7 @@ KvmInfo *qmp_query_kvm(Error **errp)
     KvmInfo *info = g_malloc0(sizeof(*info));
 
     info->enabled = kvm_enabled();
-    info->present = kvm_available();
+    info->present = accel_available("kvm");
 
     return info;
 }
diff --git a/softmmu/arch_init.c b/softmmu/arch_init.c
index 7ef32a98b9..79383c8db8 100644
--- a/softmmu/arch_init.c
+++ b/softmmu/arch_init.c
@@ -50,15 +50,6 @@ int graphic_depth = 32;
 
 const uint32_t arch_type = QEMU_ARCH;
 
-int kvm_available(void)
-{
-#ifdef CONFIG_KVM
-    return 1;
-#else
-    return 0;
-#endif
-}
-
 int xen_available(void)
 {
 #ifdef CONFIG_XEN
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 3/6] kvm: Remove kvm_available() function
@ 2020-11-25 20:56   ` Eduardo Habkost
  0 siblings, 0 replies; 37+ messages in thread
From: Eduardo Habkost @ 2020-11-25 20:56 UTC (permalink / raw)
  To: qemu-devel
  Cc: Thomas Huth, kvm, Richard Henderson, Markus Armbruster,
	Roman Bolshakov, Gerd Hoffmann, Paolo Bonzini, Claudio Fontana

The only caller can use accel_available("kvm") instead.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Claudio Fontana <cfontana@suse.de>
Cc: Roman Bolshakov <r.bolshakov@yadro.com>
---
 include/sysemu/arch_init.h | 1 -
 monitor/qmp-cmds.c         | 2 +-
 softmmu/arch_init.c        | 9 ---------
 3 files changed, 1 insertion(+), 11 deletions(-)

diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h
index 54f069d491..b32ce1afa9 100644
--- a/include/sysemu/arch_init.h
+++ b/include/sysemu/arch_init.h
@@ -32,7 +32,6 @@ enum {
 
 extern const uint32_t arch_type;
 
-int kvm_available(void);
 int xen_available(void);
 
 #endif
diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
index a08143b323..ac5b8a97d7 100644
--- a/monitor/qmp-cmds.c
+++ b/monitor/qmp-cmds.c
@@ -57,7 +57,7 @@ KvmInfo *qmp_query_kvm(Error **errp)
     KvmInfo *info = g_malloc0(sizeof(*info));
 
     info->enabled = kvm_enabled();
-    info->present = kvm_available();
+    info->present = accel_available("kvm");
 
     return info;
 }
diff --git a/softmmu/arch_init.c b/softmmu/arch_init.c
index 7ef32a98b9..79383c8db8 100644
--- a/softmmu/arch_init.c
+++ b/softmmu/arch_init.c
@@ -50,15 +50,6 @@ int graphic_depth = 32;
 
 const uint32_t arch_type = QEMU_ARCH;
 
-int kvm_available(void)
-{
-#ifdef CONFIG_KVM
-    return 1;
-#else
-    return 0;
-#endif
-}
-
 int xen_available(void)
 {
 #ifdef CONFIG_XEN
-- 
2.28.0



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 4/6] xen: Delete xen_available() function
  2020-11-25 20:56 [PATCH v2 0/6] arch_init.c cleanup Eduardo Habkost
@ 2020-11-25 20:56   ` Eduardo Habkost
  2020-11-25 20:56 ` [PATCH v2 2/6] accel: accel_available() function Eduardo Habkost
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 37+ messages in thread
From: Eduardo Habkost @ 2020-11-25 20:56 UTC (permalink / raw)
  To: qemu-devel
  Cc: Thomas Huth, Stefano Stabellini, Paul Durrant, Richard Henderson,
	Roman Bolshakov, Gerd Hoffmann, xen-devel, Anthony Perard,
	Paolo Bonzini, Claudio Fontana

The function can be replaced with accel_available("xen").

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Paul Durrant <paul@xen.org>
Cc: xen-devel@lists.xenproject.org
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Claudio Fontana <cfontana@suse.de>
Cc: Roman Bolshakov <r.bolshakov@yadro.com>
---
 include/sysemu/arch_init.h | 2 --
 softmmu/arch_init.c        | 9 ---------
 softmmu/vl.c               | 6 +++---
 3 files changed, 3 insertions(+), 14 deletions(-)

diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h
index b32ce1afa9..40ac8052b7 100644
--- a/include/sysemu/arch_init.h
+++ b/include/sysemu/arch_init.h
@@ -32,6 +32,4 @@ enum {
 
 extern const uint32_t arch_type;
 
-int xen_available(void);
-
 #endif
diff --git a/softmmu/arch_init.c b/softmmu/arch_init.c
index 79383c8db8..f4770931f5 100644
--- a/softmmu/arch_init.c
+++ b/softmmu/arch_init.c
@@ -49,12 +49,3 @@ int graphic_depth = 32;
 
 
 const uint32_t arch_type = QEMU_ARCH;
-
-int xen_available(void)
-{
-#ifdef CONFIG_XEN
-    return 1;
-#else
-    return 0;
-#endif
-}
diff --git a/softmmu/vl.c b/softmmu/vl.c
index e6e0ad5a92..74b6ebf1e4 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -3667,21 +3667,21 @@ void qemu_init(int argc, char **argv, char **envp)
                 has_defaults = 0;
                 break;
             case QEMU_OPTION_xen_domid:
-                if (!(xen_available())) {
+                if (!(accel_available("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_available("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_available("xen"))) {
                     error_report("Option not supported for this target");
                     exit(1);
                 }
-- 
2.28.0



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 4/6] xen: Delete xen_available() function
@ 2020-11-25 20:56   ` Eduardo Habkost
  0 siblings, 0 replies; 37+ messages in thread
From: Eduardo Habkost @ 2020-11-25 20:56 UTC (permalink / raw)
  To: qemu-devel
  Cc: Gerd Hoffmann, Thomas Huth, Paolo Bonzini, Stefano Stabellini,
	Anthony Perard, Paul Durrant, xen-devel, Richard Henderson,
	Claudio Fontana, Roman Bolshakov

The function can be replaced with accel_available("xen").

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Paul Durrant <paul@xen.org>
Cc: xen-devel@lists.xenproject.org
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Claudio Fontana <cfontana@suse.de>
Cc: Roman Bolshakov <r.bolshakov@yadro.com>
---
 include/sysemu/arch_init.h | 2 --
 softmmu/arch_init.c        | 9 ---------
 softmmu/vl.c               | 6 +++---
 3 files changed, 3 insertions(+), 14 deletions(-)

diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_init.h
index b32ce1afa9..40ac8052b7 100644
--- a/include/sysemu/arch_init.h
+++ b/include/sysemu/arch_init.h
@@ -32,6 +32,4 @@ enum {
 
 extern const uint32_t arch_type;
 
-int xen_available(void);
-
 #endif
diff --git a/softmmu/arch_init.c b/softmmu/arch_init.c
index 79383c8db8..f4770931f5 100644
--- a/softmmu/arch_init.c
+++ b/softmmu/arch_init.c
@@ -49,12 +49,3 @@ int graphic_depth = 32;
 
 
 const uint32_t arch_type = QEMU_ARCH;
-
-int xen_available(void)
-{
-#ifdef CONFIG_XEN
-    return 1;
-#else
-    return 0;
-#endif
-}
diff --git a/softmmu/vl.c b/softmmu/vl.c
index e6e0ad5a92..74b6ebf1e4 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -3667,21 +3667,21 @@ void qemu_init(int argc, char **argv, char **envp)
                 has_defaults = 0;
                 break;
             case QEMU_OPTION_xen_domid:
-                if (!(xen_available())) {
+                if (!(accel_available("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_available("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_available("xen"))) {
                     error_report("Option not supported for this target");
                     exit(1);
                 }
-- 
2.28.0



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 5/6] Remove unnecessary usage of arch_init.h
  2020-11-25 20:56 [PATCH v2 0/6] arch_init.c cleanup Eduardo Habkost
@ 2020-11-25 20:56   ` Eduardo Habkost
  2020-11-25 20:56 ` [PATCH v2 2/6] accel: accel_available() function Eduardo Habkost
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 37+ messages in thread
From: Eduardo Habkost @ 2020-11-25 20:56 UTC (permalink / raw)
  To: qemu-devel
  Cc: Sagar Karandikar, Michael S. Tsirkin, Aleksandar Rikalo,
	Alistair Francis, Gerd Hoffmann, David Hildenbrand,
	Markus Armbruster, Halil Pasic, Christian Borntraeger,
	Hervé Poussineau, Palmer Dabbelt, Thomas Huth,
	Richard Henderson, qemu-s390x, David Gibson, qemu-riscv,
	Bastian Koppelmann, Cornelia Huck, Philippe Mathieu-Daudé,
	qemu-ppc, Paolo Bonzini, Aurelien Jarno

The only declarations in arch_init.h are the `arch_type` variable
and the QEMU_ARCH_* constants.  Stop including arch_init.h from
code that don't use neither.

Patch generated automatically using the command:

 $ sed -i -e '/#include "sysemu.arch_init.h"/d' \
   $(comm -23 \
      <(git grep -l arch_init.h | sort) \
      <((git grep -l -w 'arch_type'; g grep -l QEMU_ARCH;) | sort -u))

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Cc: "Hervé Poussineau" <hpoussin@reactos.org>
Cc: Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
Cc: David Gibson <david@gibson.dropbear.id.au>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Alistair Francis <Alistair.Francis@wdc.com>
Cc: Sagar Karandikar <sagark@eecs.berkeley.edu>
Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Cc: Markus Armbruster <armbru@redhat.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Cornelia Huck <cohuck@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>
Cc: Halil Pasic <pasic@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: qemu-devel@nongnu.org
Cc: qemu-ppc@nongnu.org
Cc: qemu-riscv@nongnu.org
Cc: qemu-s390x@nongnu.org
---
 accel/accel.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/i386/cpu.c               | 1 -
 target/s390x/cpu.c              | 1 -
 target/s390x/cpu_models.c       | 1 -
 target/ppc/translate_init.c.inc | 1 -
 16 files changed, 16 deletions(-)

diff --git a/accel/accel.c b/accel/accel.c
index 4a64a2b38a..3e567a001f 100644
--- a/accel/accel.c
+++ b/accel/accel.c
@@ -26,7 +26,6 @@
 #include "qemu/osdep.h"
 #include "sysemu/accel.h"
 #include "hw/boards.h"
-#include "sysemu/arch_init.h"
 #include "sysemu/sysemu.h"
 #include "qom/object.h"
 
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 17b514d1da..48a5fb0798 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -67,7 +67,6 @@
 #include "ui/qemu-spice.h"
 #include "exec/memory.h"
 #include "exec/address-spaces.h"
-#include "sysemu/arch_init.h"
 #include "qemu/bitmap.h"
 #include "qemu/config-file.h"
 #include "qemu/error-report.h"
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 13d1628f13..95ee1f39d8 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -44,7 +44,6 @@
 #include "hw/kvm/clock.h"
 #include "sysemu/sysemu.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"
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index a3f4959c43..cf85b240bc 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -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"
diff --git a/hw/mips/jazz.c b/hw/mips/jazz.c
index 71448f72ac..6fee2a4ec0 100644
--- a/hw/mips/jazz.c
+++ b/hw/mips/jazz.c
@@ -34,7 +34,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"
diff --git a/hw/mips/malta.c b/hw/mips/malta.c
index 9d1a3b50b7..6b4387c179 100644
--- a/hw/mips/malta.c
+++ b/hw/mips/malta.c
@@ -38,7 +38,6 @@
 #include "hw/mips/cpudevs.h"
 #include "hw/pci/pci.h"
 #include "sysemu/sysemu.h"
-#include "sysemu/arch_init.h"
 #include "qemu/log.h"
 #include "hw/mips/bios.h"
 #include "hw/ide.h"
diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
index 4a0cb434a6..5c9ec45749 100644
--- a/hw/ppc/prep.c
+++ b/hw/ppc/prep.c
@@ -43,7 +43,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/qtest.h"
 #include "sysemu/reset.h"
diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c
index 59bac4cc9a..6185872127 100644
--- a/hw/riscv/sifive_e.c
+++ b/hw/riscv/sifive_e.c
@@ -46,7 +46,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"
 #include "exec/address-spaces.h"
 
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
index 2f19a9cda2..53b62284ab 100644
--- a/hw/riscv/sifive_u.c
+++ b/hw/riscv/sifive_u.c
@@ -53,7 +53,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"
diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c
index facac6e7d2..660fcfcfed 100644
--- a/hw/riscv/spike.c
+++ b/hw/riscv/spike.c
@@ -38,7 +38,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/qtest.h"
 #include "sysemu/sysemu.h"
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
index 25cea7aa67..cfce799ffe 100644
--- a/hw/riscv/virt.c
+++ b/hw/riscv/virt.c
@@ -37,7 +37,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"
diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
index ac5b8a97d7..64ed976fac 100644
--- a/monitor/qmp-cmds.c
+++ b/monitor/qmp-cmds.c
@@ -26,7 +26,6 @@
 #include "ui/vnc.h"
 #include "sysemu/kvm.h"
 #include "sysemu/runstate.h"
-#include "sysemu/arch_init.h"
 #include "sysemu/blockdev.h"
 #include "sysemu/block-backend.h"
 #include "qapi/error.h"
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 5a8c96072e..e5a42a8663 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -44,7 +44,6 @@
 #include "qapi/qmp/qerror.h"
 #include "qapi/visitor.h"
 #include "qom/qom-qobject.h"
-#include "sysemu/arch_init.h"
 #include "qapi/qapi-commands-machine-target.h"
 
 #include "standard-headers/asm-x86/kvm_para.h"
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
index 7b66718c44..c1e336c760 100644
--- a/target/s390x/cpu.c
+++ b/target/s390x/cpu.c
@@ -39,7 +39,6 @@
 #ifndef CONFIG_USER_ONLY
 #include "hw/s390x/pv.h"
 #include "hw/boards.h"
-#include "sysemu/arch_init.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/tcg.h"
 #endif
diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c
index b5abff8bef..04896560ad 100644
--- a/target/s390x/cpu_models.c
+++ b/target/s390x/cpu_models.c
@@ -25,7 +25,6 @@
 #include "qapi/qobject-input-visitor.h"
 #include "qapi/qmp/qdict.h"
 #ifndef CONFIG_USER_ONLY
-#include "sysemu/arch_init.h"
 #include "hw/pci/pci.h"
 #endif
 #include "qapi/qapi-commands-machine-target.h"
diff --git a/target/ppc/translate_init.c.inc b/target/ppc/translate_init.c.inc
index 78cc8f043b..df66852a74 100644
--- a/target/ppc/translate_init.c.inc
+++ b/target/ppc/translate_init.c.inc
@@ -21,7 +21,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"
-- 
2.28.0



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 5/6] Remove unnecessary usage of arch_init.h
@ 2020-11-25 20:56   ` Eduardo Habkost
  0 siblings, 0 replies; 37+ messages in thread
From: Eduardo Habkost @ 2020-11-25 20:56 UTC (permalink / raw)
  To: qemu-devel
  Cc: Gerd Hoffmann, Thomas Huth, Richard Henderson, Paolo Bonzini,
	Michael S. Tsirkin, Marcel Apfelbaum, Hervé Poussineau,
	Aleksandar Rikalo, Philippe Mathieu-Daudé,
	Aurelien Jarno, Jiaxun Yang, David Gibson, Palmer Dabbelt,
	Alistair Francis, Sagar Karandikar, Bastian Koppelmann,
	Markus Armbruster, David Hildenbrand, Cornelia Huck, Halil Pasic,
	Christian Borntraeger, qemu-ppc, qemu-riscv, qemu-s390x

The only declarations in arch_init.h are the `arch_type` variable
and the QEMU_ARCH_* constants.  Stop including arch_init.h from
code that don't use neither.

Patch generated automatically using the command:

 $ sed -i -e '/#include "sysemu.arch_init.h"/d' \
   $(comm -23 \
      <(git grep -l arch_init.h | sort) \
      <((git grep -l -w 'arch_type'; g grep -l QEMU_ARCH;) | sort -u))

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Cc: "Hervé Poussineau" <hpoussin@reactos.org>
Cc: Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>
Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
Cc: David Gibson <david@gibson.dropbear.id.au>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Alistair Francis <Alistair.Francis@wdc.com>
Cc: Sagar Karandikar <sagark@eecs.berkeley.edu>
Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Cc: Markus Armbruster <armbru@redhat.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Cornelia Huck <cohuck@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>
Cc: Halil Pasic <pasic@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: qemu-devel@nongnu.org
Cc: qemu-ppc@nongnu.org
Cc: qemu-riscv@nongnu.org
Cc: qemu-s390x@nongnu.org
---
 accel/accel.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/i386/cpu.c               | 1 -
 target/s390x/cpu.c              | 1 -
 target/s390x/cpu_models.c       | 1 -
 target/ppc/translate_init.c.inc | 1 -
 16 files changed, 16 deletions(-)

diff --git a/accel/accel.c b/accel/accel.c
index 4a64a2b38a..3e567a001f 100644
--- a/accel/accel.c
+++ b/accel/accel.c
@@ -26,7 +26,6 @@
 #include "qemu/osdep.h"
 #include "sysemu/accel.h"
 #include "hw/boards.h"
-#include "sysemu/arch_init.h"
 #include "sysemu/sysemu.h"
 #include "qom/object.h"
 
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 17b514d1da..48a5fb0798 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -67,7 +67,6 @@
 #include "ui/qemu-spice.h"
 #include "exec/memory.h"
 #include "exec/address-spaces.h"
-#include "sysemu/arch_init.h"
 #include "qemu/bitmap.h"
 #include "qemu/config-file.h"
 #include "qemu/error-report.h"
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 13d1628f13..95ee1f39d8 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -44,7 +44,6 @@
 #include "hw/kvm/clock.h"
 #include "sysemu/sysemu.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"
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index a3f4959c43..cf85b240bc 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -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"
diff --git a/hw/mips/jazz.c b/hw/mips/jazz.c
index 71448f72ac..6fee2a4ec0 100644
--- a/hw/mips/jazz.c
+++ b/hw/mips/jazz.c
@@ -34,7 +34,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"
diff --git a/hw/mips/malta.c b/hw/mips/malta.c
index 9d1a3b50b7..6b4387c179 100644
--- a/hw/mips/malta.c
+++ b/hw/mips/malta.c
@@ -38,7 +38,6 @@
 #include "hw/mips/cpudevs.h"
 #include "hw/pci/pci.h"
 #include "sysemu/sysemu.h"
-#include "sysemu/arch_init.h"
 #include "qemu/log.h"
 #include "hw/mips/bios.h"
 #include "hw/ide.h"
diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
index 4a0cb434a6..5c9ec45749 100644
--- a/hw/ppc/prep.c
+++ b/hw/ppc/prep.c
@@ -43,7 +43,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/qtest.h"
 #include "sysemu/reset.h"
diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c
index 59bac4cc9a..6185872127 100644
--- a/hw/riscv/sifive_e.c
+++ b/hw/riscv/sifive_e.c
@@ -46,7 +46,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"
 #include "exec/address-spaces.h"
 
diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
index 2f19a9cda2..53b62284ab 100644
--- a/hw/riscv/sifive_u.c
+++ b/hw/riscv/sifive_u.c
@@ -53,7 +53,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"
diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c
index facac6e7d2..660fcfcfed 100644
--- a/hw/riscv/spike.c
+++ b/hw/riscv/spike.c
@@ -38,7 +38,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/qtest.h"
 #include "sysemu/sysemu.h"
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
index 25cea7aa67..cfce799ffe 100644
--- a/hw/riscv/virt.c
+++ b/hw/riscv/virt.c
@@ -37,7 +37,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"
diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
index ac5b8a97d7..64ed976fac 100644
--- a/monitor/qmp-cmds.c
+++ b/monitor/qmp-cmds.c
@@ -26,7 +26,6 @@
 #include "ui/vnc.h"
 #include "sysemu/kvm.h"
 #include "sysemu/runstate.h"
-#include "sysemu/arch_init.h"
 #include "sysemu/blockdev.h"
 #include "sysemu/block-backend.h"
 #include "qapi/error.h"
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 5a8c96072e..e5a42a8663 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -44,7 +44,6 @@
 #include "qapi/qmp/qerror.h"
 #include "qapi/visitor.h"
 #include "qom/qom-qobject.h"
-#include "sysemu/arch_init.h"
 #include "qapi/qapi-commands-machine-target.h"
 
 #include "standard-headers/asm-x86/kvm_para.h"
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
index 7b66718c44..c1e336c760 100644
--- a/target/s390x/cpu.c
+++ b/target/s390x/cpu.c
@@ -39,7 +39,6 @@
 #ifndef CONFIG_USER_ONLY
 #include "hw/s390x/pv.h"
 #include "hw/boards.h"
-#include "sysemu/arch_init.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/tcg.h"
 #endif
diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c
index b5abff8bef..04896560ad 100644
--- a/target/s390x/cpu_models.c
+++ b/target/s390x/cpu_models.c
@@ -25,7 +25,6 @@
 #include "qapi/qobject-input-visitor.h"
 #include "qapi/qmp/qdict.h"
 #ifndef CONFIG_USER_ONLY
-#include "sysemu/arch_init.h"
 #include "hw/pci/pci.h"
 #endif
 #include "qapi/qapi-commands-machine-target.h"
diff --git a/target/ppc/translate_init.c.inc b/target/ppc/translate_init.c.inc
index 78cc8f043b..df66852a74 100644
--- a/target/ppc/translate_init.c.inc
+++ b/target/ppc/translate_init.c.inc
@@ -21,7 +21,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"
-- 
2.28.0



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH v2 6/6] Rename arch_init.h to arch_type.h
  2020-11-25 20:56 [PATCH v2 0/6] arch_init.c cleanup Eduardo Habkost
                   ` (4 preceding siblings ...)
  2020-11-25 20:56   ` Eduardo Habkost
@ 2020-11-25 20:56 ` Eduardo Habkost
  2020-11-27 12:25   ` Cornelia Huck
  2020-11-25 22:23 ` [PATCH v2 0/6] arch_init.c cleanup Roman Bolshakov
  6 siblings, 1 reply; 37+ messages in thread
From: Eduardo Habkost @ 2020-11-25 20:56 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Thomas Huth, Daniel P. Berrangé,
	qemu-block, Markus Armbruster, Max Reitz, Gerd Hoffmann,
	Paolo Bonzini

The only declarations in arch_init.h are related to the arch_type
variable (which is a useful feature that allows us to simplify
command line option handling).  Rename the header to reflect its
purpose.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
Cc: Markus Armbruster <armbru@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Max Reitz <mreitz@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: qemu-block@nongnu.org
Cc: qemu-devel@nongnu.org
---
 include/sysemu/{arch_init.h => arch_type.h} | 0
 blockdev.c                                  | 2 +-
 softmmu/arch_init.c                         | 2 +-
 softmmu/qdev-monitor.c                      | 2 +-
 softmmu/vl.c                                | 2 +-
 stubs/arch_type.c                           | 2 +-
 6 files changed, 5 insertions(+), 5 deletions(-)
 rename include/sysemu/{arch_init.h => arch_type.h} (100%)

diff --git a/include/sysemu/arch_init.h b/include/sysemu/arch_type.h
similarity index 100%
rename from include/sysemu/arch_init.h
rename to include/sysemu/arch_type.h
diff --git a/blockdev.c b/blockdev.c
index fe6fb5dc1d..46c10b2609 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -56,7 +56,7 @@
 #include "sysemu/iothread.h"
 #include "block/block_int.h"
 #include "block/trace.h"
-#include "sysemu/arch_init.h"
+#include "sysemu/arch_type.h"
 #include "sysemu/qtest.h"
 #include "sysemu/runstate.h"
 #include "sysemu/replay.h"
diff --git a/softmmu/arch_init.c b/softmmu/arch_init.c
index f4770931f5..5a9bc56387 100644
--- a/softmmu/arch_init.c
+++ b/softmmu/arch_init.c
@@ -24,7 +24,7 @@
 #include "qemu/osdep.h"
 #include "cpu.h"
 #include "sysemu/sysemu.h"
-#include "sysemu/arch_init.h"
+#include "sysemu/arch_type.h"
 #include "hw/pci/pci.h"
 #include "hw/audio/soundhw.h"
 #include "qapi/error.h"
diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
index bf79d0bbcd..c8b7fb27dc 100644
--- a/softmmu/qdev-monitor.c
+++ b/softmmu/qdev-monitor.c
@@ -22,7 +22,7 @@
 #include "monitor/hmp.h"
 #include "monitor/monitor.h"
 #include "monitor/qdev.h"
-#include "sysemu/arch_init.h"
+#include "sysemu/arch_type.h"
 #include "qapi/error.h"
 #include "qapi/qapi-commands-qdev.h"
 #include "qapi/qmp/qdict.h"
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 74b6ebf1e4..1dd63b2782 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -95,7 +95,7 @@
 #include "trace/control.h"
 #include "qemu/plugin.h"
 #include "qemu/queue.h"
-#include "sysemu/arch_init.h"
+#include "sysemu/arch_type.h"
 
 #include "ui/qemu-spice.h"
 #include "qapi/string-input-visitor.h"
diff --git a/stubs/arch_type.c b/stubs/arch_type.c
index fc5423bc98..603a49deec 100644
--- a/stubs/arch_type.c
+++ b/stubs/arch_type.c
@@ -1,4 +1,4 @@
 #include "qemu/osdep.h"
-#include "sysemu/arch_init.h"
+#include "sysemu/arch_type.h"
 
 const uint32_t arch_type = QEMU_ARCH_NONE;
-- 
2.28.0



^ permalink raw reply related	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 0/6] arch_init.c cleanup
  2020-11-25 20:56 [PATCH v2 0/6] arch_init.c cleanup Eduardo Habkost
                   ` (5 preceding siblings ...)
  2020-11-25 20:56 ` [PATCH v2 6/6] Rename arch_init.h to arch_type.h Eduardo Habkost
@ 2020-11-25 22:23 ` Roman Bolshakov
  6 siblings, 0 replies; 37+ messages in thread
From: Roman Bolshakov @ 2020-11-25 22:23 UTC (permalink / raw)
  To: Eduardo Habkost; +Cc: Thomas Huth, qemu-devel, Gerd Hoffmann

On Wed, Nov 25, 2020 at 03:56:30PM -0500, Eduardo Habkost wrote:
> This series gets rid of most of the code in arch_init.c.  It
> moves the QEMU_ARCH macro definitions to corresponding cpu.h
> files, and gets rid of kvm_available() and xen_available().
> 

For the series:
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>

Thanks,
Roman


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 2/6] accel: accel_available() function
  2020-11-25 20:56 ` [PATCH v2 2/6] accel: accel_available() function Eduardo Habkost
@ 2020-11-26  9:14   ` Claudio Fontana
  2020-11-26 13:36     ` Eduardo Habkost
  2020-11-27 12:08   ` Cornelia Huck
  1 sibling, 1 reply; 37+ messages in thread
From: Claudio Fontana @ 2020-11-26  9:14 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel
  Cc: Paolo Bonzini, Thomas Huth, Richard Henderson, Gerd Hoffmann,
	Roman Bolshakov

Hi Eduardo,

On 11/25/20 9:56 PM, Eduardo Habkost wrote:
> This function will be used to replace the xen_available() and
> kvm_available() functions from arch_init.c.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Claudio Fontana <cfontana@suse.de>
> Cc: Roman Bolshakov <r.bolshakov@yadro.com>
> ---
>  include/sysemu/accel.h | 1 +
>  accel/accel.c          | 5 +++++
>  2 files changed, 6 insertions(+)
> 
> diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h
> index e08b8ab8fa..a4a00c75c8 100644
> --- a/include/sysemu/accel.h
> +++ b/include/sysemu/accel.h
> @@ -67,6 +67,7 @@ typedef struct AccelClass {
>      OBJECT_GET_CLASS(AccelClass, (obj), TYPE_ACCEL)
>  
>  AccelClass *accel_find(const char *opt_name);
> +bool accel_available(const char *name);
>  int accel_init_machine(AccelState *accel, MachineState *ms);
>  
>  /* Called just before os_setup_post (ie just before drop OS privs) */
> diff --git a/accel/accel.c b/accel/accel.c
> index cb555e3b06..4a64a2b38a 100644
> --- a/accel/accel.c
> +++ b/accel/accel.c
> @@ -46,6 +46,11 @@ AccelClass *accel_find(const char *opt_name)
>      return ac;
>  }
>  
> +bool accel_available(const char *name)
> +{
> +    return accel_find(name) != NULL;


accel_find() in its implementation allocates and then frees memory to generate the string,
the user of accel_available() might be unaware and overuse leading to fragmentation/performance issues?


> +}
> +
>  int accel_init_machine(AccelState *accel, MachineState *ms)
>  {
>      AccelClass *acc = ACCEL_GET_CLASS(accel);
> 



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 1/6] arch_init: Move QEMU_ARCH definitions to cpu.h
  2020-11-25 20:56   ` Eduardo Habkost
@ 2020-11-26 12:31     ` Thomas Huth
  -1 siblings, 0 replies; 37+ messages in thread
From: Thomas Huth @ 2020-11-26 12:31 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel
  Cc: Peter Maydell, Sarah Harris, Cornelia Huck, Sagar Karandikar,
	David Hildenbrand, Anthony Green, Mark Cave-Ayland,
	Philippe Mathieu-Daudé,
	Max Filippov, Alistair Francis, Gerd Hoffmann, Edgar E. Iglesias,
	Guan Xuetao, Marek Vasut, Yoshinori Sato, qemu-ppc,
	Artyom Tarasenko, Aleksandar Rikalo, Richard Henderson,
	qemu-s390x, qemu-arm, Michael Rolnik, Stafford Horne,
	David Gibson, qemu-riscv, Bastian Koppelmann, Chris Wulff,
	Laurent Vivier, Michael Walle, Palmer Dabbelt, Paolo Bonzini,
	Aurelien Jarno

On 25/11/2020 21.56, Eduardo Habkost wrote:
> Instead of a collection of #ifdefs on arch_init.c, define
> QEMU_ARCH inside each cpu.h file.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---

Sounds like a good idea to get rid of the #ifdeffery!

Acked-by: Thomas Huth <thuth@redhat.com>



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 1/6] arch_init: Move QEMU_ARCH definitions to cpu.h
@ 2020-11-26 12:31     ` Thomas Huth
  0 siblings, 0 replies; 37+ messages in thread
From: Thomas Huth @ 2020-11-26 12:31 UTC (permalink / raw)
  To: Eduardo Habkost, qemu-devel
  Cc: Gerd Hoffmann, Richard Henderson, Peter Maydell, Michael Rolnik,
	Sarah Harris, Edgar E. Iglesias, Paolo Bonzini, Michael Walle,
	Laurent Vivier, Philippe Mathieu-Daudé,
	Aurelien Jarno, Jiaxun Yang, Aleksandar Rikalo, Anthony Green,
	Chris Wulff, Marek Vasut, Stafford Horne, David Gibson,
	Palmer Dabbelt, Alistair Francis, Sagar Karandikar,
	Bastian Koppelmann, Yoshinori Sato, David Hildenbrand,
	Cornelia Huck, Mark Cave-Ayland, Artyom Tarasenko, Guan Xuetao,
	Max Filippov, qemu-arm, qemu-ppc, qemu-riscv, qemu-s390x

On 25/11/2020 21.56, Eduardo Habkost wrote:
> Instead of a collection of #ifdefs on arch_init.c, define
> QEMU_ARCH inside each cpu.h file.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---

Sounds like a good idea to get rid of the #ifdeffery!

Acked-by: Thomas Huth <thuth@redhat.com>



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 2/6] accel: accel_available() function
  2020-11-26  9:14   ` Claudio Fontana
@ 2020-11-26 13:36     ` Eduardo Habkost
  2020-11-26 14:13       ` Claudio Fontana
  0 siblings, 1 reply; 37+ messages in thread
From: Eduardo Habkost @ 2020-11-26 13:36 UTC (permalink / raw)
  To: Claudio Fontana
  Cc: Thomas Huth, Richard Henderson, qemu-devel, Roman Bolshakov,
	Gerd Hoffmann, Paolo Bonzini

On Thu, Nov 26, 2020 at 10:14:31AM +0100, Claudio Fontana wrote:
> Hi Eduardo,
> 
> On 11/25/20 9:56 PM, Eduardo Habkost wrote:
> > This function will be used to replace the xen_available() and
> > kvm_available() functions from arch_init.c.
> > 
> > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> > ---
> > Cc: Richard Henderson <richard.henderson@linaro.org>
> > Cc: Paolo Bonzini <pbonzini@redhat.com>
> > Cc: Claudio Fontana <cfontana@suse.de>
> > Cc: Roman Bolshakov <r.bolshakov@yadro.com>
> > ---
> >  include/sysemu/accel.h | 1 +
> >  accel/accel.c          | 5 +++++
> >  2 files changed, 6 insertions(+)
> > 
> > diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h
> > index e08b8ab8fa..a4a00c75c8 100644
> > --- a/include/sysemu/accel.h
> > +++ b/include/sysemu/accel.h
> > @@ -67,6 +67,7 @@ typedef struct AccelClass {
> >      OBJECT_GET_CLASS(AccelClass, (obj), TYPE_ACCEL)
> >  
> >  AccelClass *accel_find(const char *opt_name);
> > +bool accel_available(const char *name);
> >  int accel_init_machine(AccelState *accel, MachineState *ms);
> >  
> >  /* Called just before os_setup_post (ie just before drop OS privs) */
> > diff --git a/accel/accel.c b/accel/accel.c
> > index cb555e3b06..4a64a2b38a 100644
> > --- a/accel/accel.c
> > +++ b/accel/accel.c
> > @@ -46,6 +46,11 @@ AccelClass *accel_find(const char *opt_name)
> >      return ac;
> >  }
> >  
> > +bool accel_available(const char *name)
> > +{
> > +    return accel_find(name) != NULL;
> 
> 
> accel_find() in its implementation allocates and then frees memory to generate the string,
> the user of accel_available() might be unaware and overuse leading to fragmentation/performance issues?

Is that a real issue?  We had only 3 users of kvm_available() and
xen_available() since those functions were added 10 years ago.

Do you have any suggestions on what we should do?

-- 
Eduardo



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 2/6] accel: accel_available() function
  2020-11-26 13:36     ` Eduardo Habkost
@ 2020-11-26 14:13       ` Claudio Fontana
  2020-11-26 14:25         ` Paolo Bonzini
  0 siblings, 1 reply; 37+ messages in thread
From: Claudio Fontana @ 2020-11-26 14:13 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Thomas Huth, Richard Henderson, qemu-devel, Roman Bolshakov,
	Gerd Hoffmann, Paolo Bonzini

On 11/26/20 2:36 PM, Eduardo Habkost wrote:
> On Thu, Nov 26, 2020 at 10:14:31AM +0100, Claudio Fontana wrote:
>> Hi Eduardo,
>>
>> On 11/25/20 9:56 PM, Eduardo Habkost wrote:
>>> This function will be used to replace the xen_available() and
>>> kvm_available() functions from arch_init.c.
>>>
>>> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
>>> ---
>>> Cc: Richard Henderson <richard.henderson@linaro.org>
>>> Cc: Paolo Bonzini <pbonzini@redhat.com>
>>> Cc: Claudio Fontana <cfontana@suse.de>
>>> Cc: Roman Bolshakov <r.bolshakov@yadro.com>
>>> ---
>>>  include/sysemu/accel.h | 1 +
>>>  accel/accel.c          | 5 +++++
>>>  2 files changed, 6 insertions(+)
>>>
>>> diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h
>>> index e08b8ab8fa..a4a00c75c8 100644
>>> --- a/include/sysemu/accel.h
>>> +++ b/include/sysemu/accel.h
>>> @@ -67,6 +67,7 @@ typedef struct AccelClass {
>>>      OBJECT_GET_CLASS(AccelClass, (obj), TYPE_ACCEL)
>>>  
>>>  AccelClass *accel_find(const char *opt_name);
>>> +bool accel_available(const char *name);
>>>  int accel_init_machine(AccelState *accel, MachineState *ms);
>>>  
>>>  /* Called just before os_setup_post (ie just before drop OS privs) */
>>> diff --git a/accel/accel.c b/accel/accel.c
>>> index cb555e3b06..4a64a2b38a 100644
>>> --- a/accel/accel.c
>>> +++ b/accel/accel.c
>>> @@ -46,6 +46,11 @@ AccelClass *accel_find(const char *opt_name)
>>>      return ac;
>>>  }
>>>  
>>> +bool accel_available(const char *name)
>>> +{
>>> +    return accel_find(name) != NULL;
>>
>>
>> accel_find() in its implementation allocates and then frees memory to generate the string,
>> the user of accel_available() might be unaware and overuse leading to fragmentation/performance issues?
> 
> Is that a real issue?  We had only 3 users of kvm_available() and
> xen_available() since those functions were added 10 years ago.
> 
> Do you have any suggestions on what we should do?
> 

One option I see is simply to document the behavior where accel_available() is declared in accel.h (ie do not use in fast path), as well as in accel_find() actually,
so that both accel_find() and accel_available() are avoided in fast path and avoid being called frequently at runtime.

Another option could be to remove the allocation completely, and use for example accel_find(ACCEL_CLASS_NAME("tcg")),
or another option again would be to remove the allocation and use either a fixed buffer + snprintf, or alloca -like builtin code to use the stack, ...

Not a big deal, but with a general utility and short name like accel_available(name) it might be tempting to use this more in the future?

Ciao,

Claudio



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 2/6] accel: accel_available() function
  2020-11-26 14:13       ` Claudio Fontana
@ 2020-11-26 14:25         ` Paolo Bonzini
  2020-11-26 21:06           ` Claudio Fontana
  0 siblings, 1 reply; 37+ messages in thread
From: Paolo Bonzini @ 2020-11-26 14:25 UTC (permalink / raw)
  To: Claudio Fontana, Eduardo Habkost
  Cc: Thomas Huth, Gerd Hoffmann, Richard Henderson, qemu-devel,
	Roman Bolshakov

On 26/11/20 15:13, Claudio Fontana wrote:
> One option I see is simply to document the behavior where
> accel_available() is declared in accel.h (ie do not use in fast
> path), as well as in accel_find() actually, so that both accel_find()
> and accel_available() are avoided in fast path and avoid being called
> frequently at runtime.
> 
> Another option could be to remove the allocation completely, and use
> for example accel_find(ACCEL_CLASS_NAME("tcg")), or another option
> again would be to remove the allocation and use either a fixed buffer
> + snprintf, or alloca -like builtin code to use the stack, ...
> 
> Not a big deal, but with a general utility and short name like
> accel_available(name) it might be tempting to use this more in the
> future?

I think it's just that the usecase is not that common.  "Is this 
accelerator compiled in the binary" is not something you need after 
startup (or if querying the monitor).

Paolo



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 2/6] accel: accel_available() function
  2020-11-26 14:25         ` Paolo Bonzini
@ 2020-11-26 21:06           ` Claudio Fontana
  2020-11-26 21:48             ` Eduardo Habkost
  2020-11-27  5:00             ` Paolo Bonzini
  0 siblings, 2 replies; 37+ messages in thread
From: Claudio Fontana @ 2020-11-26 21:06 UTC (permalink / raw)
  To: Paolo Bonzini, Eduardo Habkost
  Cc: Thomas Huth, Richard Henderson, Gerd Hoffmann, Roman Bolshakov,
	qemu-devel

On 11/26/20 3:25 PM, Paolo Bonzini wrote:
> On 26/11/20 15:13, Claudio Fontana wrote:
>> One option I see is simply to document the behavior where
>> accel_available() is declared in accel.h (ie do not use in fast
>> path), as well as in accel_find() actually, so that both accel_find()
>> and accel_available() are avoided in fast path and avoid being called
>> frequently at runtime.
>>
>> Another option could be to remove the allocation completely, and use
>> for example accel_find(ACCEL_CLASS_NAME("tcg")), or another option
>> again would be to remove the allocation and use either a fixed buffer
>> + snprintf, or alloca -like builtin code to use the stack, ...
>>
>> Not a big deal, but with a general utility and short name like
>> accel_available(name) it might be tempting to use this more in the
>> future?
> 
> I think it's just that the usecase is not that common.  "Is this 
> accelerator compiled in the binary" is not something you need after 
> startup (or if querying the monitor).
> 
> Paolo
> 
> 

A script that repeatedly uses the QMP interface to query for the status could generate fragmentation this way I think.

Ciao,

Claudio


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 2/6] accel: accel_available() function
  2020-11-26 21:06           ` Claudio Fontana
@ 2020-11-26 21:48             ` Eduardo Habkost
  2020-11-27  9:04               ` Claudio Fontana
  2020-11-27  5:00             ` Paolo Bonzini
  1 sibling, 1 reply; 37+ messages in thread
From: Eduardo Habkost @ 2020-11-26 21:48 UTC (permalink / raw)
  To: Claudio Fontana
  Cc: Thomas Huth, Richard Henderson, qemu-devel, Roman Bolshakov,
	Gerd Hoffmann, Paolo Bonzini

On Thu, Nov 26, 2020 at 10:06:03PM +0100, Claudio Fontana wrote:
> On 11/26/20 3:25 PM, Paolo Bonzini wrote:
> > On 26/11/20 15:13, Claudio Fontana wrote:
> >> One option I see is simply to document the behavior where
> >> accel_available() is declared in accel.h (ie do not use in fast
> >> path), as well as in accel_find() actually, so that both accel_find()
> >> and accel_available() are avoided in fast path and avoid being called
> >> frequently at runtime.
> >>
> >> Another option could be to remove the allocation completely, and use
> >> for example accel_find(ACCEL_CLASS_NAME("tcg")), or another option
> >> again would be to remove the allocation and use either a fixed buffer
> >> + snprintf, or alloca -like builtin code to use the stack, ...
> >>
> >> Not a big deal, but with a general utility and short name like
> >> accel_available(name) it might be tempting to use this more in the
> >> future?
> > 
> > I think it's just that the usecase is not that common.  "Is this 
> > accelerator compiled in the binary" is not something you need after 
> > startup (or if querying the monitor).
> > 
> > Paolo
> > 
> > 
> 
> A script that repeatedly uses the QMP interface to query for
> the status could generate fragmentation this way I think.

Is this a problem?  Today, execution of a "query-kvm" command
calls g_malloc() 37 times.

-- 
Eduardo



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 2/6] accel: accel_available() function
  2020-11-26 21:06           ` Claudio Fontana
  2020-11-26 21:48             ` Eduardo Habkost
@ 2020-11-27  5:00             ` Paolo Bonzini
  1 sibling, 0 replies; 37+ messages in thread
From: Paolo Bonzini @ 2020-11-27  5:00 UTC (permalink / raw)
  To: Claudio Fontana, Eduardo Habkost
  Cc: Thomas Huth, Richard Henderson, Gerd Hoffmann, Roman Bolshakov,
	qemu-devel

On 26/11/20 22:06, Claudio Fontana wrote:
>> I think it's just that the usecase is not that common.  "Is this
>> accelerator compiled in the binary" is not something you need after
>> startup (or if querying the monitor).
>
> A script that repeatedly uses the QMP interface to query for the status could generate fragmentation this way I think.

System malloc should be smarter than that, but anyway this is all but 
the only allocation in that path.

Paolo



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 2/6] accel: accel_available() function
  2020-11-26 21:48             ` Eduardo Habkost
@ 2020-11-27  9:04               ` Claudio Fontana
  2020-11-27 14:45                 ` Markus Armbruster
  0 siblings, 1 reply; 37+ messages in thread
From: Claudio Fontana @ 2020-11-27  9:04 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Thomas Huth, Richard Henderson, qemu-devel, Roman Bolshakov,
	Gerd Hoffmann, Paolo Bonzini

On 11/26/20 10:48 PM, Eduardo Habkost wrote:
> On Thu, Nov 26, 2020 at 10:06:03PM +0100, Claudio Fontana wrote:
>> On 11/26/20 3:25 PM, Paolo Bonzini wrote:
>>> On 26/11/20 15:13, Claudio Fontana wrote:
>>>> One option I see is simply to document the behavior where
>>>> accel_available() is declared in accel.h (ie do not use in fast
>>>> path), as well as in accel_find() actually, so that both accel_find()
>>>> and accel_available() are avoided in fast path and avoid being called
>>>> frequently at runtime.
>>>>
>>>> Another option could be to remove the allocation completely, and use
>>>> for example accel_find(ACCEL_CLASS_NAME("tcg")), or another option
>>>> again would be to remove the allocation and use either a fixed buffer
>>>> + snprintf, or alloca -like builtin code to use the stack, ...
>>>>
>>>> Not a big deal, but with a general utility and short name like
>>>> accel_available(name) it might be tempting to use this more in the
>>>> future?
>>>
>>> I think it's just that the usecase is not that common.  "Is this 
>>> accelerator compiled in the binary" is not something you need after 
>>> startup (or if querying the monitor).
>>>
>>> Paolo
>>>
>>>
>>
>> A script that repeatedly uses the QMP interface to query for
>> the status could generate fragmentation this way I think.
> 
> Is this a problem?  Today, execution of a "query-kvm" command
> calls g_malloc() 37 times.
> 

Not ideal in my view, but not the end of the world either.

Ciao,

Claudio


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 1/6] arch_init: Move QEMU_ARCH definitions to cpu.h
  2020-11-25 20:56   ` Eduardo Habkost
@ 2020-11-27 11:35     ` Cornelia Huck
  -1 siblings, 0 replies; 37+ messages in thread
From: Cornelia Huck @ 2020-11-27 11:35 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Peter Maydell, Sarah Harris, Sagar Karandikar, David Hildenbrand,
	Anthony Green, Mark Cave-Ayland, qemu-devel,
	Philippe Mathieu-Daudé,
	Max Filippov, Alistair Francis, Gerd Hoffmann, Edgar E. Iglesias,
	Guan Xuetao, Marek Vasut, Yoshinori Sato, qemu-ppc,
	Artyom Tarasenko, Thomas Huth, Richard Henderson, qemu-s390x,
	qemu-arm, Michael Rolnik, Stafford Horne, David Gibson,
	qemu-riscv, Bastian Koppelmann, Chris Wulff, Laurent Vivier,
	Michael Walle, Palmer Dabbelt, Paolo Bonzini, Aleksandar Rikalo,
	Aurelien Jarno

On Wed, 25 Nov 2020 15:56:31 -0500
Eduardo Habkost <ehabkost@redhat.com> wrote:

> Instead of a collection of #ifdefs on arch_init.c, define
> QEMU_ARCH inside each cpu.h file.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: Michael Rolnik <mrolnik@gmail.com>
> Cc: Sarah Harris <S.E.Harris@kent.ac.uk>
> Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Eduardo Habkost <ehabkost@redhat.com>
> Cc: Michael Walle <michael@walle.cc>
> Cc: Laurent Vivier <laurent@vivier.eu>
> Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
> Cc: Aurelien Jarno <aurelien@aurel32.net>
> Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Cc: Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>
> Cc: Anthony Green <green@moxielogic.com>
> Cc: Chris Wulff <crwulff@gmail.com>
> Cc: Marek Vasut <marex@denx.de>
> Cc: Stafford Horne <shorne@gmail.com>
> Cc: David Gibson <david@gibson.dropbear.id.au>
> Cc: Palmer Dabbelt <palmer@dabbelt.com>
> Cc: Alistair Francis <Alistair.Francis@wdc.com>
> Cc: Sagar Karandikar <sagark@eecs.berkeley.edu>
> Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Cornelia Huck <cohuck@redhat.com>
> Cc: Thomas Huth <thuth@redhat.com>
> Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> Cc: Artyom Tarasenko <atar4qemu@gmail.com>
> Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
> Cc: Max Filippov <jcmvbkbc@gmail.com>
> Cc: qemu-devel@nongnu.org
> Cc: qemu-arm@nongnu.org
> Cc: qemu-ppc@nongnu.org
> Cc: qemu-riscv@nongnu.org
> Cc: qemu-s390x@nongnu.org
> ---
>  target/alpha/cpu.h      |  1 +
>  target/arm/cpu.h        |  1 +
>  target/avr/cpu.h        |  1 +
>  target/cris/cpu.h       |  1 +
>  target/hppa/cpu.h       |  1 +
>  target/i386/cpu.h       |  1 +
>  target/lm32/cpu.h       |  1 +
>  target/m68k/cpu.h       |  1 +
>  target/microblaze/cpu.h |  1 +
>  target/mips/cpu.h       |  1 +
>  target/moxie/cpu.h      |  1 +
>  target/nios2/cpu.h      |  1 +
>  target/openrisc/cpu.h   |  1 +
>  target/ppc/cpu.h        |  1 +
>  target/riscv/cpu.h      |  1 +
>  target/rx/cpu.h         |  1 +
>  target/s390x/cpu.h      |  1 +
>  target/sh4/cpu.h        |  1 +
>  target/sparc/cpu.h      |  1 +
>  target/tricore/cpu.h    |  1 +
>  target/unicore32/cpu.h  |  1 +
>  target/xtensa/cpu.h     |  1 +
>  softmmu/arch_init.c     | 46 -----------------------------------------
>  23 files changed, 22 insertions(+), 46 deletions(-)

Much better :)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 1/6] arch_init: Move QEMU_ARCH definitions to cpu.h
@ 2020-11-27 11:35     ` Cornelia Huck
  0 siblings, 0 replies; 37+ messages in thread
From: Cornelia Huck @ 2020-11-27 11:35 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: qemu-devel, Gerd Hoffmann, Thomas Huth, Richard Henderson,
	Peter Maydell, Michael Rolnik, Sarah Harris, Edgar E. Iglesias,
	Paolo Bonzini, Michael Walle, Laurent Vivier,
	Philippe Mathieu-Daudé,
	Aurelien Jarno, Jiaxun Yang, Aleksandar Rikalo, Anthony Green,
	Chris Wulff, Marek Vasut, Stafford Horne, David Gibson,
	Palmer Dabbelt, Alistair Francis, Sagar Karandikar,
	Bastian Koppelmann, Yoshinori Sato, David Hildenbrand,
	Mark Cave-Ayland, Artyom Tarasenko, Guan Xuetao, Max Filippov,
	qemu-arm, qemu-ppc, qemu-riscv, qemu-s390x

On Wed, 25 Nov 2020 15:56:31 -0500
Eduardo Habkost <ehabkost@redhat.com> wrote:

> Instead of a collection of #ifdefs on arch_init.c, define
> QEMU_ARCH inside each cpu.h file.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: Michael Rolnik <mrolnik@gmail.com>
> Cc: Sarah Harris <S.E.Harris@kent.ac.uk>
> Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Eduardo Habkost <ehabkost@redhat.com>
> Cc: Michael Walle <michael@walle.cc>
> Cc: Laurent Vivier <laurent@vivier.eu>
> Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
> Cc: Aurelien Jarno <aurelien@aurel32.net>
> Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Cc: Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>
> Cc: Anthony Green <green@moxielogic.com>
> Cc: Chris Wulff <crwulff@gmail.com>
> Cc: Marek Vasut <marex@denx.de>
> Cc: Stafford Horne <shorne@gmail.com>
> Cc: David Gibson <david@gibson.dropbear.id.au>
> Cc: Palmer Dabbelt <palmer@dabbelt.com>
> Cc: Alistair Francis <Alistair.Francis@wdc.com>
> Cc: Sagar Karandikar <sagark@eecs.berkeley.edu>
> Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Cornelia Huck <cohuck@redhat.com>
> Cc: Thomas Huth <thuth@redhat.com>
> Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> Cc: Artyom Tarasenko <atar4qemu@gmail.com>
> Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
> Cc: Max Filippov <jcmvbkbc@gmail.com>
> Cc: qemu-devel@nongnu.org
> Cc: qemu-arm@nongnu.org
> Cc: qemu-ppc@nongnu.org
> Cc: qemu-riscv@nongnu.org
> Cc: qemu-s390x@nongnu.org
> ---
>  target/alpha/cpu.h      |  1 +
>  target/arm/cpu.h        |  1 +
>  target/avr/cpu.h        |  1 +
>  target/cris/cpu.h       |  1 +
>  target/hppa/cpu.h       |  1 +
>  target/i386/cpu.h       |  1 +
>  target/lm32/cpu.h       |  1 +
>  target/m68k/cpu.h       |  1 +
>  target/microblaze/cpu.h |  1 +
>  target/mips/cpu.h       |  1 +
>  target/moxie/cpu.h      |  1 +
>  target/nios2/cpu.h      |  1 +
>  target/openrisc/cpu.h   |  1 +
>  target/ppc/cpu.h        |  1 +
>  target/riscv/cpu.h      |  1 +
>  target/rx/cpu.h         |  1 +
>  target/s390x/cpu.h      |  1 +
>  target/sh4/cpu.h        |  1 +
>  target/sparc/cpu.h      |  1 +
>  target/tricore/cpu.h    |  1 +
>  target/unicore32/cpu.h  |  1 +
>  target/xtensa/cpu.h     |  1 +
>  softmmu/arch_init.c     | 46 -----------------------------------------
>  23 files changed, 22 insertions(+), 46 deletions(-)

Much better :)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 2/6] accel: accel_available() function
  2020-11-25 20:56 ` [PATCH v2 2/6] accel: accel_available() function Eduardo Habkost
  2020-11-26  9:14   ` Claudio Fontana
@ 2020-11-27 12:08   ` Cornelia Huck
  1 sibling, 0 replies; 37+ messages in thread
From: Cornelia Huck @ 2020-11-27 12:08 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Thomas Huth, Richard Henderson, qemu-devel, Roman Bolshakov,
	Gerd Hoffmann, Paolo Bonzini, Claudio Fontana

On Wed, 25 Nov 2020 15:56:32 -0500
Eduardo Habkost <ehabkost@redhat.com> wrote:

> This function will be used to replace the xen_available() and
> kvm_available() functions from arch_init.c.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Claudio Fontana <cfontana@suse.de>
> Cc: Roman Bolshakov <r.bolshakov@yadro.com>
> ---
>  include/sysemu/accel.h | 1 +
>  accel/accel.c          | 5 +++++
>  2 files changed, 6 insertions(+)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 3/6] kvm: Remove kvm_available() function
  2020-11-25 20:56   ` Eduardo Habkost
@ 2020-11-27 12:10     ` Cornelia Huck
  -1 siblings, 0 replies; 37+ messages in thread
From: Cornelia Huck @ 2020-11-27 12:10 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: qemu-devel, Thomas Huth, kvm, Richard Henderson,
	Markus Armbruster, Roman Bolshakov, Gerd Hoffmann, Paolo Bonzini,
	Claudio Fontana

On Wed, 25 Nov 2020 15:56:33 -0500
Eduardo Habkost <ehabkost@redhat.com> wrote:

> The only caller can use accel_available("kvm") instead.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: Markus Armbruster <armbru@redhat.com>
> Cc: qemu-devel@nongnu.org
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: kvm@vger.kernel.org
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Claudio Fontana <cfontana@suse.de>
> Cc: Roman Bolshakov <r.bolshakov@yadro.com>
> ---
>  include/sysemu/arch_init.h | 1 -
>  monitor/qmp-cmds.c         | 2 +-
>  softmmu/arch_init.c        | 9 ---------
>  3 files changed, 1 insertion(+), 11 deletions(-)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 3/6] kvm: Remove kvm_available() function
@ 2020-11-27 12:10     ` Cornelia Huck
  0 siblings, 0 replies; 37+ messages in thread
From: Cornelia Huck @ 2020-11-27 12:10 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Thomas Huth, kvm, Richard Henderson, qemu-devel,
	Markus Armbruster, Roman Bolshakov, Gerd Hoffmann, Paolo Bonzini,
	Claudio Fontana

On Wed, 25 Nov 2020 15:56:33 -0500
Eduardo Habkost <ehabkost@redhat.com> wrote:

> The only caller can use accel_available("kvm") instead.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: Markus Armbruster <armbru@redhat.com>
> Cc: qemu-devel@nongnu.org
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: kvm@vger.kernel.org
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Claudio Fontana <cfontana@suse.de>
> Cc: Roman Bolshakov <r.bolshakov@yadro.com>
> ---
>  include/sysemu/arch_init.h | 1 -
>  monitor/qmp-cmds.c         | 2 +-
>  softmmu/arch_init.c        | 9 ---------
>  3 files changed, 1 insertion(+), 11 deletions(-)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 4/6] xen: Delete xen_available() function
  2020-11-25 20:56   ` Eduardo Habkost
@ 2020-11-27 12:11     ` Cornelia Huck
  -1 siblings, 0 replies; 37+ messages in thread
From: Cornelia Huck @ 2020-11-27 12:11 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Thomas Huth, Stefano Stabellini, Paul Durrant, Richard Henderson,
	qemu-devel, Roman Bolshakov, Gerd Hoffmann, Paolo Bonzini,
	Anthony Perard, xen-devel, Claudio Fontana

On Wed, 25 Nov 2020 15:56:34 -0500
Eduardo Habkost <ehabkost@redhat.com> wrote:

> The function can be replaced with accel_available("xen").
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: qemu-devel@nongnu.org
> Cc: Stefano Stabellini <sstabellini@kernel.org>
> Cc: Anthony Perard <anthony.perard@citrix.com>
> Cc: Paul Durrant <paul@xen.org>
> Cc: xen-devel@lists.xenproject.org
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: Claudio Fontana <cfontana@suse.de>
> Cc: Roman Bolshakov <r.bolshakov@yadro.com>
> ---
>  include/sysemu/arch_init.h | 2 --
>  softmmu/arch_init.c        | 9 ---------
>  softmmu/vl.c               | 6 +++---
>  3 files changed, 3 insertions(+), 14 deletions(-)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 4/6] xen: Delete xen_available() function
@ 2020-11-27 12:11     ` Cornelia Huck
  0 siblings, 0 replies; 37+ messages in thread
From: Cornelia Huck @ 2020-11-27 12:11 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: qemu-devel, Thomas Huth, Stefano Stabellini, Paul Durrant,
	Richard Henderson, Roman Bolshakov, Gerd Hoffmann, xen-devel,
	Anthony Perard, Paolo Bonzini, Claudio Fontana

On Wed, 25 Nov 2020 15:56:34 -0500
Eduardo Habkost <ehabkost@redhat.com> wrote:

> The function can be replaced with accel_available("xen").
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: qemu-devel@nongnu.org
> Cc: Stefano Stabellini <sstabellini@kernel.org>
> Cc: Anthony Perard <anthony.perard@citrix.com>
> Cc: Paul Durrant <paul@xen.org>
> Cc: xen-devel@lists.xenproject.org
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: Claudio Fontana <cfontana@suse.de>
> Cc: Roman Bolshakov <r.bolshakov@yadro.com>
> ---
>  include/sysemu/arch_init.h | 2 --
>  softmmu/arch_init.c        | 9 ---------
>  softmmu/vl.c               | 6 +++---
>  3 files changed, 3 insertions(+), 14 deletions(-)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 5/6] Remove unnecessary usage of arch_init.h
  2020-11-25 20:56   ` Eduardo Habkost
@ 2020-11-27 12:23     ` Cornelia Huck
  -1 siblings, 0 replies; 37+ messages in thread
From: Cornelia Huck @ 2020-11-27 12:23 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Sagar Karandikar, Michael S. Tsirkin, qemu-devel,
	Alistair Francis, Gerd Hoffmann, David Hildenbrand,
	Markus Armbruster, Halil Pasic, Christian Borntraeger,
	Hervé Poussineau, Palmer Dabbelt, Thomas Huth,
	Richard Henderson, qemu-s390x, David Gibson, qemu-riscv,
	Bastian Koppelmann, Philippe Mathieu-Daudé,
	qemu-ppc, Paolo Bonzini, Aleksandar Rikalo, Aurelien Jarno

On Wed, 25 Nov 2020 15:56:35 -0500
Eduardo Habkost <ehabkost@redhat.com> wrote:

> The only declarations in arch_init.h are the `arch_type` variable
> and the QEMU_ARCH_* constants.  Stop including arch_init.h from
> code that don't use neither.
> 
> Patch generated automatically using the command:
> 
>  $ sed -i -e '/#include "sysemu.arch_init.h"/d' \
>    $(comm -23 \
>       <(git grep -l arch_init.h | sort) \
>       <((git grep -l -w 'arch_type'; g grep -l QEMU_ARCH;) | sort -u))
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Eduardo Habkost <ehabkost@redhat.com>
> Cc: "Michael S. Tsirkin" <mst@redhat.com>
> Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
> Cc: "Hervé Poussineau" <hpoussin@reactos.org>
> Cc: Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>
> Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
> Cc: Aurelien Jarno <aurelien@aurel32.net>
> Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Cc: David Gibson <david@gibson.dropbear.id.au>
> Cc: Palmer Dabbelt <palmer@dabbelt.com>
> Cc: Alistair Francis <Alistair.Francis@wdc.com>
> Cc: Sagar Karandikar <sagark@eecs.berkeley.edu>
> Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> Cc: Markus Armbruster <armbru@redhat.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Cornelia Huck <cohuck@redhat.com>
> Cc: Thomas Huth <thuth@redhat.com>
> Cc: Halil Pasic <pasic@linux.ibm.com>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Cc: qemu-devel@nongnu.org
> Cc: qemu-ppc@nongnu.org
> Cc: qemu-riscv@nongnu.org
> Cc: qemu-s390x@nongnu.org
> ---
>  accel/accel.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/i386/cpu.c               | 1 -
>  target/s390x/cpu.c              | 1 -
>  target/s390x/cpu_models.c       | 1 -
>  target/ppc/translate_init.c.inc | 1 -
>  16 files changed, 16 deletions(-)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 5/6] Remove unnecessary usage of arch_init.h
@ 2020-11-27 12:23     ` Cornelia Huck
  0 siblings, 0 replies; 37+ messages in thread
From: Cornelia Huck @ 2020-11-27 12:23 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: qemu-devel, Gerd Hoffmann, Thomas Huth, Richard Henderson,
	Paolo Bonzini, Michael S. Tsirkin, Marcel Apfelbaum,
	Hervé Poussineau, Aleksandar Rikalo,
	Philippe Mathieu-Daudé,
	Aurelien Jarno, Jiaxun Yang, David Gibson, Palmer Dabbelt,
	Alistair Francis, Sagar Karandikar, Bastian Koppelmann,
	Markus Armbruster, David Hildenbrand, Halil Pasic,
	Christian Borntraeger, qemu-ppc, qemu-riscv, qemu-s390x

On Wed, 25 Nov 2020 15:56:35 -0500
Eduardo Habkost <ehabkost@redhat.com> wrote:

> The only declarations in arch_init.h are the `arch_type` variable
> and the QEMU_ARCH_* constants.  Stop including arch_init.h from
> code that don't use neither.
> 
> Patch generated automatically using the command:
> 
>  $ sed -i -e '/#include "sysemu.arch_init.h"/d' \
>    $(comm -23 \
>       <(git grep -l arch_init.h | sort) \
>       <((git grep -l -w 'arch_type'; g grep -l QEMU_ARCH;) | sort -u))
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Eduardo Habkost <ehabkost@redhat.com>
> Cc: "Michael S. Tsirkin" <mst@redhat.com>
> Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
> Cc: "Hervé Poussineau" <hpoussin@reactos.org>
> Cc: Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>
> Cc: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
> Cc: Aurelien Jarno <aurelien@aurel32.net>
> Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Cc: David Gibson <david@gibson.dropbear.id.au>
> Cc: Palmer Dabbelt <palmer@dabbelt.com>
> Cc: Alistair Francis <Alistair.Francis@wdc.com>
> Cc: Sagar Karandikar <sagark@eecs.berkeley.edu>
> Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> Cc: Markus Armbruster <armbru@redhat.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Cornelia Huck <cohuck@redhat.com>
> Cc: Thomas Huth <thuth@redhat.com>
> Cc: Halil Pasic <pasic@linux.ibm.com>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Cc: qemu-devel@nongnu.org
> Cc: qemu-ppc@nongnu.org
> Cc: qemu-riscv@nongnu.org
> Cc: qemu-s390x@nongnu.org
> ---
>  accel/accel.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/i386/cpu.c               | 1 -
>  target/s390x/cpu.c              | 1 -
>  target/s390x/cpu_models.c       | 1 -
>  target/ppc/translate_init.c.inc | 1 -
>  16 files changed, 16 deletions(-)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 6/6] Rename arch_init.h to arch_type.h
  2020-11-25 20:56 ` [PATCH v2 6/6] Rename arch_init.h to arch_type.h Eduardo Habkost
@ 2020-11-27 12:25   ` Cornelia Huck
  0 siblings, 0 replies; 37+ messages in thread
From: Cornelia Huck @ 2020-11-27 12:25 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Kevin Wolf, Thomas Huth, Daniel P. Berrangé,
	qemu-block, qemu-devel, Markus Armbruster, Gerd Hoffmann,
	Paolo Bonzini, Max Reitz

On Wed, 25 Nov 2020 15:56:36 -0500
Eduardo Habkost <ehabkost@redhat.com> wrote:

> The only declarations in arch_init.h are related to the arch_type
> variable (which is a useful feature that allows us to simplify
> command line option handling).  Rename the header to reflect its
> purpose.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Cc: Markus Armbruster <armbru@redhat.com>
> Cc: Kevin Wolf <kwolf@redhat.com>
> Cc: Max Reitz <mreitz@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: "Daniel P. Berrangé" <berrange@redhat.com>
> Cc: Eduardo Habkost <ehabkost@redhat.com>
> Cc: qemu-block@nongnu.org
> Cc: qemu-devel@nongnu.org
> ---
>  include/sysemu/{arch_init.h => arch_type.h} | 0
>  blockdev.c                                  | 2 +-
>  softmmu/arch_init.c                         | 2 +-
>  softmmu/qdev-monitor.c                      | 2 +-
>  softmmu/vl.c                                | 2 +-
>  stubs/arch_type.c                           | 2 +-
>  6 files changed, 5 insertions(+), 5 deletions(-)
>  rename include/sysemu/{arch_init.h => arch_type.h} (100%)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 2/6] accel: accel_available() function
  2020-11-27  9:04               ` Claudio Fontana
@ 2020-11-27 14:45                 ` Markus Armbruster
  2020-11-27 14:58                   ` Claudio Fontana
  0 siblings, 1 reply; 37+ messages in thread
From: Markus Armbruster @ 2020-11-27 14:45 UTC (permalink / raw)
  To: Claudio Fontana
  Cc: Thomas Huth, Eduardo Habkost, Richard Henderson, qemu-devel,
	Roman Bolshakov, Gerd Hoffmann, Paolo Bonzini

Claudio Fontana <cfontana@suse.de> writes:

> On 11/26/20 10:48 PM, Eduardo Habkost wrote:
>> On Thu, Nov 26, 2020 at 10:06:03PM +0100, Claudio Fontana wrote:
>>> On 11/26/20 3:25 PM, Paolo Bonzini wrote:
>>>> On 26/11/20 15:13, Claudio Fontana wrote:
>>>>> One option I see is simply to document the behavior where
>>>>> accel_available() is declared in accel.h (ie do not use in fast
>>>>> path), as well as in accel_find() actually, so that both accel_find()
>>>>> and accel_available() are avoided in fast path and avoid being called
>>>>> frequently at runtime.
>>>>>
>>>>> Another option could be to remove the allocation completely, and use
>>>>> for example accel_find(ACCEL_CLASS_NAME("tcg")), or another option
>>>>> again would be to remove the allocation and use either a fixed buffer
>>>>> + snprintf, or alloca -like builtin code to use the stack, ...
>>>>>
>>>>> Not a big deal, but with a general utility and short name like
>>>>> accel_available(name) it might be tempting to use this more in the
>>>>> future?
>>>>
>>>> I think it's just that the usecase is not that common.  "Is this 
>>>> accelerator compiled in the binary" is not something you need after 
>>>> startup (or if querying the monitor).
>>>>
>>>> Paolo
>>>>
>>>>
>>>
>>> A script that repeatedly uses the QMP interface to query for
>>> the status could generate fragmentation this way I think.
>> 
>> Is this a problem?  Today, execution of a "query-kvm" command
>> calls g_malloc() 37 times.
>> 
>
> Not ideal in my view, but not the end of the world either.

QMP's appetite for malloc is roughly comparable to a pig's for truffles.



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 4/6] xen: Delete xen_available() function
  2020-11-25 20:56   ` Eduardo Habkost
@ 2020-11-27 14:52     ` Anthony PERARD
  -1 siblings, 0 replies; 37+ messages in thread
From: Anthony PERARD via @ 2020-11-27 14:52 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: qemu-devel, Gerd Hoffmann, Thomas Huth, Paolo Bonzini,
	Stefano Stabellini, Paul Durrant, xen-devel, Richard Henderson,
	Claudio Fontana, Roman Bolshakov

On Wed, Nov 25, 2020 at 03:56:34PM -0500, Eduardo Habkost wrote:
> The function can be replaced with accel_available("xen").
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Acked-by: Anthony PERARD <anthony.perard@citrix.com>

Thanks,

-- 
Anthony PERARD


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 4/6] xen: Delete xen_available() function
@ 2020-11-27 14:52     ` Anthony PERARD
  0 siblings, 0 replies; 37+ messages in thread
From: Anthony PERARD @ 2020-11-27 14:52 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: qemu-devel, Gerd Hoffmann, Thomas Huth, Paolo Bonzini,
	Stefano Stabellini, Paul Durrant, xen-devel, Richard Henderson,
	Claudio Fontana, Roman Bolshakov

On Wed, Nov 25, 2020 at 03:56:34PM -0500, Eduardo Habkost wrote:
> The function can be replaced with accel_available("xen").
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Acked-by: Anthony PERARD <anthony.perard@citrix.com>

Thanks,

-- 
Anthony PERARD


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 2/6] accel: accel_available() function
  2020-11-27 14:45                 ` Markus Armbruster
@ 2020-11-27 14:58                   ` Claudio Fontana
  2020-11-27 16:47                     ` Markus Armbruster
  0 siblings, 1 reply; 37+ messages in thread
From: Claudio Fontana @ 2020-11-27 14:58 UTC (permalink / raw)
  To: Markus Armbruster
  Cc: Thomas Huth, Eduardo Habkost, Richard Henderson, qemu-devel,
	Roman Bolshakov, Gerd Hoffmann, Paolo Bonzini

On 11/27/20 3:45 PM, Markus Armbruster wrote:
> Claudio Fontana <cfontana@suse.de> writes:
> 
>> On 11/26/20 10:48 PM, Eduardo Habkost wrote:
>>> On Thu, Nov 26, 2020 at 10:06:03PM +0100, Claudio Fontana wrote:
>>>> On 11/26/20 3:25 PM, Paolo Bonzini wrote:
>>>>> On 26/11/20 15:13, Claudio Fontana wrote:
>>>>>> One option I see is simply to document the behavior where
>>>>>> accel_available() is declared in accel.h (ie do not use in fast
>>>>>> path), as well as in accel_find() actually, so that both accel_find()
>>>>>> and accel_available() are avoided in fast path and avoid being called
>>>>>> frequently at runtime.
>>>>>>
>>>>>> Another option could be to remove the allocation completely, and use
>>>>>> for example accel_find(ACCEL_CLASS_NAME("tcg")), or another option
>>>>>> again would be to remove the allocation and use either a fixed buffer
>>>>>> + snprintf, or alloca -like builtin code to use the stack, ...
>>>>>>
>>>>>> Not a big deal, but with a general utility and short name like
>>>>>> accel_available(name) it might be tempting to use this more in the
>>>>>> future?
>>>>>
>>>>> I think it's just that the usecase is not that common.  "Is this 
>>>>> accelerator compiled in the binary" is not something you need after 
>>>>> startup (or if querying the monitor).
>>>>>
>>>>> Paolo
>>>>>
>>>>>
>>>>
>>>> A script that repeatedly uses the QMP interface to query for
>>>> the status could generate fragmentation this way I think.
>>>
>>> Is this a problem?  Today, execution of a "query-kvm" command
>>> calls g_malloc() 37 times.
>>>
>>
>> Not ideal in my view, but not the end of the world either.
> 
> QMP's appetite for malloc is roughly comparable to a pig's for truffles.
> 

:-)

Btw, do we have limits on the maximum size of these objects? I mean, a single QMP command,
a single QEMU object type name, etc?

In this case we could do some overall improvement there, and might even avoid some problems down the road..

Ciao,

Claudio


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH v2 2/6] accel: accel_available() function
  2020-11-27 14:58                   ` Claudio Fontana
@ 2020-11-27 16:47                     ` Markus Armbruster
  0 siblings, 0 replies; 37+ messages in thread
From: Markus Armbruster @ 2020-11-27 16:47 UTC (permalink / raw)
  To: Claudio Fontana
  Cc: Thomas Huth, Eduardo Habkost, Richard Henderson, qemu-devel,
	Roman Bolshakov, Gerd Hoffmann, Paolo Bonzini

Claudio Fontana <cfontana@suse.de> writes:

> On 11/27/20 3:45 PM, Markus Armbruster wrote:
>> Claudio Fontana <cfontana@suse.de> writes:
>> 
>>> On 11/26/20 10:48 PM, Eduardo Habkost wrote:
>>>> On Thu, Nov 26, 2020 at 10:06:03PM +0100, Claudio Fontana wrote:
>>>>> On 11/26/20 3:25 PM, Paolo Bonzini wrote:
>>>>>> On 26/11/20 15:13, Claudio Fontana wrote:
>>>>>>> One option I see is simply to document the behavior where
>>>>>>> accel_available() is declared in accel.h (ie do not use in fast
>>>>>>> path), as well as in accel_find() actually, so that both accel_find()
>>>>>>> and accel_available() are avoided in fast path and avoid being called
>>>>>>> frequently at runtime.
>>>>>>>
>>>>>>> Another option could be to remove the allocation completely, and use
>>>>>>> for example accel_find(ACCEL_CLASS_NAME("tcg")), or another option
>>>>>>> again would be to remove the allocation and use either a fixed buffer
>>>>>>> + snprintf, or alloca -like builtin code to use the stack, ...
>>>>>>>
>>>>>>> Not a big deal, but with a general utility and short name like
>>>>>>> accel_available(name) it might be tempting to use this more in the
>>>>>>> future?
>>>>>>
>>>>>> I think it's just that the usecase is not that common.  "Is this 
>>>>>> accelerator compiled in the binary" is not something you need after 
>>>>>> startup (or if querying the monitor).
>>>>>>
>>>>>> Paolo
>>>>>>
>>>>>>
>>>>>
>>>>> A script that repeatedly uses the QMP interface to query for
>>>>> the status could generate fragmentation this way I think.
>>>>
>>>> Is this a problem?  Today, execution of a "query-kvm" command
>>>> calls g_malloc() 37 times.
>>>>
>>>
>>> Not ideal in my view, but not the end of the world either.
>> 
>> QMP's appetite for malloc is roughly comparable to a pig's for truffles.
>> 
>
> :-)
>
> Btw, do we have limits on the maximum size of these objects? I mean, a single QMP command,
> a single QEMU object type name, etc?
>
> In this case we could do some overall improvement there, and might even avoid some problems down the road..

We have limits, but they are not comprehensive.

The QMP client is trusted.  We don't try to guard against a malicious
QMP client.  We do try to guard against mistakes.

The JSON parser limits token size (in characters), expression size (in
tokens), and expression nesting depth.  This protects against a
malfunctioning QMP client.  The limits are ridiculously generous.

The QMP core limits the number of commands in flight per monitor to a
somewhat parsimonious 8-9 in-band commands, plus one out-of-band
command.  This protects against a QMP client sending commands faster
than we can execute them.

QMP output is buffered without limit.  When a (malfunctioning) QMP
client keeps sending commands without reading their output, QEMU keeps
buffering until it runs out of memory and crashes.



^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2020-11-27 16:52 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-25 20:56 [PATCH v2 0/6] arch_init.c cleanup Eduardo Habkost
2020-11-25 20:56 ` [PATCH v2 1/6] arch_init: Move QEMU_ARCH definitions to cpu.h Eduardo Habkost
2020-11-25 20:56   ` Eduardo Habkost
2020-11-26 12:31   ` Thomas Huth
2020-11-26 12:31     ` Thomas Huth
2020-11-27 11:35   ` Cornelia Huck
2020-11-27 11:35     ` Cornelia Huck
2020-11-25 20:56 ` [PATCH v2 2/6] accel: accel_available() function Eduardo Habkost
2020-11-26  9:14   ` Claudio Fontana
2020-11-26 13:36     ` Eduardo Habkost
2020-11-26 14:13       ` Claudio Fontana
2020-11-26 14:25         ` Paolo Bonzini
2020-11-26 21:06           ` Claudio Fontana
2020-11-26 21:48             ` Eduardo Habkost
2020-11-27  9:04               ` Claudio Fontana
2020-11-27 14:45                 ` Markus Armbruster
2020-11-27 14:58                   ` Claudio Fontana
2020-11-27 16:47                     ` Markus Armbruster
2020-11-27  5:00             ` Paolo Bonzini
2020-11-27 12:08   ` Cornelia Huck
2020-11-25 20:56 ` [PATCH v2 3/6] kvm: Remove kvm_available() function Eduardo Habkost
2020-11-25 20:56   ` Eduardo Habkost
2020-11-27 12:10   ` Cornelia Huck
2020-11-27 12:10     ` Cornelia Huck
2020-11-25 20:56 ` [PATCH v2 4/6] xen: Delete xen_available() function Eduardo Habkost
2020-11-25 20:56   ` Eduardo Habkost
2020-11-27 12:11   ` Cornelia Huck
2020-11-27 12:11     ` Cornelia Huck
2020-11-27 14:52   ` Anthony PERARD via
2020-11-27 14:52     ` Anthony PERARD
2020-11-25 20:56 ` [PATCH v2 5/6] Remove unnecessary usage of arch_init.h Eduardo Habkost
2020-11-25 20:56   ` Eduardo Habkost
2020-11-27 12:23   ` Cornelia Huck
2020-11-27 12:23     ` Cornelia Huck
2020-11-25 20:56 ` [PATCH v2 6/6] Rename arch_init.h to arch_type.h Eduardo Habkost
2020-11-27 12:25   ` Cornelia Huck
2020-11-25 22:23 ` [PATCH v2 0/6] arch_init.c cleanup Roman Bolshakov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.