diff mbox series

[v2,3/5] qdev-monitor: use the new user_creatable_requires_machine_allowance

Message ID 20220331115312.30018-4-damien.hedde@greensocs.com
State New
Headers show
Series Generalize the sysbus device machine allowance | expand

Commit Message

Damien Hedde March 31, 2022, 11:53 a.m. UTC
Instead of checking if the device is a sysbus device, just check
the newly added flag in device class.

Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>
---

v2: update the flag name
---
 softmmu/qdev-monitor.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Edgar E. Iglesias April 7, 2022, 1:07 p.m. UTC | #1
On Thu, Mar 31, 2022 at 01:53:10PM +0200, Damien Hedde wrote:
> Instead of checking if the device is a sysbus device, just check
> the newly added flag in device class.
> 
> Signed-off-by: Damien Hedde <damien.hedde@greensocs.com>

Reviewed-by: Edgar E. Iglesias <edgar.iglesias@amd.com>


> ---
> 
> v2: update the flag name
> ---
>  softmmu/qdev-monitor.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
> index 12fe60c467..77f468358d 100644
> --- a/softmmu/qdev-monitor.c
> +++ b/softmmu/qdev-monitor.c
> @@ -258,12 +258,12 @@ 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 (dc->user_creatable_requires_machine_allowance) {
> +        /* some 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)) {
> +        if (!device_type_is_dynamic_allowed(mc, *driver)) {
>              error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "driver",
> -                       "a dynamic sysbus device type for the machine");
> +                       "the device type is not allowed for this machine");
>              return NULL;
>          }
>      }
> -- 
> 2.35.1
> 
>
diff mbox series

Patch

diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
index 12fe60c467..77f468358d 100644
--- a/softmmu/qdev-monitor.c
+++ b/softmmu/qdev-monitor.c
@@ -258,12 +258,12 @@  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 (dc->user_creatable_requires_machine_allowance) {
+        /* some 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)) {
+        if (!device_type_is_dynamic_allowed(mc, *driver)) {
             error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "driver",
-                       "a dynamic sysbus device type for the machine");
+                       "the device type is not allowed for this machine");
             return NULL;
         }
     }