qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Shalini Chellathurai Saroja <shalini@linux.ibm.com>
To: qemu-s390x mailing list <qemu-s390x@nongnu.org>,
	Thomas Huth <thuth@redhat.com>,
	Daniel Berrange <berrange@redhat.com>
Cc: qemu-devel mailing list <qemu-devel@nongnu.org>,
	Nina Schoetterl-Glausch <nsg@linux.ibm.com>,
	Hendrik Brueckner <brueckner@linux.ibm.com>,
	Shalini Chellathurai Saroja <shalini@linux.ibm.com>
Subject: [PATCH v3 4/4] hw/s390x: compat handling for backward migration
Date: Mon, 31 Mar 2025 16:00:41 +0200	[thread overview]
Message-ID: <20250331140041.3133621-5-shalini@linux.ibm.com> (raw)
In-Reply-To: <20250331140041.3133621-1-shalini@linux.ibm.com>

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



  parent reply	other threads:[~2025-03-31 14:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Shalini Chellathurai Saroja [this message]
2025-04-02  7:52   ` [PATCH v3 4/4] hw/s390x: compat handling for backward migration 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250331140041.3133621-5-shalini@linux.ibm.com \
    --to=shalini@linux.ibm.com \
    --cc=berrange@redhat.com \
    --cc=brueckner@linux.ibm.com \
    --cc=nsg@linux.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).