diff mbox series

spapr/kvm: Set default cpu model for all machine classes

Message ID 20191030163243.10644-1-david@gibson.dropbear.id.au (mailing list archive)
State New, archived
Headers show
Series spapr/kvm: Set default cpu model for all machine classes | expand

Commit Message

David Gibson Oct. 30, 2019, 4:32 p.m. UTC
We have to set the default model of all machine classes, not just for the
active one. Otherwise, "query-machines" will indicate the wrong CPU model
("qemu-s390x-cpu" instead of "host-s390x-cpu") as "default-cpu-type".

s390x already fixed this in de60a92e "s390x/kvm: Set default cpu model for
all machine classes".  This patch applies a similar fix for the pseries-*
machine types on ppc64.

Doing a
    {"execute":"query-machines"}
under KVM now results in
    {
      "hotpluggable-cpus": true,
      "name": "pseries-4.2",
      "numa-mem-supported": true,
      "default-cpu-type": "host-powerpc64-cpu",
      "is-default": true,
      "cpu-max": 1024,
      "deprecated": false,
      "alias": "pseries"
    },
    {
      "hotpluggable-cpus": true,
      "name": "pseries-4.1",
      "numa-mem-supported": true,
      "default-cpu-type": "host-powerpc64-cpu",
      "cpu-max": 1024,
      "deprecated": false
    },
    ...

Libvirt probes all machines via "-machine none,accel=kvm:tcg" and will
currently see the wrong CPU model under KVM.

Reported-by: Jiři Denemark <jdenemar@redhat.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>
---
 target/ppc/kvm.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

Comments

David Hildenbrand Oct. 30, 2019, 5:32 p.m. UTC | #1
On 30.10.19 17:32, David Gibson wrote:
> We have to set the default model of all machine classes, not just for the
> active one. Otherwise, "query-machines" will indicate the wrong CPU model
> ("qemu-s390x-cpu" instead of "host-s390x-cpu") as "default-cpu-type".

Maybe use ppc CPU models here instead of s390x ones :)

> 
> s390x already fixed this in de60a92e "s390x/kvm: Set default cpu model for
> all machine classes".  This patch applies a similar fix for the pseries-*
> machine types on ppc64.
> 
> Doing a
>      {"execute":"query-machines"}
> under KVM now results in
>      {
>        "hotpluggable-cpus": true,
>        "name": "pseries-4.2",
>        "numa-mem-supported": true,
>        "default-cpu-type": "host-powerpc64-cpu",
>        "is-default": true,
>        "cpu-max": 1024,
>        "deprecated": false,
>        "alias": "pseries"
>      },
>      {
>        "hotpluggable-cpus": true,
>        "name": "pseries-4.1",
>        "numa-mem-supported": true,
>        "default-cpu-type": "host-powerpc64-cpu",
>        "cpu-max": 1024,
>        "deprecated": false
>      },
>      ...
> 
> Libvirt probes all machines via "-machine none,accel=kvm:tcg" and will
> currently see the wrong CPU model under KVM.
> 
> Reported-by: Jiři Denemark <jdenemar@redhat.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Igor Mammedov <imammedo@redhat.com>
> ---
>   target/ppc/kvm.c | 21 +++++++++++++--------
>   1 file changed, 13 insertions(+), 8 deletions(-)
> 
> diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
> index 7d2e8969ac..c77f9848ec 100644
> --- a/target/ppc/kvm.c
> +++ b/target/ppc/kvm.c
> @@ -100,7 +100,7 @@ static bool kvmppc_is_pr(KVMState *ks)
>       return kvm_vm_check_extension(ks, KVM_CAP_PPC_GET_PVINFO) != 0;
>   }
>   
> -static int kvm_ppc_register_host_cpu_type(MachineState *ms);
> +static int kvm_ppc_register_host_cpu_type(void);
>   static void kvmppc_get_cpu_characteristics(KVMState *s);
>   static int kvmppc_get_dec_bits(void);
>   
> @@ -147,7 +147,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
>           exit(1);
>       }
>   
> -    kvm_ppc_register_host_cpu_type(ms);
> +    kvm_ppc_register_host_cpu_type();
>   
>       return 0;
>   }
> @@ -2534,13 +2534,19 @@ PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void)
>       return pvr_pcc;
>   }
>   
> -static int kvm_ppc_register_host_cpu_type(MachineState *ms)
> +static void pseries_machine_class_fixup(ObjectClass *oc, void *opaque)
> +{
> +    MachineClass *mc = MACHINE_CLASS(oc);
> +
> +    mc->default_cpu_type = TYPE_HOST_POWERPC_CPU;
> +}
> +
> +static int kvm_ppc_register_host_cpu_type(void)
>   {
>       TypeInfo type_info = {
>           .name = TYPE_HOST_POWERPC_CPU,
>           .class_init = kvmppc_host_cpu_class_init,
>       };
> -    MachineClass *mc = MACHINE_GET_CLASS(ms);
>       PowerPCCPUClass *pvr_pcc;
>       ObjectClass *oc;
>       DeviceClass *dc;
> @@ -2552,10 +2558,9 @@ static int kvm_ppc_register_host_cpu_type(MachineState *ms)
>       }
>       type_info.parent = object_class_get_name(OBJECT_CLASS(pvr_pcc));
>       type_register(&type_info);
> -    if (object_dynamic_cast(OBJECT(ms), TYPE_SPAPR_MACHINE)) {
> -        /* override TCG default cpu type with 'host' cpu model */
> -        mc->default_cpu_type = TYPE_HOST_POWERPC_CPU;
> -    }
> +    /* override TCG default cpu type with 'host' cpu model */
> +    object_class_foreach(pseries_machine_class_fixup, TYPE_SPAPR_MACHINE,
> +                         false, NULL);
>   
>       oc = object_class_by_name(type_info.name);
>       g_assert(oc);
> 

