Skip to content

Commit 5d3f9af

Browse files
authored
Merge pull request xapi-project#3277 from gaborigloi/reduce_number_of_vm_allowed_op_checks
Revert "Factor out all_vm_operations"
2 parents cdda6dc + 5de8def commit 5d3f9af

File tree

2 files changed

+59
-52
lines changed

2 files changed

+59
-52
lines changed

ocaml/xapi/test_vm_check_operation_error.ml

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,54 @@
11

2+
let all_vm_operations =
3+
[ `assert_operation_valid
4+
; `awaiting_memory_live
5+
; `call_plugin
6+
; `changing_VCPUs
7+
; `changing_VCPUs_live
8+
; `changing_dynamic_range
9+
; `changing_memory_limits
10+
; `changing_memory_live
11+
; `changing_shadow_memory
12+
; `changing_shadow_memory_live
13+
; `changing_static_range
14+
; `checkpoint
15+
; `clean_reboot
16+
; `clean_shutdown
17+
; `clone
18+
; `copy
19+
; `create_template
20+
; `csvm
21+
; `data_source_op
22+
; `destroy
23+
; `export
24+
; `get_boot_record
25+
; `hard_reboot
26+
; `hard_shutdown
27+
; `import
28+
; `make_into_template
29+
; `metadata_export
30+
; `migrate_send
31+
; `pause
32+
; `pool_migrate
33+
; `power_state_reset
34+
; `provision
35+
; `query_services
36+
; `resume
37+
; `resume_on
38+
; `revert
39+
; `reverting
40+
; `send_sysrq
41+
; `send_trigger
42+
; `shutdown
43+
; `snapshot
44+
; `snapshot_with_quiesce
45+
; `start
46+
; `start_on
47+
; `suspend
48+
; `unpause
49+
; `update_allowed_operations
50+
]
51+
252
let with_test_vm f =
353
let __context = Mock.make_context_with_new_db "Mock context" in
454
let vm_ref = Test_common.make_vm ~__context () in
@@ -14,7 +64,7 @@ let test_null_vdi () =
1464
let () = ignore(Test_common.make_vbd ~__context ~vM:vm_ref ~_type:`CD ~mode:`RO ~empty:true ~vDI:Ref.null ()) in
1565
List.iter
1666
(fun op -> ignore(Xapi_vm_lifecycle.check_operation_error ~__context ~ref:vm_ref ~op ~strict:true))
17-
Xapi_vm_lifecycle.all_vm_operations
67+
all_vm_operations
1868
)
1969

2070
(* Operations that check the validity of other VM operations should

ocaml/xapi/xapi_vm_lifecycle.ml

Lines changed: 8 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -23,56 +23,6 @@ open D
2323

2424
module Rrdd = Rrd_client.Client
2525

26-
let all_vm_operations =
27-
[ `assert_operation_valid
28-
; `awaiting_memory_live
29-
; `call_plugin
30-
; `changing_VCPUs
31-
; `changing_VCPUs_live
32-
; `changing_dynamic_range
33-
; `changing_memory_limits
34-
; `changing_memory_live
35-
; `changing_shadow_memory
36-
; `changing_shadow_memory_live
37-
; `changing_static_range
38-
; `checkpoint
39-
; `clean_reboot
40-
; `clean_shutdown
41-
; `clone
42-
; `copy
43-
; `create_template
44-
; `csvm
45-
; `data_source_op
46-
; `destroy
47-
; `export
48-
; `get_boot_record
49-
; `hard_reboot
50-
; `hard_shutdown
51-
; `import
52-
; `make_into_template
53-
; `metadata_export
54-
; `migrate_send
55-
; `pause
56-
; `pool_migrate
57-
; `power_state_reset
58-
; `provision
59-
; `query_services
60-
; `resume
61-
; `resume_on
62-
; `revert
63-
; `reverting
64-
; `send_sysrq
65-
; `send_trigger
66-
; `shutdown
67-
; `snapshot
68-
; `snapshot_with_quiesce
69-
; `start
70-
; `start_on
71-
; `suspend
72-
; `unpause
73-
; `update_allowed_operations
74-
]
75-
7626
let assoc_opt key assocs = Opt.of_exception (fun () -> List.assoc key assocs)
7727
let bool_of_assoc key assocs = match assoc_opt key assocs with
7828
| Some v -> v = "1" || String.lowercase v = "true"
@@ -573,7 +523,14 @@ let update_allowed_operations ~__context ~self =
573523
| None -> op :: accu
574524
| _ -> accu
575525
in
576-
let allowed = List.fold_left check [] all_vm_operations in
526+
let allowed =
527+
List.fold_left check []
528+
[`snapshot; `copy; `clone; `revert; `checkpoint; `snapshot_with_quiesce;
529+
`start; `start_on; `pause; `unpause; `clean_shutdown; `clean_reboot;
530+
`hard_shutdown; `hard_reboot; `suspend; `resume; `resume_on; `export; `destroy;
531+
`provision; `changing_VCPUs_live; `pool_migrate; `migrate_send; `make_into_template; `changing_static_range;
532+
`changing_shadow_memory; `changing_dynamic_range]
533+
in
577534
(* FIXME: need to be able to deal with rolling-upgrade for orlando as well *)
578535
let allowed =
579536
if Helpers.rolling_upgrade_in_progress ~__context

0 commit comments

Comments
 (0)