aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Le Goater <clg@redhat.com>2024-05-02 15:15:32 +0200
committerThomas Huth <thuth@redhat.com>2024-05-10 06:23:56 +0200
commitaf4a3e32f3e1284662ebc1fd50a8c5e1776ebece (patch)
treebfb69ded34460608cd42dadc817389882e005877
parentb350f6c8ed4fd796454d0f26482f3e9d9285fda1 (diff)
s390x/event-facility: Simplify sclp_get_event_facility_bus()
sclp_get_event_facility_bus() scans the whole machine to find a TYPE_SCLP_EVENTS_BUS object. The SCLPDevice instance is now available under the machine state, use it to simplify the lookup and adjust the creation of the consoles. Signed-off-by: Cédric Le Goater <clg@redhat.com> Message-ID: <20240502131533.377719-3-clg@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
-rw-r--r--hw/s390x/event-facility.c13
-rw-r--r--hw/s390x/s390-virtio-ccw.c12
-rw-r--r--include/hw/s390x/event-facility.h2
3 files changed, 10 insertions, 17 deletions
diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
index f9829de953..06c1da0ece 100644
--- a/hw/s390x/event-facility.c
+++ b/hw/s390x/event-facility.c
@@ -523,16 +523,7 @@ static void register_types(void)
type_init(register_types)
-BusState *sclp_get_event_facility_bus(void)
+BusState *sclp_get_event_facility_bus(SCLPEventFacility *ef)
{
- Object *busobj;
- SCLPEventsBus *sbus;
-
- busobj = object_resolve_path_type("", TYPE_SCLP_EVENTS_BUS, NULL);
- sbus = OBJECT_CHECK(SCLPEventsBus, busobj, TYPE_SCLP_EVENTS_BUS);
- if (!sbus) {
- return NULL;
- }
-
- return &sbus->qbus;
+ return BUS(&ef->sbus);
}
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 159f67d05c..2afaf45ce6 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -237,13 +237,15 @@ static void s390_create_virtio_net(BusState *bus, const char *name)
}
}
-static void s390_create_sclpconsole(const char *type, Chardev *chardev)
+static void s390_create_sclpconsole(SCLPDevice *sclp,
+ const char *type, Chardev *chardev)
{
- BusState *ev_fac_bus = sclp_get_event_facility_bus();
+ SCLPEventFacility *ef = sclp->event_facility;
+ BusState *ev_fac_bus = sclp_get_event_facility_bus(ef);
DeviceState *dev;
dev = qdev_new(type);
- object_property_add_child(OBJECT(ev_fac_bus->parent), type, OBJECT(dev));
+ object_property_add_child(OBJECT(ef), type, OBJECT(dev));
qdev_prop_set_chr(dev, "chardev", chardev);
qdev_realize_and_unref(dev, ev_fac_bus, &error_fatal);
}
@@ -308,10 +310,10 @@ static void ccw_init(MachineState *machine)
/* init consoles */
if (serial_hd(0)) {
- s390_create_sclpconsole("sclpconsole", serial_hd(0));
+ s390_create_sclpconsole(ms->sclp, "sclpconsole", serial_hd(0));
}
if (serial_hd(1)) {
- s390_create_sclpconsole("sclplmconsole", serial_hd(1));
+ s390_create_sclpconsole(ms->sclp, "sclplmconsole", serial_hd(1));
}
/* init the TOD clock */
diff --git a/include/hw/s390x/event-facility.h b/include/hw/s390x/event-facility.h
index 3ffd575d8f..ff874e792d 100644
--- a/include/hw/s390x/event-facility.h
+++ b/include/hw/s390x/event-facility.h
@@ -203,6 +203,6 @@ struct SCLPEventFacilityClass {
bool (*event_pending)(SCLPEventFacility *ef);
};
-BusState *sclp_get_event_facility_bus(void);
+BusState *sclp_get_event_facility_bus(SCLPEventFacility *ef);
#endif