Skip to content

Loading…

CLEARWATER: Second wave of commits for PR-1589 #1131

Merged
merged 4 commits into from

1 participant

@johnelse
The Xapi Project member

No description provided.

johnelse added some commits
@johnelse johnelse CP-4322: Remove license check from VM lifecycle operations
Signed-off-by: John Else <john.else@citrix.com>
07391fb
@johnelse johnelse CP-4318: Handle v6d not running when creating software_version
Signed-off-by: John Else <john.else@citrix.com>
9f9d2c8
@johnelse johnelse CP-4318: Fall back to free edition if v6d is not running at startup
Signed-off-by: John Else <john.else@citrix.com>
a00ba4d
@johnelse johnelse CP-4319: Detect socket count in v6client.ml
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
startup.

Signed-off-by: John Else <john.else@citrix.com>
ebddedb
@johnelse
The Xapi Project member

Equivalent (not quite a duplicate) of #1125 for Clearwater.

@johnelse johnelse merged commit 389d2e2 into xapi-project:clearwater

1 check passed

Details default Merged build finished.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 3, 2013
  1. @johnelse

    CP-4322: Remove license check from VM lifecycle operations

    johnelse committed
    Signed-off-by: John Else <john.else@citrix.com>
  2. @johnelse

    CP-4318: Handle v6d not running when creating software_version

    johnelse committed
    Signed-off-by: John Else <john.else@citrix.com>
  3. @johnelse

    CP-4318: Fall back to free edition if v6d is not running at startup

    johnelse committed
    Signed-off-by: John Else <john.else@citrix.com>
  4. @johnelse

    CP-4319: Detect socket count in v6client.ml

    johnelse committed
    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
    startup.
    
    Signed-off-by: John Else <john.else@citrix.com>
This page is out of date. Refresh to see the latest.
Showing with 51 additions and 42 deletions.
  1. +9 −1 ocaml/license/license_init.ml
  2. +11 −0 ocaml/license/v6client.ml
  3. +10 −2 ocaml/xapi/create_misc.ml
  4. +1 −4 ocaml/xapi/xapi_host.ml
  5. +20 −35 ocaml/xapi/xapi_vm.ml
