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-1620: Populate Host.cpu_info field on startup

To: xen-api <xen-api@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-API] [PATCH] CP-1620: Populate Host.cpu_info field on startup
From: Rob Hoes <rob.hoes@xxxxxxxxxx>
Date: Tue, 16 Feb 2010 23:11:00 +0000
Delivery-date: Tue, 16 Feb 2010 15:11:20 -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-1620: Populate Host.cpu_info field on startup

This field contains information about the CPUs in the host, including fields 
for CPU feature masking.

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

diff -r 0e735f437ea3 ocaml/xapi/OMakefile
--- a/ocaml/xapi/OMakefile      Fri Feb 12 16:07:50 2010 +0000
+++ b/ocaml/xapi/OMakefile      Tue Feb 16 10:53:27 2010 +0000
@@ -1,4 +1,4 @@
-OCAMLPACKS    = xml-light2 cdrom pciutil sexpr log stunnel http-svr rss
+OCAMLPACKS    = xml-light2 cdrom pciutil sexpr log stunnel http-svr rss cpuid
 OCAML_LIBS    =  ../util/version ../util/vm_memory_constraints 
../util/sanitycheck ../util/stats \
        ../idl/ocaml_backend/common ../idl/ocaml_backend/client 
../idl/ocaml_backend/server ../util/ocamltest
 OCAMLINCLUDES = ../idl ../idl/ocaml_backend \
@@ -13,6 +13,7 @@
 # Since the section didn't work, link against the xen libs for everything if 
we are building
 # xen stuff at all.
 # NB order of libraries is important: OMake cannot determine dependencies 
between libraries
+# (the same holds for OCaml packages)
 XEN_OCAML_LIBS = ../netdev/netdev ../xenops/xenops ../auth/pam
 XEN_OCAMLINCLUDES =
 XEN_OCAMLPACKS = xc xs
@@ -22,7 +23,7 @@
 OCAMLINCLUDES = $(if $(equal $(COMPILE_XENSTUFF), yes), $(XEN_OCAMLINCLUDES) 
$(OCAMLINCLUDES), $(OCAMLINCLUDES))
 # xc.cma depends on uuid.cma
 OCAML_LIBS = $(if $(equal $(COMPILE_XENSTUFF), yes), $(OCAML_LIBS) 
$(XEN_OCAML_LIBS), $(OCAML_LIBS)) 
-OCAMLPACKS = $(if $(equal $(COMPILE_XENSTUFF), yes), $(OCAMLPACKS) 
$(XEN_OCAMLPACKS), $(OCAMLPACKS))
+OCAMLPACKS = $(if $(equal $(COMPILE_XENSTUFF), yes), $(XEN_OCAMLPACKS) 
$(OCAMLPACKS), $(OCAMLPACKS))
 
 # -----------------------------------------------------------------------
 # Build the server
diff -r 0e735f437ea3 ocaml/xapi/create_misc.ml
--- a/ocaml/xapi/create_misc.ml Fri Feb 12 16:07:50 2010 +0000
+++ b/ocaml/xapi/create_misc.ml Tue Feb 16 10:53:27 2010 +0000
@@ -433,12 +433,35 @@
                Hashtbl.find tbl "cpu family"
                in
        let vendor, modelname, cpu_mhz, flags, stepping, model, family = 
get_cpuinfo () in
-
-       let host = Helpers.get_localhost ~__context
-       and number = get_nb_cpus ()
-       and speed = Int64.of_float (float_of_string cpu_mhz)
-       and model = Int64.of_string model 
-       and family = Int64.of_string family in
+       let number = get_nb_cpus () in
+       let host = Helpers.get_localhost ~__context in
+       
+       (* Fill in Host.cpu_info *)
+       
+       let cpuid = Cpuid.read_cpu_info () in
+       let features = Cpuid.features_to_string cpuid.Cpuid.features in
+       let physical_features = Cpuid.features_to_string 
cpuid.Cpuid.physical_features in
+       let cpu = [
+               "cpu_count", string_of_int number;
+               "vendor", vendor;
+               "speed", cpu_mhz;
+               "modelname", modelname;
+               "family", family;
+               "model", model;
+               "stepping", stepping;
+               "flags", flags;
+               "features", features;
+               "features_after_reboot", features;
+               "physical_features", physical_features;
+               "maskable", string_of_bool cpuid.Cpuid.maskable;
+       ] in
+       Db.Host.set_cpu_info ~__context ~self:host ~value:cpu;
+ 
+       (* Recreate all Host_cpu objects *)
+       
+       let speed = Int64.of_float (float_of_string cpu_mhz) in
+       let model = Int64.of_string model in
+       let family = Int64.of_string family in
 
        (* Recreate all Host_cpu objects *)
        let host_cpus = List.filter (fun (_, s) -> s.API.host_cpu_host = host) 
(Db.Host_cpu.get_all_records ~__context) in
@@ -453,4 +476,4 @@
                        ~utilisation:0. ~flags ~stepping ~model ~family
                        ~features:"" ~other_config:[])
        done
-
+       

Attachment: flex-startup
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-1620: Populate Host.cpu_info field on startup, Rob Hoes <=