diff mbox series

[v1] s390x/cpumodel: make qemu cpu model play with "none" machine

Message ID 20171213132407.5227-1-david@redhat.com
State New
Headers show
Series [v1] s390x/cpumodel: make qemu cpu model play with "none" machine | expand

Commit Message

David Hildenbrand Dec. 13, 2017, 1:24 p.m. UTC
Make sure "-cpu qemu" works with "-M none".

Signed-off-by: David Hildenbrand <david@redhat.com>
---

Conny, if this is okay, can you squash with the original patch?

 hw/s390x/s390-virtio-ccw.c  | 4 ----
 target/s390x/cpu_models.c   | 7 +++++--
 target/s390x/gen-features.c | 4 ++--
 3 files changed, 7 insertions(+), 8 deletions(-)

Comments

Christian Borntraeger Dec. 13, 2017, 1:34 p.m. UTC | #1
On 12/13/2017 02:24 PM, David Hildenbrand wrote:
> Make sure "-cpu qemu" works with "-M none".
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
> 
> Conny, if this is okay, can you squash with the original patch?
> 
>  hw/s390x/s390-virtio-ccw.c  | 4 ----
>  target/s390x/cpu_models.c   | 7 +++++--
>  target/s390x/gen-features.c | 4 ++--
>  3 files changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
> index c1f96418fa..466e45343c 100644
> --- a/hw/s390x/s390-virtio-ccw.c
> +++ b/hw/s390x/s390-virtio-ccw.c
> @@ -725,10 +725,6 @@ bool css_migration_enabled(void)
> 
>  static void ccw_machine_2_12_instance_options(MachineState *machine)
>  {
> -    static const S390FeatInit qemu_cpu_feat = { S390_FEAT_LIST_QEMU_V2_12 };
> -
> -    /* with 2.12 we emulated a stripped down zEC12 (GA 2) */
> -    s390_set_qemu_cpu_model(0x2827, 12, 2, qemu_cpu_feat);
>  }

So what happens now when you specify a 2.10 machine? 


