Skip to contentSkip to conversation

qapi/machine-s390x: add QAPI event SCLP_CPI_INFO_AVAILABLE

PATCH Superseded Shalini Chellathurai Saroja 3 participants 6 messages Oct 13, 2025 – Oct 16, 2025

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 qapi/machine-s390x: add QAPI event SCLP_CPI_INFO_AVAILABLE

Add QAPI event SCLP_CPI_INFO_AVAILABLE to notify the availability of Control-Program Identification data in QOM.

---
 hw/s390x/sclpcpi.c      |  4 ++++
 qapi/machine-s390x.json | 25 +++++++++++++++++++++++++
 2 files changed, 29 insertions(+)
hw/s390x/sclpcpi.c +4 -0
index 7aa039d510..90da61b1c8 100644
@@ -54,6 +54,7 @@
 #include "hw/s390x/event-facility.h"
 #include "hw/s390x/ebcdic.h"
 #include "qapi/qapi-visit-machine.h"
+#include "qapi/qapi-events-machine-s390x.h"
 #include "migration/vmstate.h"
 
 typedef struct Data {
@@ -106,6 +107,9 @@ static int write_event_data(SCLPEvent *event, EventBufferHeader *evt_buf_hdr)
     e->timestamp = qemu_clock_get_ns(QEMU_CLOCK_HOST);
 
     cpim->ebh.flags = SCLP_EVENT_BUFFER_ACCEPTED;
+
+    qapi_event_send_sclp_cpi_info_available(true);
+
     return SCLP_RC_NORMAL_COMPLETION;
 }
 
qapi/machine-s390x.json +25 -0
index 966dbd61d2..338653e0b8 100644
@@ -119,3 +119,28 @@
 { 'command': 'query-s390x-cpu-polarization', 'returns': 'CpuPolarizationInfo',
   'features': [ 'unstable' ]
 }
+
+##
+# @SCLP_CPI_INFO_AVAILABLE:
+#
+# Emitted when the Control-Program Identification data is available
+# in the QOM tree.
+#
+# @iscpiavailable: is CPI data available in QOM
+#
+# Features:
+#
+# @unstable: This event is experimental.
+#
+# Since: 10.2
+#
+# .. qmp-example::
+#
+#     <- { "event": "SCLP_CPI_INFO_AVAILABLE",
+#          "data": { "iscpiavailable": true },
+#          "timestamp": { "seconds": 1401385907, "microseconds": 422329 } }
+##
+{ 'event': 'SCLP_CPI_INFO_AVAILABLE',
+  'data': { 'iscpiavailable': 'bool' },
+  'features': [ 'unstable' ]
+}
Signature · 1 line
2.49.0
#1 lore raw

PATCH v2 2/2 tests/functional: add tests for SCLP event CPI

Add tests for SCLP event type Control-Program Identification.

---
 tests/functional/s390x/test_ccw_virtio.py | 25 +++++++++++++++++++++++
 1 file changed, 25 insertions(+)
tests/functional/s390x/test_ccw_virtio.py +25 -0
index 453711aa0f..82e73ecf5e 100755
@@ -15,6 +15,7 @@
 import tempfile
 
 from qemu_test import QemuSystemTest, Asset
+from qemu_test import exec_command
 from qemu_test import exec_command_and_wait_for_pattern
 from qemu_test import wait_for_console_pattern
 
@@ -270,5 +271,29 @@ def test_s390x_fedora(self):
                         'while ! (dmesg -c | grep Start.virtcrypto_remove) ; do'
                         ' sleep 1 ; done', 'Start virtcrypto_remove.')
 
+        # Test SCLP event Control-Program Identification (CPI)
+        cpi = '/sys/firmware/cpi/'
+        sclpcpi = '/machine/sclp/s390-sclp-event-facility/sclpcpi'
+        self.log.info("Test SCLP event CPI")
+        exec_command(self, 'echo TESTVM > ' + cpi + 'system_name')
+        exec_command(self, 'echo LINUX > ' + cpi + 'system_type')
+        exec_command(self, 'echo TESTPLEX > ' + cpi + 'sysplex_name')
+        exec_command(self, 'echo 0x001a000000060b00 > ' + cpi + 'system_level')
+        exec_command(self, 'echo 1 > ' + cpi + 'set')
+        try:
+            event = self.vm.event_wait('SCLP_CPI_INFO_AVAILABLE')
+        except TimeoutError:
+            self.skipTest('SCLP Event type CPI is not supported')
+        ts = self.vm.cmd('qom-get', path=sclpcpi, property='timestamp')
+        self.assertNotEqual(ts, 0)
+        name = self.vm.cmd('qom-get', path=sclpcpi, property='system_name')
+        self.assertEqual(name.strip(), 'TESTVM')
+        typ = self.vm.cmd('qom-get', path=sclpcpi, property='system_type')
+        self.assertEqual(typ.strip(), 'LINUX')
+        sysplex = self.vm.cmd('qom-get', path=sclpcpi, property='sysplex_name')
+        self.assertEqual(sysplex.strip(), 'TESTPLEX')
+        level = self.vm.cmd('qom-get', path=sclpcpi, property='system_level')
+        self.assertEqual(level, 0x001a000000060b00)
+
 if __name__ == '__main__':
     QemuSystemTest.main()
