Re: [Qemu-devel] [PATCHv2 1/3] qmp: expose s390-specific CPU info

2018-02-14 Thread David Hildenbrand
On 13.02.2018 18:18, Viktor Mihajlovski wrote:
> Presently s390x is the only architecture not exposing specific
> CPU information via QMP query-cpus. Upstream discussion has shown
> that it could make sense to report the architecture specific CPU
> state, e.g. to detect that a CPU has been stopped.
> 
> With this change the output of query-cpus will look like this on
> s390:
> 
>[
>  {"arch": "s390", "current": true,
>   "props": {"core-id": 0}, "cpu-state": "operating", "CPU": 0,
>   "qom_path": "/machine/unattached/device[0]",
>   "halted": false, "thread_id": 63115},
>  {"arch": "s390", "current": false,
>   "props": {"core-id": 1}, "cpu-state": "stopped", "CPU": 1,
>   "qom_path": "/machine/unattached/device[1]",
>   "halted": true, "thread_id": 63116}
>]
> 
> Signed-off-by: Viktor Mihajlovski 
> Acked-by: Eric Blake 
> ---
>  cpus.c |  6 ++
>  hmp.c  |  4 
>  hw/intc/s390_flic.c|  4 ++--
>  hw/s390x/s390-virtio-ccw.c |  2 +-
>  qapi-schema.json   | 28 +++-
>  target/s390x/cpu.c | 24 
>  target/s390x/cpu.h |  7 ++-
>  target/s390x/kvm.c |  8 
>  target/s390x/sigp.c| 38 +++---
>  9 files changed, 77 insertions(+), 44 deletions(-)
> 
> diff --git a/cpus.c b/cpus.c
> index f298b65..6006931 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -2100,6 +2100,9 @@ CpuInfoList *qmp_query_cpus(Error **errp)
>  #elif defined(TARGET_TRICORE)
>  TriCoreCPU *tricore_cpu = TRICORE_CPU(cpu);
>  CPUTriCoreState *env = &tricore_cpu->env;
> +#elif defined(TARGET_S390X)
> +S390CPU *s390_cpu = S390_CPU(cpu);
> +CPUS390XState *env = &s390_cpu->env;
>  #endif
>  
>  cpu_synchronize_state(cpu);
> @@ -2127,6 +2130,9 @@ CpuInfoList *qmp_query_cpus(Error **errp)
>  #elif defined(TARGET_TRICORE)
>  info->value->arch = CPU_INFO_ARCH_TRICORE;
>  info->value->u.tricore.PC = env->PC;
> +#elif defined(TARGET_S390X)
> +info->value->arch = CPU_INFO_ARCH_S390;
> +info->value->u.s390.cpu_state = env->cpu_state;
>  #else
>  info->value->arch = CPU_INFO_ARCH_OTHER;
>  #endif
> diff --git a/hmp.c b/hmp.c
> index 7870d6a..a6b94b7 100644
> --- a/hmp.c
> +++ b/hmp.c
> @@ -392,6 +392,10 @@ void hmp_info_cpus(Monitor *mon, const QDict *qdict)
>  case CPU_INFO_ARCH_TRICORE:
>  monitor_printf(mon, " PC=0x%016" PRIx64, 
> cpu->value->u.tricore.PC);
>  break;
> +case CPU_INFO_ARCH_S390:
> +monitor_printf(mon, " state=%s",
> +   CpuS390State_str(cpu->value->u.s390.cpu_state));
> +break;
>  default:
>  break;
>  }
> diff --git a/hw/intc/s390_flic.c b/hw/intc/s390_flic.c
> index a85a149..5f8168f 100644
> --- a/hw/intc/s390_flic.c
> +++ b/hw/intc/s390_flic.c
> @@ -192,8 +192,8 @@ static void qemu_s390_flic_notify(uint32_t type)
>  cs->interrupt_request |= CPU_INTERRUPT_HARD;
>  
>  /* ignore CPUs that are not sleeping */
> -if (s390_cpu_get_state(cpu) != CPU_STATE_OPERATING &&
> -s390_cpu_get_state(cpu) != CPU_STATE_LOAD) {
> +if (s390_cpu_get_state(cpu) != S390_CPU_STATE_OPERATING &&
> +s390_cpu_get_state(cpu) != S390_CPU_STATE_LOAD) {
>  continue;
>  }
>  
> diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
> index 4abbe89..4d0c3de 100644
> --- a/hw/s390x/s390-virtio-ccw.c
> +++ b/hw/s390x/s390-virtio-ccw.c
> @@ -368,7 +368,7 @@ static void s390_machine_reset(void)
>  
>  /* all cpus are stopped - configure and start the ipl cpu only */
>  s390_ipl_prepare_cpu(ipl_cpu);
> -s390_cpu_set_state(CPU_STATE_OPERATING, ipl_cpu);
> +s390_cpu_set_state(S390_CPU_STATE_OPERATING, ipl_cpu);
>  }
>  
>  static void s390_machine_device_plug(HotplugHandler *hotplug_dev,
> diff --git a/qapi-schema.json b/qapi-schema.json
> index 0262b9f..94d560e 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -410,10 +410,12 @@
>  # An enumeration of cpu types that enable additional information during
>  # @query-cpus.
>  #
> +# @s390: since 2.12
> +#
>  # Since: 2.6
>  ##
>  { 'enum': 'CpuInfoArch',
> -  'data': ['x86', 'sparc', 'ppc', 'mips', 'tricore', 'other' ] }
> +  'data': ['x86', 'sparc', 'ppc', 'mips', 'tricore', 's390', 'other' ] }
>  
>  ##
>  # @CpuInfo:
> @@ -452,6 +454,7 @@
>  'ppc': 'CpuInfoPPC',
>  'mips': 'CpuInfoMIPS',
>  'tricore': 'CpuInfoTricore',
> +'s390': 'CpuInfoS390',
>  'other': 'CpuInfoOther' } }
>  
>  ##
> @@ -522,6 +525,29 @@
>  { 'struct': 'CpuInfoOther', 'data': { } }
>  
>  ##
> +# @CpuS390State:
> +#
> +# An enumeration of cpu states that can be assumed by a virtual
> +# S390 CPU
> +#
> +# Since: 2.12
> +##
> +{ 'enum': 'CpuS390State',
> +  'prefix': 'S390_CPU_ST

Re: [Qemu-devel] [PATCHv2 1/3] qmp: expose s390-specific CPU info

2018-02-14 Thread Christian Borntraeger


On 02/13/2018 06:18 PM, Viktor Mihajlovski wrote:
> Presently s390x is the only architecture not exposing specific
> CPU information via QMP query-cpus. Upstream discussion has shown
> that it could make sense to report the architecture specific CPU
> state, e.g. to detect that a CPU has been stopped.
> 
> With this change the output of query-cpus will look like this on
> s390:
> 
>[
>  {"arch": "s390", "current": true,
>   "props": {"core-id": 0}, "cpu-state": "operating", "CPU": 0,
>   "qom_path": "/machine/unattached/device[0]",
>   "halted": false, "thread_id": 63115},
>  {"arch": "s390", "current": false,
>   "props": {"core-id": 1}, "cpu-state": "stopped", "CPU": 1,
>   "qom_path": "/machine/unattached/device[1]",
>   "halted": true, "thread_id": 63116}
>]
> 
> Signed-off-by: Viktor Mihajlovski 
> Acked-by: Eric Blake 

Reviewed-by: Christian Borntraeger 




[Qemu-devel] [PATCHv2 1/3] qmp: expose s390-specific CPU info

2018-02-13 Thread Viktor Mihajlovski
Presently s390x is the only architecture not exposing specific
CPU information via QMP query-cpus. Upstream discussion has shown
that it could make sense to report the architecture specific CPU
state, e.g. to detect that a CPU has been stopped.

With this change the output of query-cpus will look like this on
s390:

   [
 {"arch": "s390", "current": true,
  "props": {"core-id": 0}, "cpu-state": "operating", "CPU": 0,
  "qom_path": "/machine/unattached/device[0]",
  "halted": false, "thread_id": 63115},
 {"arch": "s390", "current": false,
  "props": {"core-id": 1}, "cpu-state": "stopped", "CPU": 1,
  "qom_path": "/machine/unattached/device[1]",
  "halted": true, "thread_id": 63116}
   ]

Signed-off-by: Viktor Mihajlovski 
Acked-by: Eric Blake 
---
 cpus.c |  6 ++
 hmp.c  |  4 
 hw/intc/s390_flic.c|  4 ++--
 hw/s390x/s390-virtio-ccw.c |  2 +-
 qapi-schema.json   | 28 +++-
 target/s390x/cpu.c | 24 
 target/s390x/cpu.h |  7 ++-
 target/s390x/kvm.c |  8 
 target/s390x/sigp.c| 38 +++---
 9 files changed, 77 insertions(+), 44 deletions(-)

diff --git a/cpus.c b/cpus.c
index f298b65..6006931 100644
--- a/cpus.c
+++ b/cpus.c
@@ -2100,6 +2100,9 @@ CpuInfoList *qmp_query_cpus(Error **errp)
 #elif defined(TARGET_TRICORE)
 TriCoreCPU *tricore_cpu = TRICORE_CPU(cpu);
 CPUTriCoreState *env = &tricore_cpu->env;
+#elif defined(TARGET_S390X)
+S390CPU *s390_cpu = S390_CPU(cpu);
+CPUS390XState *env = &s390_cpu->env;
 #endif
 
 cpu_synchronize_state(cpu);
@@ -2127,6 +2130,9 @@ CpuInfoList *qmp_query_cpus(Error **errp)
 #elif defined(TARGET_TRICORE)
 info->value->arch = CPU_INFO_ARCH_TRICORE;
 info->value->u.tricore.PC = env->PC;
+#elif defined(TARGET_S390X)
+info->value->arch = CPU_INFO_ARCH_S390;
+info->value->u.s390.cpu_state = env->cpu_state;
 #else
 info->value->arch = CPU_INFO_ARCH_OTHER;
 #endif
diff --git a/hmp.c b/hmp.c
index 7870d6a..a6b94b7 100644
--- a/hmp.c
+++ b/hmp.c
@@ -392,6 +392,10 @@ void hmp_info_cpus(Monitor *mon, const QDict *qdict)
 case CPU_INFO_ARCH_TRICORE:
 monitor_printf(mon, " PC=0x%016" PRIx64, cpu->value->u.tricore.PC);
 break;
+case CPU_INFO_ARCH_S390:
+monitor_printf(mon, " state=%s",
+   CpuS390State_str(cpu->value->u.s390.cpu_state));
+break;
 default:
 break;
 }
