diff mbox series

[v20,12/21] qapi/s390x/cpu topology: query-cpu-polarization qmp command

Message ID 20230425161456.21031-13-pmorel@linux.ibm.com
State New
Headers show
Series s390x: CPU Topology | expand

Commit Message

Pierre Morel April 25, 2023, 4:14 p.m. UTC
The query-cpu-polarization qmp command returns the current
CPU polarization of the machine.

Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
---
 qapi/machine-target.json | 30 ++++++++++++++++++++++++++++++
 hw/s390x/cpu-topology.c  | 14 ++++++++++++++
 2 files changed, 44 insertions(+)

Comments

Nina Schoetterl-Glausch May 10, 2023, 12:04 p.m. UTC | #1
On Tue, 2023-04-25 at 18:14 +0200, Pierre Morel wrote:
> The query-cpu-polarization qmp command returns the current
> CPU polarization of the machine.
> 
> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
> ---
>  qapi/machine-target.json | 30 ++++++++++++++++++++++++++++++
>  hw/s390x/cpu-topology.c  | 14 ++++++++++++++
>  2 files changed, 44 insertions(+)
> 
> diff --git a/qapi/machine-target.json b/qapi/machine-target.json
> index ffde2e9cbd..8eb05755cd 100644
> --- a/qapi/machine-target.json
> +++ b/qapi/machine-target.json
> @@ -4,6 +4,7 @@
>  # This work is licensed under the terms of the GNU GPL, version 2 or later.
>  # See the COPYING file in the top-level directory.
>  
> +{ 'include': 'common.json' }

Why do you need this?

>  { 'include': 'machine-common.json' }
>  
>  ##
> @@ -424,3 +425,32 @@
>    'features': [ 'unstable' ],
>    'if': { 'all': [ 'TARGET_S390X', 'CONFIG_KVM' ] }
>  }
> +
> +##
> +# @CpuPolarizationInfo:
> +#
> +# The result of a cpu polarization
> +#
> +# @polarization: the CPU polarization
> +#
> +# Since: 2.8

2.8?

> +##
> +{ 'struct': 'CpuPolarizationInfo',
> +  'data': { 'polarization': 'CpuS390Polarization' },
> +  'if': { 'all': [ 'TARGET_S390X', 'CONFIG_KVM' ] }
> +}
> +
> +##
> +# @query-cpu-polarization:
> +#
> +# Features:
> +# @unstable: This command may still be modified.
> +#
> +# Returns: the machine polarization
> +#
> +# Since: 8.1
> +##
> +{ 'command': 'query-cpu-polarization', 'returns': 'CpuPolarizationInfo',

Do you need the struct or could you use CpuS390Polarization directly here?
The struct allows for more flexibility in the future, I can't imagine a reason
why it'd be necessary, but I'm not opposed.


> +  'features': [ 'unstable' ],
> +  'if': { 'all': [ 'TARGET_S390X', 'CONFIG_KVM' ] }
> +}
> diff --git a/hw/s390x/cpu-topology.c b/hw/s390x/cpu-topology.c
> index e8b140d623..d440e8a3c6 100644
> --- a/hw/s390x/cpu-topology.c
> +++ b/hw/s390x/cpu-topology.c
> @@ -18,6 +18,7 @@
>  #include "hw/s390x/cpu-topology.h"
>  #include "qapi/qapi-commands-machine-target.h"
>  #include "qapi/qapi-events-machine-target.h"
> +#include "qapi/type-helpers.h"

What do you need this include for?