Signature · 1 line
2.49.0
#2 lore raw

Re: [PATCH v2 2/2] tests/functional: add tests for SCLP event CPI

Quoted 23 lines · Shalini Chellathurai Saroja

Add tests for SCLP event type Control-Program Identification.

---
  tests/functional/s390x/test_ccw_virtio.py | 25 +++++++++++++++++++++++
  1 file changed, 25 insertions(+)
tests/functional/s390x/test_ccw_virtio.py +1 -0
index 453711aa0f..82e73ecf5e 100755
@@ -15,6 +15,7 @@
  import tempfile
 
  from qemu_test import QemuSystemTest, Asset
+from qemu_test import exec_command
  from qemu_test import exec_command_and_wait_for_pattern
  from qemu_test import wait_for_console_pattern
 
@@ -270,5 +271,29 @@ def test_s390x_fedora(self):
                          'while ! (dmesg -c | grep Start.virtcrypto_remove) ; do'
                          ' sleep 1 ; done', 'Start virtcrypto_remove.')

tests/functional/s390x/test_ccw_virtio.py def test_s390x_fedora(self): · line 282

Quoted 10 lines
tests/functional/s390x/test_ccw_virtio.py +9 -0
 
+        # Test SCLP event Control-Program Identification (CPI)
+        cpi = '/sys/firmware/cpi/'
+        sclpcpi = '/machine/sclp/s390-sclp-event-facility/sclpcpi'
+        self.log.info("Test SCLP event CPI")
+        exec_command(self, 'echo TESTVM > ' + cpi + 'system_name')
+        exec_command(self, 'echo LINUX > ' + cpi + 'system_type')
+        exec_command(self, 'echo TESTPLEX > ' + cpi + 'sysplex_name')
+        exec_command(self, 'echo 0x001a000000060b00 > ' + cpi + 'system_level')
+        exec_command(self, 'echo 1 > ' + cpi + 'set')

I think at least the last statement should be replaced by exec_command_and_wait_for_pattern, waiting for the shell prompt. Otherwise there is a small race condition here that the exec_command() has been sent, but not executed yet. Ok, the event_wait() will wait for a while, so it's very unlikely, but let's better play save and wait for the shell prompt first, before waiting for the event.

tests/functional/s390x/test_ccw_virtio.py def test_s390x_fedora(self): · line 286

Quoted 4 lines
tests/functional/s390x/test_ccw_virtio.py +4 -0
+        try:
+            event = self.vm.event_wait('SCLP_CPI_INFO_AVAILABLE')
+        except TimeoutError:
+            self.skipTest('SCLP Event type CPI is not supported')

Should we rather fail the test in case we don't receive the event?

tests/functional/s390x/test_ccw_virtio.py def test_s390x_fedora(self): · line 296

Quoted 10 lines
tests/functional/s390x/test_ccw_virtio.py +10 -0
+        ts = self.vm.cmd('qom-get', path=sclpcpi, property='timestamp')
+        self.assertNotEqual(ts, 0)
+        name = self.vm.cmd('qom-get', path=sclpcpi, property='system_name')
+        self.assertEqual(name.strip(), 'TESTVM')
+        typ = self.vm.cmd('qom-get', path=sclpcpi, property='system_type')
+        self.assertEqual(typ.strip(), 'LINUX')
+        sysplex = self.vm.cmd('qom-get', path=sclpcpi, property='sysplex_name')
+        self.assertEqual(sysplex.strip(), 'TESTPLEX')
+        level = self.vm.cmd('qom-get', path=sclpcpi, property='system_level')
+        self.assertEqual(level, 0x001a000000060b00)

Thomas

#3 lore raw

Re: [PATCH v2 2/2] tests/functional: add tests for SCLP event CPI

