summaryrefslogtreecommitdiffstats
path: root/virt-top/virt_top_main.ml
diff options
context:
space:
mode:
Diffstat (limited to 'virt-top/virt_top_main.ml')
-rw-r--r--virt-top/virt_top_main.ml37
1 files changed, 37 insertions, 0 deletions
diff --git a/virt-top/virt_top_main.ml b/virt-top/virt_top_main.ml
new file mode 100644
index 0000000..5841362
--- /dev/null
+++ b/virt-top/virt_top_main.ml
@@ -0,0 +1,37 @@
+(* 'top'-like tool for libvirt domains.
+ * $Id: virt_top_main.ml,v 1.2 2007/08/30 13:16:57 rjones Exp $
+ *
+ * Just contains the main function.
+ *)
+
+open Curses
+
+open Virt_top
+
+(* Note: make sure we catch any exceptions and clean up the display.
+ *
+ * Note (2): make sure all exit paths call the GC so that we can check
+ * that all allocated resources are being counted properly (by running
+ * the program under --debug ...).
+ *)
+let error =
+ let state = start_up () in
+
+ try
+ main_loop state;
+ endwin ();
+ false
+ with
+ | Libvirt.Virterror err ->
+ endwin ();
+ prerr_endline (Libvirt.Virterror.to_string err);
+ true
+ | exn ->
+ endwin ();
+ prerr_endline ("Error: " ^ Printexc.to_string exn);
+ true
+
+let () =
+ Gc.compact (); (* See note above. *)
+
+ exit (if error then 1 else 0)