From: Stefan Hajnoczi <stefanha@gmail.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Haozhong Zhang <haozhong.zhang@intel.com>,
Eduardo Habkost <ehabkost@redhat.com>,
Stefan Weil <sw@weilnetz.de>,
qemu-devel@nongnu.org, Junyan He <junyan.he@intel.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Igor Mammedov <imammedo@redhat.com>,
Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH] memory: fetch pmem size in get_file_size()
Date: Thu, 12 Sep 2019 12:25:51 +0200 [thread overview]
Message-ID: <20190912102551.GA23174@stefanha-x1.localdomain> (raw)
In-Reply-To: <20190830184445.GF3694@habkost.net>
[-- Attachment #1: Type: text/plain, Size: 1918 bytes --]
On Fri, Aug 30, 2019 at 03:44:45PM -0300, Eduardo Habkost wrote:
> On Fri, Aug 30, 2019 at 10:30:56AM +0100, Stefan Hajnoczi wrote:
> > Neither stat(2) nor lseek(2) report the size of Linux devdax pmem
> > character device nodes. Commit 314aec4a6e06844937f1677f6cba21981005f389
> > ("hostmem-file: reject invalid pmem file sizes") added code to
> > hostmem-file.c to fetch the size from sysfs and compare against the
> > user-provided size=NUM parameter:
> >
> > if (backend->size > size) {
> > error_setg(errp, "size property %" PRIu64 " is larger than "
> > "pmem file \"%s\" size %" PRIu64, backend->size,
> > fb->mem_path, size);
> > return;
> > }
> >
> > It turns out that exec.c:qemu_ram_alloc_from_fd() already has an
> > equivalent size check but it skips devdax pmem character devices because
> > lseek(2) returns 0:
> >
> > if (file_size > 0 && file_size < size) {
> > error_setg(errp, "backing store %s size 0x%" PRIx64
> > " does not match 'size' option 0x" RAM_ADDR_FMT,
> > mem_path, file_size, size);
> > return NULL;
> > }
> >
> > This patch moves the devdax pmem file size code into get_file_size() so
> > that we check the memory size in a single place:
> > qemu_ram_alloc_from_fd(). This simplifies the code and makes it more
> > general.
> >
> > This also fixes the problem that hostmem-file only checks the devdax
> > pmem file size when the pmem=on parameter is given. An unchecked
> > size=NUM parameter can lead to SIGBUS in QEMU so we must always fetch
> > the file size for Linux devdax pmem character device nodes.
> >
> > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
>
> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
>
> Paolo, do you want to queue this, or should it go through my
> memory backend queue?
Ping for Paolo
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2019-09-12 10:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-30 9:30 [Qemu-devel] [PATCH] memory: fetch pmem size in get_file_size() Stefan Hajnoczi
2019-08-30 18:44 ` Eduardo Habkost
2019-09-12 10:25 ` Stefan Hajnoczi [this message]
2019-09-12 11:56 ` 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=20190912102551.GA23174@stefanha-x1.localdomain \
--to=stefanha@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=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
--cc=stefanha@redhat.com \
--cc=sw@weilnetz.de \
/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).