On Fri, 2014-03-07 at 00:44 +0100, Andreas Färber wrote:
> Am 05.03.2014 18:30, schrieb Marcel Apfelbaum:
> > In order to allow attaching machine options to a machine instance,
> > current_machine is converted into MachineState.
> > As a first step of deprecating QEMUMachine, some of the functions
> > were modified to return MachineCLass.
> > 
> > Signed-off-by: Marcel Apfelbaum <marce...@redhat.com>
> 
> Looks mostly good, but same issue as Alexey's patch: We are risking
> qdev_get_machine() creating a Container-typed /machine node.
> 
> What about the following on top?
Hi Andreas,

I checked with the debugger and qdev_get_machine is called
long after we add the machine to the QOM tree.
However, the race still exists as someone can call qdev_get_machine
before the machine is added to the tree, not being aware of that.

Your change solves the problem, thank you!
Do you want me to add this diff and resend,
or I will send yours separately?

Thanks,
Marcel

> 
> Alexey, if we reach agreement here, this means for you that we can just
> use type_register_static() in place of qemu_machine_register() to
> register your custom machine type with interface added.
> 
> Regards,
> Andreas
> 
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index b6deebd..749c83a 100644
> --- a/hw/core/qdev.c
> +++ b/hw/core/qdev.c
> @@ -861,7 +861,8 @@ Object *qdev_get_machine(void)
>      static Object *dev;
> 
>      if (dev == NULL) {
> -        dev = container_get(object_get_root(), "/machine");
> +        dev = object_resolve_path("/machine", NULL);
> +        g_assert(dev);
>      }
> 
>      return dev;
> 
> 




Reply via email to