All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>,
	Junyan He <junyan.he@intel.com>,
	Haozhong Zhang <haozhong.zhang@intel.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Igor Mammedov <imammedo@redhat.com>,
	Richard Henderson <richard.henderson@linaro.org>,
	Eduardo Habkost <ehabkost@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Peter Crosthwaite <crosthwaite.peter@gmail.com>,
	Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PULL 4/7] hostmem-file: add the 'pmem' option
Date: Fri, 24 Aug 2018 19:53:09 +0300	[thread overview]
Message-ID: <20180824195231-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <CAFEAcA9eOFMuvkN2gBetU4SSpV0Jp2hSVsjMG53_Cp8TrkObFg@mail.gmail.com>

On Fri, Aug 24, 2018 at 04:13:18PM +0100, Peter Maydell wrote:
> On 20 August 2018 at 21:24, Michael S. Tsirkin <mst@redhat.com> wrote:
> > From: Junyan He <junyan.he@intel.com>
> >
> > When QEMU emulates vNVDIMM labels and migrates vNVDIMM devices, it
> > needs to know whether the backend storage is a real persistent memory,
> > in order to decide whether special operations should be performed to
> > ensure the data persistence.
> >
> > This boolean option 'pmem' allows users to specify whether the backend
> > storage of memory-backend-file is a real persistent memory. If
> > 'pmem=on', QEMU will set the flag RAM_PMEM in the RAM block of the
> > corresponding memory region. If 'pmem' is set while lack of libpmem
> > support, a error is generated.
> 
> Hi; Coverity reports (CID 1395184) that there is a resource leak
> in an error-exit path in this function:
> 
> > +static void file_memory_backend_set_pmem(Object *o, bool value, Error **errp)
> > +{
> > +    HostMemoryBackend *backend = MEMORY_BACKEND(o);
> > +    HostMemoryBackendFile *fb = MEMORY_BACKEND_FILE(o);
> > +
> > +    if (host_memory_backend_mr_inited(backend)) {
> > +        error_setg(errp, "cannot change property 'pmem' of %s '%s'",
> > +                   object_get_typename(o),
> > +                   object_get_canonical_path_component(o));
> > +        return;
> > +    }
> > +
> > +#ifndef CONFIG_LIBPMEM
> > +    if (value) {
> > +        Error *local_err = NULL;
> > +        error_setg(&local_err,
> > +                   "Lack of libpmem support while setting the 'pmem=on'"
> > +                   " of %s '%s'. We can't ensure data persistence.",
> > +                   object_get_typename(o),
> > +                   object_get_canonical_path_component(o));
> 
> object_get_canonical_path_component() returns a string which
> must be freed using g_free().
> 
> > +        error_propagate(errp, local_err);
> > +        return;
> > +    }
> > +#endif
> > +
> > +    fb->is_pmem = value;
> > +}
> 
> thanks
> -- PMM


Like the following? Junyan, could you pls try this one and confirm?

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c
index 2476dcb435..d88125b86e 100644
--- a/backends/hostmem-file.c
+++ b/backends/hostmem-file.c
@@ -154,11 +154,14 @@ static void file_memory_backend_set_pmem(Object *o, bool value, Error **errp)
 #ifndef CONFIG_LIBPMEM
     if (value) {
         Error *local_err = NULL;
+        char *path = object_get_canonical_path_component(o);
+
         error_setg(&local_err,
                    "Lack of libpmem support while setting the 'pmem=on'"
                    " of %s '%s'. We can't ensure data persistence.",
                    object_get_typename(o),
-                   object_get_canonical_path_component(o));
+                   );
+        g_free(path);
         error_propagate(errp, local_err);
         return;
     }

  reply	other threads:[~2018-08-24 16:57 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-20 20:24 [Qemu-devel] [PULL 0/7] pc: fixes Michael S. Tsirkin
2018-08-20 20:24 ` [Qemu-devel] [PULL 1/7] memory, exec: Expose all memory block related flags Michael S. Tsirkin
2018-08-20 20:24 ` [Qemu-devel] [PULL 2/7] memory, exec: switch file ram allocation functions to 'flags' parameters Michael S. Tsirkin
2018-08-20 20:24 ` [Qemu-devel] [PULL 3/7] configure: add libpmem support Michael S. Tsirkin
2018-08-20 20:24 ` [Qemu-devel] [PULL 4/7] hostmem-file: add the 'pmem' option Michael S. Tsirkin
2018-08-24 15:13   ` Peter Maydell
2018-08-24 16:53     ` Michael S. Tsirkin [this message]
2018-08-24 16:57       ` Peter Maydell
2018-08-24 17:14         ` Michael S. Tsirkin
2018-08-28 15:42           ` Yi Zhang
2018-08-20 20:24 ` [Qemu-devel] [PULL 5/7] mem/nvdimm: ensure write persistence to PMEM in label emulation Michael S. Tsirkin
2018-08-20 20:24 ` [Qemu-devel] [PULL 6/7] migration/ram: Add check and info message to nvdimm post copy Michael S. Tsirkin
2018-08-20 20:24 ` [Qemu-devel] [PULL 7/7] migration/ram: ensure write persistence on loading all data to PMEM Michael S. Tsirkin
2018-08-21 10:35 ` [Qemu-devel] [PULL 0/7] pc: fixes Peter Maydell

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=20180824195231-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=crosthwaite.peter@gmail.com \
    --cc=ehabkost@redhat.com \
    --cc=haozhong.zhang@intel.com \
    --cc=imammedo@redhat.com \
    --cc=junyan.he@intel.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=rth@twiddle.net \
    --cc=stefanha@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.