View
10 ocaml/license/license_init.ml
@@ -15,12 +15,20 @@
module D = Debug.Debugger(struct let name="license" end)
open D
+let v6_initialise ~__context ~edition ~params =
+ try
+ V6client.apply_edition ~__context edition params
+ with Api_errors.Server_error (code, []) when code = Api_errors.v6d_failure ->
+ (* Couldn't communicate with v6d, so fall back to running in free mode,
+ * with all standard features enabled and no additional features advertised. *)
+ "free", Features.all_features, []
+
(* xapi calls this function upon startup *)
let initialise ~__context ~host =
try
let edition = Db.Host.get_edition ~__context ~self:host in
let edition', features, additional =
- V6client.apply_edition ~__context edition ["startup", "true"] in
+ v6_initialise ~__context ~edition ~params:["startup", "true"] in
Db.Host.set_edition ~__context ~self:host ~value:edition';
(* Copy resulting license to the database *)
Xapi_host.copy_license_to_db ~__context ~host ~features ~additional
View
11 ocaml/license/v6client.ml
@@ -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)
View
12 ocaml/xapi/create_misc.ml
@@ -381,9 +381,17 @@ let make_packs_info () =
let make_software_version () =
let option_to_list k o = match o with None -> [] | Some x -> [ k, x ] in
let info = read_localhost_info () in
- let v6_version = V6client.get_version "make_software_version" in
+ let v6_version =
+ (* Best-effort attempt to read the date-based version from v6d *)
+ try
+ match V6client.get_version "make_software_version" with
+ | "" -> []
+ | dbv -> ["dbv", dbv]
+ with Api_errors.Server_error (code, []) when code = Api_errors.v6d_failure ->
+ []
+ in
Xapi_globs.software_version @
- (if v6_version = "" then [] else ["dbv", v6_version]) @
+ v6_version @
[
"xapi", get_xapi_verstring ();
"xen", info.xen_verstring;
View
5 ocaml/xapi/xapi_host.ml
@@ -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 []
in
Db.Host.set_edition ~__context ~self:host ~value:edition';
copy_license_to_db ~__context ~host ~features ~additional
View
55 ocaml/xapi/xapi_vm.ml
@@ -180,10 +180,7 @@ let pause ~__context ~vm =
Xapi_xenops.pause ~__context ~self:vm
let unpause ~__context ~vm =
- License_check.with_vm_license_check ~__context vm
- (fun () ->
- Xapi_xenops.unpause ~__context ~self:vm
- )
+ Xapi_xenops.unpause ~__context ~self:vm
let set_xenstore_data ~__context ~self ~value =
Xapi_xenops.set_xenstore_data ~__context ~self value
@@ -194,18 +191,15 @@ let set_xenstore_data ~__context ~self ~value =
*)
let start ~__context ~vm ~start_paused ~force =
- License_check.with_vm_license_check ~__context vm
- (fun () ->
- let vmr = Db.VM.get_record ~__context ~self:vm in
- Vgpuops.create_vgpus ~__context (vm, vmr) (Helpers.will_boot_hvm ~__context ~self:vm);
-
- if vmr.API.vM_ha_restart_priority = Constants.ha_restart
- then begin
- Xapi_ha_vm_failover.assert_new_vm_preserves_ha_plan ~__context vm;
- Db.VM.set_ha_always_run ~__context ~self:vm ~value:true
- end;
- Xapi_xenops.start ~__context ~self:vm start_paused
- )
+ let vmr = Db.VM.get_record ~__context ~self:vm in
+ Vgpuops.create_vgpus ~__context (vm, vmr) (Helpers.will_boot_hvm ~__context ~self:vm);
+
+ if vmr.API.vM_ha_restart_priority = Constants.ha_restart
+ then begin
+ Xapi_ha_vm_failover.assert_new_vm_preserves_ha_plan ~__context vm;
+ Db.VM.set_ha_always_run ~__context ~self:vm ~value:true
+ end;
+ Xapi_xenops.start ~__context ~self:vm start_paused
(** For VM.start_on and VM.resume_on the message forwarding layer should only forward here
if 'host' = localhost *)
@@ -224,10 +218,7 @@ let start_on ~__context ~vm ~host ~start_paused ~force =
start ~__context ~vm ~start_paused ~force
let hard_reboot ~__context ~vm =
- License_check.with_vm_license_check ~__context vm
- (fun () ->
- Xapi_xenops.reboot ~__context ~self:vm None
- )
+ Xapi_xenops.reboot ~__context ~self:vm None
let hard_shutdown ~__context ~vm =
Db.VM.set_ha_always_run ~__context ~self:vm ~value:false;
@@ -246,10 +237,7 @@ let hard_shutdown ~__context ~vm =
Xapi_xenops.shutdown ~__context ~self:vm None
let clean_reboot ~__context ~vm =
- License_check.with_vm_license_check ~__context vm
- (fun () ->
- Xapi_xenops.reboot ~__context ~self:vm (Some 1200.0)
- )
+ Xapi_xenops.reboot ~__context ~self:vm (Some 1200.0)
let clean_shutdown ~__context ~vm =
Db.VM.set_ha_always_run ~__context ~self:vm ~value:false;
@@ -316,19 +304,16 @@ let suspend ~__context ~vm =
Xapi_xenops.suspend ~__context ~self:vm
let resume ~__context ~vm ~start_paused ~force =
- License_check.with_vm_license_check ~__context vm
- (fun () ->
- if Db.VM.get_ha_restart_priority ~__context ~self:vm = Constants.ha_restart
- then begin
- Xapi_ha_vm_failover.assert_new_vm_preserves_ha_plan ~__context vm;
- Db.VM.set_ha_always_run ~__context ~self:vm ~value:true
- end;
+ if Db.VM.get_ha_restart_priority ~__context ~self:vm = Constants.ha_restart
+ then begin
+ Xapi_ha_vm_failover.assert_new_vm_preserves_ha_plan ~__context vm;
+ Db.VM.set_ha_always_run ~__context ~self:vm ~value:true
+ end;
- let host = Helpers.get_localhost ~__context in
- if not force then Cpuid_helpers.assert_vm_is_compatible ~__context ~vm ~host ();
+ let host = Helpers.get_localhost ~__context in
+ if not force then Cpuid_helpers.assert_vm_is_compatible ~__context ~vm ~host ();
- Xapi_xenops.resume ~__context ~self:vm ~start_paused ~force
- )
+ Xapi_xenops.resume ~__context ~self:vm ~start_paused ~force
let resume_on ~__context ~vm ~host ~start_paused ~force =
(* If we modify this to support resume_on other-than-localhost,
Something went wrong with that request. Please try again.