xapi-project / xen-api

The Xapi Project's XenAPI Server
http://xenproject.org/developers/teams/xapi.html
Other
346 stars 285 forks source link

squeezed considers any value of `~/control/feature-balloon` as "true" #5027

Open ydirson opened 1 year ago

ydirson commented 1 year ago

https://github.com/xapi-project/xen-api/blob/b8abdec8f169a7567d113bf66fed42de2abbc372/ocaml/squeezed/src/squeeze_xen.ml#L496-L501:

  (** Return true if feature_balloon has been advertised *)
  let get_feature_balloon cnx domid =
    try
      ignore (read cnx domid _feature_balloon) ;
      true
    with Xs_protocol.Enoent _ -> false

This usage is counter-intuitive, as its usage by `xe-deamon' shows: https://github.com/xenserver/xe-guest-utilities/blob/388091e02f2ac8d7dae7beb7c83ccf1c905ee6c4/guestmetric/guestmetric_linux.go#L44-L48

It should likely only consider value 1 here so xe-daemon -B will work as intended.

psafont commented 1 year ago

This should work:

  (** Return true if feature_balloon has been advertised *)
  let get_feature_balloon cnx domid =
    try
      let is_advertised = read cnx domid _feature_balloon  in
      is_advertised = "1"
    with Xs_protocol.Enoent _ -> false

It might even be worth looking at how other values are read and use the same function to read "booleans"