(* 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)
+ * Hash of connid -> (C.node_info, hostname option, uri, capabilities)
*)
let static_conn_info = Hashtbl.create 13
*)
let conn = C.connect ~name:uri () in
+ (* Get the static info from the connection. *)
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
+ | Libvirt.Not_supported "virConnectGetHostname" -> None
+ | Libvirt.Virterror err ->
+ prerr_endline (Libvirt.Virterror.to_string err);
+ None in
+ let capabilities =
+ try
+ let caps = C.get_capabilities conn in
+ let caps = Xml.parse_string caps in
+ Some caps
+ with
+ | Libvirt.Not_supported "virConnectGetCapabilities" -> None
+ | Libvirt.Virterror err ->
+ prerr_endline (Libvirt.Virterror.to_string err);
+ None
+ | Xml.Error err ->
+ prerr_endline (Xml.error err);
+ 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)
+ Hashtbl.add static_conn_info conn_id (node_info, hostname, uri, capabilities)
+
+let get_node_info conn_id =
+ let node_info, _, _, _ = Hashtbl.find static_conn_info conn_id in
+ node_info
+
+let get_hostname conn_id =
+ let _, hostname, _, _ = Hashtbl.find static_conn_info conn_id in
+ hostname
+
+let get_uri conn_id =
+ let _, _, uri, _ = Hashtbl.find static_conn_info conn_id in
+ uri
+
+let get_capabilities conn_id =
+ let _, _, _, capabilities = Hashtbl.find static_conn_info conn_id in
+ capabilities
(* Stores the state and history for each domain.
* Hash of (connid, domid) -> mutable domhistory structure.
*)
type columns = string GTree.column * string GTree.column * string GTree.column * string GTree.column * string GTree.column * int GTree.column
-let debug_repopulate = true
+let debug_repopulate = false
(* Populate the tree with the current list of connections, domains.
* This function is called once per second.
let row = model#append () in
(* Get the connection name, usually the hostname. *)
let name =
- match Hashtbl.find static_conn_info conn_id with
- | (_, Some hostname, _) -> hostname
- | (_, None, _) -> sprintf "Conn #%d" conn_id in
+ match get_hostname conn_id with
+ | Some hostname -> hostname
+ | None -> sprintf "Conn #%d" conn_id in
model#set ~row ~column:col_name_id name;
model#set ~row ~column:col_id conn_id;
(* Expand the new row. *)
try
(* Number of CPUs available. *)
- let node_info, _, _ = Hashtbl.find static_conn_info conn_id in
+ let node_info = get_node_info conn_id in
let nr_cpus = C.maxcpus_of_node_info node_info in
(* For this connection, get a current list of active domains (IDs) *)