Skip to content
Browse files

CP-4319: Detect socket count in

Sending the socket count in the params list to V6client.apply_edition is
a bad idea, since this function also sends the current
Host.license_params, which may also contain the socket count, to v6d.

Instead, we update the license_params map with the socket count before
sending it to v6d.

This also means that the correct socket count is sent to v6d at xapi

Signed-off-by: John Else <>
  • Loading branch information...
1 parent a00ba4d commit ebddedb3d26458ab7b7be20db91381e7957f7525 @johnelse committed
Showing with 12 additions and 4 deletions.
  1. +11 −0 ocaml/license/
  2. +1 −4 ocaml/xapi/
11 ocaml/license/
@@ -15,6 +15,8 @@
module D=Debug.Debugger(struct let name="v6client" end)
open D
+open Listext
exception V6DaemonFailure
let retry = ref true
@@ -26,10 +28,19 @@ let v6rpc call =
XMLRPC_protocol.rpc ~srcstr:"xapi" ~dststr:"v6d" ~transport:(Unix socket) ~http:(xmlrpc ~version:"1.0" "/") call
let rec apply_edition ~__context edition additional =
+ (* Get localhost's current license state. *)
let host = Helpers.get_localhost ~__context in
let license_server = Db.Host.get_license_server ~__context ~self:host in
let current_edition = Db.Host.get_edition ~__context ~self:host in
let current_license_params = Db.Host.get_license_params ~__context ~self:host in
+ (* Make sure the socket count in license_params is correct.
+ * At first boot, the key won't exist, and it may be wrong if we've restored
+ * a database dump from a different host. *)
+ let cpu_info = Db.Host.get_cpu_info ~__context ~self:host in
+ let socket_count = List.assoc "socket_count" cpu_info in
+ let current_license_params =
+ List.replace_assoc "sockets" socket_count current_license_params in
+ (* Construct the RPC params to be sent to v6d *)
let additional = ("current_edition", current_edition) ::
license_server @ current_license_params @ additional in
let params = [ Rpc.rpc_of_string (Context.string_of_task __context)
5 ocaml/xapi/
@@ -1234,11 +1234,8 @@ let apply_edition ~__context ~host ~edition =
if Db.Pool.get_ha_enabled ~__context ~self:pool then
raise (Api_errors.Server_error (Api_errors.ha_is_enabled, []))
else begin
- let cpu_info = Db.Host.get_cpu_info ~__context ~self:host in
- let socket_count = List.assoc "socket_count" cpu_info in
let edition', features, additional =
- V6client.apply_edition ~__context edition
- ["sockets", socket_count]
+ V6client.apply_edition ~__context edition []
Db.Host.set_edition ~__context ~self:host ~value:edition';
copy_license_to_db ~__context ~host ~features ~additional

0 comments on commit ebddedb

Please sign in to comment.
Something went wrong with that request. Please try again.