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 464FDC433F5 for ; Thu, 23 Sep 2021 11:04:26 +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 0D4C260F6B for ; Thu, 23 Sep 2021 11:04:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0D4C260F6B 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.193697.345037 (Exim 4.92) (envelope-from ) id 1mTMWW-0003CX-B0; Thu, 23 Sep 2021 11:04:16 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 193697.345037; Thu, 23 Sep 2021 11:04:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mTMWW-0003CQ-7y; Thu, 23 Sep 2021 11:04:16 +0000 Received: by outflank-mailman (input) for mailman id 193697; Thu, 23 Sep 2021 11:04:15 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mTMWV-0003CK-0Z for xen-devel@lists.xenproject.org; Thu, 23 Sep 2021 11:04:15 +0000 Received: from mail-pl1-x635.google.com (unknown [2607:f8b0:4864:20::635]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0c47e261-347c-4037-9779-92573c3ef51e; Thu, 23 Sep 2021 11:04:13 +0000 (UTC) Received: by mail-pl1-x635.google.com with SMTP id w11so3728624plz.13 for ; Thu, 23 Sep 2021 04:04:13 -0700 (PDT) Received: from anisinha-lenovo ([115.96.156.170]) by smtp.googlemail.com with ESMTPSA id 126sm6890764pgi.86.2021.09.23.04.04.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 04:04:12 -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: 0c47e261-347c-4037-9779-92573c3ef51e 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=1RxHU6ohg85S859gdTN8SmlrMapEypB3sVeaylhNzKc=; b=xp676m60NgY6Pdk+CpLb9v69Dv7cEYtiwmfwoFGZ7BHxLWSfF5ZC3a2ws4uSjGuOPf 4TZzaTD+knuMaYTye3KpEj338NPh5Ff76gGjAjREmiiyTFOoTaBAbUb8MkDxQH90wkYg xlFeVbThhDtvCrKK+wJ+Dy+E2elCJ6oW1f75VWa0LVveVn6aP92rVU4ar8U4sIi1N2a/ ymrDK13CEBTLq5G7O4r16iQe5Wgb97+pgZpswQaZjm2PZb6URvfdknz0qcX2ENrqjP8T amsF0+DqaiUPp74kE1Nku+dzo/fKWirhwT9B3cjbaPY7tNoqTusSwBX+bu8idJDfmvWd sJjg== 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=1RxHU6ohg85S859gdTN8SmlrMapEypB3sVeaylhNzKc=; b=RqLgoHUk9Hc18eNA+NCtS8RLn83Oepo2N34HOqT/s9/4SXbRDqh9Z1COI3CXYDRz4u AY7rr3rhpGrvsFQsGTzE1GkmBbTJYvEKaEm7T3volUhfXTd3HhJQ3kjPCTyZrA58WTLj TrNp5Wp0fcAHnfclb6kN7mR3/vQvVtnjXqxxx1cdIMMZR6amPdheX9TxaB+zCeGCHYsw 56cTqrsr0WRkRlCwGwSdp41OllDNCURu8JXleB94Dm2IqeiXpWykYSi11JPi8rDKLdWi QoNkZ3dueyi8Ecr2+4H0bR5jwDP6wF/TNG0kERqzSDR+RQnQNK1j0ycV8Cxe10XXoPDt tYyQ== X-Gm-Message-State: AOAM532FPzRCIs5pPEza56zaJoAr23OAoujlF5GRF6p7tsruXNzqhATm izjBdvZ61CCv9Wcob4aYsJPkkA== X-Google-Smtp-Source: ABdhPJxBS6AGfLPmzLRaQHRFmVjDVoRSyb6vHulAN4aGINKZzpCa+OGlRLA+YQyj5ZUQtE0f9I/NeA== X-Received: by 2002:a17:90b:4a4c:: with SMTP id lb12mr16930916pjb.55.1632395052788; Thu, 23 Sep 2021 04:04:12 -0700 (PDT) From: Ani Sinha X-Google-Original-From: Ani Sinha Date: Thu, 23 Sep 2021 16:34:01 +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 10/16] qdev-monitor: allow adding any sysbus device before machine is ready In-Reply-To: <20210922161405.140018-11-damien.hedde@greensocs.com> Message-ID: References: <20210922161405.140018-1-damien.hedde@greensocs.com> <20210922161405.140018-11-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: > Skip the sysbus device type per-machine allow-list check before the > MACHINE_INIT_PHASE_READY phase. > > This patch permits adding any sysbus device (it still needs to be > user_creatable) when using the -preconfig experimental option. > > Signed-off-by: Damien Hedde > --- > > This commit is RFC. Depending on the condition to allow a device > to be added, it may change. > --- > softmmu/qdev-monitor.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c > index f1c9242855..73b991adda 100644 > --- a/softmmu/qdev-monitor.c > +++ b/softmmu/qdev-monitor.c > @@ -269,8 +269,13 @@ static DeviceClass *qdev_get_device_class(const char **driver, Error **errp) > return NULL; > } > > - if (object_class_dynamic_cast(oc, TYPE_SYS_BUS_DEVICE)) { > - /* sysbus devices need to be allowed by the machine */ > + if (object_class_dynamic_cast(oc, TYPE_SYS_BUS_DEVICE) && > + phase_check(MACHINE_INIT_PHASE_READY)) { > + /* > + * Sysbus devices need to be allowed by the machine. > + * We only check that after the machine is ready in order to let > + * us add any user_creatable sysbus device during machine creation. > + */ > MachineClass *mc = MACHINE_CLASS(object_get_class(qdev_get_machine())); > if (!machine_class_is_dynamic_sysbus_dev_allowed(mc, *driver)) { > error_setg(errp, "'%s' is not an allowed pluggable sysbus device " Since now you are adding the state of the machine creation in the valiation condition, the failure error message becomes misleading. Better to do this I think : if (object class is TYPE_SYS_BUS_DEVICE) { if (!phase_check(MACHINE_INIT_PHASE_READY)) { // error out here saying the state of the machine creation is too early } // do the other check on dynamic sysbus }