Reviewed-by: David Hildenbrand <david@redhat.com>
no-reply@patchew.org Oct. 30, 2019, 6:16 p.m. UTC | #2
Patchew URL: https://patchew.org/QEMU/20191030163243.10644-1-david@gibson.dropbear.id.au/



Hi,

This series failed the docker-quick@centos7 build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1
=== TEST SCRIPT END ===

  TEST    check-unit: tests/test-throttle
  TEST    check-unit: tests/test-thread-pool
**
ERROR:/tmp/qemu-test/src/tests/migration-test.c:903:wait_for_migration_fail: assertion failed: (!strcmp(status, "setup") || !strcmp(status, "failed") || (allow_active && !strcmp(status, "active")))
ERROR - Bail out! ERROR:/tmp/qemu-test/src/tests/migration-test.c:903:wait_for_migration_fail: assertion failed: (!strcmp(status, "setup") || !strcmp(status, "failed") || (allow_active && !strcmp(status, "active")))
make: *** [check-qtest-aarch64] Error 1
make: *** Waiting for unfinished jobs....
  TEST    check-unit: tests/test-hbitmap
  TEST    check-unit: tests/test-bdrv-drain
---
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=f34ee869f98f4d8fb89f4cce4cdaca05', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-xiqo9ndm/src/docker-src.2019-10-30-14.06.50.25613:/var/tmp/qemu:z,ro', 'qemu:centos7', '/var/tmp/qemu/run', 'test-quick']' returned non-zero exit status 2.
filter=--filter=label=com.qemu.instance.uuid=f34ee869f98f4d8fb89f4cce4cdaca05
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-xiqo9ndm/src'
make: *** [docker-run-test-quick@centos7] Error 2

real    9m9.268s
user    0m8.646s


The full log is available at
http://patchew.org/logs/20191030163243.10644-1-david@gibson.dropbear.id.au/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
no-reply@patchew.org Oct. 30, 2019, 7:38 p.m. UTC | #3
Patchew URL: https://patchew.org/QEMU/20191030163243.10644-1-david@gibson.dropbear.id.au/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Subject: [PATCH] spapr/kvm: Set default cpu model for all machine classes
Type: series
Message-id: 20191030163243.10644-1-david@gibson.dropbear.id.au

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
4581a2a spapr/kvm: Set default cpu model for all machine classes

=== OUTPUT BEGIN ===
ERROR: Missing Signed-off-by: line(s)

total: 1 errors, 0 warnings, 50 lines checked

Commit 4581a2a674f4 (spapr/kvm: Set default cpu model for all machine classes) has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/20191030163243.10644-1-david@gibson.dropbear.id.au/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
Greg Kurz Oct. 31, 2019, 8:15 a.m. UTC | #4
On Wed, 30 Oct 2019 17:32:43 +0100
David Gibson <david@gibson.dropbear.id.au> wrote:

> We have to set the default model of all machine classes, not just for the
> active one. Otherwise, "query-machines" will indicate the wrong CPU model
> ("qemu-s390x-cpu" instead of "host-s390x-cpu") as "default-cpu-type".
> 

A PPC cpu model might be better.

