aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2015-10-09 17:17:34 +0200
committerMichael S. Tsirkin <mst@redhat.com>2015-10-22 14:34:49 +0300
commit31190ed781a81d2de65cea405e4cb3441ab929fc (patch)
treea92dd588148f39ba39fd0268b02409a27ec20574 /util
parentde1372d466fb4a7bed13f64f50bff14aaa4a5931 (diff)
vhost: add migration block if memfd failed
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
Diffstat (limited to 'util')
-rw-r--r--util/memfd.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/util/memfd.c b/util/memfd.c
index 4b23765b4a..7c406914c5 100644
--- a/util/memfd.c
+++ b/util/memfd.c
@@ -138,3 +138,25 @@ void qemu_memfd_free(void *ptr, size_t size, int fd)
close(fd);
}
}
+
+enum {
+ MEMFD_KO,
+ MEMFD_OK,
+ MEMFD_TODO
+};
+
+bool qemu_memfd_check(void)
+{
+ static int memfd_check = MEMFD_TODO;
+
+ if (memfd_check == MEMFD_TODO) {
+ int fd;
+ void *ptr;
+
+ ptr = qemu_memfd_alloc("test", 4096, 0, &fd);
+ memfd_check = ptr ? MEMFD_OK : MEMFD_KO;
+ qemu_memfd_free(ptr, 4096, fd);
+ }
+
+ return memfd_check == MEMFD_OK;
+}