On Mon, 11 Sep 2017 14:33:03 +0100 Peter Maydell <peter.mayd...@linaro.org> wrote:
> On 11 September 2017 at 13:10, Igor Mammedov <imamm...@redhat.com> wrote: > > On Tue, 5 Sep 2017 10:08:01 +0100 > > Peter Maydell <peter.mayd...@linaro.org> wrote: > > > >> On 4 September 2017 at 20:38, Igor Mammedov <imamm...@redhat.com> wrote: > >> > On Mon, 4 Sep 2017 17:36:59 +0100 > >> > Peter Maydell <peter.mayd...@linaro.org> 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