Skip to content

Commit

Permalink
CA-400860: rrdp-netdev - drop xenctrl, use xenstore to get UUIDs from…
Browse files Browse the repository at this point in the history
… domids instead (#6068)

Follow-up to the fix we had to rush, dropping xenctrl entirely.

Tested with a Windows VM, the domain creation is picked up and network
metrics are present for it, with correct UUIDs determined.
  • Loading branch information
robhoes authored Oct 29, 2024
2 parents 82b2113 + 1bdb22a commit 58b9acc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion ocaml/xcp-rrdd/bin/rrdp-netdev/dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
(name rrdp_netdev)
(libraries
astring
ezxenstore.core
integers
netlink
rrdd-plugin
Expand All @@ -13,7 +14,6 @@
xapi-log
xapi-rrd
xapi-stdext-std
xenctrl
)
)

Expand Down
27 changes: 14 additions & 13 deletions ocaml/xcp-rrdd/bin/rrdp-netdev/rrdp_netdev.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
*)

open Rrdd_plugin
open Ezxenstore_core

module D = Debug.Make (struct let name = "xcp-rrdp-netdev" end)

module Process = Rrdd_plugin.Process (struct let name = "xcp-rrdd-netdev" end)

let fail = Printf.ksprintf failwith

type iface_stats = {
tx_bytes: int64 (** bytes emitted *)
; tx_pkts: int64 (** packets emitted *)
Expand Down Expand Up @@ -132,18 +135,16 @@ let transform_taps devs =
newdevnames

let generate_netdev_dss () =
let _, doms, _ =
Xenctrl.with_intf (fun xc -> Xenctrl_lib.domain_snapshot xc)
in

let uuid_of_domid domains domid =
let _, uuid, _ =
try List.find (fun (_, _, domid') -> domid = domid') domains
with Not_found ->
failwith
(Printf.sprintf "Failed to find uuid corresponding to domid: %d" domid)
in
uuid
let uuid_of_domid domid =
try
Xenstore.with_xs (fun xs ->
let vm = xs.Xenstore.Xs.getdomainpath domid ^ "/vm" in
let vm_dir = xs.Xenstore.Xs.read vm in
xs.Xenstore.Xs.read (vm_dir ^ "/uuid")
)
with e ->
fail "Failed to find uuid corresponding to domid: %d (%s)" domid
(Printexc.to_string e)
in

let dbg = "rrdp_netdev" in
Expand Down Expand Up @@ -198,7 +199,7 @@ let generate_netdev_dss () =
let vif_name = Printf.sprintf "vif_%d" d2 in
(* Note: rx and tx are the wrong way round because from dom0 we
see the vms backwards *)
let uuid = uuid_of_domid doms d1 in
let uuid = uuid_of_domid d1 in
( Rrd.VM uuid
, Ds.ds_make ~name:(vif_name ^ "_tx") ~units:"B/s"
~description:
Expand Down

0 comments on commit 58b9acc

Please sign in to comment.