* [PATCH v3 0/4] *** Add SCLP event type CPI ***
@ 2025-03-31 14:00 Shalini Chellathurai Saroja
2025-03-31 14:00 ` [PATCH v3 1/4] hw/s390x: add SCLP event type CPI Shalini Chellathurai Saroja
` (3 more replies)
0 siblings, 4 replies; 19+ messages in thread
From: Shalini Chellathurai Saroja @ 2025-03-31 14:00 UTC (permalink / raw)
To: qemu-s390x mailing list, Thomas Huth, Daniel Berrange
Cc: qemu-devel mailing list, Nina Schoetterl-Glausch,
Hendrik Brueckner, Shalini Chellathurai Saroja
Implement the Service-Call Logical Processor (SCLP) event
type Control-Program Identification (CPI) in QEMU.
Changed since v2:
- Add SPDX license tag in the new file hw/s390x/sclpcpi.c
- Store the control-program Identification data in the sclpcpi device
- Update the description of CPI attributes
- Use ldq_be_p() intead of be64_to_cpu()
- Return the CPI attribute system-level as an integer in QMP
- Add compat handling for backward migration
- Other minor changes
Shalini Chellathurai Saroja (4):
hw/s390x: add SCLP event type CPI
hw/s390x: add Control-Program Identification to QOM
hw/s390x: support migration of CPI data
hw/s390x: compat handling for backward migration
hw/s390x/event-facility.c | 28 ++++-
hw/s390x/meson.build | 1 +
hw/s390x/s390-virtio-ccw.c | 1 +
hw/s390x/sclpcpi.c | 196 ++++++++++++++++++++++++++++++
include/hw/s390x/event-facility.h | 12 ++
qapi/machine.json | 58 +++++++++
6 files changed, 295 insertions(+), 1 deletion(-)
create mode 100644 hw/s390x/sclpcpi.c
--
2.47.0
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 1/4] hw/s390x: add SCLP event type CPI
2025-03-31 14:00 [PATCH v3 0/4] *** Add SCLP event type CPI *** Shalini Chellathurai Saroja
@ 2025-03-31 14:00 ` Shalini Chellathurai Saroja
2025-04-02 5:48 ` Thomas Huth
2025-03-31 14:00 ` [PATCH v3 2/4] hw/s390x: add Control-Program Identification to QOM Shalini Chellathurai Saroja
` (2 subsequent siblings)
3 siblings, 1 reply; 19+ messages in thread
From: Shalini Chellathurai Saroja @ 2025-03-31 14:00 UTC (permalink / raw)
To: qemu-s390x mailing list, Thomas Huth, Daniel Berrange
Cc: qemu-devel mailing list, Nina Schoetterl-Glausch,
Hendrik Brueckner, Shalini Chellathurai Saroja
Implement the Service-Call Logical Processor (SCLP) event
type Control-Program Identification (CPI) in QEMU. This
event is used to send CPI identifiers from the guest to the
host. The CPI identifiers are: system type, system name,
system level and sysplex name.
System type: operating system of the guest (e.g. "LINUX").
System name: user configurable name of the guest (e.g. "TESTVM").
System level: distribution and kernel version, if the system type is Linux
(e.g. 0x50e00).
Sysplex name: name of the cluster which the guest belongs to (if any)
(e.g. "PLEX").
Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Reviewed-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
---
hw/s390x/event-facility.c | 12 ++-
hw/s390x/meson.build | 1 +
hw/s390x/sclpcpi.c | 133 ++++++++++++++++++++++++++++++
include/hw/s390x/event-facility.h | 3 +
4 files changed, 148 insertions(+), 1 deletion(-)
create mode 100644 hw/s390x/sclpcpi.c
diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
index 2b0332c20e..c0fb6e098c 100644
--- a/hw/s390x/event-facility.c
+++ b/hw/s390x/event-facility.c
@@ -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)
diff --git a/hw/s390x/meson.build b/hw/s390x/meson.build
index 3bbebfd817..eb7950489c 100644
--- a/hw/s390x/meson.build
+++ b/hw/s390x/meson.build
@@ -13,6 +13,7 @@ s390x_ss.add(files(
's390-skeys.c',
's390-stattrib.c',
'sclp.c',
+ 'sclpcpi.c',
'sclpcpu.c',
'sclpquiesce.c',
'tod.c',
diff --git a/hw/s390x/sclpcpi.c b/hw/s390x/sclpcpi.c
new file mode 100644
index 0000000000..7ace5dd64e
--- /dev/null
+++ b/hw/s390x/sclpcpi.c
@@ -0,0 +1,133 @@
+ /*
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * SCLP event type 11 - Control-Program Identification (CPI):
+ * CPI is used to send program identifiers from the guest to the
+ * Service-Call Logical Processor (SCLP). It is not sent by the SCLP. The
+ * program identifiers are: system type, system name, system level and
+ * sysplex name. They provide data about the guest operating system.
+ *
+ * System type, system name, and sysplex name use EBCDIC characters from
+ * this set: capital A-Z, 0-9, $, @, #, and blank. The system level is a hex
+ * value. In Linux, the system type, system name and sysplex name are
+ * arbitrary free-form texts. In Linux, all the control-program identifiers
+ * are user configurable.
+ *
+ * System-type: operating system (e.g. "LINUX ")
+ *
+ * System-name: user configurable name of the VM (e.g. "TESTVM ")
+ *
+ * System-level: distribution and kernel version, if the system-type is
+ * Linux. On Linux OS, the 8-byte hexadecimal system-level has the format
+ * 0x<a><b><cc><dd><eeee><ff><gg><hh>, where:
+ * <a>: is one hexadecimal byte, its most significant bit indicates
+ * hypervisor use
+ * <b>: is one digit that represents Linux distributions as follows
+ * 0: generic Linux
+ * 1: Red Hat Enterprise Linux
+ * 2: SUSE Linux Enterprise Server
+ * 3: Canonical Ubuntu
+ * 4: Fedora
+ * 5: openSUSE Leap
+ * 6: Debian GNU/Linux
+ * 7: Red Hat Enterprise Linux CoreOS
+ * <cc>: are two digits for a distribution-specific encoding of the major
+ * version of the distribution
+ * <dd>: are two digits for a distribution-specific encoding of the minor
+ * version of the distribution
+ * <eeee>: are four digits for the patch level of the distribution
+ * <ff>: are two digits for the major version of the kernel
+ * <gg>: are two digits for the minor version of the kernel
+ * <hh>: are two digits for the stable version of the kernel
+ * (e.g. 0x010a000000060b00). On machines prior to z16, some of the values
+ * are not available to display.
+ *
+ * Sysplex-name: sysplex refers to a cluster of logical partitions that
+ * communicates and co-operates with each other. Sysplex name is the name of
+ * the cluster which the guest belongs to (if any). (e.g. "PLEX ")
+ *
+ * Copyright IBM, Corp. 2024
+ *
+ * Authors:
+ * Shalini Chellathurai Saroja <shalini@linux.ibm.com>
+ *
+ * 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.
+ *
+ */
+
+#include "qemu/osdep.h"
+#include "hw/s390x/sclp.h"
+#include "hw/s390x/event-facility.h"
+
+typedef struct Data {
+ uint8_t id_format;
+ uint8_t reserved0;
+ uint8_t system_type[8];
+ uint64_t reserved1;
+ uint8_t system_name[8];
+ uint64_t reserved2;
+ uint64_t system_level;
+ uint64_t reserved3;
+ uint8_t sysplex_name[8];
+ uint8_t reserved4[16];
+} QEMU_PACKED Data;
+
+typedef struct ControlProgramIdMsg {
+ EventBufferHeader ebh;
+ Data data;
+} QEMU_PACKED ControlProgramIdMsg;
+
+static bool can_handle_event(uint8_t type)
+{
+ return type == SCLP_EVENT_CPI;
+}
+
+static sccb_mask_t send_mask(void)
+{
+ return 0;
+}
+
+/* Enable SCLP to accept buffers of event type CPI from the control-program. */
+static sccb_mask_t receive_mask(void)
+{
+ return SCLP_EVENT_MASK_CPI;
+}
+
+static int write_event_data(SCLPEvent *event, EventBufferHeader *evt_buf_hdr)
+{
+ ControlProgramIdMsg *cpim = container_of(evt_buf_hdr, ControlProgramIdMsg,
+ ebh);
+
+ cpim->ebh.flags = SCLP_EVENT_BUFFER_ACCEPTED;
+ return SCLP_RC_NORMAL_COMPLETION;
+}
+
+static void cpi_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+ SCLPEventClass *k = SCLP_EVENT_CLASS(klass);
+
+ dc->user_creatable = false;
+
+ k->can_handle_event = can_handle_event;
+ k->get_send_mask = send_mask;
+ k->get_receive_mask = receive_mask;
+ k->write_event_data = write_event_data;
+}
+
+static const TypeInfo sclp_cpi_info = {
+ .name = TYPE_SCLP_CPI,
+ .parent = TYPE_SCLP_EVENT,
+ .instance_size = sizeof(SCLPEvent),
+ .class_init = cpi_class_init,
+ .class_size = sizeof(SCLPEventClass),
+};
+
+static void sclp_cpi_register_types(void)
+{
+ type_register_static(&sclp_cpi_info);
+}
+
+type_init(sclp_cpi_register_types)
+
diff --git a/include/hw/s390x/event-facility.h b/include/hw/s390x/event-facility.h
index ff874e792d..f445d2f9f5 100644
--- a/include/hw/s390x/event-facility.h
+++ b/include/hw/s390x/event-facility.h
@@ -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
--
2.47.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH v3 1/4] hw/s390x: add SCLP event type CPI
2025-03-31 14:00 ` [PATCH v3 1/4] hw/s390x: add SCLP event type CPI Shalini Chellathurai Saroja
@ 2025-04-02 5:48 ` Thomas Huth
2025-04-02 7:54 ` Shalini Chellathurai Saroja
0 siblings, 1 reply; 19+ messages in thread
From: Thomas Huth @ 2025-04-02 5:48 UTC (permalink / raw)
To: Shalini Chellathurai Saroja, qemu-s390x mailing list,
Daniel Berrange
Cc: qemu-devel mailing list, Nina Schoetterl-Glausch,
Hendrik Brueckner
On 31/03/2025 16.00, Shalini Chellathurai Saroja wrote:
> Implement the Service-Call Logical Processor (SCLP) event
> type Control-Program Identification (CPI) in QEMU. This
> event is used to send CPI identifiers from the guest to the
> host. The CPI identifiers are: system type, system name,
> system level and sysplex name.
>
> System type: operating system of the guest (e.g. "LINUX").
> System name: user configurable name of the guest (e.g. "TESTVM").
> System level: distribution and kernel version, if the system type is Linux
> (e.g. 0x50e00).
> Sysplex name: name of the cluster which the guest belongs to (if any)
> (e.g. "PLEX").
>
> Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
> Reviewed-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
> ---
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 1/4] hw/s390x: add SCLP event type CPI
2025-04-02 5:48 ` Thomas Huth
@ 2025-04-02 7:54 ` Shalini Chellathurai Saroja
0 siblings, 0 replies; 19+ messages in thread
From: Shalini Chellathurai Saroja @ 2025-04-02 7:54 UTC (permalink / raw)
To: Thomas Huth
Cc: qemu-s390x mailing list, Daniel Berrange, qemu-devel mailing list,
Nina Schoetterl-Glausch, Hendrik Brueckner
On 2025-04-02 07:48, Thomas Huth wrote:
> On 31/03/2025 16.00, Shalini Chellathurai Saroja wrote:
>> Implement the Service-Call Logical Processor (SCLP) event
>> type Control-Program Identification (CPI) in QEMU. This
>> event is used to send CPI identifiers from the guest to the
>> host. The CPI identifiers are: system type, system name,
>> system level and sysplex name.
>>
>> System type: operating system of the guest (e.g. "LINUX").
>> System name: user configurable name of the guest (e.g. "TESTVM").
>> System level: distribution and kernel version, if the system type is
>> Linux
>> (e.g. 0x50e00).
>> Sysplex name: name of the cluster which the guest belongs to (if any)
>> (e.g. "PLEX").
>>
>> Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
>> Reviewed-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
>> ---
>
> Reviewed-by: Thomas Huth <thuth@redhat.com>
Hello Thomas,
Thank you very much.
--
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
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 2/4] hw/s390x: add Control-Program Identification to QOM
2025-03-31 14:00 [PATCH v3 0/4] *** Add SCLP event type CPI *** Shalini Chellathurai Saroja
2025-03-31 14:00 ` [PATCH v3 1/4] hw/s390x: add SCLP event type CPI Shalini Chellathurai Saroja
@ 2025-03-31 14:00 ` Shalini Chellathurai Saroja
2025-04-01 13:55 ` Nina Schoetterl-Glausch
2025-04-02 5:58 ` Thomas Huth
2025-03-31 14:00 ` [PATCH v3 3/4] hw/s390x: support migration of CPI data Shalini Chellathurai Saroja
2025-03-31 14:00 ` [PATCH v3 4/4] hw/s390x: compat handling for backward migration Shalini Chellathurai Saroja
3 siblings, 2 replies; 19+ messages in thread
From: Shalini Chellathurai Saroja @ 2025-03-31 14:00 UTC (permalink / raw)
To: qemu-s390x mailing list, Thomas Huth, Daniel Berrange
Cc: qemu-devel mailing list, Nina Schoetterl-Glausch,
Hendrik Brueckner, Shalini Chellathurai Saroja
Add Control-Program Identification data to the QEMU Object
Model (QOM), along with the timestamp in which the data was received.
Example:
virsh # qemu-monitor-command vm --pretty '{
"execute": "qom-get",
"arguments": {
"path": "/machine/sclp/s390-sclp-event-facility/sclpcpi",
"property": "control-program-id" }}'
{
"return": {
"timestamp": 1742390410685762000,
"system-level": 74872343805430528,
"sysplex-name": "PLEX ",
"system-name": "TESTVM ",
"system-type": "LINUX "
},
"id": "libvirt-15"
}
Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
---
hw/s390x/sclpcpi.c | 38 ++++++++++++++++++++
include/hw/s390x/event-facility.h | 9 +++++
qapi/machine.json | 58 +++++++++++++++++++++++++++++++
3 files changed, 105 insertions(+)
diff --git a/hw/s390x/sclpcpi.c b/hw/s390x/sclpcpi.c
index 7ace5dd64e..969c15e43d 100644
--- a/hw/s390x/sclpcpi.c
+++ b/hw/s390x/sclpcpi.c
@@ -57,8 +57,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 "qapi/qapi-visit-machine.h"
typedef struct Data {
uint8_t id_format;
@@ -99,10 +102,37 @@ static int write_event_data(SCLPEvent *event, EventBufferHeader *evt_buf_hdr)
ControlProgramIdMsg *cpim = container_of(evt_buf_hdr, ControlProgramIdMsg,
ebh);
+ ascii_put(event->cpi.system_type, (char *)cpim->data.system_type, 8);
+ ascii_put(event->cpi.system_name, (char *)cpim->data.system_name, 8);
+ ascii_put(event->cpi.sysplex_name, (char *)cpim->data.sysplex_name, 8);
+ event->cpi.system_level = ldq_be_p(&cpim->data.system_level);
+ event->cpi.timestamp = qemu_clock_get_ns(QEMU_CLOCK_HOST);
+
cpim->ebh.flags = SCLP_EVENT_BUFFER_ACCEPTED;
return SCLP_RC_NORMAL_COMPLETION;
}
+static void get_control_program_id(Object *obj, Visitor *v,
+ const char *name, void *opaque,
+ Error **errp)
+{
+ SCLPEvent *event = (SCLPEvent *)(obj);
+ S390ControlProgramId *cpi;
+
+ cpi = &(S390ControlProgramId){
+ .system_type = g_strndup((char *) event->cpi.system_type,
+ sizeof(event->cpi.system_type)),
+ .system_name = g_strndup((char *) event->cpi.system_name,
+ sizeof(event->cpi.system_name)),
+ .system_level = event->cpi.system_level,
+ .sysplex_name = g_strndup((char *) event->cpi.sysplex_name,
+ sizeof(event->cpi.sysplex_name)),
+ .timestamp = event->cpi.timestamp
+ };
+
+ visit_type_S390ControlProgramId(v, name, &cpi, errp);
+}
+
static void cpi_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
@@ -114,6 +144,14 @@ static void cpi_class_init(ObjectClass *klass, void *data)
k->get_send_mask = send_mask;
k->get_receive_mask = receive_mask;
k->write_event_data = write_event_data;
+
+ object_class_property_add(klass, "control-program-id",
+ "S390ControlProgramId",
+ get_control_program_id,
+ NULL, NULL, NULL);
+ object_class_property_set_description(klass, "control-program-id",
+ "Control-program identifiers provide data about the guest "
+ "operating system");
}
static const TypeInfo sclp_cpi_info = {
diff --git a/include/hw/s390x/event-facility.h b/include/hw/s390x/event-facility.h
index f445d2f9f5..39e589ed44 100644
--- a/include/hw/s390x/event-facility.h
+++ b/include/hw/s390x/event-facility.h
@@ -169,10 +169,19 @@ typedef struct ReadEventData {
};
} QEMU_PACKED ReadEventData;
+typedef struct ControlProgramId {
+ uint8_t system_type[8];
+ uint8_t system_name[8];
+ uint64_t system_level;
+ uint8_t sysplex_name[8];
+ uint64_t timestamp;
+} QEMU_PACKED ControlProgramId;
+
struct SCLPEvent {
DeviceState qdev;
bool event_pending;
char *name;
+ ControlProgramId cpi;
};
struct SCLPEventClass {
diff --git a/qapi/machine.json b/qapi/machine.json
index a6b8795b09..cd2bcd2d13 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -1898,3 +1898,61 @@
{ 'command': 'x-query-interrupt-controllers',
'returns': 'HumanReadableText',
'features': [ 'unstable' ]}
+
+##
+# @S390ControlProgramId:
+#
+# Control-program identifiers provide data about the guest operating system.
+# The control-program identifiers are: system type, system name, system level
+# and sysplex name.
+#
+# In Linux, all the control-program identifiers are user configurable. The
+# system type, system name, and sysplex name use EBCDIC characters from
+# this set: capital A-Z, 0-9, $, @, #, and blank. In Linux, the system type,
+# system name and sysplex name are arbitrary free-form texts.
+#
+# In Linux, the 8-byte hexadecimal system-level has the format
+# 0x<a><b><cc><dd><eeee><ff><gg><hh>, where:
+# <a>: is one hexadecimal byte, its most significant bit indicates hypervisor
+# use
+# <b>: is one digit that represents Linux distributions as follows
+# 0: generic Linux
+# 1: Red Hat Enterprise Linux
+# 2: SUSE Linux Enterprise Server
+# 3: Canonical Ubuntu
+# 4: Fedora
+# 5: openSUSE Leap
+# 6: Debian GNU/Linux
+# 7: Red Hat Enterprise Linux CoreOS
+# <cc>: are two digits for a distribution-specific encoding of the major version
+# of the distribution
+# <dd>: are two digits for a distribution-specific encoding of the minor version
+# of the distribution
+# <eeee>: are four digits for the patch level of the distribution
+# <ff>: are two digits for the major version of the kernel
+# <gg>: are two digits for the minor version of the kernel
+# <hh>: are two digits for the stable version of the kernel
+# (e.g. 74872343805430528, when converted to hex is 0x010a000000060b00). On
+# machines prior to z16, some of the values are not available to display.
+#
+# Sysplex refers to a cluster of logical partitions that communicates and
+# co-operates with each other.
+#
+# @system-type: operating system (e.g. "LINUX ")
+#
+# @system-name: user configurable name of the VM (e.g. "TESTVM ")
+#
+# @system-level: distribution and kernel version in Linux
+#
+# @sysplex-name: sysplex which the VM belongs to, if any (e.g. "PLEX ")
+#
+# @timestamp: latest update of CPI data in nanoseconds since the UNIX EPOCH
+#
+# Since: 10.0
+##
+{ 'struct': 'S390ControlProgramId', 'data': {
+ 'system-type': 'str',
+ 'system-name': 'str',
+ 'system-level': 'uint64',
+ 'sysplex-name': 'str',
+ 'timestamp': 'uint64' } }
--
2.47.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH v3 2/4] hw/s390x: add Control-Program Identification to QOM
2025-03-31 14:00 ` [PATCH v3 2/4] hw/s390x: add Control-Program Identification to QOM Shalini Chellathurai Saroja
@ 2025-04-01 13:55 ` Nina Schoetterl-Glausch
2025-04-02 5:58 ` Thomas Huth
1 sibling, 0 replies; 19+ messages in thread
From: Nina Schoetterl-Glausch @ 2025-04-01 13:55 UTC (permalink / raw)
To: Shalini Chellathurai Saroja, qemu-s390x mailing list, Thomas Huth,
Daniel Berrange
Cc: qemu-devel mailing list, Hendrik Brueckner
On Mon, 2025-03-31 at 16:00 +0200, Shalini Chellathurai Saroja wrote:
> Add Control-Program Identification data to the QEMU Object
> Model (QOM), along with the timestamp in which the data was received.
>
> Example:
> virsh # qemu-monitor-command vm --pretty '{
> "execute": "qom-get",
> "arguments": {
> "path": "/machine/sclp/s390-sclp-event-facility/sclpcpi",
> "property": "control-program-id" }}'
> {
> "return": {
> "timestamp": 1742390410685762000,
> "system-level": 74872343805430528,
> "sysplex-name": "PLEX ",
> "system-name": "TESTVM ",
> "system-type": "LINUX "
> },
> "id": "libvirt-15"
> }
>
> Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
> ---
> hw/s390x/sclpcpi.c | 38 ++++++++++++++++++++
> include/hw/s390x/event-facility.h | 9 +++++
> qapi/machine.json | 58 +++++++++++++++++++++++++++++++
> 3 files changed, 105 insertions(+)
>
> diff --git a/hw/s390x/sclpcpi.c b/hw/s390x/sclpcpi.c
> index 7ace5dd64e..969c15e43d 100644
> --- a/hw/s390x/sclpcpi.c
> +++ b/hw/s390x/sclpcpi.c
> @@ -57,8 +57,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 "qapi/qapi-visit-machine.h"
>
> typedef struct Data {
> uint8_t id_format;
> @@ -99,10 +102,37 @@ static int write_event_data(SCLPEvent *event, EventBufferHeader *evt_buf_hdr)
> ControlProgramIdMsg *cpim = container_of(evt_buf_hdr, ControlProgramIdMsg,
> ebh);
>
> + ascii_put(event->cpi.system_type, (char *)cpim->data.system_type, 8);
> + ascii_put(event->cpi.system_name, (char *)cpim->data.system_name, 8);
> + ascii_put(event->cpi.sysplex_name, (char *)cpim->data.sysplex_name, 8);
> + event->cpi.system_level = ldq_be_p(&cpim->data.system_level);
> + event->cpi.timestamp = qemu_clock_get_ns(QEMU_CLOCK_HOST);
> +
> cpim->ebh.flags = SCLP_EVENT_BUFFER_ACCEPTED;
> return SCLP_RC_NORMAL_COMPLETION;
> }
>
> +static void get_control_program_id(Object *obj, Visitor *v,
> + const char *name, void *opaque,
> + Error **errp)
> +{
> + SCLPEvent *event = (SCLPEvent *)(obj);
Do a checked cast with SCLP_EVENT(obj).
> + S390ControlProgramId *cpi;
> +
> + cpi = &(S390ControlProgramId){
> + .system_type = g_strndup((char *) event->cpi.system_type,
> + sizeof(event->cpi.system_type)),
> + .system_name = g_strndup((char *) event->cpi.system_name,
> + sizeof(event->cpi.system_name)),
> + .system_level = event->cpi.system_level,
> + .sysplex_name = g_strndup((char *) event->cpi.sysplex_name,
> + sizeof(event->cpi.sysplex_name)),
> + .timestamp = event->cpi.timestamp
> + };
> +
> + visit_type_S390ControlProgramId(v, name, &cpi, errp);
> +}
> +
> static void cpi_class_init(ObjectClass *klass, void *data)
> {
> DeviceClass *dc = DEVICE_CLASS(klass);
> @@ -114,6 +144,14 @@ static void cpi_class_init(ObjectClass *klass, void *data)
> k->get_send_mask = send_mask;
> k->get_receive_mask = receive_mask;
> k->write_event_data = write_event_data;
> +
> + object_class_property_add(klass, "control-program-id",
> + "S390ControlProgramId",
> + get_control_program_id,
> + NULL, NULL, NULL);
> + object_class_property_set_description(klass, "control-program-id",
> + "Control-program identifiers provide data about the guest "
> + "operating system");
> }
>
> static const TypeInfo sclp_cpi_info = {
> diff --git a/include/hw/s390x/event-facility.h b/include/hw/s390x/event-facility.h
> index f445d2f9f5..39e589ed44 100644
> --- a/include/hw/s390x/event-facility.h
> +++ b/include/hw/s390x/event-facility.h
> @@ -169,10 +169,19 @@ typedef struct ReadEventData {
> };
> } QEMU_PACKED ReadEventData;
>
> +typedef struct ControlProgramId {
> + uint8_t system_type[8];
> + uint8_t system_name[8];
> + uint64_t system_level;
> + uint8_t sysplex_name[8];
> + uint64_t timestamp;
> +} QEMU_PACKED ControlProgramId;
> +
> struct SCLPEvent {
> DeviceState qdev;
> bool event_pending;
> char *name;
> + ControlProgramId cpi;
I don't think this should go into SCLPEvent.
Rather SCLPEventFacility or SCLPDevice. Otherwise all events,
so also quiesce and cpu_hotplug have a cpi field.
> };
[...]
--
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Wolfgang Wendt
Geschäftsführung: David Faller
Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 2/4] hw/s390x: add Control-Program Identification to QOM
2025-03-31 14:00 ` [PATCH v3 2/4] hw/s390x: add Control-Program Identification to QOM Shalini Chellathurai Saroja
2025-04-01 13:55 ` Nina Schoetterl-Glausch
@ 2025-04-02 5:58 ` Thomas Huth
1 sibling, 0 replies; 19+ messages in thread
From: Thomas Huth @ 2025-04-02 5:58 UTC (permalink / raw)
To: Shalini Chellathurai Saroja, qemu-s390x mailing list,
Daniel Berrange
Cc: qemu-devel mailing list, Nina Schoetterl-Glausch,
Hendrik Brueckner
On 31/03/2025 16.00, Shalini Chellathurai Saroja wrote:
> Add Control-Program Identification data to the QEMU Object
> Model (QOM), along with the timestamp in which the data was received.
>
> Example:
> virsh # qemu-monitor-command vm --pretty '{
> "execute": "qom-get",
> "arguments": {
> "path": "/machine/sclp/s390-sclp-event-facility/sclpcpi",
> "property": "control-program-id" }}'
> {
> "return": {
> "timestamp": 1742390410685762000,
> "system-level": 74872343805430528,
> "sysplex-name": "PLEX ",
> "system-name": "TESTVM ",
> "system-type": "LINUX "
> },
> "id": "libvirt-15"
> }
>
> Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
> ---
> hw/s390x/sclpcpi.c | 38 ++++++++++++++++++++
> include/hw/s390x/event-facility.h | 9 +++++
> qapi/machine.json | 58 +++++++++++++++++++++++++++++++
> 3 files changed, 105 insertions(+)
>
> diff --git a/hw/s390x/sclpcpi.c b/hw/s390x/sclpcpi.c
> index 7ace5dd64e..969c15e43d 100644
> --- a/hw/s390x/sclpcpi.c
> +++ b/hw/s390x/sclpcpi.c
> @@ -57,8 +57,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 "qapi/qapi-visit-machine.h"
>
> typedef struct Data {
> uint8_t id_format;
> @@ -99,10 +102,37 @@ static int write_event_data(SCLPEvent *event, EventBufferHeader *evt_buf_hdr)
> ControlProgramIdMsg *cpim = container_of(evt_buf_hdr, ControlProgramIdMsg,
> ebh);
>
> + ascii_put(event->cpi.system_type, (char *)cpim->data.system_type, 8);
> + ascii_put(event->cpi.system_name, (char *)cpim->data.system_name, 8);
> + ascii_put(event->cpi.sysplex_name, (char *)cpim->data.sysplex_name, 8);
> + event->cpi.system_level = ldq_be_p(&cpim->data.system_level);
> + event->cpi.timestamp = qemu_clock_get_ns(QEMU_CLOCK_HOST);
> +
> cpim->ebh.flags = SCLP_EVENT_BUFFER_ACCEPTED;
> return SCLP_RC_NORMAL_COMPLETION;
> }
>
> +static void get_control_program_id(Object *obj, Visitor *v,
> + const char *name, void *opaque,
> + Error **errp)
> +{
> + SCLPEvent *event = (SCLPEvent *)(obj);
> + S390ControlProgramId *cpi;
> +
> + cpi = &(S390ControlProgramId){
> + .system_type = g_strndup((char *) event->cpi.system_type,
> + sizeof(event->cpi.system_type)),
> + .system_name = g_strndup((char *) event->cpi.system_name,
> + sizeof(event->cpi.system_name)),
> + .system_level = event->cpi.system_level,
> + .sysplex_name = g_strndup((char *) event->cpi.sysplex_name,
> + sizeof(event->cpi.sysplex_name)),
> + .timestamp = event->cpi.timestamp
> + };
> +
> + visit_type_S390ControlProgramId(v, name, &cpi, errp);
> +}
> +
> static void cpi_class_init(ObjectClass *klass, void *data)
> {
> DeviceClass *dc = DEVICE_CLASS(klass);
> @@ -114,6 +144,14 @@ static void cpi_class_init(ObjectClass *klass, void *data)
> k->get_send_mask = send_mask;
> k->get_receive_mask = receive_mask;
> k->write_event_data = write_event_data;
> +
> + object_class_property_add(klass, "control-program-id",
> + "S390ControlProgramId",
> + get_control_program_id,
> + NULL, NULL, NULL);
> + object_class_property_set_description(klass, "control-program-id",
> + "Control-program identifiers provide data about the guest "
> + "operating system");
> }
>
> static const TypeInfo sclp_cpi_info = {
> diff --git a/include/hw/s390x/event-facility.h b/include/hw/s390x/event-facility.h
> index f445d2f9f5..39e589ed44 100644
> --- a/include/hw/s390x/event-facility.h
> +++ b/include/hw/s390x/event-facility.h
> @@ -169,10 +169,19 @@ typedef struct ReadEventData {
> };
> } QEMU_PACKED ReadEventData;
>
> +typedef struct ControlProgramId {
> + uint8_t system_type[8];
> + uint8_t system_name[8];
> + uint64_t system_level;
> + uint8_t sysplex_name[8];
> + uint64_t timestamp;
> +} QEMU_PACKED ControlProgramId;
Do we need the QEMU_PACKED here? The members seem naturally aligned, and the
struct does not seem to be involved in the communication with the guest
directly, so if you don't need it, please drop the QEMU_PACKED here.
(without PACKED, the compiler can optimize the code in a better way, and
this causes less trouble on exotic platforms like SPARC that cannot access
unaligned memory addresses)
> struct SCLPEvent {
> DeviceState qdev;
> bool event_pending;
> char *name;
> + ControlProgramId cpi;
> };
>
> struct SCLPEventClass {
> diff --git a/qapi/machine.json b/qapi/machine.json
> index a6b8795b09..cd2bcd2d13 100644
> --- a/qapi/machine.json
> +++ b/qapi/machine.json
> @@ -1898,3 +1898,61 @@
> { 'command': 'x-query-interrupt-controllers',
> 'returns': 'HumanReadableText',
> 'features': [ 'unstable' ]}
> +
> +##
> +# @S390ControlProgramId:
> +#
> +# Control-program identifiers provide data about the guest operating system.
> +# The control-program identifiers are: system type, system name, system level
> +# and sysplex name.
> +#
> +# In Linux, all the control-program identifiers are user configurable. The
> +# system type, system name, and sysplex name use EBCDIC characters from
> +# this set: capital A-Z, 0-9, $, @, #, and blank. In Linux, the system type,
> +# system name and sysplex name are arbitrary free-form texts.
> +#
> +# In Linux, the 8-byte hexadecimal system-level has the format
> +# 0x<a><b><cc><dd><eeee><ff><gg><hh>, where:
> +# <a>: is one hexadecimal byte, its most significant bit indicates hypervisor
> +# use
> +# <b>: is one digit that represents Linux distributions as follows
> +# 0: generic Linux
> +# 1: Red Hat Enterprise Linux
> +# 2: SUSE Linux Enterprise Server
> +# 3: Canonical Ubuntu
> +# 4: Fedora
> +# 5: openSUSE Leap
> +# 6: Debian GNU/Linux
> +# 7: Red Hat Enterprise Linux CoreOS
> +# <cc>: are two digits for a distribution-specific encoding of the major version
> +# of the distribution
> +# <dd>: are two digits for a distribution-specific encoding of the minor version
> +# of the distribution
> +# <eeee>: are four digits for the patch level of the distribution
> +# <ff>: are two digits for the major version of the kernel
> +# <gg>: are two digits for the minor version of the kernel
> +# <hh>: are two digits for the stable version of the kernel
> +# (e.g. 74872343805430528, when converted to hex is 0x010a000000060b00). On
> +# machines prior to z16, some of the values are not available to display.
You've got the same information in the comment at the beginning of the
sclpcpi.c file already ... maybe it would be good to have it in one place
only to avoid double maintenance in case it needs to be changed in the
future. I'd suggest to change the comment at the beginning of sclpcpi.c to
say something like "for a detailed description of the contents of the CPI,
please see the S390ControlProgramId QOM-type description." or something similar?
Thomas
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 3/4] hw/s390x: support migration of CPI data
2025-03-31 14:00 [PATCH v3 0/4] *** Add SCLP event type CPI *** Shalini Chellathurai Saroja
2025-03-31 14:00 ` [PATCH v3 1/4] hw/s390x: add SCLP event type CPI Shalini Chellathurai Saroja
2025-03-31 14:00 ` [PATCH v3 2/4] hw/s390x: add Control-Program Identification to QOM Shalini Chellathurai Saroja
@ 2025-03-31 14:00 ` Shalini Chellathurai Saroja
2025-04-02 6:05 ` Thomas Huth
2025-03-31 14:00 ` [PATCH v3 4/4] hw/s390x: compat handling for backward migration Shalini Chellathurai Saroja
3 siblings, 1 reply; 19+ messages in thread
From: Shalini Chellathurai Saroja @ 2025-03-31 14:00 UTC (permalink / raw)
To: qemu-s390x mailing list, Thomas Huth, Daniel Berrange
Cc: qemu-devel mailing list, Nina Schoetterl-Glausch,
Hendrik Brueckner, Shalini Chellathurai Saroja
Register Control-Program Identification data with the live
migration infrastructure.
Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Reviewed-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
---
hw/s390x/sclpcpi.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/hw/s390x/sclpcpi.c b/hw/s390x/sclpcpi.c
index 969c15e43d..0b1b5293ea 100644
--- a/hw/s390x/sclpcpi.c
+++ b/hw/s390x/sclpcpi.c
@@ -62,6 +62,7 @@
#include "hw/s390x/event-facility.h"
#include "hw/s390x/ebcdic.h"
#include "qapi/qapi-visit-machine.h"
+#include "migration/vmstate.h"
typedef struct Data {
uint8_t id_format;
@@ -133,12 +134,38 @@ static void get_control_program_id(Object *obj, Visitor *v,
visit_type_S390ControlProgramId(v, name, &cpi, errp);
}
+static const VMStateDescription vmstate_control_program_id = {
+ .name = "s390_control_program_id",
+ .version_id = 0,
+ .minimum_version_id = 0,
+ .fields = (const VMStateField[]) {
+ VMSTATE_UINT8_ARRAY(system_type, ControlProgramId, 8),
+ VMSTATE_UINT8_ARRAY(system_name, ControlProgramId, 8),
+ VMSTATE_UINT64(system_level, ControlProgramId),
+ VMSTATE_UINT8_ARRAY(sysplex_name, ControlProgramId, 8),
+ VMSTATE_UINT64(timestamp, ControlProgramId),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
+static const VMStateDescription vmstate_sclpcpi = {
+ .name = "s390_sclpcpi",
+ .version_id = 0,
+ .minimum_version_id = 0,
+ .fields = (const VMStateField[]) {
+ VMSTATE_STRUCT(cpi, SCLPEvent, 0, vmstate_control_program_id,
+ ControlProgramId),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
static void cpi_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
SCLPEventClass *k = SCLP_EVENT_CLASS(klass);
dc->user_creatable = false;
+ dc->vmsd = &vmstate_sclpcpi;
k->can_handle_event = can_handle_event;
k->get_send_mask = send_mask;
--
2.47.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH v3 3/4] hw/s390x: support migration of CPI data
2025-03-31 14:00 ` [PATCH v3 3/4] hw/s390x: support migration of CPI data Shalini Chellathurai Saroja
@ 2025-04-02 6:05 ` Thomas Huth
2025-04-02 9:12 ` Shalini Chellathurai Saroja
0 siblings, 1 reply; 19+ messages in thread
From: Thomas Huth @ 2025-04-02 6:05 UTC (permalink / raw)
To: Shalini Chellathurai Saroja, qemu-s390x mailing list,
Daniel Berrange
Cc: qemu-devel mailing list, Nina Schoetterl-Glausch,
Hendrik Brueckner
On 31/03/2025 16.00, Shalini Chellathurai Saroja wrote:
> Register Control-Program Identification data with the live
> migration infrastructure.
>
> Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
> Reviewed-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
> ---
> hw/s390x/sclpcpi.c | 27 +++++++++++++++++++++++++++
> 1 file changed, 27 insertions(+)
>
> diff --git a/hw/s390x/sclpcpi.c b/hw/s390x/sclpcpi.c
> index 969c15e43d..0b1b5293ea 100644
> --- a/hw/s390x/sclpcpi.c
> +++ b/hw/s390x/sclpcpi.c
> @@ -62,6 +62,7 @@
> #include "hw/s390x/event-facility.h"
> #include "hw/s390x/ebcdic.h"
> #include "qapi/qapi-visit-machine.h"
> +#include "migration/vmstate.h"
>
> typedef struct Data {
> uint8_t id_format;
> @@ -133,12 +134,38 @@ static void get_control_program_id(Object *obj, Visitor *v,
> visit_type_S390ControlProgramId(v, name, &cpi, errp);
> }
>
> +static const VMStateDescription vmstate_control_program_id = {
> + .name = "s390_control_program_id",
> + .version_id = 0,
> + .minimum_version_id = 0,
Nit: As long as it is 0, I think you could simply omit the
minimum_version_id field here.
> + .fields = (const VMStateField[]) {
> + VMSTATE_UINT8_ARRAY(system_type, ControlProgramId, 8),
> + VMSTATE_UINT8_ARRAY(system_name, ControlProgramId, 8),
> + VMSTATE_UINT64(system_level, ControlProgramId),
> + VMSTATE_UINT8_ARRAY(sysplex_name, ControlProgramId, 8),
> + VMSTATE_UINT64(timestamp, ControlProgramId),
> + VMSTATE_END_OF_LIST()
> + }
> +};
> +
> +static const VMStateDescription vmstate_sclpcpi = {
> + .name = "s390_sclpcpi",
> + .version_id = 0,
> + .minimum_version_id = 0,
dito
> + .fields = (const VMStateField[]) {
> + VMSTATE_STRUCT(cpi, SCLPEvent, 0, vmstate_control_program_id,
> + ControlProgramId),
> + VMSTATE_END_OF_LIST()
> + }
> +};
Thomas
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 3/4] hw/s390x: support migration of CPI data
2025-04-02 6:05 ` Thomas Huth
@ 2025-04-02 9:12 ` Shalini Chellathurai Saroja
0 siblings, 0 replies; 19+ messages in thread
From: Shalini Chellathurai Saroja @ 2025-04-02 9:12 UTC (permalink / raw)
To: Thomas Huth
Cc: qemu-s390x mailing list, Daniel Berrange, qemu-devel mailing list,
Nina Schoetterl-Glausch, Hendrik Brueckner
On 2025-04-02 08:05, Thomas Huth wrote:
> On 31/03/2025 16.00, Shalini Chellathurai Saroja wrote:
>> Register Control-Program Identification data with the live
>> migration infrastructure.
>>
>> Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
>> Reviewed-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
>> ---
>> hw/s390x/sclpcpi.c | 27 +++++++++++++++++++++++++++
>> 1 file changed, 27 insertions(+)
>>
>> diff --git a/hw/s390x/sclpcpi.c b/hw/s390x/sclpcpi.c
>> index 969c15e43d..0b1b5293ea 100644
>> --- a/hw/s390x/sclpcpi.c
>> +++ b/hw/s390x/sclpcpi.c
>> @@ -62,6 +62,7 @@
>> #include "hw/s390x/event-facility.h"
>> #include "hw/s390x/ebcdic.h"
>> #include "qapi/qapi-visit-machine.h"
>> +#include "migration/vmstate.h"
>> typedef struct Data {
>> uint8_t id_format;
>> @@ -133,12 +134,38 @@ static void get_control_program_id(Object *obj,
>> Visitor *v,
>> visit_type_S390ControlProgramId(v, name, &cpi, errp);
>> }
>> +static const VMStateDescription vmstate_control_program_id = {
>> + .name = "s390_control_program_id",
>> + .version_id = 0,
>> + .minimum_version_id = 0,
>
> Nit: As long as it is 0, I think you could simply omit the
> minimum_version_id field here.
>
Ok, I will omit the minimum_version_id field in both, thank you.
>> + .fields = (const VMStateField[]) {
>> + VMSTATE_UINT8_ARRAY(system_type, ControlProgramId, 8),
>> + VMSTATE_UINT8_ARRAY(system_name, ControlProgramId, 8),
>> + VMSTATE_UINT64(system_level, ControlProgramId),
>> + VMSTATE_UINT8_ARRAY(sysplex_name, ControlProgramId, 8),
>> + VMSTATE_UINT64(timestamp, ControlProgramId),
>> + VMSTATE_END_OF_LIST()
>> + }
>> +};
>> +
>> +static const VMStateDescription vmstate_sclpcpi = {
>> + .name = "s390_sclpcpi",
>> + .version_id = 0,
>> + .minimum_version_id = 0,
>
> dito
>
>> + .fields = (const VMStateField[]) {
>> + VMSTATE_STRUCT(cpi, SCLPEvent, 0, vmstate_control_program_id,
>> + ControlProgramId),
>> + VMSTATE_END_OF_LIST()
>> + }
>> +};
> Thomas
--
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
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH v3 4/4] hw/s390x: compat handling for backward migration
2025-03-31 14:00 [PATCH v3 0/4] *** Add SCLP event type CPI *** Shalini Chellathurai Saroja
` (2 preceding siblings ...)
2025-03-31 14:00 ` [PATCH v3 3/4] hw/s390x: support migration of CPI data Shalini Chellathurai Saroja
@ 2025-03-31 14:00 ` Shalini Chellathurai Saroja
2025-04-02 7:52 ` Thomas Huth
3 siblings, 1 reply; 19+ messages in thread
From: Shalini Chellathurai Saroja @ 2025-03-31 14:00 UTC (permalink / raw)
To: qemu-s390x mailing list, Thomas Huth, Daniel Berrange
Cc: qemu-devel mailing list, Nina Schoetterl-Glausch,
Hendrik Brueckner, Shalini Chellathurai Saroja
Add Control-Program Identification (CPI) device to QOM only when the virtual
machine supports CPI. CPI is supported from "s390-ccw-virtio-10.0" machine
and higher.
Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
---
hw/s390x/event-facility.c | 27 ++++++++++++++++++++++-----
hw/s390x/s390-virtio-ccw.c | 1 +
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
index c0fb6e098c..cb23bbc54b 100644
--- a/hw/s390x/event-facility.c
+++ b/hw/s390x/event-facility.c
@@ -22,6 +22,7 @@
#include "hw/s390x/sclp.h"
#include "migration/vmstate.h"
#include "hw/s390x/event-facility.h"
+#include "hw/qdev-properties.h"
typedef struct SCLPEventsBus {
BusState qbus;
@@ -54,6 +55,7 @@ struct SCLPEventFacility {
bool allow_all_mask_sizes;
/* length of the receive mask */
uint16_t mask_length;
+ bool use_cpi;
};
/* return true if any child has event pending set */
@@ -455,11 +457,20 @@ 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;
+ /*
+ * Add sclpcpi device to QOM only when the virtual machine supports
+ * Control-Program Identification. It is supported by "s390-ccw-virtio-10.0"
+ * machine and higher.
+ */
+ if (!event_facility->use_cpi) {
+ object_unparent(OBJECT(&event_facility->cpi));
+ } else {
+ 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;
+ }
}
}
@@ -470,12 +481,18 @@ static void reset_event_facility(DeviceState *dev)
sdev->receive_mask = 0;
}
+static const Property qemu_event_facility_properties[] = {
+ DEFINE_PROP_BOOL("use-cpi", SCLPEventFacility,
+ use_cpi, true),
+};
+
static void init_event_facility_class(ObjectClass *klass, void *data)
{
SysBusDeviceClass *sbdc = SYS_BUS_DEVICE_CLASS(klass);
DeviceClass *dc = DEVICE_CLASS(sbdc);
SCLPEventFacilityClass *k = EVENT_FACILITY_CLASS(dc);
+ device_class_set_props(dc, qemu_event_facility_properties);
dc->realize = realize_event_facility;
device_class_set_legacy_reset(dc, reset_event_facility);
dc->vmsd = &vmstate_event_facility;
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 75b32182eb..c1001322e0 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -939,6 +939,7 @@ static void ccw_machine_9_2_class_options(MachineClass *mc)
{
static GlobalProperty compat[] = {
{ TYPE_S390_PCI_DEVICE, "relaxed-translation", "off", },
+ { TYPE_SCLP_EVENT_FACILITY, "use-cpi", "off", },
};
ccw_machine_10_0_class_options(mc);
--
2.47.0
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH v3 4/4] hw/s390x: compat handling for backward migration
2025-03-31 14:00 ` [PATCH v3 4/4] hw/s390x: compat handling for backward migration Shalini Chellathurai Saroja
@ 2025-04-02 7:52 ` Thomas Huth
2025-04-03 12:49 ` Shalini Chellathurai Saroja
0 siblings, 1 reply; 19+ messages in thread
From: Thomas Huth @ 2025-04-02 7:52 UTC (permalink / raw)
To: Shalini Chellathurai Saroja, qemu-s390x mailing list,
Daniel Berrange
Cc: qemu-devel mailing list, Nina Schoetterl-Glausch,
Hendrik Brueckner
On 31/03/2025 16.00, Shalini Chellathurai Saroja wrote:
> Add Control-Program Identification (CPI) device to QOM only when the virtual
> machine supports CPI. CPI is supported from "s390-ccw-virtio-10.0" machine
> and higher.
>
> Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
> ---
> hw/s390x/event-facility.c | 27 ++++++++++++++++++++++-----
> hw/s390x/s390-virtio-ccw.c | 1 +
> 2 files changed, 23 insertions(+), 5 deletions(-)
>
> diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
> index c0fb6e098c..cb23bbc54b 100644
> --- a/hw/s390x/event-facility.c
> +++ b/hw/s390x/event-facility.c
> @@ -22,6 +22,7 @@
> #include "hw/s390x/sclp.h"
> #include "migration/vmstate.h"
> #include "hw/s390x/event-facility.h"
> +#include "hw/qdev-properties.h"
>
> typedef struct SCLPEventsBus {
> BusState qbus;
> @@ -54,6 +55,7 @@ struct SCLPEventFacility {
> bool allow_all_mask_sizes;
> /* length of the receive mask */
> uint16_t mask_length;
> + bool use_cpi;
> };
>
> /* return true if any child has event pending set */
> @@ -455,11 +457,20 @@ 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;
> + /*
> + * Add sclpcpi device to QOM only when the virtual machine supports
> + * Control-Program Identification. It is supported by "s390-ccw-virtio-10.0"
> + * machine and higher.
> + */
> + if (!event_facility->use_cpi) {
> + object_unparent(OBJECT(&event_facility->cpi));
> + } else {
> + 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;
> + }
Hmm, first doing object_initialize_child() in init_event_facility() and then
unparenting it here again in case we are running with an older machine type
is a little bit ugly. I wonder whether it would be nicer to add the QOM
object from ccw_init() init instead, similar to what we do with the
SCLP-console in s390_create_sclpconsole() ? If you've got some spare
minutes, could you please give it a try whether that looks nicer?
Thanks,
Thomas
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 4/4] hw/s390x: compat handling for backward migration
2025-04-02 7:52 ` Thomas Huth
@ 2025-04-03 12:49 ` Shalini Chellathurai Saroja
2025-04-09 5:49 ` Thomas Huth
0 siblings, 1 reply; 19+ messages in thread
From: Shalini Chellathurai Saroja @ 2025-04-03 12:49 UTC (permalink / raw)
To: Thomas Huth
Cc: qemu-s390x mailing list, Daniel Berrange, qemu-devel mailing list,
Nina Schoetterl-Glausch, Hendrik Brueckner
On 2025-04-02 09:52, Thomas Huth wrote:
> On 31/03/2025 16.00, Shalini Chellathurai Saroja wrote:
>> Add Control-Program Identification (CPI) device to QOM only when the
>> virtual
>> machine supports CPI. CPI is supported from "s390-ccw-virtio-10.0"
>> machine
>> and higher.
>>
>> Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
>> ---
>> hw/s390x/event-facility.c | 27 ++++++++++++++++++++++-----
>> hw/s390x/s390-virtio-ccw.c | 1 +
>> 2 files changed, 23 insertions(+), 5 deletions(-)
>>
>> diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
>> index c0fb6e098c..cb23bbc54b 100644
>> --- a/hw/s390x/event-facility.c
>> +++ b/hw/s390x/event-facility.c
>> @@ -22,6 +22,7 @@
>> #include "hw/s390x/sclp.h"
>> #include "migration/vmstate.h"
>> #include "hw/s390x/event-facility.h"
>> +#include "hw/qdev-properties.h"
>> typedef struct SCLPEventsBus {
>> BusState qbus;
>> @@ -54,6 +55,7 @@ struct SCLPEventFacility {
>> bool allow_all_mask_sizes;
>> /* length of the receive mask */
>> uint16_t mask_length;
>> + bool use_cpi;
>> };
>> /* return true if any child has event pending set */
>> @@ -455,11 +457,20 @@ 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;
>> + /*
>> + * Add sclpcpi device to QOM only when the virtual machine
>> supports
>> + * Control-Program Identification. It is supported by
>> "s390-ccw-virtio-10.0"
>> + * machine and higher.
>> + */
>> + if (!event_facility->use_cpi) {
>> + object_unparent(OBJECT(&event_facility->cpi));
>> + } else {
>> + 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;
>> + }
>
> Hmm, first doing object_initialize_child() in init_event_facility()
> and then unparenting it here again in case we are running with an
> older machine type is a little bit ugly. I wonder whether it would be
> nicer to add the QOM object from ccw_init() init instead, similar to
> what we do with the SCLP-console in s390_create_sclpconsole() ? If
> you've got some spare minutes, could you please give it a try whether
> that looks nicer?
>
Hello Thomas,
Sure. Did you mean like the code below?, if yes, the use_cpi is always
true when adding the sclpcpi device from ccw_init(). The use_cpi is set
to false at a later point, when the machine type is 9.2 or older. This
means the sclpcpi device is always added, the output and the code are
provided below. Please let me know how to proceed, thank you very much.
virsh # qemu-monitor-command vm --pretty '{"execute":"qom-get",
"arguments":{"path":"/machine/sclp/s390-sclp-event-facility",
"property":"use-cpi"}}'
{
"return": false,
"id": "libvirt-16"
}
virsh # qemu-monitor-command vm --pretty '{"execute":"qom-get",
"arguments":{"path":"/machine/sclp/s390-sclp-event-facility/sclpcpi",
"property":"control-program-id"}}'
{
"return": {
"timestamp": 1743681889538425000,
"system-level": 74872343805430528,
"sysplex-name": " ",
"system-name": " ",
"system-type": "LINUX "
},
"id": "libvirt-17"
}
diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
index cb23bbc54b..15d9f94845 100644
--- a/hw/s390x/event-facility.c
+++ b/hw/s390x/event-facility.c
@@ -76,6 +76,11 @@ static bool event_pending(SCLPEventFacility *ef)
return false;
}
+static bool use_cpi(SCLPEventFacility *ef)
+{
+ return ef->use_cpi;
+}
+
static sccb_mask_t get_host_send_mask(SCLPEventFacility *ef)
{
sccb_mask_t mask;
@@ -438,10 +443,6 @@ 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)
@@ -457,21 +458,6 @@ static void realize_event_facility(DeviceState
*dev, Error **errp)
qdev_unrealize(DEVICE(&event_facility->quiesce));
return;
}
- /*
- * Add sclpcpi device to QOM only when the virtual machine supports
- * Control-Program Identification. It is supported by
"s390-ccw-virtio-10.0"
- * machine and higher.
- */
- if (!event_facility->use_cpi) {
- object_unparent(OBJECT(&event_facility->cpi));
- } else {
- 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)
@@ -499,6 +485,7 @@ static void init_event_facility_class(ObjectClass
*klass, void *data)
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
k->command_handler = command_handler;
k->event_pending = event_pending;
+ k->use_cpi = use_cpi;
}
static const TypeInfo sclp_event_facility_info = {
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index c1001322e0..f077ecaee1 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -260,6 +260,21 @@ static void s390_create_sclpconsole(SCLPDevice
*sclp,
qdev_realize_and_unref(dev, ev_fac_bus, &error_fatal);
}
+static void s390_create_sclpcpi(SCLPDevice *sclp)
+{
+ SCLPEventFacility *ef = sclp->event_facility;
+ SCLPEventFacilityClass *efc = EVENT_FACILITY_GET_CLASS(ef);
+ BusState *ev_fac_bus = sclp_get_event_facility_bus(ef);
+ DeviceState *dev;
+
+ if(efc->use_cpi) {
+ dev = qdev_new(TYPE_SCLP_CPI);
+ object_property_add_child(OBJECT(ef), "sclpcpi", OBJECT(dev));
+ object_unref(OBJECT(dev));
+ qdev_realize_and_unref(dev, ev_fac_bus, &error_fatal);
+ }
+}
+
static void ccw_init(MachineState *machine)
{
MachineClass *mc = MACHINE_GET_CLASS(machine);
@@ -323,6 +338,10 @@ static void ccw_init(MachineState *machine)
/* init the TOD clock */
s390_init_tod();
+
+ /* init SCLP event Control-Program Identification */
+ s390_create_sclpcpi(ms->sclp);
+
}
static void s390_cpu_plug(HotplugHandler *hotplug_dev,
diff --git a/include/hw/s390x/event-facility.h
b/include/hw/s390x/event-facility.h
index f445d2f9f5..ba20161023 100644
--- a/include/hw/s390x/event-facility.h
+++ b/include/hw/s390x/event-facility.h
@@ -204,6 +204,7 @@ struct SCLPEventFacilityClass {
SysBusDeviceClass parent_class;
void (*command_handler)(SCLPEventFacility *ef, SCCB *sccb, uint64_t
code);
bool (*event_pending)(SCLPEventFacility *ef);
+ bool (*use_cpi)(SCLPEventFacility *ef);
};
BusState *sclp_get_event_facility_bus(SCLPEventFacility *ef);
> Thanks,
> Thomas
--
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
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH v3 4/4] hw/s390x: compat handling for backward migration
2025-04-03 12:49 ` Shalini Chellathurai Saroja
@ 2025-04-09 5:49 ` Thomas Huth
2025-04-09 14:13 ` Shalini Chellathurai Saroja
0 siblings, 1 reply; 19+ messages in thread
From: Thomas Huth @ 2025-04-09 5:49 UTC (permalink / raw)
To: Shalini Chellathurai Saroja
Cc: qemu-s390x mailing list, Daniel Berrange, qemu-devel mailing list,
Nina Schoetterl-Glausch, Hendrik Brueckner
On 03/04/2025 14.49, Shalini Chellathurai Saroja wrote:
> On 2025-04-02 09:52, Thomas Huth wrote:
>> On 31/03/2025 16.00, Shalini Chellathurai Saroja wrote:
>>> Add Control-Program Identification (CPI) device to QOM only when the virtual
>>> machine supports CPI. CPI is supported from "s390-ccw-virtio-10.0" machine
>>> and higher.
>>>
>>> Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
>>> ---
>>> hw/s390x/event-facility.c | 27 ++++++++++++++++++++++-----
>>> hw/s390x/s390-virtio-ccw.c | 1 +
>>> 2 files changed, 23 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
>>> index c0fb6e098c..cb23bbc54b 100644
>>> --- a/hw/s390x/event-facility.c
>>> +++ b/hw/s390x/event-facility.c
>>> @@ -22,6 +22,7 @@
>>> #include "hw/s390x/sclp.h"
>>> #include "migration/vmstate.h"
>>> #include "hw/s390x/event-facility.h"
>>> +#include "hw/qdev-properties.h"
>>> typedef struct SCLPEventsBus {
>>> BusState qbus;
>>> @@ -54,6 +55,7 @@ struct SCLPEventFacility {
>>> bool allow_all_mask_sizes;
>>> /* length of the receive mask */
>>> uint16_t mask_length;
>>> + bool use_cpi;
>>> };
>>> /* return true if any child has event pending set */
>>> @@ -455,11 +457,20 @@ 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;
>>> + /*
>>> + * Add sclpcpi device to QOM only when the virtual machine supports
>>> + * Control-Program Identification. It is supported by "s390-ccw-
>>> virtio-10.0"
>>> + * machine and higher.
>>> + */
>>> + if (!event_facility->use_cpi) {
>>> + object_unparent(OBJECT(&event_facility->cpi));
>>> + } else {
>>> + 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;
>>> + }
>>
>> Hmm, first doing object_initialize_child() in init_event_facility()
>> and then unparenting it here again in case we are running with an
>> older machine type is a little bit ugly. I wonder whether it would be
>> nicer to add the QOM object from ccw_init() init instead, similar to
>> what we do with the SCLP-console in s390_create_sclpconsole() ? If
>> you've got some spare minutes, could you please give it a try whether
>> that looks nicer?
>>
>
> Hello Thomas,
>
> Sure. Did you mean like the code below?, if yes, the use_cpi is always true
> when adding the sclpcpi device from ccw_init(). The use_cpi is set to false
> at a later point, when the machine type is 9.2 or older. This means the
> sclpcpi device is always added, the output and the code are provided below.
> Please let me know how to proceed, thank you very much.
...
> @@ -499,6 +485,7 @@ static void init_event_facility_class(ObjectClass
> *klass, void *data)
> set_bit(DEVICE_CATEGORY_MISC, dc->categories);
> k->command_handler = command_handler;
> k->event_pending = event_pending;
> + k->use_cpi = use_cpi;
> }
...
> diff --git a/include/hw/s390x/event-facility.h b/include/hw/s390x/event-
> facility.h
> index f445d2f9f5..ba20161023 100644
> --- a/include/hw/s390x/event-facility.h
> +++ b/include/hw/s390x/event-facility.h
> @@ -204,6 +204,7 @@ struct SCLPEventFacilityClass {
> SysBusDeviceClass parent_class;
> void (*command_handler)(SCLPEventFacility *ef, SCCB *sccb, uint64_t
> code);
> bool (*event_pending)(SCLPEventFacility *ef);
> + bool (*use_cpi)(SCLPEventFacility *ef);
> };
Hi,
you certainly don't need the (*use_cpi) callback here.
I'd suggest to:
1) Add a boolean flag to S390CcwMachineClass in s390-virtio-ccw.h called
"use_cpi", "cpi_allowed", "has_cpi" or whatever.
2) Set that flag to true in ccw_machine_class_init() (similar to that
hpage_1m_allowed flag)
3) Set that flag to false in ccw_machine_9_2_class_options() so that it gets
disabled for older machine type classes. Important: use the class_options()
function here, not the instance_options()! Also not that this should go into
the ccw_machine_10_0_class_options() functions instead once v10.0 has been
released.
4) In ccw_init() you should now be able to use "S390CcwMachineClass *s390mc
= S390_CCW_MACHINE_CLASS(mc)" to query the flag from the machine class.
HTH,
Thomas
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 4/4] hw/s390x: compat handling for backward migration
2025-04-09 5:49 ` Thomas Huth
@ 2025-04-09 14:13 ` Shalini Chellathurai Saroja
0 siblings, 0 replies; 19+ messages in thread
From: Shalini Chellathurai Saroja @ 2025-04-09 14:13 UTC (permalink / raw)
To: Thomas Huth
Cc: qemu-s390x mailing list, Daniel Berrange, qemu-devel mailing list,
Nina Schoetterl-Glausch, Hendrik Brueckner,
<Shalini Chellathurai Saroja
On 2025-04-09 07:49, Thomas Huth wrote:
> On 03/04/2025 14.49, Shalini Chellathurai Saroja wrote:
>> On 2025-04-02 09:52, Thomas Huth wrote:
>>> On 31/03/2025 16.00, Shalini Chellathurai Saroja wrote:
>>>> Add Control-Program Identification (CPI) device to QOM only when the
>>>> virtual
>>>> machine supports CPI. CPI is supported from "s390-ccw-virtio-10.0"
>>>> machine
>>>> and higher.
>>>>
>>>> Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
>>>> ---
>>>> hw/s390x/event-facility.c | 27 ++++++++++++++++++++++-----
>>>> hw/s390x/s390-virtio-ccw.c | 1 +
>>>> 2 files changed, 23 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
>>>> index c0fb6e098c..cb23bbc54b 100644
>>>> --- a/hw/s390x/event-facility.c
>>>> +++ b/hw/s390x/event-facility.c
>>>> @@ -22,6 +22,7 @@
>>>> #include "hw/s390x/sclp.h"
>>>> #include "migration/vmstate.h"
>>>> #include "hw/s390x/event-facility.h"
>>>> +#include "hw/qdev-properties.h"
>>>> typedef struct SCLPEventsBus {
>>>> BusState qbus;
>>>> @@ -54,6 +55,7 @@ struct SCLPEventFacility {
>>>> bool allow_all_mask_sizes;
>>>> /* length of the receive mask */
>>>> uint16_t mask_length;
>>>> + bool use_cpi;
>>>> };
>>>> /* return true if any child has event pending set */
>>>> @@ -455,11 +457,20 @@ 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;
>>>> + /*
>>>> + * Add sclpcpi device to QOM only when the virtual machine
>>>> supports
>>>> + * Control-Program Identification. It is supported by
>>>> "s390-ccw- virtio-10.0"
>>>> + * machine and higher.
>>>> + */
>>>> + if (!event_facility->use_cpi) {
>>>> + object_unparent(OBJECT(&event_facility->cpi));
>>>> + } else {
>>>> + 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;
>>>> + }
>>>
>>> Hmm, first doing object_initialize_child() in init_event_facility()
>>> and then unparenting it here again in case we are running with an
>>> older machine type is a little bit ugly. I wonder whether it would be
>>> nicer to add the QOM object from ccw_init() init instead, similar to
>>> what we do with the SCLP-console in s390_create_sclpconsole() ? If
>>> you've got some spare minutes, could you please give it a try whether
>>> that looks nicer?
>>>
>>
>> Hello Thomas,
>>
>> Sure. Did you mean like the code below?, if yes, the use_cpi is always
>> true when adding the sclpcpi device from ccw_init(). The use_cpi is
>> set to false at a later point, when the machine type is 9.2 or older.
>> This means the sclpcpi device is always added, the output and the code
>> are provided below. Please let me know how to proceed, thank you very
>> much.
> ...
>> @@ -499,6 +485,7 @@ static void init_event_facility_class(ObjectClass
>> *klass, void *data)
>> set_bit(DEVICE_CATEGORY_MISC, dc->categories);
>> k->command_handler = command_handler;
>> k->event_pending = event_pending;
>> + k->use_cpi = use_cpi;
>> }
> ...
>> diff --git a/include/hw/s390x/event-facility.h
>> b/include/hw/s390x/event- facility.h
>> index f445d2f9f5..ba20161023 100644
>> --- a/include/hw/s390x/event-facility.h
>> +++ b/include/hw/s390x/event-facility.h
>> @@ -204,6 +204,7 @@ struct SCLPEventFacilityClass {
>> SysBusDeviceClass parent_class;
>> void (*command_handler)(SCLPEventFacility *ef, SCCB *sccb,
>> uint64_t code);
>> bool (*event_pending)(SCLPEventFacility *ef);
>> + bool (*use_cpi)(SCLPEventFacility *ef);
>> };
>
> Hi,
>
> you certainly don't need the (*use_cpi) callback here.
>
> I'd suggest to:
>
> 1) Add a boolean flag to S390CcwMachineClass in s390-virtio-ccw.h
> called "use_cpi", "cpi_allowed", "has_cpi" or whatever.
>
> 2) Set that flag to true in ccw_machine_class_init() (similar to that
> hpage_1m_allowed flag)
>
> 3) Set that flag to false in ccw_machine_9_2_class_options() so that
> it gets disabled for older machine type classes. Important: use the
> class_options() function here, not the instance_options()! Also not
> that this should go into the ccw_machine_10_0_class_options()
> functions instead once v10.0 has been released.
>
> 4) In ccw_init() you should now be able to use "S390CcwMachineClass
> *s390mc = S390_CCW_MACHINE_CLASS(mc)" to query the flag from the
> machine class.
>
> HTH,
> Thomas
Hi Thomas,
I will do this, Thank you.
--
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
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 2/4] hw/s390x: add Control-Program Identification to QOM
@ 2025-04-02 9:06 Shalini Chellathurai Saroja
0 siblings, 0 replies; 19+ messages in thread
From: Shalini Chellathurai Saroja @ 2025-04-02 9:06 UTC (permalink / raw)
To: Thomas Huth
Cc: qemu-s390x mailing list, Daniel Berrange, qemu-devel mailing list,
Nina Schoetterl-Glausch, Hendrik Brueckner
On 2025-04-02 07:58, Thomas Huth wrote:
> On 31/03/2025 16.00, Shalini Chellathurai Saroja wrote:
>> Add Control-Program Identification data to the QEMU Object
>> Model (QOM), along with the timestamp in which the data was received.
>>
>> Example:
>> virsh # qemu-monitor-command vm --pretty '{
>> "execute": "qom-get",
>> "arguments": {
>> "path": "/machine/sclp/s390-sclp-event-facility/sclpcpi",
>> "property": "control-program-id" }}'
>> {
>> "return": {
>> "timestamp": 1742390410685762000,
>> "system-level": 74872343805430528,
>> "sysplex-name": "PLEX ",
>> "system-name": "TESTVM ",
>> "system-type": "LINUX "
>> },
>> "id": "libvirt-15"
>> }
>>
>> Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
>> ---
>> hw/s390x/sclpcpi.c | 38 ++++++++++++++++++++
>> include/hw/s390x/event-facility.h | 9 +++++
>> qapi/machine.json | 58
>> +++++++++++++++++++++++++++++++
>> 3 files changed, 105 insertions(+)
>>
>> diff --git a/include/hw/s390x/event-facility.h
>> b/include/hw/s390x/event-facility.h
>> index f445d2f9f5..39e589ed44 100644
>> --- a/include/hw/s390x/event-facility.h
>> +++ b/include/hw/s390x/event-facility.h
>> @@ -169,10 +169,19 @@ typedef struct ReadEventData {
>> };
>> } QEMU_PACKED ReadEventData;
>> +typedef struct ControlProgramId {
>> + uint8_t system_type[8];
>> + uint8_t system_name[8];
>> + uint64_t system_level;
>> + uint8_t sysplex_name[8];
>> + uint64_t timestamp;
>> +} QEMU_PACKED ControlProgramId;
>
> Do we need the QEMU_PACKED here? The members seem naturally aligned,
> and the struct does not seem to be involved in the communication with
> the guest directly, so if you don't need it, please drop the
> QEMU_PACKED here.
> (without PACKED, the compiler can optimize the code in a better way,
> and this causes less trouble on exotic platforms like SPARC that
> cannot access unaligned memory addresses)
Hello Thomas,
Thank you for the explanation. I will drop the QEMU_PACKED.
>
>> struct SCLPEvent {
>> DeviceState qdev;
>> bool event_pending;
>> char *name;
>> + ControlProgramId cpi;
>> };
>> struct SCLPEventClass {
>> diff --git a/qapi/machine.json b/qapi/machine.json
>> index a6b8795b09..cd2bcd2d13 100644
>> --- a/qapi/machine.json
>> +++ b/qapi/machine.json
>> @@ -1898,3 +1898,61 @@
>> { 'command': 'x-query-interrupt-controllers',
>> 'returns': 'HumanReadableText',
>> 'features': [ 'unstable' ]}
>> +
>> +##
>> +# @S390ControlProgramId:
>> +#
>> +# Control-program identifiers provide data about the guest operating
>> system.
>> +# The control-program identifiers are: system type, system name,
>> system level
>> +# and sysplex name.
>> +#
>> +# In Linux, all the control-program identifiers are user
>> configurable. The
>> +# system type, system name, and sysplex name use EBCDIC characters
>> from
>> +# this set: capital A-Z, 0-9, $, @, #, and blank. In Linux, the
>> system type,
>> +# system name and sysplex name are arbitrary free-form texts.
>> +#
>> +# In Linux, the 8-byte hexadecimal system-level has the format
>> +# 0x<a><b><cc><dd><eeee><ff><gg><hh>, where:
>> +# <a>: is one hexadecimal byte, its most significant bit indicates
>> hypervisor
>> +# use
>> +# <b>: is one digit that represents Linux distributions as follows
>> +# 0: generic Linux
>> +# 1: Red Hat Enterprise Linux
>> +# 2: SUSE Linux Enterprise Server
>> +# 3: Canonical Ubuntu
>> +# 4: Fedora
>> +# 5: openSUSE Leap
>> +# 6: Debian GNU/Linux
>> +# 7: Red Hat Enterprise Linux CoreOS
>> +# <cc>: are two digits for a distribution-specific encoding of the
>> major version
>> +# of the distribution
>> +# <dd>: are two digits for a distribution-specific encoding of the
>> minor version
>> +# of the distribution
>> +# <eeee>: are four digits for the patch level of the distribution
>> +# <ff>: are two digits for the major version of the kernel
>> +# <gg>: are two digits for the minor version of the kernel
>> +# <hh>: are two digits for the stable version of the kernel
>> +# (e.g. 74872343805430528, when converted to hex is
>> 0x010a000000060b00). On
>> +# machines prior to z16, some of the values are not available to
>> display.
>
> You've got the same information in the comment at the beginning of the
> sclpcpi.c file already ... maybe it would be good to have it in one
> place only to avoid double maintenance in case it needs to be changed
> in the future. I'd suggest to change the comment at the beginning of
> sclpcpi.c to say something like "for a detailed description of the
> contents of the CPI, please see the S390ControlProgramId QOM-type
> description." or something similar?
ok, I will do that.
>
> Thomas
--
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
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 2/4] hw/s390x: add Control-Program Identification to QOM
@ 2025-04-03 14:33 Shalini Chellathurai Saroja
2025-04-09 5:30 ` Thomas Huth
0 siblings, 1 reply; 19+ messages in thread
From: Shalini Chellathurai Saroja @ 2025-04-03 14:33 UTC (permalink / raw)
To: Nina Schoetterl-Glausch, Thomas Huth
Cc: qemu-s390x mailing list, Daniel Berrange, qemu-devel mailing list,
Hendrik Brueckner
On 2025-04-01 15:55, Nina Schoetterl-Glausch wrote:
> On Mon, 2025-03-31 at 16:00 +0200, Shalini Chellathurai Saroja wrote:
>> Add Control-Program Identification data to the QEMU Object
>> Model (QOM), along with the timestamp in which the data was received.
>>
>> Example:
>> virsh # qemu-monitor-command vm --pretty '{
>> "execute": "qom-get",
>> "arguments": {
>> "path": "/machine/sclp/s390-sclp-event-facility/sclpcpi",
>> "property": "control-program-id" }}'
>> {
>> "return": {
>> "timestamp": 1742390410685762000,
>> "system-level": 74872343805430528,
>> "sysplex-name": "PLEX ",
>> "system-name": "TESTVM ",
>> "system-type": "LINUX "
>> },
>> "id": "libvirt-15"
>> }
>>
>> Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
>> ---
>> hw/s390x/sclpcpi.c | 38 ++++++++++++++++++++
>> include/hw/s390x/event-facility.h | 9 +++++
>> qapi/machine.json | 58
>> +++++++++++++++++++++++++++++++
>> 3 files changed, 105 insertions(+)
>>
>> diff --git a/hw/s390x/sclpcpi.c b/hw/s390x/sclpcpi.c
>> index 7ace5dd64e..969c15e43d 100644
>> --- a/hw/s390x/sclpcpi.c
>> +++ b/hw/s390x/sclpcpi.c
>> @@ -57,8 +57,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 "qapi/qapi-visit-machine.h"
>>
>> typedef struct Data {
>> uint8_t id_format;
>> @@ -99,10 +102,37 @@ static int write_event_data(SCLPEvent *event,
>> EventBufferHeader *evt_buf_hdr)
>> ControlProgramIdMsg *cpim = container_of(evt_buf_hdr,
>> ControlProgramIdMsg,
>> ebh);
>>
>> + ascii_put(event->cpi.system_type, (char *)cpim->data.system_type,
>> 8);
>> + ascii_put(event->cpi.system_name, (char *)cpim->data.system_name,
>> 8);
>> + ascii_put(event->cpi.sysplex_name, (char
>> *)cpim->data.sysplex_name, 8);
>> + event->cpi.system_level = ldq_be_p(&cpim->data.system_level);
>> + event->cpi.timestamp = qemu_clock_get_ns(QEMU_CLOCK_HOST);
>> +
>> cpim->ebh.flags = SCLP_EVENT_BUFFER_ACCEPTED;
>> return SCLP_RC_NORMAL_COMPLETION;
>> }
>>
>> +static void get_control_program_id(Object *obj, Visitor *v,
>> + const char *name, void *opaque,
>> + Error **errp)
>> +{
>> + SCLPEvent *event = (SCLPEvent *)(obj);
>
> Do a checked cast with SCLP_EVENT(obj).
Hello Nina,
ok, thank you.
>
>> + S390ControlProgramId *cpi;
>> +
>> + cpi = &(S390ControlProgramId){
>> + .system_type = g_strndup((char *) event->cpi.system_type,
>> + sizeof(event->cpi.system_type)),
>> + .system_name = g_strndup((char *) event->cpi.system_name,
>> + sizeof(event->cpi.system_name)),
>> + .system_level = event->cpi.system_level,
>> + .sysplex_name = g_strndup((char *) event->cpi.sysplex_name,
>> + sizeof(event->cpi.sysplex_name)),
>> + .timestamp = event->cpi.timestamp
>> + };
>> +
>> + visit_type_S390ControlProgramId(v, name, &cpi, errp);
>> +}
>> +
>> static void cpi_class_init(ObjectClass *klass, void *data)
>> {
>> DeviceClass *dc = DEVICE_CLASS(klass);
>> @@ -114,6 +144,14 @@ static void cpi_class_init(ObjectClass *klass,
>> void *data)
>> k->get_send_mask = send_mask;
>> k->get_receive_mask = receive_mask;
>> k->write_event_data = write_event_data;
>> +
>> + object_class_property_add(klass, "control-program-id",
>> + "S390ControlProgramId",
>> + get_control_program_id,
>> + NULL, NULL, NULL);
>> + object_class_property_set_description(klass,
>> "control-program-id",
>> + "Control-program identifiers provide data about the guest "
>> + "operating system");
>> }
>>
>> static const TypeInfo sclp_cpi_info = {
>> diff --git a/include/hw/s390x/event-facility.h
>> b/include/hw/s390x/event-facility.h
>> index f445d2f9f5..39e589ed44 100644
>> --- a/include/hw/s390x/event-facility.h
>> +++ b/include/hw/s390x/event-facility.h
>> @@ -169,10 +169,19 @@ typedef struct ReadEventData {
>> };
>> } QEMU_PACKED ReadEventData;
>>
>> +typedef struct ControlProgramId {
>> + uint8_t system_type[8];
>> + uint8_t system_name[8];
>> + uint64_t system_level;
>> + uint8_t sysplex_name[8];
>> + uint64_t timestamp;
>> +} QEMU_PACKED ControlProgramId;
>> +
>> struct SCLPEvent {
>> DeviceState qdev;
>> bool event_pending;
>> char *name;
>> + ControlProgramId cpi;
>
> I don't think this should go into SCLPEvent.
> Rather SCLPEventFacility or SCLPDevice. Otherwise all events,
> so also quiesce and cpu_hotplug have a cpi field.
>
ok, that is correct.
I gave it a try by moving ControlProgramId to SCLPDevice. With this, the
migration data is stored in dc->vmsd of TYPE_SCLP as shown below.
diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
index 5945c9b1d8..4d6d5bb857 100644
--- a/hw/s390x/sclp.c
+++ b/hw/s390x/sclp.c
@@ -424,6 +424,29 @@ static void sclp_init(Object *obj)
sclp_memory_init(sclp);
}
+static const VMStateDescription vmstate_control_program_id = {
+ .name = "s390_control_program_id",
+ .version_id = 0,
+ .fields = (const VMStateField[]) {
+ VMSTATE_UINT8_ARRAY(system_type, ControlProgramId, 8),
+ VMSTATE_UINT8_ARRAY(system_name, ControlProgramId, 8),
+ VMSTATE_UINT64(system_level, ControlProgramId),
+ VMSTATE_UINT8_ARRAY(sysplex_name, ControlProgramId, 8),
+ VMSTATE_UINT64(timestamp, ControlProgramId),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
+static const VMStateDescription vmstate_sclpcpi = {
+ .name = "s390_sclpcpi",
+ .version_id = 0,
+ .fields = (const VMStateField[]) {
+ VMSTATE_STRUCT(cpi, SCLPDevice, 0, vmstate_control_program_id,
+ ControlProgramId),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
static void sclp_class_init(ObjectClass *oc, void *data)
{
SCLPDeviceClass *sc = SCLP_CLASS(oc);
@@ -438,6 +461,7 @@ static void sclp_class_init(ObjectClass *oc, void
*data)
* which is a non-pluggable sysbus device
*/
dc->user_creatable = false;
+ dc->vmsd = &vmstate_sclpcpi;
sc->read_SCP_info = read_SCP_info;
sc->read_cpu_info = sclp_read_cpu_info;
@Thomas Huth: Is this ok?, thank you.
>> };
>
> [...]
--
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
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH v3 2/4] hw/s390x: add Control-Program Identification to QOM
2025-04-03 14:33 Shalini Chellathurai Saroja
@ 2025-04-09 5:30 ` Thomas Huth
2025-04-10 9:30 ` Shalini Chellathurai Saroja
0 siblings, 1 reply; 19+ messages in thread
From: Thomas Huth @ 2025-04-09 5:30 UTC (permalink / raw)
To: Shalini Chellathurai Saroja, Nina Schoetterl-Glausch
Cc: qemu-s390x mailing list, Daniel Berrange, qemu-devel mailing list,
Hendrik Brueckner
On 03/04/2025 16.33, Shalini Chellathurai Saroja wrote:
> On 2025-04-01 15:55, Nina Schoetterl-Glausch wrote:
>> On Mon, 2025-03-31 at 16:00 +0200, Shalini Chellathurai Saroja wrote:
>>> Add Control-Program Identification data to the QEMU Object
>>> Model (QOM), along with the timestamp in which the data was received.
>>>
>>> Example:
>>> virsh # qemu-monitor-command vm --pretty '{
>>> "execute": "qom-get",
>>> "arguments": {
>>> "path": "/machine/sclp/s390-sclp-event-facility/sclpcpi",
>>> "property": "control-program-id" }}'
>>> {
>>> "return": {
>>> "timestamp": 1742390410685762000,
>>> "system-level": 74872343805430528,
>>> "sysplex-name": "PLEX ",
>>> "system-name": "TESTVM ",
>>> "system-type": "LINUX "
>>> },
>>> "id": "libvirt-15"
>>> }
>>>
>>> Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
>>> ---
>>> hw/s390x/sclpcpi.c | 38 ++++++++++++++++++++
>>> include/hw/s390x/event-facility.h | 9 +++++
>>> qapi/machine.json | 58 +++++++++++++++++++++++++++++++
>>> 3 files changed, 105 insertions(+)
>>>
>>> diff --git a/hw/s390x/sclpcpi.c b/hw/s390x/sclpcpi.c
>>> index 7ace5dd64e..969c15e43d 100644
>>> --- a/hw/s390x/sclpcpi.c
>>> +++ b/hw/s390x/sclpcpi.c
>>> @@ -57,8 +57,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 "qapi/qapi-visit-machine.h"
>>>
>>> typedef struct Data {
>>> uint8_t id_format;
>>> @@ -99,10 +102,37 @@ static int write_event_data(SCLPEvent *event,
>>> EventBufferHeader *evt_buf_hdr)
>>> ControlProgramIdMsg *cpim = container_of(evt_buf_hdr,
>>> ControlProgramIdMsg,
>>> ebh);
>>>
>>> + ascii_put(event->cpi.system_type, (char *)cpim->data.system_type, 8);
>>> + ascii_put(event->cpi.system_name, (char *)cpim->data.system_name, 8);
>>> + ascii_put(event->cpi.sysplex_name, (char *)cpim->data.sysplex_name, 8);
>>> + event->cpi.system_level = ldq_be_p(&cpim->data.system_level);
>>> + event->cpi.timestamp = qemu_clock_get_ns(QEMU_CLOCK_HOST);
>>> +
>>> cpim->ebh.flags = SCLP_EVENT_BUFFER_ACCEPTED;
>>> return SCLP_RC_NORMAL_COMPLETION;
>>> }
>>>
>>> +static void get_control_program_id(Object *obj, Visitor *v,
>>> + const char *name, void *opaque,
>>> + Error **errp)
>>> +{
>>> + SCLPEvent *event = (SCLPEvent *)(obj);
>>
>> Do a checked cast with SCLP_EVENT(obj).
>
> Hello Nina,
>
> ok, thank you.
>>
>>> + S390ControlProgramId *cpi;
>>> +
>>> + cpi = &(S390ControlProgramId){
>>> + .system_type = g_strndup((char *) event->cpi.system_type,
>>> + sizeof(event->cpi.system_type)),
>>> + .system_name = g_strndup((char *) event->cpi.system_name,
>>> + sizeof(event->cpi.system_name)),
>>> + .system_level = event->cpi.system_level,
>>> + .sysplex_name = g_strndup((char *) event->cpi.sysplex_name,
>>> + sizeof(event->cpi.sysplex_name)),
>>> + .timestamp = event->cpi.timestamp
>>> + };
>>> +
>>> + visit_type_S390ControlProgramId(v, name, &cpi, errp);
>>> +}
>>> +
>>> static void cpi_class_init(ObjectClass *klass, void *data)
>>> {
>>> DeviceClass *dc = DEVICE_CLASS(klass);
>>> @@ -114,6 +144,14 @@ static void cpi_class_init(ObjectClass *klass, void
>>> *data)
>>> k->get_send_mask = send_mask;
>>> k->get_receive_mask = receive_mask;
>>> k->write_event_data = write_event_data;
>>> +
>>> + object_class_property_add(klass, "control-program-id",
>>> + "S390ControlProgramId",
>>> + get_control_program_id,
>>> + NULL, NULL, NULL);
>>> + object_class_property_set_description(klass, "control-program-id",
>>> + "Control-program identifiers provide data about the guest "
>>> + "operating system");
>>> }
>>>
>>> static const TypeInfo sclp_cpi_info = {
>>> diff --git a/include/hw/s390x/event-facility.h b/include/hw/s390x/event-
>>> facility.h
>>> index f445d2f9f5..39e589ed44 100644
>>> --- a/include/hw/s390x/event-facility.h
>>> +++ b/include/hw/s390x/event-facility.h
>>> @@ -169,10 +169,19 @@ typedef struct ReadEventData {
>>> };
>>> } QEMU_PACKED ReadEventData;
>>>
>>> +typedef struct ControlProgramId {
>>> + uint8_t system_type[8];
>>> + uint8_t system_name[8];
>>> + uint64_t system_level;
>>> + uint8_t sysplex_name[8];
>>> + uint64_t timestamp;
>>> +} QEMU_PACKED ControlProgramId;
>>> +
>>> struct SCLPEvent {
>>> DeviceState qdev;
>>> bool event_pending;
>>> char *name;
>>> + ControlProgramId cpi;
>>
>> I don't think this should go into SCLPEvent.
>> Rather SCLPEventFacility or SCLPDevice. Otherwise all events,
>> so also quiesce and cpu_hotplug have a cpi field.
>>
> ok, that is correct.
>
> I gave it a try by moving ControlProgramId to SCLPDevice. With this, the
> migration data is stored in dc->vmsd of TYPE_SCLP as shown below.
>
> diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
> index 5945c9b1d8..4d6d5bb857 100644
> --- a/hw/s390x/sclp.c
> +++ b/hw/s390x/sclp.c
> @@ -424,6 +424,29 @@ static void sclp_init(Object *obj)
> sclp_memory_init(sclp);
> }
>
> +static const VMStateDescription vmstate_control_program_id = {
> + .name = "s390_control_program_id",
> + .version_id = 0,
> + .fields = (const VMStateField[]) {
> + VMSTATE_UINT8_ARRAY(system_type, ControlProgramId, 8),
> + VMSTATE_UINT8_ARRAY(system_name, ControlProgramId, 8),
> + VMSTATE_UINT64(system_level, ControlProgramId),
> + VMSTATE_UINT8_ARRAY(sysplex_name, ControlProgramId, 8),
> + VMSTATE_UINT64(timestamp, ControlProgramId),
> + VMSTATE_END_OF_LIST()
> + }
> +};
> +
> +static const VMStateDescription vmstate_sclpcpi = {
> + .name = "s390_sclpcpi",
> + .version_id = 0,
> + .fields = (const VMStateField[]) {
> + VMSTATE_STRUCT(cpi, SCLPDevice, 0, vmstate_control_program_id,
> + ControlProgramId),
> + VMSTATE_END_OF_LIST()
> + }
> +};
> +
> static void sclp_class_init(ObjectClass *oc, void *data)
> {
> SCLPDeviceClass *sc = SCLP_CLASS(oc);
> @@ -438,6 +461,7 @@ static void sclp_class_init(ObjectClass *oc, void *data)
> * which is a non-pluggable sysbus device
> */
> dc->user_creatable = false;
> + dc->vmsd = &vmstate_sclpcpi;
>
> sc->read_SCP_info = read_SCP_info;
> sc->read_cpu_info = sclp_read_cpu_info;
>
> @Thomas Huth: Is this ok?, thank you.
Hi,
that also does not look like the right place to me ... can't you move the
migration state to the TYPE_SCLP_CPI device instead?
Thomas
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH v3 2/4] hw/s390x: add Control-Program Identification to QOM
2025-04-09 5:30 ` Thomas Huth
@ 2025-04-10 9:30 ` Shalini Chellathurai Saroja
0 siblings, 0 replies; 19+ messages in thread
From: Shalini Chellathurai Saroja @ 2025-04-10 9:30 UTC (permalink / raw)
To: Thomas Huth
Cc: Nina Schoetterl-Glausch, qemu-s390x mailing list, Daniel Berrange,
qemu-devel mailing list, Hendrik Brueckner,
<Shalini Chellathurai Saroja
On 2025-04-09 07:30, Thomas Huth wrote:
> On 03/04/2025 16.33, Shalini Chellathurai Saroja wrote:
>> On 2025-04-01 15:55, Nina Schoetterl-Glausch wrote:
>>> On Mon, 2025-03-31 at 16:00 +0200, Shalini Chellathurai Saroja wrote:
>>>> Add Control-Program Identification data to the QEMU Object
>>>> Model (QOM), along with the timestamp in which the data was
>>>> received.
>>>>
>>>> Example:
>>>> virsh # qemu-monitor-command vm --pretty '{
>>>> "execute": "qom-get",
>>>> "arguments": {
>>>> "path": "/machine/sclp/s390-sclp-event-facility/sclpcpi",
>>>> "property": "control-program-id" }}'
>>>> {
>>>> "return": {
>>>> "timestamp": 1742390410685762000,
>>>> "system-level": 74872343805430528,
>>>> "sysplex-name": "PLEX ",
>>>> "system-name": "TESTVM ",
>>>> "system-type": "LINUX "
>>>> },
>>>> "id": "libvirt-15"
>>>> }
>>>>
>>>> Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
>>>> ---
>>>> hw/s390x/sclpcpi.c | 38 ++++++++++++++++++++
>>>> include/hw/s390x/event-facility.h | 9 +++++
>>>> qapi/machine.json | 58
>>>> +++++++++++++++++++++++++++++++
>>>> 3 files changed, 105 insertions(+)
>>>>
>>>> diff --git a/hw/s390x/sclpcpi.c b/hw/s390x/sclpcpi.c
>>>> index 7ace5dd64e..969c15e43d 100644
>>>> --- a/hw/s390x/sclpcpi.c
>>>> +++ b/hw/s390x/sclpcpi.c
>>>> @@ -57,8 +57,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 "qapi/qapi-visit-machine.h"
>>>>
>>>> typedef struct Data {
>>>> uint8_t id_format;
>>>> @@ -99,10 +102,37 @@ static int write_event_data(SCLPEvent *event,
>>>> EventBufferHeader *evt_buf_hdr)
>>>> ControlProgramIdMsg *cpim = container_of(evt_buf_hdr,
>>>> ControlProgramIdMsg,
>>>> ebh);
>>>>
>>>> + ascii_put(event->cpi.system_type, (char
>>>> *)cpim->data.system_type, 8);
>>>> + ascii_put(event->cpi.system_name, (char
>>>> *)cpim->data.system_name, 8);
>>>> + ascii_put(event->cpi.sysplex_name, (char
>>>> *)cpim->data.sysplex_name, 8);
>>>> + event->cpi.system_level = ldq_be_p(&cpim->data.system_level);
>>>> + event->cpi.timestamp = qemu_clock_get_ns(QEMU_CLOCK_HOST);
>>>> +
>>>> cpim->ebh.flags = SCLP_EVENT_BUFFER_ACCEPTED;
>>>> return SCLP_RC_NORMAL_COMPLETION;
>>>> }
>>>>
>>>> +static void get_control_program_id(Object *obj, Visitor *v,
>>>> + const char *name, void *opaque,
>>>> + Error **errp)
>>>> +{
>>>> + SCLPEvent *event = (SCLPEvent *)(obj);
>>>
>>> Do a checked cast with SCLP_EVENT(obj).
>>
>> Hello Nina,
>>
>> ok, thank you.
>>>
>>>> + S390ControlProgramId *cpi;
>>>> +
>>>> + cpi = &(S390ControlProgramId){
>>>> + .system_type = g_strndup((char *) event->cpi.system_type,
>>>> + sizeof(event->cpi.system_type)),
>>>> + .system_name = g_strndup((char *) event->cpi.system_name,
>>>> + sizeof(event->cpi.system_name)),
>>>> + .system_level = event->cpi.system_level,
>>>> + .sysplex_name = g_strndup((char *) event->cpi.sysplex_name,
>>>> + sizeof(event->cpi.sysplex_name)),
>>>> + .timestamp = event->cpi.timestamp
>>>> + };
>>>> +
>>>> + visit_type_S390ControlProgramId(v, name, &cpi, errp);
>>>> +}
>>>> +
>>>> static void cpi_class_init(ObjectClass *klass, void *data)
>>>> {
>>>> DeviceClass *dc = DEVICE_CLASS(klass);
>>>> @@ -114,6 +144,14 @@ static void cpi_class_init(ObjectClass *klass,
>>>> void *data)
>>>> k->get_send_mask = send_mask;
>>>> k->get_receive_mask = receive_mask;
>>>> k->write_event_data = write_event_data;
>>>> +
>>>> + object_class_property_add(klass, "control-program-id",
>>>> + "S390ControlProgramId",
>>>> + get_control_program_id,
>>>> + NULL, NULL, NULL);
>>>> + object_class_property_set_description(klass,
>>>> "control-program-id",
>>>> + "Control-program identifiers provide data about the guest "
>>>> + "operating system");
>>>> }
>>>>
>>>> static const TypeInfo sclp_cpi_info = {
>>>> diff --git a/include/hw/s390x/event-facility.h
>>>> b/include/hw/s390x/event- facility.h
>>>> index f445d2f9f5..39e589ed44 100644
>>>> --- a/include/hw/s390x/event-facility.h
>>>> +++ b/include/hw/s390x/event-facility.h
>>>> @@ -169,10 +169,19 @@ typedef struct ReadEventData {
>>>> };
>>>> } QEMU_PACKED ReadEventData;
>>>>
>>>> +typedef struct ControlProgramId {
>>>> + uint8_t system_type[8];
>>>> + uint8_t system_name[8];
>>>> + uint64_t system_level;
>>>> + uint8_t sysplex_name[8];
>>>> + uint64_t timestamp;
>>>> +} QEMU_PACKED ControlProgramId;
>>>> +
>>>> struct SCLPEvent {
>>>> DeviceState qdev;
>>>> bool event_pending;
>>>> char *name;
>>>> + ControlProgramId cpi;
>>>
>>> I don't think this should go into SCLPEvent.
>>> Rather SCLPEventFacility or SCLPDevice. Otherwise all events,
>>> so also quiesce and cpu_hotplug have a cpi field.
>>>
>> ok, that is correct.
>>
>> I gave it a try by moving ControlProgramId to SCLPDevice. With this,
>> the migration data is stored in dc->vmsd of TYPE_SCLP as shown below.
>>
>> diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
>> index 5945c9b1d8..4d6d5bb857 100644
>> --- a/hw/s390x/sclp.c
>> +++ b/hw/s390x/sclp.c
>> @@ -424,6 +424,29 @@ static void sclp_init(Object *obj)
>> sclp_memory_init(sclp);
>> }
>>
>> +static const VMStateDescription vmstate_control_program_id = {
>> + .name = "s390_control_program_id",
>> + .version_id = 0,
>> + .fields = (const VMStateField[]) {
>> + VMSTATE_UINT8_ARRAY(system_type, ControlProgramId, 8),
>> + VMSTATE_UINT8_ARRAY(system_name, ControlProgramId, 8),
>> + VMSTATE_UINT64(system_level, ControlProgramId),
>> + VMSTATE_UINT8_ARRAY(sysplex_name, ControlProgramId, 8),
>> + VMSTATE_UINT64(timestamp, ControlProgramId),
>> + VMSTATE_END_OF_LIST()
>> + }
>> +};
>> +
>> +static const VMStateDescription vmstate_sclpcpi = {
>> + .name = "s390_sclpcpi",
>> + .version_id = 0,
>> + .fields = (const VMStateField[]) {
>> + VMSTATE_STRUCT(cpi, SCLPDevice, 0,
>> vmstate_control_program_id,
>> + ControlProgramId),
>> + VMSTATE_END_OF_LIST()
>> + }
>> +};
>> +
>> static void sclp_class_init(ObjectClass *oc, void *data)
>> {
>> SCLPDeviceClass *sc = SCLP_CLASS(oc);
>> @@ -438,6 +461,7 @@ static void sclp_class_init(ObjectClass *oc, void
>> *data)
>> * which is a non-pluggable sysbus device
>> */
>> dc->user_creatable = false;
>> + dc->vmsd = &vmstate_sclpcpi;
>>
>> sc->read_SCP_info = read_SCP_info;
>> sc->read_cpu_info = sclp_read_cpu_info;
>>
>> @Thomas Huth: Is this ok?, thank you.
>
> Hi,
>
> that also does not look like the right place to me ... can't you move
> the migration state to the TYPE_SCLP_CPI device instead?
>
Hi Thomas,
I will do so, thank you.
> Thomas
--
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
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2025-04-10 9:31 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-31 14:00 [PATCH v3 0/4] *** Add SCLP event type CPI *** Shalini Chellathurai Saroja
2025-03-31 14:00 ` [PATCH v3 1/4] hw/s390x: add SCLP event type CPI Shalini Chellathurai Saroja
2025-04-02 5:48 ` Thomas Huth
2025-04-02 7:54 ` Shalini Chellathurai Saroja
2025-03-31 14:00 ` [PATCH v3 2/4] hw/s390x: add Control-Program Identification to QOM Shalini Chellathurai Saroja
2025-04-01 13:55 ` Nina Schoetterl-Glausch
2025-04-02 5:58 ` Thomas Huth
2025-03-31 14:00 ` [PATCH v3 3/4] hw/s390x: support migration of CPI data Shalini Chellathurai Saroja
2025-04-02 6:05 ` Thomas Huth
2025-04-02 9:12 ` Shalini Chellathurai Saroja
2025-03-31 14:00 ` [PATCH v3 4/4] hw/s390x: compat handling for backward migration Shalini Chellathurai Saroja
2025-04-02 7:52 ` Thomas Huth
2025-04-03 12:49 ` Shalini Chellathurai Saroja
2025-04-09 5:49 ` Thomas Huth
2025-04-09 14:13 ` Shalini Chellathurai Saroja
-- strict thread matches above, loose matches on Subject: below --
2025-04-02 9:06 [PATCH v3 2/4] hw/s390x: add Control-Program Identification to QOM Shalini Chellathurai Saroja
2025-04-03 14:33 Shalini Chellathurai Saroja
2025-04-09 5:30 ` Thomas Huth
2025-04-10 9:30 ` Shalini Chellathurai Saroja
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).