qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
	"Alexander Graf" <agraf@csgraf.de>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Thomas Huth" <thuth@redhat.com>,
	"Cameron Esfahani" <dirty@apple.com>,
	"Julian Armistead" <julian.armistead@linaro.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [RFC PATCH v2 06/48] accel: Propagate AccelState to AccelClass::init_machine()
Date: Fri, 20 Jun 2025 19:12:59 +0200	[thread overview]
Message-ID: <20250620171342.92678-7-philmd@linaro.org> (raw)
In-Reply-To: <20250620171342.92678-1-philmd@linaro.org>

In order to avoid init_machine() to call current_accel(),
pass AccelState along.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
---
 include/qemu/accel.h        | 2 +-
 accel/accel-system.c        | 2 +-
 accel/hvf/hvf-accel-ops.c   | 2 +-
 accel/kvm/kvm-all.c         | 2 +-
 accel/qtest/qtest.c         | 2 +-
 accel/tcg/tcg-all.c         | 2 +-
 bsd-user/main.c             | 2 +-
 linux-user/main.c           | 2 +-
 target/i386/nvmm/nvmm-all.c | 2 +-
 target/i386/whpx/whpx-all.c | 2 +-
 10 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index 9dea3145429..39b52adc9cb 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -40,7 +40,7 @@ typedef struct AccelClass {
     /* Cached by accel_init_ops_interfaces() when created */
     AccelOpsClass *ops;
 
-    int (*init_machine)(MachineState *ms);
+    int (*init_machine)(MachineState *ms, AccelState *as);
     bool (*cpu_common_realize)(CPUState *cpu, Error **errp);
     void (*cpu_common_unrealize)(CPUState *cpu);
 
diff --git a/accel/accel-system.c b/accel/accel-system.c
index 64bc991b1ce..68d2f28388b 100644
--- a/accel/accel-system.c
+++ b/accel/accel-system.c
@@ -37,7 +37,7 @@ int accel_init_machine(AccelState *accel, MachineState *ms)
     int ret;
     ms->accelerator = accel;
     *(acc->allowed) = true;
-    ret = acc->init_machine(ms);
+    ret = acc->init_machine(ms, accel);
     if (ret < 0) {
         ms->accelerator = NULL;
         *(acc->allowed) = false;
diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c
index b9511103a75..ec82b79b515 100644
--- a/accel/hvf/hvf-accel-ops.c
+++ b/accel/hvf/hvf-accel-ops.c
@@ -321,7 +321,7 @@ static void dummy_signal(int sig)
 
 bool hvf_allowed;
 
-static int hvf_accel_init(MachineState *ms)
+static int hvf_accel_init(MachineState *ms, AccelState *as)
 {
     int x;
     hv_return_t ret;
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index aeb75e1602c..f19b20c9fdb 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -2573,7 +2573,7 @@ static int kvm_setup_dirty_ring(KVMState *s)
     return 0;
 }
 
-static int kvm_init(MachineState *ms)
+static int kvm_init(MachineState *ms, AccelState *as)
 {
     MachineClass *mc = MACHINE_GET_CLASS(ms);
     static const char upgrade_note[] =
diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c
index 92bed9264ce..c5a53ecb6dd 100644
--- a/accel/qtest/qtest.c
+++ b/accel/qtest/qtest.c
@@ -37,7 +37,7 @@ static void qtest_set_virtual_clock(int64_t count)
     qatomic_set_i64(&qtest_clock_counter, count);
 }
 
-static int qtest_init_accel(MachineState *ms)
+static int qtest_init_accel(MachineState *ms, AccelState *as)
 {
     return 0;
 }
diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
index 6e5dc333d59..6c5979861cf 100644
--- a/accel/tcg/tcg-all.c
+++ b/accel/tcg/tcg-all.c
@@ -80,7 +80,7 @@ static void tcg_accel_instance_init(Object *obj)
 
 bool one_insn_per_tb;
 
-static int tcg_init_machine(MachineState *ms)
+static int tcg_init_machine(MachineState *ms, AccelState *as)
 {
     TCGState *s = TCG_STATE(current_accel());
     unsigned max_threads = 1;
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 7c0a059c3ba..ad2032a8b01 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -474,7 +474,7 @@ int main(int argc, char **argv)
                                  opt_one_insn_per_tb, &error_abort);
         object_property_set_int(OBJECT(accel), "tb-size",
                                 opt_tb_size, &error_abort);
-        ac->init_machine(NULL);
+        ac->init_machine(NULL, accel);
     }
 
     /*
diff --git a/linux-user/main.c b/linux-user/main.c
index 5ac5b55dc65..2441e6edc71 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -820,7 +820,7 @@ int main(int argc, char **argv, char **envp)
                                  opt_one_insn_per_tb, &error_abort);
         object_property_set_int(OBJECT(accel), "tb-size",
                                 opt_tb_size, &error_abort);
-        ac->init_machine(NULL);
+        ac->init_machine(NULL, accel);
     }
 
     /*
diff --git a/target/i386/nvmm/nvmm-all.c b/target/i386/nvmm/nvmm-all.c
index f1c6120ccf1..887534d4ca6 100644
--- a/target/i386/nvmm/nvmm-all.c
+++ b/target/i386/nvmm/nvmm-all.c
@@ -1153,7 +1153,7 @@ static struct RAMBlockNotifier nvmm_ram_notifier = {
 /* -------------------------------------------------------------------------- */
 
 static int
-nvmm_accel_init(MachineState *ms)
+nvmm_accel_init(MachineState *ms, AccelState *as)
 {
     int ret, err;
 
diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index cf6d3e4cdd4..238c3b95c6f 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -2505,7 +2505,7 @@ static void whpx_set_kernel_irqchip(Object *obj, Visitor *v,
  * Partition support
  */
 
-static int whpx_accel_init(MachineState *ms)
+static int whpx_accel_init(MachineState *ms, AccelState *as)
 {
     struct whpx_state *whpx;
     int ret;
-- 
2.49.0



  parent reply	other threads:[~2025-06-20 17:15 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-20 17:12 [RFC PATCH v2 00/48] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
2025-06-20 17:12 ` [RFC PATCH v2 01/48] system/runstate: Document qemu_add_vm_change_state_handler() Philippe Mathieu-Daudé
2025-06-22  1:11   ` Richard Henderson
2025-06-20 17:12 ` [RFC PATCH v2 02/48] system/cpus: Defer memory layout changes until vCPUs are realized Philippe Mathieu-Daudé
2025-06-20 17:12 ` [RFC PATCH v2 03/48] system/cpus: Assert interrupt handling is done with BQL locked Philippe Mathieu-Daudé
2025-06-22  1:12   ` Richard Henderson
2025-06-20 17:12 ` [RFC PATCH v2 04/48] accel/kvm: Remove kvm_init_cpu_signals() stub Philippe Mathieu-Daudé
2025-06-22  1:13   ` Richard Henderson
2025-06-20 17:12 ` [RFC PATCH v2 05/48] accel/kvm: Reduce kvm_create_vcpu() declaration scope Philippe Mathieu-Daudé
2025-06-22  1:14   ` Richard Henderson
2025-06-20 17:12 ` Philippe Mathieu-Daudé [this message]
2025-06-20 17:13 ` [RFC PATCH v2 07/48] accel/kvm: Prefer local AccelState over global MachineState::accel Philippe Mathieu-Daudé
2025-06-20 17:13 ` [RFC PATCH v2 08/48] accel/hvf: Re-use QOM allocated state Philippe Mathieu-Daudé
2025-06-20 17:13 ` [RFC PATCH v2 09/48] accel/tcg: Prefer local AccelState over global current_accel() Philippe Mathieu-Daudé
2025-06-20 17:13 ` [RFC PATCH v2 10/48] accel: Pass AccelState argument to gdbstub_supported_sstep_flags() Philippe Mathieu-Daudé
2025-06-22  1:16   ` Richard Henderson
2025-06-20 17:13 ` [RFC PATCH v2 11/48] accel: Move supports_guest_debug() declaration to AccelClass Philippe Mathieu-Daudé
2025-06-22  1:20   ` Richard Henderson
2025-06-20 17:13 ` [RFC PATCH v2 12/48] accel: Move cpus_are_resettable() " Philippe Mathieu-Daudé
2025-06-22  1:22   ` Richard Henderson
2025-06-20 17:13 ` [RFC PATCH v2 13/48] accel: Move cpu_common_[un]realize() declarations to AccelOpsClass Philippe Mathieu-Daudé
2025-06-22  1:24   ` Richard Henderson
2025-06-20 17:13 ` [RFC PATCH v2 14/48] hw/core/machine: Display CPU model name in 'info cpus' command Philippe Mathieu-Daudé
2025-06-20 17:13 ` [RFC PATCH v2 15/48] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
2025-06-22  1:26   ` Richard Henderson
2025-06-20 17:13 ` [RFC PATCH v2 16/48] accel/tcg: Factor tcg_dump_flush_info() out Philippe Mathieu-Daudé
2025-06-22  1:28   ` Richard Henderson
2025-06-20 17:13 ` [RFC PATCH v2 17/48] accel/tcg: Implement get_[vcpu]_stats() Philippe Mathieu-Daudé
2025-06-22  1:28   ` Richard Henderson
2025-06-20 17:13 ` [RFC PATCH v2 18/48] accel/hvf: Implement get_vcpu_stats() Philippe Mathieu-Daudé
2025-06-22  1:30   ` Richard Henderson
2025-06-20 17:13 ` [RFC PATCH v2 19/48] cpus: Document CPUState::vcpu_dirty field Philippe Mathieu-Daudé
2025-06-22  1:30   ` Richard Henderson
2025-06-20 17:13 ` [RFC PATCH v2 20/48] cpus: Rename 'vcpu_dirty' field as negated 'hwaccel_synchronized' Philippe Mathieu-Daudé
2025-06-22  1:35   ` Richard Henderson
2025-06-23 14:13     ` Philippe Mathieu-Daudé
2025-06-20 17:13 ` [RFC PATCH v2 21/48] accel/hvf: Replace @dirty field by generic @hwaccel_synchronized Philippe Mathieu-Daudé
2025-06-20 17:13 ` [RFC PATCH v2 22/48] accel/nvmm: " Philippe Mathieu-Daudé
2025-06-20 17:13 ` [RFC PATCH v2 23/48] accel/whpx: " Philippe Mathieu-Daudé
2025-06-20 17:13 ` [RFC PATCH v2 24/48] accel/kvm: Remove kvm_cpu_synchronize_state() stub Philippe Mathieu-Daudé
2025-06-22  1:35   ` Richard Henderson
2025-06-20 17:13 ` [RFC PATCH v2 25/48] accel/system: Document cpu_synchronize_state() Philippe Mathieu-Daudé
2025-06-22  1:46   ` Richard Henderson
2025-06-20 17:13 ` [RFC PATCH v2 26/48] accel/system: Document cpu_synchronize_state_post_init/reset() Philippe Mathieu-Daudé
2025-06-22  1:46   ` Richard Henderson
2025-06-20 17:13 ` [RFC PATCH v2 27/48] accel/dummy: Factor dummy_thread_precreate() out Philippe Mathieu-Daudé
2025-06-22  1:58   ` Richard Henderson
2025-06-20 17:13 ` [RFC PATCH v2 28/48] accel/dummy: Factor tcg_vcpu_thread_precreate() out Philippe Mathieu-Daudé
2025-06-22  1:49   ` Richard Henderson
2025-06-20 17:13 ` [RFC PATCH v2 29/48] accel: Factor accel_create_vcpu_thread() out Philippe Mathieu-Daudé
2025-06-22  1:56   ` Richard Henderson
2025-06-20 17:13 ` [RFC PATCH v2 30/48] accel: Introduce AccelOpsClass::cpu_thread_routine handler Philippe Mathieu-Daudé
2025-06-22  1:58   ` Richard Henderson
2025-06-20 17:13 ` [RFC PATCH v2 31/48] accel/dummy: Convert to AccelOpsClass::cpu_thread_routine Philippe Mathieu-Daudé
2025-06-22  1:59   ` Richard Henderson
2025-06-20 17:13 ` [RFC PATCH v2 32/48] accel/tcg: " Philippe Mathieu-Daudé
2025-06-22  2:03   ` Richard Henderson
2025-06-20 17:13 ` [RFC PATCH v2 33/48] accel/hvf: " Philippe Mathieu-Daudé
2025-06-22  2:04   ` Richard Henderson
2025-06-20 17:13 ` [RFC PATCH v2 34/48] accel/kvm: " Philippe Mathieu-Daudé
2025-06-22  2:05   ` Richard Henderson
2025-06-20 17:13 ` [RFC PATCH v2 35/48] accel/nvmm: " Philippe Mathieu-Daudé
2025-06-22  2:05   ` Richard Henderson
2025-06-20 17:13 ` [RFC PATCH v2 36/48] accel/whpx: " Philippe Mathieu-Daudé
2025-06-22  2:05   ` Richard Henderson
2025-06-22  2:10   ` Richard Henderson
2025-06-23 12:31     ` Philippe Mathieu-Daudé
2025-06-20 17:13 ` [RFC PATCH v2 37/48] accel/nvmm: Expose nvmm_enabled() to common code Philippe Mathieu-Daudé
2025-06-22  2:06   ` Richard Henderson
2025-06-20 17:13 ` [RFC PATCH v2 38/48] accel/whpx: Expose whpx_enabled() " Philippe Mathieu-Daudé
2025-06-22  2:07   ` Richard Henderson
2025-06-20 17:13 ` [RFC PATCH v2 39/48] accel/system: Introduce hwaccel_enabled() helper Philippe Mathieu-Daudé
2025-06-22  2:08   ` Richard Henderson
2025-06-20 17:13 ` [RFC PATCH v2 40/48] accel: Factor accel_cpu_realize() out Philippe Mathieu-Daudé
2025-06-22  2:14   ` Richard Henderson
2025-06-23 14:16     ` Philippe Mathieu-Daudé
2025-06-20 17:13 ` [RFC PATCH v2 41/48] accel/tcg: Factor tcg_vcpu_init() out for re-use Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250620171342.92678-7-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=agraf@csgraf.de \
    --cc=alex.bennee@linaro.org \
    --cc=dirty@apple.com \
    --cc=edgar.iglesias@gmail.com \
    --cc=julian.armistead@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=pierrick.bouvier@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).