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)
(cherry picked from commit 1af2e2c9de6920fb1ef9c83d9069cf9a573c5b8f)
---
generator/c.ml | 12 +++++++-----
generator/daemon.ml | 26 ++++++++++++++++----------
generator/xdr.ml | 11 +++++++----
3 files changed, 30 insertions(+), 19 deletions(-)
diff --git a/generator/c.ml b/generator/c.ml
index 143ce22..45dad8f 100644
--- a/generator/c.ml
+++ b/generator/c.ml
@@ -1305,7 +1305,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
);
@@ -1373,7 +1376,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"
@@ -1393,7 +1396,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;
@@ -1404,8 +1406,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 9362b3f..5b5504c 100644
--- a/generator/daemon.ml
+++ b/generator/daemon.ml
@@ -56,7 +56,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;
@@ -107,7 +111,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
@@ -120,12 +128,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";
@@ -175,7 +182,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;
@@ -231,12 +238,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"
);
@@ -341,7 +347,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 c59a30e..bbbfd8b 100644
--- a/generator/xdr.ml
+++ b/generator/xdr.ml
@@ -98,9 +98,13 @@ 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
+ 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;
@@ -115,8 +119,7 @@ let generate_xdr () =
| Int64 n -> pr " int64_t %s;\n" n
| BufferIn n ->
pr " opaque %s<>;\n" n
- | FileIn _ | FileOut _ -> ()
- | Pointer _ -> assert false
+ | FileIn _ | FileOut _ | Pointer _ -> assert false
) args;
pr "};\n\n"
);
--
1.8.3.1