exit 1
let vcpus = ref 0 (* 0 = choose for me *)
+let open_console = ref false
+let open_viewer = ref false
+
let get_arg_speclist () = Arg.align [
+ "--console", Arg.Set open_console, " Open the serial console";
"--cpus", Arg.Set_int vcpus, "n Number of virtual CPUs";
"--memory", Arg.String set_memory, "nnG Amount of RAM to give guest";
"--ram", Arg.String set_memory, "nnG Amount of RAM to give guest";
"--vcpus", Arg.Set_int vcpus, "n Number of virtual CPUs";
+ "--viewer", Arg.Set open_viewer, " Open the graphical console";
]
let boot ~verbose template name =
" mac_addr network_model in
let xml = xml ^ "\
+ <serial type='pty'>
+ <target port='0'/>
+ </serial>
<console type='pty'>
- <target type='virtio' port='0'/>
+ <target type='serial' port='0'/>
</console>
<input type='tablet' bus='usb'/>
<input type='mouse' bus='ps2'/>
);
let cmd =
(* XXX Don't hard-code network_bridge here. *)
- sprintf "ssh root@%s LIBGUESTFS_BACKEND_SETTINGS=network_bridge=br0 %s build %s %s %s"
- (quote hostname) remote_filename
- (quote template_info.Template.base_image) (quote remote_image)
- format in
+ sprintf "ssh root@%s \
+LIBGUESTFS_BACKEND_SETTINGS=network_bridge=br0 \
+base_image=%s \
+format=%s \
+name=%s \
+output=%s \
+%s build"
+ (quote hostname)
+ (quote template_info.Template.base_image) (* base_image *)
+ format (* format *)
+ name (* name *)
+ (quote remote_image) (* output *)
+ remote_filename in
if verbose then printf "%s\n%!" cmd;
if Sys.command cmd <> 0 then (
eprintf "mclu: remote build failed\n";
);
(* Start the guest. *)
- try
- let conn =
- let name = node.MS.node_status.MS.node.Mclu_conf.libvirt_uri in
- C.connect ~name () in
- let dom = D.create_xml conn xml [] in
- printf "mclu: %s:%s started\n" hostname (D.get_name dom)
- with Libvirt.Virterror msg ->
- eprintf "mclu: %s: %s\n" hostname (Libvirt.Virterror.to_string msg);
- exit 1
+ let dom =
+ try
+ let conn =
+ let name = node.MS.node_status.MS.node.Mclu_conf.libvirt_uri in
+ C.connect ~name () in
+ let dom = D.create_xml conn xml [] in
+ printf "mclu: %s:%s started\n" hostname (D.get_name dom);
+ dom
+ with Libvirt.Virterror msg ->
+ eprintf "mclu: %s: %s\n" hostname (Libvirt.Virterror.to_string msg);
+ exit 1 in
+
+ (* Graphical console? *)
+ if !open_viewer then
+ Mclu_viewer.viewer ~verbose ~host:hostname (D.get_name dom);
+
+ (* Serial console? (Interactive, so run it last) *)
+ if !open_console then
+ Mclu_console.console ~verbose ~host:hostname (D.get_name dom)
let run ~verbose = function
| [ template; name ] ->