From: Richard W.M. Jones <"Richard W.M. Jones "> Date: Tue, 10 Jun 2008 09:34:21 +0000 (+0100) Subject: Improve output of --version, display readable error messages. X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=dfe6b5dddb13624323c5883381dedd34ad4a4663;hp=b46aee37b60c9e5e8c7a808b0f91fcf1a0d98103;p=virt-df.git Improve output of --version, display readable error messages. --- diff --git a/virt-df/virt_df_main.ml b/virt-df/virt_df_main.ml index 57d002a..bcb798a 100644 --- a/virt-df/virt_df_main.ml +++ b/virt-df/virt_df_main.ml @@ -58,7 +58,7 @@ let () = 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 @@ -136,31 +136,39 @@ OPTIONS" 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). *)