@@ -86,7 +86,10 @@ let check_operation_error ~__context ?sr_records:_ ?(pbd_records = [])
8686 let * () =
8787 if
8888 Helpers. rolling_upgrade_in_progress ~__context
89- && not (List. mem op Xapi_globs. rpu_allowed_vdi_operations)
89+ && not
90+ (Xapi_globs.Vdi_operations_set. mem op
91+ Xapi_globs. rpu_allowed_vdi_operations
92+ )
9093 then
9194 Error (Api_errors. not_supported_during_upgrade, [] )
9295 else
@@ -96,7 +99,7 @@ let check_operation_error ~__context ?sr_records:_ ?(pbd_records = [])
9699 (* Don't fail with other_operation_in_progress if VDI mirroring is in
97100 progress and destroy is called as part of VDI mirroring *)
98101 let is_vdi_mirroring_in_progress =
99- List. exists (fun (_ , op ) -> op = `mirror ) current_ops && op = `destroy
102+ op = `destroy && List. exists (fun (_ , op ) -> op = `mirror ) current_ops
100103 in
101104 if
102105 List. exists (fun (_ , op ) -> op <> `copy ) current_ops
@@ -130,7 +133,7 @@ let check_operation_error ~__context ?sr_records:_ ?(pbd_records = [])
130133 pbd_records
131134 in
132135 let * () =
133- if pbds_attached = [] && List. mem op [ `resize ] then
136+ if pbds_attached = [] && op = `resize then
134137 Error (Api_errors. sr_no_pbds, [Ref. string_of sr])
135138 else
136139 Ok ()
@@ -155,16 +158,14 @@ let check_operation_error ~__context ?sr_records:_ ?(pbd_records = [])
155158 )
156159 )
157160 | Some records ->
158- List. map snd
159- (List. filter
160- (fun (_ , vbd_record ) ->
161- vbd_record.Db_actions. vBD_VDI = _ref'
162- && (vbd_record.Db_actions. vBD_currently_attached
163- || vbd_record.Db_actions. vBD_reserved
164- )
165- )
166- records
161+ List. filter
162+ (fun vbd_record ->
163+ vbd_record.Db_actions. vBD_VDI = _ref'
164+ && (vbd_record.Db_actions. vBD_currently_attached
165+ || vbd_record.Db_actions. vBD_reserved
166+ )
167167 )
168+ records
168169 in
169170 let my_active_rw_vbd_records =
170171 List. filter (fun vbd -> vbd.Db_actions. vBD_mode = `RW ) my_active_vbd_records
@@ -183,14 +184,12 @@ let check_operation_error ~__context ?sr_records:_ ?(pbd_records = [])
183184 )
184185 )
185186 | Some records ->
186- List. map snd
187- (List. filter
188- (fun (_ , vbd_record ) ->
189- vbd_record.Db_actions. vBD_VDI = _ref'
190- && vbd_record.Db_actions. vBD_current_operations <> []
191- )
192- records
187+ List. filter
188+ (fun vbd_record ->
189+ vbd_record.Db_actions. vBD_VDI = _ref'
190+ && vbd_record.Db_actions. vBD_current_operations <> []
193191 )
192+ records
194193 in
195194 (* If the VBD is currently_attached then some operations can still be
196195 performed ie: VDI.clone (if the VM is suspended we have to have the
@@ -467,7 +466,7 @@ let update_allowed_operations_internal ~__context ~self ~sr_records ~pbd_records
467466 *)
468467 let all_ops =
469468 Xapi_globs. pre_ely_vdi_operations
470- |> List . filter (function
469+ |> Xapi_globs.Vdi_operations_set . filter (function
471470 | `blocked ->
472471 false (* CA-260245 *)
473472 | `force_unlock ->
@@ -477,25 +476,36 @@ let update_allowed_operations_internal ~__context ~self ~sr_records ~pbd_records
477476 )
478477 in
479478 let all = Db.VDI. get_record_internal ~__context ~self in
479+ let vbd_records =
480+ match vbd_records with
481+ | None when Pool_role. is_master () ->
482+ all.Db_actions. vDI_VBDs
483+ |> List. rev_map (fun self -> Db.VBD. get_record_internal ~__context ~self )
484+ |> Option. some
485+ | v ->
486+ v
487+ in
480488 let allowed =
481489 let check x =
482490 match
483491 check_operation_error ~__context ~sr_records ~pbd_records ?vbd_records
484492 ha_enabled all self x
485493 with
486494 | Ok () ->
487- [x]
495+ true
488496 | _ ->
489- []
497+ false
490498 in
491- List. fold_left ( fun accu op -> check op @ accu) [] all_ops
499+ all_ops |> Xapi_globs.Vdi_operations_set. filter check
492500 in
493501 let allowed =
494- if Helpers. rolling_upgrade_in_progress ~__context then
495- Xapi_stdext_std.Listext.List. intersect allowed
496- Xapi_globs. rpu_allowed_vdi_operations
497- else
498- allowed
502+ ( if Helpers. rolling_upgrade_in_progress ~__context then
503+ Xapi_globs.Vdi_operations_set. inter allowed
504+ Xapi_globs. rpu_allowed_vdi_operations
505+ else
506+ allowed
507+ )
508+ |> Xapi_globs.Vdi_operations_set. elements
499509 in
500510 Db.VDI. set_allowed_operations ~__context ~self ~value: allowed
501511
0 commit comments