All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Add Xen CpusAccel
@ 2020-10-12 20:07 ` Jason Andryuk
  0 siblings, 0 replies; 15+ messages in thread
From: Jason Andryuk @ 2020-10-12 20:07 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Thomas Huth, Stefano Stabellini, Jason Andryuk,
	Paul Durrant, xen-devel, Anthony Perard, Paolo Bonzini

Xen was left behind when CpusAccel became mandatory and fails the assert
in qemu_init_vcpu().  It relied on the same dummy cpu threads as qtest.
Move the qtest cpu functions to a common location and reuse them for
Xen.

Jason Andryuk (2):
  accel: move qtest CpusAccel functions to a common location
  accel: Add xen CpusAccel using dummy-cpu

 .../qtest-cpus.c => dummy/dummy-cpus.c}       | 22 +++++--------------
 .../qtest-cpus.h => dummy/dummy-cpus.h}       | 10 ++++-----
 accel/dummy/meson.build                       |  7 ++++++
 accel/meson.build                             |  1 +
 accel/qtest/meson.build                       |  1 -
 accel/qtest/qtest.c                           |  7 +++++-
 accel/xen/xen-all.c                           | 10 +++++++++
 7 files changed, 34 insertions(+), 24 deletions(-)
 rename accel/{qtest/qtest-cpus.c => dummy/dummy-cpus.c} (76%)
 rename accel/{qtest/qtest-cpus.h => dummy/dummy-cpus.h} (59%)
 create mode 100644 accel/dummy/meson.build

-- 
2.25.1



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

* [PATCH 0/2] Add Xen CpusAccel
@ 2020-10-12 20:07 ` Jason Andryuk
  0 siblings, 0 replies; 15+ messages in thread
From: Jason Andryuk @ 2020-10-12 20:07 UTC (permalink / raw)
  To: qemu-devel
  Cc: Jason Andryuk, Thomas Huth, Laurent Vivier, Paolo Bonzini,
	Stefano Stabellini, Anthony Perard, Paul Durrant, xen-devel

Xen was left behind when CpusAccel became mandatory and fails the assert
in qemu_init_vcpu().  It relied on the same dummy cpu threads as qtest.
Move the qtest cpu functions to a common location and reuse them for
Xen.

Jason Andryuk (2):
  accel: move qtest CpusAccel functions to a common location
  accel: Add xen CpusAccel using dummy-cpu

 .../qtest-cpus.c => dummy/dummy-cpus.c}       | 22 +++++--------------
 .../qtest-cpus.h => dummy/dummy-cpus.h}       | 10 ++++-----
 accel/dummy/meson.build                       |  7 ++++++
 accel/meson.build                             |  1 +
 accel/qtest/meson.build                       |  1 -
 accel/qtest/qtest.c                           |  7 +++++-
 accel/xen/xen-all.c                           | 10 +++++++++
 7 files changed, 34 insertions(+), 24 deletions(-)
 rename accel/{qtest/qtest-cpus.c => dummy/dummy-cpus.c} (76%)
 rename accel/{qtest/qtest-cpus.h => dummy/dummy-cpus.h} (59%)
 create mode 100644 accel/dummy/meson.build

-- 
2.25.1



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

* [PATCH 1/2] accel: move qtest CpusAccel functions to a common location
  2020-10-12 20:07 ` Jason Andryuk
  (?)
@ 2020-10-12 20:07 ` Jason Andryuk
  2020-10-12 20:23   ` Claudio Fontana
  -1 siblings, 1 reply; 15+ messages in thread
From: Jason Andryuk @ 2020-10-12 20:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier, Paolo Bonzini, Thomas Huth, Jason Andryuk

Move and rename accel/qtest/qtest-cpu.* files to accel/dummy/ so they
can be re-used by Xen.

Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
---
 .../qtest-cpus.c => dummy/dummy-cpus.c}       | 22 +++++--------------
 .../qtest-cpus.h => dummy/dummy-cpus.h}       | 10 ++++-----
 accel/dummy/meson.build                       |  6 +++++
 accel/meson.build                             |  1 +
 accel/qtest/meson.build                       |  1 -
 accel/qtest/qtest.c                           |  7 +++++-
 6 files changed, 23 insertions(+), 24 deletions(-)
 rename accel/{qtest/qtest-cpus.c => dummy/dummy-cpus.c} (76%)
 rename accel/{qtest/qtest-cpus.h => dummy/dummy-cpus.h} (59%)
 create mode 100644 accel/dummy/meson.build

diff --git a/accel/qtest/qtest-cpus.c b/accel/dummy/dummy-cpus.c
similarity index 76%
rename from accel/qtest/qtest-cpus.c
rename to accel/dummy/dummy-cpus.c
index 7c5399ed9d..efade99f03 100644
--- a/accel/qtest/qtest-cpus.c
+++ b/accel/dummy/dummy-cpus.c
@@ -1,5 +1,5 @@
 /*
- * QTest accelerator code
+ * Dummy cpu thread code
  *
  * Copyright IBM, Corp. 2011
  *
@@ -13,21 +13,14 @@
 
 #include "qemu/osdep.h"
 #include "qemu/rcu.h"
-#include "qapi/error.h"
-#include "qemu/module.h"
-#include "qemu/option.h"
-#include "qemu/config-file.h"
-#include "sysemu/accel.h"
-#include "sysemu/qtest.h"
 #include "sysemu/cpus.h"
-#include "sysemu/cpu-timers.h"
 #include "qemu/guest-random.h"
 #include "qemu/main-loop.h"
 #include "hw/core/cpu.h"
 
-#include "qtest-cpus.h"
+#include "dummy-cpus.h"
 
-static void *qtest_cpu_thread_fn(void *arg)
+static void *dummy_cpu_thread_fn(void *arg)
 {
 #ifdef _WIN32
     error_report("qtest is not supported under Windows");
@@ -72,7 +65,7 @@ static void *qtest_cpu_thread_fn(void *arg)
 #endif
 }
 
-static void qtest_start_vcpu_thread(CPUState *cpu)
+void dummy_start_vcpu_thread(CPUState *cpu)
 {
     char thread_name[VCPU_THREAD_NAME_SIZE];
 
@@ -81,11 +74,6 @@ static void qtest_start_vcpu_thread(CPUState *cpu)
     qemu_cond_init(cpu->halt_cond);
     snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/DUMMY",
              cpu->cpu_index);
-    qemu_thread_create(cpu->thread, thread_name, qtest_cpu_thread_fn, cpu,
+    qemu_thread_create(cpu->thread, thread_name, dummy_cpu_thread_fn, cpu,
                        QEMU_THREAD_JOINABLE);
 }
-
-const CpusAccel qtest_cpus = {
-    .create_vcpu_thread = qtest_start_vcpu_thread,
-    .get_virtual_clock = qtest_get_virtual_clock,
-};
diff --git a/accel/qtest/qtest-cpus.h b/accel/dummy/dummy-cpus.h
similarity index 59%
rename from accel/qtest/qtest-cpus.h
rename to accel/dummy/dummy-cpus.h
index 739519a472..a7a0469b17 100644
--- a/accel/qtest/qtest-cpus.h
+++ b/accel/dummy/dummy-cpus.h
@@ -7,11 +7,11 @@
  * See the COPYING file in the top-level directory.
  */
 
-#ifndef QTEST_CPUS_H
-#define QTEST_CPUS_H
+#ifndef DUMMY_CPUS_H
+#define DUMMY_CPUS_H
 
-#include "sysemu/cpus.h"
+#include "qemu/typedefs.h"
 
-extern const CpusAccel qtest_cpus;
+void dummy_start_vcpu_thread(CPUState *);
 
-#endif /* QTEST_CPUS_H */
+#endif /* DUMMY_CPUS_H */
diff --git a/accel/dummy/meson.build b/accel/dummy/meson.build
new file mode 100644
index 0000000000..5fbe27de90
--- /dev/null
+++ b/accel/dummy/meson.build
@@ -0,0 +1,6 @@
+dummy_ss = ss.source_set()
+dummy_ss.add(files(
+  'dummy-cpus.c',
+))
+
+specific_ss.add_all(when: ['CONFIG_SOFTMMU', 'CONFIG_POSIX'], if_true: dummy_ss)
diff --git a/accel/meson.build b/accel/meson.build
index bb00d0fd13..d45a33fb8e 100644
--- a/accel/meson.build
+++ b/accel/meson.build
@@ -1,5 +1,6 @@
 softmmu_ss.add(files('accel.c'))
 
+subdir('dummy')
 subdir('qtest')
 subdir('kvm')
 subdir('tcg')
diff --git a/accel/qtest/meson.build b/accel/qtest/meson.build
index e477cb2ae2..a2f3276459 100644
--- a/accel/qtest/meson.build
+++ b/accel/qtest/meson.build
@@ -1,7 +1,6 @@
 qtest_ss = ss.source_set()
 qtest_ss.add(files(
   'qtest.c',
-  'qtest-cpus.c',
 ))
 
 specific_ss.add_all(when: ['CONFIG_SOFTMMU', 'CONFIG_POSIX'], if_true: qtest_ss)
diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c
index 537e8b449c..ac54bc8f52 100644
--- a/accel/qtest/qtest.c
+++ b/accel/qtest/qtest.c
@@ -25,7 +25,12 @@
 #include "qemu/main-loop.h"
 #include "hw/core/cpu.h"
 
-#include "qtest-cpus.h"
+#include "accel/dummy/dummy-cpus.h"
+
+const CpusAccel qtest_cpus = {
+    .create_vcpu_thread = dummy_start_vcpu_thread,
+    .get_virtual_clock = qtest_get_virtual_clock,
+};
 
 static int qtest_init_accel(MachineState *ms)
 {
-- 
2.25.1



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

* [PATCH 2/2] accel: Add xen CpusAccel using dummy-cpu
  2020-10-12 20:07 ` Jason Andryuk