> s390x already fixed this in de60a92e "s390x/kvm: Set default cpu model for
> all machine classes".  This patch applies a similar fix for the pseries-*
> machine types on ppc64.
> 
> Doing a
>     {"execute":"query-machines"}
> under KVM now results in
>     {
>       "hotpluggable-cpus": true,
>       "name": "pseries-4.2",
>       "numa-mem-supported": true,
>       "default-cpu-type": "host-powerpc64-cpu",
>       "is-default": true,
>       "cpu-max": 1024,
>       "deprecated": false,
>       "alias": "pseries"
>     },
>     {
>       "hotpluggable-cpus": true,
>       "name": "pseries-4.1",
>       "numa-mem-supported": true,
>       "default-cpu-type": "host-powerpc64-cpu",
>       "cpu-max": 1024,
>       "deprecated": false
>     },
>     ...
> 
> Libvirt probes all machines via "-machine none,accel=kvm:tcg" and will
> currently see the wrong CPU model under KVM.
> 
> Reported-by: Jiři Denemark <jdenemar@redhat.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Igor Mammedov <imammedo@redhat.com>

Missing S-o-b.

With these fixed.

Reviewed-by: Greg Kurz <groug@kaod.org>

> ---
>  target/ppc/kvm.c | 21 +++++++++++++--------
>  1 file changed, 13 insertions(+), 8 deletions(-)
> 
> diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
> index 7d2e8969ac..c77f9848ec 100644
> --- a/target/ppc/kvm.c
> +++ b/target/ppc/kvm.c
> @@ -100,7 +100,7 @@ static bool kvmppc_is_pr(KVMState *ks)
>      return kvm_vm_check_extension(ks, KVM_CAP_PPC_GET_PVINFO) != 0;
>  }
>  
> -static int kvm_ppc_register_host_cpu_type(MachineState *ms);
> +static int kvm_ppc_register_host_cpu_type(void);
>  static void kvmppc_get_cpu_characteristics(KVMState *s);
>  static int kvmppc_get_dec_bits(void);
>  
> @@ -147,7 +147,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
>          exit(1);
>      }
>  
> -    kvm_ppc_register_host_cpu_type(ms);
> +    kvm_ppc_register_host_cpu_type();
>  
>      return 0;
>  }
> @@ -2534,13 +2534,19 @@ PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void)
>      return pvr_pcc;
>  }
>  
> -static int kvm_ppc_register_host_cpu_type(MachineState *ms)
> +static void pseries_machine_class_fixup(ObjectClass *oc, void *opaque)
> +{
> +    MachineClass *mc = MACHINE_CLASS(oc);
> +
> +    mc->default_cpu_type = TYPE_HOST_POWERPC_CPU;
> +}
> +
> +static int kvm_ppc_register_host_cpu_type(void)
>  {
>      TypeInfo type_info = {
>          .name = TYPE_HOST_POWERPC_CPU,
>          .class_init = kvmppc_host_cpu_class_init,
>      };
> -    MachineClass *mc = MACHINE_GET_CLASS(ms);
>      PowerPCCPUClass *pvr_pcc;
>      ObjectClass *oc;
>      DeviceClass *dc;
> @@ -2552,10 +2558,9 @@ static int kvm_ppc_register_host_cpu_type(MachineState *ms)
>      }
>      type_info.parent = object_class_get_name(OBJECT_CLASS(pvr_pcc));
>      type_register(&type_info);
> -    if (object_dynamic_cast(OBJECT(ms), TYPE_SPAPR_MACHINE)) {
> -        /* override TCG default cpu type with 'host' cpu model */
> -        mc->default_cpu_type = TYPE_HOST_POWERPC_CPU;
> -    }
> +    /* override TCG default cpu type with 'host' cpu model */
> +    object_class_foreach(pseries_machine_class_fixup, TYPE_SPAPR_MACHINE,
> +                         false, NULL);
>  
>      oc = object_class_by_name(type_info.name);
>      g_assert(oc);
Peter Maydell Oct. 31, 2019, 8:28 a.m. UTC | #5
On Wed, 30 Oct 2019 at 16:34, David Gibson <david@gibson.dropbear.id.au> wrote:
>
> We have to set the default model of all machine classes, not just for the
> active one. Otherwise, "query-machines" will indicate the wrong CPU model
> ("qemu-s390x-cpu" instead of "host-s390x-cpu") as "default-cpu-type".
>
> s390x already fixed this in de60a92e "s390x/kvm: Set default cpu model for
> all machine classes".  This patch applies a similar fix for the pseries-*
> machine types on ppc64.

> Libvirt probes all machines via "-machine none,accel=kvm:tcg" and will
> currently see the wrong CPU model under KVM.

