* virt-top/virt_top.ml: qemu:/// URIs (and others) don't support
[virt-top.git] / virt-top / virt_top.ml
index e2a7435..a5953f3 100644 (file)
@@ -137,6 +137,9 @@ OPTIONS" in
   let hostname =
     try C.get_hostname conn
     with
+    (* qemu:/// and other URIs didn't support virConnectGetHostname until
+     * libvirt 0.3.3.  Before that they'd throw a virterror. *)
+    | Libvirt.Virterror _
     | Invalid_argument "virConnectGetHostname not supported" -> "unknown" in
 
   let libvirt_version =
@@ -486,11 +489,18 @@ let redraw, clear_pcpu_display_data =
        ) ids in
 
       (* Inactive domains. *)
-      let n = C.num_of_defined_domains conn in
-      let names =
-       if n > 0 then Array.to_list (C.list_defined_domains conn n)
-       else [] in
-      let doms_inactive = List.map (fun name -> name, Inactive) names in
+      let doms_inactive =
+       try
+         let n = C.num_of_defined_domains conn in
+         let names =
+           if n > 0 then Array.to_list (C.list_defined_domains conn n)
+           else [] in
+         List.map (fun name -> name, Inactive) names
+       with
+         (* Ignore transient errors, in particular errors from
+          * num_of_defined_domains if it cannot contact xend.
+          *)
+       | Libvirt.Virterror _ -> [] in
 
       doms @ doms_inactive in