Skip to content

Commit 9356a5b

Browse files
committed
CP-10203: XenAPI: api call for RDP on/off request
Update code to address the review comments. Signed-off-by: Hui Zhang <[email protected]>
1 parent 555dba8 commit 9356a5b

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

ocaml/xapi/xapi_vm.ml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,13 @@ let beg_rdp ~__context ~vm ~enabled =
718718
if is_feature_ts_on ~xs ~domid ~vm
719719
then
720720
let control_ts = if enabled then "1" else "0" in
721+
(*
721722
xs.Xenstore.Xs.write (control_path ~xs ~domid "ts") control_ts
723+
*)
724+
(*
725+
set_xenstore_data ~__context ~self:vm ~value:["control/ts",control_ts]
726+
*)
727+
Xapi_xenops.beg_rdp ~__context ~self:vm enabled
722728
else raise (Api_errors.Server_error (Api_errors.vm_lacks_feature_ts, [ Ref.string_of vm ])))
723729

724730
let beg_rdp_on ~__context ~vm =

ocaml/xapi/xapi_vm_lifecycle.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ let allowed_power_states ~__context ~vmr ~(op:API.vm_operations) =
6464
| `send_trigger
6565
| `snapshot_with_quiesce
6666
| `suspend
67+
| `beg_rdp_on
68+
| `beg_rdp_off
6769
-> [`Running]
6870
| `changing_dynamic_range
6971
-> [`Halted; `Running]
@@ -80,8 +82,6 @@ let allowed_power_states ~__context ~vmr ~(op:API.vm_operations) =
8082
| `get_boot_record
8183
| `shutdown
8284
| `hard_shutdown
83-
| `beg_rdp_on
84-
| `beg_rdp_off
8585
-> [`Paused; `Suspended; `Running]
8686
| `assert_operation_valid
8787
| `metadata_export

ocaml/xapi/xapi_xenops.ml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1882,6 +1882,19 @@ let unpause ~__context ~self =
18821882
check_power_state ~__context ~self ~expected:`Running
18831883
)
18841884

1885+
let beg_rdp ~__context ~self enabled =
1886+
let queue_name = queue_of_vm ~__context ~self in
1887+
transform_xenops_exn ~__context queue_name
1888+
(fun () ->
1889+
let id = id_of_vm ~__context ~self in
1890+
debug "xenops: VM.beg_rdp %s %b" id enabled;
1891+
let dbg = Context.string_of_task __context in
1892+
let module Client = (val make_client queue_name : XENOPS) in
1893+
Client.VM.beg_rdp dbg id enabled |> sync_with_task __context queue_name;
1894+
Events_from_xenopsd.wait queue_name dbg id ();
1895+
check_power_state ~__context ~self ~expected:`Running
1896+
)
1897+
18851898
let set_xenstore_data ~__context ~self xsdata =
18861899
let queue_name = queue_of_vm ~__context ~self in
18871900
transform_xenops_exn ~__context queue_name

0 commit comments

Comments
 (0)