mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-11-05 20:35:44 +00:00
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>
This commit is contained in:
parent
df20819328
commit
edaed6c711
1 changed files with 6 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue