Skip to contentSkip to conversation

Some refactoring on xapi-libs and oxenstored

PATCH In review Zheng Li 2 participants 6 messages Jul 31, 2011 – Aug 9, 2011 Arm/actions semi architecture

lore
Share & tools
lore

Zheng Li

author
#0 lore raw

PATCH 1/1 Some refactoring on xapi-libs and oxenstored

These are mostly simplifications plus small bug fixes.

Sorry that some of the patches should have been smaller, it's a bit too late to break them. They should be quite safe to apply though, as these modifications have been running in our test facilities for a few months now.

 tools/ocaml/Makefile.rules           |   10 +-
 tools/ocaml/libs/Makefile            |    4 +-
 tools/ocaml/libs/eventchn/Makefile   |    1 +
 tools/ocaml/libs/log/META.in         |    5 -
 tools/ocaml/libs/log/Makefile        |   44 -----
 tools/ocaml/libs/log/log.ml          |  258 -----------------------------
 tools/ocaml/libs/log/log.mli         |   55 ------
 tools/ocaml/libs/log/logs.ml         |  197 ----------------------
 tools/ocaml/libs/log/logs.mli        |   46 -----
 tools/ocaml/libs/log/syslog.ml       |   26 ---
 tools/ocaml/libs/log/syslog.mli      |   41 ----
 tools/ocaml/libs/log/syslog_stubs.c  |   75 --------
 tools/ocaml/libs/uuid/META.in        |    4 -
 tools/ocaml/libs/uuid/Makefile       |   29 ---
 tools/ocaml/libs/uuid/uuid.ml        |  100 -----------
 tools/ocaml/libs/uuid/uuid.mli       |   67 -------
 tools/ocaml/libs/xb/Makefile         |    2 +-
 tools/ocaml/libs/xc/META.in          |    2 +-
 tools/ocaml/libs/xc/Makefile         |    2 +-
 tools/ocaml/libs/xc/xc.ml            |   14 +-
 tools/ocaml/libs/xc/xc.mli           |    9 +-
 tools/ocaml/libs/xc/xc_stubs.c       |   10 +-
 tools/ocaml/xenstored/Makefile       |    4 -
 tools/ocaml/xenstored/connection.ml  |    5 +
 tools/ocaml/xenstored/connections.ml |    7 +-
 tools/ocaml/xenstored/disk.ml        |    2 +-
 tools/ocaml/xenstored/domain.ml      |    2 +-
 tools/ocaml/xenstored/domains.ml     |    6 +-
 tools/ocaml/xenstored/logging.ml     |  302 ++++++++++++++++++----------------
 tools/ocaml/xenstored/perms.ml       |    8 +-
 tools/ocaml/xenstored/process.ml     |   20 +-
 tools/ocaml/xenstored/quota.ml       |    2 +-
 tools/ocaml/xenstored/store.ml       |    2 +-
 tools/ocaml/xenstored/xenstored.conf |   15 +-
 tools/ocaml/xenstored/xenstored.ml   |   62 +++---
 tools/python/xen/lowlevel/xs/xs.c    |   16 +-
 tools/xenstore/xenstore_client.c     |   29 +-
 tools/xenstore/xs.c                  |   16 +-
 tools/xenstore/xs.h                  |    1 +
 39 files changed, 309 insertions(+), 1191 deletions(-)
author
#1 lore raw

PATCH 1/1 Some recent updates on ocaml xapi-libs

* minor Makefile cleanup
* remove uuid library (oxenstored and other libraries have very little dependency on it, where we can use string instead of specific uuid type)
* remove log library (oxenstored depended on both this xapi-libs log library and a customized logging library of its own, now we have consolidated them and eliminated the heavy weight xapi-libs log library)
* fix small bug in vcpu affinity binding
* fix small bug in read console ring binding
* add an extra field in physinfo binding

----

tools/ocaml/Makefile.rules +5 -5
@@ -52,20 +52,20 @@ quiet-command = $(if $(V),$1,@printf " %
 mk-caml-lib-native = $(call quiet-command, $(OCAMLOPT) $(OCAMLOPTFLAGS) -a -o $1 $2 $3,MLA,$1)
 mk-caml-lib-bytecode = $(call quiet-command, $(OCAMLC) $(OCAMLCFLAGS) -a -o $1 $2 $3,MLA,$1)
 
-mk-caml-stubs = $(call quiet-command, $(OCAMLMKLIB) -o `basename $1 .a` $2,MKLIB,$1)
+mk-caml-stubs = $(call quiet-command, $(OCAMLMKLIB) $(LIBS_$(1)) -o $(1)_stubs $2,MKLIB,$1)
 mk-caml-lib-stubs = \
-	$(call quiet-command, $(AR) rcs $1 $2 && $(OCAMLMKLIB) -o `basename $1 .a | sed -e 's/^lib//'` $2,MKLIB,$1)
+	$(call quiet-command, $(AR) rcs lib$(1)_stubs.a $2 && $(OCAMLMKLIB) $(LIBS_$(1)) -o $(1)_stubs $2,MKLIB,$1)
 
 # define a library target <name>.cmxa and <name>.cma
 define OCAML_LIBRARY_template
  $(1).cmxa: lib$(1)_stubs.a $(foreach obj,$($(1)_OBJS),$(obj).cmx)
 	$(call mk-caml-lib-native,$$@, -cclib -l$(1)_stubs $(foreach lib,$(LIBS_$(1)),-cclib $(lib)), $(foreach obj,$($(1)_OBJS),$(obj).cmx))
  $(1).cma: $(foreach obj,$($(1)_OBJS),$(obj).cmo)
-	$(call mk-caml-lib-bytecode,$$@, -dllib dll$(1)_stubs.so -cclib -l$(1)_stubs, $$+)
+	$(call mk-caml-lib-bytecode,$$@, -dllib dll$(1)_stubs.so -cclib -l$(1)_stubs $(foreach lib,$(LIBS_$(1)),-cclib $(lib)), $$+)
  $(1)_stubs.a: $(foreach obj,$$($(1)_C_OBJS),$(obj).o)
-	$(call mk-caml-stubs,$$@, $$+)
+	$(call mk-caml-stubs,$(1), $$+)
  lib$(1)_stubs.a: $(foreach obj,$($(1)_C_OBJS),$(obj).o)
-	$(call mk-caml-lib-stubs,$$@, $$+)
+	$(call mk-caml-lib-stubs,$(1), $$+)
 endef
 
 define OCAML_NOC_LIBRARY_template
tools/ocaml/libs/Makefile +2 -2
@@ -2,8 +2,8 @@ XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
 SUBDIRS= \
-	uuid mmap \
-	log xc eventchn \
+	mmap \
+	xc eventchn \
 	xb xs xl
 
 .PHONY: all
tools/ocaml/libs/eventchn/Makefile +1 -0
@@ -7,6 +7,7 @@ CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_
 OBJS = eventchn
 INTF = $(foreach obj, $(OBJS),$(obj).cmi)
 LIBS = eventchn.cma eventchn.cmxa
+LIBS_eventchn = -L$(XEN_ROOT)/tools/libxc -lxenctrl
 
 LIBS_evtchn = $(LDLIBS_libxenctrl)
 
tools/ocaml/libs/log/META.in deleted +0 -5
deleted file mode 100644
@@ -1,5 +0,0 @@
-version = "@VERSION@"
-description = "Log - logging library"
-requires = "unix"
-archive(byte) = "log.cma"
-archive(native) = "log.cmxa"
tools/ocaml/libs/log/Makefile deleted +0 -44

44 lines not on this page · raw message

tools/ocaml/libs/log/log.ml deleted +0 -258

258 lines not on this page · raw message

tools/ocaml/libs/log/log.mli deleted +0 -55

55 lines not on this page · raw message

tools/ocaml/libs/log/logs.ml deleted +0 -197

197 lines not on this page · raw message

tools/ocaml/libs/log/logs.mli deleted +0 -46

46 lines not on this page · raw message

tools/ocaml/libs/log/syslog.ml deleted +0 -26
deleted file mode 100644
@@ -1,26 +0,0 @@
-(*
- * Copyright (C) 2006-2007 XenSource Ltd.
- * Copyright (C) 2008      Citrix Ltd.
- * Author Vincent Hanquez <[email protected]>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
- *)
-
-type level = Emerg | Alert | Crit | Err | Warning | Notice | Info | Debug
-type options = Cons | Ndelay | Nowait | Odelay | Perror | Pid
-type facility = Auth | Authpriv | Cron | Daemon | Ftp | Kern
-              | Local0 | Local1 | Local2 | Local3
-	      | 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 close : unit -> unit = "stub_closelog"
tools/ocaml/libs/log/syslog.mli deleted +0 -41

41 lines not on this page · raw message

tools/ocaml/libs/log/syslog_stubs.c deleted +0 -75

75 lines not on this page · raw message

tools/ocaml/libs/uuid/META.in deleted +0 -4
deleted file mode 100644
@@ -1,4 +0,0 @@
-version = "@VERSION@"
-description = "Uuid - universal identifer"
-archive(byte) = "uuid.cma"
-archive(native) = "uuid.cmxa"
tools/ocaml/libs/uuid/Makefile deleted +0 -29
deleted file mode 100644
@@ -1,29 +0,0 @@
-TOPLEVEL=$(CURDIR)/../..
-XEN_ROOT=$(TOPLEVEL)/../..
-include $(TOPLEVEL)/common.make
-
-OBJS = uuid
-INTF = $(foreach obj, $(OBJS),$(obj).cmi)
-LIBS = uuid.cma uuid.cmxa
-
-all: $(INTF) $(LIBS) $(PROGRAMS)
-
-bins: $(PROGRAMS)
-
-libs: $(LIBS)
-
-uuid_OBJS = $(OBJS)
-OCAML_NOC_LIBRARY = uuid
-
-.PHONY: install
-install: $(LIBS) META
-	mkdir -p $(OCAMLDESTDIR)
-	ocamlfind remove -destdir $(OCAMLDESTDIR) uuid
-	ocamlfind install -destdir $(OCAMLDESTDIR) -ldconf ignore uuid META $(INTF) $(LIBS) *.a *.cmx
-
-.PHONY: uninstall
-uninstall:
-	ocamlfind remove -destdir $(OCAMLDESTDIR) uuid
-
-include $(TOPLEVEL)/Makefile.rules
-
tools/ocaml/libs/uuid/uuid.ml deleted +0 -100

100 lines not on this page · raw message

tools/ocaml/libs/uuid/uuid.mli deleted +0 -67

67 lines not on this page · raw message

tools/ocaml/libs/xb/Makefile +1 -1
@@ -31,7 +31,7 @@ OCAML_LIBRARY = xb
 
 %.mli: %.ml
 	$(E) " MLI       $@"
-	$(Q)$(OCAMLC) -i $< $o
+	$(Q)$(OCAMLC) $(OCAMLCFLAGS) -i $< $o
 
 .PHONY: install
 install: $(LIBS) META
tools/ocaml/libs/xc/META.in +1 -1
@@ -1,5 +1,5 @@
 version = "@VERSION@"
 description = "Xen Control Interface"
-requires = "mmap,uuid"
+requires = "unix,mmap"
 archive(byte) = "xc.cma"
 archive(native) = "xc.cmxa"
tools/ocaml/libs/xc/Makefile +1 -1
@@ -3,7 +3,7 @@ XEN_ROOT=$(TOPLEVEL)/../..
 include $(TOPLEVEL)/common.make
 
 CFLAGS += -I../mmap $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest)
