Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CA-400860: rrdp-netdev - drop xenctrl, use xenstore to get UUIDs from domids instead #6068

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any other plugins that use this pattern? They could share code in the plugin library that you added

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xenops_helpers has the same function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it's where i stole the function from. but xenops_helpers also converts strings to UUIDs, which I don't need.

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
Loading