WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH]xl: move libxl init functions from xl.c to xl_cmdimpl

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH]xl: move libxl init functions from xl.c to xl_cmdimpl.c
From: Yang Hongyang <yanghy@xxxxxxxxxxxxxx>
Date: Wed, 05 May 2010 12:42:26 +0800
Delivery-date: Tue, 04 May 2010 21:42:22 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100415 Thunderbird/3.0.4
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@xxxxxxxxxxxxxx>

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

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>