aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorIlya Maximets <i.maximets@samsung.com>2019-03-11 16:58:50 +0300
committerEduardo Habkost <ehabkost@redhat.com>2019-03-11 17:17:01 -0300
commitedaed6c711f07267785a05a633d97dc9268a7385 (patch)
treefa4e23f2fff1949fad0870c6e57adc1023b7ba35 /util
parentdf20819328d6fa3cb9d4a259a58cebbee35cdd09 (diff)
memfd: improve error messages
This gives more information about the failure. Additionally 'ENOSYS' returned for a non-Linux platforms instead of 'errno', which is not initilaized in this case. Signed-off-by: Ilya Maximets <i.maximets@samsung.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20190311135850.6537-5-i.maximets@samsung.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Diffstat (limited to 'util')
-rw-r--r--util/memfd.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/util/memfd.c b/util/memfd.c
index 393d23da96..00334e5b21 100644
--- a/util/memfd.c
+++ b/util/memfd.c
@@ -71,14 +71,18 @@ int qemu_memfd_create(const char *name, size_t size, bool hugetlb,
}
mfd = memfd_create(name, flags);
if (mfd < 0) {
+ error_setg_errno(errp, errno,
+ "failed to create memfd with flags 0x%x", flags);
goto err;
}
if (ftruncate(mfd, size) == -1) {
+ error_setg_errno(errp, errno, "failed to resize memfd to %zu", size);
goto err;
}
if (seals && fcntl(mfd, F_ADD_SEALS, seals) == -1) {
+ error_setg_errno(errp, errno, "failed to add seals 0x%x", seals);
goto err;
}
@@ -88,8 +92,9 @@ err:
if (mfd >= 0) {
close(mfd);
}
+#else
+ error_setg_errno(errp, ENOSYS, "failed to create memfd");
#endif
- error_setg_errno(errp, errno, "failed to create memfd");
return -1;
}