Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial resync with xenserver-core #38

Merged
merged 3 commits into from Apr 25, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -39,3 +39,6 @@
config.mk
dist
_build
scripts/vif
scripts/xen-backend.rules
scripts/xen-backend-xl.rules
17 changes: 15 additions & 2 deletions configure.ml
Expand Up @@ -13,7 +13,7 @@ let sbindir =

let libexecdir =
let doc = "Set the directory for installing helper executables" in
Arg.(value & opt string "/usr/lib/xenopsd/bin" & info ["libexecdir"] ~docv:"LIBEXECDIR" ~doc)
Arg.(value & opt string "/usr/lib/xenopsd" & info ["libexecdir"] ~docv:"LIBEXECDIR" ~doc)

let scriptsdir =
let doc = "Set the directory for installing helper scripts" in
Expand Down Expand Up @@ -63,6 +63,15 @@ let find_ml_val verbose name libs =
Printf.printf "Looking for %s: %s\n" name (if found then "ok" else "missing");
found

let expand start finish input output =
let command = Printf.sprintf "cat %s | sed -r 's=%s=%s=g' > %s" input start finish output in
if Sys.command command <> 0
then begin
Printf.fprintf stderr "Failed to expand %s -> %s in %s producing %s\n" start finish input output;
Printf.fprintf stderr "Command-line was:\n%s\n%!" command;
exit 1;
end

let configure bindir sbindir libexecdir scriptsdir etcdir =
let xenctrl = find_ocamlfind false "xenctrl" in
let xenlight = find_ocamlfind false "xenlight" in
Expand All @@ -85,7 +94,11 @@ let configure bindir sbindir libexecdir scriptsdir etcdir =
Printf.sprintf "ENABLE_LIBVIRT=--%s-libvirt" (if libvirt then "enable" else "disable");
Printf.sprintf "ENABLE_XENGUESTBIN=--%s-xenguestbin" (if xenguest then "enable" else "disable");
] in
output_file config_mk lines
output_file config_mk lines;
(* Expand @LIBEXEC@ in udev rules *)
expand "@LIBEXEC@" libexecdir "scripts/vif.in" "scripts/vif";
expand "@LIBEXEC@" libexecdir "scripts/xen-backend.rules.in" "scripts/xen-backend.rules";
expand "@LIBEXEC@" libexecdir "scripts/xen-backend-xl.rules.in" "scripts/xen-backend-xl.rules"

let configure_t = Term.(pure configure $ bindir $ sbindir $ libexecdir $ scriptsdir $ etcdir )

Expand Down
40 changes: 0 additions & 40 deletions scripts/vif

This file was deleted.

7 changes: 0 additions & 7 deletions scripts/xen-backend-xl.rules

This file was deleted.

7 changes: 0 additions & 7 deletions scripts/xen-backend.rules

This file was deleted.

16 changes: 15 additions & 1 deletion xc/xenops_xc_main.ml
Expand Up @@ -22,7 +22,21 @@ let check_domain0_uuid () =
let uuid = Uuidm.(to_string (create `V4)) in
Inventory.update Inventory._control_domain_uuid uuid;
uuid in
Xenctrl.domain_sethandle xc 0 uuid
Xenctrl.domain_sethandle xc 0 uuid;
(* make the /vm/ tree for dom0 *)
let kvs = [
Printf.sprintf "/vm/%s/uuid" uuid, uuid;
Printf.sprintf "/vm/%s/name" uuid, "Domain-0";
Printf.sprintf "/vm/%s/domains/0" uuid, "/local/domain/0";
Printf.sprintf "/vm/%s/domains/0/create-time" uuid, "0"
] in
let open Xenstore in
with_xs (fun xs ->
List.iter (fun (k, v) -> xs.Xs.write k v) kvs
);
(* before daemonizing we need to forget the xenstore client
because the background thread will be gone after the fork() *)
forget_client ()

(* Start the program with the xen backend *)
let _ =
Expand Down
18 changes: 10 additions & 8 deletions xc/xenstore.ml
Expand Up @@ -39,14 +39,16 @@ let make_client () =
end;
raise e

let get_client =
let client = ref None in
fun () -> match !client with
| None ->
let c = make_client () in
client := Some c;
c
| Some c -> c
let client = ref None

let get_client () = match !client with
| None ->
let c = make_client () in
client := Some c;
c
| Some c -> c

let forget_client () = client := None

type domid = int

Expand Down