@@ -3490,28 +3490,29 @@ let vm_memory_target_wait printer rpc session_id params =
3490
3490
params []
3491
3491
)
3492
3492
3493
+ (* * This implements the key:file=/path/to/file.txt syntax. The value for
3494
+ key is the content of a file requested from the client *)
3495
+ let args_file fd ((k , v ) as p ) =
3496
+ match Astring.String. cut ~sep: " :" k with
3497
+ | Some (key , "file" ) -> (
3498
+ match get_client_file fd v with
3499
+ | Some s ->
3500
+ (key, s)
3501
+ | None ->
3502
+ marshal fd
3503
+ (Command (PrintStderr (Printf. sprintf " Failed to read file %s\n " v))) ;
3504
+ raise (ExitWithError 1 )
3505
+ )
3506
+ | _ ->
3507
+ p
3508
+
3493
3509
let vm_call_plugin fd printer rpc session_id params =
3494
3510
let vm_uuid = List. assoc " vm-uuid" params in
3495
3511
let vm = Client.VM. get_by_uuid ~rpc ~session_id ~uuid: vm_uuid in
3496
3512
let plugin = List. assoc " plugin" params in
3497
3513
let fn = List. assoc " fn" params in
3498
3514
let args = read_map_params " args" params in
3499
- (* Syntax interpretation: args:key:file=filename equals args:key=filename_content *)
3500
- let convert ((k , v ) as p ) =
3501
- match Astring.String. cut ~sep: " :" k with
3502
- | Some (key , "file" ) -> (
3503
- match get_client_file fd v with
3504
- | Some s ->
3505
- (key, s)
3506
- | None ->
3507
- marshal fd
3508
- (Command (PrintStderr (Printf. sprintf " Failed to read file %s\n " v))) ;
3509
- raise (ExitWithError 1 )
3510
- )
3511
- | _ ->
3512
- p
3513
- in
3514
- let args = List. map convert args in
3515
+ let args = List. map (args_file fd) args in
3515
3516
let result = Client.VM. call_plugin ~rpc ~session_id ~vm ~plugin ~fn ~args in
3516
3517
printer (Cli_printer. PList [result])
3517
3518
@@ -6907,12 +6908,13 @@ let host_set_hostname_live _printer rpc session_id params =
6907
6908
let hostname = List. assoc " host-name" params in
6908
6909
Client.Host. set_hostname_live ~rpc ~session_id ~host ~hostname
6909
6910
6910
- let host_call_plugin printer rpc session_id params =
6911
+ let host_call_plugin fd printer rpc session_id params =
6911
6912
let host_uuid = List. assoc " host-uuid" params in
6912
6913
let host = Client.Host. get_by_uuid ~rpc ~session_id ~uuid: host_uuid in
6913
6914
let plugin = List. assoc " plugin" params in
6914
6915
let fn = List. assoc " fn" params in
6915
6916
let args = read_map_params " args" params in
6917
+ let args = List. map (args_file fd) args in
6916
6918
let result =
6917
6919
Client.Host. call_plugin ~rpc ~session_id ~host ~plugin ~fn ~args
6918
6920
in
0 commit comments