From patchwork Wed Mar 30 16:12:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Hedde X-Patchwork-Id: 1611239 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=greensocs.com header.i=@greensocs.com header.a=rsa-sha256 header.s=mail header.b=y6ndgJ9A; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KTBWQ6pHjz9sFt for ; Thu, 31 Mar 2022 03:21:06 +1100 (AEDT) Received: from localhost ([::1]:44806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nZb4C-0007WT-JA for incoming@patchwork.ozlabs.org; Wed, 30 Mar 2022 12:21:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43704) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZavm-0001wm-R6 for qemu-devel@nongnu.org; Wed, 30 Mar 2022 12:12:22 -0400 Received: from beetle.greensocs.com ([5.135.226.135]:43274) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZavj-00015U-37 for qemu-devel@nongnu.org; Wed, 30 Mar 2022 12:12:22 -0400 Received: from crumble.bar.greensocs.com (unknown [172.17.10.6]) by beetle.greensocs.com (Postfix) with ESMTPS id A01FD21C38; Wed, 30 Mar 2022 16:12:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=greensocs.com; s=mail; t=1648656736; 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=HZxEDrSOjfWFBbGyVVQI54kbQO1rmKUBNEhxdHOuVxU=; b=y6ndgJ9A6/RFgbYwrJvVOMdLPbhAeplamjZBCeSCbD8OAquaMwaRBRgqCw5KELAjLgOjiG rQKrKyzufNUxWPWbseU5Af9XWpOHVs8uRmLxPPAqfZZLD4SD4q6C9WGWpXqCTBWmnPHz2Z 3JmuUTab7eqt7HCNPOb1EzYY2U6GW0M= From: Damien Hedde To: qemu-devel@nongnu.org Subject: [PATCH 1/5] qdev: add uc_requires_machine_allowance flag Date: Wed, 30 Mar 2022 18:12:11 +0200 Message-Id: <20220330161215.235231-2-damien.hedde@greensocs.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220330161215.235231-1-damien.hedde@greensocs.com> References: <20220330161215.235231-1-damien.hedde@greensocs.com> MIME-Version: 1.0 X-Spam: Yes 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_P=2E_Berrang=C3=A9?= , =?utf-8?q?Phil?= =?utf-8?q?ippe_Mathieu-Daud=C3=A9?= , Yanan Wang , Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 --- include/hw/qdev-core.h | 6 ++++++ hw/core/qdev.c | 1 + hw/core/sysbus.c | 1 + 3 files changed, 8 insertions(+) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 92c3d65208..f5a05ced39 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -123,6 +123,12 @@ struct DeviceClass { */ bool user_creatable; bool hotpluggable; + /* + * Some devices (eg: sysbus devices) are only user-creatable if + * the machine allowed it. user_creatable need still to be set to + * true, this is an additional constraint. + */ + bool uc_requires_machine_allowance; /* callbacks */ /* diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 84f3019440..0825277521 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 = true; dc->user_creatable = true; + dc->uc_requires_machine_allowance = false; vc->get_id = device_vmstate_if_get_id; rc->get_state = device_get_reset_state; rc->child_foreach = device_reset_child_foreach; diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c index 05c1da3d31..462eb1116c 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=true. */ k->user_creatable = false; + k->uc_requires_machine_allowance = true; } static const TypeInfo sysbus_device_type_info = {