@ 2020-10-12 20:07   ` Jason Andryuk
  -1 siblings, 0 replies; 15+ messages in thread
From: Jason Andryuk @ 2020-10-12 20:07 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Perard, open list:X86 Xen CPUs, Stefano Stabellini,
	Paul Durrant, Jason Andryuk

Xen was broken by commit 1583a3898853 ("cpus: extract out qtest-specific
code to accel/qtest").  Xen relied on qemu_init_vcpu() calling
qemu_dummy_start_vcpu() in the default case, but that was replaced by
g_assert_not_reached().

Add a minimal "CpusAccel" for xen using the dummy-cpu implementation
used by qtest.

Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
---
 accel/dummy/meson.build |  1 +
 accel/xen/xen-all.c     | 10 ++++++++++
 2 files changed, 11 insertions(+)

diff --git a/accel/dummy/meson.build b/accel/dummy/meson.build
index 5fbe27de90..cdff0ba746 100644
--- a/accel/dummy/meson.build
+++ b/accel/dummy/meson.build
@@ -4,3 +4,4 @@ dummy_ss.add(files(
 ))
 
 specific_ss.add_all(when: ['CONFIG_SOFTMMU', 'CONFIG_POSIX'], if_true: dummy_ss)
+specific_ss.add_all(when: ['CONFIG_XEN'], if_true: dummy_ss)
diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c
index 60b971d0a8..2d243c58d4 100644
--- a/accel/xen/xen-all.c
+++ b/accel/xen/xen-all.c
@@ -16,12 +16,15 @@
 #include "hw/xen/xen_pt.h"
 #include "chardev/char.h"
 #include "sysemu/accel.h"
+#include "sysemu/cpus.h"
 #include "sysemu/xen.h"
 #include "sysemu/runstate.h"
 #include "migration/misc.h"
 #include "migration/global_state.h"
 #include "hw/boards.h"
 
+#include "accel/dummy/dummy-cpus.h"
+
 //#define DEBUG_XEN
 
 #ifdef DEBUG_XEN
@@ -153,6 +156,10 @@ static void xen_setup_post(MachineState *ms, AccelState *accel)
     }
 }
 
+const CpusAccel xen_cpus = {
+    .create_vcpu_thread = dummy_start_vcpu_thread,
+};
+
 static int xen_init(MachineState *ms)
 {
     MachineClass *mc = MACHINE_GET_CLASS(ms);
@@ -180,6 +187,9 @@ static int xen_init(MachineState *ms)
      * opt out of system RAM being allocated by generic code
      */
     mc->default_ram_id = NULL;
+
+    cpus_register_accel(&xen_cpus);
+
     return 0;
 }
 
-- 
2.25.1



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

* [PATCH 2/2] accel: Add xen CpusAccel using dummy-cpu
@ 2020-10-12 20:07   ` Jason Andryuk
  0 siblings, 0 replies; 15+ messages in thread
From: Jason Andryuk @ 2020-10-12 20:07 UTC (permalink / raw)
  To: qemu-devel
  Cc: Jason Andryuk, Stefano Stabellini, Anthony Perard, Paul Durrant,
	open list:X86 Xen CPUs

Xen was broken by commit 1583a3898853 ("cpus: extract out qtest-specific
code to accel/qtest").  Xen relied on qemu_init_vcpu() calling
qemu_dummy_start_vcpu() in the default case, but that was replaced by
g_assert_not_reached().

Add a minimal "CpusAccel" for xen using the dummy-cpu implementation
used by qtest.

Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
---
 accel/dummy/meson.build |  1 +
 accel/xen/xen-all.c     | 10 ++++++++++
 2 files changed, 11 insertions(+)

diff --git a/accel/dummy/meson.build b/accel/dummy/meson.build
index 5fbe27de90..cdff0ba746 100644
--- a/accel/dummy/meson.build
+++ b/accel/dummy/meson.build
@@ -4,3 +4,4 @@ dummy_ss.add(files(
 ))
 
 specific_ss.add_all(when: ['CONFIG_SOFTMMU', 'CONFIG_POSIX'], if_true: dummy_ss)
+specific_ss.add_all(when: ['CONFIG_XEN'], if_true: dummy_ss)
diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c
index 60b971d0a8..2d243c58d4 100644
--- a/accel/xen/xen-all.c
+++ b/accel/xen/xen-all.c
@@ -16,12 +16,15 @@
 #include "hw/xen/xen_pt.h"
 #include "chardev/char.h"
 #include "sysemu/accel.h"
+#include "sysemu/cpus.h"
 #include "sysemu/xen.h"
 #include "sysemu/runstate.h"
 #include "migration/misc.h"
 #include "migration/global_state.h"
 #include "hw/boards.h"
 
+#include "accel/dummy/dummy-cpus.h"
+
 //#define DEBUG_XEN
 
 #ifdef DEBUG_XEN
@@ -153,6 +156,10 @@ static void xen_setup_post(MachineState *ms, AccelState *accel)
     }
 }
 
+const CpusAccel xen_cpus = {
+    .create_vcpu_thread = dummy_start_vcpu_thread,
+};
+
 static int xen_init(MachineState *ms)
 {
     MachineClass *mc = MACHINE_GET_CLASS(ms);
@@ -180,6 +187,9 @@ static int xen_init(MachineState *ms)
      * opt out of system RAM being allocated by generic code
      */
     mc->default_ram_id = NULL;
+
+    cpus_register_accel(&xen_cpus);
+
     return 0;
 }
 
-- 
2.25.1



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

* Re: [PATCH 0/2] Add Xen CpusAccel
  2020-10-12 20:07 ` Jason Andryuk
@ 2020-10-12 20:16   ` Claudio Fontana
  -1 siblings, 0 replies; 15+ messages in thread
From: Claudio Fontana @ 2020-10-12 20:16 UTC (permalink / raw)
  To: Jason Andryuk
  Cc: Laurent Vivier, Thomas Huth, Stefano Stabellini, Paul Durrant,
	qemu-devel, Paolo Bonzini, Anthony Perard, xen-devel

On 10/12/20 10:07 PM, Jason Andryuk wrote:
> Xen was left behind when CpusAccel became mandatory and fails the assert
> in qemu_init_vcpu().  It relied on the same dummy cpu threads as qtest.
> Move the qtest cpu functions to a common location and reuse them for
> Xen.
> 
> Jason Andryuk (2):
>   accel: move qtest CpusAccel functions to a common location
>   accel: Add xen CpusAccel using dummy-cpu
> 
>  .../qtest-cpus.c => dummy/dummy-cpus.c}       | 22 +++++--------------
>  .../qtest-cpus.h => dummy/dummy-cpus.h}       | 10 ++++-----
>  accel/dummy/meson.build                       |  7 ++++++
>  accel/meson.build                             |  1 +
>  accel/qtest/meson.build                       |  1 -
>  accel/qtest/qtest.c                           |  7 +++++-
>  accel/xen/xen-all.c                           | 10 +++++++++
>  7 files changed, 34 insertions(+), 24 deletions(-)
>  rename accel/{qtest/qtest-cpus.c => dummy/dummy-cpus.c} (76%)
>  rename accel/{qtest/qtest-cpus.h => dummy/dummy-cpus.h} (59%)
>  create mode 100644 accel/dummy/meson.build
> 

