From nobody Fri Nov 14 20:40:45 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589902533; cv=none; d=zohomail.com; s=zohoarc; b=nw4QK1Z+LbQUzFKhrdYtM3N6IpwJsZzGbgsNzR4n5QQiDGzc5sktns91VeKAP/I6Fn29JExTEJ4Sz3m7RuuQ72PvVQGPLXXRc6bbyL+mDPSYi8RQ7dRMEuIOvQQ2cUgp8I98WLjYA1wMz/xFWyeE4XXyZ5UL3LUBtKtOaSpVYfw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589902533; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+t2Q0tx5Gsh01Axo9sX5jfvhJDZwhD0ryD7YGKjXGTs=; b=OuU+0vj/aPnVGVsgtiBbMd5bTeRLTOluznysnp74EodZr5oRr3AMYaMPkXotWNlTNH35DyM6uE3tuBlwEJ82gu0MTNNSwzy16rOjQgyCLz5nWR/gnHIQtur66Q2Xu57JUJ9Cz63iLnlNLPbdofnzn7xUp29wyMMmoju1MDHyuE8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589902533143900.8064813998798; Tue, 19 May 2020 08:35:33 -0700 (PDT) Received: from localhost ([::1]:42456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jb4HE-0007VV-3w for importer@patchew.org; Tue, 19 May 2020 11:35:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46340) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jb3nx-0004Hc-CF for qemu-devel@nongnu.org; Tue, 19 May 2020 11:05:17 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:37280 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jb3nu-00058r-OG for qemu-devel@nongnu.org; Tue, 19 May 2020 11:05:16 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-93-38PH_EwSP1G8_slmQtQrnw-1; Tue, 19 May 2020 11:05:11 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C2D2A805724; Tue, 19 May 2020 15:05:09 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-32.ams2.redhat.com [10.36.112.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 48E635D9E7; Tue, 19 May 2020 15:05:02 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6C1D41135230; Tue, 19 May 2020 16:55:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589900712; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+t2Q0tx5Gsh01Axo9sX5jfvhJDZwhD0ryD7YGKjXGTs=; b=M0PIDQXIgPb6ZvY0PA3/LKd2h5Sjvb+BVL6/vqHy2s6UKXHKLKl4+09QvbeHNTRllV4zv4 iNECWe6Jhi4TU7OvTegew8eIdUu5jTvoz4mhqwdXFRfJX3X4V2xsUuv3FEpPE+ZTAV93BG 0wNmmbgxU7KHgfbTocneMZQlcoiRt0E= X-MC-Unique: 38PH_EwSP1G8_slmQtQrnw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH 50/55] s390x/event-facility: Simplify creation of SCLP event devices Date: Tue, 19 May 2020 16:55:46 +0200 Message-Id: <20200519145551.22836-51-armbru@redhat.com> In-Reply-To: <20200519145551.22836-1-armbru@redhat.com> References: <20200519145551.22836-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/19 00:34:39 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: berrange@redhat.com, ehabkost@redhat.com, David Hildenbrand , Cornelia Huck , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, pbonzini@redhat.com, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" init_event_facility() creates the SCLP events bus with two SCLP event devices (sclpquiesce and sclp-cpu-hotplug). It leaves the devices unrealized. A comment explains they will be realized "via the bus". The bus's realize method sclp_events_bus_realize() indeed realizes all unrealized devices on this bus. It carries a TODO comment claiming this "has to be done in common code". No other bus realize method realizes its devices. The common code in question is bus_set_realized(), which has a TODO comment asking for recursive realization. It's been asking for years. The only devices sclp_events_bus_realize() will ever realize are the two init_event_facility() puts there. Simplify as follows: * Make the devices members of the event facility instance struct, just like the bus. object_initialize_child() is simpler than object_property_add_child() and object_unref(). * Realize them in the event facility realize method. This is in line with how such things are done elsewhere. Cc: Cornelia Huck Cc: Halil Pasic Cc: Christian Borntraeger Cc: Richard Henderson Cc: David Hildenbrand Cc: qemu-s390x@nongnu.org Signed-off-by: Markus Armbruster --- hw/s390x/event-facility.c | 59 ++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 35 deletions(-) diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c index 97a4f0b1f5..1ecaa20556 100644 --- a/hw/s390x/event-facility.c +++ b/hw/s390x/event-facility.c @@ -39,6 +39,7 @@ typedef struct SCLPEventsBus { struct SCLPEventFacility { SysBusDevice parent_obj; SCLPEventsBus sbus; + SCLPEvent quiesce, cpu_hotplug; /* guest's receive mask */ union { uint32_t receive_mask_pieces[2]; @@ -328,34 +329,9 @@ static void write_event_mask(SCLPEventFacility *ef, SC= CB *sccb) =20 #define TYPE_SCLP_EVENTS_BUS "s390-sclp-events-bus" =20 -static void sclp_events_bus_realize(BusState *bus, Error **errp) -{ - Error *err =3D NULL; - BusChild *kid; - - /* TODO: recursive realization has to be done in common code */ - QTAILQ_FOREACH(kid, &bus->children, sibling) { - DeviceState *dev =3D kid->child; - - object_property_set_bool(OBJECT(dev), true, "realized", &err); - if (err) { - error_propagate(errp, err); - return; - } - } -} - -static void sclp_events_bus_class_init(ObjectClass *klass, void *data) -{ - BusClass *bc =3D BUS_CLASS(klass); - - bc->realize =3D sclp_events_bus_realize; -} - static const TypeInfo sclp_events_bus_info =3D { .name =3D TYPE_SCLP_EVENTS_BUS, .parent =3D TYPE_BUS, - .class_init =3D sclp_events_bus_class_init, }; =20 static void command_handler(SCLPEventFacility *ef, SCCB *sccb, uint64_t co= de) @@ -443,27 +419,39 @@ static void init_event_facility(Object *obj) { SCLPEventFacility *event_facility =3D EVENT_FACILITY(obj); DeviceState *sdev =3D DEVICE(obj); - Object *new; =20 event_facility->mask_length =3D 4; event_facility->allow_all_mask_sizes =3D true; object_property_add_bool(obj, "allow_all_mask_sizes", sclp_event_get_allow_all_mask_sizes, sclp_event_set_allow_all_mask_sizes); + /* Spawn a new bus for SCLP events */ qbus_create_inplace(&event_facility->sbus, sizeof(event_facility->sbus= ), TYPE_SCLP_EVENTS_BUS, sdev, NULL); =20 - new =3D object_new(TYPE_SCLP_QUIESCE); - object_property_add_child(obj, TYPE_SCLP_QUIESCE, new); - object_unref(new); - qdev_set_parent_bus(DEVICE(new), BUS(&event_facility->sbus)); + object_initialize_child(obj, TYPE_SCLP_QUIESCE, + &event_facility->quiesce, + TYPE_SCLP_QUIESCE); =20 - new =3D object_new(TYPE_SCLP_CPU_HOTPLUG); - object_property_add_child(obj, TYPE_SCLP_CPU_HOTPLUG, new); - object_unref(new); - qdev_set_parent_bus(DEVICE(new), BUS(&event_facility->sbus)); - /* the facility will automatically realize the devices via the bus */ + object_initialize_child(obj, TYPE_SCLP_CPU_HOTPLUG, + &event_facility->cpu_hotplug, + TYPE_SCLP_CPU_HOTPLUG); +} + +static void realize_event_facility(DeviceState *dev, Error **errp) +{ + SCLPEventFacility *event_facility =3D EVENT_FACILITY(dev); + Error *local_err =3D NULL; + + qdev_realize(DEVICE(&event_facility->quiesce), + BUS(&event_facility->sbus), &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + qdev_realize(DEVICE(&event_facility->cpu_hotplug), + BUS(&event_facility->sbus), errp); } =20 static void reset_event_facility(DeviceState *dev) @@ -479,6 +467,7 @@ static void init_event_facility_class(ObjectClass *klas= s, void *data) DeviceClass *dc =3D DEVICE_CLASS(sbdc); SCLPEventFacilityClass *k =3D EVENT_FACILITY_CLASS(dc); =20 + dc->realize =3D realize_event_facility; dc->reset =3D reset_event_facility; dc->vmsd =3D &vmstate_event_facility; set_bit(DEVICE_CATEGORY_MISC, dc->categories); --=20 2.21.1