-OCAMLINCLUDE += -I ../mmap -I ../uuid
+OCAMLINCLUDE += -I ../mmap
 
 OBJS = xc
 INTF = xc.cmi
tools/ocaml/libs/xc/xc.ml +12 -2
@@ -70,6 +70,7 @@ type physinfo =
 	scrub_pages      : nativeint;
 	(* XXX hw_cap *)
 	capabilities     : physinfo_cap_flag list;
+	max_nr_cpus      : int;
 }
 
 type version =
@@ -118,14 +119,23 @@ let with_intf f =
 external _domain_create: handle -> int32 -> domain_create_flag list -> int array -> domid
        = "stub_xc_domain_create"
 
+let int_array_of_uuid_string s =
+	try
+		Scanf.sscanf s
+			"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
+			(fun a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 ->
+				[| a0; a1; a2; a3; a4; a5; a6; a7;
+				   a8; a9; a10; a11; a12; a13; a14; a15 |])
+	with _ -> invalid_arg ("Xc.int_array_of_uuid_string: " ^ s)
+
 let domain_create handle n flags uuid =
-	_domain_create handle n flags (Uuid.int_array_of_uuid uuid)
+	_domain_create handle n flags (int_array_of_uuid_string uuid)
 
 external _domain_sethandle: handle -> domid -> int array -> unit
                           = "stub_xc_domain_sethandle"
 
 let domain_sethandle handle n uuid =
-	_domain_sethandle handle n (Uuid.int_array_of_uuid uuid)
+	_domain_sethandle handle n (int_array_of_uuid_string uuid)
 
 external domain_max_vcpus: handle -> domid -> int -> unit
        = "stub_xc_domain_max_vcpus"