Yep, forgot completely, sorry.

Acked-by: Claudio Fontana <cfontana@suse.de>




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

* Re: [PATCH 0/2] Add Xen CpusAccel
@ 2020-10-12 20:16   ` Claudio Fontana
  0 siblings, 0 replies; 15+ messages in thread
From: Claudio Fontana @ 2020-10-12 20:16 UTC (permalink / raw)
  To: Jason Andryuk
  Cc: qemu-devel, Laurent Vivier, Thomas Huth, Stefano Stabellini,
	Paul Durrant, xen-devel, Anthony Perard, Paolo Bonzini

On 10/12/20 10:07 PM, Jason Andryuk wrote:
> Xen was left behind when CpusAccel became mandatory and fails the assert
> in qemu_init_vcpu().  It relied on the same dummy cpu threads as qtest.
> Move the qtest cpu functions to a common location and reuse them for
> Xen.
> 
> Jason Andryuk (2):
>   accel: move qtest CpusAccel functions to a common location
>   accel: Add xen CpusAccel using dummy-cpu
> 
>  .../qtest-cpus.c => dummy/dummy-cpus.c}       | 22 +++++--------------
>  .../qtest-cpus.h => dummy/dummy-cpus.h}       | 10 ++++-----
>  accel/dummy/meson.build                       |  7 ++++++
>  accel/meson.build                             |  1 +
>  accel/qtest/meson.build                       |  1 -
>  accel/qtest/qtest.c                           |  7 +++++-
>  accel/xen/xen-all.c                           | 10 +++++++++
>  7 files changed, 34 insertions(+), 24 deletions(-)
>  rename accel/{qtest/qtest-cpus.c => dummy/dummy-cpus.c} (76%)
>  rename accel/{qtest/qtest-cpus.h => dummy/dummy-cpus.h} (59%)
>  create mode 100644 accel/dummy/meson.build
> 

Yep, forgot completely, sorry.

Acked-by: Claudio Fontana <cfontana@suse.de>




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

* Re: [PATCH 1/2] accel: move qtest CpusAccel functions to a common location
  2020-10-12 20:07 ` [PATCH 1/2] accel: move qtest CpusAccel functions to a common location Jason Andryuk
