summaryrefslogtreecommitdiffstats
path: root/virt-ctrl/vc_connections.ml
diff options
context:
space:
mode:
Diffstat (limited to 'virt-ctrl/vc_connections.ml')
-rw-r--r--virt-ctrl/vc_connections.ml63
1 files changed, 27 insertions, 36 deletions
diff --git a/virt-ctrl/vc_connections.ml b/virt-ctrl/vc_connections.ml
index c99b2c4..05024c5 100644
--- a/virt-ctrl/vc_connections.ml
+++ b/virt-ctrl/vc_connections.ml
@@ -43,22 +43,29 @@ let get_conns, add_conn, del_conn =
in
get_conns, add_conn, del_conn
-(* The current state. This is used so that we can see changes that
- * have happened and add or remove parts of the model. (Previously
- * we used to recreate the whole model each time, but the problem
- * with that is we "forget" things like the selection).
- *)
-type state = connection list
-and connection = int (* connection ID *) * (active list * inactive list)
-and active = int (* domain's ID *)
-and inactive = string (* domain's name *)
-
(* Store the node_info and hostname for each connection, fetched
* once just after we connect since these don't normally change.
* Hash of connid -> (C.node_info, hostname option, uri)
*)
let static_conn_info = Hashtbl.create 13
+let open_connection uri =
+ (* If this fails, let the exception escape and be printed
+ * in the global exception handler.
+ *)
+ let conn = C.connect ~name:uri () in
+
+ let node_info = C.get_node_info conn in
+ let hostname =
+ try Some (C.get_hostname conn)
+ with
+ | Libvirt.Not_supported "virConnectGetHostname"
+ | Libvirt.Virterror _ -> None in
+
+ (* Add it to our list of connections. *)
+ let conn_id = add_conn conn in
+ Hashtbl.add static_conn_info conn_id (node_info, hostname, uri)
+
(* Stores the state and history for each domain.
* Hash of (connid, domid) -> mutable domhistory structure.
* We never delete entries in this hash table, which may be a problem
@@ -92,6 +99,16 @@ let new_domhistory () = {
let hist_max = 86400 (* max history stored, seconds *)
let hist_rot = 3600 (* rotation of array when we hit max *)
+(* The current state. This is used so that we can see changes that
+ * have happened and add or remove parts of the model. (Previously
+ * we used to recreate the whole model each time, but the problem
+ * with that is we "forget" things like the selection).
+ *)
+type state = connection list
+and connection = int (* connection ID *) * (active list * inactive list)
+and active = int (* domain's ID *)
+and inactive = string (* domain's name *)
+
(* The types of the display columns in the main window. The interesting
* one of the final (int) field which stores the ID of the row, either
* connid or domid.
@@ -396,32 +413,6 @@ let make_treeview ?packing () =
(tree, model, columns, state)
-(* Callback function to open a connection.
- * This should be a lot more sophisticated. XXX
- *)
-let open_connection () =
- let title = "Open connection to hypervisor" in
- let uri =
- GToolbox.input_string ~title ~text:"xen:///" ~ok:"Open" "Connection:" in
- match uri with
- | None -> ()
- | Some uri ->
- (* If this fails, let the exception escape and be printed
- * in the global exception handler.
- *)
- let conn = C.connect ~name:uri () in
-
- let node_info = C.get_node_info conn in
- let hostname =
- try Some (C.get_hostname conn)
- with
- | Libvirt.Not_supported "virConnectGetHostname"
- | Libvirt.Virterror _ -> None in
-
- (* Add it to our list of connections. *)
- let conn_id = add_conn conn in
- Hashtbl.add static_conn_info conn_id (node_info, hostname, uri)
-
(* Get historical data size. *)
let get_hist_size connid domid =
try