From: Paolo Bonzini <pbonzini@redhat.com>
To: Peter Xu <peterx@redhat.com>, qemu-devel@nongnu.org
Cc: Igor Mammedov <imammedo@redhat.com>,
Eduardo Habkost <ehabkost@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] hostmem: fix reference to uninit mr
Date: Fri, 10 Mar 2017 09:33:57 +0100 [thread overview]
Message-ID: <da6200fe-c0ac-00bb-d0b7-dbf3c5a8a21f@redhat.com> (raw)
In-Reply-To: <1489119213-977-1-git-send-email-peterx@redhat.com>
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 <peterx@redhat.com>
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).
Paolo
> ---
> backends/hostmem-file.c | 17 +++++++----------
> 1 file changed, 7 insertions(+), 10 deletions(-)
>
> diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c
> index 42efb2f..a61d1bd 100644
> --- a/backends/hostmem-file.c
> +++ b/backends/hostmem-file.c
> @@ -39,6 +39,7 @@ static void
> file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
> {
> HostMemoryBackendFile *fb = MEMORY_BACKEND_FILE(backend);
> + gchar *path;
>
> if (!backend->size) {
> error_setg(errp, "can't create backend with size 0");
> @@ -51,16 +52,12 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
> #ifndef CONFIG_LINUX
> error_setg(errp, "-mem-path not supported on this host");
> #else
> - if (!memory_region_size(&backend->mr)) {
> - gchar *path;
> - backend->force_prealloc = mem_prealloc;
> - path = object_get_canonical_path(OBJECT(backend));
> - memory_region_init_ram_from_file(&backend->mr, OBJECT(backend),
> - path,
> - backend->size, fb->share,
> - fb->mem_path, errp);
> - g_free(path);
> - }
> + backend->force_prealloc = mem_prealloc;
> + path = object_get_canonical_path(OBJECT(backend));
> + memory_region_init_ram_from_file(&backend->mr, OBJECT(backend),
> + path, backend->size, fb->share,
> + fb->mem_path, errp);
> + g_free(path);
> #endif
> }
>
>
next prev parent reply other threads:[~2017-03-10 8:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-10 4:13 [Qemu-devel] [PATCH] hostmem: fix reference to uninit mr Peter Xu
2017-03-10 8:33 ` Paolo Bonzini [this message]
2017-03-10 8:59 ` Peter Xu
2017-03-10 9:17 ` Peter Maydell
2017-03-10 9:36 ` Peter Xu
2017-03-10 10:06 ` Paolo Bonzini
2017-03-10 9:19 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=da6200fe-c0ac-00bb-d0b7-dbf3c5a8a21f@redhat.com \
--to=pbonzini@redhat.com \
--cc=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).