@ 2020-10-12 20:23   ` Claudio Fontana
  2020-10-12 20:30     ` Paolo Bonzini
  2020-10-12 20:40     ` Jason Andryuk
  0 siblings, 2 replies; 15+ messages in thread
From: Claudio Fontana @ 2020-10-12 20:23 UTC (permalink / raw)
  To: Jason Andryuk, qemu-devel; +Cc: Laurent Vivier, Paolo Bonzini, Thomas Huth

On 10/12/20 10:07 PM, Jason Andryuk wrote:
> Move and rename accel/qtest/qtest-cpu.* files to accel/dummy/ so they
> can be re-used by Xen.
> 
> Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
> ---
>  .../qtest-cpus.c => dummy/dummy-cpus.c}       | 22 +++++--------------
>  .../qtest-cpus.h => dummy/dummy-cpus.h}       | 10 ++++-----
>  accel/dummy/meson.build                       |  6 +++++
>  accel/meson.build                             |  1 +
>  accel/qtest/meson.build                       |  1 -
>  accel/qtest/qtest.c                           |  7 +++++-
>  6 files changed, 23 insertions(+), 24 deletions(-)
>  rename accel/{qtest/qtest-cpus.c => dummy/dummy-cpus.c} (76%)
>  rename accel/{qtest/qtest-cpus.h => dummy/dummy-cpus.h} (59%)
>  create mode 100644 accel/dummy/meson.build
> 
> diff --git a/accel/qtest/qtest-cpus.c b/accel/dummy/dummy-cpus.c
> similarity index 76%
> rename from accel/qtest/qtest-cpus.c
> rename to accel/dummy/dummy-cpus.c
> index 7c5399ed9d..efade99f03 100644
> --- a/accel/qtest/qtest-cpus.c
> +++ b/accel/dummy/dummy-cpus.c
> @@ -1,5 +1,5 @@
>  /*
> - * QTest accelerator code
> + * Dummy cpu thread code
>   *
>   * Copyright IBM, Corp. 2011
>   *
> @@ -13,21 +13,14 @@
>  
>  #include "qemu/osdep.h"
>  #include "qemu/rcu.h"
> -#include "qapi/error.h"
> -#include "qemu/module.h"
> -#include "qemu/option.h"
> -#include "qemu/config-file.h"
> -#include "sysemu/accel.h"
> -#include "sysemu/qtest.h"
>  #include "sysemu/cpus.h"
> -#include "sysemu/cpu-timers.h"
>  #include "qemu/guest-random.h"
>  #include "qemu/main-loop.h"
>  #include "hw/core/cpu.h"
>  
> -#include "qtest-cpus.h"
> +#include "dummy-cpus.h"
>  
> -static void *qtest_cpu_thread_fn(void *arg)
> +static void *dummy_cpu_thread_fn(void *arg)
>  {
>  #ifdef _WIN32
>      error_report("qtest is not supported under Windows");

I wonder if this should be changed to "dummy cpu thread is not supported under Windows".

Does not matter probably.

> @@ -72,7 +65,7 @@ static void *qtest_cpu_thread_fn(void *arg)
>  #endif
>  }
>  
> -static void qtest_start_vcpu_thread(CPUState *cpu)
> +void dummy_start_vcpu_thread(CPUState *cpu)
>  {
>      char thread_name[VCPU_THREAD_NAME_SIZE];
>  
> @@ -81,11 +74,6 @@ static void qtest_start_vcpu_thread(CPUState *cpu)
>      qemu_cond_init(cpu->halt_cond);
>      snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/DUMMY",
>               cpu->cpu_index);
> -    qemu_thread_create(cpu->thread, thread_name, qtest_cpu_thread_fn, cpu,
> +    qemu_thread_create(cpu->thread, thread_name, dummy_cpu_thread_fn, cpu,
>                         QEMU_THREAD_JOINABLE);
>  }
> -
> -const CpusAccel qtest_cpus = {
> -    .create_vcpu_thread = qtest_start_vcpu_thread,
> -    .get_virtual_clock = qtest_get_virtual_clock,
> -};
> diff --git a/accel/qtest/qtest-cpus.h b/accel/dummy/dummy-cpus.h
> similarity index 59%
> rename from accel/qtest/qtest-cpus.h
> rename to accel/dummy/dummy-cpus.h
> index 739519a472..a7a0469b17 100644
> --- a/accel/qtest/qtest-cpus.h
> +++ b/accel/dummy/dummy-cpus.h
> @@ -7,11 +7,11 @@
>   * See the COPYING file in the top-level directory.
>   */
>  
> -#ifndef QTEST_CPUS_H
> -#define QTEST_CPUS_H
> +#ifndef DUMMY_CPUS_H
> +#define DUMMY_CPUS_H
>  
> -#include "sysemu/cpus.h"
> +#include "qemu/typedefs.h"
>  
> -extern const CpusAccel qtest_cpus;
> +void dummy_start_vcpu_thread(CPUState *);
>  
> -#endif /* QTEST_CPUS_H */
> +#endif /* DUMMY_CPUS_H */
> diff --git a/accel/dummy/meson.build b/accel/dummy/meson.build
> new file mode 100644
> index 0000000000..5fbe27de90
> --- /dev/null
> +++ b/accel/dummy/meson.build
> @@ -0,0 +1,6 @@
> +dummy_ss = ss.source_set()
> +dummy_ss.add(files(
> +  'dummy-cpus.c',
> +))
> +
> +specific_ss.add_all(when: ['CONFIG_SOFTMMU', 'CONFIG_POSIX'], if_true: dummy_ss)
> diff --git a/accel/meson.build b/accel/meson.build
> index bb00d0fd13..d45a33fb8e 100644
> --- a/accel/meson.build
> +++ b/accel/meson.build
> @@ -1,5 +1,6 @@
>  softmmu_ss.add(files('accel.c'))
>  
> +subdir('dummy')
>  subdir('qtest')
>  subdir('kvm')
>  subdir('tcg')
> diff --git a/accel/qtest/meson.build b/accel/qtest/meson.build
> index e477cb2ae2..a2f3276459 100644
> --- a/accel/qtest/meson.build
> +++ b/accel/qtest/meson.build
> @@ -1,7 +1,6 @@
>  qtest_ss = ss.source_set()
>  qtest_ss.add(files(
>    'qtest.c',
> -  'qtest-cpus.c',
>  ))
>  
>  specific_ss.add_all(when: ['CONFIG_SOFTMMU', 'CONFIG_POSIX'], if_true: qtest_ss)
> diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c
> index 537e8b449c..ac54bc8f52 100644
> --- a/accel/qtest/qtest.c
> +++ b/accel/qtest/qtest.c
> @@ -25,7 +25,12 @@
>  #include "qemu/main-loop.h"
>  #include "hw/core/cpu.h"
>  
> -#include "qtest-cpus.h"
> +#include "accel/dummy/dummy-cpus.h"

this is a bit strange from my perspective, does not look right.

Maybe this dummy cpu prototype should be somewhere in include/ ,
like include/sysemu/cpus.h or even better include/sysemu/accel.h

> +
> +const CpusAccel qtest_cpus = {
> +    .create_vcpu_thread = dummy_start_vcpu_thread,
> +    .get_virtual_clock = qtest_get_virtual_clock,
> +};
>  
>  static int qtest_init_accel(MachineState *ms)
>  {
> 



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

* Re: [PATCH 2/2] accel: Add xen CpusAccel using dummy-cpu
  2020-10-12 20:07   ` Jason Andryuk
  (?)
