let set_uri = function "" -> uri := None | u -> uri := Some u in
let version () =
- printf "virt-df %s\n" (Libvirt_version.version);
+ printf "virt-df %s\n" Virt_df_version.version;
let major, minor, release =
let v, _ = Libvirt.get_version () in
);
exit 1 in
- (* Get the list of active & inactive domains. *)
- let doms =
- 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
- if not !all then
- active_doms
- else (
- let nr_inactive_doms = C.num_of_defined_domains conn in
- let inactive_doms =
- Array.to_list (C.list_defined_domains conn nr_inactive_doms) in
- let inactive_doms =
- List.map (D.lookup_by_name conn) inactive_doms in
- active_doms @ inactive_doms
- ) in
-
- (* Get their XML. *)
- let xmls = List.map (fun dom -> dom, D.get_xml_desc dom) doms in
-
- (* Parse the XML. *)
- let xmls = List.map (fun (dom, xml) ->
- dom, Xml.parse_string xml) xmls in
-
+ let xmls =
+ try
+ (* Get the list of active & inactive domains. *)
+ let doms =
+ 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
+ if not !all then
+ active_doms
+ else (
+ let nr_inactive_doms = C.num_of_defined_domains conn in
+ let inactive_doms =
+ Array.to_list
+ (C.list_defined_domains conn nr_inactive_doms) in
+ let inactive_doms =
+ List.map (D.lookup_by_name conn) inactive_doms in
+ active_doms @ inactive_doms
+ ) in
+
+ (* Get their XML. *)
+ let xmls = List.map (fun dom -> dom, D.get_xml_desc dom) doms in
+
+ (* Parse the XML. *)
+ let xmls = List.map (fun (dom, xml) ->
+ dom, Xml.parse_string xml) xmls in
+
+ xmls
+ with
+ Libvirt.Virterror err ->
+ prerr_endline (Libvirt.Virterror.to_string err);
+ exit 1 in
xmls in
(* Grr.. Need to use a library which has XPATH support (or cduce). *)