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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF9B7C433F5 for ; Tue, 12 Oct 2021 23:08: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 5896D60C4B for ; Tue, 12 Oct 2021 23:08:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5896D60C4B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.207767.363677 (Exim 4.92) (envelope-from ) id 1maQsP-0003oI-Ex; Tue, 12 Oct 2021 23:08:05 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 207767.363677; Tue, 12 Oct 2021 23:08:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1maQsP-0003oB-BV; Tue, 12 Oct 2021 23:08:05 +0000 Received: by outflank-mailman (input) for mailman id 207767; Tue, 12 Oct 2021 23:08:04 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1maQsO-0003o5-Qi for xen-devel@lists.xenproject.org; Tue, 12 Oct 2021 23:08:04 +0000 Received: from mail-io1-xd2d.google.com (unknown [2607:f8b0:4864:20::d2d]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 3303686c-96ed-483c-8441-e169d5e2b41b; Tue, 12 Oct 2021 23:08:03 +0000 (UTC) Received: by mail-io1-xd2d.google.com with SMTP id i189so717168ioa.1 for ; Tue, 12 Oct 2021 16:08:03 -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: 3303686c-96ed-483c-8441-e169d5e2b41b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=D23sb8bFeCXI94xUkUzdKmg69G7zDAbwqduFczWfvKA=; b=Es3UE5dss4rZylCN7k44ApvHlCaGU4yXyfFXVgiwjK++fiVIj2AKyYlhX4iAoXUJOm CtSsoA4ibc2vMn9zCCRDTEOys3irqDNERLbvfsl8FtIskFvMfYPIxDmhYNrSBO6XV0hi FOvfleplF/JVnW1XO/X1GH23yuGwJN5Td7ReeJ5nhPGgxCrQwYOAJfV9mWo/s7aGoAHx hgwBiim7ZtjYHhe8Upjehw7vm9f6ONaDVoNk8y1ytrp2plFJEBsprIw21sUuNsYSYnwc B/NTXWA9gpi42gCU9Q//B3uCy6IkbzHo6gsWN7PflOKs4cmdY6C+GuFuof6yViEAJVIw 0jpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=D23sb8bFeCXI94xUkUzdKmg69G7zDAbwqduFczWfvKA=; b=PI6EXbWl1aAla2DouH81zCUw5PWGHXZPhsKLxK+5nwIiOXOnZrdDe68JZSY356KNNb 0Qp+ivnMY1n7+0bBIH+wINzdxa6VjfZ307k3K7SGxVHGn3udOjO6a4l+QhssTWez+ZYY MXKepIjmBeHv3cCOqLdlB56CNwmMc6neKPFQQ6xun62rBgw2NToG5VvRMuGnbh7zdE1a sN25akHKAG1d9cOBBlcfKKe1SBRAsUiHyMEO6O7BP9fL+/PgRBAo/SpbYLOHa5CfKOo4 a4GWHydU+UKk2W7c2uE19KefYoV3k5J2bxVR4HrKf2KlD3dTo6ygiyLyp7HFqHwzduDy vqkw== X-Gm-Message-State: AOAM532zU5X0Ir78QYv+WmXlg8NCLOnJ91vrRYGSDYftzgOs4mMqySqR DK7BEoo+xzDfFIwnsIT9cWjgL4i2MnVq9zOQn0Y= X-Google-Smtp-Source: ABdhPJxDPo9qtToO6ewaPjuNrBsi+QXGD1yiMTi37OJGplkSUxNlRnlVrO+pWqYJmSF5JUPbJAj3fBICmq3UUqxD/5U= X-Received: by 2002:a05:6638:1483:: with SMTP id j3mr25110746jak.63.1634080083372; Tue, 12 Oct 2021 16:08:03 -0700 (PDT) MIME-Version: 1.0 References: <20210922161405.140018-1-damien.hedde@greensocs.com> <20210922161405.140018-10-damien.hedde@greensocs.com> In-Reply-To: <20210922161405.140018-10-damien.hedde@greensocs.com> From: Alistair Francis Date: Wed, 13 Oct 2021 09:07:37 +1000 Message-ID: Subject: Re: [RFC PATCH v2 09/16] hw/core/machine: Remove the dynamic sysbus devices type check To: Damien Hedde Cc: "qemu-devel@nongnu.org Developers" , Peter Maydell , "Michael S. Tsirkin" , David Hildenbrand , Peter Xu , mirela.grujic@greensocs.com, Alistair Francis , Gerd Hoffmann , Ani Sinha , Eric Blake , Stefano Stabellini , "open list:X86" , Paul Durrant , Markus Armbruster , Anthony Perard , =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= , Eduardo Habkost , "Dr. David Alan Gilbert" , Eric Auger , Paolo Bonzini , "open list:RISC-V" , =?UTF-8?Q?Daniel_P=2E_Berrang=C3=A9?= , Mark Burton , Edgar Iglesias , Igor Mammedov Content-Type: text/plain; charset="UTF-8" On Thu, Sep 23, 2021 at 2:23 AM Damien Hedde wrote: > > Now that we check sysbus device types during device creation, we > can remove the check done in the machine init done notifier. > This was the only thing done by this notifier, so we remove the > whole sysbus_notifier structure of the MachineState. > > Note: This notifier was checking all /peripheral and /peripheral-anon > sysbus devices. Now we only check those added by -device cli option or > device_add qmp command when handling the command/option. So if there > are some devices added in one of these containers manually (eg in > machine C code), these will not be checked anymore. > This use case does not seem to appear apart from > hw/xen/xen-legacy-backend.c (it uses qdev_set_id() and in this case, > not for a sysbus device, so it's ok). > > Signed-off-by: Damien Hedde Acked-by: Alistair Francis Alistair > --- > include/hw/boards.h | 1 - > hw/core/machine.c | 27 --------------------------- > 2 files changed, 28 deletions(-) > > diff --git a/include/hw/boards.h b/include/hw/boards.h > index 934443c1cd..ccbc40355a 100644 > --- a/include/hw/boards.h > +++ b/include/hw/boards.h > @@ -311,7 +311,6 @@ typedef struct CpuTopology { > struct MachineState { > /*< private >*/ > Object parent_obj; > - Notifier sysbus_notifier; > > /*< public >*/ > > diff --git a/hw/core/machine.c b/hw/core/machine.c > index 1a18912dc8..521438e90a 100644 > --- a/hw/core/machine.c > +++ b/hw/core/machine.c > @@ -571,18 +571,6 @@ bool machine_class_is_dynamic_sysbus_dev_allowed(MachineClass *mc, > return allowed; > } > > -static void validate_sysbus_device(SysBusDevice *sbdev, void *opaque) > -{ > - MachineState *machine = opaque; > - MachineClass *mc = MACHINE_GET_CLASS(machine); > - > - if (!device_is_dynamic_sysbus(mc, DEVICE(sbdev))) { > - error_report("Option '-device %s' cannot be handled by this machine", > - object_class_get_name(object_get_class(OBJECT(sbdev)))); > - exit(1); > - } > -} > - > static char *machine_get_memdev(Object *obj, Error **errp) > { > MachineState *ms = MACHINE(obj); > @@ -598,17 +586,6 @@ static void machine_set_memdev(Object *obj, const char *value, Error **errp) > ms->ram_memdev_id = g_strdup(value); > } > > -static void machine_init_notify(Notifier *notifier, void *data) > -{ > - MachineState *machine = MACHINE(qdev_get_machine()); > - > - /* > - * Loop through all dynamically created sysbus devices and check if they are > - * all allowed. If a device is not allowed, error out. > - */ > - foreach_dynamic_sysbus_device(validate_sysbus_device, machine); > -} > - > HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine) > { > int i; > @@ -1030,10 +1007,6 @@ static void machine_initfn(Object *obj) > "Table (HMAT)"); > } > > - /* Register notifier when init is done for sysbus sanity checks */ > - ms->sysbus_notifier.notify = machine_init_notify; > - qemu_add_machine_init_done_notifier(&ms->sysbus_notifier); > - > /* default to mc->default_cpus */ > ms->smp.cpus = mc->default_cpus; > ms->smp.max_cpus = mc->default_cpus; > -- > 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7021AC433EF for ; Tue, 12 Oct 2021 23:09:23 +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 9D6D360C4B for ; Tue, 12 Oct 2021 23:09:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9D6D360C4B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:44546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1maQtd-0007oA-Cy for qemu-devel@archiver.kernel.org; Tue, 12 Oct 2021 19:09:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44008) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maQsT-0006Xo-Qc; Tue, 12 Oct 2021 19:08:09 -0400 Received: from mail-io1-xd35.google.com ([2607:f8b0:4864:20::d35]:45884) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1maQsO-0004pL-Tb; Tue, 12 Oct 2021 19:08:09 -0400 Received: by mail-io1-xd35.google.com with SMTP id b10so658205iof.12; Tue, 12 Oct 2021 16:08:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=D23sb8bFeCXI94xUkUzdKmg69G7zDAbwqduFczWfvKA=; b=Es3UE5dss4rZylCN7k44ApvHlCaGU4yXyfFXVgiwjK++fiVIj2AKyYlhX4iAoXUJOm CtSsoA4ibc2vMn9zCCRDTEOys3irqDNERLbvfsl8FtIskFvMfYPIxDmhYNrSBO6XV0hi FOvfleplF/JVnW1XO/X1GH23yuGwJN5Td7ReeJ5nhPGgxCrQwYOAJfV9mWo/s7aGoAHx hgwBiim7ZtjYHhe8Upjehw7vm9f6ONaDVoNk8y1ytrp2plFJEBsprIw21sUuNsYSYnwc B/NTXWA9gpi42gCU9Q//B3uCy6IkbzHo6gsWN7PflOKs4cmdY6C+GuFuof6yViEAJVIw 0jpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=D23sb8bFeCXI94xUkUzdKmg69G7zDAbwqduFczWfvKA=; b=AteYja1sNkjo/JE0k2GQOzUWsa5EOShuu5dy4zDaeujrt6mGXpdjH7RQ40pBt/3hL9 xzhWdgTZDLMybsewUxsGzeoGF49IpIeyPCXTYtwBlkP25TRo7HTRAWtEDr6evk9o/GP8 unw2dzduyn9CfH+POgYoIAFC2eW+X2ENt2nmbUq70zGs4x2cmAarWF6ONxw00oyKNACt xDF0cij4q2LZjBNKZvK5hqQcMqg8TKdu5NNV3EYsmp5qpzCgaJnOB6+Ckj6hwhQfzmfS 518NH4Jls0GXd5zExRodM7Sd0MvgSWVupfF6Vs7jgVQmMY9DzoOQOirp30o6Feq96Rgk YUvA== X-Gm-Message-State: AOAM533Yi7blOq1GeWCNC5OMvbdHiDZtrWfCPL/HJTLNP7zcZKI1+gis 48hO4rSWXl7nVIDQ4q5P1e50xVQ1n4iXbIOTMIM= X-Google-Smtp-Source: ABdhPJxDPo9qtToO6ewaPjuNrBsi+QXGD1yiMTi37OJGplkSUxNlRnlVrO+pWqYJmSF5JUPbJAj3fBICmq3UUqxD/5U= X-Received: by 2002:a05:6638:1483:: with SMTP id j3mr25110746jak.63.1634080083372; Tue, 12 Oct 2021 16:08:03 -0700 (PDT) MIME-Version: 1.0 References: <20210922161405.140018-1-damien.hedde@greensocs.com> <20210922161405.140018-10-damien.hedde@greensocs.com> In-Reply-To: <20210922161405.140018-10-damien.hedde@greensocs.com> From: Alistair Francis Date: Wed, 13 Oct 2021 09:07:37 +1000 Message-ID: Subject: Re: [RFC PATCH v2 09/16] hw/core/machine: Remove the dynamic sysbus devices type check To: Damien Hedde Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2607:f8b0:4864:20::d35; envelope-from=alistair23@gmail.com; helo=mail-io1-xd35.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-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 , David Hildenbrand , "qemu-devel@nongnu.org Developers" , Peter Xu , mirela.grujic@greensocs.com, Alistair Francis , Gerd Hoffmann , Ani Sinha , Eric Blake , Stefano Stabellini , "Michael S. Tsirkin" , Markus Armbruster , Anthony Perard , =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= , Igor Mammedov , Eduardo Habkost , "Dr. David Alan Gilbert" , Paul Durrant , Eric Auger , "open list:X86" , "open list:RISC-V" , =?UTF-8?Q?Daniel_P=2E_Berrang=C3=A9?= , Mark Burton , Edgar Iglesias , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Thu, Sep 23, 2021 at 2:23 AM Damien Hedde wrote: > > Now that we check sysbus device types during device creation, we > can remove the check done in the machine init done notifier. > This was the only thing done by this notifier, so we remove the > whole sysbus_notifier structure of the MachineState. > > Note: This notifier was checking all /peripheral and /peripheral-anon > sysbus devices. Now we only check those added by -device cli option or > device_add qmp command when handling the command/option. So if there > are some devices added in one of these containers manually (eg in > machine C code), these will not be checked anymore. > This use case does not seem to appear apart from > hw/xen/xen-legacy-backend.c (it uses qdev_set_id() and in this case, > not for a sysbus device, so it's ok). > > Signed-off-by: Damien Hedde Acked-by: Alistair Francis Alistair > --- > include/hw/boards.h | 1 - > hw/core/machine.c | 27 --------------------------- > 2 files changed, 28 deletions(-) > > diff --git a/include/hw/boards.h b/include/hw/boards.h > index 934443c1cd..ccbc40355a 100644 > --- a/include/hw/boards.h > +++ b/include/hw/boards.h > @@ -311,7 +311,6 @@ typedef struct CpuTopology { > struct MachineState { > /*< private >*/ > Object parent_obj; > - Notifier sysbus_notifier; > > /*< public >*/ > > diff --git a/hw/core/machine.c b/hw/core/machine.c > index 1a18912dc8..521438e90a 100644 > --- a/hw/core/machine.c > +++ b/hw/core/machine.c > @@ -571,18 +571,6 @@ bool machine_class_is_dynamic_sysbus_dev_allowed(MachineClass *mc, > return allowed; > } > > -static void validate_sysbus_device(SysBusDevice *sbdev, void *opaque) > -{ > - MachineState *machine = opaque; > - MachineClass *mc = MACHINE_GET_CLASS(machine); > - > - if (!device_is_dynamic_sysbus(mc, DEVICE(sbdev))) { > - error_report("Option '-device %s' cannot be handled by this machine", > - object_class_get_name(object_get_class(OBJECT(sbdev)))); > - exit(1); > - } > -} > - > static char *machine_get_memdev(Object *obj, Error **errp) > { > MachineState *ms = MACHINE(obj); > @@ -598,17 +586,6 @@ static void machine_set_memdev(Object *obj, const char *value, Error **errp) > ms->ram_memdev_id = g_strdup(value); > } > > -static void machine_init_notify(Notifier *notifier, void *data) > -{ > - MachineState *machine = MACHINE(qdev_get_machine()); > - > - /* > - * Loop through all dynamically created sysbus devices and check if they are > - * all allowed. If a device is not allowed, error out. > - */ > - foreach_dynamic_sysbus_device(validate_sysbus_device, machine); > -} > - > HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine) > { > int i; > @@ -1030,10 +1007,6 @@ static void machine_initfn(Object *obj) > "Table (HMAT)"); > } > > - /* Register notifier when init is done for sysbus sanity checks */ > - ms->sysbus_notifier.notify = machine_init_notify; > - qemu_add_machine_init_done_notifier(&ms->sysbus_notifier); > - > /* default to mc->default_cpus */ > ms->smp.cpus = mc->default_cpus; > ms->smp.max_cpus = mc->default_cpus; > -- > 2.33.0 > >