Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
5f9cb82
CP-2252: Pass VDI type through to SM when doing a VDI.create
johnelse Feb 3, 2011
279315d
CP-2258: Pass VDI.set_is_a_snapshot and VDI.set_snapshot_of through t…
johnelse Feb 3, 2011
ff045c8
CP-2278: Add DR to features list
johnelse Feb 3, 2011
1a4e354
CP-2281: Add the VM.suspend_SR field, including CLI getter and setter
johnelse Feb 3, 2011
22c6453
CP-2230: Add API fields relating a pool to its metadata VDIs
johnelse Feb 4, 2011
5a1543e
CP-2247: Add DB upgrade rule for VDI types.
johnelse Feb 4, 2011
84641f5
CP-2230: Add API stubs for enabling/disabling database replication.
johnelse Feb 4, 2011
dafa78c
CP-2229: Add DB upgrade rule for ha_restart_priority
johnelse Feb 5, 2011
17f6a7f
CP-2245: Initial commit of DR_task API changes.
johnelse Feb 10, 2011
efc485c
CP-2279: Initial commit of the redo_log data type.
johnelse Feb 11, 2011
9b6d79e
CP-2279: Remove global state from redo_log.
johnelse Feb 12, 2011
7643763
CP-2279: Keep track of a set of redo_log instances
johnelse Feb 14, 2011
3fb9495
CP-2279: Shutdown all active redo_logs on exit.
johnelse Feb 14, 2011
5a9b4ea
CP-2279: Monitor a redo_log instance.
johnelse Feb 14, 2011
5c1b1aa
CP-2279: Changes to high-level redo log functions.
johnelse Feb 14, 2011
fc4e2a2
CP-2279: Make HA use its own instance of redo_log
johnelse Feb 14, 2011
da404b4
CP-2279: Change xapi_pool to use the HA redo_log instance
johnelse Feb 14, 2011
a3c0904
CP-2279: Change xapi to use the HA redo_log instance
johnelse Feb 14, 2011
60081a0
CP-2247: Change HA to use a VDI of type `redo_log.
johnelse Feb 15, 2011
61ceef7
CP-2249: Checkpoint commit of VDI.open_database changes
johnelse Feb 16, 2011
7a5db82
PR-1223: Redo log can use a path instead of a VDI object
johnelse Feb 17, 2011
ac2520e
PR-1223: Add some DR-related errors
johnelse Feb 17, 2011
1dc4938
Fix indentation
johnelse Feb 17, 2011
152f8a9
PR-1223: Don't read from redo log into global database
johnelse Feb 17, 2011
c84851d
PR-1223: Remove master db reference
johnelse Feb 17, 2011
573a60d
PR-1223: Add helper function to context
johnelse Feb 17, 2011
602c507
PR-1223: Add constants for importing foreign metadata
johnelse Feb 17, 2011
a2d7b07
apply_delta_to_cache now requires a DB reference
johnelse Feb 17, 2011
3a85645
Ensure use of the master db when querying sessions
johnelse Feb 17, 2011
d52fe31
Make changes to Xapi_session.create_readonly_session
johnelse Feb 17, 2011
8de8830
PR-1223: Changes to VDI.open_database
johnelse Feb 17, 2011
652c89b
Fix unbound value
johnelse Feb 17, 2011
fc9691e
Add threadsafe interface to the foreign db table
johnelse Feb 18, 2011
49583cc
Add error could_not_import_database
johnelse Feb 18, 2011
8cfae7d
CP-2226: Catch errors on VDI.database_open
johnelse Feb 18, 2011
7816387
Use threadsafe interface when registering foreign DBs
johnelse Feb 18, 2011
086955f
Enable VDI.open_database with VDIs of any type
johnelse Feb 18, 2011
e73dedb
CP-2249: Unregister session with Db_backend on delete
johnelse Feb 18, 2011
40675f5
Add field VM.version
johnelse Feb 21, 2011
42e93aa
Populate last_boot_CPU_flags on VM.start
johnelse Feb 21, 2011
608824e
Create Xapi_vm_helpers.populate_cpu_flags
johnelse Feb 23, 2011
27e7096
Populate last_boot_CPU_flags on database upgrade
johnelse Feb 23, 2011
37a5933
Add error vm_incompatible_with_this_host
johnelse Feb 23, 2011
adc7eae
Allow creation of VBDs from metadata VDIs
johnelse Feb 23, 2011
b67e62e
Implement database replication to SRs
johnelse Feb 24, 2011
4163363
Don't enable database replication unless DR feature is enabled
johnelse Feb 24, 2011
36b5f72
Add error cannot_destroy_disaster_recovery_task.
johnelse Feb 25, 2011
1a72279
Restrict certain SMAPI calls during DR.
johnelse Feb 25, 2011
6a053b6
Add sanity checks when setting VM fields
johnelse Feb 28, 2011
7a72d0a
Fix typo in db upgrade rule.
johnelse Mar 1, 2011
97ff287
Change VM field order in datamodel.
johnelse Mar 1, 2011
00dcae2
Add error vm_is_part_of_an_appliance.
johnelse Mar 4, 2011
efa919d
Make VDI.open_database reindex the opened database.
johnelse Mar 4, 2011
d302dcb
Change where check for foreign databases is made.
johnelse Mar 4, 2011
f3a8e76
Implement VM.assert_can_be_recovered.
johnelse Mar 7, 2011
0bf5475
Pass name_description through to SM backend on VDI_create.
johnelse Mar 7, 2011
16996c5
CLI fields should have dashes, not underscores.
johnelse Mar 7, 2011
d651beb
Fix typo.
johnelse Mar 7, 2011
2253cb4
Fix whitespace in VM import handler.
johnelse Mar 7, 2011
085fd0e
Checkpoint commit of VM.recover implementation.
johnelse Mar 9, 2011
f4bfab9
Implement VM_appliance.assert_can_be_recovered.
johnelse Mar 9, 2011
62206c7
Move assert_can_be_recovered to Xapi_vm_helpers.
johnelse Mar 9, 2011
6625646
Finish implementing VM.recover.
johnelse Mar 9, 2011
3d45a9c
Remove useless List.iter over single-element list.
johnelse Mar 9, 2011
026c4c1
Perform RBAC check when recovering VMs.
johnelse Mar 9, 2011
120e94d
Move VM recovery code to a new module.
johnelse Mar 10, 2011
c812222
Implement VM_appliance.recover
johnelse Mar 10, 2011
ea0d85f
Add CLI getter for field VM.version.
johnelse Mar 10, 2011
8aa40f0
VM metadata import changes for disaster recovery.
johnelse Mar 10, 2011
54cb39d
Change rules for incrementing VM.version on VM import.
johnelse Mar 10, 2011
f357064
VM.assert_can_be_recovered should not require CD drives to be present.
johnelse Mar 10, 2011
53ea7b3
Bump API version to 1.9
johnelse Mar 11, 2011
06917ae
HA: Deprecate method VM.set_ha_always_run
johnelse Mar 14, 2011
7f4cfd0
HA: Changes to Helpers.vm_should_always_run
johnelse Mar 14, 2011
6f173b0
HA: Remove reference to ha_always_run.
johnelse Mar 14, 2011
b3df2ef
HA: Remove VM.ha_assert_always_run_is_* functions.
johnelse Mar 14, 2011
dacff13
HA: Use VM.order field to decide VM restart order.
johnelse Mar 14, 2011
706e38d
HA: Fix invalid default field in xapi_test_common.
johnelse Mar 14, 2011
7a6d667
Add DB upgrade rule for VMs with auto_poweron=true.
johnelse Mar 14, 2011
21c7699
Remove auto-start on server boot script.
johnelse Mar 14, 2011
ba4c424
Implement DR_task create and destroy.
johnelse Mar 15, 2011
63c0ef4
Check appliance field using is_valid_ref
johnelse Mar 16, 2011
91c0e1d
On vm_install check SR reference using DB.is_valid_ref
johnelse Mar 16, 2011
4a6729c
Fix whitespace in pbd plug/unplug.
johnelse Mar 16, 2011
94ab77b
Move code from Xapi_sr to Xapi_vdi_helpers.
johnelse Mar 16, 2011
53bc6d4
Use unique attach reasons when opening metadata from VDIs.
johnelse Mar 17, 2011
42ec66c
Start/stop metadata replication on PBD plug/unplug.
johnelse Mar 17, 2011
bcd2304
Improve VDI.open_database error handling.
johnelse Mar 17, 2011
57fb09e
Make VDI.open_database return read-only session.
johnelse Mar 18, 2011
ba0a657
Don't destroy the special foreign database sessions.
johnelse Mar 18, 2011
b0ae2f3
Use raw VDIs for metadata replication.
johnelse Mar 18, 2011
08c6428
Use datamodel schema when importing database.
johnelse Mar 18, 2011
baa6877
Remove redundant check for VM.appliance on VM.recover.
johnelse Mar 22, 2011
faf620f
CLI changes for DR_task object.
johnelse Mar 22, 2011
201473e
Make some parameters optional for drtask-create.
johnelse Mar 23, 2011
e3fac7d
Improve error handling and logging for DR_task.
johnelse Mar 23, 2011
a821844
Fix syntax errors caused by the merge with trunk.
johnelse Mar 23, 2011
133d4e7
Uncomment VDI type check in VDI.open_database.
johnelse Mar 23, 2011
32c6b11
Include snapshots when recovering VMs.
johnelse Mar 23, 2011
0998c62
Don't add templates to recovered appliances.
johnelse Mar 23, 2011
02eb038
CLI implementation of disaster recovery methods.
johnelse Mar 24, 2011
0d7513b
Clear SR introduced_by field on VM recovery.
johnelse Mar 24, 2011
9a8a86a
Remove unused function from Xapi_sr.
johnelse Mar 24, 2011
52dd900
Use correct context when clearing the introduced_by field.
johnelse Mar 24, 2011
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions ocaml/client_records/records.ml
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,9 @@ let vm_record rpc session_id vm =
~set:(fun x -> Client.VM.set_memory_static_min rpc session_id vm (Record_util.bytes_of_string "memory-static-min" x)) ();
make_field ~name:"suspend-VDI-uuid"
~get:(fun () -> get_uuid_from_ref (x ()).API.vM_suspend_VDI) ();
make_field ~name:"suspend-SR-uuid"
~get:(fun () -> get_uuid_from_ref (x ()).API.vM_suspend_SR) ()
~set:(fun x -> Client.VM.set_suspend_SR rpc session_id vm (Client.SR.get_by_uuid rpc session_id x));
make_field ~name:"VCPUs-params"
~get:(fun () -> Record_util.s2sm_to_string "; " (x ()).API.vM_VCPUs_params)
~add_to_map:(fun k v -> match k with
Expand Down Expand Up @@ -859,7 +862,7 @@ let vm_record rpc session_id vm =
~add_to_map:(fun k v -> Client.VM.add_to_xenstore_data rpc session_id vm k v)
~remove_from_map:(fun k -> Client.VM.remove_from_xenstore_data rpc session_id vm k)
~get_map:(fun () -> (x ()).API.vM_xenstore_data) ();
make_field ~name:"ha-always-run"
make_field ~name:"ha-always-run" ~deprecated:true
~get:(fun () -> string_of_bool ((x ()).API.vM_ha_always_run))
~set:(fun x -> Client.VM.set_ha_always_run rpc session_id vm (bool_of_string x)) ();
make_field ~name:"ha-restart-priority"
Expand Down Expand Up @@ -925,6 +928,8 @@ let vm_record rpc session_id vm =
make_field ~name:"order"
~get:(fun () -> Int64.to_string (x ()).API.vM_shutdown_delay)
~set:(fun x -> Client.VM.set_order rpc session_id vm (safe_i64_of_string "order" x)) ();
make_field ~name:"version"
~get:(fun () -> Int64.to_string (x ()).API.vM_version) ();
]}

let host_crashdump_record rpc session_id host =
Expand Down Expand Up @@ -1412,9 +1417,9 @@ let vm_appliance_record rpc session_id vm_appliance =
fields =
[
make_field ~name:"uuid" ~get:(fun () -> (x ()).API.vM_appliance_uuid) ();
make_field ~name:"name_label" ~get:(fun () -> (x ()).API.vM_appliance_name_label)
make_field ~name:"name-label" ~get:(fun () -> (x ()).API.vM_appliance_name_label)
~set:(fun x -> Client.VM_appliance.set_name_label rpc session_id !_ref x) ();
make_field ~name:"name_description" ~get:(fun () -> (x ()).API.vM_appliance_name_description)
make_field ~name:"name-description" ~get:(fun () -> (x ()).API.vM_appliance_name_description)
~set:(fun x -> Client.VM_appliance.set_name_description rpc session_id !_ref x) ();
make_field ~name:"VMs" ~get:(fun () -> String.concat "; " (List.map get_uuid_from_ref (x ()).API.vM_appliance_VMs))
~get_set:(fun () -> List.map get_uuid_from_ref (x ()).API.vM_appliance_VMs) ();
Expand All @@ -1427,6 +1432,24 @@ let vm_appliance_record rpc session_id vm_appliance =
]
}

let dr_task_record rpc session_id dr_task =
let _ref = ref dr_task in
let empty_record = ToGet (fun () ->
Client.DR_task.get_record ~rpc ~session_id ~self:!_ref) in
let record = ref empty_record in
let x () = lzy_get record in
{
setref = (fun r -> _ref := r; record := empty_record);
setrefrec = (fun (a, b) -> _ref := a; record := Got b);
record = x;
getref = (fun () -> !_ref);
fields =
[
make_field ~name:"uuid" ~get:(fun () -> (x ()).API.dR_task_uuid) ();
make_field ~name:"introduced-SRs" ~get:(fun () -> String.concat "; " (List.map get_uuid_from_ref (x ()).API.dR_task_introduced_SRs)) ();
]
}


(*let record_from_ref rpc session_id ref =
let all = [
Expand Down
17 changes: 15 additions & 2 deletions ocaml/database/db_backend.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ open Db_exn
open Db_lock
open Db_cache_types
open Pervasiveext
open Threadext

module D = Debug.Debugger(struct let name = "sql" end)
open D
Expand All @@ -30,7 +31,6 @@ let master_database = ref (Db_cache_types.Database.make Schema.empty)

let make () = Db_ref.in_memory (ref master_database)


(* !!! Right now this is called at cache population time. It would probably be preferable to call it on flush time instead, so we
don't waste writes storing non-persistent field values on disk.. At the moment there's not much to worry about, since there are
few non-persistent fields. However, if this number increases we may want to consider calling this fn on every flush instead.. *)
Expand Down Expand Up @@ -63,4 +63,17 @@ let blow_away_non_persistent_fields (schema: Schema.t) db =
let tbl' = table tblname tbl in
TableSet.add tblname tbl' acc) ts TableSet.empty)
db


let db_registration_mutex = Mutex.create ()
let foreign_databases: ((API.ref_session, Db_ref.t) Hashtbl.t) = Hashtbl.create 5

let register_session_with_database session db_ref =
Mutex.execute db_registration_mutex (fun () ->
Hashtbl.replace foreign_databases session db_ref)

let unregister_session session =
Mutex.execute db_registration_mutex (fun () ->
Hashtbl.remove foreign_databases session)

let is_session_registered session =
Hashtbl.mem foreign_databases session
9 changes: 4 additions & 5 deletions ocaml/database/db_cache.ml
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,16 @@ let get = function
| Db_ref.In_memory _ -> (module Local_db : DB_ACCESS)
| Db_ref.Remote -> (module Remote_db : DB_ACCESS)

let apply_delta_to_cache entry =
let apply_delta_to_cache entry db_ref =
let module DB = (Local_db : DB_ACCESS) in
let t = Db_backend.make () in
let context = Context.make "redo_log" in
match entry with
| Redo_log.CreateRow(tblname, objref, kvs) ->
debug "Redoing create_row %s (%s)" tblname objref;
DB.create_row t tblname kvs objref
DB.create_row db_ref tblname kvs objref
| Redo_log.DeleteRow(tblname, objref) ->
debug "Redoing delete_row %s (%s)" tblname objref;
DB.delete_row t tblname objref
DB.delete_row db_ref tblname objref
| Redo_log.WriteField(tblname, objref, fldname, newval) ->
debug "Redoing write_field %s (%s) [%s -> %s]" tblname objref fldname newval;
DB.write_field t tblname objref fldname newval
DB.write_field db_ref tblname objref fldname newval
8 changes: 3 additions & 5 deletions ocaml/database/db_connections.ml
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,9 @@ let dec_and_read_db_flush_thread_refcount() =
)

let pre_exit_hook () =
if Redo_log.is_enabled() then begin
(* We're about to exit. Close the redo log. *)
Redo_log.shutdown();
R.debug "Closed redo log"
end
(* We're about to exit. Close the active redo logs. *)
Redo_log.with_active_redo_logs (Redo_log.shutdown);
R.debug "Closed all active redo logs."

(* The connection flushing calls each lock the connection they're flushing to.
The backend flush calls have to do enough locking (i.e. with the db_lock) to ensure that they
Expand Down
Loading