Skip to content

Commit c4ccc56

Browse files
committed
CA-217842: Replace instances of vm_lacks_feature_x with vm_lacks_feature
Rationale: This leads to less confusion when, for example, attempting to migrate a VM leads to an error that the VM does not support suspend. The lacking feature is currently always better defined by context than by the error text itself, so let's make the error generic and rely on the context to signify which feature is lacking. Also, given that the shutdown/reboot features might be advertised by either feature_poweroff,feature_reboot or feature_shutdown, this makes the error raised less wrong. Signed-off-by: Jon Ludlam <jonathan.ludlam@citrix.com>
1 parent 023809d commit c4ccc56

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

ocaml/idl/api_errors.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ let vm_migrate_failed = "VM_MIGRATE_FAILED"
178178
let vm_missing_pv_drivers = "VM_MISSING_PV_DRIVERS"
179179
let vm_failed_shutdown_ack = "VM_FAILED_SHUTDOWN_ACKNOWLEDGMENT"
180180
let vm_old_pv_drivers = "VM_OLD_PV_DRIVERS"
181+
let vm_lacks_feature = "VM_LACKS_FEATURE"
181182
let vm_lacks_feature_shutdown = "VM_LACKS_FEATURE_SHUTDOWN"
182183
let vm_lacks_feature_suspend = "VM_LACKS_FEATURE_SUSPEND"
183184
let vm_lacks_feature_vcpu_hotplug = "VM_LACKS_FEATURE_VCPU_HOTPLUG"

ocaml/idl/datamodel.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,8 @@ let _ =
677677
~doc:"You attempted an operation which needs the VM cooperative suspend feature on a VM which lacks it." ();
678678
error Api_errors.vm_lacks_feature_static_ip_setting [ "vm" ]
679679
~doc:"You attempted an operation which needs the VM static-ip-setting feature on a VM which lacks it." ();
680+
error Api_errors.vm_lacks_feature [ "vm" ]
681+
~doc:"You attempted an operation on a VM which lacks the feature." ();
680682
error Api_errors.vm_is_template ["vm"]
681683
~doc:"The operation attempted is not valid for a template VM" ();
682684
error Api_errors.other_operation_in_progress ["class"; "object"]

ocaml/xapi/xapi_vif.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ let assert_has_feature_static_ip_setting ~__context ~self =
145145
if List.assoc feature other <> "1" then
146146
failwith "not found"
147147
with _ ->
148-
raise Api_errors.(Server_error (vm_lacks_feature_static_ip_setting, [Ref.string_of vm]))
148+
raise Api_errors.(Server_error (vm_lacks_feature, [Ref.string_of vm]))
149149

150150
let assert_no_locking_mode_conflict ~__context ~self kind address =
151151
let vif_locking_mode = Db.VIF.get_locking_mode ~__context ~self in

ocaml/xapi/xapi_vm_lifecycle.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,16 @@ let check_op_for_feature ~__context ~vmr ~vmgmr ~power_state ~op ~ref ~strict =
166166
match op with
167167
| `clean_shutdown
168168
when strict && lack_feature "feature-shutdown" && lack_feature "feature-poweroff"
169-
-> some_err Api_errors.vm_lacks_feature_shutdown
169+
-> some_err Api_errors.vm_lacks_feature
170170
| `clean_reboot
171171
when strict && lack_feature "feature-shutdown" && lack_feature "feature-reboot"
172-
-> some_err Api_errors.vm_lacks_feature_shutdown
172+
-> some_err Api_errors.vm_lacks_feature
173173
| `changing_VCPUs_live
174174
when lack_feature "feature-vcpu-hotplug"
175-
-> some_err Api_errors.vm_lacks_feature_vcpu_hotplug
175+
-> some_err Api_errors.vm_lacks_feature
176176
| `suspend | `checkpoint | `pool_migrate | `migrate_send
177177
when strict && lack_feature "feature-suspend"
178-
-> some_err Api_errors.vm_lacks_feature_suspend
178+
-> some_err Api_errors.vm_lacks_feature
179179
| _ -> None
180180
(* N.B. In the pattern matching above, "pat1 | pat2 | pat3" counts as
181181
* one pattern, and the whole thing can be guarded by a "when" clause. *)

0 commit comments

Comments
 (0)