Skip to contentSkip to conversation

hw/s390x: add SCLP event type CPI

PATCH Superseded Shalini Chellathurai Saroja 3 participants 8 messages Jan 15, 2025 – Feb 24, 2025 Arm/Amlogic Meson SoC support

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 hw/s390x: add SCLP event type CPI

This commit implements the SCLP event type Control-Program Identification in QEMU. Control-program is an IBM term for operating system. This event is used to send firmware program identifiers from KVM guest to SCLP. The program identifiers provide data about the guest OS. The program identifiers are system type, system name, system level and sysplex name.

System type provides the OS type of the guest. System name provides the name of the guest. System level provides the distribution and kernel version of the guest OS. Sysplex name provides sysplex name of the guest.

---
 hw/s390x/event-facility.c         | 12 +++-
 hw/s390x/meson.build              |  1 +
 hw/s390x/sclpcpi.c                | 94 +++++++++++++++++++++++++++++++
 include/hw/s390x/event-facility.h |  3 +
 4 files changed, 109 insertions(+), 1 deletion(-)
 create mode 100644 hw/s390x/sclpcpi.c
hw/s390x/event-facility.c +11 -1
index 2b0332c20e..c0fb6e098c 100644
@@ -39,7 +39,7 @@ typedef struct SCLPEventsBus {
 struct SCLPEventFacility {
     SysBusDevice parent_obj;
     SCLPEventsBus sbus;
-    SCLPEvent quiesce, cpu_hotplug;
+    SCLPEvent quiesce, cpu_hotplug, cpi;
     /* guest's receive mask */
     union {
         uint32_t receive_mask_pieces[2];
@@ -436,6 +436,10 @@ static void init_event_facility(Object *obj)
     object_initialize_child(obj, TYPE_SCLP_CPU_HOTPLUG,
                             &event_facility->cpu_hotplug,
                             TYPE_SCLP_CPU_HOTPLUG);
+
+    object_initialize_child(obj, TYPE_SCLP_CPI,
+                            &event_facility->cpi,
+                            TYPE_SCLP_CPI);
 }
 
 static void realize_event_facility(DeviceState *dev, Error **errp)
@@ -451,6 +455,12 @@ static void realize_event_facility(DeviceState *dev, Error **errp)
         qdev_unrealize(DEVICE(&event_facility->quiesce));
         return;
     }
+    if (!qdev_realize(DEVICE(&event_facility->cpi),
+                      BUS(&event_facility->sbus), errp)) {
+        qdev_unrealize(DEVICE(&event_facility->quiesce));
+        qdev_unrealize(DEVICE(&event_facility->cpu_hotplug));
+        return;
+    }
 }
 
 static void reset_event_facility(DeviceState *dev)