diff --git a/hw/intc/s390_flic.c b/hw/intc/s390_flic.c
index a85a149..5f8168f 100644
--- a/hw/intc/s390_flic.c
+++ b/hw/intc/s390_flic.c
@@ -192,8 +192,8 @@ static void qemu_s390_flic_notify(uint32_t type)
 cs->interrupt_request |= CPU_INTERRUPT_HARD;
 
 /* ignore CPUs that are not sleeping */
-if (s390_cpu_get_state(cpu) != CPU_STATE_OPERATING &&
-s390_cpu_get_state(cpu) != CPU_STATE_LOAD) {
+if (s390_cpu_get_state(cpu) != S390_CPU_STATE_OPERATING &&
+s390_cpu_get_state(cpu) != S390_CPU_STATE_LOAD) {
 continue;
 }
 
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 4abbe89..4d0c3de 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -368,7 +368,7 @@ static void s390_machine_reset(void)
 
 /* all cpus are stopped - configure and start the ipl cpu only */
 s390_ipl_prepare_cpu(ipl_cpu);
-s390_cpu_set_state(CPU_STATE_OPERATING, ipl_cpu);
+s390_cpu_set_state(S390_CPU_STATE_OPERATING, ipl_cpu);
 }
 
 static void s390_machine_device_plug(HotplugHandler *hotplug_dev,
diff --git a/qapi-schema.json b/qapi-schema.json
index 0262b9f..94d560e 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -410,10 +410,12 @@
 # An enumeration of cpu types that enable additional information during
 # @query-cpus.
 #
+# @s390: since 2.12
+#
 # Since: 2.6
 ##
 { 'enum': 'CpuInfoArch',
-  'data': ['x86', 'sparc', 'ppc', 'mips', 'tricore', 'other' ] }
+  'data': ['x86', 'sparc', 'ppc', 'mips', 'tricore', 's390', 'other' ] }
 
 ##
 # @CpuInfo:
@@ -452,6 +454,7 @@
 'ppc': 'CpuInfoPPC',
 'mips': 'CpuInfoMIPS',
 'tricore': 'CpuInfoTricore',
+'s390': 'CpuInfoS390',
 'other': 'CpuInfoOther' } }
 
 ##
@@ -522,6 +525,29 @@
 { 'struct': 'CpuInfoOther', 'data': { } }
 
 ##
+# @CpuS390State:
+#
+# An enumeration of cpu states that can be assumed by a virtual
+# S390 CPU
+#
+# Since: 2.12
+##
+{ 'enum': 'CpuS390State',
+  'prefix': 'S390_CPU_STATE',
+  'data': [ 'uninitialized', 'stopped', 'check-stop', 'operating', 'load' ] }
+
+##
+# @CpuInfoS390:
+#
+# Additional information about a virtual S390 CPU
+#
+# @cpu-state: the virtual CPU's state
+#
+# Since: 2.12
+##
+{ 'struct': 'CpuInfoS390', 'data': { 'cpu-state': 'CpuS390State' } }
+
+##
 # @query-cpus:
 #
 # Retu