[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-API] [PATCH] CA-37471: Recreate Host_cpu tables on startup
# 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 _______________________________________________ xen-api mailing list xen-api@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/mailman/listinfo/xen-api
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |