From: "Richard W.M. Jones" <rjones(a)redhat.com>
The FileIn/FileOut parameters are not passed through to the daemon.
Previously we generated incorrect RPC code (an empty 'struct
guestfs_<fn>_args') because we didn't account for these FileIn/FileOut
parameters correctly.
(cherry picked from commit e31c32ce1bc87d164103e79288effc64bb41181f)
---
generator/c.ml | 12 +++++++-----
generator/daemon.ml | 26 ++++++++++++++++----------
generator/xdr.ml | 47 +++++++++++++++++++++++++----------------------
3 files changed, 48 insertions(+), 37 deletions(-)
diff --git a/generator/c.ml b/generator/c.ml
index 646a173..451c28d 100644
--- a/generator/c.ml
+++ b/generator/c.ml
@@ -1317,7 +1317,10 @@ and generate_client_actions hash () =
handle_null_optargs optargs c_name;
- (match args with
+ let args_passed_to_daemon =
+ List.filter (function FileIn _ | FileOut _ -> false | _ -> true)
+ args in
+ (match args_passed_to_daemon with
| [] -> ()
| _ -> pr " struct guestfs_%s_args args;\n" name
);
@@ -1385,7 +1388,7 @@ and generate_client_actions hash () =
pr "\n";
(* Send the main header and arguments. *)
- if args = [] && optargs = [] then (
+ if args_passed_to_daemon = [] && optargs = [] then (
pr " serial = guestfs___send (g, GUESTFS_PROC_%s, progress_hint, 0,\n"
(String.uppercase name);
pr " NULL, NULL);\n"
@@ -1407,7 +1410,6 @@ and generate_client_actions hash () =
pr " args.%s = %s;\n" n n
| Int64 n ->
pr " args.%s = %s;\n" n n
- | FileIn _ | FileOut _ -> ()
| BufferIn n ->
pr " /* Just catch grossly large sizes. XDR encoding will make this
precise. */\n";
pr " if (%s_size >= GUESTFS_MESSAGE_MAX) {\n" n;
@@ -1418,8 +1420,8 @@ and generate_client_actions hash () =
pr " }\n";
pr " args.%s.%s_val = (char *) %s;\n" n n n;
pr " args.%s.%s_len = %s_size;\n" n n n
- | Pointer _ -> assert false
- ) args;
+ | FileIn _ | FileOut _ | Pointer _ -> assert false
+ ) args_passed_to_daemon;
List.iter (
fun argt ->
diff --git a/generator/daemon.ml b/generator/daemon.ml
index 704deb6..e68622b 100644
--- a/generator/daemon.ml
+++ b/generator/daemon.ml
@@ -57,7 +57,11 @@ let generate_daemon_actions_h () =
List.iter (
fun { name = name; style = ret, args, optargs } ->
- let style = ret, args @ args_of_optargs optargs, [] in
+ let args_passed_to_daemon = args @ args_of_optargs optargs in
+ let args_passed_to_daemon =
+ List.filter (function FileIn _ | FileOut _ -> false | _ -> true)
+ args_passed_to_daemon in
+ let style = ret, args_passed_to_daemon, [] in
generate_prototype
~single_line:true ~newline:true ~in_daemon:true ~prefix:"do_"
name style;
@@ -108,7 +112,11 @@ and generate_daemon_actions () =
pr " char *r;\n"
);
- if args <> [] || optargs <> [] then (
+ let args_passed_to_daemon = args @ args_of_optargs optargs in
+ let args_passed_to_daemon =
+ List.filter (function FileIn _ | FileOut _ -> false | _ -> true)
+ args_passed_to_daemon in
+ if args_passed_to_daemon <> [] then (
pr " struct guestfs_%s_args args;\n" name;
List.iter (
function
@@ -119,12 +127,11 @@ and generate_daemon_actions () =
| Bool n -> pr " int %s;\n" n
| Int n -> pr " int %s;\n" n
| Int64 n -> pr " int64_t %s;\n" n
- | FileIn _ | FileOut _ -> ()
| BufferIn n ->
pr " const char *%s;\n" n;
pr " size_t %s_size;\n" n
- | Pointer _ -> assert false
- ) (args @ args_of_optargs optargs)
+ | FileIn _ | FileOut _ | Pointer _ -> assert false
+ ) args_passed_to_daemon
);
pr "\n";
@@ -174,7 +181,7 @@ and generate_daemon_actions () =
pr "\n";
(* Decode arguments. *)
- if args <> [] || optargs <> [] then (
+ if args_passed_to_daemon <> [] then (
pr " memset (&args, 0, sizeof args);\n";
pr "\n";
pr " if (!xdr_guestfs_%s_args (xdr_in, &args)) {\n" name;
@@ -236,12 +243,11 @@ and generate_daemon_actions () =
| Bool n -> pr " %s = args.%s;\n" n n
| Int n -> pr " %s = args.%s;\n" n n
| Int64 n -> pr " %s = args.%s;\n" n n
- | FileIn _ | FileOut _ -> ()
| BufferIn n ->
pr " %s = args.%s.%s_val;\n" n n n;
pr " %s_size = args.%s.%s_len;\n" n n n
- | Pointer _ -> assert false
- ) (args @ args_of_optargs optargs);
+ | FileIn _ | FileOut _ | Pointer _ -> assert false
+ ) args_passed_to_daemon;
pr "\n"
);
@@ -346,7 +352,7 @@ and generate_daemon_actions () =
(* Free the args. *)
pr "done:\n";
- (match args with
+ (match args_passed_to_daemon with
| [] -> ()
| _ ->
pr " xdr_free ((xdrproc_t) xdr_guestfs_%s_args, (char *)
&args);\n"
diff --git a/generator/xdr.ml b/generator/xdr.ml
index 60e9dad..0d1b4e3 100644
--- a/generator/xdr.ml
+++ b/generator/xdr.ml
@@ -98,29 +98,32 @@ let generate_xdr () =
(* Ordinary arguments and optional arguments are concatenated
* together in the XDR args struct. The optargs_bitmask field
* in the header controls which optional arguments are
- * meaningful.
+ * meaningful. FileIn/FileOut parameters are ignored here.
*)
- (match args @ args_of_optargs optargs with
- | [] -> ()
- | args ->
- pr "struct %s_args {\n" name;
- List.iter (
- function
- | Pathname n | Device n | Mountable n | Dev_or_Path n
- | Mountable_or_Path n | String n
- | Key n ->
- pr " string %s<>;\n" n
- | OptString n -> pr " guestfs_str *%s;\n" n
- | StringList n | DeviceList n -> pr " guestfs_str
%s<>;\n" n
- | Bool n -> pr " bool %s;\n" n
- | Int n -> pr " int %s;\n" n
- | Int64 n -> pr " int64_t %s;\n" n
- | BufferIn n ->
- pr " opaque %s<>;\n" n
- | FileIn _ | FileOut _ -> ()
- | Pointer _ -> assert false
- ) args;
- pr "};\n\n"
+ let args_passed_to_daemon = args @ args_of_optargs optargs in
+ let args_passed_to_daemon =
+ List.filter (function FileIn _ | FileOut _ -> false | _ -> true)
+ args_passed_to_daemon in
+ (match args_passed_to_daemon with
+ | [] -> ()
+ | args ->
+ pr "struct %s_args {\n" name;
+ List.iter (
+ function
+ | Pathname n | Device n | Mountable n | Dev_or_Path n
+ | Mountable_or_Path n | String n
+ | Key n ->
+ pr " string %s<>;\n" n
+ | OptString n -> pr " guestfs_str *%s;\n" n
+ | StringList n | DeviceList n -> pr " guestfs_str %s<>;\n"
n
+ | Bool n -> pr " bool %s;\n" n
+ | Int n -> pr " int %s;\n" n
+ | Int64 n -> pr " int64_t %s;\n" n
+ | BufferIn n ->
+ pr " opaque %s<>;\n" n
+ | FileIn _ | FileOut _ | Pointer _ -> assert false
+ ) args;
+ pr "};\n\n"
);
(match ret with
| RErr -> ()
--
1.8.3.1