[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [PATCH for-2.13] Add host_memory_backend_pagesize() helpe
From: |
David Gibson |
Subject: |
Re: [Qemu-ppc] [PATCH for-2.13] Add host_memory_backend_pagesize() helper |
Date: |
Tue, 3 Apr 2018 15:31:46 +1000 |
User-agent: |
Mutt/1.9.2 (2017-12-15) |
On Thu, Mar 29, 2018 at 08:37:48AM +0200, Greg Kurz wrote:
> On Thu, 29 Mar 2018 16:25:37 +1100
> David Gibson <address@hidden> wrote:
>
> > There are a couple places (one generic, one target specific) where we need
> > to get the host page size associated with a particular memory backend. I
> > have some upcoming code which will add another place which wants this. So,
> > for convenience, add a helper function to calculate this.
> >
> > host_memory_backend_pagesize() returns the host pagesize for a given
> > HostMemoryBackend object, or for the default backend (-mem-path) if passed
> > NULL.
> >
> > Signed-off-by: David Gibson <address@hidden>
> > ---
>
> The idea is good but there's a small issue. See below.
>
> > backends/hostmem.c | 20 ++++++++++++++++++++
> > exec.c | 21 +++++----------------
> > include/sysemu/hostmem.h | 2 ++
> > target/ppc/kvm.c | 10 +---------
> > 4 files changed, 28 insertions(+), 25 deletions(-)
> >
> > diff --git a/backends/hostmem.c b/backends/hostmem.c
> > index f61093654e..b6a60cfc5d 100644
> > --- a/backends/hostmem.c
> > +++ b/backends/hostmem.c
> > @@ -18,6 +18,7 @@
> > #include "qapi/visitor.h"
> > #include "qemu/config-file.h"
> > #include "qom/object_interfaces.h"
> > +#include "qemu/mmap-alloc.h"
> >
> > #ifdef CONFIG_NUMA
> > #include <numaif.h>
> > @@ -262,6 +263,25 @@ bool host_memory_backend_is_mapped(HostMemoryBackend
> > *backend)
> > return backend->is_mapped;
> > }
> >
> > +long host_memory_backend_pagesize(HostMemoryBackend *memdev)
> > +{
> > + const char *path = NULL;
> > +
> > +#ifdef __linux__
> > + if (memdev) {
> > + path = object_property_get_str(OBJECT(memdev), "mem-path", NULL);
>
> object_property_get_str() returns an allocated string. It should be freed
> before returning.
Ah, nice catch, I'll correct that.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
signature.asc
Description: PGP signature