> 
>  static void ccw_machine_2_12_class_options(MachineClass *mc)
> diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c
> index 7404ef52c6..212a5f0697 100644
> --- a/target/s390x/cpu_models.c
> +++ b/target/s390x/cpu_models.c
> @@ -1122,8 +1122,6 @@ static void s390_qemu_cpu_model_initfn(Object *obj)
>      S390CPU *cpu = S390_CPU(obj);
> 
>      cpu->model = g_malloc0(sizeof(*cpu->model));
> -    /* has to be initialized by now via s390_set_qemu_cpu_model() */
> -    g_assert(s390_qemu_cpu_model.def);
>      /* copy the CPU model so we can modify it */
>      memcpy(cpu->model, &s390_qemu_cpu_model, sizeof(*cpu->model));
>  }
> @@ -1266,6 +1264,7 @@ static void init_ignored_base_feat(void)
> 
>  static void register_types(void)
>  {
> +    static const S390FeatInit qemu_latest_init = { S390_FEAT_LIST_QEMU_LATEST };
>      int i;
> 
>      init_ignored_base_feat();
> @@ -1281,6 +1280,10 @@ static void register_types(void)
>                                s390_cpu_defs[i].full_feat);
>      }
> 
> +    /* initialize the qemu model with latest definition */
> +    s390_set_qemu_cpu_model(QEMU_MAX_CPU_TYPE, QEMU_MAX_CPU_GEN,
> +                            QEMU_MAX_CPU_EC_GA, qemu_latest_init);
> +
>      for (i = 0; i < ARRAY_SIZE(s390_cpu_defs); i++) {
>          char *base_name = s390_base_cpu_type_name(s390_cpu_defs[i].name);
>          TypeInfo ti_base = {
> diff --git a/target/s390x/gen-features.c b/target/s390x/gen-features.c
> index 983f2dcd52..deace660e1 100644
> --- a/target/s390x/gen-features.c
> +++ b/target/s390x/gen-features.c
> @@ -544,7 +544,7 @@ static uint16_t qemu_V2_11[] = {
>      S390_FEAT_ZARCH,
>  };
> 
> -static uint16_t qemu_V2_12[] = {
> +static uint16_t qemu_LATEST[] = {
>      S390_FEAT_DAT_ENH,
>      S390_FEAT_IDTE_SEGMENT,
>      S390_FEAT_STFLE,
> @@ -685,7 +685,7 @@ static FeatGroupDefSpec FeatGroupDef[] = {
>   *******************************/
>  static FeatGroupDefSpec QemuFeatDef[] = {
>      QEMU_FEAT_INITIALIZER(V2_11),
> -    QEMU_FEAT_INITIALIZER(V2_12),
> +    QEMU_FEAT_INITIALIZER(LATEST),
>      QEMU_FEAT_INITIALIZER(MAX),
>  };
>
David Hildenbrand Dec. 13, 2017, 1:38 p.m. UTC | #2
On 13.12.2017 14:34, Christian Borntraeger wrote:
> 
> 
> On 12/13/2017 02:24 PM, David Hildenbrand wrote:
>> Make sure "-cpu qemu" works with "-M none".
>>
>> Signed-off-by: David Hildenbrand <david@redhat.com>
>> ---
>>
>> Conny, if this is okay, can you squash with the original patch?
>>
>>  hw/s390x/s390-virtio-ccw.c  | 4 ----
>>  target/s390x/cpu_models.c   | 7 +++++--
>>  target/s390x/gen-features.c | 4 ++--
>>  3 files changed, 7 insertions(+), 8 deletions(-)
>>
>> diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
>> index c1f96418fa..466e45343c 100644
>> --- a/hw/s390x/s390-virtio-ccw.c
>> +++ b/hw/s390x/s390-virtio-ccw.c
>> @@ -725,10 +725,6 @@ bool css_migration_enabled(void)
>>
>>  static void ccw_machine_2_12_instance_options(MachineState *machine)
>>  {
>> -    static const S390FeatInit qemu_cpu_feat = { S390_FEAT_LIST_QEMU_V2_12 };
>> -
>> -    /* with 2.12 we emulated a stripped down zEC12 (GA 2) */
>> -    s390_set_qemu_cpu_model(0x2827, 12, 2, qemu_cpu_feat);
>>  }
> 
> So what happens now when you specify a 2.10 machine? 

the 2.11 handler is called, initializing it to a z900.

$ qemu-system-s390x -nographic -machine s390-ccw-virtio-2.10 -hda
guest-tcg.qcow2
LOADPARM=[........]
Using virtio-blk.
Using SCSI scheme.
.....
The Linux kernel requires more recent processor hardware
Detected machine-type number: 2064
Missing facilities: 18,21,25,27,32,33,34,35,45,49,52
See Principles of Operations for facility bits

$ qemu-system-s390x -nographic -machine s390-ccw-virtio-2.12 -hda
guest-tcg.qcow2
LOADPARM=[........]
Using virtio-blk.
Using SCSI scheme.
.....
[    0.325571] Linux version 4.13.9-300.fc27.s390x ...
Cornelia Huck Dec. 13, 2017, 5:17 p.m. UTC | #3
On Wed, 13 Dec 2017 14:24:07 +0100
David Hildenbrand <david@redhat.com> wrote:

> Make sure "-cpu qemu" works with "-M none".
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>

This fixes using libvirt for me.

> ---
> 
> Conny, if this is okay, can you squash with the original patch?

Sure. Waiting until tomorrow in case anyone has feedback.

> 
>  hw/s390x/s390-virtio-ccw.c  | 4 ----
>  target/s390x/cpu_models.c   | 7 +++++--
>  target/s390x/gen-features.c | 4 ++--
>  3 files changed, 7 insertions(+), 8 deletions(-)
Cornelia Huck Dec. 14, 2017, 12:18 p.m. UTC | #4
On Wed, 13 Dec 2017 14:24:07 +0100
David Hildenbrand <david@redhat.com> wrote:

> Make sure "-cpu qemu" works with "-M none".
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
> 
> Conny, if this is okay, can you squash with the original patch?
> 
>  hw/s390x/s390-virtio-ccw.c  | 4 ----
>  target/s390x/cpu_models.c   | 7 +++++--
>  target/s390x/gen-features.c | 4 ++--
>  3 files changed, 7 insertions(+), 8 deletions(-)

Squashed into "s390x: change the QEMU cpu model to a stripped down z12".
diff mbox series

Patch

diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index c1f96418fa..466e45343c 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -725,10 +725,6 @@  bool css_migration_enabled(void)
 
 static void ccw_machine_2_12_instance_options(MachineState *machine)
 {
-    static const S390FeatInit qemu_cpu_feat = { S390_FEAT_LIST_QEMU_V2_12 };
-
-    /* with 2.12 we emulated a stripped down zEC12 (GA 2) */
-    s390_set_qemu_cpu_model(0x2827, 12, 2, qemu_cpu_feat);
 }
 
 static void ccw_machine_2_12_class_options(MachineClass *mc)
diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c
index 7404ef52c6..212a5f0697 100644
--- a/target/s390x/cpu_models.c
+++ b/target/s390x/cpu_models.c
@@ -1122,8 +1122,6 @@  static void s390_qemu_cpu_model_initfn(Object *obj)
     S390CPU *cpu = S390_CPU(obj);
 
     cpu->model = g_malloc0(sizeof(*cpu->model));
-    /* has to be initialized by now via s390_set_qemu_cpu_model() */
-    g_assert(s390_qemu_cpu_model.def);
     /* copy the CPU model so we can modify it */
     memcpy(cpu->model, &s390_qemu_cpu_model, sizeof(*cpu->model));
 }
@@ -1266,6 +1264,7 @@  static void init_ignored_base_feat(void)
 
 static void register_types(void)
 {
+    static const S390FeatInit qemu_latest_init = { S390_FEAT_LIST_QEMU_LATEST };
     int i;
 
     init_ignored_base_feat();
@@ -1281,6 +1280,10 @@  static void register_types(void)
                               s390_cpu_defs[i].full_feat);
     }
 
+    /* initialize the qemu model with latest definition */
+    s390_set_qemu_cpu_model(QEMU_MAX_CPU_TYPE, QEMU_MAX_CPU_GEN,
+                            QEMU_MAX_CPU_EC_GA, qemu_latest_init);
+
     for (i = 0; i < ARRAY_SIZE(s390_cpu_defs); i++) {
         char *base_name = s390_base_cpu_type_name(s390_cpu_defs[i].name);
         TypeInfo ti_base = {
diff --git a/target/s390x/gen-features.c b/target/s390x/gen-features.c
index 983f2dcd52..deace660e1 100644
--- a/target/s390x/gen-features.c
+++ b/target/s390x/gen-features.c
@@ -544,7 +544,7 @@  static uint16_t qemu_V2_11[] = {
     S390_FEAT_ZARCH,
 };
 
-static uint16_t qemu_V2_12[] = {
+static uint16_t qemu_LATEST[] = {
     S390_FEAT_DAT_ENH,
     S390_FEAT_IDTE_SEGMENT,
     S390_FEAT_STFLE,
@@ -685,7 +685,7 @@  static FeatGroupDefSpec FeatGroupDef[] = {
  *******************************/
 static FeatGroupDefSpec QemuFeatDef[] = {
     QEMU_FEAT_INITIALIZER(V2_11),
-    QEMU_FEAT_INITIALIZER(V2_12),
+    QEMU_FEAT_INITIALIZER(LATEST),
     QEMU_FEAT_INITIALIZER(MAX),
 };