Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions ocaml/client_records/record_util.ml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ let vdi_operation_to_string = function
| `destroy -> "destroy"
| `force_unlock -> "force_unlock"
| `snapshot -> "snapshot"
| `mirror -> "mirror"
| `forget -> "forget"
| `update -> "update"
| `generate_config -> "generate_config"
Expand All @@ -124,6 +125,7 @@ let sr_operation_to_string = function
| `vdi_resize -> "VDI.resize"
| `vdi_clone -> "VDI.clone"
| `vdi_snapshot -> "VDI.snapshot"
| `vdi_mirror -> "VDI.mirror"
| `pbd_create -> "PBD.create"
| `pbd_destroy -> "PBD.destroy"

Expand Down
2 changes: 2 additions & 0 deletions ocaml/idl/datamodel.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5541,6 +5541,7 @@ let storage_operations =
"vdi_resize", "Resizing a VDI";
"vdi_clone", "Cloneing a VDI";
"vdi_snapshot", "Snapshotting a VDI";
"vdi_mirror", "Mirroring a VDI";
"pbd_create", "Creating a PBD for this SR";
"pbd_destroy", "Destroying one of this SR's PBDs"; ])

Expand Down Expand Up @@ -5850,6 +5851,7 @@ let vdi_operations =
"resize", "Resizing the VDI";
"resize_online", "Resizing the VDI which may or may not be online";
"snapshot", "Snapshotting the VDI";
"mirror", "Mirroring the VDI";
"destroy", "Destroying the VDI";
"forget", "Forget about the VDI";
"update", "Refreshing the fields of the VDI";
Expand Down
6 changes: 4 additions & 2 deletions ocaml/xapi/message_forwarding.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3434,8 +3434,10 @@ module Forward = functor(Local: Custom_actions.CUSTOM_ACTIONS) -> struct
(snapshot, host) in
VM.reserve_memory_for_vm ~__context ~vm:vm ~host ~snapshot ~host_op:`vm_migrate
(fun () ->
do_op_on ~local_fn ~__context ~host
(fun session_id rpc -> Client.VDI.pool_migrate ~rpc ~session_id ~vdi ~sr ~options)))
with_sr_andor_vdi ~__context ~vdi:(vdi, `mirror) ~doc:"VDI.mirror"
(fun () ->
do_op_on ~local_fn ~__context ~host
(fun session_id rpc -> Client.VDI.pool_migrate ~rpc ~session_id ~vdi ~sr ~options))))

let resize ~__context ~vdi ~size =
info "VDI.resize: VDI = '%s'; size = %Ld" (vdi_uuid ~__context vdi) size;
Expand Down
3 changes: 2 additions & 1 deletion ocaml/xapi/smint.ml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type capability =
| Sr_stats
| Sr_metadata
| Sr_trim
| Vdi_create | Vdi_delete | Vdi_attach | Vdi_detach
| Vdi_create | Vdi_delete | Vdi_attach | Vdi_detach | Vdi_mirror
| Vdi_clone | Vdi_snapshot | Vdi_resize | Vdi_activate | Vdi_deactivate
| Vdi_update | Vdi_introduce
| Vdi_resize_online
Expand Down Expand Up @@ -69,6 +69,7 @@ let string_to_capability_table = [
"VDI_DELETE", Vdi_delete;
"VDI_ATTACH", Vdi_attach;
"VDI_DETACH", Vdi_detach;
"VDI_MIRROR", Vdi_mirror;
"VDI_RESIZE", Vdi_resize;
"VDI_RESIZE_ONLINE",Vdi_resize_online;
"VDI_CLONE", Vdi_clone;
Expand Down
3 changes: 2 additions & 1 deletion ocaml/xapi/xapi_sr_operations.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@ open D
open Record_util

let all_ops : API.storage_operations_set =
[ `scan; `destroy; `forget; `plug; `unplug; `vdi_create; `vdi_destroy; `vdi_resize; `vdi_clone; `vdi_snapshot;
[ `scan; `destroy; `forget; `plug; `unplug; `vdi_create; `vdi_destroy; `vdi_resize; `vdi_clone; `vdi_snapshot; `vdi_mirror;
`vdi_introduce; `update; `pbd_create; `pbd_destroy ]

let sm_cap_table =
[ `vdi_create, Smint.Vdi_create;
`vdi_destroy, Smint.Vdi_delete;
`vdi_resize, Smint.Vdi_resize;
`vdi_introduce, Smint.Vdi_introduce;
`vdi_mirror, Smint.Vdi_mirror;
`update, Smint.Sr_update;
(* We fake clone ourselves *)
`vdi_snapshot, Smint.Vdi_snapshot ]
Expand Down
14 changes: 11 additions & 3 deletions ocaml/xapi/xapi_vdi.ml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ let check_operation_error ~__context ?(sr_records=[]) ?(pbd_records=[]) ?(vbd_re

(* Policy:
1. any current_operation besides copy implies exclusivity; fail everything
else
else; except vdi mirroring is in current operations and destroy is performed
as part of vdi_pool_migrate.
2. if a copy is ongoing, don't fail with other_operation_in_progress, as
blocked operations could then get stuck behind a long-running copy.
Instead, rely on the blocked_by_attach check further down to decide
Expand All @@ -44,7 +45,10 @@ let check_operation_error ~__context ?(sr_records=[]) ?(pbd_records=[]) ?(vbd_re
has a current_operation itself
5. HA prevents you from deleting statefiles or metadata volumes
*)
if List.exists (fun (_, op) -> op <> `copy) current_ops
(* Don't fail with other_operation_in_progress if VDI mirroring is in progress
* and destroy is called as part of VDI mirroring *)
let is_vdi_mirroring_in_progress = (List.exists (fun (_, op) -> op = `mirror) current_ops) && (op = `destroy) in
if (List.exists (fun (_, op) -> op <> `copy) current_ops) && not is_vdi_mirroring_in_progress
then Some(Api_errors.other_operation_in_progress,["VDI"; _ref])
else
(* check to see whether it's a local cd drive *)
Expand Down Expand Up @@ -96,7 +100,7 @@ let check_operation_error ~__context ?(sr_records=[]) ?(pbd_records=[]) ?(vbd_re
VDI.clone (if the VM is suspended we have to have the 'allow_clone_suspended_vm'' flag)
VDI.snapshot; VDI.resize_online; 'blocked' (CP-831) *)
let operation_can_be_performed_live = match op with
| `snapshot | `resize_online | `blocked | `clone -> true
| `snapshot | `resize_online | `blocked | `clone | `mirror -> true
| _ -> false in

let operation_can_be_performed_with_ro_attach =
Expand Down Expand Up @@ -188,6 +192,10 @@ let check_operation_error ~__context ?(sr_records=[]) ?(pbd_records=[]) ?(vbd_re
if not Smint.(has_capability Vdi_clone sm_features)
then Some (Api_errors.sr_operation_not_supported, [Ref.string_of sr])
else None
| `mirror ->
if not Smint.(has_capability Vdi_mirror sm_features)
then Some (Api_errors.sr_operation_not_supported, [Ref.string_of sr])
else None
| _ -> None
)

Expand Down