@@ -3490,28 +3490,29 @@ let vm_memory_target_wait printer rpc session_id params =
34903490 params []
34913491 )
34923492
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+
34933509let vm_call_plugin fd printer rpc session_id params =
34943510 let vm_uuid = List. assoc " vm-uuid" params in
34953511 let vm = Client.VM. get_by_uuid ~rpc ~session_id ~uuid: vm_uuid in
34963512 let plugin = List. assoc " plugin" params in
34973513 let fn = List. assoc " fn" params in
34983514 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
35153516 let result = Client.VM. call_plugin ~rpc ~session_id ~vm ~plugin ~fn ~args in
35163517 printer (Cli_printer. PList [result])
35173518
@@ -6907,12 +6908,13 @@ let host_set_hostname_live _printer rpc session_id params =
69076908 let hostname = List. assoc " host-name" params in
69086909 Client.Host. set_hostname_live ~rpc ~session_id ~host ~hostname
69096910
6910- let host_call_plugin printer rpc session_id params =
6911+ let host_call_plugin fd printer rpc session_id params =
69116912 let host_uuid = List. assoc " host-uuid" params in
69126913 let host = Client.Host. get_by_uuid ~rpc ~session_id ~uuid: host_uuid in
69136914 let plugin = List. assoc " plugin" params in
69146915 let fn = List. assoc " fn" params in
69156916 let args = read_map_params " args" params in
6917+ let args = List. map (args_file fd) args in
69166918 let result =
69176919 Client.Host. call_plugin ~rpc ~session_id ~host ~plugin ~fn ~args
69186920 in
0 commit comments