+
+(* Do what the user asked on the command line. *)
+let rec run_cli_request ws = function
+ | Cmdline.Empty_window -> ()
+ | Cmdline.Open_images images ->
+ open_disk_images ws images
+ | Cmdline.Open_guest guest ->
+ (* Open libvirt connection, and in the callback open the guest. *)
+ let uri = connect_uri () in
+ Slave.connect uri (when_connected_cli_request ws guest)
+and when_connected_cli_request ws guest doms =
+ populate_vmcombo ws doms;
+
+ (* "guest" should match a domain in "doms". Check this and
+ * get the index of it.
+ *)
+ let rec loop i = function
+ | [] ->
+ failwith "guest %s not found (do you need to use --connect?)" guest
+ | d::ds when d = guest -> i
+ | _::ds -> loop (i+1) ds
+ in
+ let i = loop 0 (List.map (fun { Slave.dom_name = name } -> name) doms) in
+
+ let combo, _ = ws.vmcombo in
+ combo#set_active i