hw/s390x/meson.build +1 -0
index 3bbebfd817..eb7950489c 100644
@@ -13,6 +13,7 @@ s390x_ss.add(files(
   's390-skeys.c',
   's390-stattrib.c',
   'sclp.c',
+  'sclpcpi.c',
   'sclpcpu.c',
   'sclpquiesce.c',
   'tod.c',
hw/s390x/sclpcpi.c new file +94 -0

94 lines not on this page · raw message

include/hw/s390x/event-facility.h +3 -0
index ff874e792d..f445d2f9f5 100644
@@ -25,6 +25,7 @@
 #define SCLP_EVENT_MESSAGE                      0x02
 #define SCLP_EVENT_CONFIG_MGT_DATA              0x04
 #define SCLP_EVENT_PMSGCMD                      0x09
+#define SCLP_EVENT_CPI                          0x0b
 #define SCLP_EVENT_ASCII_CONSOLE_DATA           0x1a
 #define SCLP_EVENT_SIGNAL_QUIESCE               0x1d
 
@@ -35,6 +36,7 @@
 #define SCLP_EVENT_MASK_MSG             SCLP_EVMASK(SCLP_EVENT_MESSAGE)
 #define SCLP_EVENT_MASK_CONFIG_MGT_DATA SCLP_EVMASK(SCLP_EVENT_CONFIG_MGT_DATA)
 #define SCLP_EVENT_MASK_PMSGCMD         SCLP_EVMASK(SCLP_EVENT_PMSGCMD)
+#define SCLP_EVENT_MASK_CPI             SCLP_EVMASK(SCLP_EVENT_CPI)
 #define SCLP_EVENT_MASK_MSG_ASCII       SCLP_EVMASK(SCLP_EVENT_ASCII_CONSOLE_DATA)
 #define SCLP_EVENT_MASK_SIGNAL_QUIESCE  SCLP_EVMASK(SCLP_EVENT_SIGNAL_QUIESCE)
 
@@ -46,6 +48,7 @@ OBJECT_DECLARE_TYPE(SCLPEvent, SCLPEventClass,
                     SCLP_EVENT)
 
 #define TYPE_SCLP_CPU_HOTPLUG "sclp-cpu-hotplug"
+#define TYPE_SCLP_CPI "sclpcpi"
 #define TYPE_SCLP_QUIESCE "sclpquiesce"
 
 #define SCLP_EVENT_MASK_LEN_MAX 1021
Signature · 1 line
2.47.0
#1 lore raw

PATCH 2/3 hw/s390x: add CPI values to QOM

This commit adds the firmware control-program identifiers received from a KVM guest via the SCLP event type Control-Program Identification to QOM. A timestamp in which the data is received is also added to QOM.

Example:
virsh # qemu-monitor-command vm --pretty '{ "execute":"qom-get","arguments": {
"path": "/machine", "property": "s390-cpi"}}' {

  "return": {
    "timestamp": 1711620874948254000,
    "system-level": "0x50e00",
    "sysplex-name": "SYSPLEX ",
    "system-name": "TESTVM  ",
    "system-type": "LINUX   "

},
"id": "libvirt-15"
}

---
 hw/s390x/s390-virtio-ccw.c         | 26 ++++++++++++++++++++++++++
 hw/s390x/sclpcpi.c                 | 10 ++++++++++
 include/hw/s390x/s390-virtio-ccw.h |  8 ++++++++
 qapi/machine.json                  | 24 ++++++++++++++++++++++++
 4 files changed, 68 insertions(+)
hw/s390x/s390-virtio-ccw.c +26 -0
index 38aeba14ee..35fb523af9 100644
@@ -49,6 +49,7 @@
 #include "hw/virtio/virtio-md-pci.h"
 #include "hw/s390x/virtio-ccw-md.h"
 #include CONFIG_DEVICES
+#include "qapi/qapi-visit-machine.h"
 
 static Error *pv_mig_blocker;
 
@@ -773,6 +774,25 @@ static void machine_set_loadparm(Object *obj, Visitor *v,
     s390_ipl_fmt_loadparm(ms->loadparm, val, errp);
 }
 
+static void machine_get_cpi(Object *obj, Visitor *v,
+                             const char *name, void *opaque, Error **errp)
+{
+    S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
+    S390Cpi *cpi;
+    cpi = &(S390Cpi){
+        .system_type = g_strndup((char *) ms->cpi.system_type,
+                       sizeof(ms->cpi.system_type)),
+        .system_name = g_strndup((char *) ms->cpi.system_name,
+                       sizeof(ms->cpi.system_name)),
+        .system_level = g_strdup_printf("0x%lx", ms->cpi.system_level),
+        .sysplex_name = g_strndup((char *) ms->cpi.sysplex_name,
+                        sizeof(ms->cpi.sysplex_name)),
+        .timestamp = ms->cpi.timestamp
+    };
+
+    visit_type_S390Cpi(v, name, &cpi, &error_abort);
+}
+
 static void ccw_machine_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
@@ -826,6 +846,12 @@ static void ccw_machine_class_init(ObjectClass *oc, void *data)
             "Up to 8 chars in set of [A-Za-z0-9. ] (lower case chars converted"
             " to upper case) to pass to machine loader, boot manager,"
             " and guest kernel");
