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

Re: [Xen-devel] [PATCH 0/7] [xen-ocaml-tools.hg] integrate ocaml xenstor

To: Alex Zeffertt <alex.zeffertt@xxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH 0/7] [xen-ocaml-tools.hg] integrate ocaml xenstored with xen-unstable.hg
From: Alex Zeffertt <alex.zeffertt@xxxxxxxxxxxxx>
Date: Wed, 10 Jun 2009 16:35:58 +0100
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Wed, 10 Jun 2009 08:36:27 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <49E8A3BF.5080102@xxxxxxxxxxxxx>
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>
References: <49E8A3BF.5080102@xxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.21 (X11/20090409)
Hi,

I'd like to append an 8th patch to this patchqueue.

The attached patch causes all syslog to be redirected to the console when
the ocaml version of xenstore is running in a mini-OS stubdomain. The console messages can be viewed using xenconsole_dump, or with "/etc/init.d/xenstored console" which just calls xenconsole_dump with the appropriate parameters.

Without this patch all syslog messages are just lost when the ocaml version of xenstore is running in a stubdomain.

Regards,

Alex


Alex Zeffertt wrote:
Hi Vincent,

Please consider applying this patchqueue to xen-ocaml-tools.hg.  The purpose of
these patches is to integrate xen-ocaml-tools.hg with xen-unstable.hg.

In more detail: I have a xen-unstable.hg patchqueue which gives the user the
option of selecting xen-ocaml-tools.hg as the source for xenstored in preference
to tools/xenstore.  This is similar to the mechanism we already employ with qemu
where the user may select between the in tree code and a remote repo.

However, for the xen-unstable.hg patchqueue to work I first need these changes
in xen-ocaml-tools.hg.  The main change I have made is to add stubdom support.

Regards,

Alex


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


Support syslog when running in a stub domain (messages are routed to console).
Without this patch all messages are simply lost when xenstored is compiled into 
a 
mini-OS stubdomain. 

Signed-off-by: <alex.zeffertt@xxxxxxxxxxxxx>

diff -r f7972857413a libs/log/log.ml
--- a/libs/log/log.ml   Fri Apr 17 15:11:52 2009 +0100
+++ b/libs/log/log.ml   Thu May 07 11:47:20 2009 +0100
@@ -71,6 +71,7 @@
 
 (** open a syslog logger *)
 let opensyslog k level =
+       Syslog.init "xenstored" [] Syslog.Daemon ; 
        make (Syslog k) level
 
 (** open a stderr logger *)
@@ -236,7 +237,7 @@
                | Info  -> Syslog.Info
                | Warn  -> Syslog.Warning
                | Error -> Syslog.Err in
