From nobody Tue Feb 10 11:15:51 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648729025412677.2071326208991; Thu, 31 Mar 2022 05:17:05 -0700 (PDT) Received: from localhost ([::1]:55896 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nZtjc-0005jZ-5v for importer@patchew.org; Thu, 31 Mar 2022 08:17:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47986) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZtMi-00061n-3H for qemu-devel@nongnu.org; Thu, 31 Mar 2022 07:53:26 -0400 Received: from beetle.greensocs.com ([5.135.226.135]:54046) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZtMb-00005g-OT for qemu-devel@nongnu.org; Thu, 31 Mar 2022 07:53:23 -0400 Received: from crumble.bar.greensocs.com (unknown [172.17.10.10]) by beetle.greensocs.com (Postfix) with ESMTPS id BEBF321C39; Thu, 31 Mar 2022 11:53:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=greensocs.com; s=mail; t=1648727593; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dsQmNcNr3FKvvqlW4Fm/tpXyRbUqSTE4gpq1FzHqJIY=; b=CY4M9NwccVDz3xvaHOXKuB5tNhZbON/w5pKw2FVG2iSPoKMaqhMO87Jx93EYx8oUZmTPNS EHXgESlw+G/lGZtaRpyi1x7/E0klL8ESOXNW1Fq+PR/CPg1uo6m7vw9FVrQlm9jKx3agyn UhqUdh0zs7dTK3xJ173fbeLeOFAjcp8= From: Damien Hedde To: qemu-devel@nongnu.org Subject: [PATCH v2 1/5] qdev: add user_creatable_requires_machine_allowance class flag Date: Thu, 31 Mar 2022 13:53:08 +0200 Message-Id: <20220331115312.30018-2-damien.hedde@greensocs.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220331115312.30018-1-damien.hedde@greensocs.com> References: <20220331115312.30018-1-damien.hedde@greensocs.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam: Yes 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=5.135.226.135; envelope-from=damien.hedde@greensocs.com; helo=beetle.greensocs.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Damien Hedde , Eduardo Habkost , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yanan Wang , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1648729027898100001 Content-Type: text/plain; charset="utf-8" This flag will be used in device_add to check if the device needs special allowance from the machine model. It will replace the current check based only on the device being a TYPE_SYB_BUS_DEVICE. Signed-off-by: Damien Hedde Reviewed-by: Edgar E. Iglesias --- v2: + change the flag name and put it just below user_creatable --- include/hw/qdev-core.h | 9 +++++++++ hw/core/qdev.c | 1 + hw/core/sysbus.c | 1 + 3 files changed, 11 insertions(+) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 92c3d65208..6a040fcd3b 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -122,6 +122,15 @@ struct DeviceClass { * TODO remove once we're there */ bool user_creatable; + /* + * Some devices can be user created under certain conditions (eg: + * specific machine support for sysbus devices), but it is + * preferable to prevent global allowance for the reasons + * described above. + * This flag is an additional constraint over user_creatable: + * user_creatable still needs to be set to true. + */ + bool user_creatable_requires_machine_allowance; bool hotpluggable; =20 /* callbacks */ diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 84f3019440..0844c85a21 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -833,6 +833,7 @@ static void device_class_init(ObjectClass *class, void = *data) */ dc->hotpluggable =3D true; dc->user_creatable =3D true; + dc->user_creatable_requires_machine_allowance =3D false; vc->get_id =3D device_vmstate_if_get_id; rc->get_state =3D device_get_reset_state; rc->child_foreach =3D device_reset_child_foreach; diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c index 05c1da3d31..5f771ed1e9 100644 --- a/hw/core/sysbus.c +++ b/hw/core/sysbus.c @@ -325,6 +325,7 @@ static void sysbus_device_class_init(ObjectClass *klass= , void *data) * subclass needs to override it and set user_creatable=3Dtrue. */ k->user_creatable =3D false; + k->user_creatable_requires_machine_allowance =3D true; } =20 static const TypeInfo sysbus_device_type_info =3D { --=20 2.35.1