Isn't this a bug in libvirt ? The default CPU for one machine type
tells you nothing at all about the default machine for another CPU
type. Libvirt needs to ask about the default CPU for the machine
it's actually interested in, which is not likely to be "none".

thanks
-- PMM
Peter Maydell Oct. 31, 2019, 8:34 a.m. UTC | #6
On Thu, 31 Oct 2019 at 08:28, Peter Maydell <peter.maydell@linaro.org> wrote:
> Isn't this a bug in libvirt ? The default CPU for one machine type
> tells you nothing at all about the default machine for another CPU
> type. Libvirt needs to ask about the default CPU for the machine
> it's actually interested in, which is not likely to be "none".

Oh, wait, I should have read the QMP output rather than skipping
over it -- it uses -machine none but then issues a QMP command
asking about all machines, not just the current one. Sorry for the noise.

-- PMM
David Gibson Oct. 31, 2019, 10:06 a.m. UTC | #7
On Wed, Oct 30, 2019 at 06:32:28PM +0100, David Hildenbrand wrote:
> On 30.10.19 17:32, David Gibson wrote:
> > We have to set the default model of all machine classes, not just for the
> > active one. Otherwise, "query-machines" will indicate the wrong CPU model
> > ("qemu-s390x-cpu" instead of "host-s390x-cpu") as "default-cpu-type".
> 
> Maybe use ppc CPU models here instead of s390x ones :)

Oops, thanks.


> 
> > 
> > s390x already fixed this in de60a92e "s390x/kvm: Set default cpu model for
> > all machine classes".  This patch applies a similar fix for the pseries-*
> > machine types on ppc64.
> > 
> > Doing a
> >      {"execute":"query-machines"}
> > under KVM now results in
> >      {
> >        "hotpluggable-cpus": true,
> >        "name": "pseries-4.2",
> >        "numa-mem-supported": true,
> >        "default-cpu-type": "host-powerpc64-cpu",
> >        "is-default": true,
> >        "cpu-max": 1024,
> >        "deprecated": false,
> >        "alias": "pseries"
> >      },
> >      {
> >        "hotpluggable-cpus": true,
> >        "name": "pseries-4.1",
> >        "numa-mem-supported": true,
> >        "default-cpu-type": "host-powerpc64-cpu",
> >        "cpu-max": 1024,
> >        "deprecated": false
> >      },
> >      ...
> > 
> > Libvirt probes all machines via "-machine none,accel=kvm:tcg" and will
> > currently see the wrong CPU model under KVM.
> > 
> > Reported-by: Jiři Denemark <jdenemar@redhat.com>
> > Cc: David Hildenbrand <david@redhat.com>
> > Cc: Igor Mammedov <imammedo@redhat.com>
> > ---
> >   target/ppc/kvm.c | 21 +++++++++++++--------
> >   1 file changed, 13 insertions(+), 8 deletions(-)
> > 
> > diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
> > index 7d2e8969ac..c77f9848ec 100644
> > --- a/target/ppc/kvm.c
> > +++ b/target/ppc/kvm.c
> > @@ -100,7 +100,7 @@ static bool kvmppc_is_pr(KVMState *ks)
> >       return kvm_vm_check_extension(ks, KVM_CAP_PPC_GET_PVINFO) != 0;
> >   }
> > -static int kvm_ppc_register_host_cpu_type(MachineState *ms);
> > +static int kvm_ppc_register_host_cpu_type(void);
> >   static void kvmppc_get_cpu_characteristics(KVMState *s);
> >   static int kvmppc_get_dec_bits(void);
> > @@ -147,7 +147,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
> >           exit(1);
> >       }
> > -    kvm_ppc_register_host_cpu_type(ms);
> > +    kvm_ppc_register_host_cpu_type();
> >       return 0;
> >   }
> > @@ -2534,13 +2534,19 @@ PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void)
> >       return pvr_pcc;
> >   }
> > -static int kvm_ppc_register_host_cpu_type(MachineState *ms)
> > +static void pseries_machine_class_fixup(ObjectClass *oc, void *opaque)
> > +{
> > +    MachineClass *mc = MACHINE_CLASS(oc);
> > +
> > +    mc->default_cpu_type = TYPE_HOST_POWERPC_CPU;
> > +}
> > +
> > +static int kvm_ppc_register_host_cpu_type(void)
> >   {
> >       TypeInfo type_info = {
> >           .name = TYPE_HOST_POWERPC_CPU,
> >           .class_init = kvmppc_host_cpu_class_init,
> >       };
> > -    MachineClass *mc = MACHINE_GET_CLASS(ms);
> >       PowerPCCPUClass *pvr_pcc;
> >       ObjectClass *oc;
> >       DeviceClass *dc;
> > @@ -2552,10 +2558,9 @@ static int kvm_ppc_register_host_cpu_type(MachineState *ms)
> >       }
> >       type_info.parent = object_class_get_name(OBJECT_CLASS(pvr_pcc));
> >       type_register(&type_info);
> > -    if (object_dynamic_cast(OBJECT(ms), TYPE_SPAPR_MACHINE)) {
> > -        /* override TCG default cpu type with 'host' cpu model */
> > -        mc->default_cpu_type = TYPE_HOST_POWERPC_CPU;
> > -    }
> > +    /* override TCG default cpu type with 'host' cpu model */
> > +    object_class_foreach(pseries_machine_class_fixup, TYPE_SPAPR_MACHINE,
> > +                         false, NULL);
> >       oc = object_class_by_name(type_info.name);
> >       g_assert(oc);
> > 
> 
> Reviewed-by: David Hildenbrand <david@redhat.com>
>
David Gibson Oct. 31, 2019, 10:07 a.m. UTC | #8
On Thu, Oct 31, 2019 at 09:15:56AM +0100, Greg Kurz wrote:
> On Wed, 30 Oct 2019 17:32:43 +0100
> David Gibson <david@gibson.dropbear.id.au> wrote:
> 
> > We have to set the default model of all machine classes, not just for the
> > active one. Otherwise, "query-machines" will indicate the wrong CPU model
> > ("qemu-s390x-cpu" instead of "host-s390x-cpu") as "default-cpu-type".
> > 
> 
> A PPC cpu model might be better.

