From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA0DFC433EF for ; Thu, 23 Sep 2021 10:52:34 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 9AD05610C9 for ; Thu, 23 Sep 2021 10:52:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9AD05610C9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=anisinha.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.193681.345015 (Exim 4.92) (envelope-from ) id 1mTML4-0000fr-VC; Thu, 23 Sep 2021 10:52:26 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 193681.345015; Thu, 23 Sep 2021 10:52:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mTML4-0000fk-SF; Thu, 23 Sep 2021 10:52:26 +0000 Received: by outflank-mailman (input) for mailman id 193681; Thu, 23 Sep 2021 10:51:24 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mTMK4-0000Eq-KF for xen-devel@lists.xenproject.org; Thu, 23 Sep 2021 10:51:24 +0000 Received: from mail-pl1-x634.google.com (unknown [2607:f8b0:4864:20::634]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 11461a33-4c5f-4c4b-b0b0-1094f814d6d0; Thu, 23 Sep 2021 10:51:23 +0000 (UTC) Received: by mail-pl1-x634.google.com with SMTP id y1so3720435plk.10 for ; Thu, 23 Sep 2021 03:51:23 -0700 (PDT) Received: from anisinha-lenovo ([115.96.156.170]) by smtp.googlemail.com with ESMTPSA id e13sm5257765pfi.210.2021.09.23.03.51.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 03:51:21 -0700 (PDT) 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: 11461a33-4c5f-4c4b-b0b0-1094f814d6d0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anisinha-ca.20210112.gappssmtp.com; s=20210112; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=4fJXlclBbnkVQPBywtqy0QsfK3GLzEGhebPQ86PZ4yM=; b=UwDv30mJvlcUbc5vsqv5ShtJ3oE0rdWz5cuSzKVT1VMx7oOAhptBwIZn+62mHKdIda CcTYo+EH+KpGcDyZdaNnrJToFa4sWqSUcsxSlx9OQMQwM6QNX2Bww7OSG0RQXXbD3De5 /pWCE/0WJrdF+Yon0++dBCaOxfyz5xkXytI1DQ+bx6EBoEMTn9XJoS68bJ+H7GOwtgB8 qoSCK6s0PZy1TP/XYoD8RYoHjlNP3fM2zc0dTANnUrIbLemr+exTR/fR3LouYTH11512 q0A2gT3vXM5gNC++K3kAcqiW6ZU/MP54Ed6BdACd1DXgZye8fizrfC83ybMpvRifxhXA lPMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=4fJXlclBbnkVQPBywtqy0QsfK3GLzEGhebPQ86PZ4yM=; b=VXIpjNXwcQ4dC8pW25Ecqfz+r5N47avqQvSKRZwqj+8qRBdQYGKcgfs4WpxqrQFOR1 nb6pAux0UA7DBrH8Y8ysGR1GLDgRNrQ8zw/3FMtLgp+TiFT7HjXBgf3VgQ3FoV9Ywps1 Ddez/dtmi2FxiI1QmHiyEQWGkPvzHqnGK2iUDjfBTDhUWylwhFfLAckeMrTd0ZvBsKoE yOst9ZZAwLM3r7YgrzBh/w2LDhpNIaHqxtj/DHYaFyeWrzb4GAbIWqrHyJ/WIF3yB2k8 J5GrpbDNQIEAQSbj8EyZfVceu1EBbOvQuzqcqK5RnVkq7Pitql+fY6iYZmaUPxoBwoni sufg== X-Gm-Message-State: AOAM5339eKGXUUwHByCHSTAfQJWFRVtz2hKmpSuVD4m6mRZefRAfHDqr u1ZVUwN1iEuRNnvHFmmCLtutVg== X-Google-Smtp-Source: ABdhPJzia+90/vmutfv9+OVhfiSOiEAHqZONBLVWc1gCXXoo34eh7DSYhO2/LLO7Y/O8VFiKodZgxw== X-Received: by 2002:a17:90b:4d8f:: with SMTP id oj15mr4553491pjb.13.1632394282429; Thu, 23 Sep 2021 03:51:22 -0700 (PDT) From: Ani Sinha X-Google-Original-From: Ani Sinha Date: Thu, 23 Sep 2021 16:21:11 +0530 (IST) X-X-Sender: anisinha@anisinha-lenovo To: Damien Hedde cc: qemu-devel@nongnu.org, Alistair Francis , =?ISO-8859-15?Q?Marc-Andr=E9_Lureau?= , Paolo Bonzini , Eduardo Habkost , Marcel Apfelbaum , =?ISO-8859-15?Q?Daniel_P=2E_Berrang=E9?= , "Michael S. Tsirkin" , Igor Mammedov , Ani Sinha , Gerd Hoffmann , Eric Auger , Stefano Stabellini , Anthony Perard , Paul Durrant , Peter Xu , David Hildenbrand , "Dr. David Alan Gilbert" , Markus Armbruster , Eric Blake , qemu-riscv@nongnu.org, xen-devel@lists.xenproject.org, mark.burton@greensocs.com, mirela.grujic@greensocs.com, edgari@xilinx.com, Peter Maydell Subject: Re: [RFC PATCH v2 07/16] hw/core/machine: add machine_class_is_dynamic_sysbus_dev_allowed In-Reply-To: <20210922161405.140018-8-damien.hedde@greensocs.com> Message-ID: References: <20210922161405.140018-1-damien.hedde@greensocs.com> <20210922161405.140018-8-damien.hedde@greensocs.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII On Wed, 22 Sep 2021, Damien Hedde wrote: > Right now the allowance check for adding a sysbus device using > -device cli option (or device_add qmp command) is done well after > the device has been created. It is done during the machine init done > notifier: machine_init_notify() in hw/core/machine.c > > This new function will allow us to check if a sysbus device type is > allowed to be dynamically created by the machine during the device > creation time. > > Also make device_is_dynamic_sysbus() use the new function. > > Signed-off-by: Damien Hedde > --- > > In the context of our series, we need to be able to do the check at > device creation time to allow doing it depending on the current > MACHINE_INIT phase. > --- > include/hw/boards.h | 17 +++++++++++++++++ > hw/core/machine.c | 15 ++++++++++++--- > 2 files changed, 29 insertions(+), 3 deletions(-) > > diff --git a/include/hw/boards.h b/include/hw/boards.h > index 463a5514f9..934443c1cd 100644 > --- a/include/hw/boards.h > +++ b/include/hw/boards.h > @@ -51,6 +51,23 @@ void machine_set_cpu_numa_node(MachineState *machine, > */ > void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type); > > +/** > + * machine_class_is_dynamic_sysbus_dev_allowed: Check if type is an allowed > + * sysbus device type for the machine class. > + * @mc: Machine class > + * @type: type to check (should be a subtype of TYPE_SYS_BUS_DEVICE) > + * > + * Returns: true if @type is a type in the machine's list of > + * dynamically pluggable sysbus devices; otherwise false. > + * > + * Check if the QOM type @type is in the list of allowed sysbus device > + * types (see machine_class_allowed_dynamic_sysbus_dev()). > + * Note that if @type is a subtype of a type which is in the list, it is > + * allowed too. > + */ > +bool machine_class_is_dynamic_sysbus_dev_allowed(MachineClass *mc, > + const char *type); > + How about renaming this to device_type_is_allowed_dynamic_sysbus() ? > /** > * device_is_dynamic_sysbus: test whether device is a dynamic sysbus device > * @mc: Machine class > diff --git a/hw/core/machine.c b/hw/core/machine.c > index 9125c9aad0..1a18912dc8 100644 > --- a/hw/core/machine.c > +++ b/hw/core/machine.c > @@ -545,18 +545,27 @@ void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type) > > bool device_is_dynamic_sysbus(MachineClass *mc, DeviceState *dev) > { > - bool allowed = false; > - strList *wl; > Object *obj = OBJECT(dev); > > if (!object_dynamic_cast(obj, TYPE_SYS_BUS_DEVICE)) { > return false; > } > > + return machine_class_is_dynamic_sysbus_dev_allowed(mc, > + object_get_typename(obj)); > +} > + > +bool machine_class_is_dynamic_sysbus_dev_allowed(MachineClass *mc, > + const char *type) > +{ > + bool allowed = false; > + strList *wl; > + ObjectClass *klass = object_class_by_name(type); > + > for (wl = mc->allowed_dynamic_sysbus_devices; > !allowed && wl; > wl = wl->next) { > - allowed |= !!object_dynamic_cast(obj, wl->value); > + allowed |= !!object_class_dynamic_cast(klass, wl->value); > } > > return allowed; > -- > 2.33.0 > > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BFC79C433EF for ; Thu, 23 Sep 2021 10:52:55 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 3F0C56023F for ; Thu, 23 Sep 2021 10:52:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3F0C56023F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=anisinha.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:60008 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTMLV-00016R-67 for qemu-devel@archiver.kernel.org; Thu, 23 Sep 2021 06:52:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34414) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTMKK-00087u-87 for qemu-devel@nongnu.org; Thu, 23 Sep 2021 06:51:40 -0400 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]:55964) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mTMK5-0005gh-1k for qemu-devel@nongnu.org; Thu, 23 Sep 2021 06:51:39 -0400 Received: by mail-pj1-x1029.google.com with SMTP id t20so4146075pju.5 for ; Thu, 23 Sep 2021 03:51:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anisinha-ca.20210112.gappssmtp.com; s=20210112; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=4fJXlclBbnkVQPBywtqy0QsfK3GLzEGhebPQ86PZ4yM=; b=UwDv30mJvlcUbc5vsqv5ShtJ3oE0rdWz5cuSzKVT1VMx7oOAhptBwIZn+62mHKdIda CcTYo+EH+KpGcDyZdaNnrJToFa4sWqSUcsxSlx9OQMQwM6QNX2Bww7OSG0RQXXbD3De5 /pWCE/0WJrdF+Yon0++dBCaOxfyz5xkXytI1DQ+bx6EBoEMTn9XJoS68bJ+H7GOwtgB8 qoSCK6s0PZy1TP/XYoD8RYoHjlNP3fM2zc0dTANnUrIbLemr+exTR/fR3LouYTH11512 q0A2gT3vXM5gNC++K3kAcqiW6ZU/MP54Ed6BdACd1DXgZye8fizrfC83ybMpvRifxhXA lPMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=4fJXlclBbnkVQPBywtqy0QsfK3GLzEGhebPQ86PZ4yM=; b=WM4p10HxgcxQUe556arl3NOW3VWilmHfk5tRBbgQ5kpjG0Wi1Fjnkb+b1ad+BMFs0a COCBWa9qkkVxyinLalVDY4qwFL/0YspGrjCsdUTxCgSM5i9m0qDGID1w8n0Ffp8H7ra1 gRPcxY5nDejd8pEfPzB2IQFdNL4WuMU2/Aizj2PBZrrl/rm0RzuYs5QTfjD/GSQ7kuw1 KiVPfgKUqQqeTKNZ6Gl56be/mrjlXuzlo2ZYGW2lAurQ4X2F1LP4nsTdc8n3rXMoLBxk 2rQDIRwW1Uffuufan9nfYvSapNhP/6KfcQRqALT+Vr3uI8O0jlgntEFmNTqn9VFzt4JF D2tQ== X-Gm-Message-State: AOAM532gMydzkKDz7CO6Ghc0tIoehqSdMax3io6qOvH8jt1kYMRunofI sqz75a4eEEfp6/D620y4FWC9yg== X-Google-Smtp-Source: ABdhPJzia+90/vmutfv9+OVhfiSOiEAHqZONBLVWc1gCXXoo34eh7DSYhO2/LLO7Y/O8VFiKodZgxw== X-Received: by 2002:a17:90b:4d8f:: with SMTP id oj15mr4553491pjb.13.1632394282429; Thu, 23 Sep 2021 03:51:22 -0700 (PDT) Received: from anisinha-lenovo ([115.96.156.170]) by smtp.googlemail.com with ESMTPSA id e13sm5257765pfi.210.2021.09.23.03.51.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 03:51:21 -0700 (PDT) From: Ani Sinha X-Google-Original-From: Ani Sinha Date: Thu, 23 Sep 2021 16:21:11 +0530 (IST) X-X-Sender: anisinha@anisinha-lenovo To: Damien Hedde Subject: Re: [RFC PATCH v2 07/16] hw/core/machine: add machine_class_is_dynamic_sysbus_dev_allowed In-Reply-To: <20210922161405.140018-8-damien.hedde@greensocs.com> Message-ID: References: <20210922161405.140018-1-damien.hedde@greensocs.com> <20210922161405.140018-8-damien.hedde@greensocs.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Received-SPF: none client-ip=2607:f8b0:4864:20::1029; envelope-from=ani@anisinha.ca; helo=mail-pj1-x1029.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no 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: Peter Maydell , "Michael S. Tsirkin" , David Hildenbrand , qemu-devel@nongnu.org, Peter Xu , mirela.grujic@greensocs.com, Alistair Francis , Gerd Hoffmann , Ani Sinha , Eric Blake , Stefano Stabellini , xen-devel@lists.xenproject.org, Paul Durrant , Markus Armbruster , Anthony Perard , =?ISO-8859-15?Q?Marc-Andr=E9_Lureau?= , Eduardo Habkost , "Dr. David Alan Gilbert" , Eric Auger , Paolo Bonzini , qemu-riscv@nongnu.org, =?ISO-8859-15?Q?Daniel_P=2E_Berrang=E9?= , mark.burton@greensocs.com, edgari@xilinx.com, Igor Mammedov Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Wed, 22 Sep 2021, Damien Hedde wrote: > Right now the allowance check for adding a sysbus device using > -device cli option (or device_add qmp command) is done well after > the device has been created. It is done during the machine init done > notifier: machine_init_notify() in hw/core/machine.c > > This new function will allow us to check if a sysbus device type is > allowed to be dynamically created by the machine during the device > creation time. > > Also make device_is_dynamic_sysbus() use the new function. > > Signed-off-by: Damien Hedde > --- > > In the context of our series, we need to be able to do the check at > device creation time to allow doing it depending on the current > MACHINE_INIT phase. > --- > include/hw/boards.h | 17 +++++++++++++++++ > hw/core/machine.c | 15 ++++++++++++--- > 2 files changed, 29 insertions(+), 3 deletions(-) > > diff --git a/include/hw/boards.h b/include/hw/boards.h > index 463a5514f9..934443c1cd 100644 > --- a/include/hw/boards.h > +++ b/include/hw/boards.h > @@ -51,6 +51,23 @@ void machine_set_cpu_numa_node(MachineState *machine, > */ > void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type); > > +/** > + * machine_class_is_dynamic_sysbus_dev_allowed: Check if type is an allowed > + * sysbus device type for the machine class. > + * @mc: Machine class > + * @type: type to check (should be a subtype of TYPE_SYS_BUS_DEVICE) > + * > + * Returns: true if @type is a type in the machine's list of > + * dynamically pluggable sysbus devices; otherwise false. > + * > + * Check if the QOM type @type is in the list of allowed sysbus device > + * types (see machine_class_allowed_dynamic_sysbus_dev()). > + * Note that if @type is a subtype of a type which is in the list, it is > + * allowed too. > + */ > +bool machine_class_is_dynamic_sysbus_dev_allowed(MachineClass *mc, > + const char *type); > + How about renaming this to device_type_is_allowed_dynamic_sysbus() ? > /** > * device_is_dynamic_sysbus: test whether device is a dynamic sysbus device > * @mc: Machine class > diff --git a/hw/core/machine.c b/hw/core/machine.c > index 9125c9aad0..1a18912dc8 100644 > --- a/hw/core/machine.c > +++ b/hw/core/machine.c > @@ -545,18 +545,27 @@ void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type) > > bool device_is_dynamic_sysbus(MachineClass *mc, DeviceState *dev) > { > - bool allowed = false; > - strList *wl; > Object *obj = OBJECT(dev); > > if (!object_dynamic_cast(obj, TYPE_SYS_BUS_DEVICE)) { > return false; > } > > + return machine_class_is_dynamic_sysbus_dev_allowed(mc, > + object_get_typename(obj)); > +} > + > +bool machine_class_is_dynamic_sysbus_dev_allowed(MachineClass *mc, > + const char *type) > +{ > + bool allowed = false; > + strList *wl; > + ObjectClass *klass = object_class_by_name(type); > + > for (wl = mc->allowed_dynamic_sysbus_devices; > !allowed && wl; > wl = wl->next) { > - allowed |= !!object_dynamic_cast(obj, wl->value); > + allowed |= !!object_class_dynamic_cast(klass, wl->value); > } > > return allowed; > -- > 2.33.0 > >