WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

[Xen-API] [PATCH] CP-1622: XenAPI functions for masking CPU features

To: xen-api <xen-api@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-API] [PATCH] CP-1622: XenAPI functions for masking CPU features
From: Rob Hoes <rob.hoes@xxxxxxxxxx>
Date: Tue, 16 Feb 2010 23:11:25 +0000
Delivery-date: Tue, 16 Feb 2010 15:12:08 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Rob Hoes <rob.hoes@xxxxxxxxxx>
CP-1622: XenAPI functions for masking CPU features

There are two new functions:
* Host.set_cpu_features, for applying feature masks
* Host.reset_cpu_features, for removing all current masks

Signed-off-by: Rob Hoes <rob.hoes@xxxxxxxxxx>

diff -r 1cbc49ef217a ocaml/xapi/xapi_host.ml
--- a/ocaml/xapi/xapi_host.ml   Tue Feb 16 22:52:01 2010 +0000
+++ b/ocaml/xapi/xapi_host.ml   Tue Feb 16 22:54:32 2010 +0000
@@ -13,6 +13,7 @@
  *)
 open Pervasiveext
 open Stringext
+open Listext
 open Threadext
 open Xapi_host_helpers
 open Xapi_support
@@ -1262,12 +1263,47 @@
        debug "Refreshing software_version";
        let software_version = Create_misc.make_software_version () in
        Db.Host.set_software_version ~__context ~self:host 
~value:software_version
-       
+               
 let set_cpu_features ~__context ~host ~features =
        debug "Set CPU features";
-       ()
+       (* check restrictions *)
+       if not (Restrictions.ok_for_cpu_masking ()) then
+               raise (Api_errors.Server_error (Api_errors.feature_restricted, 
[]));
+       
+       let cpuid = Cpuid.read_cpu_info () in
+       
+       (* parse features string *)
+       let features =
+               try Cpuid.string_to_features features
+               with Cpuid.InvalidFeatureString e ->
+                       raise (Api_errors.Server_error 
(Api_errors.invalid_feature_string, [e]))
+       in
+       
+       (* check masking is possible *)
+       begin try
+               Cpuid.assert_maskability cpuid cpuid.Cpuid.manufacturer features
+       with
+       | Cpuid.MaskingNotSupported e -> 
+               raise (Api_errors.Server_error 
(Api_errors.cpu_feature_masking_not_supported, [e]))
+       | Cpuid.InvalidFeatureString e ->       
+               raise (Api_errors.Server_error 
(Api_errors.invalid_feature_string, [e]))
+       | Cpuid.ManufacturersDiffer -> () (* cannot happen *)
+       end;
+       
+       (* add masks to Xen command line *)
+       ignore (Xen_cmdline.delete_cpuid_masks ["cpuid_mask_ecx"; 
"cpuid_mask_edx"; "cpuid_mask_ext_ecx"; "cpuid_mask_ext_edx"]);
+       let new_masks = Cpuid.xen_masking_string cpuid features in
+       ignore (Xen_cmdline.set_cpuid_masks new_masks);
+       
+       (* update database *)
+       let cpu_info = Db.Host.get_cpu_info ~__context ~self:host in
+       let cpu_info = List.replace_assoc "features_after_reboot" 
(Cpuid.features_to_string features) cpu_info in
+       Db.Host.set_cpu_info ~__context ~self:host ~value:cpu_info
                
 let reset_cpu_features ~__context ~host =
        debug "Reset CPU features";
-       ()
-
+       ignore (Xen_cmdline.delete_cpuid_masks ["cpuid_mask_ecx"; 
"cpuid_mask_edx"; "cpuid_mask_ext_ecx"; "cpuid_mask_ext_edx"]);
+       let cpu_info = Db.Host.get_cpu_info ~__context ~self:host in
+       let physical_features = List.assoc "physical_features" cpu_info in
+       let cpu_info = List.replace_assoc "features_after_reboot" 
physical_features cpu_info in
+       Db.Host.set_cpu_info ~__context ~self:host ~value:cpu_info
diff -r 1cbc49ef217a ocaml/xapi/xapi_host.mli
--- a/ocaml/xapi/xapi_host.mli  Tue Feb 16 22:52:01 2010 +0000
+++ b/ocaml/xapi/xapi_host.mli  Tue Feb 16 22:54:32 2010 +0000
@@ -227,15 +227,15 @@
 
 (** {2 Licensing} *)
 
-val apply_edition : __context:Context.t -> host:API.ref_host -> edition:string 
-> unit
 (** Attempt to activate the given edition (one of "free", "enterprise" or 
"platinum".
  *  In needed, the function automatically checks v6 licenses in and out
  *  from the license server (via the v6 daemon). If the requested edition is 
not
  *  available, the call will fail with an exception, leaving the edition as it 
is.
  *  Also call this function to change to a different license server, after the
  *  connection details in host.license_server have been amended. *)
+val apply_edition : __context:Context.t -> host:API.ref_host -> edition:string 
-> unit 
  
- 
+
 (** {2 CPU Feature Masking} *)
  
 (** Set the CPU features to be used after a reboot, if the given features 
string is valid. *)

Attachment: flex-calls
Description: Text document

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-API] [PATCH] CP-1622: XenAPI functions for masking CPU features, Rob Hoes <=