+    object_class_property_add(oc, "s390-cpi", "S390Cpi",
+        machine_get_cpi, NULL, NULL, NULL);
+    object_class_property_set_description(oc, "s390-cpi",
+        "Control-progam identifiers provide data about the guest "
+        "operating system");
+
 }
 
 static inline void s390_machine_initfn(Object *obj)
hw/s390x/sclpcpi.c +10 -0
index 64bc730f47..75101b8f61 100644
@@ -20,8 +20,11 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/timer.h"
 #include "hw/s390x/sclp.h"
 #include "hw/s390x/event-facility.h"
+#include "hw/s390x/ebcdic.h"
+#include "hw/s390x/s390-virtio-ccw.h"
 
 typedef struct Data {
     uint8_t id_format;
@@ -60,6 +63,13 @@ static sccb_mask_t receive_mask(void)
 static int write_event_data(SCLPEvent *event, EventBufferHeader *evt_buf_hdr)
 {
     CPI *cpi = container_of(evt_buf_hdr, CPI, ebh);
+    S390CcwMachineState *ms = S390_CCW_MACHINE(qdev_get_machine());
+
+    ascii_put(ms->cpi.system_type, (char *)cpi->data.system_type, 8);
+    ascii_put(ms->cpi.system_name, (char *)cpi->data.system_name, 8);
+    ascii_put(ms->cpi.sysplex_name, (char *)cpi->data.sysplex_name, 8);
+    ms->cpi.system_level = cpi->data.system_level;
+    ms->cpi.timestamp = qemu_clock_get_ns(QEMU_CLOCK_HOST);
 
     cpi->ebh.flags = SCLP_EVENT_BUFFER_ACCEPTED;
     return SCLP_RC_NORMAL_COMPLETION;
include/hw/s390x/s390-virtio-ccw.h +8 -0
index 686d9497d2..c4212ff857 100644
@@ -19,6 +19,13 @@
 
 OBJECT_DECLARE_TYPE(S390CcwMachineState, S390CcwMachineClass, S390_CCW_MACHINE)
 
+typedef struct Cpi {
+    uint8_t system_type[8];
+    uint8_t system_name[8];
+    uint64_t system_level;
+    uint8_t sysplex_name[8];
+    uint64_t timestamp;
+} QEMU_PACKED Cpi;
 
 struct S390CcwMachineState {
     /*< private >*/
@@ -33,6 +40,7 @@ struct S390CcwMachineState {
     uint64_t max_pagesize;
 
     SCLPDevice *sclp;
+    Cpi cpi;
 };
 
 static inline uint64_t s390_get_memory_limit(S390CcwMachineState *s390ms)
qapi/machine.json +24 -0
index a6b8795b09..9dcd2790eb 100644
@@ -1898,3 +1898,27 @@
 { 'command': 'x-query-interrupt-controllers',
   'returns': 'HumanReadableText',
   'features': [ 'unstable' ]}
+
+##
+# @S390Cpi:
+#
+# Control-program identifiers provide data about Linux instance.
+#
+# @system-type: operating system of Linux instance
+#
+# @system-name: system name of Linux instance
+#
+# @system-level: distribution and kernel version of Linux instance
+#
+# @sysplex-name: sysplex name of Linux instance
+#
+# @timestamp: latest update of CPI data
+#
+# Since: 9.2
+##
+{ 'struct': 'S390Cpi', 'data': {
+     'system-type': 'str',
+     'system-name': 'str',
+     'system-level': 'str',
+     'sysplex-name': 'str',
+     'timestamp': 'uint64' } }
Signature · 1 line
2.47.0
#2 lore raw

Re: [PATCH v1 2/3] hw/s390x: add CPI values to QOM

Quoted 46 lines · Shalini Chellathurai Saroja

This commit adds the firmware control-program identifiers received from a KVM guest via the SCLP event type Control-Program Identification to QOM. A timestamp in which the data is received is also added to QOM.

Example:
virsh # qemu-monitor-command vm --pretty '{ "execute":"qom-get","arguments": {
"path": "/machine", "property": "s390-cpi"}}' {

  "return": {
    "timestamp": 1711620874948254000,
    "system-level": "0x50e00",
    "sysplex-name": "SYSPLEX ",
    "system-name": "TESTVM  ",
    "system-type": "LINUX   "

},
"id": "libvirt-15"
}

