* [PATCH]xl: move libxl init functions from xl.c to xl_cmdimpl.c
@ 2010-05-05 4:42 Yang Hongyang
2010-05-05 16:20 ` Ian Jackson
0 siblings, 1 reply; 3+ messages in thread
From: Yang Hongyang @ 2010-05-05 4:42 UTC (permalink / raw)
To: xen-devel@lists.xensource.com
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH]xl: move libxl init functions from xl.c to xl_cmdimpl.c
2010-05-05 4:42 [PATCH]xl: move libxl init functions from xl.c to xl_cmdimpl.c Yang Hongyang
@ 2010-05-05 16:20 ` Ian Jackson
2010-05-06 1:12 ` Yang Hongyang
0 siblings, 1 reply; 3+ messages in thread
From: Ian Jackson @ 2010-05-05 16:20 UTC (permalink / raw)
To: Yang Hongyang; +Cc: xen-devel@lists.xensource.com
Yang Hongyang writes ("[Xen-devel] [PATCH]xl: move libxl init functions from xl.c to xl_cmdimpl.c"):
> Move libxl init functions from xl.c to xl_cmdimpl.c, use a wrapper function
> xl_init to do libxl init things.
I don't understand the purpose of this change.
Ian.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH]xl: move libxl init functions from xl.c to xl_cmdimpl.c
2010-05-05 16:20 ` Ian Jackson
@ 2010-05-06 1:12 ` Yang Hongyang
0 siblings, 0 replies; 3+ messages in thread
From: Yang Hongyang @ 2010-05-06 1:12 UTC (permalink / raw)
To: Ian Jackson; +Cc: xen-devel@lists.xensource.com
Hi Ian,
On 05/06/2010 12:20 AM, Ian Jackson wrote:
> Yang Hongyang writes ("[Xen-devel] [PATCH]xl: move libxl init functions from xl.c to xl_cmdimpl.c"):
>> Move libxl init functions from xl.c to xl_cmdimpl.c, use a wrapper function
>> xl_init to do libxl init things.
>
> I don't understand the purpose of this change.
It's my mistake that uses extern vars in .c file this way, Keir fix part of it, but there remains
two declarations in xl.c. My prupose is to correct this usage. But compare to move these
declarations to .h file, I prefer move code related to these vars to xl_cmdimpl.c, because
I think the libxl init and set log functions is more related to command implementations.
>
> Ian.
>
>
--
Regards
Yang Hongyang
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-05-06 1:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-05 4:42 [PATCH]xl: move libxl init functions from xl.c to xl_cmdimpl.c Yang Hongyang
2010-05-05 16:20 ` Ian Jackson
2010-05-06 1:12 ` Yang Hongyang
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.