All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yang Hongyang <yanghy@cn.fujitsu.com>
To: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: [PATCH]xl: move libxl init functions from xl.c to xl_cmdimpl.c
Date: Wed, 05 May 2010 12:42:26 +0800	[thread overview]
Message-ID: <4BE0F732.8000005@cn.fujitsu.com> (raw)

Move libxl init functions from xl.c to xl_cmdimpl.c, use a wrapper function
xl_init to do libxl init things.

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>

diff -r efa1b905d893 tools/libxl/xl.c
--- a/tools/libxl/xl.c	Tue May 04 13:59:55 2010 +0100
+++ b/tools/libxl/xl.c	Wed May 05 20:22:03 2010 +0800
@@ -31,17 +31,6 @@
 #include "xl_cmdimpl.h"
 #include "xl_cmdtable.h"
 
-extern struct libxl_ctx ctx;
-extern int logfile;
-
-void log_callback(void *userdata, int loglevel, const char *file, int line, const char *func, char *s)
-{
-    char str[1024];
-
-    snprintf(str, sizeof(str), "[%d] %s:%d:%s: %s\n", loglevel, file, line, func, s);
-    write(logfile, str, strlen(str));
-}
-
 int main(int argc, char **argv)
 {
     int i;
@@ -51,14 +40,7 @@
         exit(1);
     }
 
-    if (libxl_ctx_init(&ctx, LIBXL_VERSION)) {
-        fprintf(stderr, "cannot init xl context\n");
-        exit(1);
-    }
-    if (libxl_ctx_set_log(&ctx, log_callback, NULL)) {
-        fprintf(stderr, "cannot set xl log callback\n");
-        exit(-ERROR_FAIL);
-    }
+    xl_init();
 
     srand(time(0));
 
diff -r efa1b905d893 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Tue May 04 13:59:55 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c	Wed May 05 20:22:03 2010 +0800
@@ -87,6 +87,26 @@
 
 #define SAVEFILE_BYTEORDER_VALUE ((uint32_t)0x01020304UL)
 
+void log_callback(void *userdata, int loglevel, const char *file, int line, const char *func, char *s)
+{
+    char str[1024];
+
+    snprintf(str, sizeof(str), "[%d] %s:%d:%s: %s\n", loglevel, file, line, func, s);
+    write(logfile, str, strlen(str));
+}
+
+void xl_init(void)
+{
+    if (libxl_ctx_init(&ctx, LIBXL_VERSION)) {
+        fprintf(stderr, "cannot init xl context\n");
+        exit(1);
+    }
+    if (libxl_ctx_set_log(&ctx, log_callback, NULL)) {
+        fprintf(stderr, "cannot set xl log callback\n");
+        exit(-ERROR_FAIL);
+    }
+}
+
 static int domain_qualifier_to_domid(const char *p, uint32_t *domid_r,
                                      int *was_name_r)
 {
diff -r efa1b905d893 tools/libxl/xl_cmdimpl.h
--- a/tools/libxl/xl_cmdimpl.h	Tue May 04 13:59:55 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.h	Wed May 05 20:22:03 2010 +0800
@@ -37,3 +37,4 @@
 int main_sched_credit(int argc, char **argv);
 
 void help(char *command);
+void xl_init(void);

-- 
Regards
Yang Hongyang

             reply	other threads:[~2010-05-05  4:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-05  4:42 Yang Hongyang [this message]
2010-05-05 16:20 ` [PATCH]xl: move libxl init functions from xl.c to xl_cmdimpl.c Ian Jackson
2010-05-06  1:12   ` Yang Hongyang

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=4BE0F732.8000005@cn.fujitsu.com \
    --to=yanghy@cn.fujitsu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.