@ 2020-10-12 20:25   ` Claudio Fontana
  -1 siblings, 0 replies; 15+ messages in thread
From: Claudio Fontana @ 2020-10-12 20:25 UTC (permalink / raw)
  To: Jason Andryuk, qemu-devel
  Cc: Anthony Perard, open list:X86 Xen CPUs, Stefano Stabellini, Paul Durrant

On 10/12/20 10:07 PM, Jason Andryuk wrote:
> Xen was broken by commit 1583a3898853 ("cpus: extract out qtest-specific
> code to accel/qtest").  Xen relied on qemu_init_vcpu() calling
> qemu_dummy_start_vcpu() in the default case, but that was replaced by
> g_assert_not_reached().
> 
> Add a minimal "CpusAccel" for xen using the dummy-cpu implementation
> used by qtest.
> 
> Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
> ---
>  accel/dummy/meson.build |  1 +
>  accel/xen/xen-all.c     | 10 ++++++++++
>  2 files changed, 11 insertions(+)
> 
> diff --git a/accel/dummy/meson.build b/accel/dummy/meson.build
> index 5fbe27de90..cdff0ba746 100644
> --- a/accel/dummy/meson.build
> +++ b/accel/dummy/meson.build
> @@ -4,3 +4,4 @@ dummy_ss.add(files(
>  ))
>  
>  specific_ss.add_all(when: ['CONFIG_SOFTMMU', 'CONFIG_POSIX'], if_true: dummy_ss)
> +specific_ss.add_all(when: ['CONFIG_XEN'], if_true: dummy_ss)
> diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c
> index 60b971d0a8..2d243c58d4 100644
> --- a/accel/xen/xen-all.c
> +++ b/accel/xen/xen-all.c
> @@ -16,12 +16,15 @@
>  #include "hw/xen/xen_pt.h"
>  #include "chardev/char.h"
>  #include "sysemu/accel.h"
> +#include "sysemu/cpus.h"
>  #include "sysemu/xen.h"
>  #include "sysemu/runstate.h"
>  #include "migration/misc.h"
>  #include "migration/global_state.h"
>  #include "hw/boards.h"
>  
> +#include "accel/dummy/dummy-cpus.h"

it seems this should be in includes/sysemu/accel.h or so.

> +
>  //#define DEBUG_XEN
>  
>  #ifdef DEBUG_XEN
> @@ -153,6 +156,10 @@ static void xen_setup_post(MachineState *ms, AccelState *accel)
>      }
>  }
>  
> +const CpusAccel xen_cpus = {
> +    .create_vcpu_thread = dummy_start_vcpu_thread,
> +};
> +
>  static int xen_init(MachineState *ms)
>  {
>      MachineClass *mc = MACHINE_GET_CLASS(ms);
> @@ -180,6 +187,9 @@ static int xen_init(MachineState *ms)
>       * opt out of system RAM being allocated by generic code
>       */
>      mc->default_ram_id = NULL;
> +
> +    cpus_register_accel(&xen_cpus);
> +
>      return 0;
>  }
>  
> 

Ciao,

Claudio


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

* Re: [PATCH 1/2] accel: move qtest CpusAccel functions to a common location
  2020-10-12 20:23   ` Claudio Fontana
@ 2020-10-12 20:30     ` Paolo Bonzini
  2020-10-12 20:38       ` Jason Andryuk
  2020-10-12 20:40     ` Jason Andryuk
  1 sibling, 1 reply; 15+ messages in thread
From: Paolo Bonzini @ 2020-10-12 20:30 UTC (permalink / raw)
  To: Claudio Fontana, Jason Andryuk, qemu-devel; +Cc: Laurent Vivier, Thomas Huth

On 12/10/20 22:23, Claudio Fontana wrote:
> On 10/12/20 10:07 PM, Jason Andryuk wrote:
>> Move and rename accel/qtest/qtest-cpu.* files to accel/dummy/ so they
>> can be re-used by Xen.
>>
>> Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
>> ---
>>  .../qtest-cpus.c => dummy/dummy-cpus.c}       | 22 +++++--------------
>>  .../qtest-cpus.h => dummy/dummy-cpus.h}       | 10 ++++-----
>>  accel/dummy/meson.build                       |  6 +++++
>>  accel/meson.build                             |  1 +
>>  accel/qtest/meson.build                       |  1 -
>>  accel/qtest/qtest.c                           |  7 +++++-
>>  6 files changed, 23 insertions(+), 24 deletions(-)
>>  rename accel/{qtest/qtest-cpus.c => dummy/dummy-cpus.c} (76%)
>>  rename accel/{qtest/qtest-cpus.h => dummy/dummy-cpus.h} (59%)
>>  create mode 100644 accel/dummy/meson.build

Maybe accel/dummy-cpus.c, no need to add a new directory.

>> diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c
>> index 537e8b449c..ac54bc8f52 100644
>> --- a/accel/qtest/qtest.c
>> +++ b/accel/qtest/qtest.c
>> @@ -25,7 +25,12 @@
>>  #include "qemu/main-loop.h"
>>  #include "hw/core/cpu.h"
>>  
>> -#include "qtest-cpus.h"
>> +#include "accel/dummy/dummy-cpus.h"
> 
> this is a bit strange from my perspective, does not look right.
> 
> Maybe this dummy cpu prototype should be somewhere in include/ ,
> like include/sysemu/cpus.h or even better include/sysemu/accel.h

Yes, it should be in include/sysemu/cpus.h.

Paolo

>> +
>> +const CpusAccel qtest_cpus = {
>> +    .create_vcpu_thread = dummy_start_vcpu_thread,
>> +    .get_virtual_clock = qtest_get_virtual_clock,
>> +};
>>  
>>  static int qtest_init_accel(MachineState *ms)
>>  {
>>
> 



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

* Re: [PATCH 1/2] accel: move qtest CpusAccel functions to a common location
  2020-10-12 20:30     ` Paolo Bonzini
