From nobody Mon Feb 9 16:56:02 2026 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=1592256896; cv=none; d=zohomail.com; s=zohoarc; b=Lk6o7/cfQbbTj2Kbfxsx9CCb0/XQgY9soG2Fd1WBebO1OAB0rayP/agAAzzy5atA9+/+e0fFkQeDdOSMC5dex9D3RxJozhYVxiYoYCg2BcpxrqUhiqynkSMJqsCkL1GwyxYpxrAfu7pscpO5z8aKniTKyt1CD0XTS0Daoe0bumg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592256896; 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=4/N/qdd2vGuSHd641b14kVv0r6nRlJ212mugWR9M9Rw=; b=WjwX3IrTSFJi0YfLnUxNmBiuSoTZNmgusD64mZ7JxutRjhXvefFRNTXdLS1AfhOWbv35+7xb+QPyaa2ygjE6NholUB/StWNTNwinJf02HixzRLRQTm1x8SQ0SPfy+VmYeFyLpEXuhWpKwF058OxWatG51W1YiHG9F4fzGcM13h8= 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 1592256896155606.9887137449845; Mon, 15 Jun 2020 14:34:56 -0700 (PDT) Received: from localhost ([::1]:59386 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jkwkn-00010A-TD for importer@patchew.org; Mon, 15 Jun 2020 17:34:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35584) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jkw23-00075L-AQ for qemu-devel@nongnu.org; Mon, 15 Jun 2020 16:48:39 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:53636 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 1jkw1z-0001sh-2l for qemu-devel@nongnu.org; Mon, 15 Jun 2020 16:48:38 -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-348-YfNrHADgOSiBjkev6YHKpw-1; Mon, 15 Jun 2020 16:48:30 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5F115E920; Mon, 15 Jun 2020 20:48:29 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-121.ams2.redhat.com [10.36.112.121]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 29D0E7FE8B; Mon, 15 Jun 2020 20:48:26 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 601751131C04; Mon, 15 Jun 2020 22:40:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592254114; 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=4/N/qdd2vGuSHd641b14kVv0r6nRlJ212mugWR9M9Rw=; b=hnWA1MlIgLH+LGLb6BiwiLuHlOYZT3i+IkPJx+DV6BWsZCLBdleCz37uD56gH91HN6R2pE aSSHFjGpEMAX31PIEz6v6LzWLQNxATbXWUuddoC0GHwW6BXDesph18ppUeuKh4eOU553R8 gUtlxZ4uzeKSVyr3KEsMxpQsvSU3GA0= X-MC-Unique: YfNrHADgOSiBjkev6YHKpw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 79/84] s390x/event-facility: Simplify creation of SCLP event devices Date: Mon, 15 Jun 2020 22:40:03 +0200 Message-Id: <20200615204008.3069956-80-armbru@redhat.com> In-Reply-To: <20200615204008.3069956-1-armbru@redhat.com> References: <20200615204008.3069956-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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=205.139.110.61; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/15 15:33:00 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-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: David Hildenbrand , Cornelia Huck , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Paolo Bonzini , 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 Reviewed-by: David Hildenbrand Acked-by: Cornelia Huck Reviewed-by: Paolo Bonzini Message-Id: <20200610053247.1583243-54-armbru@redhat.com> --- hw/s390x/event-facility.c | 64 ++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 35 deletions(-) diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c index 97a4f0b1f5..164b1fd295 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,44 @@ 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), &local_err); + if (local_err) { + error_propagate(errp, local_err); + qdev_unrealize(DEVICE(&event_facility->quiesce)); + return; + } } =20 static void reset_event_facility(DeviceState *dev) @@ -479,6 +472,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.26.2