Permalink
Browse files

[xenops]: plumb xenstore,console backend domids through domain build

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
  • Loading branch information...
1 parent 3f24722 commit f81f53eb5a55bd6a1d605926aeddd5fd50fdd78f David Scott committed with Aug 25, 2012
@@ -25,11 +25,11 @@ external close : handle -> unit = "stub_xenguest_close"
(** build a linux domain *)
external linux_build : handle -> domid -> int -> int -> string ->
string option -> string -> string -> int ->
- int -> int -> (nativeint * nativeint * string)
+ int -> int -> int -> int -> (nativeint * nativeint * string)
= "stub_xc_linux_build_bytecode" "stub_xc_linux_build_native"
(** build a hvm domain *)
-external hvm_build : handle -> domid -> int -> int -> string -> int -> int ->
+external hvm_build : handle -> domid -> int -> int -> string -> int -> int -> int -> int ->
(nativeint * nativeint)
= "stub_xc_hvm_build_bytecode" "stub_xc_hvm_build_native"
@@ -229,20 +229,20 @@ let with_xenguest f =
let xc = Xenguest.init () in
finally (fun () -> f xc) (fun () -> Xenguest.close xc)
-let linux_build_real domid mem_max_mib mem_start_mib image ramdisk cmdline features flags store_port console_port =
+let linux_build_real domid mem_max_mib mem_start_mib image ramdisk cmdline features flags store_port store_domid console_port console_domid =
with_xenguest (fun xc ->
let store_mfn, console_mfn, proto =
Xenguest.linux_build xc domid mem_max_mib mem_start_mib image
- ramdisk cmdline features flags store_port console_port in
+ ramdisk cmdline features flags store_port store_domid console_port console_domid in
String.concat " " [ Nativeint.to_string store_mfn;
Nativeint.to_string console_mfn; proto ]
)
-let hvm_build_real domid mem_max_mib mem_start_mib image store_port console_port=
+let hvm_build_real domid mem_max_mib mem_start_mib image store_port store_domid console_port console_domid =
with_xenguest (fun xc ->
let store_mfn, console_mfn =
Xenguest.hvm_build xc domid mem_max_mib mem_start_mib image
- store_port console_port in
+ store_port store_domid console_port console_domid in
String.concat " " [Nativeint.to_string store_mfn;
Nativeint.to_string console_mfn]
)
@@ -263,15 +263,15 @@ let domain_restore_real fd domid store_port store_domid console_port console_dom
)
(** fake operations *)
-let linux_build_fake domid mem_max_mib mem_start_mib image ramdisk cmdline features flags store_port console_port = "10 10 x86-32"
-let hvm_build_fake domid mem_max_mib mem_start_mib image store_port console_port = "2901 2901"
+let linux_build_fake domid mem_max_mib mem_start_mib image ramdisk cmdline features flags store_port store_domid console_port console_domid = "10 10 x86-32"
+let hvm_build_fake domid mem_max_mib mem_start_mib image store_port store_domid console_port console_domid = "2901 2901"
let domain_save_fake fd domid x y flags hvm = Unix.sleep 1; ignore (suspend_callback domid); ""
let domain_restore_fake fd domid store_port store_domid console_port console_domid hvm no_incr_generationid = "10 10"
(** operation vector *)
type ops = {
- linux_build: int -> int -> int -> string -> string option -> string -> string -> int -> int -> int -> string;
- hvm_build: int -> int -> int -> string -> int -> int -> string;
+ linux_build: int -> int -> int -> string -> string option -> string -> string -> int -> int -> int -> int -> int -> string;
+ hvm_build: int -> int -> int -> string -> int -> int -> int -> int -> string;
domain_save: Unix.file_descr -> int -> int -> int -> Xenguest.suspend_flags list -> bool -> string;
domain_restore: Unix.file_descr -> int -> int -> int -> int -> int -> bool -> bool -> string;
}
@@ -402,11 +402,13 @@ let _ =
and features = get_param "features"
and flags = int_of_string (get_param "flags")
and store_port = int_of_string (get_param "store_port")
- and console_port = int_of_string (get_param "console_port") in
+ and store_domid = int_of_string (get_param "store_domid")
+ and console_port = int_of_string (get_param "console_port")
+ and console_domid = int_of_string (get_param "console_domid") in
with_logging (fun () -> ops.linux_build domid mem_max_mib mem_start_mib image
(if ramdisk = "" then None else Some ramdisk)
- cmdline features flags store_port console_port)
+ cmdline features flags store_port store_domid console_port console_domid)
| Some "hvm_build" ->
debug "hvm_build mode selected";
require [ "domid"; "mem_max_mib"; "mem_start_mib"; "image";
@@ -416,10 +418,12 @@ let _ =
and mem_start_mib = int_of_string (get_param "mem_start_mib")
and image = get_param "image"
and store_port = int_of_string (get_param "store_port")
- and console_port = int_of_string (get_param "console_port") in
+ and store_domid = int_of_string (get_param "store_domid")
+ and console_port = int_of_string (get_param "console_port")
+ and console_domid = int_of_string (get_param "console_domid") in
with_logging (fun () -> ops.hvm_build domid mem_max_mib mem_start_mib image
- store_port console_port)
+ store_port store_domid console_port console_domid)
| Some "test" ->
debug "test mode selected";
with_logging (fun () -> ignore(Unix.system "/tmp/test"); "result")
@@ -283,6 +283,8 @@ CAMLprim value stub_xenguest_close(value xenguest_handle)
CAMLreturn(Val_unit);
}
+
+
extern struct xc_dom_image *xc_dom_allocate(xc_interface *xch, const char *cmdline, const char *features);
static void configure_vcpus(xc_interface *xch, int domid, struct flags f){
@@ -335,8 +337,9 @@ CAMLprim value stub_xc_linux_build_native(value xc_handle, value domid,
value mem_max_mib, value mem_start_mib,
value image_name, value ramdisk_name,
value cmdline, value features,
- value flags, value store_evtchn,
- value console_evtchn)
+ value flags,
+ value store_evtchn, value store_domid,
+ value console_evtchn, value console_domid)
{
CAMLparam5(xc_handle, domid, mem_max_mib, mem_start_mib, image_name);
CAMLxparam5(ramdisk_name, cmdline, features, flags, store_evtchn);
@@ -375,6 +378,13 @@ CAMLprim value stub_xc_linux_build_native(value xc_handle, value domid,
c_image_name, c_ramdisk_name, c_flags,
c_store_evtchn, &store_mfn,
c_console_evtchn, &console_mfn);
+ if (r == 0)
+ r = xc_dom_gnttab_seed(xch, c_domid,
+ console_mfn,
+ store_mfn,
+ Int_val(console_domid),
+ Int_val(store_domid));
+
caml_leave_blocking_section();
#ifndef XEN_UNSTABLE
@@ -402,7 +412,8 @@ CAMLprim value stub_xc_linux_build_bytecode(value * argv, int argn)
{
return stub_xc_linux_build_native(argv[0], argv[1], argv[2], argv[3],
argv[4], argv[5], argv[6], argv[7],
- argv[8], argv[9], argv[10]);
+ argv[8], argv[9], argv[10], argv[11],
+ argv[12]);
}
static int hvm_build_set_params(xc_interface *xch, int domid,
@@ -454,7 +465,9 @@ static int hvm_build_set_params(xc_interface *xch, int domid,
}
CAMLprim value stub_xc_hvm_build_native(value xc_handle, value domid,
- value mem_max_mib, value mem_start_mib, value image_name, value store_evtchn, value console_evtchn)
+ value mem_max_mib, value mem_start_mib, value image_name,
+ value store_domid, value store_evtchn,
+ value console_domid, value console_evtchn)
{
CAMLparam5(xc_handle, domid, mem_max_mib, mem_start_mib, image_name);
CAMLxparam2(store_evtchn, console_evtchn);
@@ -507,6 +520,9 @@ CAMLprim value stub_xc_hvm_build_native(value xc_handle, value domid,
if (r)
failwith_oss_xc(xch, "hvm_build_params");
+ xc_dom_gnttab_hvm_seed(xch, _D(domid), console_mfn, store_mfn, Int_val(console_domid), Int_val(store_domid));
+
+
result = caml_alloc_tuple(2);
Store_field(result, 0, caml_copy_nativeint(store_mfn));
Store_field(result, 1, caml_copy_nativeint(console_mfn));
@@ -517,7 +533,7 @@ CAMLprim value stub_xc_hvm_build_native(value xc_handle, value domid,
CAMLprim value stub_xc_hvm_build_bytecode(value * argv, int argn)
{
return stub_xc_hvm_build_native(argv[0], argv[1], argv[2], argv[3],
- argv[4], argv[5], argv[6]);
+ argv[4], argv[5], argv[6], argv[7], argv[8]);
}
View
@@ -539,8 +539,8 @@ let build_post ~xc ~xs ~vcpus ~static_max_mib ~target_mib domid
xs.Xs.introduce domid store_mfn store_port
(** build a linux type of domain *)
-let build_linux (task: Xenops_task.t) ~xc ~xs ~static_max_kib ~target_kib ~kernel ~cmdline ~ramdisk
- ~vcpus xenguest_path domid =
+let build_linux (task: Xenops_task.t) ~xc ~xs ~store_domid ~console_domid ~static_max_kib ~target_kib
+ ~kernel ~cmdline ~ramdisk ~vcpus xenguest_path domid =
let uuid = get_uuid ~xc domid in
assert_file_is_readable kernel;
maybe assert_file_is_readable ramdisk;
@@ -582,7 +582,9 @@ let build_linux (task: Xenops_task.t) ~xc ~xs ~static_max_kib ~target_kib ~kerne
"-features"; "";
"-flags"; "0";
"-store_port"; string_of_int store_port;
+ "-store_domid"; string_of_int store_domid;
"-console_port"; string_of_int console_port;
+ "-console_domid"; string_of_int console_domid;
"-fork"; "true";
] []
XenguestHelper.receive_success in
@@ -610,7 +612,7 @@ let build_linux (task: Xenops_task.t) ~xc ~xs ~static_max_kib ~target_kib ~kerne
| _ -> Arch_native
(** build hvm type of domain *)
-let build_hvm (task: Xenops_task.t) ~xc ~xs ~static_max_kib ~target_kib ~shadow_multiplier ~vcpus
+let build_hvm (task: Xenops_task.t) ~xc ~xs ~store_domid ~console_domid ~static_max_kib ~target_kib ~shadow_multiplier ~vcpus
~kernel ~timeoffset ~video_mib xenguest_path domid =
let uuid = get_uuid ~xc domid in
assert_file_is_readable kernel;
@@ -642,7 +644,9 @@ let build_hvm (task: Xenops_task.t) ~xc ~xs ~static_max_kib ~target_kib ~shadow_
"-mode"; "hvm_build";
"-domid"; string_of_int domid;
"-store_port"; string_of_int store_port;
+ "-store_domid"; string_of_int store_domid;
"-console_port"; string_of_int console_port;
+ "-console_domid"; string_of_int console_domid;
"-image"; kernel;
"-mem_max_mib"; Int64.to_string build_max_mib;
"-mem_start_mib"; Int64.to_string build_start_mib;
@@ -695,14 +699,14 @@ let build_hvm (task: Xenops_task.t) ~xc ~xs ~static_max_kib ~target_kib ~shadow_
Arch_HVM
-let build (task: Xenops_task.t) ~xc ~xs info timeoffset xenguest_path domid =
+let build (task: Xenops_task.t) ~xc ~xs ~store_domid ~console_domid info timeoffset xenguest_path domid =
match info.priv with
| BuildHVM hvminfo ->
- build_hvm task ~xc ~xs ~static_max_kib:info.memory_max ~target_kib:info.memory_target
+ build_hvm task ~xc ~xs ~store_domid ~console_domid ~static_max_kib:info.memory_max ~target_kib:info.memory_target
~shadow_multiplier:hvminfo.shadow_multiplier ~vcpus:info.vcpus
~kernel:info.kernel ~timeoffset ~video_mib:hvminfo.video_mib xenguest_path domid
| BuildPV pvinfo ->
- build_linux task ~xc ~xs ~static_max_kib:info.memory_max ~target_kib:info.memory_target
+ build_linux task ~xc ~xs ~store_domid ~console_domid ~static_max_kib:info.memory_max ~target_kib:info.memory_target
~kernel:info.kernel ~cmdline:pvinfo.cmdline ~ramdisk:pvinfo.ramdisk
~vcpus:info.vcpus xenguest_path domid
View
@@ -118,20 +118,22 @@ val get_action_request: xs:Xenstore.Xs.xsh -> domid -> string option
(* val create_channels : xc:Xenctrl.handle -> domid -> int * int *)
(** Builds a linux guest in a fresh domain created with 'make' *)
-val build_linux: Xenops_task.Xenops_task.t -> xc: Xenctrl.handle -> xs: Xenstore.Xs.xsh -> static_max_kib:Int64.t
+val build_linux: Xenops_task.Xenops_task.t -> xc: Xenctrl.handle -> xs: Xenstore.Xs.xsh
+ -> store_domid:int -> console_domid:int -> static_max_kib:Int64.t
-> target_kib:Int64.t -> kernel:string -> cmdline:string
-> ramdisk:string option -> vcpus:int -> string -> domid
-> domarch
(** build an hvm domain in a fresh domain created with 'make' *)
-val build_hvm: Xenops_task.Xenops_task.t -> xc: Xenctrl.handle -> xs: Xenstore.Xs.xsh -> static_max_kib:Int64.t
+val build_hvm: Xenops_task.Xenops_task.t -> xc: Xenctrl.handle -> xs: Xenstore.Xs.xsh
+ -> store_domid:int -> console_domid:int -> static_max_kib:Int64.t
-> target_kib:Int64.t -> shadow_multiplier:float
-> vcpus:int -> kernel:string
-> timeoffset:string -> video_mib:int -> string -> domid
-> domarch
(** Restore a domain using the info provided *)
-val build: Xenops_task.Xenops_task.t -> xc: Xenctrl.handle -> xs: Xenstore.Xs.xsh -> build_info -> string -> string -> domid -> domarch
+val build: Xenops_task.Xenops_task.t -> xc: Xenctrl.handle -> xs: Xenstore.Xs.xsh -> store_domid:int -> console_domid:int -> build_info -> string -> string -> domid -> domarch
(** resume a domain either cooperative or not *)
val resume: Xenops_task.Xenops_task.t -> xc: Xenctrl.handle -> xs: Xenstore.Xs.xsh -> hvm: bool -> cooperative: bool -> qemu_domid:int -> domid -> unit
View
@@ -41,9 +41,9 @@ let create ~xc ~xs domid =
Domain.set_machine_address_size ~xc stubdom_domid (Some 32);
stubdom_domid
-let build (task: Xenops_task.t) ~xc ~xs info xenguest domid stubdom_domid =
+let build (task: Xenops_task.t) ~xc ~xs ~store_domid ~console_domid info xenguest domid stubdom_domid =
(* Now build it as a PV domain *)
- let (_: Domain.domarch) = Domain.build task ~xc ~xs {
+ let (_: Domain.domarch) = Domain.build task ~xc ~xs ~store_domid ~console_domid {
Domain.memory_max=memory_kib;
Domain.memory_target=memory_kib;
Domain.kernel="/usr/lib/xen/boot/ioemu-stubdom.gz";
View
@@ -16,4 +16,4 @@ val memory_kib: int64
val create: xc:Xenctrl.handle -> xs:Xenstore.Xs.xsh -> Xenctrl.domid -> Xenctrl.domid
-val build: Xenops_task.Xenops_task.t -> xc:Xenctrl.handle -> xs:Xenstore.Xs.xsh -> Device.Dm.info -> string -> Xenctrl.domid -> Xenctrl.domid -> unit
+val build: Xenops_task.Xenops_task.t -> xc:Xenctrl.handle -> xs:Xenstore.Xs.xsh -> store_domid:int -> console_domid:int -> Device.Dm.info -> string -> Xenctrl.domid -> Xenctrl.domid -> unit
View
@@ -74,12 +74,12 @@ let create_domain ~xc ~xs ~hvm =
let default_xenguest = "/opt/xensource/libexec/xenguest"
let build_domain ~xc ~xs ~kernel ?(ramdisk=None) ~cmdline ~domid ~vcpus ~static_max_kib ~target_kib =
- let (_: Domain.domarch) = Domain.build_linux task xc xs static_max_kib target_kib
+ let (_: Domain.domarch) = Domain.build_linux task xc xs 0 0 static_max_kib target_kib
kernel cmdline ramdisk vcpus default_xenguest domid in
printf "built domain: %u\n" domid
let build_hvm ~xc ~xs ~kernel ~domid ~vcpus ~static_max_kib ~target_kib =
- let (_: Domain.domarch) = Domain.build_hvm task xc xs static_max_kib target_kib 1.
+ let (_: Domain.domarch) = Domain.build_hvm task xc xs 0 0 static_max_kib target_kib 1.
vcpus kernel "" 4 default_xenguest domid in
printf "built hvm domain: %u\n" domid
@@ -32,6 +32,8 @@ let _qemu_dm_default = Filename.concat Fhs.libexecdir "qemu-dm-wrapper"
let _xenguest_default = Filename.concat Fhs.libexecdir "xenguest"
let _device_model = "device-model"
let _xenguest = "xenguest"
+let store_domid = 0
+let console_domid = 0
let _tune2fs = "/sbin/tune2fs"
let _mkfs = "/sbin/mkfs"
let _mount = "/bin/mount"
@@ -1013,7 +1015,7 @@ module VM = struct
} in
((make_build_info b.Bootloader.kernel_path builder_spec_info), "")
) in
- let arch = Domain.build task ~xc ~xs build_info timeoffset (choose_xenguest vm.Vm.platformdata) domid in
+ let arch = Domain.build task ~xc ~xs ~store_domid ~console_domid build_info timeoffset (choose_xenguest vm.Vm.platformdata) domid in
Int64.(
let min = to_int (div vm.Vm.memory_dynamic_min 1024L)
and max = to_int (div vm.Vm.memory_dynamic_max 1024L) in
@@ -1075,7 +1077,7 @@ module VM = struct
if saved_state then failwith "Cannot resume with stubdom yet";
Opt.iter
(fun stubdom_domid ->
- Stubdom.build task ~xc ~xs info xenguest di.domid stubdom_domid;
+ Stubdom.build task ~xc ~xs ~store_domid ~console_domid info xenguest di.domid stubdom_domid;
Device.Dm.start_vnconly task ~xs ~dmpath:qemu_dm info stubdom_domid
) (get_stubdom ~xs di.domid);
| Vm.HVM { Vm.qemu_stubdom = false } ->
@@ -1265,8 +1267,6 @@ module VM = struct
Some x -> (match x with HVM hvm_info -> hvm_info.timeoffset | _ -> "")
| _ -> "" in
({ x with Domain.memory_target = initial_target }, timeoffset) in
- let store_domid = 0 in
- let console_domid = 0 in
let no_incr_generationid = false in
begin
try

0 comments on commit f81f53e

Please sign in to comment.