Add SCLP event type CPI
v4 cover Add SCLP event type CPI
Implement the Service-Call Logical Processor (SCLP) event type Control-Program Identification (CPI) in QEMU.
Changed since v3:
- Add QOM object sclpcpi from ccw_init()
- Add SCLPEventCPI state to store the CPI data in the sclpcpi device
- Other minor changes
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 | 2 + hw/s390x/meson.build | 1 + hw/s390x/s390-virtio-ccw.c | 22 ++++ hw/s390x/sclpcpi.c | 156 +++++++++++++++++++++++++++++ include/hw/s390x/event-facility.h | 22 ++++ include/hw/s390x/s390-virtio-ccw.h | 1 + qapi/machine.json | 58 +++++++++++ 7 files changed, 262 insertions(+) create mode 100644 hw/s390x/sclpcpi.c
Signature · 1 line
2.49.0
PATCH v4 1/4 hw/s390x: add SCLP event type CPI
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").
--- hw/s390x/event-facility.c | 2 + hw/s390x/meson.build | 1 + hw/s390x/s390-virtio-ccw.c | 14 +++++ hw/s390x/sclpcpi.c | 92 +++++++++++++++++++++++++++++++ include/hw/s390x/event-facility.h | 13 +++++ 5 files changed, 122 insertions(+) create mode 100644 hw/s390x/sclpcpi.c
hw/s390x/event-facility.c +2 -0
@@ -4,6 +4,7 @@* handles SCLP event types * - Signal Quiesce - system power down * - ASCII Console Data - VT220 read and write +* - Control-Program Identification - Send OS data from guest to host * * Copyright IBM, Corp. 2012 *
@@ -40,6 +41,7 @@ struct SCLPEventFacility {SysBusDevice parent_obj;SCLPEventsBus sbus;SCLPEvent quiesce, cpu_hotplug; +SCLPEventCPI cpi;/* guest's receive mask */ union {uint32_t receive_mask_pieces[2 ];
hw/s390x/meson.build +1 -0
@@ -13,6 +13,7 @@ s390x_ss.add(files( 's390-skeys.c', 's390-stattrib.c', 'sclp.c', + 'sclpcpi.c', 'sclpcpu.c', 'sclpquiesce.c', 'tod.c',
hw/s390x/s390-virtio-ccw.c +14 -0
@@ -260,6 +260,17 @@ 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; +BusState *ev_fac_bus =sclp_get_event_facility_bus (ef); +DeviceState *dev; + + dev =qdev_new (TYPE_SCLP_EVENT_CPI ); +object_property_add_child (OBJECT (ef),"sclpcpi" ,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 +334,9 @@ 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,
hw/s390x/sclpcpi.c new file +92 -0
92 lines not on this page · raw message
include/hw/s390x/event-facility.h +13 -0
@@ -25,6 +25,7 @@#define SCLP_EVENT_MESSAGE 0x02#define SCLP_EVENT_CONFIG_MGT_DATA 0x04#define SCLP_EVENT_PMSGCMD 0x09 +#define SCLP_EVENT_CTRL_PGM_ID 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_CTRL_PGM_ID SCLP_EVMASK(SCLP_EVENT_CTRL_PGM_ID)#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)
@@ -191,6 +193,17 @@ struct SCLPEventClass {bool (*can_handle_event)(uint8_t type); }; +#define TYPE_SCLP_EVENT_CPI "sclpcpi" +typedef struct SCLPEventCPIClass SCLPEventCPIClass ; +typedef struct SCLPEventCPI SCLPEventCPI ; +OBJECT_DECLARE_TYPE (SCLPEventCPI, SCLPEventCPIClass, + SCLP_EVENT_CPI) + +struct SCLPEventCPI { +DeviceState qdev; +SCLPEvent event; +}; +#define TYPE_SCLP_EVENT_FACILITY "s390-sclp-event-facility"typedef struct SCLPEventFacility SCLPEventFacility ;typedef struct SCLPEventFacilityClass SCLPEventFacilityClass ;
Signature · 1 line
2.49.0
Re: [PATCH v4 1/4] hw/s390x: add SCLP event type CPI
Quoted 63 lines · 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 <[email protected]>Reviewed-by Thomas Huth <[email protected]>--- hw/s390x/event-facility.c | 2 + hw/s390x/meson.build | 1 + hw/s390x/s390-virtio-ccw.c | 14 +++++ hw/s390x/sclpcpi.c | 92 +++++++++++++++++++++++++++++++ include/hw/s390x/event-facility.h | 13 +++++ 5 files changed, 122 insertions(+) create mode 100644 hw/s390x/sclpcpi.chw/s390x/event-facility.c +2
-0@@ -4,6 +4,7 @@* handles SCLP event types * - Signal Quiesce - system power down * - ASCII Console Data - VT220 read and write +* - Control-Program Identification - Send OS data from guest to host * * Copyright IBM, Corp. 2012 * @@ -40,6 +41,7 @@ struct SCLPEventFacility {SysBusDevice parent_obj;SCLPEventsBus sbus;SCLPEvent quiesce, cpu_hotplug; +SCLPEventCPI cpi;/* guest's receive mask */ union {uint32_t receive_mask_pieces[2 ];hw/s390x/meson.build +1
-0@@ -13,6 +13,7 @@ s390x_ss.add(files( 's390-skeys.c', 's390-stattrib.c', 'sclp.c', + 'sclpcpi.c', 'sclpcpu.c', 'sclpquiesce.c', 'tod.c',hw/s390x/s390-virtio-ccw.c +0
-0@@ -260,6 +260,17 @@ static void s390_create_sclpconsole(SCLPDevice *sclp,qdev_realize_and_unref (dev, ev_fac_bus, &error_fatal); }
hw/s390x/s390-virtio-ccw.c static void s390_create_sclpconsole(SCLPDevice *sclp, · line 271
Quoted 10 lines
hw/s390x/s390-virtio-ccw.c +9
-0+static void s390_create_sclpcpi (SCLPDevice *sclp) +{ +SCLPEventFacility *ef = sclp->event_facility; +BusState *ev_fac_bus =sclp_get_event_facility_bus (ef); +DeviceState *dev; + + dev =qdev_new (TYPE_SCLP_EVENT_CPI ); +object_property_add_child (OBJECT (ef),"sclpcpi" ,OBJECT (dev)); +qdev_realize_and_unref (dev, ev_fac_bus, &error_fatal);
I wonder if we should drop this and add control-program-id directly on the event facility. I don't see what purpose having the intermediate level sclpcpi serves.
Quoted 1 line
hw/s390x/s390-virtio-ccw.c +1
-0+}
[...]
include/hw/s390x/event-facility.h
Quoted 4 lines
include/hw/s390x/event-facility.h +0
-0
[...]
I.
include/hw/s390x/event-facility.h struct SCLPEventClass { · line 204
Quoted 3 lines
include/hw/s390x/event-facility.h +3
-0+struct SCLPEventCPI { +DeviceState qdev; +SCLPEvent event;
I think you should just inherit from SCLPEvent, which in turn inherits from DeviceState. So without the qdev.
Quoted 5 lines
include/hw/s390x/event-facility.h +2
-0+}; +#define TYPE_SCLP_EVENT_FACILITY "s390-sclp-event-facility"typedef struct SCLPEventFacility SCLPEventFacility ;typedef struct SCLPEventFacilityClass SCLPEventFacilityClass ;
Signature · 2 lines
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
Re: [PATCH v4 1/4] hw/s390x: add SCLP event type CPI
In reply to Shalini Chellathurai SarojaQuoted 23 lines · 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 <[email protected]>Reviewed-by Thomas Huth <[email protected]>--- hw/s390x/event-facility.c | 2 + hw/s390x/meson.build | 1 + hw/s390x/s390-virtio-ccw.c | 14 +++++ hw/s390x/sclpcpi.c | 92 +++++++++++++++++++++++++++++++ include/hw/s390x/event-facility.h | 13 +++++ 5 files changed, 122 insertions(+) create mode 100644 hw/s390x/sclpcpi.c
[...]
Quoted 6 lines
static void s390_cpu_plug(HotplugHandler
*hotplug_dev,hw/s390x/sclpcpi.c new file +0
-0
[...]
Quoted 1 line
+static void
cpi_class_init(ObjectClass *klass, void *data)
Should be 'const void *data'.
Quoted 11 lines
hw/s390x/sclpcpi.c new file +11
-0+{ +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; +}
[...]
Signature · 4 lines
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
Re: [PATCH v4 1/4] hw/s390x: add SCLP event type CPI
Quoted 38 lines · Nina Schoetterl-Glausch
Quoted 24 lines · 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 <[email protected]>Reviewed-by Thomas Huth <[email protected]>--- hw/s390x/event-facility.c | 2 + hw/s390x/meson.build | 1 + hw/s390x/s390-virtio-ccw.c | 14 +++++ hw/s390x/sclpcpi.c | 92 +++++++++++++++++++++++++++++++ include/hw/s390x/event-facility.h | 13 +++++ 5 files changed, 122 insertions(+) create mode 100644 hw/s390x/sclpcpi.c[...]
Quoted 6 lines
static void s390_cpu_plug(HotplugHandler
*hotplug_dev,hw/s390x/sclpcpi.c new file +0
-0[...]
Quoted 4 lines
Quoted 1 line
+static void
cpi_class_init(ObjectClass *klass, void *data)Should be 'const void *data'.
Ok, thank you.
Quoted 13 lines
Quoted 11 lines
hw/s390x/sclpcpi.c new file +11
-0+{ +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; +}[...]
Signature · 9 lines
Mit freundlichen Grüßen / Kind regards Shalini Chellathurai Saroja Software Developer Linux on IBM Z & KVM Development IBM Deutschland Research & Development GmbH Dept 1419, Schoenaicher Str. 220, 71032 Boeblingen Vorsitzender des Aufsichtsrats: Wolfgang Wendt Geschäftsführung: David Faller Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294
PATCH v4 2/4 hw/s390x: add Control-Program Identification to QOM
In reply to Shalini Chellathurai SarojaAdd 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"
}
--- hw/s390x/sclpcpi.c | 39 +++++++++++++++++++++ include/hw/s390x/event-facility.h | 9 +++++ qapi/machine.json | 58 +++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+)
hw/s390x/sclpcpi.c +39 -0
@@ -18,7 +18,10 @@*/ #include "qemu/osdep.h" +#include "qemu/timer.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;
@@ -58,11 +61,39 @@ static int write_event_data(SCLPEvent *event, EventBufferHeader *evt_buf_hdr) {ControlProgramIdMsg *cpim =container_of (evt_buf_hdr, ControlProgramIdMsg, ebh); +SCLPEventCPI *e =SCLP_EVENT_CPI (event); + +ascii_put (e->cpi.system_type, (char *)cpim->data.system_type,8 ); +ascii_put (e->cpi.system_name, (char *)cpim->data.system_name,8 ); +ascii_put (e->cpi.sysplex_name, (char *)cpim->data.sysplex_name,8 ); + e->cpi.system_level =ldq_be_p (&cpim->data.system_level); + e->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) +{ +SCLPEventCPI *e =SCLP_EVENT_CPI (obj); +S390ControlProgramId *cpi; + + cpi = &(S390ControlProgramId ){ + .system_type =g_strndup ((char *) e->cpi.system_type, +sizeof (e->cpi.system_type)), + .system_name =g_strndup ((char *) e->cpi.system_name, +sizeof (e->cpi.system_name)), + .system_level = e->cpi.system_level, + .sysplex_name =g_strndup ((char *) e->cpi.sysplex_name, +sizeof (e->cpi.sysplex_name)), + .timestamp = e->cpi.timestamp + }; + +visit_type_S390ControlProgramId (v, name, &cpi, errp); +} +static void cpi_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);
@@ -74,6 +105,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 = {
include/hw/s390x/event-facility.h +9 -0
@@ -199,9 +199,18 @@ typedef struct SCLPEventCPI SCLPEventCPI;OBJECT_DECLARE_TYPE (SCLPEventCPI, SCLPEventCPIClass, SCLP_EVENT_CPI) +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; +}ControlProgramId ; +struct SCLPEventCPI {DeviceState qdev;SCLPEvent event; +ControlProgramId cpi; };#define TYPE_SCLP_EVENT_FACILITY "s390-sclp-event-facility"
qapi/machine.json +58 -0
61 lines not on this page · raw message
Signature · 1 line
2.49.0
Re: [PATCH v4 2/4] hw/s390x: add Control-Program Identification to QOM
Quoted 26 lines · 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 <[email protected]>--- hw/s390x/sclpcpi.c | 39 +++++++++++++++++++++ include/hw/s390x/event-facility.h | 9 +++++ qapi/machine.json | 58 +++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+)
[...]
Quoted 8 lines
include/hw/s390x/event-facility.h +2
-0@@ -199,9 +199,18 @@ typedef struct SCLPEventCPI SCLPEventCPI;OBJECT_DECLARE_TYPE (SCLPEventCPI, SCLPEventCPIClass, SCLP_EVENT_CPI) +typedef struct ControlProgramId { + uint8_t system_type[8];
include/hw/s390x/event-facility.h typedef struct SCLPEventCPI SCLPEventCPI; · line 213
Quoted 10 lines
include/hw/s390x/event-facility.h +7
-0+uint8_t system_name[8 ]; +uint64_t system_level; +uint8_t sysplex_name[8 ]; +uint64_t timestamp; +} ControlProgramId; +struct SCLPEventCPI {DeviceState qdev;SCLPEvent event; +ControlProgramId cpi;
Now that this struct exists I would go ahead and inline ControlProgramId.
Quoted 3 lines
include/hw/s390x/event-facility.h +0
-0};#define TYPE_SCLP_EVENT_FACILITY "s390-sclp-event-facility"
[...]
Signature · 4 lines
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
Re: [PATCH v4 2/4] hw/s390x: add Control-Program Identification to QOM
Quoted 37 lines · Nina Schoetterl-Glausch
Quoted 27 lines · 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 <[email protected]>--- hw/s390x/sclpcpi.c | 39 +++++++++++++++++++++ include/hw/s390x/event-facility.h | 9 +++++ qapi/machine.json | 58 +++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+)[...]
Quoted 6 lines
include/hw/s390x/event-facility.h +0
-0@@ -199,9 +199,18 @@ typedef struct SCLPEventCPI SCLPEventCPI;OBJECT_DECLARE_TYPE (SCLPEventCPI, SCLPEventCPIClass,SCLP_EVENT_CPI )
Quoted 14 lines
include/hw/s390x/event-facility.h typedef struct SCLPEventCPI SCLPEventCPI; · line 213
Quoted 12 lines
include/hw/s390x/event-facility.h +9
-0+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; +}ControlProgramId ; +struct SCLPEventCPI {DeviceState qdev;SCLPEvent event; +ControlProgramId cpi;Now that this struct exists I would go ahead and inline ControlProgramId.
Ok, I will do so, thank you.
Quoted 6 lines
Quoted 4 lines
include/hw/s390x/event-facility.h +0
-0};#define TYPE_SCLP_EVENT_FACILITY "s390-sclp-event-facility"[...]
Signature · 9 lines
Mit freundlichen Grüßen / Kind regards Shalini Chellathurai Saroja Software Developer Linux on IBM Z & KVM Development IBM Deutschland Research & Development GmbH Dept 1419, Schoenaicher Str. 220, 71032 Boeblingen Vorsitzender des Aufsichtsrats: Wolfgang Wendt Geschäftsführung: David Faller Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294
Re: [PATCH v4 2/4] hw/s390x: add Control-Program Identification to QOM
In reply to Shalini Chellathurai SarojaQuoted 2 lines · Shalini Chellathurai Saroja
Add Control-Program Identification data to the QEMU Object Model (QOM), along with the timestamp in which the data was received.
...
Quoted 16 lines
hw/s390x/sclpcpi.c +3
-0@@ -18,7 +18,10 @@*/ #include "qemu/osdep.h" +#include "qemu/timer.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;
hw/s390x/sclpcpi.c static int write_event_data(SCLPEvent *event, EventBufferHeader *evt_buf_hdr) · line 68
Quoted 8 lines
hw/s390x/sclpcpi.c +5
-0@@ -58,11 +61,39 @@ static int write_event_data(SCLPEvent *event, EventBufferHeader *evt_buf_hdr) {ControlProgramIdMsg *cpim =container_of (evt_buf_hdr, ControlProgramIdMsg, ebh); +SCLPEventCPI *e =SCLP_EVENT_CPI (event); + +ascii_put (e->cpi.system_type, (char *)cpim->data.system_type,8 ); +ascii_put (e->cpi.system_name, (char *)cpim->data.system_name,8 ); +ascii_put (e->cpi.sysplex_name, (char *)cpim->data.sysplex_name,8 );
Would it be possible to use sizeof() instead of hard-coding "8" here?
Thanks,
Thomas
Re: [PATCH v4 2/4] hw/s390x: add Control-Program Identification to QOM
Quoted 23 lines · Thomas Huth
Quoted 2 lines · Shalini Chellathurai Saroja
Add Control-Program Identification data to the QEMU Object Model (QOM), along with the timestamp in which the data was received.
...
Quoted 19 lines
hw/s390x/sclpcpi.c +3
-0@@ -18,7 +18,10 @@*/ #include "qemu/osdep.h" +#include "qemu/timer.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;@@ -58,11 +61,39 @@ static int write_event_data(SCLPEvent *event, EventBufferHeader *evt_buf_hdr) {ControlProgramIdMsg *cpim =container_of (evt_buf_hdr, ControlProgramIdMsg, ebh);
Quoted 8 lines
hw/s390x/sclpcpi.c static int write_event_data(SCLPEvent *event, EventBufferHeader *evt_buf_hdr)
Quoted 6 lines
hw/s390x/sclpcpi.c +5
-0+SCLPEventCPI *e =SCLP_EVENT_CPI (event); + +ascii_put (e->cpi.system_type, (char *)cpim->data.system_type,8 ); +ascii_put (e->cpi.system_name, (char *)cpim->data.system_name,8 ); +ascii_put (e->cpi.sysplex_name, (char *)cpim->data.sysplex_name,8 );Would it be possible to use
sizeof()instead of hard-coding "8" here?
Hello Thomas,
Yes, it is. I will do so. Thank you very much for the review.
I will also move the property use_cpi to ccw_machine_10_0_class_options, as version 10.0 is already released.
Quoted 3 lines
Thanks,
Thomas
Signature · 9 lines
Mit freundlichen Grüßen / Kind regards Shalini Chellathurai Saroja Software Developer Linux on IBM Z & KVM Development IBM Deutschland Research & Development GmbH Dept 1419, Schoenaicher Str. 220, 71032 Boeblingen Vorsitzender des Aufsichtsrats: Wolfgang Wendt Geschäftsführung: David Faller Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294
PATCH v4 3/4 hw/s390x: support migration of CPI data
In reply to Shalini Chellathurai SarojaRegister Control-Program Identification data with the live migration infrastructure.
--- hw/s390x/sclpcpi.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
hw/s390x/sclpcpi.c +25 -0
@@ -22,6 +22,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;
@@ -94,12 +95,36 @@ 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 , + .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, SCLPEventCPI,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;
Signature · 1 line
2.49.0
PATCH v4 4/4 hw/s390x: compat handling for backward migration
In reply to Shalini Chellathurai SarojaAdd 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.
--- hw/s390x/s390-virtio-ccw.c | 10 +++++++++- include/hw/s390x/s390-virtio-ccw.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-)
hw/s390x/s390-virtio-ccw.c +9 -1
@@ -274,6 +274,7 @@ static void s390_create_sclpcpi(SCLPDevice *sclp)static void ccw_init (MachineState *machine) {MachineClass *mc =MACHINE_GET_CLASS (machine); +S390CcwMachineClass *s390mc =S390_CCW_MACHINE_CLASS (mc);S390CcwMachineState *ms =S390_CCW_MACHINE (machine);int ret;VirtualCssBus *css_bus;
@@ -336,7 +337,10 @@ static void ccw_init(MachineState *machine)s390_init_tod ();/* init SCLP event Control-Program Identification */ -s390_create_sclpcpi (ms->sclp); +if (s390mc->use_cpi) { +s390_create_sclpcpi (ms->sclp); + } + } static void s390_cpu_plug(HotplugHandler *hotplug_dev,
@@ -827,6 +831,7 @@ static void ccw_machine_class_init(ObjectClass *oc, void *data) s390mc->hpage_1m_allowed = true; s390mc->max_threads =1 ; + s390mc->use_cpi = true; mc->reset = s390_machine_reset; mc->block_default_type =IF_VIRTIO ; mc->no_cdrom =1 ;
@@ -955,6 +960,9 @@ static void ccw_machine_9_2_class_options(MachineClass *mc) { TYPE_S390_PCI_DEVICE, "relaxed-translation", "off", }, }; + S390CcwMachineClass *s390mc =S390_CCW_MACHINE_CLASS (mc); + s390mc->use_cpi = false; +ccw_machine_10_0_class_options (mc);compat_props_add (mc->compat_props, hw_compat_9_2, hw_compat_9_2_len);compat_props_add (mc->compat_props, compat,G_N_ELEMENTS (compat));
include/hw/s390x/s390-virtio-ccw.h +1 -0
@@ -55,6 +55,7 @@ struct S390CcwMachineClass {/*< public >*/ bool hpage_1m_allowed;int max_threads; +bool use_cpi; };/* 1M huge page mappings allowed by the machine */
Signature · 1 line
2.49.0
Re: [PATCH v4 4/4] hw/s390x: compat handling for backward migration
Quoted 23 lines · 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 <[email protected]>--- hw/s390x/s390-virtio-ccw.c | 10 +++++++++- include/hw/s390x/s390-virtio-ccw.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-)hw/s390x/s390-virtio-ccw.c +1
-0@@ -274,6 +274,7 @@ static void s390_create_sclpcpi(SCLPDevice *sclp)static void ccw_init (MachineState *machine) {MachineClass *mc =MACHINE_GET_CLASS (machine); +S390CcwMachineClass *s390mc =S390_CCW_MACHINE_CLASS (mc);S390CcwMachineState *ms =S390_CCW_MACHINE (machine);int ret;VirtualCssBus *css_bus;
hw/s390x/s390-virtio-ccw.c static void ccw_init(MachineState *machine) · line 342
Quoted 7 lines
hw/s390x/s390-virtio-ccw.c +3
-1@@ -336,7 +337,10 @@ static void ccw_init(MachineState *machine)s390_init_tod ();/* init SCLP event Control-Program Identification */ -s390_create_sclpcpi (ms->sclp); +if (s390mc->use_cpi) { +s390_create_sclpcpi (ms->sclp); + }
Fixing this in a separate commit could be bad for bisecting. You introduce use_cpi in an earlier commit set to false and then flipping it in the migration patch for new machines. This way there is no broken intermediate state.
I would also squash the compat migration changes into the previous patch.
Quoted 33 lines
hw/s390x/s390-virtio-ccw.c +4
-0} static void s390_cpu_plug(HotplugHandler *hotplug_dev,@@ -827,6 +831,7 @@ static void ccw_machine_class_init(ObjectClass *oc, void *data) s390mc->hpage_1m_allowed = true; s390mc->max_threads =1 ; + s390mc->use_cpi = true; mc->reset = s390_machine_reset; mc->block_default_type =IF_VIRTIO ; mc->no_cdrom =1 ;@@ -955,6 +960,9 @@ static void ccw_machine_9_2_class_options(MachineClass *mc) { TYPE_S390_PCI_DEVICE, "relaxed-translation", "off", }, }; + S390CcwMachineClass *s390mc =S390_CCW_MACHINE_CLASS (mc); + s390mc->use_cpi = false; +ccw_machine_10_0_class_options (mc);compat_props_add (mc->compat_props, hw_compat_9_2, hw_compat_9_2_len);compat_props_add (mc->compat_props, compat,G_N_ELEMENTS (compat));include/hw/s390x/s390-virtio-ccw.h +1
-0@@ -55,6 +55,7 @@ struct S390CcwMachineClass {/*< public >*/ bool hpage_1m_allowed;int max_threads; +bool use_cpi; };/* 1M huge page mappings allowed by the machine */
Signature · 4 lines
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
Re: [PATCH v4 4/4] hw/s390x: compat handling for backward migration
Quoted 26 lines · Nina Schoetterl-Glausch
Quoted 25 lines · 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 <[email protected]>--- hw/s390x/s390-virtio-ccw.c | 10 +++++++++- include/hw/s390x/s390-virtio-ccw.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-)hw/s390x/s390-virtio-ccw.c +1
-0@@ -274,6 +274,7 @@ static void s390_create_sclpcpi(SCLPDevice *sclp)static void ccw_init (MachineState *machine) {MachineClass *mc =MACHINE_GET_CLASS (machine); +S390CcwMachineClass *s390mc =S390_CCW_MACHINE_CLASS (mc);S390CcwMachineState *ms =S390_CCW_MACHINE (machine);int ret;VirtualCssBus *css_bus;@@ -336,7 +337,10 @@ static void ccw_init(MachineState *machine)s390_init_tod ();
Quoted 7 lines
hw/s390x/s390-virtio-ccw.c static void ccw_init(MachineState *machine) · line 342
Quoted 5 lines
hw/s390x/s390-virtio-ccw.c +3
-1/* init SCLP event Control-Program Identification */ -s390_create_sclpcpi (ms->sclp); +if (s390mc->use_cpi) { +s390_create_sclpcpi (ms->sclp); + }Fixing this in a separate commit could be bad for bisecting.
Ok.
Quoted 7 lines
You introduce
use_cpiin an earlier commit set to false and then flipping it in the migration patch for new machines. This way there is no broken intermediate state.I would also squash the compat migration changes into the previous patch.
Hello Nina,
If use_cpi is set to false in patch 1, then the sclpcpi device will not be instantiated even for new machines at that point. The sclpcpi device will only be instantiated when the use_cpi is set to true in the migration patch.
I prefer to squash this entire patch to patch 1, then the sclpcpi device will only be instantiated for new machines with the code in patch 1 itself and will not be dependent on the migration patch. I like this approach as the logic to add sclpcpi device is complete in patch 1.
What do you think?, thank you.
Quoted 36 lines
Quoted 36 lines
hw/s390x/s390-virtio-ccw.c +1
-0} static void s390_cpu_plug(HotplugHandler *hotplug_dev,@@ -827,6 +831,7 @@ static void ccw_machine_class_init(ObjectClass *oc, void *data) s390mc->hpage_1m_allowed = true; s390mc->max_threads =1 ; + s390mc->use_cpi = true; mc->reset = s390_machine_reset; mc->block_default_type =IF_VIRTIO ;mc->no_cdrom = 1;hw/s390x/s390-virtio-ccw.c +3
-0@@ -955,6 +960,9 @@ static void ccw_machine_9_2_class_options(MachineClass *mc) { TYPE_S390_PCI_DEVICE, "relaxed-translation", "off", }, }; + S390CcwMachineClass *s390mc =S390_CCW_MACHINE_CLASS (mc); + s390mc->use_cpi = false; +ccw_machine_10_0_class_options (mc); compat_props_add(mc->compat_props, hw_compat_9_2,hw_compat_9_2_len); compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));include/hw/s390x/s390-virtio-ccw.h +1
-0@@ -55,6 +55,7 @@ struct S390CcwMachineClass {/*< public >*/ bool hpage_1m_allowed;int max_threads; +bool use_cpi; };/* 1M huge page mappings allowed by the machine */
Signature · 9 lines
Mit freundlichen Grüßen / Kind regards Shalini Chellathurai Saroja Software Developer Linux on IBM Z & KVM Development IBM Deutschland Research & Development GmbH Dept 1419, Schoenaicher Str. 220, 71032 Boeblingen Vorsitzender des Aufsichtsrats: Wolfgang Wendt Geschäftsführung: David Faller Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294
Re: [PATCH v4 4/4] hw/s390x: compat handling for backward migration
Quoted 18 lines · Shalini Chellathurai Saroja
Quoted 17 lines · Nina Schoetterl-Glausch
Quoted 16 lines · 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 <[email protected]>--- hw/s390x/s390-virtio-ccw.c | 10 +++++++++- include/hw/s390x/s390-virtio-ccw.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-)hw/s390x/s390-virtio-ccw.c +0
-0
[...]
Quoted 19 lines
Quoted 1 line
Fixing this in a separate commit could be bad for bisecting.
Ok.
Quoted 7 lines
You introduce
use_cpiin an earlier commit set to false and then flipping it in the migration patch for new machines. This way there is no broken intermediate state.I would also squash the compat migration changes into the previous patch.
Hello Nina,
If
use_cpiis set to false in patch 1, then the sclpcpi device will not be instantiated even for new machines at that point. The sclpcpi device will only be instantiated when theuse_cpiis set to true in the migration patch.
Quoted 6 lines
I prefer to squash this entire patch to patch 1, then the sclpcpi device will only be instantiated for new machines with the code in patch 1 itself and will not be dependent on the migration patch. I like this approach as the logic to add sclpcpi device is complete in patch 1.
What do you think?, thank you.
Sounds good!
[...]
Signature · 4 lines
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