---
 hw/s390x/s390-virtio-ccw.c         | 26 ++++++++++++++++++++++++++
 hw/s390x/sclpcpi.c                 | 10 ++++++++++
 include/hw/s390x/s390-virtio-ccw.h |  8 ++++++++
 qapi/machine.json                  | 24 ++++++++++++++++++++++++
 4 files changed, 68 insertions(+)
hw/s390x/s390-virtio-ccw.c +2 -0
index 38aeba14ee..35fb523af9 100644
@@ -49,6 +49,7 @@
 #include "hw/virtio/virtio-md-pci.h"
 #include "hw/s390x/virtio-ccw-md.h"
 #include CONFIG_DEVICES
+#include "qapi/qapi-visit-machine.h"
 
 static Error *pv_mig_blocker;
 
@@ -773,6 +774,25 @@ static void machine_set_loadparm(Object *obj, Visitor *v,
     s390_ipl_fmt_loadparm(ms->loadparm, val, errp);
 }
 
+static void machine_get_cpi(Object *obj, Visitor *v,

hw/s390x/s390-virtio-ccw.c static void machine_set_loadparm(Object *obj, Visitor *v, · line 787

Quoted 10 lines
hw/s390x/s390-virtio-ccw.c +10 -0
+                             const char *name, void *opaque, Error **errp)
+{
+    S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
+    S390Cpi *cpi;
+    cpi = &(S390Cpi){
+        .system_type = g_strndup((char *) ms->cpi.system_type,
+                       sizeof(ms->cpi.system_type)),
+        .system_name = g_strndup((char *) ms->cpi.system_name,
+                       sizeof(ms->cpi.system_name)),
+        .system_level = g_strdup_printf("0x%lx", ms->cpi.system_level),

Is there any way in which it would make sense for the qmp caller to interpret this as a number? If so exposing it as a number would be preferable.

Quoted 41 lines
hw/s390x/s390-virtio-ccw.c +14 -0
+        .sysplex_name = g_strndup((char *) ms->cpi.sysplex_name,
+                        sizeof(ms->cpi.sysplex_name)),
+        .timestamp = ms->cpi.timestamp
+    };
+
+    visit_type_S390Cpi(v, name, &cpi, &error_abort);
+}
+
 static void ccw_machine_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
@@ -826,6 +846,12 @@ static void ccw_machine_class_init(ObjectClass *oc, void *data)
             "Up to 8 chars in set of [A-Za-z0-9. ] (lower case chars converted"
             " to upper case) to pass to machine loader, boot manager,"
             " and guest kernel");
+    object_class_property_add(oc, "s390-cpi", "S390Cpi",
+        machine_get_cpi, NULL, NULL, NULL);
+    object_class_property_set_description(oc, "s390-cpi",
+        "Control-progam identifiers provide data about the guest "
+        "operating system");
+
 }
 
 static inline void s390_machine_initfn(Object *obj)
hw/s390x/sclpcpi.c +3 -0
index 64bc730f47..75101b8f61 100644
@@ -20,8 +20,11 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/timer.h"
 #include "hw/s390x/sclp.h"
 #include "hw/s390x/event-facility.h"
