[Top][All Lists]

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

Re: [Qemu-devel] [PATCH] hostmem: fix reference to uninit mr

From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH] hostmem: fix reference to uninit mr
Date: Fri, 10 Mar 2017 10:17:30 +0100

On 10 March 2017 at 09:59, Peter Xu <address@hidden> wrote:
> On Fri, Mar 10, 2017 at 09:33:57AM +0100, Paolo Bonzini wrote:
>> On 10/03/2017 05:13, Peter Xu wrote:
>> > Trying to get memory region size of an uninitialized memory region is
>> > probably not a good idea. Let's just do the alloc no matter what.
>> >
>> > Signed-off-by: Peter Xu <address@hidden>
>> What is the effect of the bug? The idea was to do the initialization
>> once only (memory_region_size ought to be 0 when the MR is
>> uninitialized; now it is ugly but it made more sense when MemoryRegion
>> was just a C struct and not a QOM object).
> It's not really a bug. I just saw it, thought it was something not
> quite right, so posted a patch.

We could reasonably abstract out the test into a function
bool backend_mr_initialized(HostMemoryBackend *backend)
    /* We forbid zero-length in file_backend_memory_alloc,
     * so zero always means "we haven't allocated the backend
     * MR yet".
    return memory_region_size(&backend->mr) != 0;

and use it in file_backend_memory_alloc(), set_mem_path()
and file_memory_backend_set_share(). That would make the intent
clearer here I think.

-- PMM

reply via email to

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