-               Syslog.log Syslog.Daemon sys_prio ((construct_string false) ^ 
"\n")
+               Syslog.log sys_prio ((construct_string false) ^ "\n")
        | Stream s -> (
              match !(s.channel) with
                | Some c -> write_to_stream c
diff -r f7972857413a libs/log/syslog.ml
--- a/libs/log/syslog.ml        Fri Apr 17 15:11:52 2009 +0100
+++ b/libs/log/syslog.ml        Thu May 07 11:47:20 2009 +0100
@@ -21,6 +21,6 @@
              | Local4 | Local5 | Local6 | Local7
              | Lpr | Mail | News | Syslog | User | Uucp
 
-(* external init : string -> options list -> facility -> unit = "stub_openlog" 
*)
-external log : facility -> level -> string -> unit = "stub_syslog"
+external init : string -> options list -> facility -> unit = "stub_openlog"
+external log : level -> string -> unit = "stub_syslog"
 external close : unit -> unit = "stub_closelog"
diff -r f7972857413a libs/log/syslog.mli
--- a/libs/log/syslog.mli       Fri Apr 17 15:11:52 2009 +0100
+++ b/libs/log/syslog.mli       Thu May 07 11:47:20 2009 +0100
@@ -37,5 +37,6 @@
   | Syslog
   | User
   | Uucp
-external log : facility -> level -> string -> unit = "stub_syslog"
+external init : string -> options list -> facility -> unit = "stub_openlog"
+external log : level -> string -> unit = "stub_syslog"
 external close : unit -> unit = "stub_closelog"
diff -r f7972857413a libs/log/syslog_stubs.c
--- a/libs/log/syslog_stubs.c   Fri Apr 17 15:11:52 2009 +0100
+++ b/libs/log/syslog_stubs.c   Thu May 07 11:47:20 2009 +0100
@@ -15,12 +15,36 @@
  */
 
 #include <syslog.h>
+#include <string.h>
 #include <caml/mlvalues.h>
 #include <caml/memory.h>
 #include <caml/alloc.h>
 #include <caml/custom.h>
+#include <caml/fail.h>
 
-#ifndef __MINIOS__
+/* defs needed for mini-os which only implements a subset */
+#ifndef  LOG_AUTHPRIV
+# define LOG_AUTHPRIV LOG_AUTH
+#endif
+#ifndef  LOG_FTP
+# define LOG_FTP      LOG_DAEMON
+#endif
+#ifndef  LOG_LOCAL0
+# define LOG_LOCAL0   LOG_USER
+# define LOG_LOCAL1   LOG_USER
+# define LOG_LOCAL2   LOG_USER
+# define LOG_LOCAL3   LOG_USER
+# define LOG_LOCAL4   LOG_USER
+# define LOG_LOCAL5   LOG_USER
+# define LOG_LOCAL6   LOG_USER
+# define LOG_LOCAL7   LOG_USER
+#endif
+#ifndef  LOG_PERROR
+# define LOG_PERROR   LOG_CONS
+#endif
+#ifndef  LOG_SYSLOG
+# define LOG_SYSLOG   LOG_DAEMON
+#endif
 
 static int __syslog_level_table[] = {
        LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING,
@@ -38,52 +62,49 @@
        LOG_LPR | LOG_MAIL | LOG_NEWS | LOG_SYSLOG | LOG_USER | LOG_UUCP
 };
 
-/* According to the openlog manpage the 'openlog' call may take a reference
-   to the 'ident' string and keep it long-term. This means we cannot just pass 
in
-   an ocaml string which is under the control of the GC. Since we aren't 
actually
-   calling this function we can just comment it out for the time-being. */
-/*
+static char *__ident = NULL;
+
 value stub_openlog(value ident, value option, value facility)
 {
        CAMLparam3(ident, option, facility);
        int c_option;
        int c_facility;
 
+       /* Duplicate ident string as GC destroys original, but openlog passes 
pointer to syslog */
+       if (__ident != NULL)
+               caml_failwith("openlog called twice without intervening 
closelog");
+       if ((__ident = strdup(String_val(ident))) == NULL)
+               caml_failwith("openlog: strdup failed");
+
        c_option = caml_convert_flag_list(option, __syslog_options_table);
        c_facility = __syslog_facility_table[Int_val(facility)];
-       openlog(String_val(ident), c_option, c_facility);
+       openlog(__ident, c_option, c_facility);
        CAMLreturn(Val_unit);
 }
-*/
 
-value stub_syslog(value facility, value level, value msg)
+value stub_syslog(value level, value msg)
 {
-       CAMLparam3(facility, level, msg);
-       int c_facility;
+       CAMLparam2(level, msg);
+       int c_level;
 
-       c_facility = __syslog_facility_table[Int_val(facility)]
-                  | __syslog_level_table[Int_val(level)];
-       syslog(c_facility, "%s", String_val(msg));
+       if (__ident == NULL)
+               caml_failwith("syslog: openlog not called");
+
+       c_level = __syslog_level_table[Int_val(level)];
+       syslog(c_level, "%s", String_val(msg));
        CAMLreturn(Val_unit);
 }
 
 value stub_closelog(value unit)
 {
        CAMLparam1(unit);
+
+       if (__ident == NULL)
+               caml_failwith("closelog: openlog not called");
+
        closelog();
+       free(__ident);
+       __ident = NULL;
+       
        CAMLreturn(Val_unit);
 }
-
-#else 
-/* MINIOS StubDOM TODO: We need to redirect this to dom0 somehow ... */
-value stub_syslog(value facility, value level, value msg) 
-{
-       CAMLparam3(facility, level, msg);
-       CAMLreturn(Val_unit);
-}
-value stub_closelog(value unit)
-{
-       CAMLparam1(unit);
-       CAMLreturn(Val_unit);
-}
-#endif /* __MINIOS__ */
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • Re: [Xen-devel] [PATCH 0/7] [xen-ocaml-tools.hg] integrate ocaml xenstored with xen-unstable.hg, Alex Zeffertt <=