Indeed.

> 
> > s390x already fixed this in de60a92e "s390x/kvm: Set default cpu model for
> > all machine classes".  This patch applies a similar fix for the pseries-*
> > machine types on ppc64.
> > 
> > Doing a
> >     {"execute":"query-machines"}
> > under KVM now results in
> >     {
> >       "hotpluggable-cpus": true,
> >       "name": "pseries-4.2",
> >       "numa-mem-supported": true,
> >       "default-cpu-type": "host-powerpc64-cpu",
> >       "is-default": true,
> >       "cpu-max": 1024,
> >       "deprecated": false,
> >       "alias": "pseries"
> >     },
> >     {
> >       "hotpluggable-cpus": true,
> >       "name": "pseries-4.1",
> >       "numa-mem-supported": true,
> >       "default-cpu-type": "host-powerpc64-cpu",
> >       "cpu-max": 1024,
> >       "deprecated": false
> >     },
> >     ...
> > 
> > Libvirt probes all machines via "-machine none,accel=kvm:tcg" and will
> > currently see the wrong CPU model under KVM.
> > 
> > Reported-by: Jiři Denemark <jdenemar@redhat.com>
> > Cc: David Hildenbrand <david@redhat.com>
> > Cc: Igor Mammedov <imammedo@redhat.com>
> 
> Missing S-o-b.

Oops, fixed.