Quoted 34 lines · Thomas Huth
Quoted 33 lines · Shalini Chellathurai Saroja

Add tests for SCLP event type Control-Program Identification.

---
  tests/functional/s390x/test_ccw_virtio.py | 25 
+++++++++++++++++++++++
  1 file changed, 25 insertions(+)
tests/functional/s390x/test_ccw_virtio.py +1 -0
index 453711aa0f..82e73ecf5e 100755
@@ -15,6 +15,7 @@
  import tempfile
    from qemu_test import QemuSystemTest, Asset
+from qemu_test import exec_command
  from qemu_test import exec_command_and_wait_for_pattern
  from qemu_test import wait_for_console_pattern
  @@ -270,5 +271,29 @@ def test_s390x_fedora(self):
                          'while ! (dmesg -c | grep 

Start.virtcrypto_remove) ; do'
' sleep 1 ; done', 'Start
virtcrypto_remove.')
+ # Test SCLP event Control-Program Identification (CPI)

tests/functional/s390x/test_ccw_virtio.py +7 -0
+        cpi = '/sys/firmware/cpi/'
+        sclpcpi = '/machine/sclp/s390-sclp-event-facility/sclpcpi'
+        self.log.info("Test SCLP event CPI")
+        exec_command(self, 'echo TESTVM > ' + cpi + 'system_name')
+        exec_command(self, 'echo LINUX > ' + cpi + 'system_type')
+        exec_command(self, 'echo TESTPLEX > ' + cpi + 'sysplex_name')
+        exec_command(self, 'echo 0x001a000000060b00 > ' + cpi + 

'system_level')

Quoted 9 lines
Quoted 1 line

+ exec_command(self, 'echo 1 > ' + cpi + 'set')

I think at least the last statement should be replaced by exec_command_and_wait_for_pattern, waiting for the shell prompt. Otherwise there is a small race condition here that the exec_command() has been sent, but not executed yet. Ok, the event_wait() will wait for a while, so it's very unlikely, but let's better play save and wait for the shell prompt first, before waiting for the event.

ok.

Quoted 6 lines

tests/functional/s390x/test_ccw_virtio.py def test_s390x_fedora(self): · line 286

Quoted 4 lines
tests/functional/s390x/test_ccw_virtio.py +4 -0
+        try:
+            event = self.vm.event_wait('SCLP_CPI_INFO_AVAILABLE')
+        except TimeoutError:
+            self.skipTest('SCLP Event type CPI is not supported')

Should we rather fail the test in case we don't receive the event?

ok.

Hello Thomas,

I will incorporate the changes and will send the v3. Thank you for the review.

Quoted 18 lines
Quoted 14 lines

+ ts = self.vm.cmd('qom-get', path=sclpcpi,
property='timestamp')

tests/functional/s390x/test_ccw_virtio.py +2 -0
+        self.assertNotEqual(ts, 0)
+        name = self.vm.cmd('qom-get', path=sclpcpi, 

property='system_name')

tests/functional/s390x/test_ccw_virtio.py +2 -0
+        self.assertEqual(name.strip(), 'TESTVM')
+        typ = self.vm.cmd('qom-get', path=sclpcpi, 

property='system_type')

tests/functional/s390x/test_ccw_virtio.py +2 -0
+        self.assertEqual(typ.strip(), 'LINUX')
+        sysplex = self.vm.cmd('qom-get', path=sclpcpi, 

property='sysplex_name')

tests/functional/s390x/test_ccw_virtio.py +2 -0
+        self.assertEqual(sysplex.strip(), 'TESTPLEX')
+        level = self.vm.cmd('qom-get', path=sclpcpi, 
Quoted 2 lines

property='system_level')
+ self.assertEqual(level, 0x001a000000060b00)

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
#4 lore raw
In reply to Shalini Chellathurai Saroja
Quoted 53 lines · Shalini Chellathurai Saroja

Add QAPI event SCLP_CPI_INFO_AVAILABLE to notify the availability of Control-Program Identification data in QOM.

---
 hw/s390x/sclpcpi.c      |  4 ++++
 qapi/machine-s390x.json | 25 +++++++++++++++++++++++++
 2 files changed, 29 insertions(+)
hw/s390x/sclpcpi.c +4 -0
index 7aa039d510..90da61b1c8 100644
@@ -54,6 +54,7 @@
 #include "hw/s390x/event-facility.h"
 #include "hw/s390x/ebcdic.h"
 #include "qapi/qapi-visit-machine.h"
