diff mbox series

[v2,2/3] accel: move qtest CpusAccel functions to a common location

Message ID 20201013140511.5681-3-jandryuk@gmail.com (mailing list archive)
State New, archived
Headers show
Series Add Xen CpusAccel | expand

Commit Message

Jason Andryuk Oct. 13, 2020, 2:05 p.m. UTC
Move and rename accel/qtest/qtest-cpus.c files to accel/dummy-cpus.c so
it can be re-used by Xen.

Signed-off-by: Jason Andryuk <jandryuk@gmail.com>

---
v2:
 - Use accel/dummy-cpus.c
 - Put prototype in include/sysemu/cpus.h
---
 accel/{qtest/qtest-cpus.c => dummy-cpus.c} | 22 ++++------------------
 accel/meson.build                          |  7 +++++++
 accel/qtest/meson.build                    |  1 -
 accel/qtest/qtest-cpus.h                   | 17 -----------------
 accel/qtest/qtest.c                        |  5 ++++-
 include/sysemu/cpus.h                      |  3 +++
 6 files changed, 18 insertions(+), 37 deletions(-)
 rename accel/{qtest/qtest-cpus.c => dummy-cpus.c} (75%)
 delete mode 100644 accel/qtest/qtest-cpus.h

Comments

Claudio Fontana Oct. 13, 2020, 2:12 p.m. UTC | #1
On 10/13/20 4:05 PM, Jason Andryuk wrote:
> Move and rename accel/qtest/qtest-cpus.c files to accel/dummy-cpus.c so
> it can be re-used by Xen.
> 
> Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
> 
> ---
> v2:
>  - Use accel/dummy-cpus.c
>  - Put prototype in include/sysemu/cpus.h
> ---
>  accel/{qtest/qtest-cpus.c => dummy-cpus.c} | 22 ++++------------------
>  accel/meson.build                          |  7 +++++++
>  accel/qtest/meson.build                    |  1 -
>  accel/qtest/qtest-cpus.h                   | 17 -----------------
>  accel/qtest/qtest.c                        |  5 ++++-
>  include/sysemu/cpus.h                      |  3 +++
>  6 files changed, 18 insertions(+), 37 deletions(-)
>  rename accel/{qtest/qtest-cpus.c => dummy-cpus.c} (75%)
>  delete mode 100644 accel/qtest/qtest-cpus.h
> 
> diff --git a/accel/qtest/qtest-cpus.c b/accel/dummy-cpus.c
> similarity index 75%
> rename from accel/qtest/qtest-cpus.c
> rename to accel/dummy-cpus.c
> index db094201c1..10429fdfb2 100644
> --- a/accel/qtest/qtest-cpus.c
> +++ b/accel/dummy-cpus.c
> @@ -1,5 +1,5 @@
>  /*
> - * QTest accelerator code
> + * Dummy cpu thread code
>   *
>   * Copyright IBM, Corp. 2011
>   *
> @@ -13,21 +13,12 @@
>  
>  #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"
> -
> -static void *qtest_cpu_thread_fn(void *arg)
> +static void *dummy_cpu_thread_fn(void *arg)
>  {
>      CPUState *cpu = arg;
>      sigset_t waitset;
> @@ -67,7 +58,7 @@ static void *qtest_cpu_thread_fn(void *arg)
>      return NULL;
>  }
>  
> -static void qtest_start_vcpu_thread(CPUState *cpu)
> +void dummy_start_vcpu_thread(CPUState *cpu)
>  {
>      char thread_name[VCPU_THREAD_NAME_SIZE];
>  
> @@ -76,11 +67,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/meson.build b/accel/meson.build
> index bb00d0fd13..9a417396bd 100644
> --- a/accel/meson.build
> +++ b/accel/meson.build
> @@ -5,3 +5,10 @@ subdir('kvm')
>  subdir('tcg')
>  subdir('xen')
>  subdir('stubs')
> +
> +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/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-cpus.h b/accel/qtest/qtest-cpus.h
> deleted file mode 100644
> index 739519a472..0000000000
> --- a/accel/qtest/qtest-cpus.h
> +++ /dev/null
> @@ -1,17 +0,0 @@
> -/*
> - * Accelerator CPUS Interface
> - *
> - * Copyright 2020 SUSE LLC
> - *
> - * This work is licensed under the terms of the GNU GPL, version 2 or later.
> - * See the COPYING file in the top-level directory.
> - */
> -
> -#ifndef QTEST_CPUS_H
> -#define QTEST_CPUS_H
> -
> -#include "sysemu/cpus.h"
> -
> -extern const CpusAccel qtest_cpus;
> -
> -#endif /* QTEST_CPUS_H */
> diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c
> index 537e8b449c..b282cea5cf 100644
> --- a/accel/qtest/qtest.c
> +++ b/accel/qtest/qtest.c
> @@ -25,7 +25,10 @@
>  #include "qemu/main-loop.h"
>  #include "hw/core/cpu.h"
>  
> -#include "qtest-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)
>  {
> diff --git a/include/sysemu/cpus.h b/include/sysemu/cpus.h
> index 231685955d..e8156728c6 100644
> --- a/include/sysemu/cpus.h
> +++ b/include/sysemu/cpus.h
> @@ -25,6 +25,9 @@ typedef struct CpusAccel {
>  /* register accel-specific cpus interface implementation */
>  void cpus_register_accel(const CpusAccel *i);
>  
> +/* Create a dummy vcpu for CpusAccel->create_vcpu_thread */
> +void dummy_start_vcpu_thread(CPUState *);
> +
>  /* interface available for cpus accelerator threads */
>  
>  /* For temporary buffers for forming a name */
> 
Reviewed-by: Claudio Fontana <cfontana@suse.de>
Thomas Huth Oct. 23, 2020, 7:07 a.m. UTC | #2
On 13/10/2020 16.05, Jason Andryuk wrote:
> Move and rename accel/qtest/qtest-cpus.c files to accel/dummy-cpus.c so
> it can be re-used by Xen.
> 
> Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
> 
> ---
> v2:
>  - Use accel/dummy-cpus.c
>  - Put prototype in include/sysemu/cpus.h
> ---
>  accel/{qtest/qtest-cpus.c => dummy-cpus.c} | 22 ++++------------------
>  accel/meson.build                          |  7 +++++++
>  accel/qtest/meson.build                    |  1 -
>  accel/qtest/qtest-cpus.h                   | 17 -----------------
>  accel/qtest/qtest.c                        |  5 ++++-
>  include/sysemu/cpus.h                      |  3 +++
>  6 files changed, 18 insertions(+), 37 deletions(-)
>  rename accel/{qtest/qtest-cpus.c => dummy-cpus.c} (75%)
>  delete mode 100644 accel/qtest/qtest-cpus.h

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

Patch

diff --git a/accel/qtest/qtest-cpus.c b/accel/dummy-cpus.c
similarity index 75%
rename from accel/qtest/qtest-cpus.c
rename to accel/dummy-cpus.c
index db094201c1..10429fdfb2 100644
--- a/accel/qtest/qtest-cpus.c
+++ b/accel/dummy-cpus.c
@@ -1,5 +1,5 @@ 
 /*
- * QTest accelerator code
+ * Dummy cpu thread code
  *
  * Copyright IBM, Corp. 2011
  *
@@ -13,21 +13,12 @@ 
 
 #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"
-
-static void *qtest_cpu_thread_fn(void *arg)
+static void *dummy_cpu_thread_fn(void *arg)
 {
     CPUState *cpu = arg;
     sigset_t waitset;
@@ -67,7 +58,7 @@  static void *qtest_cpu_thread_fn(void *arg)
     return NULL;
 }
 
-static void qtest_start_vcpu_thread(CPUState *cpu)
+void dummy_start_vcpu_thread(CPUState *cpu)
 {
     char thread_name[VCPU_THREAD_NAME_SIZE];
 
@@ -76,11 +67,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/meson.build b/accel/meson.build
index bb00d0fd13..9a417396bd 100644
--- a/accel/meson.build
+++ b/accel/meson.build
@@ -5,3 +5,10 @@  subdir('kvm')
 subdir('tcg')
 subdir('xen')
 subdir('stubs')
+
+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/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-cpus.h b/accel/qtest/qtest-cpus.h
deleted file mode 100644
index 739519a472..0000000000
--- a/accel/qtest/qtest-cpus.h
+++ /dev/null
@@ -1,17 +0,0 @@ 
-/*
- * Accelerator CPUS Interface
- *
- * Copyright 2020 SUSE LLC
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- */
-
-#ifndef QTEST_CPUS_H
-#define QTEST_CPUS_H
-
-#include "sysemu/cpus.h"
-
-extern const CpusAccel qtest_cpus;
-
-#endif /* QTEST_CPUS_H */
diff --git a/accel/qtest/qtest.c b/accel/qtest/qtest.c
index 537e8b449c..b282cea5cf 100644
--- a/accel/qtest/qtest.c
+++ b/accel/qtest/qtest.c
@@ -25,7 +25,10 @@ 
 #include "qemu/main-loop.h"
 #include "hw/core/cpu.h"
 
-#include "qtest-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)
 {
diff --git a/include/sysemu/cpus.h b/include/sysemu/cpus.h
index 231685955d..e8156728c6 100644
--- a/include/sysemu/cpus.h
+++ b/include/sysemu/cpus.h
@@ -25,6 +25,9 @@  typedef struct CpusAccel {
 /* register accel-specific cpus interface implementation */
 void cpus_register_accel(const CpusAccel *i);
 
+/* Create a dummy vcpu for CpusAccel->create_vcpu_thread */
+void dummy_start_vcpu_thread(CPUState *);
+
 /* interface available for cpus accelerator threads */
 
 /* For temporary buffers for forming a name */