xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Jackson <ian.jackson@eu.citrix.com>
To: xen-devel@lists.xensource.com
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>
Subject: [PATCH 01/11] libxl: Make logging functions preserve errno
Date: Thu, 25 Mar 2010 19:04:04 +0000	[thread overview]
Message-ID: <1269543854-7780-2-git-send-email-ian.jackson@eu.citrix.com> (raw)
In-Reply-To: <1269543854-7780-1-git-send-email-ian.jackson@eu.citrix.com>

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>
---
 tools/libxl/libxl_internal.c |    5 ++++-
 tools/libxl/libxl_internal.h |    2 ++
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c
index f48e9eb..4dcdabe 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,
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 300c108..10e72e5 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -47,6 +47,7 @@
 #define XL_LOG_ERRNO(ctx, loglevel, _f, _a...)
 #define XL_LOG_ERRNOVAL(ctx, loglevel, errnoval, _f, _a...)
 #endif
+  /* all of these macros preserve errno (saving and restoring) */
 
 #define XL_LOG_DEBUG 3
 #define XL_LOG_INFO 2
@@ -56,6 +57,7 @@
 /* logging */
 void xl_logv(struct libxl_ctx *ctx, int errnoval, int loglevel, const char *file, int line, const char *func, char *fmt, va_list al);
 void xl_log(struct libxl_ctx *ctx, int errnoval, int loglevel, const char *file, int line, const char *func, char *fmt, ...);
+  /* these functions preserve errno (saving and restoring) */
 
 
 typedef enum {
-- 
1.5.6.5

  reply	other threads:[~2010-03-25 19:04 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-25 19:04 [PATCH 00/11] Migration support for "xl" Ian Jackson
2010-03-25 19:04 ` Ian Jackson [this message]
2010-03-25 19:04 ` [PATCH 02/11] libxl: Report error if logfile rotation fails Ian Jackson
2010-03-25 19:04 ` [PATCH 03/11] libxl: New utility functions in for reading and writing files Ian Jackson
2010-03-25 19:04 ` [PATCH 04/11] libxl: libxl_domain_restore: Put fd back to blocking mode Ian Jackson
2010-03-25 19:04 ` [PATCH 05/11] libxl: Provide libxl_domain_rename Ian Jackson
2010-03-26 10:01   ` Vincent Hanquez
2010-03-26 10:23     ` Ian Jackson
2010-03-26 10:34       ` Vincent Hanquez
2010-03-26 10:40         ` Ian Jackson
2010-04-01 11:00         ` Stefano Stabellini
2010-03-25 19:04 ` [PATCH 06/11] libxl: Expose functions for helping with subprocesses Ian Jackson
2010-03-25 19:04 ` [PATCH 07/11] libxl: Expose libxl_report_exitstatus Ian Jackson
2010-03-25 19:04 ` [PATCH 08/11] libxl: Per-domain data storage for the convenience of the library user Ian Jackson
2010-03-26 10:06   ` Vincent Hanquez
2010-03-26 10:20     ` Ian Jackson
2010-03-26 10:29       ` Vincent Hanquez
2010-03-26 10:34         ` Ian Jackson
2010-03-26 10:41           ` Vincent Hanquez
2010-03-26 10:45             ` Ian Jackson
2010-03-26 11:27               ` Vincent Hanquez
2010-03-26 11:56                 ` Ian Jackson
2010-04-01 11:04       ` Stefano Stabellini
2010-03-25 19:04 ` [PATCH 09/11] xl: New savefile format. Save domain config when saving a domain Ian Jackson
2010-04-01 11:08   ` Stefano Stabellini
2010-03-25 19:04 ` [PATCH 10/11] xl: Domain creation logging fixes Ian Jackson
2010-03-25 19:04 ` [PATCH 11/11] xl: Migration support Ian Jackson
2010-04-01 11:10   ` Stefano Stabellini
2010-04-01 11:10 ` [PATCH 00/11] Migration support for "xl" Stefano Stabellini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1269543854-7780-2-git-send-email-ian.jackson@eu.citrix.com \
    --to=ian.jackson@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).