Message ID | 20181127111050.18453-5-i.maximets@samsung.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | memfd fixes. | expand |
On Tue, Nov 27, 2018 at 3:11 PM Ilya Maximets <i.maximets@samsung.com> wrote: > > 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> > --- > util/memfd.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > 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; > } > > -- > 2.17.1 >
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; }
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> --- util/memfd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)