From patchwork Sat Jan 25 18:13:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 13950483 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 32D4AC0218C for ; Sat, 25 Jan 2025 18:14:13 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.877009.1287230 (Exim 4.92) (envelope-from ) id 1tbkfU-0005R9-Ko; Sat, 25 Jan 2025 18:14:04 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 877009.1287230; Sat, 25 Jan 2025 18:14:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tbkfU-0005QM-HR; Sat, 25 Jan 2025 18:14:04 +0000 Received: by outflank-mailman (input) for mailman id 877009; Sat, 25 Jan 2025 18:14:03 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tbkfT-000565-R0 for xen-devel@lists.xenproject.org; Sat, 25 Jan 2025 18:14:03 +0000 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [2a00:1450:4864:20::430]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 27a761a7-db48-11ef-99a4-01e77a169b0f; Sat, 25 Jan 2025 19:14:02 +0100 (CET) Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-385ef8b64b3so2698316f8f.0 for ; Sat, 25 Jan 2025 10:14:02 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38c2a17d865sm6249213f8f.38.2025.01.25.10.14.00 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 25 Jan 2025 10:14:01 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 27a761a7-db48-11ef-99a4-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737828842; x=1738433642; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=60AuA1WDx9vhZn9WTP7sL5YOcyHTmPSWNTPXV1fPX/g=; b=IFlm2xVQAoQfvtsA1V7yF+n0t4VdAbrIGxxDsUiOutAcB2a3fkoTR3/WbpNST1hPEd TYwZybs9iRmfjhmz6C1PGkSJ3gXQGct1y2xMS4u7nWnYRHGb0cgiR0ufF8xtxNSAEKBb yCTahB+URGpRTBcAd7XKPBmJ2Z9M0jpQt1PoOCDA9m60ECHEeyeHQuDYZGOXkcAYpgtK YdDxCarS07jWcGnWUUOqyliOISqDNFDfuqkGRfeLrlXn49DU0I0nTRN3LfdMKMdjaj/C xjqFMrRd2x3XcVhqWBxT8b3+03sNUStBhMQ+YbDnHWwKD7Gn28ACAKlIe1kNVCemx7UK fZpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737828842; x=1738433642; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=60AuA1WDx9vhZn9WTP7sL5YOcyHTmPSWNTPXV1fPX/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:6000:2c5:b0:37d:4647:154e with SMTP id ffacd0b85a97d-38bf5655bd3mr29759427f8f.9.1737828841654; Sat, 25 Jan 2025 10:14:01 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Yi Liu , Markus Armbruster , Eduardo Habkost , Anthony PERARD , Gustavo Romero , Jason Wang , qemu-ppc@nongnu.org, "Michael S. Tsirkin" , Paolo Bonzini , Alexander Graf , Richard Henderson , Stefan Berger , Bernhard Beschow , Stefano Stabellini , Gerd Hoffmann , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , "Edgar E. Iglesias" , xen-devel@lists.xenproject.org, Marcel Apfelbaum , Alex Williamson , Paul Durrant , =?utf-8?q?Cl=C3=A9ment_Mathieu--Drif?= , =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Math?= =?utf-8?q?ieu-Daud=C3=A9?= Subject: [PATCH 3/9] hw/sysbus: Introduce TYPE_DYNAMIC_SYS_BUS_DEVICE Date: Sat, 25 Jan 2025 19:13:37 +0100 Message-ID: <20250125181343.59151-4-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250125181343.59151-1-philmd@linaro.org> References: <20250125181343.59151-1-philmd@linaro.org> MIME-Version: 1.0 Some TYPE_SYS_BUS_DEVICEs can be optionally dynamically plugged on the TYPE_PLATFORM_BUS_DEVICE. Rather than sometimes noting that with comment around the 'user_creatable = true' line in each DeviceRealize handler, introduce an abstract TYPE_DYNAMIC_SYS_BUS_DEVICE class. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Clément Mathieu--Drif --- include/hw/sysbus.h | 2 ++ hw/core/sysbus.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h index c9b1e0e90e3..81bbda10d37 100644 --- a/include/hw/sysbus.h +++ b/include/hw/sysbus.h @@ -19,6 +19,8 @@ DECLARE_INSTANCE_CHECKER(BusState, SYSTEM_BUS, OBJECT_DECLARE_TYPE(SysBusDevice, SysBusDeviceClass, SYS_BUS_DEVICE) +#define TYPE_DYNAMIC_SYS_BUS_DEVICE "dynamic-sysbus-device" + /** * SysBusDeviceClass: * diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c index 306f98406c0..e8d03fd28d9 100644 --- a/hw/core/sysbus.c +++ b/hw/core/sysbus.c @@ -321,6 +321,14 @@ BusState *sysbus_get_default(void) return main_system_bus; } +static void dynamic_sysbus_device_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *k = DEVICE_CLASS(klass); + + k->user_creatable = true; + k->hotpluggable = false; +} + static const TypeInfo sysbus_types[] = { { .name = TYPE_SYSTEM_BUS, @@ -336,6 +344,12 @@ static const TypeInfo sysbus_types[] = { .class_size = sizeof(SysBusDeviceClass), .class_init = sysbus_device_class_init, }, + { + .name = TYPE_DYNAMIC_SYS_BUS_DEVICE, + .parent = TYPE_SYS_BUS_DEVICE, + .class_init = dynamic_sysbus_device_class_init, + .abstract = true, + } }; DEFINE_TYPES(sysbus_types)