Skip to content

Commit b08fd46

Browse files
committed
CA-194089: allow no-op VM.set_has_vendor_device
In Xapi_vm.assert_can_set_has_vendor_device, we were raising an exception if the PV drivers were in use. Now we do this check only if the new value of has_vendor_device is different to the old one. Signed-off-by: Thomas Sanders <[email protected]>
1 parent 73b2e95 commit b08fd46

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

ocaml/xapi/xapi_vm.ml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,12 +1088,16 @@ let assert_can_set_has_vendor_device ~__context ~self ~value =
10881088
then Pool_features.assert_enabled ~__context ~f:Features.PCI_device_for_auto_update;
10891089

10901090
Xapi_vm_lifecycle.assert_power_state_is ~__context ~self ~expected:`Halted;
1091-
let vm_gm = Db.VM.get_guest_metrics ~__context ~self in
1092-
let network_optimized = try Db.VM_guest_metrics.get_network_paths_optimized ~__context ~self:vm_gm with _ -> false in
1093-
let storage_optimized = try Db.VM_guest_metrics.get_storage_paths_optimized ~__context ~self:vm_gm with _ -> false in
1094-
if storage_optimized || network_optimized
1095-
then
1096-
raise (Api_errors.Server_error(Api_errors.vm_pv_drivers_in_use, [ Ref.string_of self ]))
1091+
1092+
let old_val = Db.VM.get_has_vendor_device ~__context ~self in
1093+
if old_val <> value then (
1094+
let vm_gm = Db.VM.get_guest_metrics ~__context ~self in
1095+
let network_optimized = try Db.VM_guest_metrics.get_network_paths_optimized ~__context ~self:vm_gm with _ -> false in
1096+
let storage_optimized = try Db.VM_guest_metrics.get_storage_paths_optimized ~__context ~self:vm_gm with _ -> false in
1097+
if storage_optimized || network_optimized
1098+
then
1099+
raise (Api_errors.Server_error(Api_errors.vm_pv_drivers_in_use, [ Ref.string_of self ]))
1100+
)
10971101

10981102
let set_has_vendor_device ~__context ~self ~value =
10991103
assert_can_set_has_vendor_device ~__context ~self ~value;

0 commit comments

Comments
 (0)