- let nr_active_doms = C.num_of_domains conn in
- let active_doms =
- Array.to_list (C.list_domains conn nr_active_doms) in
- let active_doms =
- List.map (D.lookup_by_id conn) active_doms in
- active_doms in
+ if anon_args = [] then (
+ (* List of active domains. *)
+ let nr_active_doms = C.num_of_domains conn in
+ let active_doms =
+ Array.to_list (C.list_domains conn nr_active_doms) in
+ List.map (D.lookup_by_id conn) active_doms
+ ) else (
+ List.map (
+ fun arg ->
+ let dom =
+ try D.lookup_by_uuid_string conn arg
+ with _ ->
+ try D.lookup_by_name conn arg
+ with _ ->
+ try D.lookup_by_id conn (int_of_string arg)
+ with _ ->
+ failwith (sprintf (f_"%s: unknown domain (not a UUID, name or ID of any active domain)") arg) in
+
+ (* XXX Primitive test to see if the domain is active. *)
+ let is_active = try D.get_id dom >= 0 with _ -> false in
+ if not is_active then
+ failwith (sprintf (f_"%s: domain is not running") arg);
+
+ dom
+ ) anon_args
+ ) in