mbox series

[0/2] Add Xen CpusAccel

Message ID 20201012200725.64137-1-jandryuk@gmail.com
Headers show
Series Add Xen CpusAccel | expand

Message

Jason Andryuk Oct. 12, 2020, 8:07 p.m. UTC
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

Comments

Claudio Fontana Oct. 12, 2020, 8:16 p.m. UTC | #1
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>
Claudio Fontana Oct. 12, 2020, 8:23 p.m. UTC | #2
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)
>  {
>
Paolo Bonzini Oct. 12, 2020, 8:30 p.m. UTC | #3
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)

>>  {

>>

>
Jason Andryuk Oct. 12, 2020, 8:38 p.m. UTC | #4
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
Jason Andryuk Oct. 12, 2020, 8:40 p.m. UTC | #5
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
Paolo Bonzini Oct. 12, 2020, 8:44 p.m. UTC | #6
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
Philippe Mathieu-Daudé Oct. 13, 2020, 8:42 a.m. UTC | #7
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>
> 
> 
>