qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 10/15] memory: Replace current_machine by qdev_get_machine()


From: Alistair Francis
Subject: Re: [PATCH 10/15] memory: Replace current_machine by qdev_get_machine()
Date: Tue, 14 Jan 2020 12:02:02 +1000

On Sun, Jan 12, 2020 at 11:45 PM Philippe Mathieu-Daudé
<address@hidden> wrote:
>
> On 1/12/20 10:48 AM, Alistair Francis wrote:
> > On Thu, Jan 9, 2020 at 11:29 PM Philippe Mathieu-Daudé
> > <address@hidden> wrote:
> >>
> >> As we want to remove the global current_machine,
> >> replace 'current_machine' by MACHINE(qdev_get_machine()).
> >>
> >> Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
> >> ---
> >>   memory.c | 4 +++-
> >>   1 file changed, 3 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/memory.c b/memory.c
> >> index d7b9bb6951..57e38b1f50 100644
> >> --- a/memory.c
> >> +++ b/memory.c
> >> @@ -3004,6 +3004,7 @@ static void mtree_print_flatview(gpointer key, 
> >> gpointer value,
> >>       int n = view->nr;
> >>       int i;
> >>       AddressSpace *as;
> >> +    MachineState *ms;
> >>
> >>       qemu_printf("FlatView #%d\n", fvi->counter);
> >>       ++fvi->counter;
> >> @@ -3026,6 +3027,7 @@ static void mtree_print_flatview(gpointer key, 
> >> gpointer value,
> >>           return;
> >>       }
> >>
> >> +    ms = MACHINE(qdev_get_machine());
> >
> > Why not set this at the top?
>
> Calling qdev_get_machine() is not free as it does some introspection
> checks. Since we can return earlier if there are no rendered FlatView, I
> placed the machinestate initialization just before it we need to access it.

Works for me, maybe worth putting this in the commit?

Reviewed-by: Alistair Francis <address@hidden>

Alistair

>
> > Alistair
> >
> >>       while (n--) {
> >>           mr = range->mr;
> >>           if (range->offset_in_region) {
> >> @@ -3057,7 +3059,7 @@ static void mtree_print_flatview(gpointer key, 
> >> gpointer value,
> >>           if (fvi->ac) {
> >>               for (i = 0; i < fv_address_spaces->len; ++i) {
> >>                   as = g_array_index(fv_address_spaces, AddressSpace*, i);
> >> -                if (fvi->ac->has_memory(current_machine, as,
> >> +                if (fvi->ac->has_memory(ms, as,
> >>                                           int128_get64(range->addr.start),
> >>                                           MR_SIZE(range->addr.size) + 1)) {
> >>                       qemu_printf(" %s", fvi->ac->name);
> >> --
> >> 2.21.1
> >>
> >>
> >
>



reply via email to

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