>  
>  /*
>   * s390_topology is used to keep the topology information.
> @@ -468,3 +469,16 @@ void qmp_set_cpu_topology(uint16_t core,
>                           has_drawer, drawer, has_entitlement, entitlement,
>                           has_dedicated, dedicated, errp);
>  }
> +
> +CpuPolarizationInfo *qmp_query_cpu_polarization(Error **errp)
> +{
> +    CpuPolarizationInfo *info = g_new0(CpuPolarizationInfo, 1);
> +
> +    if (s390_topology.vertical_polarization) {
> +        info->polarization = S390_CPU_POLARIZATION_VERTICAL;
> +    } else {
> +        info->polarization = S390_CPU_POLARIZATION_HORIZONTAL;
> +    }
> +
> +    return info;
> +}
Pierre Morel May 12, 2023, 11:56 a.m. UTC | #2
On 5/10/23 14:04, Nina Schoetterl-Glausch wrote:
> On Tue, 2023-04-25 at 18:14 +0200, Pierre Morel wrote:
>> The query-cpu-polarization qmp command returns the current
>> CPU polarization of the machine.
>>
>> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
>> ---
>>   qapi/machine-target.json | 30 ++++++++++++++++++++++++++++++
>>   hw/s390x/cpu-topology.c  | 14 ++++++++++++++
>>   2 files changed, 44 insertions(+)
>>
>> diff --git a/qapi/machine-target.json b/qapi/machine-target.json
>> index ffde2e9cbd..8eb05755cd 100644
>> --- a/qapi/machine-target.json
>> +++ b/qapi/machine-target.json
>> @@ -4,6 +4,7 @@
>>   # This work is licensed under the terms of the GNU GPL, version 2 or later.
>>   # See the COPYING file in the top-level directory.
>>   
>> +{ 'include': 'common.json' }
> Why do you need this?

exact, I do not need it.


>
>>   { 'include': 'machine-common.json' }
>>   
>>   ##
>> @@ -424,3 +425,32 @@
>>     'features': [ 'unstable' ],
>>     'if': { 'all': [ 'TARGET_S390X', 'CONFIG_KVM' ] }
>>   }
>> +
>> +##
>> +# @CpuPolarizationInfo:
>> +#
>> +# The result of a cpu polarization
>> +#
>> +# @polarization: the CPU polarization
>> +#
>> +# Since: 2.8
> 2.8?

yes, 8.1


>
>> +##
>> +{ 'struct': 'CpuPolarizationInfo',
>> +  'data': { 'polarization': 'CpuS390Polarization' },
>> +  'if': { 'all': [ 'TARGET_S390X', 'CONFIG_KVM' ] }
>> +}
>> +
>> +##
>> +# @query-cpu-polarization:
>> +#
>> +# Features:
>> +# @unstable: This command may still be modified.
>> +#
>> +# Returns: the machine polarization
>> +#
>> +# Since: 8.1
>> +##
>> +{ 'command': 'query-cpu-polarization', 'returns': 'CpuPolarizationInfo',
> Do you need the struct or could you use CpuS390Polarization directly here?
> The struct allows for more flexibility in the future, I can't imagine a reason
> why it'd be necessary, but I'm not opposed.

That is what I thought, keeping flexibility.



>
>
>> +  'features': [ 'unstable' ],
>> +  'if': { 'all': [ 'TARGET_S390X', 'CONFIG_KVM' ] }
>> +}
>> diff --git a/hw/s390x/cpu-topology.c b/hw/s390x/cpu-topology.c
>> index e8b140d623..d440e8a3c6 100644
>> --- a/hw/s390x/cpu-topology.c
>> +++ b/hw/s390x/cpu-topology.c
>> @@ -18,6 +18,7 @@
>>   #include "hw/s390x/cpu-topology.h"
>>   #include "qapi/qapi-commands-machine-target.h"
>>   #include "qapi/qapi-events-machine-target.h"
>> +#include "qapi/type-helpers.h"
> What do you need this include for?

I do not need it.


>
>>   
>>   /*
>>    * s390_topology is used to keep the topology information.
>> @@ -468,3 +469,16 @@ void qmp_set_cpu_topology(uint16_t core,
>>                            has_drawer, drawer, has_entitlement, entitlement,
>>                            has_dedicated, dedicated, errp);
>>   }
>> +
>> +CpuPolarizationInfo *qmp_query_cpu_polarization(Error **errp)
>> +{
>> +    CpuPolarizationInfo *info = g_new0(CpuPolarizationInfo, 1);
>> +
>> +    if (s390_topology.vertical_polarization) {
>> +        info->polarization = S390_CPU_POLARIZATION_VERTICAL;
>> +    } else {
>> +        info->polarization = S390_CPU_POLARIZATION_HORIZONTAL;
>> +    }
>> +
>> +    return info;
>> +}

Thanks,

I will clean this leftovers from the first draw.

Regards

Pierre
diff mbox series

Patch

diff --git a/qapi/machine-target.json b/qapi/machine-target.json
index ffde2e9cbd..8eb05755cd 100644
--- a/qapi/machine-target.json
+++ b/qapi/machine-target.json
@@ -4,6 +4,7 @@ 
 # This work is licensed under the terms of the GNU GPL, version 2 or later.
 # See the COPYING file in the top-level directory.
 
+{ 'include': 'common.json' }
 { 'include': 'machine-common.json' }
 
 ##
@@ -424,3 +425,32 @@ 
   'features': [ 'unstable' ],
   'if': { 'all': [ 'TARGET_S390X', 'CONFIG_KVM' ] }
 }
+
+##
+# @CpuPolarizationInfo:
+#
+# The result of a cpu polarization
+#
+# @polarization: the CPU polarization
+#
+# Since: 2.8
+##
+{ 'struct': 'CpuPolarizationInfo',
+  'data': { 'polarization': 'CpuS390Polarization' },
+  'if': { 'all': [ 'TARGET_S390X', 'CONFIG_KVM' ] }
+}
+
+##
+# @query-cpu-polarization:
+#
+# Features:
+# @unstable: This command may still be modified.
+#
+# Returns: the machine polarization
+#
+# Since: 8.1
+##
+{ 'command': 'query-cpu-polarization', 'returns': 'CpuPolarizationInfo',
+  'features': [ 'unstable' ],
+  'if': { 'all': [ 'TARGET_S390X', 'CONFIG_KVM' ] }
+}
diff --git a/hw/s390x/cpu-topology.c b/hw/s390x/cpu-topology.c
index e8b140d623..d440e8a3c6 100644
--- a/hw/s390x/cpu-topology.c
+++ b/hw/s390x/cpu-topology.c
@@ -18,6 +18,7 @@ 
 #include "hw/s390x/cpu-topology.h"
 #include "qapi/qapi-commands-machine-target.h"
 #include "qapi/qapi-events-machine-target.h"
+#include "qapi/type-helpers.h"
 
 /*
  * s390_topology is used to keep the topology information.
@@ -468,3 +469,16 @@  void qmp_set_cpu_topology(uint16_t core,
                          has_drawer, drawer, has_entitlement, entitlement,
                          has_dedicated, dedicated, errp);
 }
+
+CpuPolarizationInfo *qmp_query_cpu_polarization(Error **errp)
+{
+    CpuPolarizationInfo *info = g_new0(CpuPolarizationInfo, 1);
+
+    if (s390_topology.vertical_polarization) {
+        info->polarization = S390_CPU_POLARIZATION_VERTICAL;
+    } else {
+        info->polarization = S390_CPU_POLARIZATION_HORIZONTAL;
+    }
+
+    return info;
+}