ssh_directory : string; (* Remote directory. *)
ssh_username : string; (* Remote username. *)
ssh_password : string; (* Remote password/passphrase. *)
+ ssh_compression : bool; (* If true, use SSH compression. *)
ssh_check : bool; (* If true, check SSH is working. *)
ssh_libvirtd : bool; (* If true, contact remote libvirtd. *)
}
let config_memory = ref None
let config_vcpus = ref None
let config_mac_address = ref None
-let config_compression = ref None
(* The name of the program as displayed in various places. *)
let program_name = "virt-p2v"
fun dev ->
Pcre.replace ~rex:devsd ~itempl:devsd_subst dev
+(* Make an SSH connection to the remote machine. *)
+(*
+let ssh_connect config =
+ let cmd = sprintf "ssh%s -l %s -p %s %s" XXXXX
+ (if config.ssh_compression then " -C" else "")
+ (quote config.ssh_username)
+ (quote config.ssh_port)
+ (quote config.ssh_host) in
+ eprintf "ssh_connect: %s\n%!" cmd;
+ let chan = open_process_out cmd in
+ descr_of_out_channel chan, chan
+
+let ssh_disconnect (_, chan) =
+ match close_process_out chan with
+ | WEXITED 0 -> () (* OK *)
+ | WEXITED i -> failwith (sprintf "ssh: exited with error code %d" i)
+ | WSIGNALED i -> failwith (sprintf "ssh: killed by signal %d" i)
+ | WSTOPPED i -> failwith (sprintf "ssh: stopped by signal %d" i)*)
+
(* Rewrite /mnt/root/etc/fstab. *)
let rewrite_fstab state devices_to_send =
let filename = "/mnt/root/etc/fstab" in
"You should only run this script from the live CD or a USB key.";
(* Start of the information gathering phase. *)
- printf "%s detecting hard drives (this may take some time) ...\n%!"
- program_name;
+ printf "Detecting hard drives (this may take some time) ...\n%!";
(* Search for all non-removable block devices. Do this early and bail
* if we can't find anything. This is a list of strings, like "hda".
) all_partitions
in
- printf "finished detecting hard drives\n%!";
+ printf "Finished detecting hard drives.\n%!";
(* Autodetect system memory. *)
let system_memory =
| None ->
(* Query the user for SSH configuration. *)
open_centered_window ~stage:"SSH configuration"
- 60 15 "SSH configuration";
+ 60 20 "SSH configuration";
let label1 = Newt.label 1 1 "Remote host" in
let host = Newt.entry 20 1 None 36 [] in
let label4 = Newt.label 1 4 "SSH username" in
let user = Newt.entry 20 4 (Some "root") 16 [] in
let label5 = Newt.label 1 5 "SSH password" in
- let pass = Newt.entry 20 5 None 16 [] in
+ let pass = Newt.entry 20 5 None 16 [Newt.PASSWORD] in
+
+ let compr =
+ Newt.checkbox 16 7 "Use SSH compression (not good for LANs)"
+ ' ' None in
- let check = Newt.checkbox 17 7 "Test SSH connection" '*' None in
+ let check = Newt.checkbox 16 9 "Test SSH connection" '*' None in
let libvirtd =
- Newt.checkbox 17 8 "libvirtd is running on host" '*' None in
+ Newt.checkbox 16 10 "libvirtd is running on host" '*' None in
Newt.component_add_callback check
(fun () ->
)
);
- let ok = Newt.button 48 11 " OK " in
+ let ok = Newt.button 48 16 " OK " in
let form = Newt.form None None [] in
Newt.form_add_components form [label1;label2;label3;label4;label5];
Newt.form_add_components form [host;port;dir;user;pass];
- Newt.form_add_components form [check;libvirtd];
+ Newt.form_add_components form [compr;check;libvirtd];
Newt.form_add_component form ok;
let c =
let dir = Newt.entry_get_value dir in
let user = Newt.entry_get_value user in
let pass = Newt.entry_get_value pass in
+ let compr = Newt.checkbox_get_value compr = '*' in
let check = Newt.checkbox_get_value check = '*' in
let libvirtd = Newt.checkbox_get_value libvirtd = '*' in
if host <> "" && port > 0 && port < 65536 &&
user <> "" then
{ ssh_host = host; ssh_port = port; ssh_directory = dir;
ssh_username = user; ssh_password = pass;
+ ssh_compression = compr;
ssh_check = check; ssh_libvirtd = libvirtd }
else
loop ()
c
) in
+ (* If asked, check the SSH connection. At the same time
+ * grab the capabilities from the remote host.
+ *)
+ let capabilities =
+ if config_ssh.ssh_check then (
+ printf "Testing SSH connection.\n\n";
+
+ Some "foo"
+
+
+ )
+ else None in
(*
let remote_directory = Option.get state.remote_directory in
let remote_username = Option.get state.remote_username in
- (* Functions to connect and disconnect from the remote system. *)
- let do_connect remote_name _ =
- let cmd = sprintf "ssh%s -l %s -p %s %s \"cat > %s/%s\""
- (if state.compression = Some false then "" else " -C")
- (quote remote_username) (quote remote_port) (quote remote_host)
- (quote remote_directory) (quote remote_name) in
- eprintf "connect: %s\n%!" cmd;
- let chan = open_process_out cmd in
- descr_of_out_channel chan, chan
- in
- let do_disconnect (_, chan) =
- match close_process_out chan with
- | WEXITED 0 -> () (* OK *)
- | WEXITED i -> failwith (sprintf "ssh: exited with error code %d" i)
- | WSIGNALED i -> failwith (sprintf "ssh: killed by signal %d" i)
- | WSTOPPED i -> failwith (sprintf "ssh: stopped by signal %d" i)
- in
-
(* XXX This is using the hostname derived from network configuration
* above. We might want to ask the user to choose.
*)