From: "Michael S. Tsirkin" <mst@redhat.com>
To: Antonios Motakis <a.motakis@virtualopensystems.com>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
snabb-devel@googlegroups.com,
"Anthony Liguori" <aliguori@amazon.com>,
"Jan Kiszka" <jan.kiszka@siemens.com>,
"Michael Tokarev" <mjt@tls.msk.ru>,
qemu-devel@nongnu.org, n.nikolaev@virtualopensystems.com,
"Markus Armbruster" <armbru@redhat.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
lukego@gmail.com, "Paolo Bonzini" <pbonzini@redhat.com>,
tech@virtualopensystems.com, "Andreas Färber" <afaerber@suse.de>,
"Richard Henderson" <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH v6 2/8] New -mem-path option - unlink.
Date: Tue, 14 Jan 2014 13:16:08 +0200 [thread overview]
Message-ID: <20140114111608.GC27922@redhat.com> (raw)
In-Reply-To: <1389623119-15863-3-git-send-email-a.motakis@virtualopensystems.com>
On Mon, Jan 13, 2014 at 03:25:13PM +0100, Antonios Motakis wrote:
> The unlink option allows the created file to be externally deleted
> after QEMU is terminated.
>
> - unlink=on|off - default on, unlink the file after opening it
>
> Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com>
> Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
I have doubts about this patch.
In particular we seem to commit to a specific
file naming scheme without ever documenting
its users or adding any tests.
Please document who uses this in the commit log,
document the scheme in docs/ and add a test so we
don't break this without noticing.
> ---
> exec.c | 18 +++++++++++++-----
> qemu-options.hx | 7 ++++---
> vl.c | 4 ++++
> 3 files changed, 21 insertions(+), 8 deletions(-)
>
> diff --git a/exec.c b/exec.c
> index 1c40a0d..30f4019 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -999,7 +999,7 @@ static void *file_ram_alloc(RAMBlock *block,
> int flags;
> unsigned long hpagesize;
> QemuOpts *opts;
> - unsigned int mem_prealloc = 0, mem_share = 0;
> + unsigned int mem_prealloc = 0, mem_share = 0, mem_unlink = 1;
>
> hpagesize = gethugepagesize(path);
> if (!hpagesize) {
> @@ -1020,6 +1020,7 @@ static void *file_ram_alloc(RAMBlock *block,
> if (opts) {
> mem_prealloc = qemu_opt_get_bool(opts, "prealloc", 0);
> mem_share = qemu_opt_get_bool(opts, "share", 0);
> + mem_unlink = qemu_opt_get_bool(opts, "unlink", 1);
> }
>
> /* Make name safe to use with mkstemp by replacing '/' with '_'. */
> @@ -1029,18 +1030,25 @@ static void *file_ram_alloc(RAMBlock *block,
> *c = '_';
> }
>
> - filename = g_strdup_printf("%s/qemu_back_mem.%s.XXXXXX", path,
> - sanitized_name);
> + filename = g_strdup_printf("%s/qemu_back_mem.%s%s", path, sanitized_name,
> + (mem_unlink) ? ".XXXXXX" : "");
> g_free(sanitized_name);
>
> - fd = mkstemp(filename);
> + if (mem_unlink) {
> + fd = mkstemp(filename);
> + } else {
> + fd = open(filename, O_CREAT | O_RDWR | O_EXCL,
> + S_IRWXU | S_IRWXG | S_IRWXO);
> + }
> if (fd < 0) {
> perror("unable to create guest RAM backing store");
> g_free(filename);
> return NULL;
> }
>
> - unlink(filename);
> + if (mem_unlink) {
> + unlink(filename);
> + }
> g_free(filename);
>
> memory = (memory + hpagesize - 1) & ~(hpagesize - 1);
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 60ecc95..a12af97 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -221,14 +221,15 @@ gigabytes respectively.
> ETEXI
>
> DEF("mem-path", HAS_ARG, QEMU_OPTION_mempath,
> - "-mem-path [path=]path[,prealloc=on|off][,share=on|off]\n"
> + "-mem-path [path=]path[,prealloc=on|off][,share=on|off][,unlink=on|off]\n"
> " provide backing storage for guest RAM\n"
> " path= a directory path for the backing store\n"
> " prealloc= preallocate guest memory [default disabled]\n"
> - " share= enable mmap share flag [default disabled]\n",
> + " share= enable mmap share flag [default disabled]\n"
> + " unlink= enable unlinking the guest RAM files [default enabled]\n",
> QEMU_ARCH_ALL)
> STEXI
> -@item -mem-path [path=]@var{path}[,prealloc=on|off][,share=on|off]
> +@item -mem-path [path=]@var{path}[,prealloc=on|off][,share=on|off][,unlink=on|off]
> @findex -mem-path
> Allocate guest RAM from a temporarily created file in @var{path}.
> ETEXI
> diff --git a/vl.c b/vl.c
> index e98abc8..5034bb6 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -546,6 +546,10 @@ static QemuOptsList qemu_mem_path_opts = {
> .name = "share",
> .type = QEMU_OPT_BOOL,
> },
> + {
> + .name = "unlink",
> + .type = QEMU_OPT_BOOL,
> + },
> { /* end of list */ }
> },
> };
> --
> 1.8.3.2
>
next prev parent reply other threads:[~2014-01-14 11:16 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-13 14:25 [Qemu-devel] [PATCH v6 0/8] Vhost and vhost-net support for userspace based backends Antonios Motakis
2014-01-13 14:25 ` [Qemu-devel] [PATCH v6 1/8] Convert -mem-path to QemuOpts and add prealloc and share properties Antonios Motakis
2014-01-13 14:25 ` [Qemu-devel] [PATCH v6 2/8] New -mem-path option - unlink Antonios Motakis
2014-01-14 11:16 ` Michael S. Tsirkin [this message]
2014-01-14 18:13 ` Antonios Motakis
2014-01-13 14:25 ` [Qemu-devel] [PATCH v6 3/8] Decouple vhost from kernel interface Antonios Motakis
2014-01-13 14:25 ` [Qemu-devel] [PATCH v6 4/8] Add vhost-user skeleton Antonios Motakis
2014-01-14 11:17 ` Michael S. Tsirkin
2014-01-13 14:25 ` [Qemu-devel] [PATCH v6 5/8] Add domain socket communication for vhost-user backend Antonios Motakis
2014-01-14 11:10 ` Michael S. Tsirkin
2014-01-14 18:14 ` Antonios Motakis
2014-01-15 9:13 ` Michael S. Tsirkin
2014-01-13 14:25 ` [Qemu-devel] [PATCH v6 6/8] Add vhost-user calls implementation Antonios Motakis
2014-01-14 11:21 ` Michael S. Tsirkin
2014-01-14 18:14 ` Antonios Motakis
2014-01-15 9:14 ` Michael S. Tsirkin
2014-01-15 10:08 ` Michael S. Tsirkin
2014-01-13 14:25 ` [Qemu-devel] [PATCH v6 7/8] Add new vhost-user netdev backend Antonios Motakis
2014-01-13 14:25 ` [Qemu-devel] [PATCH v6 8/8] Add vhost-user reconnection Antonios Motakis
2014-01-14 11:14 ` [Qemu-devel] [PATCH v6 0/8] Vhost and vhost-net support for userspace based backends Michael S. Tsirkin
2014-01-14 18:13 ` Antonios Motakis
2014-01-15 8:54 ` Michael S. Tsirkin
2014-01-14 11:33 ` Michael S. Tsirkin
2014-01-14 18:13 ` Antonios Motakis
2014-01-15 9:07 ` Michael S. Tsirkin
2014-01-15 12:50 ` Antonios Motakis
2014-01-15 14:49 ` Michael S. Tsirkin
2014-01-16 12:35 ` Antonios Motakis
2014-01-27 16:37 ` Antonios Motakis
2014-01-27 16:49 ` Michael S. Tsirkin
2014-01-29 12:04 ` Antonios Motakis
2014-01-29 14:10 ` Michael S. Tsirkin
2014-01-21 13:32 ` Antonios Motakis
2014-01-15 10:05 ` Michael S. Tsirkin
2014-01-21 13:32 ` Antonios Motakis
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=20140114111608.GC27922@redhat.com \
--to=mst@redhat.com \
--cc=a.motakis@virtualopensystems.com \
--cc=afaerber@suse.de \
--cc=aliguori@amazon.com \
--cc=armbru@redhat.com \
--cc=jan.kiszka@siemens.com \
--cc=lukego@gmail.com \
--cc=mjt@tls.msk.ru \
--cc=n.nikolaev@virtualopensystems.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
--cc=snabb-devel@googlegroups.com \
--cc=stefanha@redhat.com \
--cc=tech@virtualopensystems.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 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).