+#include "hw/s390x/ebcdic.h"
+#include "hw/s390x/s390-virtio-ccw.h"
 
 typedef struct Data {
     uint8_t id_format;

hw/s390x/sclpcpi.c static sccb_mask_t receive_mask(void) · line 71

Quoted 9 lines
hw/s390x/sclpcpi.c +6 -0
@@ -60,6 +63,13 @@ static sccb_mask_t receive_mask(void)
 static int write_event_data(SCLPEvent *event, EventBufferHeader *evt_buf_hdr)
 {
     CPI *cpi = container_of(evt_buf_hdr, CPI, ebh);
+    S390CcwMachineState *ms = S390_CCW_MACHINE(qdev_get_machine());
+
+    ascii_put(ms->cpi.system_type, (char *)cpi->data.system_type, 8);
+    ascii_put(ms->cpi.system_name, (char *)cpi->data.system_name, 8);
+    ascii_put(ms->cpi.sysplex_name, (char *)cpi->data.sysplex_name, 8);
+    ms->cpi.system_level = cpi->data.system_level;

cpi is overlayed with the sccb copied from the guest, correct? So you need a endianess conversion here.

Quoted 9 lines
hw/s390x/sclpcpi.c +1 -0
+    ms->cpi.timestamp = qemu_clock_get_ns(QEMU_CLOCK_HOST);
 
     cpi->ebh.flags = SCLP_EVENT_BUFFER_ACCEPTED;
     return SCLP_RC_NORMAL_COMPLETION;
include/hw/s390x/s390-virtio-ccw.h +0 -0
index 686d9497d2..c4212ff857 100644

include/hw/s390x/s390-virtio-ccw.h line 28

Quoted 10 lines
include/hw/s390x/s390-virtio-ccw.h +7 -0
@@ -19,6 +19,13 @@
 
 OBJECT_DECLARE_TYPE(S390CcwMachineState, S390CcwMachineClass, S390_CCW_MACHINE)
 
+typedef struct Cpi {
+    uint8_t system_type[8];
+    uint8_t system_name[8];
+    uint64_t system_level;
+    uint8_t sysplex_name[8];
+    uint64_t timestamp;
+} QEMU_PACKED Cpi;

I don't like there being a CPI and a Cpi struct. I'd just go ahead and inline the definition into S390CcwMachineState and not name this type.

Quoted 16 lines
include/hw/s390x/s390-virtio-ccw.h +1 -0
 struct S390CcwMachineState {
     /*< private >*/
@@ -33,6 +40,7 @@ struct S390CcwMachineState {
     uint64_t max_pagesize;
 
     SCLPDevice *sclp;
+    Cpi cpi;
 };
 
 static inline uint64_t s390_get_memory_limit(S390CcwMachineState *s390ms)
qapi/machine.json +0 -0
index a6b8795b09..9dcd2790eb 100644

qapi/machine.json line 1903

Quoted 6 lines
qapi/machine.json +3 -0
@@ -1898,3 +1898,27 @@
 { 'command': 'x-query-interrupt-controllers',
   'returns': 'HumanReadableText',
   'features': [ 'unstable' ]}
+
+##
+# @S390Cpi:

Maybe spelling this out would be preferable?
S390ControlProgramId?

Quoted 21 lines
qapi/machine.json +21 -0
+#
+# Control-program identifiers provide data about Linux instance.
+#
+# @system-type: operating system of Linux instance
+#
+# @system-name: system name of Linux instance
+#
+# @system-level: distribution and kernel version of Linux instance
+#
+# @sysplex-name: sysplex name of Linux instance
+#
+# @timestamp: latest update of CPI data
+#
+# Since: 9.2
+##
+{ 'struct': 'S390Cpi', 'data': {
+     'system-type': 'str',
+     'system-name': 'str',
+     'system-level': 'str',
+     'sysplex-name': 'str',
+     'timestamp': 'uint64' } }
#3 lore raw

Re: [PATCH v1 2/3] hw/s390x: add CPI values to QOM

Quoted 47 lines · Nina Schoetterl-Glausch
Quoted 46 lines · Shalini Chellathurai Saroja

This commit adds the firmware control-program identifiers received from a KVM guest via the SCLP event type Control-Program Identification to QOM. A timestamp in which the data is received is also added to QOM.

Example:
virsh # qemu-monitor-command vm --pretty '{ "execute":"qom-get","arguments": {
"path": "/machine", "property": "s390-cpi"}}' {

  "return": {
    "timestamp": 1711620874948254000,
    "system-level": "0x50e00",
    "sysplex-name": "SYSPLEX ",
    "system-name": "TESTVM  ",
    "system-type": "LINUX   "

},
"id": "libvirt-15"
}

