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 07/11] libxl: Expose libxl_report_exitstatus
Date: Thu, 25 Mar 2010 19:04:10 +0000 [thread overview]
Message-ID: <1269543854-7780-8-git-send-email-ian.jackson@eu.citrix.com> (raw)
In-Reply-To: <1269543854-7780-1-git-send-email-ian.jackson@eu.citrix.com>
xl would like to use libxl_report_exitstatus, so expose it in
libxl_utils.h to avoid having to write it twice. Also, give it a
"level" argument to set the loglevel of the resulting message.
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
tools/libxl/libxl_exec.c | 16 +++++++---------
tools/libxl/libxl_internal.h | 5 -----
tools/libxl/libxl_utils.h | 11 +++++++++++
3 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/tools/libxl/libxl_exec.c b/tools/libxl/libxl_exec.c
index 6d4a5c5..52dda97 100644
--- a/tools/libxl/libxl_exec.c
+++ b/tools/libxl/libxl_exec.c
@@ -57,34 +57,32 @@ void libxl_exec(int stdinfd, int stdoutfd, int stderrfd, char *arg0, char **args
_exit(-1);
}
-void libxl_report_child_exitstatus(struct libxl_ctx *ctx,
+void libxl_report_child_exitstatus(struct libxl_ctx *ctx, int level,
const char *what, pid_t pid, int status)
{
- /* treats all exit statuses as errors; if that's not what you want,
- * check status yourself first */
if (WIFEXITED(status)) {
int st = WEXITSTATUS(status);
if (st)
- XL_LOG(ctx, XL_LOG_ERROR, "%s [%ld] exited"
+ XL_LOG(ctx, level, "%s [%ld] exited"
" with error status %d", what, (unsigned long)pid, st);
else
- XL_LOG(ctx, XL_LOG_ERROR, "%s [%ld] unexpectedly"
+ XL_LOG(ctx, level, "%s [%ld] unexpectedly"
" exited status zero", what, (unsigned long)pid);
} else if (WIFSIGNALED(status)) {
int sig = WTERMSIG(status);
const char *str = strsignal(sig);
const char *coredump = WCOREDUMP(status) ? " (core dumped)" : "";
if (str)
- XL_LOG(ctx, XL_LOG_ERROR, "%s [%ld] died due to"
+ XL_LOG(ctx, level, "%s [%ld] died due to"
" fatal signal %s%s", what, (unsigned long)pid,
str, coredump);
else
- XL_LOG(ctx, XL_LOG_ERROR, "%s [%ld] died due to unknown"
+ XL_LOG(ctx, level, "%s [%ld] died due to unknown"
" fatal signal number %d%s", what, (unsigned long)pid,
sig, coredump);
} else {
- XL_LOG(ctx, XL_LOG_ERROR, "%s [%ld] gave unknown"
+ XL_LOG(ctx, level, "%s [%ld] gave unknown"
" wait status 0x%x", what, (unsigned long)pid, status);
}
}
@@ -145,7 +143,7 @@ static void report_spawn_intermediate_status(struct libxl_ctx *ctx,
char *intermediate_what = libxl_sprintf(ctx,
"%s intermediate process (startup monitor)",
for_spawn->what);
- libxl_report_child_exitstatus(ctx, intermediate_what,
+ libxl_report_child_exitstatus(ctx, XL_LOG_ERROR, intermediate_what,
for_spawn->intermediate, status);
}
}
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 10e72e5..d1e355c 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -49,11 +49,6 @@
#endif
/* all of these macros preserve errno (saving and restoring) */
-#define XL_LOG_DEBUG 3
-#define XL_LOG_INFO 2
-#define XL_LOG_WARNING 1
-#define XL_LOG_ERROR 0
-
/* 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, ...);
diff --git a/tools/libxl/libxl_utils.h b/tools/libxl/libxl_utils.h
index fe8b975..4c04c46 100644
--- a/tools/libxl/libxl_utils.h
+++ b/tools/libxl/libxl_utils.h
@@ -48,5 +48,16 @@ pid_t libxl_fork(struct libxl_ctx *ctx);
int libxl_pipe(struct libxl_ctx *ctx, int pipes[2]);
/* Just like fork(2), pipe(2), but log errors. */
+void libxl_report_child_exitstatus(struct libxl_ctx *ctx, int level,
+ const char *what, pid_t pid, int status);
+ /* treats all exit statuses as errors; if that's not what you want,
+ * check status yourself first */
+
+/* log levels: */
+#define XL_LOG_DEBUG 3
+#define XL_LOG_INFO 2
+#define XL_LOG_WARNING 1
+#define XL_LOG_ERROR 0
+
#endif
--
1.5.6.5
next prev parent 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 ` [PATCH 01/11] libxl: Make logging functions preserve errno Ian Jackson
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 ` Ian Jackson [this message]
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-8-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).