X-Git-Url: http://git.annexia.org/?p=virt-ctrl.git;a=blobdiff_plain;f=virt-ctrl%2Fvc_connections.ml;h=5d9e22c10b47a31f54ba704e608f7240f4244dc0;hp=03d06ac3a04de3957377427f666114ef9189916d;hb=b64cf8e133089a82996beb01402eb504eb30ac38;hpb=2a128db5bb37fc904f611d1344adf5d743e1b0db diff --git a/virt-ctrl/vc_connections.ml b/virt-ctrl/vc_connections.ml index 03d06ac..5d9e22c 100644 --- a/virt-ctrl/vc_connections.ml +++ b/virt-ctrl/vc_connections.ml @@ -46,7 +46,7 @@ let get_conns, add_conn, del_conn = (* 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 @@ -56,16 +56,48 @@ let open_connection uri = *) 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. @@ -116,7 +148,7 @@ and inactive = string (* domain's name *) *) 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. @@ -148,9 +180,9 @@ let repopulate (tree : GTree.view) (model : GTree.tree_store) 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. *) @@ -178,7 +210,7 @@ let repopulate (tree : GTree.view) (model : GTree.tree_store) 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) *)