Skip to contentSkip to conversation

support being run in stubdomain

PATCH In review Alex Zeffertt 1 participant 1 message Apr 17, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 6/7 support being run in stubdomain

When run inside a stubdomain xenstored is passed some extra args. Use these arguments to determine whether we are running in a stubdomain or in dom0 and act accordingly.

Make xenstored also work when built as minios stubdomain.

When started as a stubdomain, xenstored is passed the following extra arguments:

* local-domid: the domain id of the stubdom
* dom0-grant-ref: the grant ref needed to map dom0's store page
* dom0-port: the port used by dom0 to notify xenstored of changes

local-domid defaults to 0. If it is non-zero then we're in a stub domain. In this case, use the grant mechanism to map store pages into xenstore rather than map_foreign_range (as that requires the domain to be priviledged).

If local-domid = 0 then we cannot use the grant mechanism to map dom0's store page (as dom0-grant-ref isn't passed in) so we use map_foreign_range as before. In fact we use map_foreign_range for mapping all domains' store pages when local-domid = 0 as well, just to keep things consistent.

When running in a stubdom we disable a few things that minios cannot support:

* listening for clients on unix domain sockets
* saveto/restorefrom on disk DB
* signal handling (for updating on disk DB and exiting cleanly)

libs/xc/xc.ml +10 -0
diff -r efd7fd89d8c6 libs/xc/xc.ml
@@ -42,6 +42,8 @@
 
 external interface_open: unit -> handle = "stub_xc_interface_open"
 external interface_close: handle -> unit = "stub_xc_interface_close"
+external gnttab_open : unit -> handle  = "stub_gnttab_open"
+external gnttab_close : handle -> unit = "stub_gnttab_close"
 
 external using_injection: unit -> bool = "stub_xc_using_injection"
 
@@ -57,4 +59,12 @@
                          -> nativeint -> Mmap.mmap_interface
        = "stub_map_foreign_range"
 
+external gnttab_map_grant_ref :
+  handle -> domid -> int -> nativeint -> Mmap.mmap_interface
+  = "stub_gnttab_map_grant_ref"
+external gnttab_munmap :
+  handle -> Mmap.mmap_interface -> unit
+  = "stub_gnttab_munmap"
+
+
 let _ = Callback.register_exception "xc.error" (Error "register_callback")
libs/xc/xc.mli +13 -0
diff -r efd7fd89d8c6 libs/xc/xc.mli
@@ -48,3 +48,16 @@
 external map_foreign_range :
   handle -> domid -> int -> nativeint -> Mmap.mmap_interface
   = "stub_map_foreign_range"
+external gnttab_open :
+  unit -> handle
+  = "stub_gnttab_open"
+external gnttab_close :
+  handle -> unit
+  = "stub_gnttab_close"
+external gnttab_map_grant_ref :
+  handle -> domid -> int -> nativeint -> Mmap.mmap_interface
+  = "stub_gnttab_map_grant_ref"
+external gnttab_munmap :
+  handle -> Mmap.mmap_interface -> unit
+  = "stub_gnttab_munmap"
+
libs/xc/xc_stubs.c +72 -0

84 lines not on this page · raw message

xenstored/Makefile +2 -2
diff -r efd7fd89d8c6 xenstored/Makefile
@@ -5,9 +5,9 @@
 	-I ../libs/mmap -I ../libs/xc -I ../libs/eventchn \
 	-I ../libs/stdext -I ../common
 
-OBJS = define ../common/config logging quota perms symbol utils store disk transaction \
+OBJS = define parse_arg ../common/config logging quota perms symbol utils store disk transaction \
        event domain domains connection connections \
-       parse_arg process xenstored
+       process xenstored
 INTF = symbol.cmi
 XENSTOREDLIBS = unix.cmxa \
 	../libs/uuid/uuid.cmxa \
xenstored/domain.ml +5 -2
diff -r efd7fd89d8c6 xenstored/domain.ml
@@ -15,6 +15,7 @@
  *)
 
 open Printf
+open Parse_arg
 
 let debug fmt = Logs.debug "general" fmt
 
@@ -24,6 +25,7 @@
 	mfn: nativeint;
 	remote_port: int;
 	interface: Mmap.mmap_interface;
+	interface_destroy: unit -> unit;
 	eventchn: Event.t;
 	mutable port: int;
 }
@@ -47,14 +49,15 @@
 let close dom =
 	debug "domain %d unbound port %d" dom.id dom.port;
 	Event.unbind dom.eventchn dom.port;
-	Mmap.unmap dom.interface;
+	dom.interface_destroy ();
 	()
 
-let make id mfn remote_port interface eventchn = {
+let make id mfn remote_port interface interface_destroy eventchn = {
 	id = id;
 	mfn = mfn;
 	remote_port = remote_port;
 	interface = interface;
+	interface_destroy = interface_destroy;
 	eventchn = eventchn;
 	port = -1
 }
xenstored/domains.ml +38 -12

71 lines not on this page · raw message

xenstored/parse_arg.ml +16 -4
diff -r efd7fd89d8c6 xenstored/parse_arg.ml
@@ -24,6 +24,9 @@
 	pidfile: string option; (* old xenstored compatibility *)
 	tracefile: string option; (* old xenstored compatibility *)
 	restart: bool;
+	local_domid: int;
+	dom0_grant_ref: nativeint;
+	dom0_port: int;
 }
 
 let do_argv =
@@ -33,7 +36,10 @@
 	and daemonize = ref true
 	and reraise_top_level = ref false
 	and config_file = ref ""
-	and restart = ref false in
+	and restart = ref false 
+	and local_domid = ref 0 
+	and dom0_grant_ref = ref (-1)
+	and dom0_port = ref (-1) in
 
 	let speclist =
 		[ ("--no-domain-init", Arg.Unit (fun () -> domain_init := false),
@@ -49,8 +55,11 @@
 		  ("--pid-file", Arg.Set_string pidfile, ""); (* for compatibility *)
 		  ("-T", Arg.Set_string tracefile, ""); (* for compatibility *)
 		  ("--restart", Arg.Set restart, "Read database on starting");
-		   ] in
-	let usage_msg = "usage : xenstored [--config-file <filename>] [--no-domain-init] [--help] [--no-fork] [--reraise-top-level] [--restart]" in
+		  ("--local-domid", Arg.Set_int local_domid, ""); 
+		  ("--dom0-grant-ref", Arg.Set_int dom0_grant_ref, ""); 
+		  ("--dom0-port", Arg.Set_int dom0_port, ""); 
+		] in
+	let usage_msg = "usage : xenstored [--config-file <filename>] [--no-domain-init] [--help] [--no-fork] [--reraise-top-level] [--restart] --local-domid=<num> --dom0-grant-ref=<num> --dom0-port=<num>" in
 	Arg.parse speclist (fun s -> ()) usage_msg;
 	{
 		domain_init = !domain_init;
@@ -60,5 +69,8 @@
 		config_file = if !config_file <> "" then Some !config_file else None;
 		pidfile = if !pidfile <> "" then Some !pidfile else None;
 		tracefile = if !tracefile <> "" then Some !tracefile else None;
-		restart = !restart
+		restart = !restart;
+		local_domid = !local_domid;
+		dom0_grant_ref = Nativeint.of_int !dom0_grant_ref;
+		dom0_port = !dom0_port;
 	}
xenstored/xenstored.ml +32 -22

85 lines not on this page · raw message

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