> With these fixed.
> 
> Reviewed-by: Greg Kurz <groug@kaod.org>
> 
> > ---
> >  target/ppc/kvm.c | 21 +++++++++++++--------
> >  1 file changed, 13 insertions(+), 8 deletions(-)
> > 
> > diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
> > index 7d2e8969ac..c77f9848ec 100644
> > --- a/target/ppc/kvm.c
> > +++ b/target/ppc/kvm.c
> > @@ -100,7 +100,7 @@ static bool kvmppc_is_pr(KVMState *ks)
> >      return kvm_vm_check_extension(ks, KVM_CAP_PPC_GET_PVINFO) != 0;
> >  }
> >  
> > -static int kvm_ppc_register_host_cpu_type(MachineState *ms);
> > +static int kvm_ppc_register_host_cpu_type(void);
> >  static void kvmppc_get_cpu_characteristics(KVMState *s);
> >  static int kvmppc_get_dec_bits(void);
> >  
> > @@ -147,7 +147,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
> >          exit(1);
> >      }
> >  
> > -    kvm_ppc_register_host_cpu_type(ms);
> > +    kvm_ppc_register_host_cpu_type();
> >  
> >      return 0;
> >  }
> > @@ -2534,13 +2534,19 @@ PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void)
> >      return pvr_pcc;
> >  }
> >  
> > -static int kvm_ppc_register_host_cpu_type(MachineState *ms)
> > +static void pseries_machine_class_fixup(ObjectClass *oc, void *opaque)
> > +{
> > +    MachineClass *mc = MACHINE_CLASS(oc);
> > +
> > +    mc->default_cpu_type = TYPE_HOST_POWERPC_CPU;
> > +}
> > +
> > +static int kvm_ppc_register_host_cpu_type(void)
> >  {
> >      TypeInfo type_info = {
> >          .name = TYPE_HOST_POWERPC_CPU,
> >          .class_init = kvmppc_host_cpu_class_init,
> >      };
> > -    MachineClass *mc = MACHINE_GET_CLASS(ms);
> >      PowerPCCPUClass *pvr_pcc;
> >      ObjectClass *oc;
> >      DeviceClass *dc;
> > @@ -2552,10 +2558,9 @@ static int kvm_ppc_register_host_cpu_type(MachineState *ms)
> >      }
> >      type_info.parent = object_class_get_name(OBJECT_CLASS(pvr_pcc));
> >      type_register(&type_info);
> > -    if (object_dynamic_cast(OBJECT(ms), TYPE_SPAPR_MACHINE)) {
> > -        /* override TCG default cpu type with 'host' cpu model */
> > -        mc->default_cpu_type = TYPE_HOST_POWERPC_CPU;
> > -    }
> > +    /* override TCG default cpu type with 'host' cpu model */
> > +    object_class_foreach(pseries_machine_class_fixup, TYPE_SPAPR_MACHINE,
> > +                         false, NULL);
> >  
> >      oc = object_class_by_name(type_info.name);
> >      g_assert(oc);
>
Jiri Denemark Nov. 1, 2019, 12:27 p.m. UTC | #9
On Wed, Oct 30, 2019 at 17:32:43 +0100, David Gibson wrote:
> We have to set the default model of all machine classes, not just for the
> active one. Otherwise, "query-machines" will indicate the wrong CPU model
> ("qemu-s390x-cpu" instead of "host-s390x-cpu") as "default-cpu-type".
> 
> s390x already fixed this in de60a92e "s390x/kvm: Set default cpu model for
> all machine classes".  This patch applies a similar fix for the pseries-*
> machine types on ppc64.
> 
> Doing a
>     {"execute":"query-machines"}
> under KVM now results in
>     {
>       "hotpluggable-cpus": true,
>       "name": "pseries-4.2",
>       "numa-mem-supported": true,
>       "default-cpu-type": "host-powerpc64-cpu",
>       "is-default": true,
>       "cpu-max": 1024,
>       "deprecated": false,
>       "alias": "pseries"
>     },
>     {
>       "hotpluggable-cpus": true,
>       "name": "pseries-4.1",
>       "numa-mem-supported": true,
>       "default-cpu-type": "host-powerpc64-cpu",
>       "cpu-max": 1024,
>       "deprecated": false
>     },
>     ...
> 
> Libvirt probes all machines via "-machine none,accel=kvm:tcg" and will
> currently see the wrong CPU model under KVM.
> 
> Reported-by: Jiři Denemark <jdenemar@redhat.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Igor Mammedov <imammedo@redhat.com>

Works as expected now, thanks.

Tested-by: Jiri Denemark <jdenemar@redhat.com>
Jiri Denemark Nov. 13, 2019, 2:43 p.m. UTC | #10
Hi David.

On Wed, Oct 30, 2019 at 17:32:43 +0100, David Gibson wrote:
> We have to set the default model of all machine classes, not just for the
> active one. Otherwise, "query-machines" will indicate the wrong CPU model
> ("qemu-s390x-cpu" instead of "host-s390x-cpu") as "default-cpu-type".
> 
> s390x already fixed this in de60a92e "s390x/kvm: Set default cpu model for
> all machine classes".  This patch applies a similar fix for the pseries-*
> machine types on ppc64.
> 
> Doing a
>     {"execute":"query-machines"}
> under KVM now results in
>     {
>       "hotpluggable-cpus": true,
>       "name": "pseries-4.2",
>       "numa-mem-supported": true,
>       "default-cpu-type": "host-powerpc64-cpu",
>       "is-default": true,
>       "cpu-max": 1024,
>       "deprecated": false,
>       "alias": "pseries"
>     },
>     {
>       "hotpluggable-cpus": true,
>       "name": "pseries-4.1",
>       "numa-mem-supported": true,
>       "default-cpu-type": "host-powerpc64-cpu",
>       "cpu-max": 1024,
>       "deprecated": false
>     },
>     ...
> 
> Libvirt probes all machines via "-machine none,accel=kvm:tcg" and will
> currently see the wrong CPU model under KVM.

Will this patch make it into 4.2.0?

