[PATCH v3 3/4] hw/s390x: support migration of CPI data

Shalini Chellathurai Saroja posted 4 patches 7 months, 2 weeks ago
[PATCH v3 3/4] hw/s390x: support migration of CPI data
Posted by Shalini Chellathurai Saroja 7 months, 2 weeks ago
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
Re: [PATCH v3 3/4] hw/s390x: support migration of CPI data
Posted by Thomas Huth 7 months, 2 weeks ago
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
Re: [PATCH v3 3/4] hw/s390x: support migration of CPI data
Posted by Shalini Chellathurai Saroja 7 months, 2 weeks ago
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