- let dlgs =
- let dont_skip _ = false in
- [|
- ask_greeting, not defaults.greeting, dont_skip;
- ask_hostname, defaults.remote_host <> None, dont_skip;
- ask_port, defaults.remote_port <> None, dont_skip;
- ask_directory, defaults.remote_directory <> None, dont_skip;
- ask_username, defaults.remote_username <> None, dont_skip;
- ask_network, defaults.network <> None, dont_skip;
- ask_static_network_config,
- defaults.static_network_config <> None,
- (function { network = Some Static } -> false | _ -> true);
- ask_devices, defaults.devices_to_send <> None, dont_skip;
- ask_root, defaults.root_filesystem <> None, dont_skip;
- ask_hypervisor, defaults.hypervisor <> None, dont_skip;
- ask_architecture, defaults.architecture <> None, dont_skip;
- ask_memory, defaults.memory <> None, dont_skip;
- ask_vcpus, defaults.vcpus <> None, dont_skip;
- ask_mac_address, defaults.mac_address <> None, dont_skip;
- ask_compression, defaults.compression <> None, dont_skip;
- ask_verify, not defaults.greeting, dont_skip;
- |] in
-
- (* Loop through the dialogs until we reach the end. *)
- let rec loop ?(back=false) posn state =
- eprintf "dialog loop: posn = %d, back = %b\n%!" posn back;
- if posn >= Array.length dlgs then state (* Finished all dialogs. *)
- else if posn < 0 then loop 0 state
- else (
- let dlg, skip_static, skip_dynamic = dlgs.(posn) in
- if skip_static || skip_dynamic state then
- (* Skip this dialog. *)
- loop ~back (if back then posn-1 else posn+1) state
- else (
- (* Run dialog. *)
- match dlg state with
- | Next new_state -> loop (posn+1) new_state (* Forwards. *)
- | Ask_again -> loop posn state (* Repeat the question. *)
- | Prev -> loop ~back:true (posn-1) state (* Backwards / back button. *)
- )
- )
- in
- let state = loop 0 defaults in
-
- eprintf "finished dialog loop\n%!";
-
- (* In test mode, exit here before we do bad things to the developer's
+ let capabilities =
+ try
+ if not config_target.tgt_libvirtd then raise Not_found;
+
+ let proto, path =
+ match config_target.tgt_hypervisor with
+ | Some Xen -> "xen", "/"
+ | Some (QEMU|KVM) -> "qemu", "/system"
+ | None -> raise Not_found in
+ let name =
+ sprintf "%s+ssh://%s@%s:%s%s"
+ proto config_ssh.ssh_username
+ config_ssh.ssh_host config_ssh.ssh_port path in
+ eprintf "fetch capabilities from %S\n%!" name;
+
+ let conn = Libvirt.Connect.connect_readonly ~name () in
+ let caps = Libvirt.Connect.get_capabilities conn in
+ Libvirt.Connect.close conn;
+
+ eprintf "capabilities:\n%s\n%!" caps;
+
+ Some caps
+ with
+ | Not_found -> None
+ | Libvirt.Virterror err ->
+ eprintf "libvirt error: %s\n%!" (Libvirt.Virterror.to_string err);
+ None
+ | Invalid_argument str ->
+ eprintf "libvirt error: %s\n%!" str;
+ None in
+
+ (* In test mode, exit here before we do Bad Things to the developer's