+#include "qapi/qapi-events-machine-s390x.h"
 #include "migration/vmstate.h"
 
 typedef struct Data {
@@ -106,6 +107,9 @@ static int write_event_data(SCLPEvent *event, EventBufferHeader *evt_buf_hdr)
     e->timestamp = qemu_clock_get_ns(QEMU_CLOCK_HOST);
 
     cpim->ebh.flags = SCLP_EVENT_BUFFER_ACCEPTED;
+
+    qapi_event_send_sclp_cpi_info_available(true);
+
     return SCLP_RC_NORMAL_COMPLETION;
 }
 
qapi/machine-s390x.json +13 -0
index 966dbd61d2..338653e0b8 100644
@@ -119,3 +119,28 @@
 { 'command': 'query-s390x-cpu-polarization', 'returns': 'CpuPolarizationInfo',
   'features': [ 'unstable' ]
 }
+
+##
+# @SCLP_CPI_INFO_AVAILABLE:
+#
+# Emitted when the Control-Program Identification data is available
+# in the QOM tree.
+#
+# @iscpiavailable: is CPI data available in QOM
+#
+# Features:
+#
+# @unstable: This event is experimental.
+#

qapi/machine-s390x.json line 144

Quoted 10 lines
qapi/machine-s390x.json +10 -0
+# Since: 10.2
+#
+# .. qmp-example::
+#
+#     <- { "event": "SCLP_CPI_INFO_AVAILABLE",
+#          "data": { "iscpiavailable": true },
+#          "timestamp": { "seconds": 1401385907, "microseconds": 422329 } }
+##
+{ 'event': 'SCLP_CPI_INFO_AVAILABLE',
+  'data': { 'iscpiavailable': 'bool' },

What is the point of this payload?

Quoted 2 lines
qapi/machine-s390x.json +2 -0
+  'features': [ 'unstable' ]
+}
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
#5 lore raw
Quoted 62 lines · Nina Schoetterl-Glausch
Quoted 61 lines · Shalini Chellathurai Saroja

Add QAPI event SCLP_CPI_INFO_AVAILABLE to notify the availability of Control-Program Identification data in QOM.

---
 hw/s390x/sclpcpi.c      |  4 ++++
 qapi/machine-s390x.json | 25 +++++++++++++++++++++++++
 2 files changed, 29 insertions(+)
hw/s390x/sclpcpi.c +4 -0
index 7aa039d510..90da61b1c8 100644
@@ -54,6 +54,7 @@
 #include "hw/s390x/event-facility.h"
 #include "hw/s390x/ebcdic.h"
 #include "qapi/qapi-visit-machine.h"
+#include "qapi/qapi-events-machine-s390x.h"
 #include "migration/vmstate.h"
 
 typedef struct Data {
@@ -106,6 +107,9 @@ static int write_event_data(SCLPEvent *event, 
 EventBufferHeader *evt_buf_hdr)
     e->timestamp = qemu_clock_get_ns(QEMU_CLOCK_HOST);
 
     cpim->ebh.flags = SCLP_EVENT_BUFFER_ACCEPTED;
+
+    qapi_event_send_sclp_cpi_info_available(true);
+
     return SCLP_RC_NORMAL_COMPLETION;
 }
qapi/machine-s390x.json +19 -0
index 966dbd61d2..338653e0b8 100644
@@ -119,3 +119,28 @@
 { 'command': 'query-s390x-cpu-polarization', 'returns': 
 'CpuPolarizationInfo',
   'features': [ 'unstable' ]
 }
+
+##
+# @SCLP_CPI_INFO_AVAILABLE:
+#
+# Emitted when the Control-Program Identification data is available
+# in the QOM tree.
+#
+# @iscpiavailable: is CPI data available in QOM
+#
+# Features:
+#
+# @unstable: This event is experimental.
+#
+# Since: 10.2
+#
+# .. qmp-example::
+#
+#     <- { "event": "SCLP_CPI_INFO_AVAILABLE",
+#          "data": { "iscpiavailable": true },
Quoted 8 lines

qapi/machine-s390x.json line 144

Quoted 5 lines

+# "timestamp": { "seconds": 1401385907, "microseconds":
422329 } }

qapi/machine-s390x.json +3 -0
+##
+{ 'event': 'SCLP_CPI_INFO_AVAILABLE',
+  'data': { 'iscpiavailable': 'bool' },

What is the point of this payload?

The data 'iscpiavailable' is not necessary. I will remove this and send v3. Thank you Nina for the quick feedback.

Quoted 3 lines
Quoted 3 lines
qapi/machine-s390x.json +2 -0
+  'features': [ 'unstable' ]
+}
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