@ 2020-10-12 20:38       ` Jason Andryuk
  0 siblings, 0 replies; 15+ messages in thread
From: Jason Andryuk @ 2020-10-12 20:38 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Laurent Vivier, Thomas Huth, Claudio Fontana, QEMU

On Mon, Oct 12, 2020 at 4:30 PM Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> On 12/10/20 22:23, Claudio Fontana wrote:
> > On 10/12/20 10:07 PM, Jason Andryuk wrote:
> >> Move and rename accel/qtest/qtest-cpu.* files to accel/dummy/ so they
> >> can be re-used by Xen.
> >>
> >> Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
> >> ---
> >>  .../qtest-cpus.c => dummy/dummy-cpus.c}       | 22 +++++--------------
> >>  .../qtest-cpus.h => dummy/dummy-cpus.h}       | 10 ++++-----
> >>  accel/dummy/meson.build                       |  6 +++++
> >>  accel/meson.build                             |  1 +
> >>  accel/qtest/meson.build                       |  1 -
> >>  accel/qtest/qtest.c                           |  7 +++++-
> >>  6 files changed, 23 insertions(+), 24 deletions(-)
> >>  rename accel/{qtest/qtest-cpus.c => dummy/dummy-cpus.c} (76%)
> >>  rename accel/{qtest/qtest-cpus.h => dummy/dummy-cpus.h} (59%)
> >>  create mode 100644 accel/dummy/meson.build
>
> Maybe accel/dummy-cpus.c, no need to add a new directory.

Sure.

> >> diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c
> >> index 537e8b449c..ac54bc8f52 100644
> >> --- a/accel/qtest/qtest.c
> >> +++ b/accel/qtest/qtest.c
> >> @@ -25,7 +25,12 @@
> >>  #include "qemu/main-loop.h"
> >>  #include "hw/core/cpu.h"
> >>
> >> -#include "qtest-cpus.h"
> >> +#include "accel/dummy/dummy-cpus.h"
> >
> > this is a bit strange from my perspective, does not look right.

Yeah, I didn't really know where to put it.

> > Maybe this dummy cpu prototype should be somewhere in include/ ,
> > like include/sysemu/cpus.h or even better include/sysemu/accel.h
>
> Yes, it should be in include/sysemu/cpus.h.

Sounds good.

Thanks,
Jason


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

* Re: [PATCH 1/2] accel: move qtest CpusAccel functions to a common location
  2020-10-12 20:23   ` Claudio Fontana
  2020-10-12 20:30     ` Paolo Bonzini
@ 2020-10-12 20:40     ` Jason Andryuk
  2020-10-12 20:44       ` Paolo Bonzini
  1 sibling, 1 reply; 15+ messages in thread
From: Jason Andryuk @ 2020-10-12 20:40 UTC (permalink / raw)
  To: Claudio Fontana; +Cc: Laurent Vivier, Paolo Bonzini, Thomas Huth, QEMU

On Mon, Oct 12, 2020 at 4:23 PM Claudio Fontana <cfontana@suse.de> wrote:
>
> On 10/12/20 10:07 PM, Jason Andryuk wrote:
> > Move and rename accel/qtest/qtest-cpu.* files to accel/dummy/ so they
> > can be re-used by Xen.
> >
> > Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
> > ---
> >  .../qtest-cpus.c => dummy/dummy-cpus.c}       | 22 +++++--------------
> >  .../qtest-cpus.h => dummy/dummy-cpus.h}       | 10 ++++-----
> >  accel/dummy/meson.build                       |  6 +++++
> >  accel/meson.build                             |  1 +
> >  accel/qtest/meson.build                       |  1 -
> >  accel/qtest/qtest.c                           |  7 +++++-
> >  6 files changed, 23 insertions(+), 24 deletions(-)
> >  rename accel/{qtest/qtest-cpus.c => dummy/dummy-cpus.c} (76%)
> >  rename accel/{qtest/qtest-cpus.h => dummy/dummy-cpus.h} (59%)
> >  create mode 100644 accel/dummy/meson.build
> >
> > diff --git a/accel/qtest/qtest-cpus.c b/accel/dummy/dummy-cpus.c
> > similarity index 76%
> > rename from accel/qtest/qtest-cpus.c
> > rename to accel/dummy/dummy-cpus.c
> > index 7c5399ed9d..efade99f03 100644
> > --- a/accel/qtest/qtest-cpus.c
> > +++ b/accel/dummy/dummy-cpus.c
> > @@ -1,5 +1,5 @@
> >  /*
> > - * QTest accelerator code
> > + * Dummy cpu thread code
> >   *
> >   * Copyright IBM, Corp. 2011
> >   *
> > @@ -13,21 +13,14 @@
> >
> >  #include "qemu/osdep.h"
> >  #include "qemu/rcu.h"
> > -#include "qapi/error.h"
> > -#include "qemu/module.h"
> > -#include "qemu/option.h"
> > -#include "qemu/config-file.h"
> > -#include "sysemu/accel.h"
> > -#include "sysemu/qtest.h"
> >  #include "sysemu/cpus.h"
> > -#include "sysemu/cpu-timers.h"
> >  #include "qemu/guest-random.h"
> >  #include "qemu/main-loop.h"
> >  #include "hw/core/cpu.h"
> >
> > -#include "qtest-cpus.h"
> > +#include "dummy-cpus.h"
> >
> > -static void *qtest_cpu_thread_fn(void *arg)
> > +static void *dummy_cpu_thread_fn(void *arg)
> >  {
> >  #ifdef _WIN32
> >      error_report("qtest is not supported under Windows");
>
> I wonder if this should be changed to "dummy cpu thread is not supported under Windows".
>
> Does not matter probably.

I left it since I was just moving the file.  But...

> > diff --git a/accel/dummy/meson.build b/accel/dummy/meson.build
> > new file mode 100644
> > index 0000000000..5fbe27de90
> > --- /dev/null
> > +++ b/accel/dummy/meson.build
> > @@ -0,0 +1,6 @@
> > +dummy_ss = ss.source_set()
> > +dummy_ss.add(files(
> > +  'dummy-cpus.c',
> > +))
> > +
> > +specific_ss.add_all(when: ['CONFIG_SOFTMMU', 'CONFIG_POSIX'], if_true: dummy_ss)

...  I don't really know meson, but this file is guarded by
CONFIG_POSIX?  If that's true, then this ifdef can just go away.

Regards,
Jason


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

* Re: [PATCH 1/2] accel: move qtest CpusAccel functions to a common location
  2020-10-12 20:40     ` Jason Andryuk
