From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Damien Hedde <damien.hedde@greensocs.com>, qemu-devel@nongnu.org
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
"Eduardo Habkost" <ehabkost@redhat.com>,
mark.burton@greensocs.com, edgari@xilinx.com,
mirela.grujic@greensocs.com,
"Alistair Francis" <alistair.francis@wdc.com>,
"Ani Sinha" <ani@anisinha.ca>,
"Paolo Bonzini" <pbonzini@redhat.com>
Subject: Re: [PATCH v3 2/3] qdev-monitor: Check sysbus device type before creating it
Date: Fri, 29 Oct 2021 20:13:28 +0200 [thread overview]
Message-ID: <7594e869-e424-4df8-a0bd-0d600b47f3f8@redhat.com> (raw)
In-Reply-To: <aedc893d-79bf-1d3c-74d6-8388d0d1915c@redhat.com>
On 10/29/21 19:34, Philippe Mathieu-Daudé wrote:
> On 10/29/21 16:22, Damien Hedde wrote:
>> Add an early check to test if the requested sysbus device type
>> is allowed by the current machine before creating the device. This
>> impacts both -device cli option and device_add qmp command.
>>
>> Before this patch, the check was done well after the device has
>> been created (in a machine init done notifier).
Before / Until? Also you could mention "in a machine init_done
notifier, which we will remove in the next commit".
>> We can now report
>> the error right away.
>>
>> Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
>> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
>> ---
>>
>> v3: update error message
>> ---
>> softmmu/qdev-monitor.c | 11 +++++++++++
>
> /me wonders why this file is named '-monitor'.
>
>> diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
>> index 4851de51a5..e49d9773d2 100644
>> --- a/softmmu/qdev-monitor.c
>> +++ b/softmmu/qdev-monitor.c
>> @@ -42,6 +42,7 @@
>> #include "qemu/cutils.h"
>> #include "hw/qdev-properties.h"
>> #include "hw/clock.h"
>> +#include "hw/boards.h"
>>
>> /*
>> * Aliases were a bad idea from the start. Let's keep them
>> @@ -254,6 +255,16 @@ 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 */
>> + MachineClass *mc = MACHINE_CLASS(object_get_class(qdev_get_machine()));
>> + if (!device_type_is_dynamic_sysbus(mc, *driver)) {
>> + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "driver",
>
> Per include/qapi/qmp/qerror.h:
>
> /*
> * These macros will go away, please don't use in new code, and do not
> * add new ones!
> */
>
> #define QERR_INVALID_PARAMETER_VALUE \
> "Parameter '%s' expects %s"
>
>> + "a dynamic sysbus device type for the machine");
>
> Besides, this is easier to read:
>
> error_setg(errp, "Parameter 'driver' expects a dynamic"
> " sysbus device type for the machine");
>
> Maybe remove QERR_INVALID_PARAMETER_VALUE from qdev_get_device_class()
> in a preliminary patch?
>
> Otherwise:
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>
>> + return NULL;
>> + }
>> + }
>> +
>> return dc;
>> }
>>
>>
>
next prev parent reply other threads:[~2021-10-29 18:33 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-29 14:22 [PATCH v3 0/3] Dynamic sysbus device check error report Damien Hedde
2021-10-29 14:22 ` [PATCH v3 1/3] machine: add device_type_is_dynamic_sysbus function Damien Hedde
2021-10-29 17:25 ` Philippe Mathieu-Daudé
2021-10-31 23:36 ` Alistair Francis
2021-10-29 14:22 ` [PATCH v3 2/3] qdev-monitor: Check sysbus device type before creating it Damien Hedde
2021-10-29 17:34 ` Philippe Mathieu-Daudé
2021-10-29 18:13 ` Philippe Mathieu-Daudé [this message]
2021-10-29 14:22 ` [PATCH v3 3/3] machine: remove the done notifier for dynamic sysbus device type check Damien Hedde
2021-10-29 19:59 ` Philippe Mathieu-Daudé
2021-10-29 20:00 ` [PATCH v3 0/3] Dynamic sysbus device check error report Philippe Mathieu-Daudé
2021-11-01 15:18 ` Eduardo Habkost
2021-11-01 18:30 ` Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7594e869-e424-4df8-a0bd-0d600b47f3f8@redhat.com \
--to=philmd@redhat.com \
--cc=alistair.francis@wdc.com \
--cc=ani@anisinha.ca \
--cc=berrange@redhat.com \
--cc=damien.hedde@greensocs.com \
--cc=edgari@xilinx.com \
--cc=ehabkost@redhat.com \
--cc=mark.burton@greensocs.com \
--cc=mirela.grujic@greensocs.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).