Skip to content

Commit adf6ab2

Browse files
committed
CA-183752: Block VDI forget/destroy operation for rrd stats VDI
Signed-off-by: Sharad Yadav <[email protected]>
1 parent f043152 commit adf6ab2

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

ocaml/idl/api_errors.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ let vbd_cds_must_be_readonly = "VBD_CDS_MUST_BE_READONLY"
216216
let disk_vbd_must_be_readwrite_for_hvm = "DISK_VBD_MUST_BE_READWRITE_FOR_HVM"
217217
let host_cd_drive_empty = "HOST_CD_DRIVE_EMPTY"
218218
let vdi_not_available = "VDI_NOT_AVAILABLE"
219+
let vdi_has_rrds = "VDI_HAS_RRDS"
219220
let vdi_location_missing = "VDI_LOCATION_MISSING"
220221
let vdi_content_id_missing = "VDI_CONTENT_ID_MISSING"
221222
let vdi_missing = "VDI_MISSING"

ocaml/idl/datamodel.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,8 @@ let _ =
966966
~doc:"The operation could not proceed because necessary VDIs were already locked at the storage level." ();
967967
error Api_errors.vdi_readonly [ "vdi" ]
968968
~doc:"The operation required write access but this VDI is read-only" ();
969+
error Api_errors.vdi_has_rrds [ "vdi" ]
970+
~doc:"The operation cannot be performed because this VDI has rrd stats" ();
969971
error Api_errors.vdi_too_small [ "vdi"; "minimum size" ]
970972
~doc:"The VDI is too small. Please resize it to at least the minimum size." ();
971973
error Api_errors.vdi_not_sparse [ "vdi" ]

ocaml/xapi/xapi_vdi.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,17 @@ let check_operation_error ~__context ?(sr_records=[]) ?(pbd_records=[]) ?(vbd_re
128128
| `forget ->
129129
if ha_enabled && List.mem record.Db_actions.vDI_type [ `ha_statefile; `redo_log ]
130130
then Some (Api_errors.ha_is_enabled, [])
131+
else if List.mem record.Db_actions.vDI_type [ `rrd ]
132+
then Some (Api_errors.vdi_has_rrds, [_ref])
131133
else None
132134
| `destroy ->
133135
if sr_type = "udev"
134136
then Some (Api_errors.vdi_is_a_physical_device, [_ref])
135137
else
136138
if is_tools_sr
137139
then Some (Api_errors.sr_operation_not_supported, [Ref.string_of sr])
140+
else if List.mem record.Db_actions.vDI_type [ `rrd ]
141+
then Some (Api_errors.vdi_has_rrds, [_ref])
138142
else
139143
if ha_enabled && List.mem record.Db_actions.vDI_type [ `ha_statefile; `redo_log ]
140144
then Some (Api_errors.ha_is_enabled, [])

0 commit comments

Comments
 (0)