Jirka
Greg Kurz Nov. 13, 2019, 3:09 p.m. UTC | #11
On Wed, 13 Nov 2019 15:43:44 +0100
Jiri Denemark <jdenemar@redhat.com> wrote:

> Hi David.
> 
> On Wed, Oct 30, 2019 at 17:32:43 +0100, David Gibson wrote:
> > We have to set the default model of all machine classes, not just for the
> > active one. Otherwise, "query-machines" will indicate the wrong CPU model
> > ("qemu-s390x-cpu" instead of "host-s390x-cpu") as "default-cpu-type".
> > 
> > s390x already fixed this in de60a92e "s390x/kvm: Set default cpu model for
> > all machine classes".  This patch applies a similar fix for the pseries-*
> > machine types on ppc64.
> > 
> > Doing a
> >     {"execute":"query-machines"}
> > under KVM now results in
> >     {
> >       "hotpluggable-cpus": true,
> >       "name": "pseries-4.2",
> >       "numa-mem-supported": true,
> >       "default-cpu-type": "host-powerpc64-cpu",
> >       "is-default": true,
> >       "cpu-max": 1024,
> >       "deprecated": false,
> >       "alias": "pseries"
> >     },
> >     {
> >       "hotpluggable-cpus": true,
> >       "name": "pseries-4.1",
> >       "numa-mem-supported": true,
> >       "default-cpu-type": "host-powerpc64-cpu",
> >       "cpu-max": 1024,
> >       "deprecated": false
> >     },
> >     ...
> > 
> > Libvirt probes all machines via "-machine none,accel=kvm:tcg" and will
> > currently see the wrong CPU model under KVM.
> 
> Will this patch make it into 4.2.0?
> 

David is away until the 19th of November, which is the release date
of rc2 according to the planning [*]. Then we have rc3 the 26th, and
final release (or rc4) the 3rd of December, so it should be ok.

If David cannot make it for some reason, I guess Laurent Vivier or
myself can send a PR with this patch, as already suggested by David
in the past.

Cheers,

--
Greg

[*] https://wiki.qemu.org/Planning/4.2

> Jirka
> 
>
Peter Maydell Nov. 13, 2019, 3:31 p.m. UTC | #12
On Wed, 13 Nov 2019 at 15:10, Greg Kurz <groug@kaod.org> wrote:
> David is away until the 19th of November, which is the release date
> of rc2 according to the planning [*]. Then we have rc3 the 26th, and
> final release (or rc4) the 3rd of December, so it should be ok.

Please don't actively plan to delay putting changes in
until later release candidates. The release process
involves steadily winding up the bar of whether it's
worth putting in and hopefully reducing the volume
of changes between rcs. In an ideal world rc3 would
have very few changes, and then there would be no
changes at all between rc3 and the final release.

thanks
-- PMM
Greg Kurz Nov. 13, 2019, 4 p.m. UTC | #13
On Wed, 13 Nov 2019 15:31:58 +0000
Peter Maydell <peter.maydell@linaro.org> wrote:

> On Wed, 13 Nov 2019 at 15:10, Greg Kurz <groug@kaod.org> wrote:
> > David is away until the 19th of November, which is the release date
> > of rc2 according to the planning [*]. Then we have rc3 the 26th, and
> > final release (or rc4) the 3rd of December, so it should be ok.
> 
> Please don't actively plan to delay putting changes in
> until later release candidates. The release process
> involves steadily winding up the bar of whether it's
> worth putting in and hopefully reducing the volume
> of changes between rcs. In an ideal world rc3 would
> have very few changes, and then there would be no
> changes at all between rc3 and the final release.
> 

Right. I could discuss with Laurent: David should be back on Monday
actually. Hopefully he can a send a PR before rc2.

> thanks
> -- PMM
>
David Gibson Nov. 15, 2019, 9:20 a.m. UTC | #14
On Wed, Nov 13, 2019 at 05:00:40PM +0100, Greg Kurz wrote:
> On Wed, 13 Nov 2019 15:31:58 +0000
> Peter Maydell <peter.maydell@linaro.org> wrote:
> 
> > On Wed, 13 Nov 2019 at 15:10, Greg Kurz <groug@kaod.org> wrote:
> > > David is away until the 19th of November, which is the release date
> > > of rc2 according to the planning [*]. Then we have rc3 the 26th, and
> > > final release (or rc4) the 3rd of December, so it should be ok.
> > 
> > Please don't actively plan to delay putting changes in
> > until later release candidates. The release process
> > involves steadily winding up the bar of whether it's
> > worth putting in and hopefully reducing the volume
> > of changes between rcs. In an ideal world rc3 would
> > have very few changes, and then there would be no
> > changes at all between rc3 and the final release.
> > 
> 
> Right. I could discuss with Laurent: David should be back on Monday
> actually. Hopefully he can a send a PR before rc2.

