@@ -224,6 +224,7 @@ type guest_metrics_t = {
224224 ; other : m
225225 ; memory : m
226226 ; device_id : m
227+ ; services : m
227228 ; last_updated : float
228229 ; can_use_hotplug_vbd : API .tristate_type
229230 ; can_use_hotplug_vif : API .tristate_type
@@ -235,6 +236,29 @@ let dead_domains : IntSet.t ref = ref IntSet.empty
235236
236237let mutex = Mutex. create ()
237238
239+ (* Parse data/service which has the following structure:
240+ data/service/<service_name>/<key> = <value>
241+ data/service/<service_name>/<key> = <value>
242+ ...
243+ data/service/<service_name>/<key> = <value>
244+ Read and convert to [(<service_name>/<key>, <value>)] pair list.
245+ The list is intended to store in VM_guest_metrics.services at last *)
246+ let get_guest_services (lookup : string -> string option )
247+ (list : string -> string list ) =
248+ let base_path = " data/service" in
249+ let services = list base_path in
250+ services
251+ |> List. concat_map (fun service ->
252+ let sub_path = base_path // service in
253+ list sub_path
254+ |> List. map (fun key ->
255+ let full_path_key = sub_path // key in
256+ let db_key = service // key in
257+ let value = lookup full_path_key in
258+ (db_key, Option. value ~default: " " value)
259+ )
260+ )
261+
238262(* In the following functions, 'lookup' reads a key from xenstore and 'list' reads
239263 a directory from xenstore. Both are relative to the guest's domainpath. *)
240264let get_initial_guest_metrics (lookup : string -> string option )
@@ -289,6 +313,7 @@ let get_initial_guest_metrics (lookup : string -> string option)
289313 ; networks " xenserver/attr" " net-sriov-vf" list
290314 ]
291315 )
316+ and services = get_guest_services lookup list
292317 and other = List. append (to_map (other all_control)) ts
293318 and memory = to_map memory
294319 and last_updated = Unix. gettimeofday () in
@@ -310,6 +335,7 @@ let get_initial_guest_metrics (lookup : string -> string option)
310335 ; other
311336 ; memory
312337 ; device_id
338+ ; services
313339 ; last_updated
314340 ; can_use_hotplug_vbd
315341 ; can_use_hotplug_vif
@@ -326,7 +352,8 @@ let create_and_set_guest_metrics (lookup : string -> string option)
326352 ~os_version: initial_gm.os_version ~netbios_name: initial_gm.netbios_name
327353 ~p V_drivers_version:initial_gm.pv_drivers_version
328354 ~p V_drivers_up_to_date:pV_drivers_detected ~memory: [] ~disks: []
329- ~networks: initial_gm.networks ~p V_drivers_detected ~other: initial_gm.other
355+ ~networks: initial_gm.networks ~services: initial_gm.services
356+ ~p V_drivers_detected ~other: initial_gm.other
330357 ~last_updated: (Date. of_unix_time initial_gm.last_updated)
331358 ~other_config: [] ~live: true
332359 ~can_use_hotplug_vbd: initial_gm.can_use_hotplug_vbd
@@ -356,6 +383,7 @@ let all (lookup : string -> string option) (list : string -> string list)
356383 ; other
357384 ; memory
358385 ; device_id
386+ ; services
359387 ; last_updated
360388 ; can_use_hotplug_vbd
361389 ; can_use_hotplug_vif
@@ -390,6 +418,7 @@ let all (lookup : string -> string option) (list : string -> string list)
390418 ; other= []
391419 ; memory= []
392420 ; device_id= []
421+ ; services= []
393422 ; last_updated= 0.0
394423 ; can_use_hotplug_vbd= `unspecified
395424 ; can_use_hotplug_vif= `unspecified
@@ -407,6 +436,7 @@ let all (lookup : string -> string option) (list : string -> string list)
407436 ; other
408437 ; memory
409438 ; device_id
439+ ; services
410440 ; last_updated
411441 ; can_use_hotplug_vbd
412442 ; can_use_hotplug_vif
@@ -420,6 +450,7 @@ let all (lookup : string -> string option) (list : string -> string list)
420450 || guest_metrics_cached.networks <> networks
421451 || guest_metrics_cached.other <> other
422452 || guest_metrics_cached.device_id <> device_id
453+ || guest_metrics_cached.services <> services
423454 )
424455 || guest_metrics_cached.can_use_hotplug_vbd <> can_use_hotplug_vbd
425456 || guest_metrics_cached.can_use_hotplug_vif <> can_use_hotplug_vif
@@ -452,6 +483,8 @@ let all (lookup : string -> string option) (list : string -> string list)
452483 ~value: netbios_name ;
453484 if guest_metrics_cached.networks <> networks then
454485 Db.VM_guest_metrics. set_networks ~__context ~self: gm ~value: networks ;
486+ if guest_metrics_cached.services <> services then
487+ Db.VM_guest_metrics. set_services ~__context ~self: gm ~value: services ;
455488 if guest_metrics_cached.other <> other then (
456489 Db.VM_guest_metrics. set_other ~__context ~self: gm ~value: other ;
457490 Helpers. call_api_functions ~__context (fun rpc session_id ->
0 commit comments