[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-API] [PATCH 3 of 4] CA-35397: reduce the number of calls to domain_getinfo by passing the domain's uuid to the guest agent monitoring code, where we know it already



# HG changeset patch
# User David Scott <dave.scott@xxxxxxxxxxxxx>
# Date 1259589193 0
# Node ID 73883a5db626d9861185db38ba14fe667289d589
# Parent  2c13b21ff2d436e451a91009cc0676124df8e3cd
CA-35397: reduce the number of calls to domain_getinfo by passing the domain's 
uuid to the guest agent monitoring code, where we know it already.

This reduces the amount of hypercall spam in the simulator a lot.

Signed-off-by: David Scott <dave.scott@xxxxxxxxxxxxx>

diff -r 2c13b21ff2d4 -r 73883a5db626 ocaml/xapi/dbsync_slave.ml
--- a/ocaml/xapi/dbsync_slave.ml        Mon Nov 30 13:53:09 2009 +0000
+++ b/ocaml/xapi/dbsync_slave.ml        Mon Nov 30 13:53:13 2009 +0000
@@ -447,7 +447,8 @@
           have missed an update; and (ii) if the tools .iso has been updated 
then
           we wish to re-evaluate whether we believe the VMs have up-to-date
           tools *)
-       Events.callback_guest_agent xal dinfo.Xc.domid;
+
+       Events.guest_agent_update xal dinfo.Xc.domid (uuid_from_dinfo dinfo);
        (* Now register with monitoring thread *)
 
       Monitor_rrds.load_rrd ~__context (Uuid.to_string uuid) false
@@ -733,4 +734,3 @@
     if Db.Host.get_bios_strings ~__context ~self:localhost = [] then
       Bios_strings.set_host_bios_strings ~__context ~host:localhost
   );
-
diff -r 2c13b21ff2d4 -r 73883a5db626 ocaml/xapi/events.ml
--- a/ocaml/xapi/events.ml      Mon Nov 30 13:53:09 2009 +0000
+++ b/ocaml/xapi/events.ml      Mon Nov 30 13:53:13 2009 +0000
@@ -546,9 +546,9 @@
 (** Handles guest agent xenstore updates.
     NB this should be a fairly quick operation, consisting of only a few 
xenstore reads and database
     writes. We don't bother to fork a thread for it. Since we're the only 
place where the guest metrics
-    should be modified we also don't bother to acquire any other locks. *)
-let callback_guest_agent ctx domid = 
-  debug "VM (domid: %d) guest agent update" domid;
+    should be modified we also don't bother to acquire any other locks. 
+       Called from dbsync and from Xal. *)
+let guest_agent_update ctx domid uuid = 
   (* Be careful not to kill the main xal event thread *)
   Helpers.log_exn_continue (Printf.sprintf "callback_guest_agent (domid: %d)" 
domid)
     (fun () ->
@@ -558,8 +558,17 @@
        let list (dir: string) = try List.filter (fun x -> x <> "") 
(xs.Xs.directory (path ^ dir)) with Xb.Noent -> [] in
        (* NB Xapi_guest_agent.all is robust to spurious events *)
        Server_helpers.exec_with_new_task (Printf.sprintf "Event thread 
updating guest metrics (domid: %d)" domid)
-        (fun __context -> Xapi_guest_agent.all lookup list ~__context ~domid)
+        (fun __context -> Xapi_guest_agent.all lookup list ~__context ~domid 
~uuid)
     ) ()
+
+(** Called from Xal *)
+let callback_guest_agent ctx domid = 
+  debug "VM (domid: %d) guest agent update" domid;
+  try
+       (* This might fail if the domain has been destroyed: *)
+       let uuid = uuid_of_domid domid in
+       guest_agent_update ctx domid uuid
+  with _ -> ()
 
 (** Handles updates to VM memory targets. *)
 let callback_memory_target ctx domid =
diff -r 2c13b21ff2d4 -r 73883a5db626 ocaml/xapi/xapi_guest_agent.ml
--- a/ocaml/xapi/xapi_guest_agent.ml    Mon Nov 30 13:53:09 2009 +0000
+++ b/ocaml/xapi/xapi_guest_agent.ml    Mon Nov 30 13:53:13 2009 +0000
@@ -90,7 +90,7 @@
 (** Reset all the guest metrics for a particular VM. 'lookup' reads a key from 
xenstore
     and 'list' reads a directory from xenstore. Both are relative to the 
guest's 
     domainpath. *)
-let all (lookup: string -> string option) (list: string -> string list) 
~__context ~domid =
+let all (lookup: string -> string option) (list: string -> string list) 
~__context ~domid ~uuid =
   let all_attr = list "/attr" and all_control = list "/control" in
   let to_map kvpairs = List.concat (List.map (fun (xskey, mapkey) -> match 
lookup xskey with
     | Some xsval -> [ mapkey, xsval ]
@@ -112,6 +112,8 @@
     if List.mem_assoc "micro" pv_drivers_version then pv_drivers_version (* 
already there; do nothing *)
     else ("micro","-1")::pv_drivers_version in
 
+  let self = Db.VM.get_by_uuid ~__context ~uuid in
+
   let (
     pv_drivers_version_cached,
     os_version_cached,
@@ -123,8 +125,7 @@
        Hashtbl.find cache domid 
     with _ -> 
       (* Make sure our cached idea of whether the domain is live or not is 
correct *)
-      let vm=Vmopshelpers.vm_of_domid ~__context domid in
-      let vm_guest_metrics = Db.VM.get_guest_metrics ~__context ~self:vm in
+      let vm_guest_metrics = Db.VM.get_guest_metrics ~__context ~self in
       let live = try Db.VM_guest_metrics.get_live ~__context 
~self:vm_guest_metrics with _ -> false in
       if live then
        dead_domains := IntSet.remove domid !dead_domains
@@ -174,8 +175,6 @@
          if other_cached <> other then
            debug "other changed";
          
-         let self = Vmopshelpers.vm_of_domid ~__context domid in
-
 (*       if memory_cached <> memory then
            debug "memory changed";*)
 
3 files changed, 19 insertions(+), 11 deletions(-)
ocaml/xapi/dbsync_slave.ml     |    4 ++--
ocaml/xapi/events.ml           |   17 +++++++++++++----
ocaml/xapi/xapi_guest_agent.ml |    9 ++++-----


Attachment: xen-api.hg-4.patch
Description: Text Data

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.