@ 2020-10-12 20:44       ` Paolo Bonzini
  0 siblings, 0 replies; 15+ messages in thread
From: Paolo Bonzini @ 2020-10-12 20:44 UTC (permalink / raw)
  To: Jason Andryuk, Claudio Fontana; +Cc: Laurent Vivier, Thomas Huth, QEMU

On 12/10/20 22:40, Jason Andryuk wrote:
>>> +specific_ss.add_all(when: ['CONFIG_SOFTMMU', 'CONFIG_POSIX'], if_true: dummy_ss)
> ...  I don't really know meson, but this file is guarded by
> CONFIG_POSIX?  If that's true, then this ifdef can just go away.

Yes, it's redundant since cpus.c was split.

Paolo



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

* Re: [PATCH 0/2] Add Xen CpusAccel
  2020-10-12 20:16   ` Claudio Fontana
@ 2020-10-13  8:42     ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 15+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-10-13  8:42 UTC (permalink / raw)
  To: Claudio Fontana, Jason Andryuk
  Cc: Laurent Vivier, Thomas Huth, Stefano Stabellini, Paul Durrant,
	qemu-devel, xen-devel, Anthony Perard, Paolo Bonzini

On 10/12/20 10:16 PM, Claudio Fontana wrote:
> On 10/12/20 10:07 PM, Jason Andryuk wrote:
>> Xen was left behind when CpusAccel became mandatory and fails the assert
>> in qemu_init_vcpu().  It relied on the same dummy cpu threads as qtest.
>> Move the qtest cpu functions to a common location and reuse them for
>> Xen.
>>
>> Jason Andryuk (2):
>>    accel: move qtest CpusAccel functions to a common location
>>    accel: Add xen CpusAccel using dummy-cpu
>>
>>   .../qtest-cpus.c => dummy/dummy-cpus.c}       | 22 +++++--------------
>>   .../qtest-cpus.h => dummy/dummy-cpus.h}       | 10 ++++-----
>>   accel/dummy/meson.build                       |  7 ++++++
>>   accel/meson.build                             |  1 +
>>   accel/qtest/meson.build                       |  1 -
>>   accel/qtest/qtest.c                           |  7 +++++-
>>   accel/xen/xen-all.c                           | 10 +++++++++
>>   7 files changed, 34 insertions(+), 24 deletions(-)
>>   rename accel/{qtest/qtest-cpus.c => dummy/dummy-cpus.c} (76%)
>>   rename accel/{qtest/qtest-cpus.h => dummy/dummy-cpus.h} (59%)
>>   create mode 100644 accel/dummy/meson.build
>>
> 
> Yep, forgot completely, sorry.

Good opportunity to ask the Xen folks to add testing
to our Gitlab CI, so this doesn't happen again :)

> 
> Acked-by: Claudio Fontana <cfontana@suse.de>
> 
> 
> 



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

* Re: [PATCH 0/2] Add Xen CpusAccel
@ 2020-10-13  8:42     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 15+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-10-13  8:42 UTC (permalink / raw)
  To: Claudio Fontana, Jason Andryuk
  Cc: Laurent Vivier, Thomas Huth, Stefano Stabellini, Paul Durrant,
	qemu-devel, Paolo Bonzini, Anthony Perard, xen-devel

On 10/12/20 10:16 PM, Claudio Fontana wrote:
> On 10/12/20 10:07 PM, Jason Andryuk wrote:
>> Xen was left behind when CpusAccel became mandatory and fails the assert
>> in qemu_init_vcpu().  It relied on the same dummy cpu threads as qtest.
>> Move the qtest cpu functions to a common location and reuse them for
>> Xen.
>>
>> Jason Andryuk (2):
>>    accel: move qtest CpusAccel functions to a common location
>>    accel: Add xen CpusAccel using dummy-cpu
>>
>>   .../qtest-cpus.c => dummy/dummy-cpus.c}       | 22 +++++--------------
>>   .../qtest-cpus.h => dummy/dummy-cpus.h}       | 10 ++++-----
>>   accel/dummy/meson.build                       |  7 ++++++
>>   accel/meson.build                             |  1 +
>>   accel/qtest/meson.build                       |  1 -
>>   accel/qtest/qtest.c                           |  7 +++++-
>>   accel/xen/xen-all.c                           | 10 +++++++++
>>   7 files changed, 34 insertions(+), 24 deletions(-)
>>   rename accel/{qtest/qtest-cpus.c => dummy/dummy-cpus.c} (76%)
>>   rename accel/{qtest/qtest-cpus.h => dummy/dummy-cpus.h} (59%)
>>   create mode 100644 accel/dummy/meson.build
>>
> 
> Yep, forgot completely, sorry.

Good opportunity to ask the Xen folks to add testing
to our Gitlab CI, so this doesn't happen again :)

> 
> Acked-by: Claudio Fontana <cfontana@suse.de>
> 
> 
> 



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

end of thread, other threads:[~2020-10-13  8:45 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-12 20:07 [PATCH 0/2] Add Xen CpusAccel Jason Andryuk
2020-10-12 20:07 ` Jason Andryuk
2020-10-12 20:07 ` [PATCH 1/2] accel: move qtest CpusAccel functions to a common location Jason Andryuk
2020-10-12 20:23   ` Claudio Fontana
2020-10-12 20:30     ` Paolo Bonzini
2020-10-12 20:38       ` Jason Andryuk
2020-10-12 20:40     ` Jason Andryuk
2020-10-12 20:44       ` Paolo Bonzini
2020-10-12 20:07 ` [PATCH 2/2] accel: Add xen CpusAccel using dummy-cpu Jason Andryuk
2020-10-12 20:07   ` Jason Andryuk
2020-10-12 20:25   ` Claudio Fontana
2020-10-12 20:16 ` [PATCH 0/2] Add Xen CpusAccel Claudio Fontana
2020-10-12 20:16   ` Claudio Fontana
2020-10-13  8:42   ` Philippe Mathieu-Daudé
2020-10-13  8:42     ` Philippe Mathieu-Daudé

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.