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] CA-37471: Recreate Host_cpu tables on startup

To: xen-api <xen-api@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-API] [PATCH] CA-37471: Recreate Host_cpu tables on startup
From: Rob Hoes <rob.hoes@xxxxxxxxxx>
Date: Tue, 16 Feb 2010 23:10:38 +0000
Delivery-date: Tue, 16 Feb 2010 15:10:48 -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>
CA-37471: Recreate Host_cpu tables on startup

Host_cpu tables should be removed and recreated when xapi starts. Currently, 
Host_cpu tables are never removed, so when removing a CPU, the CPU records in 
the database will be incorrect. This patch fixes that.

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

diff -r 37bcad9b65fe ocaml/xapi/create_misc.ml
--- a/ocaml/xapi/create_misc.ml Wed Feb 10 10:07:47 2010 +0000
+++ b/ocaml/xapi/create_misc.ml Wed Feb 10 16:44:59 2010 +0000
@@ -440,30 +440,17 @@
        and model = Int64.of_string model 
        and family = Int64.of_string family in
 
-       let existing = Db.Host.get_host_CPUs ~__context ~self:host in
-       let numbers = List.map (fun self -> Int64.to_int 
(Db.Host_cpu.get_number ~__context ~self)) existing in
-       let table = List.combine numbers existing 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
+       List.iter (fun (r, _) -> Db.Host_cpu.destroy ~__context ~self:r) 
host_cpus;
        for i = 0 to number - 1
        do
-         if List.mem i numbers then begin
-           let self = List.assoc i table in
-           Db.Host_cpu.set_vendor ~__context ~self ~value:vendor;
-           Db.Host_cpu.set_speed ~__context ~self ~value:speed;
-           Db.Host_cpu.set_modelname ~__context ~self ~value:modelname;
-           Db.Host_cpu.set_flags ~__context ~self ~value:flags;
-           Db.Host_cpu.set_stepping ~__context ~self ~value:stepping;
-           Db.Host_cpu.set_model ~__context ~self ~value:model;
-           Db.Host_cpu.set_family ~__context ~self ~value:family;
-           Db.Host_cpu.set_features ~__context ~self ~value:"";
-         end else begin
-           let uuid = Uuid.to_string (Uuid.make_uuid ())
+               let uuid = Uuid.to_string (Uuid.make_uuid ())
            and ref = Ref.make () in
-           debug "Creating CPU %d: %s" i uuid;
-           let () = Db.Host_cpu.create ~__context ~ref ~uuid ~host 
~number:(Int64.of_int i)
-             ~vendor ~speed ~modelname
-             ~utilisation:0. ~flags ~stepping ~model ~family
-              ~features:"" ~other_config:[] in 
-           ()
-         end
+               debug "Creating CPU %d: %s" i uuid;
+               ignore (Db.Host_cpu.create ~__context ~ref ~uuid ~host 
~number:(Int64.of_int i)
+                       ~vendor ~speed ~modelname
+                       ~utilisation:0. ~flags ~stepping ~model ~family
+                       ~features:"" ~other_config:[])
        done
 

Attachment: host-cpu-reset
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] CA-37471: Recreate Host_cpu tables on startup, Rob Hoes <=