aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl/libxl_internal.c
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2010-04-12 17:38:17 +0100
committerKeir Fraser <keir.fraser@citrix.com>2010-04-12 17:38:17 +0100
commitc20f18fbe847416f89c6362aea8604b2b2e28aae (patch)
tree2104dc269cf15af523cda1115d34cfef0e47fa8a /tools/libxl/libxl_internal.c
parentc6ddf6e062989ec5b1c2b850b10f165ad2744a4e (diff)
downloadxen-c20f18fbe847416f89c6362aea8604b2b2e28aae.tar.gz
xen-c20f18fbe847416f89c6362aea8604b2b2e28aae.tar.bz2
xen-c20f18fbe847416f89c6362aea8604b2b2e28aae.zip
libxl: Make logging functions preserve errno
This is needed by the following patches. It makes it much more convenient for libxl functions to return the errno value from the failure, when they fail. Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Diffstat (limited to 'tools/libxl/libxl_internal.c')
-rw-r--r--tools/libxl/libxl_internal.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c
index f48e9eb109..4dcdabe653 100644
--- a/tools/libxl/libxl_internal.c
+++ b/tools/libxl/libxl_internal.c
@@ -156,11 +156,13 @@ void xl_logv(struct libxl_ctx *ctx, int loglevel, int errnoval,
{
char *enomem = "[out of memory formatting log message]";
char *s;
- int rc;
+ int rc, esave;
if (!ctx->log_callback)
return;
+ esave = errno;
+
rc = vasprintf(&s, fmt, ap);
if (rc<0) { s = enomem; goto x; }
@@ -180,6 +182,7 @@ void xl_logv(struct libxl_ctx *ctx, int loglevel, int errnoval,
ctx->log_callback(ctx->log_userdata, loglevel, file, line, func, s);
if (s != enomem)
free(s);
+ errno = esave;
}
void xl_log(struct libxl_ctx *ctx, int loglevel, int errnoval,