[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v6 06/24] memfd: add fallback for memfd
From: |
Michael S. Tsirkin |
Subject: |
Re: [Qemu-devel] [PATCH v6 06/24] memfd: add fallback for memfd |
Date: |
Wed, 30 Sep 2015 12:08:27 +0300 |
On Wed, Sep 30, 2015 at 05:06:55AM -0400, Marc-André Lureau wrote:
> Hi
>
> ----- Original Message -----
> > On Tue, Sep 29, 2015 at 06:34:36PM +0200, address@hidden wrote:
> > > From: Marc-André Lureau <address@hidden>
> > >
> > > Add an open/unlink/mmap fallback for system that do not support memfd.
> > > This patch may require additional SELinux policies to work for enforced
> > > systems, but should gracefully fail nonetheless.
> > >
> > > Signed-off-by: Marc-André Lureau <address@hidden>
> >
> > I'd rather just fail migration.
>
> So we don't provide this compatibility code and migration should fail.
>
> Would it be enough to check if memfd works at early runtime and add a
> migration blocker for vhost-user? Or is it possible to recover if migration
> fails when memfd fails to allocate? I would thing the former is better.
Fine with me.
> >
> > > ---
> > > util/memfd.c | 22 ++++++++++++++++++++--
> > > 1 file changed, 20 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/util/memfd.c b/util/memfd.c
> > > index 3168902..970b5b0 100644
> > > --- a/util/memfd.c
> > > +++ b/util/memfd.c
> > > @@ -84,8 +84,26 @@ void *qemu_memfd_alloc(const char *name, size_t size,
> > > unsigned int seals,
> > > return NULL;
> > > }
> > > } else {
> > > - perror("memfd");
> > > - return NULL;
> > > + const char *tmpdir = getenv("TMPDIR");
> > > + gchar *fname;
> > > +
> > > + tmpdir = tmpdir ? tmpdir : "/tmp";
> > > +
> > > + fname = g_strdup_printf("%s/memfd-XXXXXX", tmpdir);
> > > + mfd = mkstemp(fname);
> > > + unlink(fname);
> > > + g_free(fname);
> > > +
> > > + if (mfd == -1) {
> > > + perror("mkstemp");
> > > + return NULL;
> > > + }
> > > +
> > > + if (ftruncate(mfd, size) == -1) {
> > > + perror("ftruncate");
> > > + close(mfd);
> > > + return NULL;
> > > + }
> > > }
> > >
> > > ptr = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, mfd, 0);
> > > --
> > > 2.4.3
> >
- [Qemu-devel] [PATCH v6 00/24] vhost-user: add migration support, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v6 08/24] vhost: add vhost_set_log_base op, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v6 09/24] vhost-user: add vhost_user_requires_shm_log(), marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v6 11/24] vhost-user: send log shm fd along with log_base, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v6 14/24] vhost-user: document migration log, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v6 15/24] net: add trace_vhost_user_event, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v6 13/24] vhost: use a function for each call, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v6 06/24] memfd: add fallback for memfd, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v6 16/24] vhost user: add support of live migration, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v6 23/24] vhost-user-test: check ownership during migration, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v6 22/24] vhost-user-test: add live-migration test, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v6 24/24] vhost-user: use an enum helper for features mask, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v6 01/24] vhost-user: unit test for new messages, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v6 04/24] util: add linux-only memfd fallback, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v6 07/24] vhost: document log resizing, marcandre . lureau, 2015/10/08
- [Qemu-devel] [PATCH v6 12/24] vhost-user: add a migration blocker, marcandre . lureau, 2015/10/08