qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 4/4] qdev-hotplug: Don't check type of qdev_get_


From: Philippe Mathieu-Daudé
Subject: Re: [Qemu-devel] [PATCH 4/4] qdev-hotplug: Don't check type of qdev_get_machine()
Date: Mon, 1 Nov 2021 19:03:04 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0

On 4/25/19 22:00, Eduardo Habkost wrote:
> Now that qdev_get_machine_hotplug_handler() is only compiled in
> softmmu mode, we don't need to check if qdev_gt_machine() is
> really of type TYPE_MACHINE.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>  hw/core/qdev-hotplug.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/hw/core/qdev-hotplug.c b/hw/core/qdev-hotplug.c
> index 8ab31043a7..017500c1e1 100644
> --- a/hw/core/qdev-hotplug.c
> +++ b/hw/core/qdev-hotplug.c
> @@ -35,16 +35,11 @@ void qbus_set_bus_hotplug_handler(BusState *bus, Error 
> **errp)
>  
>  HotplugHandler *qdev_get_machine_hotplug_handler(DeviceState *dev)
>  {
> -    MachineState *machine;
> -    MachineClass *mc;
> -    Object *m_obj = qdev_get_machine();
> +    MachineState *machine = MACHINE(qdev_get_machine());
> +    MachineClass *mc = MACHINE_GET_CLASS(machine);
>  
> -    if (object_dynamic_cast(m_obj, TYPE_MACHINE)) {
> -        machine = MACHINE(m_obj);
> -        mc = MACHINE_GET_CLASS(machine);
> -        if (mc->get_hotplug_handler) {
> -            return mc->get_hotplug_handler(machine, dev);
> -        }
> +    if (mc->get_hotplug_handler) {
> +        return mc->get_hotplug_handler(machine, dev);
>      }
>  
>      return NULL;
> 

I rebased this patch and tried it, but it fails 'check-unit':

Running test test-qdev-global-props
**
ERROR:../tests/unit/test-qdev-global-props.c:89:test_static_prop: child
process (/qdev/properties/static/default/subprocess [12678]) failed
unexpectedly
ERROR test-qdev-global-props - Bail out!
ERROR:../tests/unit/test-qdev-global-props.c:89:test_static_prop: child
process (/qdev/properties/static/default/subprocess [12678]) failed
unexpectedly
make: *** [Makefile.mtest:640: run-test-78] Error 1

Here the object is of type "container":

  Object *object_get_root(void)
  {
      static Object *root;

      if (!root) {
          root = object_new("container");
      }

      return root;
  }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]