libxl: preserve errno in libxl__xcinfo2xlinfo()
PATCH 1/1 libxl: preserve errno in libxl__xcinfo2xlinfo()
Callers observing errors elsewhere may be confused by the ENOSYS that the Flask operation would yield on a Flask-disabled hypervisor.
---
Of course I don't know whether clobbering errno is perhaps deemed "fine" in libxl.
tools/libs/light/libxl_domain.c +2 -0
@@ -277,6 +277,7 @@ void libxl__xcinfo2xlinfo(libxl_ctx *ctx libxl_dominfo *xlinfo) {size_t size; +int saved_errno = errno;memcpy (&(xlinfo->uuid), xcinfo->handle,sizeof (xen_domain_handle_t)); xlinfo->domid = xcinfo->domain;
@@ -284,6 +285,7 @@ void libxl__xcinfo2xlinfo(libxl_ctx *ctxif (libxl_flask_sid_to_context (ctx, xlinfo->ssidref, &xlinfo->ssid_label, &size) <0 ) xlinfo->ssid_label =NULL ; + errno = saved_errno; xlinfo->dying = !!(xcinfo->flags&XEN_DOMINF_dying); xlinfo->shutdown = !!(xcinfo->flags&XEN_DOMINF_shutdown);
Quoted 7 lines · Jan Beulich
Callers observing errors elsewhere may be confused by the ENOSYS that the Flask operation would yield on a Flask-disabled hypervisor.
Signed-off-by Jan Beulich <[email protected]>---
Of course I don't know whether clobbering errno is perhaps deemed "fine" in libxl.
I wonder if it would be better to special case libxl_flask_sid_to_context() to preserve errno on ENOSYS. flask returning ENOSYS is common, but libxl_flask_sid_to_context() can legitimately have error.
I guess this is fine if we want to use this approach:
Quoted 19 lines
tools/libs/light/libxl_domain.c +2
-0@@ -277,6 +277,7 @@ void libxl__xcinfo2xlinfo(libxl_ctx *ctx libxl_dominfo *xlinfo) {size_t size; +int saved_errno = errno;memcpy (&(xlinfo->uuid), xcinfo->handle,sizeof (xen_domain_handle_t)); xlinfo->domid = xcinfo->domain;@@ -284,6 +285,7 @@ void libxl__xcinfo2xlinfo(libxl_ctx *ctxif (libxl_flask_sid_to_context (ctx, xlinfo->ssidref, &xlinfo->ssid_label, &size) <0 ) xlinfo->ssid_label =NULL ; + errno = saved_errno; xlinfo->dying = !!(xcinfo->flags&XEN_DOMINF_dying); xlinfo->shutdown = !!(xcinfo->flags&XEN_DOMINF_shutdown);
Quoted 9 lines · Jason Andryuk
Quoted 7 lines · Jan Beulich
Callers observing errors elsewhere may be confused by the ENOSYS that the Flask operation would yield on a Flask-disabled hypervisor.
Signed-off-by Jan Beulich <[email protected]>---
Of course I don't know whether clobbering errno is perhaps deemed "fine" in libxl.
Quoted 4 lines
I wonder if it would be better to special case
libxl_flask_sid_to_context()to preserve errno on ENOSYS. flask returning ENOSYS is common, butlibxl_flask_sid_to_context()can legitimately have error.
But then libxl__xcinfo2xlinfo() also shouldn't (effectively) ignore such other errors? Question is what it should do in such an event.
Quoted 3 lines
I guess this is fine if we want to use this approach:
Reviewed-by Jason Andryuk <[email protected]>
Thanks.
Jan
Anthony PERARD
Acked-byQuoted 4 lines · Jason Andryuk
Quoted 3 lines · Jan Beulich
Callers observing errors elsewhere may be confused by the ENOSYS that the Flask operation would yield on a Flask-disabled hypervisor.
Quoted 8 lines
Quoted 4 lines
Signed-off-by Jan Beulich <[email protected]>---
Of course I don't know whether clobbering errno is perhaps deemed "fine" in libxl.I wonder if it would be better to special case
libxl_flask_sid_to_context()to preserve errno on ENOSYS. flask returning ENOSYS is common, butlibxl_flask_sid_to_context()can legitimately have error.
Well, errno=ENOSYS gives information about why libxl_flask_sid_to_context() returns an error.
They are multiple error code for returns libxl_*() functions but they aren't really check. We often rely on errno to print an error message. And in this case, libxl_flask_sid_to_context() doesn't event return a proper libxl_error value.
Quoted 3 lines
I guess this is fine if we want to use this approach:
Reviewed-by Jason Andryuk <[email protected]>
Thanks,
Signature · 1 line
Anthony PERARD