---
 hw/s390x/s390-virtio-ccw.c         | 26 ++++++++++++++++++++++++++
 hw/s390x/sclpcpi.c                 | 10 ++++++++++
 include/hw/s390x/s390-virtio-ccw.h |  8 ++++++++
 qapi/machine.json                  | 24 ++++++++++++++++++++++++
 4 files changed, 68 insertions(+)
hw/s390x/s390-virtio-ccw.c +1 -0
index 38aeba14ee..35fb523af9 100644
@@ -49,6 +49,7 @@
 #include "hw/virtio/virtio-md-pci.h"
 #include "hw/s390x/virtio-ccw-md.h"
 #include CONFIG_DEVICES
+#include "qapi/qapi-visit-machine.h"
 
 static Error *pv_mig_blocker;
 
@@ -773,6 +774,25 @@ static void machine_set_loadparm(Object *obj, 
 Visitor *v,
     s390_ipl_fmt_loadparm(ms->loadparm, val, errp);
 }
 
Quoted 17 lines

hw/s390x/s390-virtio-ccw.c static void machine_set_loadparm(Object *obj, Visitor *v,

Quoted 13 lines
hw/s390x/s390-virtio-ccw.c +11 -0
+static void machine_get_cpi(Object *obj, Visitor *v,
+                             const char *name, void *opaque, Error 
 **errp)
+{
+    S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
+    S390Cpi *cpi;
+    cpi = &(S390Cpi){
+        .system_type = g_strndup((char *) ms->cpi.system_type,
+                       sizeof(ms->cpi.system_type)),
+        .system_name = g_strndup((char *) ms->cpi.system_name,
+                       sizeof(ms->cpi.system_name)),
+        .system_level = g_strdup_printf("0x%lx", 
 ms->cpi.system_level),

Is there any way in which it would make sense for the qmp caller to interpret this as a number? If so exposing it as a number would be preferable.

Hello Nina,

As discussed offline, when interpreted as a number the output was

'system-level': 74872343805430528

however, the desired output is

'system-level': '0x10a000000060b00'

So, this code is not changed in v2. Thank you.

Quoted 8 lines
Quoted 8 lines
hw/s390x/s390-virtio-ccw.c +8 -0
+        .sysplex_name = g_strndup((char *) ms->cpi.sysplex_name,
+                        sizeof(ms->cpi.sysplex_name)),
+        .timestamp = ms->cpi.timestamp
+    };
+
+    visit_type_S390Cpi(v, name, &cpi, &error_abort);
+}
+
Signature · 9 lines
Mit freundlichen Grüßen / Kind regards
Shalini Chellathurai Saroja
Software Developer
Linux on IBM Z & KVM Development
IBM Deutschland Research & Development GmbH
Dept 1419, Schoenaicher Str. 220, 71032 Boeblingen
Vorsitzender des Aufsichtsrats: Wolfgang Wendt
Geschäftsführung: David Faller
Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294
#4 lore raw

PATCH 3/3 hw/s390x: support migration of CPI values

In reply to Shalini Chellathurai Saroja

This commit saves the state of CPI values in the guest and transfers this state during live migration of the guest.

---
 hw/s390x/s390-virtio-ccw.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
hw/s390x/s390-virtio-ccw.c +17 -0
index 35fb523af9..8fe0c5c1cb 100644
@@ -259,6 +259,20 @@ static void s390_create_sclpconsole(SCLPDevice *sclp,
     qdev_realize_and_unref(dev, ev_fac_bus, &error_fatal);
 }
 
+static const VMStateDescription vmstate_cpi = {
+    .name = "s390_cpi",
+    .version_id = 0,
+    .minimum_version_id = 0,
+    .fields = (const VMStateField[]) {
+        VMSTATE_UINT8_ARRAY(system_type, Cpi, 8),
+        VMSTATE_UINT8_ARRAY(system_name, Cpi, 8),
+        VMSTATE_UINT64(system_level, Cpi),
+        VMSTATE_UINT8_ARRAY(sysplex_name, Cpi, 8),
+        VMSTATE_UINT64(timestamp, Cpi),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 static void ccw_init(MachineState *machine)
 {
     MachineClass *mc = MACHINE_GET_CLASS(machine);
@@ -307,6 +321,9 @@ static void ccw_init(MachineState *machine)
     ret = css_create_css_image(VIRTUAL_CSSID, true);
     assert(ret == 0);
 
+    /* register CPI values */
+    vmstate_register_any(NULL, &vmstate_cpi, &ms->cpi);
+
     css_register_vmstate();
 
     /* Create VirtIO network adapters */
Signature · 1 line
2.47.0
Reviewed-by on v1 3/3
#5 lore raw

Re: [PATCH v1 3/3] hw/s390x: support migration of CPI values

Quoted 2 lines · Shalini Chellathurai Saroja

This commit saves the state of CPI values in the guest and transfers this state during live migration of the guest.

IMO, using active voice and directly stating what is done is preferable.

Something like:
Register Control-Program Identifier data with the migration infrastructure.

"This commit" doesn't really add anything. (Applies to other commits also)
I also prefer verbosity when it comes to abbreviations.

Quoted 15 lines
---
 hw/s390x/s390-virtio-ccw.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
hw/s390x/s390-virtio-ccw.c +1 -0
index 35fb523af9..8fe0c5c1cb 100644
@@ -259,6 +259,20 @@ static void s390_create_sclpconsole(SCLPDevice *sclp,
     qdev_realize_and_unref(dev, ev_fac_bus, &error_fatal);
 }
 
+static const VMStateDescription vmstate_cpi = {

hw/s390x/s390-virtio-ccw.c static void s390_create_sclpconsole(SCLPDevice *sclp, · line 272

Quoted 10 lines
hw/s390x/s390-virtio-ccw.c +10 -0
+    .name = "s390_cpi",
+    .version_id = 0,
+    .minimum_version_id = 0,
+    .fields = (const VMStateField[]) {
+        VMSTATE_UINT8_ARRAY(system_type, Cpi, 8),
+        VMSTATE_UINT8_ARRAY(system_name, Cpi, 8),
+        VMSTATE_UINT64(system_level, Cpi),
+        VMSTATE_UINT8_ARRAY(sysplex_name, Cpi, 8),
+        VMSTATE_UINT64(timestamp, Cpi),
+        VMSTATE_END_OF_LIST()

I see, you need the Cpi type here.
How about naming it ControlProgramId and renaming CPI to ControlProgramIdMsg or similar?

With that sorted out:

#6 lore raw

Re: [PATCH v1 3/3] hw/s390x: support migration of CPI values

Quoted 44 lines · Nina Schoetterl-Glausch
Quoted 2 lines · Shalini Chellathurai Saroja

This commit saves the state of CPI values in the guest and transfers this state during live migration of the guest.

IMO, using active voice and directly stating what is done is preferable.

Something like:
Register Control-Program Identifier data with the migration infrastructure.

"This commit" doesn't really add anything. (Applies to other commits also)
I also prefer verbosity when it comes to abbreviations.

Quoted 16 lines
---
 hw/s390x/s390-virtio-ccw.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
hw/s390x/s390-virtio-ccw.c +1 -0
index 35fb523af9..8fe0c5c1cb 100644
@@ -259,6 +259,20 @@ static void s390_create_sclpconsole(SCLPDevice 
 *sclp,
     qdev_realize_and_unref(dev, ev_fac_bus, &error_fatal);
 }
 
+static const VMStateDescription vmstate_cpi = {

hw/s390x/s390-virtio-ccw.c static void s390_create_sclpconsole(SCLPDevice · line 273

Quoted 10 lines
hw/s390x/s390-virtio-ccw.c +10 -0
+    .name = "s390_cpi",
+    .version_id = 0,
+    .minimum_version_id = 0,
+    .fields = (const VMStateField[]) {
+        VMSTATE_UINT8_ARRAY(system_type, Cpi, 8),
+        VMSTATE_UINT8_ARRAY(system_name, Cpi, 8),
+        VMSTATE_UINT64(system_level, Cpi),
+        VMSTATE_UINT8_ARRAY(sysplex_name, Cpi, 8),
+        VMSTATE_UINT64(timestamp, Cpi),
+        VMSTATE_END_OF_LIST()

I see, you need the Cpi type here.
How about naming it ControlProgramId and renaming CPI to ControlProgramIdMsg or similar?

Quoted 3 lines

With that sorted out:

Hello Nina,

Thank you for your comments. I have implemented all the changes according to your feedback and I have sent the version 2 of my patch series.

Signature · 9 lines
Mit freundlichen Grüßen / Kind regards
Shalini Chellathurai Saroja
Software Developer
Linux on IBM Z & KVM Development
IBM Deutschland Research & Development GmbH
Dept 1419, Schoenaicher Str. 220, 71032 Boeblingen
Vorsitzender des Aufsichtsrats: Wolfgang Wendt
Geschäftsführung: David Faller
Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294
Reviewed-by on v1 1/3
#7 lore raw
In reply to Shalini Chellathurai Saroja

Please swap patch 1 and 2 and incorporate the changes of write_event_data into this patch.

See some minor nits below.

Quoted 4 lines · Shalini Chellathurai Saroja

This commit implements the SCLP event type Control-Program Identification in QEMU. Control-program is an IBM term for operating system. This event is used to send firmware program identifiers from KVM guest to SCLP. The program

This event is used to send information about the guest OS to the host.

Quoted 2 lines

identifiers provide data about the guest OS. The program identifiers are system type, system name, system level and

identifiers are: ...

Quoted 6 lines

sysplex name.

System type provides the OS type of the guest. System name provides the name of the guest. System level provides the distribution and kernel version of the guest OS. Sysplex name provides sysplex name of the guest.

The system type provides the OS type of the guest (e.g. LINUX).
The system name provides the name of the guest (e.g. TESTVM).
The system level provides the distribution and kernel version of the guest OS (e.g. 0x50e00). The sysplex name provides the sysplex name of the guest (e.g. SYSPLEX).

Quoted 10 lines
---
 hw/s390x/event-facility.c         | 12 +++-
 hw/s390x/meson.build              |  1 +
 hw/s390x/sclpcpi.c                | 94 +++++++++++++++++++++++++++++++
 include/hw/s390x/event-facility.h |  3 +
 4 files changed, 109 insertions(+), 1 deletion(-)
 create mode 100644 hw/s390x/sclpcpi.c

[...]

hw/s390x/sclpcpi.c line 3

Quoted 10 lines
hw/s390x/sclpcpi.c new file +3 -0
new file mode 100644
index 0000000000..64bc730f47
@@ -0,0 +1,94 @@
+/*
+ * SCLP event type 11 - Control-Program Identification(CPI):
+ *    CPI is used to send program identifiers from control-program to the SCLP.

...from the control-program...

hw/s390x/sclpcpi.c line 4

Quoted 1 line
hw/s390x/sclpcpi.c new file +1 -0
+ *    The program identifiers provide data about Linux instance. It is not sent

... about the guest instance...

hw/s390x/sclpcpi.c line 10

Quoted 6 lines
hw/s390x/sclpcpi.c new file +6 -0
+ *    by the SCLP.
+ *
+ *    The program identifiers are system type, system name, sysplex name and
+ *    system level. The system type, system name, and sysplex name use EBCDIC
+ *    ucharacters from this set: capital A-Z, 0-9, $, @, #, and blank. The
+ *    system level is hex value.

... is a hex value...
(Well I guess it's just a number)

Quoted 11 lines
hw/s390x/sclpcpi.c new file +11 -0
+ *
+ * Copyright IBM, Corp. 2024
+ *
+ * Authors:
+ *  Shalini Chellathurai Saroja <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at your
+ * option) any later version.  See the COPYING file in the top-level directory.
+ *
+ */
+

[...]