I'm back home now, back to work on Monday.  It'll probably take me a
full day of catching up on email and whatnot, so the earliest I'd be
likely to do the PR is Tuesday.  If you can get it ready before that,
please go ahead.
Laurent Vivier Nov. 15, 2019, 10:42 a.m. UTC | #15
On 15/11/2019 10:20, David Gibson wrote:
> On Wed, Nov 13, 2019 at 05:00:40PM +0100, Greg Kurz wrote:
>> On Wed, 13 Nov 2019 15:31:58 +0000
>> Peter Maydell <peter.maydell@linaro.org> wrote:
>>
>>> On Wed, 13 Nov 2019 at 15:10, Greg Kurz <groug@kaod.org> wrote:
>>>> David is away until the 19th of November, which is the release date
>>>> of rc2 according to the planning [*]. Then we have rc3 the 26th, and
>>>> final release (or rc4) the 3rd of December, so it should be ok.
>>>
>>> Please don't actively plan to delay putting changes in
>>> until later release candidates. The release process
>>> involves steadily winding up the bar of whether it's
>>> worth putting in and hopefully reducing the volume
>>> of changes between rcs. In an ideal world rc3 would
>>> have very few changes, and then there would be no
>>> changes at all between rc3 and the final release.
>>>
>>
>> Right. I could discuss with Laurent: David should be back on Monday
>> actually. Hopefully he can a send a PR before rc2.
> 
> I'm back home now, back to work on Monday.  It'll probably take me a
> full day of catching up on email and whatnot, so the earliest I'd be
> likely to do the PR is Tuesday.  If you can get it ready before that,
> please go ahead.
> 
I'm going to take your ppc-for-4.2 branch to build and test, and then I
will do the PR, probably today.

Thanks,
Laurent
diff mbox series

Patch

diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
index 7d2e8969ac..c77f9848ec 100644
--- a/target/ppc/kvm.c
+++ b/target/ppc/kvm.c
@@ -100,7 +100,7 @@  static bool kvmppc_is_pr(KVMState *ks)
     return kvm_vm_check_extension(ks, KVM_CAP_PPC_GET_PVINFO) != 0;
 }
 
-static int kvm_ppc_register_host_cpu_type(MachineState *ms);
+static int kvm_ppc_register_host_cpu_type(void);
 static void kvmppc_get_cpu_characteristics(KVMState *s);
 static int kvmppc_get_dec_bits(void);
 
@@ -147,7 +147,7 @@  int kvm_arch_init(MachineState *ms, KVMState *s)
         exit(1);
     }
 
-    kvm_ppc_register_host_cpu_type(ms);
+    kvm_ppc_register_host_cpu_type();
 
     return 0;
 }
@@ -2534,13 +2534,19 @@  PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void)
     return pvr_pcc;
 }
 
-static int kvm_ppc_register_host_cpu_type(MachineState *ms)
+static void pseries_machine_class_fixup(ObjectClass *oc, void *opaque)
+{
+    MachineClass *mc = MACHINE_CLASS(oc);
+
+    mc->default_cpu_type = TYPE_HOST_POWERPC_CPU;
+}
+
+static int kvm_ppc_register_host_cpu_type(void)
 {
     TypeInfo type_info = {
         .name = TYPE_HOST_POWERPC_CPU,
         .class_init = kvmppc_host_cpu_class_init,
     };
-    MachineClass *mc = MACHINE_GET_CLASS(ms);
     PowerPCCPUClass *pvr_pcc;
     ObjectClass *oc;
     DeviceClass *dc;
@@ -2552,10 +2558,9 @@  static int kvm_ppc_register_host_cpu_type(MachineState *ms)
     }
     type_info.parent = object_class_get_name(OBJECT_CLASS(pvr_pcc));
     type_register(&type_info);
-    if (object_dynamic_cast(OBJECT(ms), TYPE_SPAPR_MACHINE)) {
-        /* override TCG default cpu type with 'host' cpu model */
-        mc->default_cpu_type = TYPE_HOST_POWERPC_CPU;
-    }
+    /* override TCG default cpu type with 'host' cpu model */
+    object_class_foreach(pseries_machine_class_fixup, TYPE_SPAPR_MACHINE,
+                         false, NULL);
 
     oc = object_class_by_name(type_info.name);
     g_assert(oc);