From: Alex Zeffertt <alex.zeffertt@eu.citrix.com>
To: Alex Zeffertt <alex.zeffertt@eu.citrix.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: Re: [PATCH 0/7] [xen-ocaml-tools.hg] integrate ocaml xenstored with xen-unstable.hg
Date: Wed, 10 Jun 2009 16:35:58 +0100 [thread overview]
Message-ID: <4A2FD2DE.3050303@eu.citrix.com> (raw)
In-Reply-To: <49E8A3BF.5080102@eu.citrix.com>
[-- Attachment #1: Type: text/plain, Size: 1359 bytes --]
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@lists.xensource.com
> http://lists.xensource.com/xen-devel
>
[-- Attachment #2: ocaml-xenstore-stubdom-logging-enable --]
[-- Type: text/plain, Size: 5207 bytes --]
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@eu.citrix.com>
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__ */
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
prev parent reply other threads:[~2009-06-10 15:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-17 15:43 [PATCH 0/7] [xen-ocaml-tools.hg] integrate ocaml xenstored with xen-unstable.hg Alex Zeffertt
2009-06-10 15:35 ` Alex Zeffertt [this message]
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=4A2FD2DE.3050303@eu.citrix.com \
--to=alex.zeffertt@eu.citrix.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.