From dd7317a4a24d764d31caf6bc87060b399bfd5648 Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Fri, 11 Apr 2014 16:46:13 +0100 Subject: [PATCH] libxl/save-helper: Code motion of logging functions ... in preparation for a subsequent functional fix Signed-off-by: Andrew Cooper Acked-by: Ian Jackson Acked-by: Ian Campbell --- tools/libxl/libxl_save_helper.c | 58 ++++++++++++++++----------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/tools/libxl/libxl_save_helper.c b/tools/libxl/libxl_save_helper.c index 880565e2fc..d6fa5dd040 100644 --- a/tools/libxl/libxl_save_helper.c +++ b/tools/libxl/libxl_save_helper.c @@ -47,6 +47,35 @@ #include "xenguest.h" #include "_libxl_save_msgs_helper.h" +/*----- logger -----*/ + +static void tellparent_vmessage(xentoollog_logger *logger_in, + xentoollog_level level, + int errnoval, + const char *context, + const char *format, + va_list al) +{ + char *formatted; + int r = vasprintf(&formatted, format, al); + if (r < 0) { perror("memory allocation failed during logging"); exit(-1); } + helper_stub_log(level, errnoval, context, formatted, 0); + free(formatted); +} + +static void tellparent_progress(struct xentoollog_logger *logger_in, + const char *context, + const char *doing_what, int percent, + unsigned long done, unsigned long total) +{ + helper_stub_progress(context, doing_what, done, total, 0); +} + +static void tellparent_destroy(struct xentoollog_logger *logger_in) +{ + abort(); +} + /*----- globals -----*/ static const char *program = "libxl-save-helper"; @@ -86,39 +115,10 @@ static void *xmalloc(size_t sz) return r; } -/*----- logger -----*/ - typedef struct { xentoollog_logger vtable; } xentoollog_logger_tellparent; -static void tellparent_vmessage(xentoollog_logger *logger_in, - xentoollog_level level, - int errnoval, - const char *context, - const char *format, - va_list al) -{ - char *formatted; - int r = vasprintf(&formatted, format, al); - if (r < 0) { perror("memory allocation failed during logging"); exit(-1); } - helper_stub_log(level, errnoval, context, formatted, 0); - free(formatted); -} - -static void tellparent_progress(struct xentoollog_logger *logger_in, - const char *context, - const char *doing_what, int percent, - unsigned long done, unsigned long total) -{ - helper_stub_progress(context, doing_what, done, total, 0); -} - -static void tellparent_destroy(struct xentoollog_logger *logger_in) -{ - abort(); -} - static xentoollog_logger_tellparent *createlogger_tellparent(void) { xentoollog_logger_tellparent newlogger; -- 2.30.2