tools/ocaml/libs/xc/xc.mli +3 -6
@@ -52,6 +52,7 @@ type physinfo = {
   free_pages       : nativeint;
   scrub_pages      : nativeint;
   capabilities     : physinfo_cap_flag list;
+  max_nr_cpus      : int; (** compile-time max possible number of nr_cpus *)
 }
 type version = { major : int; minor : int; extra : string; }
 type compile_info = {
@@ -74,12 +75,8 @@ external interface_open : unit -> handle
 external is_fake : unit -> bool = "stub_xc_interface_is_fake"
 external interface_close : handle -> unit = "stub_xc_interface_close"
 val with_intf : (handle -> 'a) -> 'a
-external _domain_create : handle -> int32 -> domain_create_flag list -> int array -> domid
-  = "stub_xc_domain_create"
-val domain_create : handle -> int32 -> domain_create_flag list -> 'a Uuid.t -> domid
-external _domain_sethandle : handle -> domid -> int array -> unit
-  = "stub_xc_domain_sethandle"
-val domain_sethandle : handle -> domid -> 'a Uuid.t -> unit
+val domain_create : handle -> int32 -> domain_create_flag list -> string -> domid
+val domain_sethandle : handle -> domid -> string -> unit
 external domain_max_vcpus : handle -> domid -> int -> unit
   = "stub_xc_domain_max_vcpus"
 external domain_pause : handle -> domid -> unit = "stub_xc_domain_pause"
tools/ocaml/libs/xc/xc_stubs.c +6 -4
@@ -430,7 +430,7 @@ CAMLprim value stub_xc_vcpu_setaffinity(
 
 	for (i=0; i<len; i++) {
 		if (Bool_val(Field(cpumap, i)))
-			c_cpumap[i/8] |= i << (i&7);
+			c_cpumap[i/8] |= 1 << (i&7);
 	}
 	retval = xc_vcpu_setaffinity(_H(xch), _D(domid),
 	                             Int_val(vcpu), c_cpumap);
@@ -466,7 +466,7 @@ CAMLprim value stub_xc_vcpu_getaffinity(
 	ret = caml_alloc(len, 0);
 
 	for (i=0; i<len; i++) {
-		if (c_cpumap[i%8] & 1 << (i&7))
+		if (c_cpumap[i/8] & 1 << (i&7))
 			Store_field(ret, i, Val_true);
 		else
 			Store_field(ret, i, Val_false);
@@ -523,7 +523,7 @@ static char ring[RING_SIZE];
 
 CAMLprim value stub_xc_readconsolering(value xch)
 {
-	unsigned int size = RING_SIZE;
+	unsigned int size = RING_SIZE - 1;
 	char *ring_ptr = ring;
 
 	CAMLparam1(xch);
@@ -534,6 +534,7 @@ CAMLprim value stub_xc_readconsolering(v
 
 	if (retval)
 		failwith_xc(_H(xch));
+
 	ring[size] = '\0';
 	CAMLreturn(caml_copy_string(ring));
 }
@@ -573,7 +574,7 @@ CAMLprim value stub_xc_physinfo(value xc
 		}
 	}
 
-	physinfo = caml_alloc_tuple(9);
+	physinfo = caml_alloc_tuple(10);
 	Store_field(physinfo, 0, Val_int(c_physinfo.threads_per_core));
 	Store_field(physinfo, 1, Val_int(c_physinfo.cores_per_socket));
 	Store_field(physinfo, 2, Val_int(c_physinfo.nr_cpus));
@@ -583,6 +584,7 @@ CAMLprim value stub_xc_physinfo(value xc
 	Store_field(physinfo, 6, caml_copy_nativeint(c_physinfo.free_pages));
 	Store_field(physinfo, 7, caml_copy_nativeint(c_physinfo.scrub_pages));
 	Store_field(physinfo, 8, cap_list);
+	Store_field(physinfo, 9, Val_int(c_physinfo.max_cpu_id + 1));
 
 	CAMLreturn(physinfo);
 }
 tools/ocaml/Makefile.rules          |   10 +-
 tools/ocaml/libs/Makefile           |    4 +-
 tools/ocaml/libs/eventchn/Makefile  |    1 +
 tools/ocaml/libs/log/META.in        |    5 -
 tools/ocaml/libs/log/Makefile       |   44 ------
 tools/ocaml/libs/log/log.ml         |  258 ------------------------------------
 tools/ocaml/libs/log/log.mli        |   55 -------
 tools/ocaml/libs/log/logs.ml        |  197 ---------------------------
 tools/ocaml/libs/log/logs.mli       |   46 ------
 tools/ocaml/libs/log/syslog.ml      |   26 ---
 tools/ocaml/libs/log/syslog.mli     |   41 -----
 tools/ocaml/libs/log/syslog_stubs.c |   75 ----------
 tools/ocaml/libs/uuid/META.in       |    4 -
 tools/ocaml/libs/uuid/Makefile      |   29 ----
 tools/ocaml/libs/uuid/uuid.ml       |  100 -------------
 tools/ocaml/libs/uuid/uuid.mli      |   67 ---------
 tools/ocaml/libs/xb/Makefile        |    2 +-
 tools/ocaml/libs/xc/META.in         |    2 +-
 tools/ocaml/libs/xc/Makefile        |    2 +-
 tools/ocaml/libs/xc/xc.ml           |   14 +-
 tools/ocaml/libs/xc/xc.mli          |    9 +-
 tools/ocaml/libs/xc/xc_stubs.c      |   10 +-
 22 files changed, 32 insertions(+), 969 deletions(-)

# HG changeset patch
# User Zheng Li <[email protected]>
# Date 1312037817 0
# Node ID 9455d912516401c3d7423ea8d4f507c9ec6a2df8 # Parent 42edf1481c5704c8ce1eb171a713b5411df0551a Some recent updates on ocaml xapi-libs

* minor Makefile cleanup
* remove uuid library (oxenstored and other libraries have very little dependency on it, where we can use string instead of specific uuid type)
* remove log library (oxenstored depended on both this xapi-libs log library and a customized logging library of its own, now we have consolidated them and eliminated the heavy weight xapi-libs log library)
* fix small bug in vcpu affinity binding
* fix small bug in read console ring binding
* add an extra field in physinfo binding

tools/ocaml/Makefile.rules +5 -5
@@ -52,20 +52,20 @@ quiet-command = $(if $(V),$1,@printf " %
 mk-caml-lib-native = $(call quiet-command, $(OCAMLOPT) $(OCAMLOPTFLAGS) -a -o $1 $2 $3,MLA,$1)
 mk-caml-lib-bytecode = $(call quiet-command, $(OCAMLC) $(OCAMLCFLAGS) -a -o $1 $2 $3,MLA,$1)
 
-mk-caml-stubs = $(call quiet-command, $(OCAMLMKLIB) -o `basename $1 .a` $2,MKLIB,$1)
+mk-caml-stubs = $(call quiet-command, $(OCAMLMKLIB) $(LIBS_$(1)) -o $(1)_stubs $2,MKLIB,$1)
 mk-caml-lib-stubs = \
-	$(call quiet-command, $(AR) rcs $1 $2 && $(OCAMLMKLIB) -o `basename $1 .a | sed -e 's/^lib//'` $2,MKLIB,$1)
+	$(call quiet-command, $(AR) rcs lib$(1)_stubs.a $2 && $(OCAMLMKLIB) $(LIBS_$(1)) -o $(1)_stubs $2,MKLIB,$1)
 
 # define a library target <name>.cmxa and <name>.cma
 define OCAML_LIBRARY_template
  $(1).cmxa: lib$(1)_stubs.a $(foreach obj,$($(1)_OBJS),$(obj).cmx)
 	$(call mk-caml-lib-native,$$@, -cclib -l$(1)_stubs $(foreach lib,$(LIBS_$(1)),-cclib $(lib)), $(foreach obj,$($(1)_OBJS),$(obj).cmx))
  $(1).cma: $(foreach obj,$($(1)_OBJS),$(obj).cmo)
-	$(call mk-caml-lib-bytecode,$$@, -dllib dll$(1)_stubs.so -cclib -l$(1)_stubs, $$+)
+	$(call mk-caml-lib-bytecode,$$@, -dllib dll$(1)_stubs.so -cclib -l$(1)_stubs $(foreach lib,$(LIBS_$(1)),-cclib $(lib)), $$+)
  $(1)_stubs.a: $(foreach obj,$$($(1)_C_OBJS),$(obj).o)
-	$(call mk-caml-stubs,$$@, $$+)
+	$(call mk-caml-stubs,$(1), $$+)
  lib$(1)_stubs.a: $(foreach obj,$($(1)_C_OBJS),$(obj).o)
-	$(call mk-caml-lib-stubs,$$@, $$+)
+	$(call mk-caml-lib-stubs,$(1), $$+)
 endef
 
 define OCAML_NOC_LIBRARY_template
tools/ocaml/libs/Makefile +2 -2
@@ -2,8 +2,8 @@ XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
 SUBDIRS= \
-	uuid mmap \
-	log xc eventchn \
+	mmap \
+	xc eventchn \
 	xb xs xl
 
 .PHONY: all
tools/ocaml/libs/eventchn/Makefile +1 -0
@@ -7,6 +7,7 @@ CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_
 OBJS = eventchn
 INTF = $(foreach obj, $(OBJS),$(obj).cmi)
 LIBS = eventchn.cma eventchn.cmxa
+LIBS_eventchn = -L$(XEN_ROOT)/tools/libxc -lxenctrl
 
 LIBS_evtchn = $(LDLIBS_libxenctrl)
 
tools/ocaml/libs/log/META.in deleted +0 -5
deleted file mode 100644
@@ -1,5 +0,0 @@
-version = "@VERSION@"
-description = "Log - logging library"
-requires = "unix"
-archive(byte) = "log.cma"
-archive(native) = "log.cmxa"
tools/ocaml/libs/log/Makefile deleted +0 -44

44 lines not on this page · raw message

tools/ocaml/libs/log/log.ml deleted +0 -258

258 lines not on this page · raw message

tools/ocaml/libs/log/log.mli deleted +0 -55

55 lines not on this page · raw message

tools/ocaml/libs/log/logs.ml deleted +0 -197

197 lines not on this page · raw message

tools/ocaml/libs/log/logs.mli deleted +0 -46

46 lines not on this page · raw message

tools/ocaml/libs/log/syslog.ml deleted +0 -26
deleted file mode 100644
@@ -1,26 +0,0 @@
-(*
- * Copyright (C) 2006-2007 XenSource Ltd.
- * Copyright (C) 2008      Citrix Ltd.
- * Author Vincent Hanquez <[email protected]>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; version 2.1 only. with the special
- * exception on linking described in file LICENSE.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
- *)
-
-type level = Emerg | Alert | Crit | Err | Warning | Notice | Info | Debug
-type options = Cons | Ndelay | Nowait | Odelay | Perror | Pid
-type facility = Auth | Authpriv | Cron | Daemon | Ftp | Kern
-              | Local0 | Local1 | Local2 | Local3
-	      | 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 close : unit -> unit = "stub_closelog"
tools/ocaml/libs/log/syslog.mli deleted +0 -41

41 lines not on this page · raw message

tools/ocaml/libs/log/syslog_stubs.c deleted +0 -75

75 lines not on this page · raw message

tools/ocaml/libs/uuid/META.in deleted +0 -4
deleted file mode 100644
@@ -1,4 +0,0 @@
-version = "@VERSION@"
-description = "Uuid - universal identifer"
-archive(byte) = "uuid.cma"
-archive(native) = "uuid.cmxa"
tools/ocaml/libs/uuid/Makefile deleted +0 -29
deleted file mode 100644
@@ -1,29 +0,0 @@
-TOPLEVEL=$(CURDIR)/../..
-XEN_ROOT=$(TOPLEVEL)/../..
-include $(TOPLEVEL)/common.make
-
-OBJS = uuid
-INTF = $(foreach obj, $(OBJS),$(obj).cmi)
-LIBS = uuid.cma uuid.cmxa
-
-all: $(INTF) $(LIBS) $(PROGRAMS)
-
-bins: $(PROGRAMS)
-
-libs: $(LIBS)
-
-uuid_OBJS = $(OBJS)
-OCAML_NOC_LIBRARY = uuid
-
-.PHONY: install
-install: $(LIBS) META
-	mkdir -p $(OCAMLDESTDIR)
-	ocamlfind remove -destdir $(OCAMLDESTDIR) uuid
-	ocamlfind install -destdir $(OCAMLDESTDIR) -ldconf ignore uuid META $(INTF) $(LIBS) *.a *.cmx
-
-.PHONY: uninstall
-uninstall:
-	ocamlfind remove -destdir $(OCAMLDESTDIR) uuid
-
-include $(TOPLEVEL)/Makefile.rules
-
tools/ocaml/libs/uuid/uuid.ml deleted +0 -100

100 lines not on this page · raw message

tools/ocaml/libs/uuid/uuid.mli deleted +0 -67

67 lines not on this page · raw message

tools/ocaml/libs/xb/Makefile +1 -1
@@ -31,7 +31,7 @@ OCAML_LIBRARY = xb
 
 %.mli: %.ml
 	$(E) " MLI       $@"
-	$(Q)$(OCAMLC) -i $< $o
+	$(Q)$(OCAMLC) $(OCAMLCFLAGS) -i $< $o
 
 .PHONY: install
 install: $(LIBS) META
tools/ocaml/libs/xc/META.in +1 -1
@@ -1,5 +1,5 @@
 version = "@VERSION@"
 description = "Xen Control Interface"
-requires = "mmap,uuid"
+requires = "unix,mmap"
 archive(byte) = "xc.cma"
 archive(native) = "xc.cmxa"
tools/ocaml/libs/xc/Makefile +1 -1
@@ -3,7 +3,7 @@ XEN_ROOT=$(TOPLEVEL)/../..
 include $(TOPLEVEL)/common.make
 
 CFLAGS += -I../mmap $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest)
-OCAMLINCLUDE += -I ../mmap -I ../uuid
+OCAMLINCLUDE += -I ../mmap
 
 OBJS = xc
 INTF = xc.cmi
tools/ocaml/libs/xc/xc.ml +12 -2
@@ -70,6 +70,7 @@ type physinfo =
 	scrub_pages      : nativeint;
 	(* XXX hw_cap *)
 	capabilities     : physinfo_cap_flag list;
+	max_nr_cpus      : int;
 }
 
 type version =
@@ -118,14 +119,23 @@ let with_intf f =
 external _domain_create: handle -> int32 -> domain_create_flag list -> int array -> domid
        = "stub_xc_domain_create"
 
+let int_array_of_uuid_string s =
+	try
+		Scanf.sscanf s
+			"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
+			(fun a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 ->
+				[| a0; a1; a2; a3; a4; a5; a6; a7;
+				   a8; a9; a10; a11; a12; a13; a14; a15 |])
+	with _ -> invalid_arg ("Xc.int_array_of_uuid_string: " ^ s)
+
 let domain_create handle n flags uuid =
-	_domain_create handle n flags (Uuid.int_array_of_uuid uuid)
+	_domain_create handle n flags (int_array_of_uuid_string uuid)
 
 external _domain_sethandle: handle -> domid -> int array -> unit
                           = "stub_xc_domain_sethandle"
 
 let domain_sethandle handle n uuid =
-	_domain_sethandle handle n (Uuid.int_array_of_uuid uuid)
+	_domain_sethandle handle n (int_array_of_uuid_string uuid)
 
 external domain_max_vcpus: handle -> domid -> int -> unit
        = "stub_xc_domain_max_vcpus"
tools/ocaml/libs/xc/xc.mli +3 -6
@@ -52,6 +52,7 @@ type physinfo = {
   free_pages       : nativeint;
   scrub_pages      : nativeint;
   capabilities     : physinfo_cap_flag list;
+  max_nr_cpus      : int; (** compile-time max possible number of nr_cpus *)
 }
 type version = { major : int; minor : int; extra : string; }
 type compile_info = {
@@ -74,12 +75,8 @@ external interface_open : unit -> handle
 external is_fake : unit -> bool = "stub_xc_interface_is_fake"
 external interface_close : handle -> unit = "stub_xc_interface_close"
 val with_intf : (handle -> 'a) -> 'a
-external _domain_create : handle -> int32 -> domain_create_flag list -> int array -> domid
-  = "stub_xc_domain_create"
-val domain_create : handle -> int32 -> domain_create_flag list -> 'a Uuid.t -> domid
-external _domain_sethandle : handle -> domid -> int array -> unit
-  = "stub_xc_domain_sethandle"
-val domain_sethandle : handle -> domid -> 'a Uuid.t -> unit
+val domain_create : handle -> int32 -> domain_create_flag list -> string -> domid
+val domain_sethandle : handle -> domid -> string -> unit
 external domain_max_vcpus : handle -> domid -> int -> unit
   = "stub_xc_domain_max_vcpus"
 external domain_pause : handle -> domid -> unit = "stub_xc_domain_pause"
tools/ocaml/libs/xc/xc_stubs.c +6 -4
@@ -430,7 +430,7 @@ CAMLprim value stub_xc_vcpu_setaffinity(
 
 	for (i=0; i<len; i++) {
 		if (Bool_val(Field(cpumap, i)))
-			c_cpumap[i/8] |= i << (i&7);
+			c_cpumap[i/8] |= 1 << (i&7);
 	}
 	retval = xc_vcpu_setaffinity(_H(xch), _D(domid),
 	                             Int_val(vcpu), c_cpumap);
@@ -466,7 +466,7 @@ CAMLprim value stub_xc_vcpu_getaffinity(
 	ret = caml_alloc(len, 0);
 
 	for (i=0; i<len; i++) {
-		if (c_cpumap[i%8] & 1 << (i&7))
+		if (c_cpumap[i/8] & 1 << (i&7))
 			Store_field(ret, i, Val_true);
 		else
 			Store_field(ret, i, Val_false);
@@ -523,7 +523,7 @@ static char ring[RING_SIZE];
 
 CAMLprim value stub_xc_readconsolering(value xch)
 {
-	unsigned int size = RING_SIZE;
+	unsigned int size = RING_SIZE - 1;
 	char *ring_ptr = ring;
 
 	CAMLparam1(xch);
@@ -534,6 +534,7 @@ CAMLprim value stub_xc_readconsolering(v
 
 	if (retval)
 		failwith_xc(_H(xch));
+
 	ring[size] = '\0';
 	CAMLreturn(caml_copy_string(ring));
 }
@@ -573,7 +574,7 @@ CAMLprim value stub_xc_physinfo(value xc
 		}
 	}
 
-	physinfo = caml_alloc_tuple(9);
+	physinfo = caml_alloc_tuple(10);
 	Store_field(physinfo, 0, Val_int(c_physinfo.threads_per_core));
 	Store_field(physinfo, 1, Val_int(c_physinfo.cores_per_socket));
 	Store_field(physinfo, 2, Val_int(c_physinfo.nr_cpus));
@@ -583,6 +584,7 @@ CAMLprim value stub_xc_physinfo(value xc
 	Store_field(physinfo, 6, caml_copy_nativeint(c_physinfo.free_pages));
 	Store_field(physinfo, 7, caml_copy_nativeint(c_physinfo.scrub_pages));
 	Store_field(physinfo, 8, cap_list);
+	Store_field(physinfo, 9, Val_int(c_physinfo.max_cpu_id + 1));
 
 	CAMLreturn(physinfo);
 }

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

author
#2 lore raw

PATCH 1/1 Remove oxenstored's dependency on the log library of xapi-libs

In reply to Zheng Li

... by consolidating some of the functions with its own logging facility.

----

tools/ocaml/xenstored/Makefile +0 -4
@@ -3,9 +3,7 @@ OCAML_TOPLEVEL = $(CURDIR)/..
 include $(OCAML_TOPLEVEL)/common.make
 
 OCAMLINCLUDE += \
-	-I $(OCAML_TOPLEVEL)/libs/log \
 	-I $(OCAML_TOPLEVEL)/libs/xb \
-	-I $(OCAML_TOPLEVEL)/libs/uuid \
 	-I $(OCAML_TOPLEVEL)/libs/mmap \
 	-I $(OCAML_TOPLEVEL)/libs/xc \
 	-I $(OCAML_TOPLEVEL)/libs/eventchn
@@ -34,9 +32,7 @@ OBJS = define \
 INTF = symbol.cmi trie.cmi
 XENSTOREDLIBS = \
 	unix.cmxa \
-	$(OCAML_TOPLEVEL)/libs/uuid/uuid.cmxa \
 	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/mmap $(OCAML_TOPLEVEL)/libs/mmap/mmap.cmxa \
-	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/log $(OCAML_TOPLEVEL)/libs/log/log.cmxa \
 	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/eventchn $(OCAML_TOPLEVEL)/libs/eventchn/eventchn.cmxa \
 	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/xc $(OCAML_TOPLEVEL)/libs/xc/xc.cmxa \
 	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/xb $(OCAML_TOPLEVEL)/libs/xb/xb.cmxa \
tools/ocaml/xenstored/connection.ml +5 -0
@@ -232,3 +232,8 @@ let dump con chan =
 			Printf.fprintf chan "watch,%d,%s,%s\n" domid (Utils.hexify path) (Utils.hexify token)
 			) (list_watches con);
 	| None -> ()
+
+let debug con =
+	let domid = get_domstr con in
+	let watches = List.map (fun (path, token) -> Printf.sprintf "watch %s: %s %s\n" domid path token) (list_watches con) in
+	String.concat "" watches
tools/ocaml/xenstored/connections.ml +6 -1
@@ -15,7 +15,7 @@
  * GNU Lesser General Public License for more details.
  *)
 
-let debug fmt = Logs.debug "general" fmt
+let debug fmt = Logging.debug "connections" fmt
 
 type t = {
 	mutable anonymous: Connection.t list;
@@ -165,3 +165,8 @@ let stats cons =
 	);
 	(List.length cons.anonymous, !nb_ops_anon, !nb_watchs_anon,
 	 Hashtbl.length cons.domains, !nb_ops_dom, !nb_watchs_dom)
+
+let debug cons =
+	let anonymous = List.map Connection.debug cons.anonymous in
+	let domains = Hashtbl.fold (fun _ con accu -> Connection.debug con :: accu) cons.domains [] in
+	String.concat "" (domains @ anonymous)
tools/ocaml/xenstored/disk.ml +1 -1
@@ -17,7 +17,7 @@
 let enable = ref false
 let xs_daemon_database = "/var/run/xenstored/db"
 
-let error = Logs.error "general"
+let error fmt = Logging.error "disk" fmt
 
 (* unescape utils *)
 exception Bad_escape
tools/ocaml/xenstored/domain.ml +1 -1
@@ -16,7 +16,7 @@
 
 open Printf
 
-let debug fmt = Logs.debug "general" fmt
+let debug fmt = Logging.debug "domain" fmt
 
 type t =
 {
tools/ocaml/xenstored/domains.ml +4 -2
@@ -14,6 +14,8 @@
  * GNU Lesser General Public License for more details.
  *)
 
+let debug fmt = Logging.debug "domains" fmt
+
 type domains = {
 	eventchn: Event.t;
 	table: (Xc.domid, Domain.t) Hashtbl.t;
@@ -35,7 +37,7 @@ let cleanup xc doms =
 		try
 			let info = Xc.domain_getinfo xc id in
 			if info.Xc.shutdown || info.Xc.dying then (
-				Logs.debug "general" "Domain %u died (dying=%b, shutdown %b -- code %d)"
+				debug "Domain %u died (dying=%b, shutdown %b -- code %d)"
 				                    id info.Xc.dying info.Xc.shutdown info.Xc.shutdown_code;
 				if info.Xc.dying then
 					dead_dom := id :: !dead_dom
@@ -43,7 +45,7 @@ let cleanup xc doms =
 					notify := true;
 			)
 		with Xc.Error _ ->
-			Logs.debug "general" "Domain %u died -- no domain info" id;
+			debug "Domain %u died -- no domain info" id;
 			dead_dom := id :: !dead_dom;
 		) doms.table;
 	List.iter (fun id ->
tools/ocaml/xenstored/logging.ml +162 -140

348 lines not on this page · raw message

tools/ocaml/xenstored/perms.ml +5 -3
@@ -15,6 +15,8 @@
  * GNU Lesser General Public License for more details.
  *)
 
+let info fmt = Logging.info "perms" fmt
+
 open Stdext
 
 let activate = ref true
@@ -145,16 +147,16 @@ let check (connection:Connection.t) requ
 		in
 		match perm, request with
 		| NONE, _ ->
-			Logs.info "io" "Permission denied: Domain %d has no permission" domainid;
+			info "Permission denied: Domain %d has no permission" domainid;
 			false
 		| RDWR, _ -> true
 		| READ, READ -> true
 		| WRITE, WRITE -> true
 		| READ, _ ->
-			Logs.info "io" "Permission denied: Domain %d has read only access" domainid;
+			info "Permission denied: Domain %d has read only access" domainid;
 			false
 		| WRITE, _ ->
-			Logs.info "io" "Permission denied: Domain %d has write only access" domainid;
+			info "Permission denied: Domain %d has write only access" domainid;
 			false
 	in
 	if !activate
tools/ocaml/xenstored/process.ml +13 -7
@@ -14,6 +14,9 @@
  * GNU Lesser General Public License for more details.
  *)
 
+let error fmt = Logging.error "process" fmt
+let info fmt = Logging.info "process" fmt
+
 open Printf
 open Stdext
 
@@ -79,7 +82,7 @@ let create_implicit_path t perm path =
 
 (* packets *)
 let do_debug con t domains cons data =
-	if not !allow_debug
+	if not (Connection.is_dom0 con) && not !allow_debug
 	then None
 	else try match split None '\000' data with
 	| "print" :: msg :: _ ->
@@ -89,6 +92,9 @@ let do_debug con t domains cons data =
 		let domid = int_of_string domid in
 		let quota = (Store.get_quota t.Transaction.store) in
 		Some (Quota.to_string quota domid ^ "\000")
+	| "watches" :: _ ->
+		let watches = Connections.debug cons in
+		Some (watches ^ "\000")
 	| "mfn" :: domid :: _ ->
 		let domid = int_of_string domid in
 		let con = Connections.find_domain cons domid in
@@ -162,9 +168,10 @@ let do_introduce con t domains cons data
 		| _                         -> raise Invalid_Cmd_Args;
 		in
 	let dom =
-		if Domains.exist domains domid then
+		if Domains.exist domains domid then begin
+			Connections.fire_spec_watches cons "@introduceDomain";
 			Domains.find domains domid
-		else try
+		end else try
 			let ndom = Xc.with_intf (fun xc ->
 				Domains.create xc domains domid mfn port) in
 			Connections.add_domain cons ndom;
@@ -357,8 +364,7 @@ let process_packet ~store ~cons ~doms ~c
 			in
 		input_handle_error ~cons ~doms ~fct ~ty ~con ~t ~rid ~data;
 	with exn ->
-		Logs.error "general" "process packet: %s"
-		          (Printexc.to_string exn);
+		error "process packet: %s" (Printexc.to_string exn);
 		Connection.send_error con tid rid "EIO"
 
 let write_access_log ~ty ~tid ~con ~data =
@@ -372,7 +378,7 @@ let do_input store cons doms con =
 		let packet = Connection.pop_in con in
 		let tid, rid, ty, data = Xb.Packet.unpack packet in
 		(* As we don't log IO, do not call an unnecessary sanitize_data 
-		   Logs.info "io" "[%s] -> [%d] %s \"%s\""
+		   info "[%s] -> [%d] %s \"%s\""
 		         (Connection.get_domstr con) tid
 		         (Xb.Op.to_string ty) (sanitize_data data); *)
 		process_packet ~store ~cons ~doms ~con ~tid ~rid ~ty ~data;
@@ -386,7 +392,7 @@ let do_output store cons doms con =
 			let packet = Connection.peek_output con in
 			let tid, rid, ty, data = Xb.Packet.unpack packet in
 			(* As we don't log IO, do not call an unnecessary sanitize_data 
-			   Logs.info "io" "[%s] <- %s \"%s\""
+			   info "[%s] <- %s \"%s\""
 			         (Connection.get_domstr con)
 			         (Xb.Op.to_string ty) (sanitize_data data);*)
 			write_answer_log ~ty ~tid ~con ~data;
tools/ocaml/xenstored/quota.ml +1 -1
@@ -18,7 +18,7 @@ exception Limit_reached
 exception Data_too_big
 exception Transaction_opened
 
-let warn fmt = Logs.warn "general" fmt
+let warn fmt = Logging.warn "quota" fmt
 let activate = ref true
 let maxent = ref (10000)
 let maxsize = ref (4096)
tools/ocaml/xenstored/store.ml +1 -1
@@ -83,7 +83,7 @@ let check_perm node connection request =
 let check_owner node connection =
 	if not (Perms.check_owner connection node.perms)
 	then begin
-		Logs.info "io" "Permission denied: Domain %d not owner" (get_owner node);
+		Logging.info "store|node" "Permission denied: Domain %d not owner" (get_owner node);
 		raise Define.Permission_denied;
 	end
 
tools/ocaml/xenstored/xenstored.conf +10 -5
@@ -22,9 +22,14 @@ quota-transaction = 10
 # Activate filed base backend
 persistant = false
 
-# Logs
-log = error;general;file:/var/log/xenstored.log
-log = warn;general;file:/var/log/xenstored.log
-log = info;general;file:/var/log/xenstored.log
+# Xenstored logs
+# xenstored-log-file = /var/log/xenstored.log
+# xenstored-log-level = null
+# xenstored-log-nb-files = 10
 
-# log = debug;io;file:/var/log/xenstored-io.log
+# Xenstored access logs
+# access-log-file = /var/log/xenstored-access.log
+# access-log-nb-lines = 13215
+# acesss-log-nb-chars = 180
+# access-log-special-ops = false
+
tools/ocaml/xenstored/xenstored.ml +28 -34

111 lines not on this page · raw message

 tools/ocaml/xenstored/Makefile       |    4 -
 tools/ocaml/xenstored/connection.ml  |    5 +
 tools/ocaml/xenstored/connections.ml |    7 +-
 tools/ocaml/xenstored/disk.ml        |    2 +-
 tools/ocaml/xenstored/domain.ml      |    2 +-
 tools/ocaml/xenstored/domains.ml     |    6 +-
 tools/ocaml/xenstored/logging.ml     |  302 ++++++++++++++++++----------------
 tools/ocaml/xenstored/perms.ml       |    8 +-
 tools/ocaml/xenstored/process.ml     |   20 +-
 tools/ocaml/xenstored/quota.ml       |    2 +-
 tools/ocaml/xenstored/store.ml       |    2 +-
 tools/ocaml/xenstored/xenstored.conf |   15 +-
 tools/ocaml/xenstored/xenstored.ml   |   62 +++---
 13 files changed, 237 insertions(+), 200 deletions(-)

# HG changeset patch
# User Zheng Li <[email protected]>
# Date 1312038133 0
# Node ID 6cb432bc2d1d73d309318136db9e39b76e2ba326
# Parent 9455d912516401c3d7423ea8d4f507c9ec6a2df8 Remove oxenstored's dependency on the log library of xapi-libs

... by consolidating some of the functions with its own logging facility.

tools/ocaml/xenstored/Makefile +0 -4
@@ -3,9 +3,7 @@ OCAML_TOPLEVEL = $(CURDIR)/..
 include $(OCAML_TOPLEVEL)/common.make
 
 OCAMLINCLUDE += \
-	-I $(OCAML_TOPLEVEL)/libs/log \
 	-I $(OCAML_TOPLEVEL)/libs/xb \
-	-I $(OCAML_TOPLEVEL)/libs/uuid \
 	-I $(OCAML_TOPLEVEL)/libs/mmap \
 	-I $(OCAML_TOPLEVEL)/libs/xc \
 	-I $(OCAML_TOPLEVEL)/libs/eventchn
@@ -34,9 +32,7 @@ OBJS = define \
 INTF = symbol.cmi trie.cmi
 XENSTOREDLIBS = \
 	unix.cmxa \
-	$(OCAML_TOPLEVEL)/libs/uuid/uuid.cmxa \
 	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/mmap $(OCAML_TOPLEVEL)/libs/mmap/mmap.cmxa \
-	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/log $(OCAML_TOPLEVEL)/libs/log/log.cmxa \
 	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/eventchn $(OCAML_TOPLEVEL)/libs/eventchn/eventchn.cmxa \
 	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/xc $(OCAML_TOPLEVEL)/libs/xc/xc.cmxa \
 	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/xb $(OCAML_TOPLEVEL)/libs/xb/xb.cmxa \
tools/ocaml/xenstored/connection.ml +5 -0
@@ -232,3 +232,8 @@ let dump con chan =
 			Printf.fprintf chan "watch,%d,%s,%s\n" domid (Utils.hexify path) (Utils.hexify token)
 			) (list_watches con);
 	| None -> ()
+
+let debug con =
+	let domid = get_domstr con in
+	let watches = List.map (fun (path, token) -> Printf.sprintf "watch %s: %s %s\n" domid path token) (list_watches con) in
+	String.concat "" watches
tools/ocaml/xenstored/connections.ml +6 -1
@@ -15,7 +15,7 @@
  * GNU Lesser General Public License for more details.
  *)
 
-let debug fmt = Logs.debug "general" fmt
+let debug fmt = Logging.debug "connections" fmt
 
 type t = {
 	mutable anonymous: Connection.t list;
@@ -165,3 +165,8 @@ let stats cons =
 	);
 	(List.length cons.anonymous, !nb_ops_anon, !nb_watchs_anon,
 	 Hashtbl.length cons.domains, !nb_ops_dom, !nb_watchs_dom)
+
+let debug cons =
+	let anonymous = List.map Connection.debug cons.anonymous in
+	let domains = Hashtbl.fold (fun _ con accu -> Connection.debug con :: accu) cons.domains [] in
+	String.concat "" (domains @ anonymous)
tools/ocaml/xenstored/disk.ml +1 -1
@@ -17,7 +17,7 @@
 let enable = ref false
 let xs_daemon_database = "/var/run/xenstored/db"
 
-let error = Logs.error "general"
+let error fmt = Logging.error "disk" fmt
 
 (* unescape utils *)
 exception Bad_escape
tools/ocaml/xenstored/domain.ml +1 -1
@@ -16,7 +16,7 @@
 
 open Printf
 
-let debug fmt = Logs.debug "general" fmt
+let debug fmt = Logging.debug "domain" fmt
 
 type t =
 {
tools/ocaml/xenstored/domains.ml +4 -2
@@ -14,6 +14,8 @@
  * GNU Lesser General Public License for more details.
  *)
 
+let debug fmt = Logging.debug "domains" fmt
+
 type domains = {
 	eventchn: Event.t;
 	table: (Xc.domid, Domain.t) Hashtbl.t;
@@ -35,7 +37,7 @@ let cleanup xc doms =
 		try
 			let info = Xc.domain_getinfo xc id in
 			if info.Xc.shutdown || info.Xc.dying then (
-				Logs.debug "general" "Domain %u died (dying=%b, shutdown %b -- code %d)"
+				debug "Domain %u died (dying=%b, shutdown %b -- code %d)"
 				                    id info.Xc.dying info.Xc.shutdown info.Xc.shutdown_code;
 				if info.Xc.dying then
 					dead_dom := id :: !dead_dom
@@ -43,7 +45,7 @@ let cleanup xc doms =
 					notify := true;
 			)
 		with Xc.Error _ ->
-			Logs.debug "general" "Domain %u died -- no domain info" id;
+			debug "Domain %u died -- no domain info" id;
 			dead_dom := id :: !dead_dom;
 		) doms.table;
 	List.iter (fun id ->
tools/ocaml/xenstored/logging.ml +162 -140

348 lines not on this page · raw message

tools/ocaml/xenstored/perms.ml +5 -3
@@ -15,6 +15,8 @@
  * GNU Lesser General Public License for more details.
  *)
 
+let info fmt = Logging.info "perms" fmt
+
 open Stdext
 
 let activate = ref true
@@ -145,16 +147,16 @@ let check (connection:Connection.t) requ
 		in
 		match perm, request with
 		| NONE, _ ->
-			Logs.info "io" "Permission denied: Domain %d has no permission" domainid;
+			info "Permission denied: Domain %d has no permission" domainid;
 			false
 		| RDWR, _ -> true
 		| READ, READ -> true
 		| WRITE, WRITE -> true
 		| READ, _ ->
-			Logs.info "io" "Permission denied: Domain %d has read only access" domainid;
+			info "Permission denied: Domain %d has read only access" domainid;
 			false
 		| WRITE, _ ->
-			Logs.info "io" "Permission denied: Domain %d has write only access" domainid;
+			info "Permission denied: Domain %d has write only access" domainid;
 			false
 	in
 	if !activate
tools/ocaml/xenstored/process.ml +13 -7
@@ -14,6 +14,9 @@
  * GNU Lesser General Public License for more details.
  *)
 
+let error fmt = Logging.error "process" fmt
+let info fmt = Logging.info "process" fmt
+
 open Printf
 open Stdext
 
@@ -79,7 +82,7 @@ let create_implicit_path t perm path =
 
 (* packets *)
 let do_debug con t domains cons data =
-	if not !allow_debug
+	if not (Connection.is_dom0 con) && not !allow_debug
 	then None
 	else try match split None '\000' data with
 	| "print" :: msg :: _ ->
@@ -89,6 +92,9 @@ let do_debug con t domains cons data =
 		let domid = int_of_string domid in
 		let quota = (Store.get_quota t.Transaction.store) in
 		Some (Quota.to_string quota domid ^ "\000")
+	| "watches" :: _ ->
+		let watches = Connections.debug cons in
+		Some (watches ^ "\000")
 	| "mfn" :: domid :: _ ->
 		let domid = int_of_string domid in
 		let con = Connections.find_domain cons domid in
@@ -162,9 +168,10 @@ let do_introduce con t domains cons data
 		| _                         -> raise Invalid_Cmd_Args;
 		in
 	let dom =
-		if Domains.exist domains domid then
+		if Domains.exist domains domid then begin
+			Connections.fire_spec_watches cons "@introduceDomain";
 			Domains.find domains domid
-		else try
+		end else try
 			let ndom = Xc.with_intf (fun xc ->
 				Domains.create xc domains domid mfn port) in
 			Connections.add_domain cons ndom;
@@ -357,8 +364,7 @@ let process_packet ~store ~cons ~doms ~c
 			in
 		input_handle_error ~cons ~doms ~fct ~ty ~con ~t ~rid ~data;
 	with exn ->
-		Logs.error "general" "process packet: %s"
-		          (Printexc.to_string exn);
+		error "process packet: %s" (Printexc.to_string exn);
 		Connection.send_error con tid rid "EIO"
 
 let write_access_log ~ty ~tid ~con ~data =
@@ -372,7 +378,7 @@ let do_input store cons doms con =
 		let packet = Connection.pop_in con in
 		let tid, rid, ty, data = Xb.Packet.unpack packet in
 		(* As we don't log IO, do not call an unnecessary sanitize_data 
-		   Logs.info "io" "[%s] -> [%d] %s \"%s\""
+		   info "[%s] -> [%d] %s \"%s\""
 		         (Connection.get_domstr con) tid
 		         (Xb.Op.to_string ty) (sanitize_data data); *)
 		process_packet ~store ~cons ~doms ~con ~tid ~rid ~ty ~data;
@@ -386,7 +392,7 @@ let do_output store cons doms con =
 			let packet = Connection.peek_output con in
 			let tid, rid, ty, data = Xb.Packet.unpack packet in
 			(* As we don't log IO, do not call an unnecessary sanitize_data 
-			   Logs.info "io" "[%s] <- %s \"%s\""
+			   info "[%s] <- %s \"%s\""
 			         (Connection.get_domstr con)
 			         (Xb.Op.to_string ty) (sanitize_data data);*)
 			write_answer_log ~ty ~tid ~con ~data;
tools/ocaml/xenstored/quota.ml +1 -1
@@ -18,7 +18,7 @@ exception Limit_reached
 exception Data_too_big
 exception Transaction_opened
 
-let warn fmt = Logs.warn "general" fmt
+let warn fmt = Logging.warn "quota" fmt
 let activate = ref true
 let maxent = ref (10000)
 let maxsize = ref (4096)
tools/ocaml/xenstored/store.ml +1 -1
@@ -83,7 +83,7 @@ let check_perm node connection request =
 let check_owner node connection =
 	if not (Perms.check_owner connection node.perms)
 	then begin
-		Logs.info "io" "Permission denied: Domain %d not owner" (get_owner node);
+		Logging.info "store|node" "Permission denied: Domain %d not owner" (get_owner node);
 		raise Define.Permission_denied;
 	end
 
tools/ocaml/xenstored/xenstored.conf +10 -5
@@ -22,9 +22,14 @@ quota-transaction = 10
 # Activate filed base backend
 persistant = false
 
-# Logs
-log = error;general;file:/var/log/xenstored.log
-log = warn;general;file:/var/log/xenstored.log
-log = info;general;file:/var/log/xenstored.log
+# Xenstored logs
+# xenstored-log-file = /var/log/xenstored.log
+# xenstored-log-level = null
+# xenstored-log-nb-files = 10
 
-# log = debug;io;file:/var/log/xenstored-io.log
+# Xenstored access logs
+# access-log-file = /var/log/xenstored-access.log
+# access-log-nb-lines = 13215
+# acesss-log-nb-chars = 180
+# access-log-special-ops = false
+
tools/ocaml/xenstored/xenstored.ml +28 -34

111 lines not on this page · raw message

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

author
#3 lore raw

PATCH 1/1 Add xenbus-only communication switch for xenstore clients/API

In reply to Zheng Li

Currently, xenstore clients default to socket communication mode and only fallback to xenbus if the former is not present. This is a reasonable choice for both normal hosts (Dom0) and normal VMs (DomU), but it would cause troubles for SDK/DDK VMs which are playing both host and VM roles. In such VMs, xenstore clients sometimes need to talk with the xenstored running inside the VM as a Dom0 client via socket, and sometimes need to talk with the xenstored running on the real host as a DomU client via xenbus (e.g. as guest agent to report information back to the real host). With current design, the xenstore clients in a SDK/DDK VM will always talk to its own xenstored running inside the VM, and there is no option for us to enforce xenbus communication when necessary.

In this patch, we add an extra flag XS_OPEN_XENBUSONLY (and also a command line option "-b") corresponding to the current XS_OPEN_SOCKETONLY flag (and the "-s" option). The algorithm of choosing communication method becomes:

* As before, XENSTORED_PATH environment variable still has the highest priority over any other options
* If XS_OPEN_SOCKETONLY flag is set, xenstore clients will always use socket communication and will not try xenbus communication even if socket communication is not feasible
* If XS_OPEN_XENBUSONLY flag is set, xenstore clients will always use xenbus communication and will not try socket communication even if xenbus communication is not feasible
* If both options are unset or both options are set, socket communication will have the higher priority, and xenbus communication will take place only when the socket communication is not feasible.

To avoid having to add these switches everywhere, three environment variables of the same name i.e. "XS_OPEN_XXXONLY" are added and will have the same effect (in addition to) as passing explicit flags/options to the xs_open primitive if not empty.

----

tools/python/xen/lowlevel/xs/xs.c +11 -5
@@ -898,15 +898,21 @@ fail:
 static int
 xshandle_init(XsHandle *self, PyObject *args, PyObject *kwds)
 {
-    static char *kwd_spec[] = { "readonly", NULL };
-    static char *arg_spec = "|i";
-    int readonly = 0;
+    static char *kwd_spec[] = { "readonly", "socket", "xenbus", NULL };
+    static char *arg_spec = "|iii";
+    int readonly = 0, socket = 0, xenbus = 0;
+    unsigned long flags = 0;
 
     if (!PyArg_ParseTupleAndKeywords(args, kwds, arg_spec, kwd_spec,
-                                     &readonly))
+                                     &readonly, &socket, &xenbus))
         goto fail;
 
-    self->xh = (readonly ? xs_daemon_open_readonly() : xs_daemon_open());
+    flags |= (readonly ? XS_OPEN_READONLY : 0);
+    flags |= (socket ? XS_OPEN_SOCKETONLY : 0);
+    flags |= (xenbus ? XS_OPEN_XENBUSONLY : 0);
+
+    self->xh = xs_open(flags);
+
     if (!self->xh)
         goto fail;
 
tools/xenstore/xenstore_client.c +17 -12
@@ -78,24 +78,24 @@ usage(enum mode mode, int incl_mode, con
 	errx(1, "Usage: %s <mode> [-h] [...]", progname);
     case MODE_read:
 	mstr = incl_mode ? "read " : "";
-	errx(1, "Usage: %s %s[-h] [-p] [-s] key [...]", progname, mstr);
+	errx(1, "Usage: %s %s[-h] [-p] [-s|-b] key [...]", progname, mstr);
     case MODE_write:
 	mstr = incl_mode ? "write " : "";
-	errx(1, "Usage: %s %s[-h] [-s] key value [...]", progname, mstr);
+	errx(1, "Usage: %s %s[-h] [-s|-b] key value [...]", progname, mstr);
     case MODE_rm:
 	mstr = incl_mode ? "rm " : "";
-	errx(1, "Usage: %s %s[-h] [-s] [-t] key [...]", progname, mstr);
+	errx(1, "Usage: %s %s[-h] [-s|-b] [-t] key [...]", progname, mstr);
     case MODE_exists:
 	mstr = incl_mode ? "exists " : "";
     case MODE_list:
 	mstr = mstr ? : incl_mode ? "list " : "";
-	errx(1, "Usage: %s %s[-h] [-p] [-s] key [...]", progname, mstr);
+	errx(1, "Usage: %s %s[-h] [-p] [-s|-b] key [...]", progname, mstr);
     case MODE_ls:
 	mstr = mstr ? : incl_mode ? "ls " : "";
-	errx(1, "Usage: %s %s[-h] [-f] [-p] [-s] [path]", progname, mstr);
+	errx(1, "Usage: %s %s[-h] [-f] [-p] [-s|-b] [path]", progname, mstr);
     case MODE_chmod:
 	mstr = incl_mode ? "chmod " : "";
-	errx(1, "Usage: %s %s[-h] [-u] [-r] [-s] key <mode [modes...]>", progname, mstr);
+	errx(1, "Usage: %s %s[-h] [-u] [-r] [-s|-b] key <mode [modes...]>", progname, mstr);
     case MODE_watch:
 	mstr = incl_mode ? "watch " : "";
 	errx(1, "Usage: %s %s[-h] [-n NR] key", progname, mstr);
@@ -496,7 +496,8 @@ main(int argc, char **argv)
 {
     struct xs_handle *xsh;
     xs_transaction_t xth = XBT_NULL;
-    int ret = 0, socket = 0;
+    int ret = 0;
+    unsigned long flags = 0;
     int prefix = 0;
     int tidy = 0;
     int upto = 0;
@@ -531,6 +532,7 @@ main(int argc, char **argv)
 	    {"help",    0, 0, 'h'},
 	    {"flat",    0, 0, 'f'}, /* MODE_ls */
 	    {"socket",  0, 0, 's'},
+	    {"xenbus",  0, 0, 'b'},
 	    {"prefix",  0, 0, 'p'}, /* MODE_read || MODE_list || MODE_ls */
 	    {"tidy",    0, 0, 't'}, /* MODE_rm */
 	    {"upto",    0, 0, 'u'}, /* MODE_chmod */
@@ -539,7 +541,7 @@ main(int argc, char **argv)
 	    {0, 0, 0, 0}
 	};
 
-	c = getopt_long(argc - switch_argv, argv + switch_argv, "hfspturn:",
+	c = getopt_long(argc - switch_argv, argv + switch_argv, "hfsbpturn:",
 			long_options, &index);
 	if (c == -1)
 	    break;
@@ -557,9 +559,12 @@ main(int argc, char **argv)
 		usage(mode, switch_argv, argv[0]);
 	    }
             break;
-        case 's':
-            socket = 1;
-            break;
+	case 's':
+	    flags |= XS_OPEN_SOCKETONLY;
+	    break;
+	case 'b':
+	    flags |= XS_OPEN_XENBUSONLY;
+	    break;
 	case 'p':
 	    if ( mode == MODE_read || mode == MODE_list || mode == MODE_ls )
 		prefix = 1;
@@ -633,7 +638,7 @@ main(int argc, char **argv)
 	    max_width = ws.ws_col - 2;
     }
 
-    xsh = xs_open(socket ? XS_OPEN_SOCKETONLY : 0);
+    xsh = xs_open(flags);
     if (xsh == NULL) err(1, "xs_open");
 
 again:
tools/xenstore/xs.c +11 -5
@@ -257,12 +257,18 @@ struct xs_handle *xs_open(unsigned long 
 {
 	struct xs_handle *xsh = NULL;
 
-	if (flags & XS_OPEN_READONLY)
-		xsh = get_handle(xs_daemon_socket_ro(), flags);
-	else
-		xsh = get_handle(xs_daemon_socket(), flags);
+	flags |= (getenv("XS_OPEN_READONLY") ? XS_OPEN_READONLY : 0);
+	flags |= (getenv("XS_OPEN_SOCKETONLY") ? XS_OPEN_SOCKETONLY : 0);
+	flags |= (getenv("XS_OPEN_XENBUSONLY") ? XS_OPEN_XENBUSONLY : 0);
+       
+	if ((flags & XS_OPEN_SOCKETONLY) || !(flags & XS_OPEN_XENBUSONLY)) {
+		if (flags & XS_OPEN_READONLY)
+			xsh = get_handle(xs_daemon_socket_ro(), flags);
+		else
+			xsh = get_handle(xs_daemon_socket(), flags);
+	}
 
-	if (!xsh && !(flags & XS_OPEN_SOCKETONLY))
+	if (!xsh && ((flags & XS_OPEN_XENBUSONLY) || !(flags & XS_OPEN_SOCKETONLY)))
 		xsh = get_handle(xs_domain_dev(), flags);
 
 	return xsh;
tools/xenstore/xs.h +1 -0
@@ -26,6 +26,7 @@
 
 #define XS_OPEN_READONLY	1UL<<0
 #define XS_OPEN_SOCKETONLY      1UL<<1
+#define XS_OPEN_XENBUSONLY      1UL<<2
 
 struct xs_handle;
 typedef uint32_t xs_transaction_t;
 tools/python/xen/lowlevel/xs/xs.c |  16 +++++++++++-----
 tools/xenstore/xenstore_client.c  |  29 +++++++++++++++++------------
 tools/xenstore/xs.c               |  16 +++++++++++-----
 tools/xenstore/xs.h               |   1 +
 4 files changed, 40 insertions(+), 22 deletions(-)

# HG changeset patch
# User Zheng Li <[email protected]>
# Date 1312039526 0
# Node ID ffb97f0a99eaaca10d01cce1bcc22ce7be5ea407 # Parent 6cb432bc2d1d73d309318136db9e39b76e2ba326 Add xenbus-only communication switch for xenstore clients/API

Currently, xenstore clients default to socket communication mode and only fallback to xenbus if the former is not present. This is a reasonable choice for both normal hosts (Dom0) and normal VMs (DomU), but it would cause troubles for SDK/DDK VMs which are playing both host and VM roles. In such VMs, xenstore clients sometimes need to talk with the xenstored running inside the VM as a Dom0 client via socket, and sometimes need to talk with the xenstored running on the real host as a DomU client via xenbus (e.g. as guest agent to report information back to the real host). With current design, the xenstore clients in a SDK/DDK VM will always talk to its own xenstored running inside the VM, and there is no option for us to enforce xenbus communication when necessary.

In this patch, we add an extra flag XS_OPEN_XENBUSONLY (and also a command line option "-b") corresponding to the current XS_OPEN_SOCKETONLY flag (and the "-s" option). The algorithm of choosing communication method becomes:

* As before, XENSTORED_PATH environment variable still has the highest priority over any other options
* If XS_OPEN_SOCKETONLY flag is set, xenstore clients will always use socket communication and will not try xenbus communication even if socket communication is not feasible
* If XS_OPEN_XENBUSONLY flag is set, xenstore clients will always use xenbus communication and will not try socket communication even if xenbus communication is not feasible
* If both options are unset or both options are set, socket communication will have the higher priority, and xenbus communication will take place only when the socket communication is not feasible.

To avoid having to add these switches everywhere, three environment variables of the same name i.e. "XS_OPEN_XXXONLY" are added and will have the same effect (in addition to) as passing explicit flags/options to the xs_open primitive if not empty.

tools/python/xen/lowlevel/xs/xs.c +11 -5
@@ -898,15 +898,21 @@ fail:
 static int
 xshandle_init(XsHandle *self, PyObject *args, PyObject *kwds)
 {
-    static char *kwd_spec[] = { "readonly", NULL };
-    static char *arg_spec = "|i";
-    int readonly = 0;
+    static char *kwd_spec[] = { "readonly", "socket", "xenbus", NULL };
+    static char *arg_spec = "|iii";
+    int readonly = 0, socket = 0, xenbus = 0;
+    unsigned long flags = 0;
 
     if (!PyArg_ParseTupleAndKeywords(args, kwds, arg_spec, kwd_spec,
-                                     &readonly))
+                                     &readonly, &socket, &xenbus))
         goto fail;
 
-    self->xh = (readonly ? xs_daemon_open_readonly() : xs_daemon_open());
+    flags |= (readonly ? XS_OPEN_READONLY : 0);
+    flags |= (socket ? XS_OPEN_SOCKETONLY : 0);
+    flags |= (xenbus ? XS_OPEN_XENBUSONLY : 0);
+
+    self->xh = xs_open(flags);
+
     if (!self->xh)
         goto fail;
 
tools/xenstore/xenstore_client.c +17 -12
@@ -78,24 +78,24 @@ usage(enum mode mode, int incl_mode, con
 	errx(1, "Usage: %s <mode> [-h] [...]", progname);
     case MODE_read:
 	mstr = incl_mode ? "read " : "";
-	errx(1, "Usage: %s %s[-h] [-p] [-s] key [...]", progname, mstr);
+	errx(1, "Usage: %s %s[-h] [-p] [-s|-b] key [...]", progname, mstr);
     case MODE_write:
 	mstr = incl_mode ? "write " : "";
-	errx(1, "Usage: %s %s[-h] [-s] key value [...]", progname, mstr);
+	errx(1, "Usage: %s %s[-h] [-s|-b] key value [...]", progname, mstr);
     case MODE_rm:
 	mstr = incl_mode ? "rm " : "";
-	errx(1, "Usage: %s %s[-h] [-s] [-t] key [...]", progname, mstr);
+	errx(1, "Usage: %s %s[-h] [-s|-b] [-t] key [...]", progname, mstr);
     case MODE_exists:
 	mstr = incl_mode ? "exists " : "";
     case MODE_list:
 	mstr = mstr ? : incl_mode ? "list " : "";
-	errx(1, "Usage: %s %s[-h] [-p] [-s] key [...]", progname, mstr);
+	errx(1, "Usage: %s %s[-h] [-p] [-s|-b] key [...]", progname, mstr);
     case MODE_ls:
 	mstr = mstr ? : incl_mode ? "ls " : "";
-	errx(1, "Usage: %s %s[-h] [-f] [-p] [-s] [path]", progname, mstr);
+	errx(1, "Usage: %s %s[-h] [-f] [-p] [-s|-b] [path]", progname, mstr);
     case MODE_chmod:
 	mstr = incl_mode ? "chmod " : "";
-	errx(1, "Usage: %s %s[-h] [-u] [-r] [-s] key <mode [modes...]>", progname, mstr);
+	errx(1, "Usage: %s %s[-h] [-u] [-r] [-s|-b] key <mode [modes...]>", progname, mstr);
     case MODE_watch:
 	mstr = incl_mode ? "watch " : "";
 	errx(1, "Usage: %s %s[-h] [-n NR] key", progname, mstr);
@@ -496,7 +496,8 @@ main(int argc, char **argv)
 {
     struct xs_handle *xsh;
     xs_transaction_t xth = XBT_NULL;
-    int ret = 0, socket = 0;
+    int ret = 0;
+    unsigned long flags = 0;
     int prefix = 0;
     int tidy = 0;
     int upto = 0;
@@ -531,6 +532,7 @@ main(int argc, char **argv)
 	    {"help",    0, 0, 'h'},
 	    {"flat",    0, 0, 'f'}, /* MODE_ls */
 	    {"socket",  0, 0, 's'},
+	    {"xenbus",  0, 0, 'b'},
 	    {"prefix",  0, 0, 'p'}, /* MODE_read || MODE_list || MODE_ls */
 	    {"tidy",    0, 0, 't'}, /* MODE_rm */
 	    {"upto",    0, 0, 'u'}, /* MODE_chmod */
@@ -539,7 +541,7 @@ main(int argc, char **argv)
 	    {0, 0, 0, 0}
 	};
 
-	c = getopt_long(argc - switch_argv, argv + switch_argv, "hfspturn:",
+	c = getopt_long(argc - switch_argv, argv + switch_argv, "hfsbpturn:",
 			long_options, &index);
 	if (c == -1)
 	    break;
@@ -557,9 +559,12 @@ main(int argc, char **argv)
 		usage(mode, switch_argv, argv[0]);
 	    }
             break;
-        case 's':
-            socket = 1;
-            break;
+	case 's':
+	    flags |= XS_OPEN_SOCKETONLY;
+	    break;
+	case 'b':
+	    flags |= XS_OPEN_XENBUSONLY;
+	    break;
 	case 'p':
 	    if ( mode == MODE_read || mode == MODE_list || mode == MODE_ls )
 		prefix = 1;
@@ -633,7 +638,7 @@ main(int argc, char **argv)
 	    max_width = ws.ws_col - 2;
     }
 
-    xsh = xs_open(socket ? XS_OPEN_SOCKETONLY : 0);
+    xsh = xs_open(flags);
     if (xsh == NULL) err(1, "xs_open");
 
 again:
tools/xenstore/xs.c +11 -5
@@ -257,12 +257,18 @@ struct xs_handle *xs_open(unsigned long 
 {
 	struct xs_handle *xsh = NULL;
 
-	if (flags & XS_OPEN_READONLY)
-		xsh = get_handle(xs_daemon_socket_ro(), flags);
-	else
-		xsh = get_handle(xs_daemon_socket(), flags);
+	flags |= (getenv("XS_OPEN_READONLY") ? XS_OPEN_READONLY : 0);
+	flags |= (getenv("XS_OPEN_SOCKETONLY") ? XS_OPEN_SOCKETONLY : 0);
+	flags |= (getenv("XS_OPEN_XENBUSONLY") ? XS_OPEN_XENBUSONLY : 0);
+       
+	if ((flags & XS_OPEN_SOCKETONLY) || !(flags & XS_OPEN_XENBUSONLY)) {
+		if (flags & XS_OPEN_READONLY)
+			xsh = get_handle(xs_daemon_socket_ro(), flags);
+		else
+			xsh = get_handle(xs_daemon_socket(), flags);
+	}
 
-	if (!xsh && !(flags & XS_OPEN_SOCKETONLY))
+	if (!xsh && ((flags & XS_OPEN_XENBUSONLY) || !(flags & XS_OPEN_SOCKETONLY)))
 		xsh = get_handle(xs_domain_dev(), flags);
 
 	return xsh;
tools/xenstore/xs.h +1 -0
@@ -26,6 +26,7 @@
 
 #define XS_OPEN_READONLY	1UL<<0
 #define XS_OPEN_SOCKETONLY      1UL<<1
+#define XS_OPEN_XENBUSONLY      1UL<<2
 
 struct xs_handle;
 typedef uint32_t xs_transaction_t;

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

author
#4 lore raw
In reply to Zheng Li

Sorry for the noise.

These should be the same as the patches I previously send. They were previously blocked by the list because I didn't register with the list at the time before I sending them (the list page didn't mention this requirement). I then did the registration and resend them to the list, and they turned up successfully. Somehow the blocked ones seemed to have been unblocked today (possibly the mailing list software recheck the blocked mails every now and found I'm now registered hence approved them :-().

Cheers
Zheng

Quoted 48 lines · Zheng Li

These are mostly simplifications plus small bug fixes.

Sorry that some of the patches should have been smaller, it's a bit too late to break them. They should be quite safe to apply though, as these modifications have been running in our test facilities for a few months now.

  tools/ocaml/Makefile.rules           |   10 +-
  tools/ocaml/libs/Makefile            |    4 +-
  tools/ocaml/libs/eventchn/Makefile   |    1 +
  tools/ocaml/libs/log/META.in         |    5 -
  tools/ocaml/libs/log/Makefile        |   44 -----
  tools/ocaml/libs/log/log.ml          |  258 -----------------------------
  tools/ocaml/libs/log/log.mli         |   55 ------
  tools/ocaml/libs/log/logs.ml         |  197 ----------------------
  tools/ocaml/libs/log/logs.mli        |   46 -----
  tools/ocaml/libs/log/syslog.ml       |   26 ---
  tools/ocaml/libs/log/syslog.mli      |   41 ----
  tools/ocaml/libs/log/syslog_stubs.c  |   75 --------
  tools/ocaml/libs/uuid/META.in        |    4 -
  tools/ocaml/libs/uuid/Makefile       |   29 ---
  tools/ocaml/libs/uuid/uuid.ml        |  100 -----------
  tools/ocaml/libs/uuid/uuid.mli       |   67 -------
  tools/ocaml/libs/xb/Makefile         |    2 +-
  tools/ocaml/libs/xc/META.in          |    2 +-
  tools/ocaml/libs/xc/Makefile         |    2 +-
  tools/ocaml/libs/xc/xc.ml            |   14 +-
  tools/ocaml/libs/xc/xc.mli           |    9 +-
  tools/ocaml/libs/xc/xc_stubs.c       |   10 +-
  tools/ocaml/xenstored/Makefile       |    4 -
  tools/ocaml/xenstored/connection.ml  |    5 +
  tools/ocaml/xenstored/connections.ml |    7 +-
  tools/ocaml/xenstored/disk.ml        |    2 +-
  tools/ocaml/xenstored/domain.ml      |    2 +-
  tools/ocaml/xenstored/domains.ml     |    6 +-
  tools/ocaml/xenstored/logging.ml     |  302 ++++++++++++++++++----------------
  tools/ocaml/xenstored/perms.ml       |    8 +-
  tools/ocaml/xenstored/process.ml     |   20 +-
  tools/ocaml/xenstored/quota.ml       |    2 +-
  tools/ocaml/xenstored/store.ml       |    2 +-
  tools/ocaml/xenstored/xenstored.conf |   15 +-
  tools/ocaml/xenstored/xenstored.ml   |   62 +++---
  tools/python/xen/lowlevel/xs/xs.c    |   16 +-
  tools/xenstore/xenstore_client.c     |   29 +-
  tools/xenstore/xs.c                  |   16 +-
  tools/xenstore/xs.h                  |    1 +
  39 files changed, 309 insertions(+), 1191 deletions(-)
#5 lore raw
Quoted 10 lines · Zheng Li

Sorry for the noise.

These should be the same as the patches I previously send. They were previously blocked by the list because I didn't register with the list at the time before I sending them (the list page didn't mention this requirement). I then did the registration and resend them to the list, and they turned up successfully. Somehow the blocked ones seemed to have been unblocked today (possibly the mailing list software recheck the blocked mails every now and found I'm now registered hence approved them :-().

The list is moderated for non-subscribers. A moderator must have ok'd them without realising you'd resent them already.

Ian.

Quoted 60 lines

Cheers
Zheng

Quoted 40 lines · Zheng Li

These are mostly simplifications plus small bug fixes.

Sorry that some of the patches should have been smaller, it's a bit too late to break them. They should be quite safe to apply though, as these modifications have been running in our test facilities for a few months now.

  tools/ocaml/Makefile.rules           |   10 +-
  tools/ocaml/libs/Makefile            |    4 +-
  tools/ocaml/libs/eventchn/Makefile   |    1 +
  tools/ocaml/libs/log/META.in         |    5 -
  tools/ocaml/libs/log/Makefile        |   44 -----
  tools/ocaml/libs/log/log.ml          |  258 -----------------------------
  tools/ocaml/libs/log/log.mli         |   55 ------
  tools/ocaml/libs/log/logs.ml         |  197 ----------------------
  tools/ocaml/libs/log/logs.mli        |   46 -----
  tools/ocaml/libs/log/syslog.ml       |   26 ---
  tools/ocaml/libs/log/syslog.mli      |   41 ----
  tools/ocaml/libs/log/syslog_stubs.c  |   75 --------
  tools/ocaml/libs/uuid/META.in        |    4 -
  tools/ocaml/libs/uuid/Makefile       |   29 ---
  tools/ocaml/libs/uuid/uuid.ml        |  100 -----------
  tools/ocaml/libs/uuid/uuid.mli       |   67 -------
  tools/ocaml/libs/xb/Makefile         |    2 +-
  tools/ocaml/libs/xc/META.in          |    2 +-
  tools/ocaml/libs/xc/Makefile         |    2 +-
  tools/ocaml/libs/xc/xc.ml            |   14 +-
  tools/ocaml/libs/xc/xc.mli           |    9 +-
  tools/ocaml/libs/xc/xc_stubs.c       |   10 +-
  tools/ocaml/xenstored/Makefile       |    4 -
  tools/ocaml/xenstored/connection.ml  |    5 +
  tools/ocaml/xenstored/connections.ml |    7 +-
  tools/ocaml/xenstored/disk.ml        |    2 +-
  tools/ocaml/xenstored/domain.ml      |    2 +-
  tools/ocaml/xenstored/domains.ml     |    6 +-
  tools/ocaml/xenstored/logging.ml     |  302 ++++++++++++++++++----------------
  tools/ocaml/xenstored/perms.ml       |    8 +-
  tools/ocaml/xenstored/process.ml     |   20 +-
  tools/ocaml/xenstored/quota.ml       |    2 +-
Quoted 8 lines
  tools/ocaml/xenstored/store.ml       |    2 +-
  tools/ocaml/xenstored/xenstored.conf |   15 +-
  tools/ocaml/xenstored/xenstored.ml   |   62 +++---
  tools/python/xen/lowlevel/xs/xs.c    |   16 +-
  tools/xenstore/xenstore_client.c     |   29 +-
  tools/xenstore/xs.c                  |   16 +-
  tools/xenstore/xs.h                  |    1 +
  39 files changed, 309 insertions(+), 1191 deletions(-)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel