qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] qdev_get_machine() can return something non-NULL but no


From: Igor Mammedov
Subject: Re: [Qemu-devel] qdev_get_machine() can return something non-NULL but not TYPE_MACHINE
Date: Tue, 12 Sep 2017 09:40:01 +0200

On Mon, 11 Sep 2017 14:33:03 +0100
Peter Maydell <address@hidden> wrote:

> On 11 September 2017 at 13:10, Igor Mammedov <address@hidden> wrote:
> > On Tue, 5 Sep 2017 10:08:01 +0100
> > Peter Maydell <address@hidden> wrote:
> >  
> >> On 4 September 2017 at 20:38, Igor Mammedov <address@hidden> wrote:  
> >> > On Mon, 4 Sep 2017 17:36:59 +0100
> >> > Peter Maydell <address@hidden> wrote:
> >> >  
> >> >> I just got bitten by qdev_get_machine()'s behaviour on the user-only
> >> >> emulators, where it can return something that isn't NULL and isn't
> >> >> an instance of TYPE_MACHINE either.  
> >> > user-only shouldn't get to qdev_get_machine() at all,
> >> > issue probably in container_get().  
> >>
> >> I need it in cpu_common_realizefn(), for
> >> http://patchwork.ozlabs.org/patch/797940/  
> > Link might be broken (unable to connect to server)  
> 
> Works for me, but it is in master now anyway, commit
> ed860129acd3fcd0b1.
> 
> > Anyways I'd avoid using machine from cpu_*_realizefn(),
> > instead of I'd add property to CPU that has needed data
> > and set it from board code. Should work fine for *-user targets
> > and maintain clear separation of device impl. and board details.  
> 
> It's not possible in all cases to set a CPU property from the
> top level board code. In quite a lot of cases the CPU
> object is created by an SoC object which is in turn
> created by the board code, and there is no plumbing
> there to pass arbitrary properties through to the CPU
> object...
there is a cleaner way without cpu accessing machine,
make it property of cpu and use compat machinery that
was invented for fixing up stuff of this kind.

SET_MACHINE_COMPAT(MachineClass,
                   { .driver = "arm-cpu",
                     .property = "foo",
                     .value    = "off",
                   }
                  )

> 
> thanks
> -- PMM




reply via email to

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