[PATCH 01/12] generator: Add new Mountable argument type
by Matthew Booth
This type is initially identical to Device.
---
generator/bindtests.ml | 2 +-
generator/c.ml | 7 +++++--
generator/csharp.ml | 6 ++++--
generator/daemon.ml | 4 ++--
generator/erlang.ml | 6 +++---
generator/fish.ml | 8 ++++----
generator/gobject.ml | 11 ++++++-----
generator/haskell.ml | 11 +++++++----
generator/java.ml | 10 +++++-----
generator/lua.ml | 6 +++---
generator/ocaml.ml | 10 +++++-----
generator/perl.ml | 9 +++++----
generator/php.ml | 10 +++++-----
generator/python.ml | 12 ++++++------
generator/ruby.ml | 4 ++--
generator/tests_c_api.ml | 3 ++-
generator/types.ml | 1 +
generator/utils.ml | 2 +-
generator/xdr.ml | 3 ++-
19 files changed, 69 insertions(+), 56 deletions(-)
diff --git a/generator/bindtests.ml b/generator/bindtests.ml
index 55c39cb..0ca5af9 100644
--- a/generator/bindtests.ml
+++ b/generator/bindtests.ml
@@ -127,7 +127,7 @@ print_strings (guestfs_h *g, char *const *argv)
List.iter (
function
| Pathname n
- | Device n | Dev_or_Path n
+ | Device n | Mountable n | Dev_or_Path n
| String n
| FileIn n
| FileOut n
diff --git a/generator/c.ml b/generator/c.ml
index 518ac1b..afa81ed 100644
--- a/generator/c.ml
+++ b/generator/c.ml
@@ -121,7 +121,7 @@ let rec generate_prototype ?(extern = true) ?(static = false)
List.iter (
function
| Pathname n
- | Device n | Dev_or_Path n
+ | Device n | Mountable n | Dev_or_Path n
| String n
| OptString n
| Key n ->
@@ -852,6 +852,7 @@ and generate_client_actions hash () =
(* parameters which should not be NULL *)
| String n
| Device n
+ | Mountable n
| Pathname n
| Dev_or_Path n
| FileIn n
@@ -969,6 +970,7 @@ and generate_client_actions hash () =
function
| String n (* strings *)
| Device n
+ | Mountable n
| Pathname n
| Dev_or_Path n
| FileIn n
@@ -1284,7 +1286,8 @@ and generate_client_actions hash () =
) else (
List.iter (
function
- | Pathname n | Device n | Dev_or_Path n | String n | Key n ->
+ | Pathname n | Device n | Mountable n | Dev_or_Path n | String n
+ | Key n ->
pr " args.%s = (char *) %s;\n" n n
| OptString n ->
pr " args.%s = %s ? (char **) &%s : NULL;\n" n n n
diff --git a/generator/csharp.ml b/generator/csharp.ml
index de54e62..e2fcb42 100644
--- a/generator/csharp.ml
+++ b/generator/csharp.ml
@@ -187,7 +187,8 @@ namespace Guestfs
(c_return_type ()) c_function;
List.iter (
function
- | Pathname n | Device n | Dev_or_Path n | String n | OptString n
+ | Pathname n | Device n | Mountable n | Dev_or_Path n | String n
+ | OptString n
| FileIn n | FileOut n
| Key n
| BufferIn n ->
@@ -213,7 +214,8 @@ namespace Guestfs
in
List.iter (
function
- | Pathname n | Device n | Dev_or_Path n | String n | OptString n
+ | Pathname n | Device n | Mountable n | Dev_or_Path n | String n
+ | OptString n
| FileIn n | FileOut n
| Key n
| BufferIn n ->
diff --git a/generator/daemon.ml b/generator/daemon.ml
index 9362b3f..a075bdc 100644
--- a/generator/daemon.ml
+++ b/generator/daemon.ml
@@ -111,7 +111,7 @@ and generate_daemon_actions () =
pr " struct guestfs_%s_args args;\n" name;
List.iter (
function
- | Device n | Dev_or_Path n
+ | Device n | Mountable n | Dev_or_Path n
| Pathname n
| String n
| Key n
@@ -205,7 +205,7 @@ and generate_daemon_actions () =
pr_args n;
pr " ABS_PATH (%s, %s, goto done);\n"
n (if is_filein then "cancel_receive ()" else "");
- | Device n ->
+ | Device n | Mountable n ->
pr_args n;
pr " RESOLVE_DEVICE (%s, %s, goto done);\n"
n (if is_filein then "cancel_receive ()" else "");
diff --git a/generator/erlang.ml b/generator/erlang.ml
index 357335b..004aee4 100644
--- a/generator/erlang.ml
+++ b/generator/erlang.ml
@@ -293,7 +293,7 @@ extern void free_strings (char **r);
fun i ->
function
| Pathname n
- | Device n | Dev_or_Path n
+ | Device n | Mountable n | Dev_or_Path n
| String n
| FileIn n
| FileOut n
@@ -386,8 +386,8 @@ extern void free_strings (char **r);
(* Free strings if we copied them above. *)
List.iter (
function
- | Pathname n | Device n | Dev_or_Path n | String n | OptString n
- | FileIn n | FileOut n | Key n ->
+ | Pathname n | Device n | Mountable n | Dev_or_Path n | String n
+ | OptString n | FileIn n | FileOut n | Key n ->
pr " free (%s);\n" n
| StringList n | DeviceList n ->
pr " free_strings (%s);\n" n;
diff --git a/generator/fish.ml b/generator/fish.ml
index b93f4fc..eacca37 100644
--- a/generator/fish.ml
+++ b/generator/fish.ml
@@ -324,7 +324,7 @@ Guestfish will prompt for these separately."
);
List.iter (
function
- | Device n
+ | Device n | Mountable n
| String n
| OptString n -> pr " const char *%s;\n" n
| Pathname n
@@ -407,7 +407,7 @@ Guestfish will prompt for these separately."
List.iter (
function
- | Device name
+ | Device name | Mountable name
| String name ->
pr " %s = argv[i++];\n" name
| Pathname name
@@ -619,7 +619,7 @@ Guestfish will prompt for these separately."
) (List.rev optargs);
List.iter (
function
- | Device _ | String _
+ | Device _ | Mountable _ | String _
| OptString _
| BufferIn _ -> ()
| Bool name
@@ -852,7 +852,7 @@ and generate_fish_actions_pod () =
pr " %s" name;
List.iter (
function
- | Pathname n | Device n | Dev_or_Path n | String n ->
+ | Pathname n | Device n | Mountable n | Dev_or_Path n | String n ->
pr " %s" n
| OptString n -> pr " %s" n
| StringList n | DeviceList n -> pr " '%s ...'" n
diff --git a/generator/gobject.ml b/generator/gobject.ml
index 9b18de1..5a36bfc 100644
--- a/generator/gobject.ml
+++ b/generator/gobject.ml
@@ -75,7 +75,7 @@ let generate_gobject_proto name ?(single_line = true)
| Int64 n->
pr "gint64 %s" n
| String n
- | Device n
+ | Device n | Mountable n
| Pathname n
| Dev_or_Path n
| OptString n
@@ -1033,7 +1033,8 @@ guestfs_session_close(GuestfsSession *session, GError **err)
pr " (transfer none) (type utf8):"
| OptString _ ->
pr " (transfer none) (type utf8) (allow-none):"
- | Device _ | Pathname _ | Dev_or_Path _ | FileIn _ | FileOut _ ->
+ | Device _ | Mountable _ | Pathname _ | Dev_or_Path _
+ | FileIn _ | FileOut _ ->
pr " (transfer none) (type filename):"
| StringList _ ->
pr " (transfer none) (array zero-terminated=1) (element-type utf8): an array of strings"
@@ -1183,9 +1184,9 @@ guestfs_session_close(GuestfsSession *session, GError **err)
match argt with
| BufferIn n ->
pr "%s, %s_size" n n
- | Bool n | Int n | Int64 n | String n | Device n | Pathname n
- | Dev_or_Path n | OptString n | StringList n | DeviceList n
- | Key n | FileIn n | FileOut n ->
+ | Bool n | Int n | Int64 n | String n | Device n | Mountable n
+ | Pathname n | Dev_or_Path n | OptString n | StringList n
+ | DeviceList n | Key n | FileIn n | FileOut n ->
pr "%s" n
| Pointer _ ->
failwith "gobject bindings do not support Pointer arguments"
diff --git a/generator/haskell.ml b/generator/haskell.ml
index dc19259..2033dbf 100644
--- a/generator/haskell.ml
+++ b/generator/haskell.ml
@@ -140,7 +140,8 @@ assocListOfHashtable (a:b:rest) = (a,b) : assocListOfHashtable rest
function
| FileIn n
| FileOut n
- | Pathname n | Device n | Dev_or_Path n | String n | Key n ->
+ | Pathname n | Device n | Mountable n | Dev_or_Path n | String n
+ | Key n ->
pr "withCString %s $ \\%s -> " n n
| BufferIn n ->
pr "withCStringLen %s $ \\(%s, %s_size) -> " n n n
@@ -156,7 +157,7 @@ assocListOfHashtable (a:b:rest) = (a,b) : assocListOfHashtable rest
| Int n -> sprintf "(fromIntegral %s)" n
| Int64 n | Pointer (_, n) -> sprintf "(fromIntegral %s)" n
| FileIn n | FileOut n
- | Pathname n | Device n | Dev_or_Path n
+ | Pathname n | Device n | Mountable n | Dev_or_Path n
| String n | OptString n
| StringList n | DeviceList n
| Key n -> n
@@ -213,7 +214,8 @@ and generate_haskell_prototype ~handle ?(hs = false) (ret, args, optargs) =
List.iter (
fun arg ->
(match arg with
- | Pathname _ | Device _ | Dev_or_Path _ | String _ | Key _ ->
+ | Pathname _ | Device _ | Mountable _ | Dev_or_Path _ | String _
+ | Key _ ->
pr "CString"
| BufferIn _ ->
pr "CString -> CInt"
@@ -254,7 +256,8 @@ and generate_haskell_prototype ~handle ?(hs = false) (ret, args, optargs) =
List.iter (
fun arg ->
(match arg with
- | Pathname _ | Device _ | Dev_or_Path _ | String _ | Key _ ->
+ | Pathname _ | Device _ | Mountable _ | Dev_or_Path _ | String _
+ | Key _ ->
pr "String"
| BufferIn _ ->
pr "String"
diff --git a/generator/java.ml b/generator/java.ml
index 75732e8..ad53ba3 100644
--- a/generator/java.ml
+++ b/generator/java.ml
@@ -463,7 +463,7 @@ and generate_java_prototype ?(public=false) ?(privat=false) ?(native=false)
match arg with
| Pathname n
- | Device n | Dev_or_Path n
+ | Device n | Mountable n | Dev_or_Path n
| String n
| OptString n
| FileIn n
@@ -798,7 +798,7 @@ get_all_event_callbacks (guestfs_h *g, size_t *len_rtn)
List.iter (
function
| Pathname n
- | Device n | Dev_or_Path n
+ | Device n | Mountable n | Dev_or_Path n
| String n
| OptString n
| FileIn n
@@ -867,7 +867,7 @@ get_all_event_callbacks (guestfs_h *g, size_t *len_rtn)
List.iter (
function
| Pathname n
- | Device n | Dev_or_Path n
+ | Device n | Mountable n | Dev_or_Path n
| String n
| OptString n
| FileIn n
@@ -924,7 +924,7 @@ get_all_event_callbacks (guestfs_h *g, size_t *len_rtn)
List.iter (
function
| Pathname n
- | Device n | Dev_or_Path n
+ | Device n | Mountable n | Dev_or_Path n
| String n
| FileIn n
| FileOut n
@@ -991,7 +991,7 @@ get_all_event_callbacks (guestfs_h *g, size_t *len_rtn)
List.iter (
function
| Pathname n
- | Device n | Dev_or_Path n
+ | Device n | Mountable n | Dev_or_Path n
| String n
| FileIn n
| FileOut n
diff --git a/generator/lua.ml b/generator/lua.ml
index 691b966..04a3941 100644
--- a/generator/lua.ml
+++ b/generator/lua.ml
@@ -470,7 +470,7 @@ guestfs_lua_delete_event_callback (lua_State *L)
List.iter (
function
- | Pathname n | Device n | Dev_or_Path n | String n
+ | Pathname n | Device n | Mountable n | Dev_or_Path n | String n
| FileIn n | FileOut n | Key n ->
pr " const char *%s;\n" n
| BufferIn n ->
@@ -500,7 +500,7 @@ guestfs_lua_delete_event_callback (lua_State *L)
fun i ->
let i = i+2 in (* Lua indexes from 1(!), plus the handle. *)
function
- | Pathname n | Device n | Dev_or_Path n | String n
+ | Pathname n | Device n | Mountable n | Dev_or_Path n | String n
| FileIn n | FileOut n | Key n ->
pr " %s = luaL_checkstring (L, %d);\n" n i
| BufferIn n ->
@@ -560,7 +560,7 @@ guestfs_lua_delete_event_callback (lua_State *L)
(* Free temporary data. *)
List.iter (
function
- | Pathname _ | Device _ | Dev_or_Path _ | String _
+ | Pathname _ | Device _ | Mountable _ | Dev_or_Path _ | String _
| FileIn _ | FileOut _ | Key _
| BufferIn _ | OptString _
| Bool _ | Int _ | Int64 _
diff --git a/generator/ocaml.ml b/generator/ocaml.ml
index 80ab596..6302298 100644
--- a/generator/ocaml.ml
+++ b/generator/ocaml.ml
@@ -497,7 +497,7 @@ copy_table (char * const * argv)
List.iter (
function
| Pathname n
- | Device n | Dev_or_Path n
+ | Device n | Mountable n | Dev_or_Path n
| String n
| FileIn n
| FileOut n
@@ -583,8 +583,8 @@ copy_table (char * const * argv)
(* Free strings if we copied them above. *)
List.iter (
function
- | Pathname n | Device n | Dev_or_Path n | String n | OptString n
- | FileIn n | FileOut n | BufferIn n | Key n ->
+ | Pathname n | Device n | Mountable n | Dev_or_Path n | String n
+ | OptString n | FileIn n | FileOut n | BufferIn n | Key n ->
pr " free (%s);\n" n
| StringList n | DeviceList n ->
pr " ocaml_guestfs_free_strings (%s);\n" n;
@@ -712,8 +712,8 @@ and generate_ocaml_function_type ?(extra_unit = false) (ret, args, optargs) =
) optargs;
List.iter (
function
- | Pathname _ | Device _ | Dev_or_Path _ | String _ | FileIn _ | FileOut _
- | BufferIn _ | Key _ -> pr "string -> "
+ | Pathname _ | Device _ | Mountable _ | Dev_or_Path _ | String _
+ | FileIn _ | FileOut _ | BufferIn _ | Key _ -> pr "string -> "
| OptString _ -> pr "string option -> "
| StringList _ | DeviceList _ -> pr "string array -> "
| Bool _ -> pr "bool -> "
diff --git a/generator/perl.ml b/generator/perl.ml
index db11cb6..3b4108a 100644
--- a/generator/perl.ml
+++ b/generator/perl.ml
@@ -342,7 +342,7 @@ user_cancel (g)
iteri (
fun i ->
function
- | Pathname n | Device n | Dev_or_Path n | String n
+ | Pathname n | Device n | Mountable n | Dev_or_Path n | String n
| FileIn n | FileOut n | Key n ->
pr " char *%s;\n" n
| BufferIn n ->
@@ -491,8 +491,8 @@ user_cancel (g)
(* Cleanup any arguments. *)
List.iter (
function
- | Pathname _ | Device _ | Dev_or_Path _ | String _ | OptString _
- | Bool _ | Int _ | Int64 _
+ | Pathname _ | Device _ | Mountable _ | Dev_or_Path _ | String _
+ | OptString _ | Bool _ | Int _ | Int64 _
| FileIn _ | FileOut _
| BufferIn _ | Key _ | Pointer _ -> ()
| StringList n | DeviceList n -> pr " free (%s);\n" n
@@ -920,6 +920,7 @@ handlers and threads.
let pr_type i = function
| Pathname n -> pr "[ '%s', 'string(path)', %d ]" n i
| Device n -> pr "[ '%s', 'string(device)', %d ]" n i
+ | Mountable n -> pr "[ '%s', 'string(mountable)', %d ]" n i
| Dev_or_Path n -> pr "[ '%s', 'string(dev_or_path)', %d ]" n i
| String n -> pr "[ '%s', 'string', %d ]" n i
| FileIn n -> pr "[ '%s', 'string(filename)', %d ]" n i
@@ -1092,7 +1093,7 @@ and generate_perl_prototype name (ret, args, optargs) =
if !comma then pr ", ";
comma := true;
match arg with
- | Pathname n | Device n | Dev_or_Path n | String n
+ | Pathname n | Device n | Mountable n | Dev_or_Path n | String n
| OptString n | Bool n | Int n | Int64 n | FileIn n | FileOut n
| BufferIn n | Key n | Pointer (_, n) ->
pr "$%s" n
diff --git a/generator/php.ml b/generator/php.ml
index 6618ce5..cf23863 100644
--- a/generator/php.ml
+++ b/generator/php.ml
@@ -188,7 +188,7 @@ PHP_FUNCTION (guestfs_last_error)
List.iter (
function
- | String n | Device n | Pathname n | Dev_or_Path n
+ | String n | Device n | Mountable n | Pathname n | Dev_or_Path n
| FileIn n | FileOut n | Key n
| OptString n
| BufferIn n ->
@@ -232,7 +232,7 @@ PHP_FUNCTION (guestfs_last_error)
let param_string = String.concat "" (
List.map (
function
- | String n | Device n | Pathname n | Dev_or_Path n
+ | String n | Device n | Mountable n | Pathname n | Dev_or_Path n
| FileIn n | FileOut n | BufferIn n | Key n -> "s"
| OptString n -> "s!"
| StringList n | DeviceList n -> "a"
@@ -260,7 +260,7 @@ PHP_FUNCTION (guestfs_last_error)
pr " &z_g";
List.iter (
function
- | String n | Device n | Pathname n | Dev_or_Path n
+ | String n | Device n | Mountable n | Pathname n | Dev_or_Path n
| FileIn n | FileOut n | BufferIn n | Key n
| OptString n ->
pr ", &%s, &%s_size" n n
@@ -293,7 +293,7 @@ PHP_FUNCTION (guestfs_last_error)
List.iter (
function
- | String n | Device n | Pathname n | Dev_or_Path n
+ | String n | Device n | Mountable n | Pathname n | Dev_or_Path n
| FileIn n | FileOut n | Key n
| OptString n ->
(* Just need to check the string doesn't contain any ASCII
@@ -420,7 +420,7 @@ PHP_FUNCTION (guestfs_last_error)
(* Free up parameters. *)
List.iter (
function
- | String n | Device n | Pathname n | Dev_or_Path n
+ | String n | Device n | Mountable n | Pathname n | Dev_or_Path n
| FileIn n | FileOut n | Key n
| OptString n -> ()
| BufferIn n -> ()
diff --git a/generator/python.ml b/generator/python.ml
index 9bff5b9..cff3049 100644
--- a/generator/python.ml
+++ b/generator/python.ml
@@ -289,7 +289,7 @@ free_strings (char **argv)
List.iter (
function
- | Pathname n | Device n | Dev_or_Path n | String n | Key n
+ | Pathname n | Device n | Mountable n | Dev_or_Path n | String n | Key n
| FileIn n | FileOut n ->
pr " const char *%s;\n" n
| OptString n -> pr " const char *%s;\n" n
@@ -326,7 +326,7 @@ free_strings (char **argv)
pr " if (!PyArg_ParseTuple (args, (char *) \"O";
List.iter (
function
- | Pathname _ | Device _ | Dev_or_Path _ | String _ | Key _
+ | Pathname _ | Device _ | Mountable _ | Dev_or_Path _ | String _ | Key _
| FileIn _ | FileOut _ -> pr "s"
| OptString _ -> pr "z"
| StringList _ | DeviceList _ -> pr "O"
@@ -347,7 +347,7 @@ free_strings (char **argv)
pr " &py_g";
List.iter (
function
- | Pathname n | Device n | Dev_or_Path n | String n | Key n
+ | Pathname n | Device n | Mountable n | Dev_or_Path n | String n | Key n
| FileIn n | FileOut n -> pr ", &%s" n
| OptString n -> pr ", &%s" n
| StringList n | DeviceList n -> pr ", &py_%s" n
@@ -369,7 +369,7 @@ free_strings (char **argv)
pr " g = get_handle (py_g);\n";
List.iter (
function
- | Pathname _ | Device _ | Dev_or_Path _ | String _ | Key _
+ | Pathname _ | Device _ | Mountable _ | Dev_or_Path _ | String _ | Key _
| FileIn _ | FileOut _ | OptString _ | Bool _ | Int _ | Int64 _
| BufferIn _ -> ()
| StringList n | DeviceList n ->
@@ -505,7 +505,7 @@ free_strings (char **argv)
List.iter (
function
- | Pathname _ | Device _ | Dev_or_Path _ | String _ | Key _
+ | Pathname _ | Device _ | Mountable _ | Dev_or_Path _ | String _ | Key _
| FileIn _ | FileOut _ | OptString _ | Bool _ | Int _ | Int64 _
| BufferIn _ | Pointer _ -> ()
| StringList n | DeviceList n ->
@@ -773,7 +773,7 @@ class GuestFS(object):
*)
List.iter (
function
- | Pathname _ | Device _ | Dev_or_Path _ | String _ | Key _
+ | Pathname _ | Device _ | Mountable _ | Dev_or_Path _ | String _ | Key _
| FileIn _ | FileOut _ | OptString _ | Bool _ | Int _ | Int64 _
| BufferIn _ | Pointer _ -> ()
| StringList n | DeviceList n ->
diff --git a/generator/ruby.ml b/generator/ruby.ml
index 23ce1fe..b98c7ff 100644
--- a/generator/ruby.ml
+++ b/generator/ruby.ml
@@ -505,7 +505,7 @@ ruby_user_cancel (VALUE gv)
List.iter (
function
- | Pathname n | Device n | Dev_or_Path n | String n | Key n
+ | Pathname n | Device n | Mountable n | Dev_or_Path n | String n | Key n
| FileIn n | FileOut n ->
pr " const char *%s = StringValueCStr (%sv);\n" n n;
| BufferIn n ->
@@ -607,7 +607,7 @@ ruby_user_cancel (VALUE gv)
List.iter (
function
- | Pathname _ | Device _ | Dev_or_Path _ | String _ | Key _
+ | Pathname _ | Device _ | Mountable _ | Dev_or_Path _ | String _ | Key _
| FileIn _ | FileOut _ | OptString _ | Bool _ | Int _ | Int64 _
| BufferIn _ | Pointer _ -> ()
| StringList n | DeviceList n ->
diff --git a/generator/tests_c_api.ml b/generator/tests_c_api.ml
index e97e4ef..9cc047c 100644
--- a/generator/tests_c_api.ml
+++ b/generator/tests_c_api.ml
@@ -793,6 +793,7 @@ and generate_test_command_call ?(expect_error = false) ?test test_name cmd =
| OptString n, "NULL" -> ()
| Pathname n, arg
| Device n, arg
+ | Mountable n, arg
| Dev_or_Path n, arg
| String n, arg
| OptString n, arg
@@ -902,7 +903,7 @@ and generate_test_command_call ?(expect_error = false) ?test test_name cmd =
function
| OptString _, "NULL" -> pr ", NULL"
| Pathname n, _
- | Device n, _ | Dev_or_Path n, _
+ | Device n, _ | Mountable n, _ | Dev_or_Path n, _
| String n, _
| OptString n, _
| Key n, _ ->
diff --git a/generator/types.ml b/generator/types.ml
index c618add..d928724 100644
--- a/generator/types.ml
+++ b/generator/types.ml
@@ -132,6 +132,7 @@ and argt =
| Int64 of string (* any 64 bit int *)
| String of string (* const char *name, cannot be NULL *)
| Device of string (* /dev device name, cannot be NULL *)
+ | Mountable of string (* location of mountable filesystem, cannot be NULL *)
| Pathname of string (* file name, cannot be NULL *)
| Dev_or_Path of string (* /dev device name or Pathname, cannot be NULL *)
| OptString of string (* const char *name, may be NULL *)
diff --git a/generator/utils.ml b/generator/utils.ml
index 67a6747..6a94009 100644
--- a/generator/utils.ml
+++ b/generator/utils.ml
@@ -250,7 +250,7 @@ let map_chars f str =
List.map f (explode str)
let name_of_argt = function
- | Pathname n | Device n | Dev_or_Path n | String n | OptString n
+ | Pathname n | Device n | Mountable n | Dev_or_Path n | String n | OptString n
| StringList n | DeviceList n | Bool n | Int n | Int64 n
| FileIn n | FileOut n | BufferIn n | Key n | Pointer (_, n) -> n
diff --git a/generator/xdr.ml b/generator/xdr.ml
index 3b79b33..976a958 100644
--- a/generator/xdr.ml
+++ b/generator/xdr.ml
@@ -106,7 +106,8 @@ let generate_xdr () =
pr "struct %s_args {\n" name;
List.iter (
function
- | Pathname n | Device n | Dev_or_Path n | String n | Key n ->
+ | Pathname n | Device n | Mountable n | Dev_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
--
1.8.1
11 years, 9 months
virt-v2v fails 'iface' parameter is not supported by the libvirt attach-method
by Chris Noffsinger
So I am getting this error on Fed18 virt-v2v trying to convert libvirtxml
to Rhev 3.1 NFS Export domain:
'iface' parameter is not supported by the libvirt attach-method at
/usr/share/perl5/vendor_perl/Sys/VirtConvert/GuestfsHandle.pm line 96.
Which is mentioned in this bug:
https://bugzilla.redhat.com/show_bug.cgi?id=895898
and this one:
https://bugzilla.redhat.com/show_bug.cgi?id=892272
Is there a work-around way for me to manipulate my xml to get it to
convert? Or am I not hitting a bug at all and just have the wrong hardware
specified somewhere?
<domain type='kvm'>
<name>XP</name>
<uuid>46683b8c-6638-9eed-b1a4-7b72c2080c9f</uuid>
<memory unit='KiB'>2097152</memory>
<currentMemory unit='KiB'>2097152</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='i686' machine='pc-1.2'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='localtime'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/500gig/xp.raw'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<controller type='usb' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01'
function='0x2'/>
</controller>
<controller type='ide' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01'
function='0x1'/>
</controller>
<controller type='virtio-serial' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04'
function='0x0'/>
</controller>
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
<channel type='spicevmc'>
<target type='virtio' name='com.redhat.spice.0'/>
<address type='virtio-serial' controller='0' bus='0' port='1'/>
</channel>
<input type='tablet' bus='usb'/>
<input type='mouse' bus='ps2'/>
<graphics type='spice' autoport='yes'/>
<sound model='ich6'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03'
function='0x0'/>
</sound>
<video>
<model type='qxl' vram='65536' heads='1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02'
function='0x0'/>
</video>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05'
function='0x0'/>
</memballoon>
</devices>
</domain>
Thanks!
--
Chris Noffsinger
11 years, 9 months
[PATCH] New API: is_whole_device
by Matthew Booth
---
daemon/devsparts.c | 27 +++++++++++++++++++++++++++
generator/actions.ml | 17 +++++++++++++++++
src/MAX_PROC_NR | 2 +-
3 files changed, 45 insertions(+), 1 deletion(-)
diff --git a/daemon/devsparts.c b/daemon/devsparts.c
index 9a2ce9a..1939f2a 100644
--- a/daemon/devsparts.c
+++ b/daemon/devsparts.c
@@ -245,6 +245,33 @@ do_part_to_partnum (const char *part)
}
int
+do_is_whole_device (const char *device)
+{
+ #define PREFIX "/dev/"
+
+ /* Shouldn't be possible because we already sanity checked our input */
+ if (!STRPREFIX (device, PREFIX)) return 0;
+
+ CLEANUP_FREE char *devpath = NULL;
+ if (asprintf (&devpath, "/sys/block/%s/device",
+ device + strlen (PREFIX)) == -1)
+ {
+ reply_with_perror ("asprintf");
+ return -1;
+ }
+
+ struct stat statbuf;
+ if (stat (devpath, &statbuf) == -1) {
+ if (errno == ENOENT || errno == ENOTDIR) return 0;
+
+ reply_with_perror ("stat");
+ return -1;
+ }
+
+ return 1;
+}
+
+int
do_device_index (const char *device)
{
size_t i;
diff --git a/generator/actions.ml b/generator/actions.ml
index 96702f7..711f97e 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -10704,6 +10704,23 @@ Rename a file to a new place on the same filesystem. This is
the same as the Linux L<rename(2)> system call. In most cases
you are better to use C<guestfs_mv> instead." };
+ { defaults with
+ name = "is_whole_device";
+ style = RBool "flag", [Device "device"], [];
+ proc_nr = Some 395;
+ tests = [
+ InitEmpty, Always, TestOutputTrue (
+ [["is_whole_device"; "/dev/sda"]]);
+ InitPartition, Always, TestOutputFalse (
+ [["is_whole_device"; "/dev/sda1"]]);
+ InitBasicFSonLVM, Always, TestOutputFalse (
+ [["is_whole_device"; "/dev/VG/LV"]]);
+ ];
+ shortdesc = "test if a device is a whole device";
+ longdesc = "\
+This returns C<true> if and only if C<device> refers to a whole block
+device. That is, not a partition or a logical device." };
+
]
(* Non-API meta-commands available only in guestfish.
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 0ca45a0..e537bfe 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-394
+395
--
1.8.1
11 years, 9 months
[libhivex] Patch implementing hivex_node_get_child_deep
by Mahmoud Al-Qudsi
Hello,
First and foremost - awesome library, beautiful code. Thank you!
If I may be so bold as to make my first post to the mailing list a request
for an API change, I have attached a patch for a new function in the hivex
library that implements obtaining a handle to a "deep" node, allowing the
user to enter a path like "SOFTWARE\Intel\Infinst\Uninstall" with only a
previous call to load the root of, say, HKLM. When I first used libhivex, I
assumed hivex_node_get_child would take such a path, but then learned that
it only scans the children of the current node for a match.
I do realize that hivex_node_get_child has a O(n) where n is the number of
keys in the node and this means hivex_node_get_child_deep has a O(mn) where
m is the number of \-separated paths; but the extra *m overhead is always
going to be there when iterating through a registry hive.
I tried to stick to the coding conventions as close as possible, and to
keep the changes to a minimal. Please note that I was not sure where the
function prototype should be declared so as to get it exported in hivex.h,
that is something that will need to be added to my patch (please).
I apologize for not taking the time to ask whether or not such a new API
function would be welcome. As it was, I needed this code for my own
purposes, so I am sharing it here on the mailing list in case it proves to
be helpful to anyone else.
Thank you,
Mahmoud Al-Qudsi
NeoSmart Technologies
11 years, 9 months
[PATCH 1/2] Fix bogus partition number passed to guestfs___check_for_filesystem_on
by Matthew Booth
Partition number was being passed to guestfs___check_for_filesystem_on
based on an index in list_partition. However, this ignores the
possibility of multiple block devices.
This change makes guestfs___check_for_filesystem_on examine the
passed-in device directly to determine if it is a whole device, or
what its partition number is.
---
src/guestfs-internal.h | 2 +-
src/inspect-fs.c | 45 +++++++++++++++++++++++++--------------------
src/inspect.c | 8 ++++----
3 files changed, 30 insertions(+), 25 deletions(-)
diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h
index 86d024a..cf298f2 100644
--- a/src/guestfs-internal.h
+++ b/src/guestfs-internal.h
@@ -524,7 +524,7 @@ extern struct inspect_fs *guestfs___search_for_root (guestfs_h *g, const char *r
/* inspect-fs.c */
extern int guestfs___is_file_nocase (guestfs_h *g, const char *);
extern int guestfs___is_dir_nocase (guestfs_h *g, const char *);
-extern int guestfs___check_for_filesystem_on (guestfs_h *g, const char *device, int is_block, int is_partnum);
+extern int guestfs___check_for_filesystem_on (guestfs_h *g, const char *device);
extern int guestfs___parse_unsigned_int (guestfs_h *g, const char *str);
extern int guestfs___parse_unsigned_int_ignore_trailing (guestfs_h *g, const char *str);
extern int guestfs___parse_major_minor (guestfs_h *g, struct inspect_fs *fs);
diff --git a/src/inspect-fs.c b/src/inspect-fs.c
index ce075db..0069dc6 100644
--- a/src/inspect-fs.c
+++ b/src/inspect-fs.c
@@ -79,47 +79,47 @@ free_regexps (void)
pcre_free (re_major_minor);
}
-static int check_filesystem (guestfs_h *g, const char *device, int is_block, int is_partnum);
+static int check_filesystem (guestfs_h *g, const char *device,
+ int whole_device);
static int extend_fses (guestfs_h *g);
/* Find out if 'device' contains a filesystem. If it does, add
* another entry in g->fses.
*/
int
-guestfs___check_for_filesystem_on (guestfs_h *g, const char *device,
- int is_block, int is_partnum)
+guestfs___check_for_filesystem_on (guestfs_h *g, const char *device)
{
- CLEANUP_FREE char *vfs_type = NULL;
- int is_swap, r;
- struct inspect_fs *fs;
+ int r;
/* Get vfs-type in order to check if it's a Linux(?) swap device.
* If there's an error we should ignore it, so to do that we have to
* temporarily replace the error handler with a null one.
*/
guestfs_push_error_handler (g, NULL, NULL);
- vfs_type = guestfs_vfs_type (g, device);
+ CLEANUP_FREE char *vfs_type = guestfs_vfs_type (g, device);
guestfs_pop_error_handler (g);
- is_swap = vfs_type && STREQ (vfs_type, "swap");
-
- debug (g, "check_for_filesystem_on: %s %d %d (%s)",
- device, is_block, is_partnum,
- vfs_type ? vfs_type : "failed to get vfs type");
+ debug (g, "check_for_filesystem_on: %s (%s)",
+ device, vfs_type ? vfs_type : "failed to get vfs type");
- if (is_swap) {
+ if (vfs_type && STREQ (vfs_type, "swap")) {
if (extend_fses (g) == -1)
return -1;
- fs = &g->fses[g->nr_fses-1];
+ struct inspect_fs *fs = &g->fses[g->nr_fses-1];
fs->device = safe_strdup (g, device);
return 0;
}
/* If it's a whole device, see if it is an install ISO. */
- if (is_block) {
+ int whole_device = guestfs_is_whole_device (g, device);
+ if (whole_device == -1) {
+ return -1;
+ }
+
+ if (whole_device) {
if (extend_fses (g) == -1)
return -1;
- fs = &g->fses[g->nr_fses-1];
+ struct inspect_fs *fs = &g->fses[g->nr_fses-1];
r = guestfs___check_installer_iso (g, fs, device);
if (r == -1) { /* Fatal error. */
@@ -149,7 +149,7 @@ guestfs___check_for_filesystem_on (guestfs_h *g, const char *device,
return 0;
/* Do the rest of the checks. */
- r = check_filesystem (g, device, is_block, is_partnum);
+ r = check_filesystem (g, device, whole_device);
/* Unmount the filesystem. */
if (guestfs_umount_all (g) == -1)
@@ -165,12 +165,17 @@ guestfs___check_for_filesystem_on (guestfs_h *g, const char *device,
* (eg. /dev/sda1 => is_partnum == 1).
*/
static int
-check_filesystem (guestfs_h *g, const char *device,
- int is_block, int is_partnum)
+check_filesystem (guestfs_h *g, const char *device, int whole_device)
{
if (extend_fses (g) == -1)
return -1;
+ int partnum = -1;
+ if (!whole_device) {
+ partnum = guestfs_part_to_partnum (g, device);
+ /* If this returns an error it just means it's not a partition */
+ }
+
struct inspect_fs *fs = &g->fses[g->nr_fses-1];
fs->device = safe_strdup (g, device);
@@ -292,7 +297,7 @@ check_filesystem (guestfs_h *g, const char *device,
* Skip these checks if it's not a whole device (eg. CD) or the
* first partition (eg. bootable USB key).
*/
- else if ((is_block || is_partnum == 1) &&
+ else if ((whole_device || partnum == 1) &&
(guestfs_is_file (g, "/isolinux/isolinux.cfg") > 0 ||
guestfs_is_dir (g, "/EFI/BOOT") > 0 ||
guestfs_is_file (g, "/images/install.img") > 0 ||
diff --git a/src/inspect.c b/src/inspect.c
index c51c3f5..d0eb012 100644
--- a/src/inspect.c
+++ b/src/inspect.c
@@ -64,7 +64,7 @@ guestfs__inspect_os (guestfs_h *g)
size_t i;
for (i = 0; devices[i] != NULL; ++i) {
- if (guestfs___check_for_filesystem_on (g, devices[i], 1, 0) == -1) {
+ if (guestfs___check_for_filesystem_on (g, devices[i]) == -1) {
guestfs___free_string_list (devices);
guestfs___free_inspect_info (g);
return NULL;
@@ -83,7 +83,7 @@ guestfs__inspect_os (guestfs_h *g)
if (parent_device_already_probed (g, partitions[i]))
continue;
- if (guestfs___check_for_filesystem_on (g, partitions[i], 0, i+1) == -1) {
+ if (guestfs___check_for_filesystem_on (g, partitions[i]) == -1) {
guestfs___free_string_list (partitions);
guestfs___free_inspect_info (g);
return NULL;
@@ -99,7 +99,7 @@ guestfs__inspect_os (guestfs_h *g)
}
for (i = 0; mds[i] != NULL; ++i) {
- if (guestfs___check_for_filesystem_on (g, mds[i], 0, i+1) == -1) {
+ if (guestfs___check_for_filesystem_on (g, mds[i]) == -1) {
guestfs___free_string_list (mds);
guestfs___free_inspect_info (g);
return NULL;
@@ -117,7 +117,7 @@ guestfs__inspect_os (guestfs_h *g)
}
for (i = 0; lvs[i] != NULL; ++i) {
- if (guestfs___check_for_filesystem_on (g, lvs[i], 0, 0) == -1) {
+ if (guestfs___check_for_filesystem_on (g, lvs[i]) == -1) {
guestfs___free_string_list (lvs);
guestfs___free_inspect_info (g);
return NULL;
--
1.8.1
11 years, 9 months
[PATCH] btrfs: Fix btrfs_subvolume_list on F18
by Matthew Booth
The output of btrfs subvolume list has changed in F18 to include generation,
which breaks the parsing in btrfs_subvolume_list. This change replaces sscanf
with a more robust regular expression. The new regular expression should also
handle the addition of future unexpected columns.
Fixes RHBZ#903620
---
appliance/packagelist.in | 3 +
daemon/Makefile.am | 6 +-
daemon/btrfs.c | 149 ++++++++++++++++++++++++++++++-----------------
3 files changed, 104 insertions(+), 54 deletions(-)
diff --git a/appliance/packagelist.in b/appliance/packagelist.in
index ead6d41..a43039c 100644
--- a/appliance/packagelist.in
+++ b/appliance/packagelist.in
@@ -42,6 +42,7 @@
ntfsprogs
ntfs-3g
openssh-clients
+ pcre
reiserfs-utils
libselinux
systemd /* for /sbin/reboot and udevd */
@@ -65,6 +66,7 @@
libaugeas0
libcap2
libhivex0
+ libpcre3
libyajl2
linux-image
nilfs-tools
@@ -95,6 +97,7 @@
nilfs-utils
ntfsprogs
ntfs-3g
+ pcre
reiserfsprogs
systemd
vim
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index eac9058..a1e5e68 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -194,7 +194,8 @@ guestfsd_LDADD = \
$(LIBSOCKET) \
$(LIB_CLOCK_GETTIME) \
$(LIBINTL) \
- $(SERVENT_LIB)
+ $(SERVENT_LIB) \
+ $(PCRE_LIBS)
guestfsd_CPPFLAGS = \
-I$(top_srcdir)/gnulib/lib \
@@ -204,7 +205,8 @@ guestfsd_CFLAGS = \
$(WARN_CFLAGS) $(WERROR_CFLAGS) \
$(AUGEAS_CFLAGS) \
$(HIVEX_CFLAGS) \
- $(YAJL_CFLAGS)
+ $(YAJL_CFLAGS) \
+ $(PCRE_CFLAGS)
# Manual pages and HTML files for the website.
man_MANS = guestfsd.8
diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index c100d18..81ce5f5 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -21,12 +21,14 @@
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
+#include <pcre.h>
#include <string.h>
#include <unistd.h>
#include "daemon.h"
#include "actions.h"
#include "optgroups.h"
+#include "xstrtol.h"
GUESTFSD_EXT_CMD(str_btrfs, btrfs);
GUESTFSD_EXT_CMD(str_btrfstune, btrfstune);
@@ -307,94 +309,137 @@ do_btrfs_subvolume_create (const char *dest)
guestfs_int_btrfssubvolume_list *
do_btrfs_subvolume_list (const char *fs)
{
- const size_t MAX_ARGS = 64;
- guestfs_int_btrfssubvolume_list *ret;
- CLEANUP_FREE char *fs_buf = NULL;
- const char *argv[MAX_ARGS];
- size_t i = 0;
- char **lines, *pos;
- CLEANUP_FREE char *out = NULL, *err = NULL;
- size_t nr_subvolumes;
- int r;
+ char **lines;
- fs_buf = sysroot_path (fs);
- if (fs_buf == NULL) {
- reply_with_perror ("malloc");
- return NULL;
- }
+ /* Execute 'btrfs subvolume list <fs>', and split the output into lines */
+ {
+ CLEANUP_FREE char *fs_buf = sysroot_path (fs);
+ if (fs_buf == NULL) {
+ reply_with_perror ("malloc");
+ return NULL;
+ }
- ADD_ARG (argv, i, str_btrfs);
- ADD_ARG (argv, i, "subvolume");
- ADD_ARG (argv, i, "list");
- ADD_ARG (argv, i, fs_buf);
- ADD_ARG (argv, i, NULL);
+ size_t i = 0;
+ const size_t MAX_ARGS = 64;
+ const char *argv[MAX_ARGS];
+ ADD_ARG (argv, i, str_btrfs);
+ ADD_ARG (argv, i, "subvolume");
+ ADD_ARG (argv, i, "list");
+ ADD_ARG (argv, i, fs_buf);
+ ADD_ARG (argv, i, NULL);
+
+ CLEANUP_FREE char *out = NULL, *err = NULL;
+ int r = commandv (&out, &err, argv);
+ if (r == -1) {
+ reply_with_error ("%s: %s", fs, err);
+ return NULL;
+ }
- r = commandv (&out, &err, argv);
- if (r == -1) {
- reply_with_error ("%s: %s", fs, err);
- return NULL;
+ lines = split_lines (out);
+ if (!lines)
+ return NULL;
}
- lines = split_lines (out);
- if (!lines)
- return NULL;
-
/* Output is:
*
- * ID 256 top level 5 path test1
- * ID 257 top level 5 path dir/test2
- * ID 258 top level 5 path test3
+ * ID 256 gen 30 top level 5 path test1
+ * ID 257 gen 30 top level 5 path dir/test2
+ * ID 258 gen 30 top level 5 path test3
*
- * "ID <n>" is the subvolume ID. "top level <n>" is the top level
- * subvolume ID. "path <str>" is the subvolume path, relative to
- * the top of the filesystem.
+ * "ID <n>" is the subvolume ID.
+ * "gen <n>" is the generation when the root was created or last
+ * updated.
+ * "top level <n>" is the top level subvolume ID.
+ * "path <str>" is the subvolume path, relative to the top of the
+ * filesystem.
+ *
+ * Note that the order that each of the above is fixed, but
+ * different versions of btrfs may display different sets of data.
+ * Specifically, older versions of btrfs do not display gen.
*/
- nr_subvolumes = count_strings (lines);
+
+ guestfs_int_btrfssubvolume_list *ret = NULL;
+ pcre *re = NULL;
+
+ size_t nr_subvolumes = count_strings (lines);
ret = malloc (sizeof *ret);
if (!ret) {
reply_with_perror ("malloc");
- free_stringslen (lines, nr_subvolumes);
- return NULL;
+ goto error;
}
+
ret->guestfs_int_btrfssubvolume_list_len = nr_subvolumes;
ret->guestfs_int_btrfssubvolume_list_val =
calloc (nr_subvolumes, sizeof (struct guestfs_int_btrfssubvolume));
if (ret->guestfs_int_btrfssubvolume_list_val == NULL) {
reply_with_perror ("malloc");
- free (ret);
- free_stringslen (lines, nr_subvolumes);
- return NULL;
+ goto error;
+ }
+
+ const char *errptr;
+ int erroffset;
+ re = pcre_compile ("ID\\s+(\\d+).*\\s"
+ "top level\\s+(\\d+).*\\s"
+ "path\\s(.*)",
+ 0, &errptr, &erroffset, NULL);
+ if (re == NULL) {
+ reply_with_error ("pcre_compile (%i): %s", erroffset, errptr);
+ goto error;
}
- for (i = 0; i < nr_subvolumes; ++i) {
+ for (size_t i = 0; i < nr_subvolumes; ++i) {
/* To avoid allocations, reuse the 'line' buffer to store the
* path. Thus we don't need to free 'line', since it will be
* freed by the calling (XDR) code.
*/
char *line = lines[i];
+ #define N_MATCHES 4
+ int ovector[N_MATCHES * 3];
- if (sscanf (line, "ID %" SCNu64 " top level %" SCNu64 " path ",
- &ret->guestfs_int_btrfssubvolume_list_val[i].btrfssubvolume_id,
- &ret->guestfs_int_btrfssubvolume_list_val[i].btrfssubvolume_top_level_id) != 2) {
+ if (pcre_exec (re, NULL, line, strlen (line), 0, 0,
+ ovector, N_MATCHES * 3) < 0)
+ #undef N_MATCHES
+ {
unexpected_output:
reply_with_error ("unexpected output from 'btrfs subvolume list' command: %s", line);
- free_stringslen (lines, nr_subvolumes);
- free (ret->guestfs_int_btrfssubvolume_list_val);
- free (ret);
- return NULL;
+ goto error;
}
- pos = strstr (line, " path ");
- if (pos == NULL)
+ struct guestfs_int_btrfssubvolume *this =
+ &ret->guestfs_int_btrfssubvolume_list_val[i];
+
+ #if __WORDSIZE == 64
+ #define XSTRTOU64 xstrtoul
+ #else
+ #define XSTRTOU64 xstrtoull
+ #endif
+
+ if (XSTRTOU64 (line + ovector[2], NULL, 10,
+ &this->btrfssubvolume_id, NULL) != LONGINT_OK)
+ goto unexpected_output;
+ if (XSTRTOU64 (line + ovector[4], NULL, 10,
+ &this->btrfssubvolume_top_level_id, NULL) != LONGINT_OK)
goto unexpected_output;
- pos += 6;
- memmove (line, pos, strlen (pos) + 1);
- ret->guestfs_int_btrfssubvolume_list_val[i].btrfssubvolume_path = line;
+ #undef XSTRTOU64
+
+ memmove (line, line + ovector[6], ovector[7] + 1);
+ this->btrfssubvolume_path = line;
}
+ free (lines);
+ pcre_free (re);
+
return ret;
+
+error:
+ free_stringslen (lines, nr_subvolumes);
+ if (ret) free (ret->guestfs_int_btrfssubvolume_list_val);
+ free (ret);
+ if (re) pcre_free (re);
+
+ return NULL;
}
int
--
1.8.1
11 years, 9 months
Issues with p2v & virt-v2v Windows
by Jason A. Kates
It looks to me that the windows 2008 image I am attempting to convert is
not being detected as windows but is being updated as a Linux system.
When PXE booted the server with the p2v image I ended up with this
error:
Failed to launch guestfs appliance. Try running again with
LIBGUESTFS_DEBUG=1 for more information
The system image transferred and I was able to create an XML file to
boot it under kvm with IDE disks.
I undefined it and attempted to convert the system into another storage
pool to help in the debugging and I ended up with the same error.
This is what I ran:
LIBGUESTFS_TRACE=1 LIBGUESTFS_DEBUG=1 virt-v2v -i libvirtxml -os
external --network default window2008_r1.xml 2>&1 | tee virt-v2v.log
This is the log file that was produced:
"
libguestfs: new guestfs handle 0x32df9a0
libguestfs: trace: add_drive_opts
"/run/media/jkates/WD-3TB-DSK-B/p2v/window2008_r1-cciss_c0d0"
"format:raw" "iface:ide" "name:hda"
libguestfs: trace: add_drive_opts = 0
libguestfs: trace: add_drive_opts "/tmp/JxIRaWzMVf" "readonly:true"
"format:raw" "iface:ide"
libguestfs: trace: add_drive_opts = 0
libguestfs: trace: set_network true
libguestfs: trace: set_network = 0
libguestfs: trace: launch
libguestfs: [00000ms] febootstrap-supermin-helper --verbose -f checksum
'/usr/lib64/guestfs/supermin.d' x86_64
supermin helper [00000ms] whitelist = (not specified), host_cpu =
x86_64, kernel = (null), initrd = (null), appliance = (null)
supermin helper [00000ms] inputs[0] = /usr/lib64/guestfs/supermin.d
checking modpath /lib/modules/3.6.11-5.fc17.x86_64 is a directory
picked vmlinuz-3.6.11-5.fc17.x86_64 because
modpath /lib/modules/3.6.11-5.fc17.x86_64 exists
checking modpath /lib/modules/3.7.3-101.fc17.x86_64 is a directory
picked vmlinuz-3.7.3-101.fc17.x86_64 because
modpath /lib/modules/3.7.3-101.fc17.x86_64 exists
checking modpath /lib/modules/3.7.5-101.fc17.x86_64 is a directory
picked vmlinuz-3.7.5-101.fc17.x86_64 because
modpath /lib/modules/3.7.5-101.fc17.x86_64 exists
supermin helper [00000ms] finished creating kernel
supermin helper [00000ms] visiting /usr/lib64/guestfs/supermin.d
supermin helper [00000ms]
visiting /usr/lib64/guestfs/supermin.d/base.img
supermin helper [00000ms]
visiting /usr/lib64/guestfs/supermin.d/daemon.img
supermin helper [00001ms]
visiting /usr/lib64/guestfs/supermin.d/hostfiles
supermin helper [00054ms]
visiting /usr/lib64/guestfs/supermin.d/init.img
supermin helper [00054ms]
visiting /usr/lib64/guestfs/supermin.d/ntfs.hostfiles
supermin helper [00055ms]
visiting /usr/lib64/guestfs/supermin.d/ntfs.img
supermin helper [00055ms] adding kernel modules
supermin helper [00134ms] finished creating appliance
libguestfs: [00146ms] begin building supermin appliance
libguestfs: [00146ms] run febootstrap-supermin-helper
libguestfs: [00146ms] febootstrap-supermin-helper --verbose -f
ext2 /usr/lib64/guestfs/supermin.d
x86_64 /var/tmp/guestfs.ohng6U/kernel /var/tmp/guestfs.ohng6U/initrd /var/tmp/guestfs.ohng6U/root
supermin helper [00000ms] whitelist = (not specified), host_cpu =
x86_64, kernel = /var/tmp/guestfs.ohng6U/kernel, initrd
= /var/tmp/guestfs.ohng6U/initrd, appliance
= /var/tmp/guestfs.ohng6U/root
supermin helper [00000ms] inputs[0] = /usr/lib64/guestfs/supermin.d
checking modpath /lib/modules/3.6.11-5.fc17.x86_64 is a directory
picked vmlinuz-3.6.11-5.fc17.x86_64 because
modpath /lib/modules/3.6.11-5.fc17.x86_64 exists
checking modpath /lib/modules/3.7.3-101.fc17.x86_64 is a directory
picked vmlinuz-3.7.3-101.fc17.x86_64 because
modpath /lib/modules/3.7.3-101.fc17.x86_64 exists
checking modpath /lib/modules/3.7.5-101.fc17.x86_64 is a directory
picked vmlinuz-3.7.5-101.fc17.x86_64 because
modpath /lib/modules/3.7.5-101.fc17.x86_64 exists
supermin helper [00000ms] finished creating kernel
supermin helper [00393ms] finished mke2fs
supermin helper [00394ms] visiting /usr/lib64/guestfs/supermin.d
supermin helper [00394ms]
visiting /usr/lib64/guestfs/supermin.d/base.img
supermin helper [03635ms]
visiting /usr/lib64/guestfs/supermin.d/daemon.img
supermin helper [03646ms]
visiting /usr/lib64/guestfs/supermin.d/hostfiles
supermin helper [08967ms]
visiting /usr/lib64/guestfs/supermin.d/init.img
supermin helper [08968ms]
visiting /usr/lib64/guestfs/supermin.d/ntfs.hostfiles
supermin helper [08973ms]
visiting /usr/lib64/guestfs/supermin.d/ntfs.img
febootstrap-supermin-helper: ext2fs_unlink_inode: Ext2 inode is not a
directory
libguestfs: trace: launch = -1 (error)
virt-v2v: Failed to launch guestfs appliance. Try running again with
LIBGUESTFS_DEBUG=1 for more information
libguestfs: trace: close
libguestfs: closing guestfs handle 0x32df9a0 (state 0)
virt-v2v: Transferring storage volume window2008_r1-cciss_c0d0:
72833679360 bytes
"
I redefined the guest and I ran this:
[root@W520 v2v]# virt-inspector window2008_r1
febootstrap-supermin-helper: ext2fs_unlink_inode: Ext2 inode is not a
directory
libguestfs: error: external command failed, see earlier error messages
This is a list of the RPM files that I think might be relevant:
libguestfs-winsupport-1.0-7.el6.x86_64
libguestfs-tools-c-1.18.11-2.fc17.x86_64
libguestfs-1.18.11-2.fc17.x86_64
libguestfs-tools-1.18.11-2.fc17.x86_64
virtio-win-1.5.3-1.el6_3.noarch
virt-manager-0.9.4-3.fc17.noarch
libvirt-daemon-config-nwfilter-0.9.11.9-1.fc17.x86_64
libvirt-0.9.11.9-1.fc17.x86_64
libvirt-python-0.9.11.9-1.fc17.x86_64
virt-v2v-0.9.0-1.fc17.x86_64
libvirt-daemon-config-network-0.9.11.9-1.fc17.x86_64
virt-manager-common-0.9.4-3.fc17.noarch
libvirt-daemon-0.9.11.9-1.fc17.x86_64
libvirt-client-0.9.11.9-1.fc17.x86_64
python-virtinst-0.600.3-2.fc17.noarch
Any help or suggestions of what to attempt next would be appreciated.
-Jason
--
----------------------------------------------------------------------------
Jason A. Kates (jason(a)kates.org)
Fax: 208-975-1514
Phone: 660-960-0070
============================================================================
11 years, 9 months
[PATCH] generator: Add visibility to action struct
by Matthew Booth
The visibility field in action replaces in_fish, in_docs and internal.
The defined types are:
VPublic:
A public API. This is exported and documented in all language
bindings, and in guestfish.
VStateTest:
A public API which queries the library state machine. It is exported
and documented in all language bindings, but not guestfish.
VBindTest:
An internal API used only for testing language bindings. It is
guarded by GUESTFS_PRIVATE in the C api, but exported by all other
language bindings as it is required for testing. If language
bindings offer any way to guard use of these apis, that mechanism
should be used. It is not documented anywhere.
VDebug:
A debugging API. It is exported by all language bindings, and in
guestfish, but is not documented anywhere.
VInternal:
An internal-only API. It is guarded by GUESTFS_PRIVATE in the C api,
and not exported at all in any other language binding. It is not
documented anywhere.
---
generator/actions.ml | 90 ++++++++++++++++++++++++++++++++++++---------------
generator/actions.mli | 24 ++++++++++++++
generator/c.ml | 7 ++--
generator/csharp.ml | 4 +--
generator/erlang.ml | 10 +++---
generator/fish.ml | 46 +++++++++-----------------
generator/gobject.ml | 6 ++--
generator/haskell.ml | 4 +--
generator/java.ml | 52 ++++++++++++++---------------
generator/lua.ml | 8 ++---
generator/main.ml | 4 +--
generator/ocaml.ml | 18 +++++------
generator/perl.ml | 14 ++++----
generator/php.ml | 6 ++--
generator/python.ml | 26 +++++++--------
generator/ruby.ml | 35 ++++++++++----------
generator/types.ml | 13 +++++---
17 files changed, 208 insertions(+), 159 deletions(-)
diff --git a/generator/actions.ml b/generator/actions.ml
index a97b867..8d31317 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -27,8 +27,8 @@ open Utils
let defaults = { name = ""; style = RErr, [], []; proc_nr = None;
tests = []; shortdesc = ""; longdesc = "";
protocol_limit_warning = false; fish_alias = [];
- fish_output = None; in_fish = true; in_docs = true;
- internal = false; deprecated_by = None; optional = None;
+ fish_output = None; visibility = VPublic;
+ deprecated_by = None; optional = None;
progress = false; camel_name = "";
cancellable = false; config_only = false;
once_had_no_optargs = false; blocking = true;
@@ -76,7 +76,7 @@ let test_functions = [
{ defaults with
name = "internal_test";
style = RErr, test_all_args, test_all_optargs;
- in_fish = false; in_docs = false; internal = true; cancellable = true;
+ visibility = VBindTest; cancellable = true;
blocking = false;
shortdesc = "internal test function - do not use";
longdesc = "\
@@ -92,7 +92,7 @@ You probably don't want to call this function." };
{ defaults with
name = "internal_test_only_optargs";
style = RErr, [], [OInt "test"];
- in_fish = false; in_docs = false; internal = true; cancellable = true;
+ visibility = VBindTest; cancellable = true;
blocking = false;
shortdesc = "internal test function - do not use";
longdesc = "\
@@ -108,7 +108,7 @@ You probably don't want to call this function." };
{ defaults with
name = "internal_test_63_optargs";
style = RErr, [], [OInt "opt1"; OInt "opt2"; OInt "opt3"; OInt "opt4"; OInt "opt5"; OInt "opt6"; OInt "opt7"; OInt "opt8"; OInt "opt9"; OInt "opt10"; OInt "opt11"; OInt "opt12"; OInt "opt13"; OInt "opt14"; OInt "opt15"; OInt "opt16"; OInt "opt17"; OInt "opt18"; OInt "opt19"; OInt "opt20"; OInt "opt21"; OInt "opt22"; OInt "opt23"; OInt "opt24"; OInt "opt25"; OInt "opt26"; OInt "opt27"; OInt "opt28"; OInt "opt29"; OInt "opt30"; OInt "opt31"; OInt "opt32"; OInt "opt33"; OInt "opt34"; OInt "opt35"; OInt "opt36"; OInt "opt37"; OInt "opt38"; OInt "opt39"; OInt "opt40"; OInt "opt41"; OInt "opt42"; OInt "opt43"; OInt "opt44"; OInt "opt45"; OInt "opt46"; OInt "opt47"; OInt "opt48"; OInt "opt49"; OInt "opt50"; OInt "opt51"; OInt "opt52"; OInt "opt53"; OInt "opt54"; OInt "opt55"; OInt "opt56"; OInt "opt57"; OInt "opt58"; OInt "opt59"; OInt "opt60"; OInt "opt61"; OInt "opt62"; OInt "opt63"];
- in_fish = false; in_docs = false; internal = true; cancellable = true;
+ visibility = VBindTest; cancellable = true;
blocking = false;
shortdesc = "internal test function - do not use";
longdesc = "\
@@ -128,7 +128,7 @@ You probably don't want to call this function." }
{ defaults with
name = name;
style = ret, [String "val"], [];
- in_fish = false; in_docs = false; internal = true;
+ visibility = VBindTest;
blocking = false;
shortdesc = "internal test function - do not use";
longdesc = "\
@@ -142,7 +142,7 @@ You probably don't want to call this function." };
{ defaults with
name = name ^ "err";
style = ret, [], [];
- in_fish = false; in_docs = false; internal = true;
+ visibility = VBindTest;
blocking = false;
shortdesc = "internal test function - do not use";
longdesc = "\
@@ -166,7 +166,7 @@ let non_daemon_functions = test_functions @ [
{ defaults with
name = "internal_test_set_output";
style = RErr, [String "filename"], [];
- in_fish = false; in_docs = false; internal = true;
+ visibility = VBindTest;
blocking = false;
shortdesc = "internal test function - do not use";
longdesc = "\
@@ -181,7 +181,7 @@ You probably don't want to call this function." };
{ defaults with
name = "internal_test_close_output";
style = RErr, [], [];
- in_fish = false; in_docs = false; internal = true;
+ visibility = VBindTest;
blocking = false;
shortdesc = "internal test function - do not use";
longdesc = "\
@@ -214,7 +214,8 @@ very cheap to create, so create a new one for each launch." };
{ defaults with
name = "wait_ready";
style = RErr, [], [];
- in_fish = false; deprecated_by = Some "launch";
+ visibility = VStateTest;
+ deprecated_by = Some "launch";
blocking = false;
shortdesc = "wait until the qemu subprocess launches (no op)";
longdesc = "\
@@ -434,6 +435,7 @@ This returns the verbose messages flag." };
{ defaults with
name = "is_ready";
style = RBool "ready", [], [];
+ visibility = VStateTest;
blocking = false;
tests = [
InitNone, Always, TestOutputTrue (
@@ -464,6 +466,7 @@ For more information on states, see L<guestfs(3)>." };
{ defaults with
name = "is_launching";
style = RBool "launching", [], [];
+ visibility = VStateTest;
blocking = false;
tests = [
InitNone, Always, TestOutputFalse (
@@ -479,7 +482,7 @@ For more information on states, see L<guestfs(3)>." };
{ defaults with
name = "is_busy";
style = RBool "busy", [], [];
- in_docs = false;
+ visibility = VStateTest;
blocking = false;
tests = [
InitNone, Always, TestOutputFalse (
@@ -487,13 +490,15 @@ For more information on states, see L<guestfs(3)>." };
];
shortdesc = "is busy processing a command";
longdesc = "\
-This always returns false. Do not use this function.
+This always returns false. This function is deprecated with no
+replacement. Do not use this function.
For more information on states, see L<guestfs(3)>." };
{ defaults with
name = "get_state";
style = RInt "state", [], [];
+ visibility = VStateTest;
blocking = false;
shortdesc = "get the current state";
longdesc = "\
@@ -1345,7 +1350,7 @@ Please read L<guestfs(3)/INSPECTION> for more details." };
{ defaults with
name = "debug_drives";
style = RStringList "cmdline", [], [];
- in_docs = false;
+ visibility = VDebug;
blocking = false;
shortdesc = "debug the drives (internal use only)";
longdesc = "\
@@ -4231,7 +4236,7 @@ as for the L<mount(8)> I<-o> and I<-t> flags." };
name = "debug";
style = RString "result", [String "subcmd"; StringList "extraargs"], [];
proc_nr = Some 76;
- in_docs = false;
+ visibility = VDebug;
shortdesc = "debugging and internals";
longdesc = "\
The C<guestfs_debug> command exposes some internals of
@@ -6825,7 +6830,7 @@ yourself (Augeas support makes this relatively easy)." };
name = "internal_lstatlist";
style = RStructList ("statbufs", "stat"), [Pathname "path"; StringList "names"], [];
proc_nr = Some 204;
- in_docs = false; in_fish = false; internal = true;
+ visibility = VInternal;
shortdesc = "lstat on multiple files";
longdesc = "\
This call allows you to perform the C<guestfs_lstat> operation
@@ -6849,7 +6854,7 @@ into smaller groups of names." };
name = "internal_lxattrlist";
style = RStructList ("xattrs", "xattr"), [Pathname "path"; StringList "names"], [];
proc_nr = Some 205;
- in_docs = false; in_fish = false; internal = true;
+ visibility = VInternal;
optional = Some "linuxxattrs";
shortdesc = "lgetxattr on multiple files";
longdesc = "\
@@ -6879,7 +6884,7 @@ into smaller groups of names." };
name = "internal_readlinklist";
style = RStringList "links", [Pathname "path"; StringList "names"], [];
proc_nr = Some 206;
- in_docs = false; in_fish = false; internal = true;
+ visibility = VInternal;
shortdesc = "readlink on multiple files";
longdesc = "\
This call allows you to do a C<readlink> operation
@@ -7602,7 +7607,8 @@ unless it has been set by calling C<guestfs_umask>." };
name = "debug_upload";
style = RErr, [FileIn "filename"; String "tmpname"; Int "mode"], [];
proc_nr = Some 241;
- in_docs = false; cancellable = true;
+ visibility = VDebug;
+ cancellable = true;
shortdesc = "upload a file to the appliance (internal use only)";
longdesc = "\
The C<guestfs_debug_upload> command uploads a file to
@@ -7677,7 +7683,7 @@ to ensure the length of the file is exactly C<len> bytes." };
name = "internal_write";
style = RErr, [Pathname "path"; BufferIn "content"], [];
proc_nr = Some 246;
- in_fish = false; in_docs = false; internal = true;
+ visibility = VInternal;
protocol_limit_warning = true;
tests = [
InitScratchFS, Always, TestOutput (
@@ -8391,7 +8397,7 @@ See also L<guestfs(3)/RESIZE2FS ERRORS>." };
name = "internal_autosync";
style = RErr, [], [];
proc_nr = Some 282;
- in_fish = false; in_docs = false; internal = true;
+ visibility = VInternal;
shortdesc = "internal autosync operation";
longdesc = "\
This command performs the autosync operation just before the
@@ -8537,7 +8543,7 @@ See also L<btrfs(8)>." };
name = "internal_write_append";
style = RErr, [Pathname "path"; BufferIn "content"], [];
proc_nr = Some 290;
- in_fish = false; in_docs = false; internal = true;
+ visibility = VInternal;
protocol_limit_warning = true;
tests = [
InitScratchFS, Always, TestOutput (
@@ -10302,7 +10308,7 @@ are the full raw block device and partition names
name = "internal_hot_add_drive";
style = RErr, [String "label"], [];
proc_nr = Some 370;
- in_fish = false; in_docs = false; internal = true;
+ visibility = VInternal;
tests = [];
shortdesc = "internal hotplugging operation";
longdesc = "\
@@ -10312,7 +10318,7 @@ This function is used internally when hotplugging drives." };
name = "internal_hot_remove_drive_precheck";
style = RErr, [String "label"], [];
proc_nr = Some 371;
- in_fish = false; in_docs = false; internal = true;
+ visibility = VInternal;
tests = [];
shortdesc = "internal hotplugging operation";
longdesc = "\
@@ -10322,7 +10328,7 @@ This function is used internally when hotplugging drives." };
name = "internal_hot_remove_drive";
style = RErr, [String "label"], [];
proc_nr = Some 372;
- in_fish = false; in_docs = false; internal = true;
+ visibility = VInternal;
tests = [];
shortdesc = "internal hotplugging operation";
longdesc = "\
@@ -11054,11 +11060,37 @@ let non_daemon_functions, daemon_functions =
(* All functions. *)
let all_functions = non_daemon_functions @ daemon_functions
+let is_external =
+ fun x -> match x.visibility with
+ | VPublic | VStateTest | VBindTest | VDebug -> true
+ | VInternal -> false
+
+let is_internal =
+ fun x -> match x.visibility with
+ | VPublic | VStateTest | VBindTest | VDebug -> false
+ | VInternal -> true
+
+let is_documented =
+ fun x -> match x.visibility with
+ | VPublic | VStateTest -> true
+ | VBindTest | VDebug | VInternal -> false
+
+let is_fish =
+ fun x -> match x.visibility with
+ | VPublic | VDebug -> true
+ | VStateTest | VBindTest | VInternal -> false
+
let external_functions =
- List.filter (fun x -> not x.internal) all_functions
+ List.filter is_external all_functions
let internal_functions =
- List.filter (fun x -> x.internal) all_functions
+ List.filter is_internal all_functions
+
+let documented_functions =
+ List.filter is_documented all_functions
+
+let fish_functions =
+ List.filter is_fish all_functions
(* In some places we want the functions to be displayed sorted
* alphabetically, so this is useful:
@@ -11071,6 +11103,12 @@ let external_functions_sorted =
let internal_functions_sorted =
List.sort action_compare internal_functions
+let documented_functions_sorted =
+ List.sort action_compare documented_functions
+
+let fish_functions_sorted =
+ List.sort action_compare fish_functions
+
(* This is used to generate the src/MAX_PROC_NR file which
* contains the maximum procedure number, a surrogate for the
* ABI version number. See src/Makefile.am for the details.
diff --git a/generator/actions.mli b/generator/actions.mli
index 26ae7e9..5641e57 100644
--- a/generator/actions.mli
+++ b/generator/actions.mli
@@ -29,12 +29,30 @@ val daemon_functions : Types.action list
val all_functions : Types.action list
(** Concatenation of [non_daemon_functions] and [daemon_functions] lists. *)
+val is_external : Types.action -> bool
+(** Returns true if function is external, false otherwise *)
+
+val is_internal : Types.action -> bool
+(** Returns true if function is internal, false otherwise *)
+
+val is_documented : Types.action -> bool
+(** Returns true if function should be documented, false otherwise *)
+
+val is_fish : Types.action -> bool
+(** Returns true if function should be in guestfish, false otherwise *)
+
val external_functions : Types.action list
(** [all_functions] filtered for external functions **)
val internal_functions : Types.action list
(** [all_functions] filtered for internal functions **)
+val documented_functions : Types.action list
+(** [all_functions] filtered for functions requiring documentation **)
+
+val fish_functions : Types.action list
+(** [all_functions] filtered for functions in guestfish **)
+
val all_functions_sorted : Types.action list
(** [all_functions] but sorted by name. *)
@@ -44,6 +62,12 @@ val external_functions_sorted : Types.action list
val internal_functions_sorted : Types.action list
(** [internal_functions] but sorted by name. *)
+val documented_functions_sorted : Types.action list
+(** [documented_functions] but sorted by name. *)
+
+val fish_functions_sorted : Types.action list
+(** [fish_functions] but sorted by name. *)
+
val test_functions : Types.action list
(** Internal test functions used to test the language bindings. *)
diff --git a/generator/c.ml b/generator/c.ml
index e0ce7e1..9ca477b 100644
--- a/generator/c.ml
+++ b/generator/c.ml
@@ -196,13 +196,12 @@ and generate_c_call_args ?handle ?(implicit_size_ptr = "&size")
and generate_actions_pod () =
List.iter (
function
- | { in_docs = false } -> ()
- | ({ in_docs = true; once_had_no_optargs = false } as f) ->
+ | ({ once_had_no_optargs = false } as f) ->
generate_actions_pod_entry f
- | ({ in_docs = true; once_had_no_optargs = true } as f) ->
+ | ({ once_had_no_optargs = true } as f) ->
generate_actions_pod_back_compat_entry f;
generate_actions_pod_entry f
- ) all_functions_sorted
+ ) documented_functions_sorted
and generate_actions_pod_entry ({ c_name = c_name;
style = ret, args, optargs as style } as f) =
diff --git a/generator/csharp.ml b/generator/csharp.ml
index bc92cf1..0fbd02c 100644
--- a/generator/csharp.ml
+++ b/generator/csharp.ml
@@ -131,7 +131,7 @@ namespace Guestfs
) cols;
pr " }\n";
pr "\n"
- ) structs;
+ ) external_structs;
(* Generate C# function bindings. *)
List.iter (
@@ -286,7 +286,7 @@ namespace Guestfs
pr "\n";
List.iter generate_alias non_c_aliases
- ) all_functions_sorted;
+ ) external_functions_sorted;
pr " }
}
diff --git a/generator/erlang.ml b/generator/erlang.ml
index b7d4e6c..6242338 100644
--- a/generator/erlang.ml
+++ b/generator/erlang.ml
@@ -50,7 +50,7 @@ let rec generate_erlang_erl () =
in
export name;
List.iter export aliases
- ) all_functions_sorted;
+ ) external_functions_sorted;
pr "\n";
@@ -178,7 +178,7 @@ loop(Port) ->
) aliases;
pr "\n"
- ) all_functions_sorted
+ ) external_functions_sorted
and generate_erlang_c () =
generate_header CStyle GPLv2plus;
@@ -279,7 +279,7 @@ extern void free_strings (char **r);
(* generate the function for typ *)
emit_copy_list_function typ
| typ, _ -> () (* empty *)
- ) (rstructs_used_by all_functions);
+ ) (rstructs_used_by external_functions);
(* The wrapper functions. *)
List.iter (
@@ -461,7 +461,7 @@ extern void free_strings (char **r);
pr "}\n";
pr "\n";
- ) all_functions_sorted;
+ ) external_functions_sorted;
pr "\
@@ -480,7 +480,7 @@ dispatch (ETERM *message)
pr "if (atom_equals (fun, \"%s\"))\n" name;
pr " return run_%s (message);\n" name;
pr " else ";
- ) all_functions_sorted;
+ ) external_functions_sorted;
pr "return unknown_function (fun);
}
diff --git a/generator/fish.ml b/generator/fish.ml
index 077a0b4..411cf11 100644
--- a/generator/fish.ml
+++ b/generator/fish.ml
@@ -31,6 +31,9 @@ open Prepopts
open C
open Events
+let fish_functions_and_commands_sorted =
+ List.sort action_compare (fish_functions_sorted @ fish_commands)
+
let doc_opttype_of = function
| OBool n -> "true|false"
| OInt n
@@ -47,13 +50,6 @@ let get_aliases { fish_alias = fish_alias; non_c_aliases = non_c_aliases } =
let generate_fish_cmds () =
generate_header CStyle GPLv2plus;
- let all_functions =
- List.filter (fun { in_fish = b } -> b) all_functions in
- let all_functions_sorted =
- List.filter (fun { in_fish = b } -> b) all_functions_sorted in
-
- let all_functions_and_fish_commands_sorted =
- List.sort action_compare (all_functions_sorted @ fish_commands) in
pr "#include <config.h>\n";
pr "\n";
@@ -84,7 +80,7 @@ let generate_fish_cmds () =
fun { name = name } ->
pr "static int run_%s (const char *cmd, size_t argc, char *argv[]);\n"
name
- ) all_functions;
+ ) fish_functions;
pr "\n";
@@ -174,7 +170,7 @@ Guestfish will prompt for these separately."
pr " .run = run_%s\n" name;
pr "};\n";
pr "\n";
- ) all_functions;
+ ) fish_functions;
(* list_commands function, which implements guestfish -h *)
pr "void\n";
@@ -187,7 +183,7 @@ Guestfish will prompt for these separately."
let name = replace_char name '_' '-' in
pr " printf (\"%%-20s %%s\\n\", \"%s\", _(\"%s\"));\n"
name shortdesc
- ) all_functions_and_fish_commands_sorted;
+ ) fish_functions_and_commands_sorted;
pr " printf (\" %%s\\n\",";
pr " _(\"Use -h <cmd> / help <cmd> to show detailed help for a command.\"));\n";
pr "}\n";
@@ -288,7 +284,7 @@ Guestfish will prompt for these separately."
(* generate the function for typ *)
emit_print_list_function typ
| typ, _ -> () (* empty *)
- ) (rstructs_used_by all_functions);
+ ) (rstructs_used_by fish_functions);
(* Emit a print_TYPE function definition only if that function is used. *)
List.iter (
@@ -301,7 +297,7 @@ Guestfish will prompt for these separately."
pr "}\n";
pr "\n";
| typ, _ -> () (* empty *)
- ) (rstructs_used_by all_functions);
+ ) (rstructs_used_by fish_functions);
(* run_<action> actions *)
List.iter (
@@ -639,7 +635,7 @@ Guestfish will prompt for these separately."
pr " return ret;\n";
pr "}\n";
pr "\n"
- ) all_functions;
+ ) fish_functions;
(* run_action function *)
pr "int\n";
@@ -678,12 +674,6 @@ and generate_fish_cmds_h () =
and generate_fish_cmds_gperf () =
generate_header CStyle GPLv2plus;
- let all_functions_sorted =
- List.filter (fun { in_fish = b } -> b) all_functions_sorted in
-
- let all_functions_and_fish_commands_sorted =
- List.sort action_compare (all_functions_sorted @ fish_commands) in
-
pr "\
%%language=ANSI-C
%%define lookup-function-name lookup_fish_command
@@ -705,7 +695,7 @@ and generate_fish_cmds_gperf () =
List.iter (
fun { name = name } ->
pr "extern struct command_entry %s_cmd_entry;\n" name
- ) all_functions_and_fish_commands_sorted;
+ ) fish_functions_and_commands_sorted;
pr "\
%%}
@@ -732,15 +722,12 @@ struct command_table;
fun alias ->
pr "%s, &%s_cmd_entry\n" alias name;
) aliases;
- ) all_functions_and_fish_commands_sorted
+ ) fish_functions_and_commands_sorted
(* Readline completion for guestfish. *)
and generate_fish_completion () =
generate_header CStyle GPLv2plus;
- let all_functions =
- List.filter (fun { in_fish = b } -> b) all_functions in
-
pr "\
#include <config.h>
@@ -769,7 +756,7 @@ static const char *const commands[] = {
let aliases = get_aliases f in
let name2 = replace_char name '_' '-' in
name2 :: aliases
- ) (all_functions @ fish_commands) in
+ ) (fish_functions_and_commands_sorted) in
let commands = List.flatten commands in
List.iter (pr " \"%s\",\n") commands;
@@ -829,10 +816,9 @@ do_completion (const char *text, int start, int end)
(* Generate the POD documentation for guestfish. *)
and generate_fish_actions_pod () =
- let all_functions_sorted =
- List.filter (
- fun { in_fish = in_fish; in_docs = in_docs } -> in_fish && in_docs
- ) all_functions_sorted in
+ let fishdoc_functions_sorted =
+ List.filter is_documented fish_functions_sorted
+ in
let rex = Str.regexp "C<guestfs_\\([^>]+\\)>" in
@@ -895,7 +881,7 @@ Guestfish will prompt for these separately.\n\n";
match deprecation_notice ~replace_underscores:true f with
| None -> ()
| Some txt -> pr "%s\n\n" txt
- ) all_functions_sorted
+ ) fishdoc_functions_sorted
(* Generate documentation for guestfish-only commands. *)
and generate_fish_commands_pod () =
diff --git a/generator/gobject.ml b/generator/gobject.ml
index 519cb26..801ffb4 100644
--- a/generator/gobject.ml
+++ b/generator/gobject.ml
@@ -115,7 +115,7 @@ let filenames =
function
| { style = _, _, (_::_) } -> true
| { style = _, _, [] } -> false
- ) all_functions
+ ) external_functions
)
let header_start filename =
@@ -697,7 +697,7 @@ gboolean guestfs_session_close(GuestfsSession *session, GError **err);
fun ({ name = name; style = style } as f) ->
generate_gobject_proto name style f;
pr ";\n";
- ) all_functions;
+ ) external_functions;
header_end filename
@@ -1279,4 +1279,4 @@ guestfs_session_close(GuestfsSession *session, GError **err)
);
pr "}\n";
- ) all_functions
+ ) external_functions
diff --git a/generator/haskell.ml b/generator/haskell.ml
index 396eeb7..cee9e28 100644
--- a/generator/haskell.ml
+++ b/generator/haskell.ml
@@ -60,7 +60,7 @@ module Guestfs (
List.iter (
fun { name = name; style = style } ->
if can_generate style then pr ",\n %s" name
- ) all_functions;
+ ) external_functions;
pr "
) where
@@ -208,7 +208,7 @@ assocListOfHashtable (a:b:rest) = (a,b) : assocListOfHashtable rest
);
pr "\n";
)
- ) all_functions
+ ) external_functions
and generate_haskell_prototype ~handle ?(hs = false) (ret, args, optargs) =
pr "%s -> " handle;
diff --git a/generator/java.ml b/generator/java.ml
index 4375b81..45fb569 100644
--- a/generator/java.ml
+++ b/generator/java.ml
@@ -246,11 +246,11 @@ public class GuestFS {
(* Methods. *)
List.iter (
- fun ({ name = name; style = (ret, args, optargs as style);
- in_docs = in_docs; shortdesc = shortdesc;
- longdesc = longdesc; non_c_aliases = non_c_aliases } as f) ->
- if in_docs then (
- let doc = replace_str longdesc "C<guestfs_" "C<g." in
+ fun f ->
+ let ret, args, optargs = f.style in
+
+ if is_documented f then (
+ let doc = replace_str f.longdesc "C<guestfs_" "C<g." in
let doc =
if optargs <> [] then
doc ^ "\n\nOptional arguments are supplied in the final Map<String,Object> parameter, which is a hash of the argument name to its value (cast to Object). Pass an empty Map or null for no optional arguments."
@@ -263,7 +263,7 @@ public class GuestFS {
match deprecation_notice f with
| None -> doc
| Some txt -> doc ^ "\n\n" ^ txt in
- let doc = pod2text ~width:60 name doc in
+ let doc = pod2text ~width:60 f.name doc in
let doc = List.map ( (* RHBZ#501883 *)
function
| "" -> "<p>"
@@ -272,19 +272,19 @@ public class GuestFS {
let doc = String.concat "\n * " doc in
pr " /**\n";
- pr " * %s\n" shortdesc;
+ pr " * %s\n" f.shortdesc;
pr " * <p>\n";
pr " * %s\n" doc;
pr " * @throws LibGuestFSException\n";
pr " */\n";
);
pr " ";
- generate_java_prototype ~public:true ~semicolon:false name style;
+ generate_java_prototype ~public:true ~semicolon:false f.name f.style;
pr "\n";
pr " {\n";
pr " if (g == 0)\n";
pr " throw new LibGuestFSException (\"%s: handle is closed\");\n"
- name;
+ f.name;
if optargs <> [] then (
pr "\n";
pr " /* Unpack optional args. */\n";
@@ -313,12 +313,12 @@ public class GuestFS {
pr "\n";
(match ret with
| RErr ->
- pr " _%s " name;
- generate_java_call_args ~handle:"g" style;
+ pr " _%s " f.name;
+ generate_java_call_args ~handle:"g" f.style;
pr ";\n"
| RHashtable _ ->
- pr " String[] r = _%s " name;
- generate_java_call_args ~handle:"g" style;
+ pr " String[] r = _%s " f.name;
+ generate_java_call_args ~handle:"g" f.style;
pr ";\n";
pr "\n";
pr " HashMap<String, String> rhash = new HashMap<String, String> ();\n";
@@ -326,8 +326,8 @@ public class GuestFS {
pr " rhash.put (r[i], r[i+1]);\n";
pr " return rhash;\n"
| _ ->
- pr " return _%s " name;
- generate_java_call_args ~handle:"g" style;
+ pr " return _%s " f.name;
+ generate_java_call_args ~handle:"g" f.style;
pr ";\n"
);
pr " }\n";
@@ -340,14 +340,14 @@ public class GuestFS {
if optargs <> [] then (
pr " ";
generate_java_prototype ~public:true ~semicolon:false
- name (ret, args, []);
+ f.name (ret, args, []);
pr "\n";
pr " {\n";
(match ret with
| RErr -> pr " "
| _ -> pr " return "
);
- pr "%s (" name;
+ pr "%s (" f.name;
List.iter (fun arg -> pr "%s, " (name_of_argt arg)) args;
pr "null);\n";
pr " }\n";
@@ -358,14 +358,14 @@ public class GuestFS {
List.iter (
fun alias ->
pr " ";
- generate_java_prototype ~public:true ~semicolon:false alias style;
+ generate_java_prototype ~public:true ~semicolon:false alias f.style;
pr "\n";
pr " {\n";
(match ret with
| RErr -> pr " "
| _ -> pr " return "
);
- pr "%s (" name;
+ pr "%s (" f.name;
let needs_comma = ref false in
List.iter (
fun arg ->
@@ -392,20 +392,20 @@ public class GuestFS {
| RErr -> pr " "
| _ -> pr " return "
);
- pr "%s (" name;
+ pr "%s (" f.name;
List.iter (fun arg -> pr "%s, " (name_of_argt arg)) args;
pr "null);\n";
pr " }\n";
pr "\n"
)
- ) non_c_aliases;
+ ) f.non_c_aliases;
(* Prototype for the native method. *)
pr " ";
- generate_java_prototype ~privat:true ~native:true name style;
+ generate_java_prototype ~privat:true ~native:true f.name f.style;
pr "\n";
pr "\n";
- ) all_functions;
+ ) external_functions;
pr "}\n"
@@ -1099,7 +1099,7 @@ get_all_event_callbacks (guestfs_h *g, size_t *len_rtn)
pr "}\n";
pr "\n"
- ) all_functions
+ ) external_functions
and generate_java_struct_return typ jtyp cols =
pr " cl = (*env)->FindClass (env, \"com/redhat/et/libguestfs/%s\");\n" jtyp;
@@ -1190,7 +1190,7 @@ and generate_java_struct_list_return typ jtyp cols =
and generate_java_makefile_inc () =
generate_header HashStyle GPLv2plus;
- let jtyps = List.map (fun { s_camel_name = jtyp } -> jtyp) structs in
+ let jtyps = List.map (fun { s_camel_name = jtyp } -> jtyp) external_structs in
let jtyps = List.sort compare jtyps in
pr "java_built_sources = \\\n";
@@ -1200,7 +1200,7 @@ and generate_java_makefile_inc () =
pr "\tcom/redhat/et/libguestfs/GuestFS.java\n"
and generate_java_gitignore () =
- let jtyps = List.map (fun { s_camel_name = jtyp } -> jtyp) structs in
+ let jtyps = List.map (fun { s_camel_name = jtyp } -> jtyp) external_structs in
let jtyps = List.sort compare jtyps in
List.iter (pr "%s.java\n") jtyps
diff --git a/generator/lua.ml b/generator/lua.ml
index 042a8a0..1878844 100644
--- a/generator/lua.ml
+++ b/generator/lua.ml
@@ -107,7 +107,7 @@ static void free_strings (char **r);
| typ, (RStructListOnly | RStructAndList) ->
pr "static void push_%s (lua_State *L, struct guestfs_%s *v);\n" typ typ;
pr "static void push_%s_list (lua_State *L, struct guestfs_%s_list *v);\n" typ typ
- ) (rstructs_used_by all_functions);
+ ) (rstructs_used_by external_functions);
pr "\
@@ -629,7 +629,7 @@ guestfs_lua_delete_event_callback (lua_State *L)
pr " return 1;\n";
pr "}\n";
pr "\n"
- ) all_functions_sorted;
+ ) external_functions_sorted;
pr "\
static struct userdata *
@@ -866,7 +866,7 @@ push_event (lua_State *L, uint64_t event)
| typ, (RStructListOnly | RStructAndList) ->
generate_push_struct typ;
generate_push_struct_list typ
- ) (rstructs_used_by all_functions);
+ ) (rstructs_used_by external_functions);
pr "\
void
@@ -904,7 +904,7 @@ static luaL_Reg methods[] = {
List.iter (
fun { name = name } -> pr " { \"%s\", guestfs_lua_%s },\n" name name
- ) all_functions_sorted;
+ ) external_functions_sorted;
pr "\
diff --git a/generator/main.ml b/generator/main.ml
index 1d35a53..0216140 100644
--- a/generator/main.ml
+++ b/generator/main.ml
@@ -136,7 +136,7 @@ Run it from the top source directory using the command
let cols = cols_of_struct typ in
let filename = sprintf "java/com/redhat/et/libguestfs/%s.java" jtyp in
output_to filename (generate_java_struct jtyp cols)
- ) structs;
+ ) external_structs;
delete_except_generated
~skip:["java/com/redhat/et/libguestfs/LibGuestFSException.java";
"java/com/redhat/et/libguestfs/EventCallback.java"]
@@ -186,7 +186,7 @@ Run it from the top source directory using the command
output_to filename
(generate_gobject_optargs_source short name optargs f)
| { style = _, _, [] } -> ()
- ) all_functions;
+ ) external_functions;
delete_except_generated "gobject/include/guestfs-gobject/optargs-*.h";
delete_except_generated "gobject/src/optargs-*.c";
diff --git a/generator/ocaml.ml b/generator/ocaml.ml
index 0b1f96b..d922c0f 100644
--- a/generator/ocaml.ml
+++ b/generator/ocaml.ml
@@ -130,12 +130,12 @@ val user_cancel : t -> unit
(* The actions. *)
List.iter (
- fun { name = name; style = style; deprecated_by = deprecated_by;
+ fun ({ name = name; style = style; deprecated_by = deprecated_by;
non_c_aliases = non_c_aliases;
- in_docs = in_docs; shortdesc = shortdesc } ->
+ shortdesc = shortdesc } as f) ->
generate_ocaml_prototype name style;
- if in_docs then (
+ if is_documented f then (
pr "(** %s" shortdesc;
(match deprecated_by with
| None -> ()
@@ -152,7 +152,7 @@ val user_cancel : t -> unit
generate_ocaml_prototype alias style;
pr "\n";
) non_c_aliases;
- ) all_functions_sorted;
+ ) external_functions_sorted;
pr "\
(** {2 Object-oriented API}
@@ -203,7 +203,7 @@ class guestfs : ?environment:bool -> ?close_on_exit:bool -> unit -> object
generate_ocaml_function_type style;
pr "\n"
) non_c_aliases
- ) all_functions_sorted;
+ ) external_functions_sorted;
pr "end\n"
@@ -268,7 +268,7 @@ let () =
fun { name = name; style = style; non_c_aliases = non_c_aliases } ->
generate_ocaml_prototype ~is_external:true name style;
List.iter (fun alias -> pr "let %s = %s\n" alias name) non_c_aliases
- ) all_functions_sorted;
+ ) external_functions_sorted;
(* OO API. *)
pr "
@@ -297,7 +297,7 @@ class guestfs ?environment ?close_on_exit () =
);
List.iter
(fun alias -> pr " method %s = self#%s\n" alias name) non_c_aliases
- ) all_functions_sorted;
+ ) external_functions_sorted;
pr " end\n"
@@ -431,7 +431,7 @@ copy_table (char * const * argv)
(* generate the function for typ *)
emit_ocaml_copy_list_function typ
| typ, _ -> () (* empty *)
- ) (rstructs_used_by all_functions);
+ ) (rstructs_used_by external_functions);
(* The wrappers. *)
List.iter (
@@ -669,7 +669,7 @@ copy_table (char * const * argv)
pr "}\n";
pr "\n"
)
- ) all_functions_sorted
+ ) external_functions_sorted
and generate_ocaml_structure_decls () =
List.iter (
diff --git a/generator/perl.ml b/generator/perl.ml
index ddae5bb..9133bcf 100644
--- a/generator/perl.ml
+++ b/generator/perl.ml
@@ -560,7 +560,7 @@ user_cancel (g)
);
pr "\n"
- ) all_functions
+ ) external_functions
and generate_perl_struct_list_code typ cols name style n =
pr " if (r == NULL)\n";
@@ -858,10 +858,8 @@ handlers and threads.
* they are pulled in from the XS code automatically.
*)
List.iter (
- function
- | { in_docs = false } -> ()
- | ({ name = name; style = style; in_docs = true;
- longdesc = longdesc; non_c_aliases = non_c_aliases } as f) ->
+ fun ({ name = name; style = style;
+ longdesc = longdesc; non_c_aliases = non_c_aliases } as f) ->
let longdesc = replace_str longdesc "C<guestfs_" "C<$g-E<gt>" in
pr "=item ";
generate_perl_prototype name style;
@@ -891,7 +889,7 @@ handlers and threads.
pr "=pod\n";
pr "\n";
) non_c_aliases
- ) all_functions_sorted;
+ ) documented_functions_sorted;
pr "=cut\n\n";
@@ -956,7 +954,7 @@ handlers and threads.
pr " name => \"%s\",\n" name;
pr " description => %S,\n" shortdesc;
pr " },\n";
- ) all_functions_sorted;
+ ) external_functions_sorted;
pr ");\n\n";
pr "# Add aliases to the introspection hash.\n";
@@ -969,7 +967,7 @@ handlers and threads.
pr "$guestfs_introspection{%s} = \\%%ielem%d;\n" alias !i;
incr i
) non_c_aliases
- ) all_functions_sorted;
+ ) external_functions_sorted;
pr "\n";
(* End of file. *)
diff --git a/generator/php.ml b/generator/php.ml
index 4ed7b30..d457507 100644
--- a/generator/php.ml
+++ b/generator/php.ml
@@ -53,7 +53,7 @@ PHP_FUNCTION (guestfs_last_error);
List.iter (
fun { name = name } -> pr "PHP_FUNCTION (guestfs_%s);\n" name
- ) all_functions_sorted;
+ ) external_functions_sorted;
pr "\
@@ -113,7 +113,7 @@ static zend_function_entry guestfs_php_functions[] = {
List.iter (
fun { name = name } -> pr " PHP_FE (guestfs_%s, NULL)\n" name
- ) all_functions_sorted;
+ ) external_functions_sorted;
pr " { NULL, NULL, NULL }
};
@@ -506,7 +506,7 @@ PHP_FUNCTION (guestfs_last_error)
pr "}\n";
pr "\n"
- ) all_functions_sorted
+ ) external_functions_sorted
and generate_php_struct_code typ cols =
pr " array_init (return_value);\n";
diff --git a/generator/python.ml b/generator/python.ml
index 3863c71..64c5a8d 100644
--- a/generator/python.ml
+++ b/generator/python.ml
@@ -249,7 +249,7 @@ free_strings (char **argv)
(* generate the function for typ *)
emit_put_list_function typ
| typ, _ -> () (* empty *)
- ) (rstructs_used_by all_functions);
+ ) (rstructs_used_by external_functions);
(* Python wrapper functions. *)
List.iter (
@@ -528,7 +528,7 @@ free_strings (char **argv)
pr " return py_r;\n";
pr "}\n";
pr "\n"
- ) all_functions;
+ ) external_functions;
(* Table of functions. *)
pr "static PyMethodDef methods[] = {\n";
@@ -542,7 +542,7 @@ free_strings (char **argv)
fun { name = name } ->
pr " { (char *) \"%s\", py_guestfs_%s, METH_VARARGS, NULL },\n"
name name
- ) all_functions;
+ ) external_functions;
pr " { NULL, NULL, 0, NULL }\n";
pr "};\n";
pr "\n";
@@ -734,9 +734,9 @@ class GuestFS(object):
";
List.iter (
- fun ({ name = name; style = ret, args, optargs; in_docs = in_docs;
- longdesc = longdesc; non_c_aliases = non_c_aliases } as f) ->
- pr " def %s (self" name;
+ fun f ->
+ let ret, args, optargs = f.style in
+ pr " def %s (self" f.name;
List.iter (fun arg -> pr ", %s" (name_of_argt arg)) args;
List.iter (
fun optarg ->
@@ -744,8 +744,8 @@ class GuestFS(object):
) optargs;
pr "):\n";
- if in_docs then (
- let doc = replace_str longdesc "C<guestfs_" "C<g." in
+ if is_documented f then (
+ let doc = replace_str f.longdesc "C<guestfs_" "C<g." in
let doc =
match ret with
| RErr | RInt _ | RInt64 _ | RBool _
@@ -767,7 +767,7 @@ class GuestFS(object):
match deprecation_notice f with
| None -> doc
| Some txt -> doc ^ "\n\n" ^ txt in
- let doc = pod2text ~width:60 name doc in
+ let doc = pod2text ~width:60 f.name doc in
let doc = List.map (fun line -> replace_str line "\\" "\\\\") doc in
let doc = String.concat "\n " doc in
pr " \"\"\"%s\"\"\"\n" doc;
@@ -786,7 +786,7 @@ class GuestFS(object):
pr " %s = list (%s)\n" n n
) args;
pr " self._check_not_closed ()\n";
- pr " return libguestfsmod.%s (self._o" name;
+ pr " return libguestfsmod.%s (self._o" f.name;
List.iter (fun arg -> pr ", %s" (name_of_argt arg))
(args @ args_of_optargs optargs);
pr ")\n\n";
@@ -794,6 +794,6 @@ class GuestFS(object):
(* Aliases. *)
List.iter (
fun alias ->
- pr " %s = %s\n\n" alias name
- ) non_c_aliases
- ) all_functions
+ pr " %s = %s\n\n" alias f.name
+ ) f.non_c_aliases
+ ) external_functions
diff --git a/generator/ruby.ml b/generator/ruby.ml
index 0114aca..706c726 100644
--- a/generator/ruby.ml
+++ b/generator/ruby.ml
@@ -393,13 +393,12 @@ ruby_user_cancel (VALUE gv)
";
List.iter (
- fun ({ name = name; style = (ret, args, optargs as style);
- in_docs = in_docs;
- c_function = c_function; c_optarg_prefix = c_optarg_prefix;
- shortdesc = shortdesc; longdesc = longdesc } as f) ->
+ fun f ->
+ let ret, args, optargs = f.style in
+
(* Generate rdoc. *)
- if in_docs then (
- let doc = replace_str longdesc "C<guestfs_" "C<g." in
+ if is_documented f then (
+ let doc = replace_str f.longdesc "C<guestfs_" "C<g." in
let doc =
if optargs <> [] then
doc ^ "\n\nOptional arguments are supplied in the final hash parameter, which is a hash of the argument name to its value. Pass an empty {} for no optional arguments."
@@ -412,7 +411,7 @@ ruby_user_cancel (VALUE gv)
match deprecation_notice f with
| None -> doc
| Some txt -> doc ^ "\n\n" ^ txt in
- let doc = pod2text ~width:60 name doc in
+ let doc = pod2text ~width:60 f.name doc in
let doc = String.concat "\n * " doc in
let doc = trim doc in
@@ -452,7 +451,7 @@ ruby_user_cancel (VALUE gv)
* (For the C API documentation for this function, see
* +guestfs_%s+[http://libguestfs.org/guestfs.3.html#guestfs_%s]).
*/
-" name args ret shortdesc doc name name
+" f.name args ret f.shortdesc doc f.name f.name
);
(* Generate the function. Prototype is completely different
@@ -462,7 +461,7 @@ ruby_user_cancel (VALUE gv)
* http://stackoverflow.com/questions/7626745/extending-ruby-in-c-how-to-spe...
*)
pr "static VALUE\n";
- pr "ruby_guestfs_%s (" name;
+ pr "ruby_guestfs_%s (" f.name;
if optargs = [] then (
pr "VALUE gv";
List.iter
@@ -476,7 +475,7 @@ ruby_user_cancel (VALUE gv)
pr " Data_Get_Struct (gv, guestfs_h, g);\n";
pr " if (!g)\n";
pr " rb_raise (rb_eArgError, \"%%s: used handle after closing it\", \"%s\");\n"
- name;
+ f.name;
pr "\n";
(* For optargs case, get the arg VALUEs into local variables.
@@ -509,7 +508,7 @@ ruby_user_cancel (VALUE gv)
pr " const char *%s = RSTRING_PTR (%sv);\n" n n;
pr " if (!%s)\n" n;
pr " rb_raise (rb_eTypeError, \"expected string for parameter %%s of %%s\",\n";
- pr " \"%s\", \"%s\");\n" n name;
+ pr " \"%s\", \"%s\");\n" n f.name;
pr " size_t %s_size = RSTRING_LEN (%sv);\n" n n
| OptString n ->
pr " const char *%s = !NIL_P (%sv) ? StringValueCStr (%sv) : NULL;\n" n n n
@@ -541,8 +540,8 @@ ruby_user_cancel (VALUE gv)
(* Optional arguments are passed in a final hash parameter. *)
if optargs <> [] then (
pr " Check_Type (optargsv, T_HASH);\n";
- pr " struct %s optargs_s = { .bitmask = 0 };\n" c_function;
- pr " struct %s *optargs = &optargs_s;\n" c_function;
+ pr " struct %s optargs_s = { .bitmask = 0 };\n" f.c_function;
+ pr " struct %s *optargs = &optargs_s;\n" f.c_function;
pr " volatile VALUE v;\n";
List.iter (
fun argt ->
@@ -575,7 +574,7 @@ ruby_user_cancel (VALUE gv)
pr " optargs_s.%s = r;\n" n;
pr " }\n"
);
- pr " optargs_s.bitmask |= %s_%s_BITMASK;\n" c_optarg_prefix uc_n;
+ pr " optargs_s.bitmask |= %s_%s_BITMASK;\n" f.c_optarg_prefix uc_n;
pr " }\n";
) optargs;
pr "\n";
@@ -597,8 +596,8 @@ ruby_user_cancel (VALUE gv)
);
pr "\n";
- pr " r = %s " c_function;
- generate_c_call_args ~handle:"g" style;
+ pr " r = %s " f.c_function;
+ generate_c_call_args ~handle:"g" f.style;
pr ";\n";
List.iter (
@@ -674,7 +673,7 @@ ruby_user_cancel (VALUE gv)
pr "}\n";
pr "\n"
- ) all_functions;
+ ) external_functions;
pr "\
extern void Init__guestfs (void); /* keep GCC warnings happy */
@@ -727,7 +726,7 @@ Init__guestfs (void)
pr " rb_define_method (c_guestfs, \"%s\",\n" alias;
pr " ruby_guestfs_%s, %d);\n" name nr_args
) non_c_aliases
- ) all_functions;
+ ) external_functions;
pr "}\n"
diff --git a/generator/types.ml b/generator/types.ml
index 26bf746..c809d2b 100644
--- a/generator/types.ml
+++ b/generator/types.ml
@@ -370,6 +370,14 @@ and test_init =
and seq = cmd list
and cmd = string list
+type visibility =
+ | VPublic (* Part of the public API *)
+ | VStateTest (* A function which tests the state
+ of the appliance *)
+ | VBindTest (* Only used for testing language bindings *)
+ | VDebug (* Exported everywhere, but not documented *)
+ | VInternal (* Not exported *)
+
(* Type of an action as declared in Actions module. *)
type action = {
name : string; (* name, not including "guestfs_" *)
@@ -383,10 +391,7 @@ type action = {
protocol_limit_warning : bool; (* warn about protocol size limits *)
fish_alias : string list; (* alias(es) for this cmd in guestfish *)
fish_output : fish_output_t option; (* how to display output in guestfish *)
- in_fish : bool; (* export via guestfish *)
- in_docs : bool; (* add this function to documentation *)
- internal: bool; (* function is not part of the
- external api *)
+ visibility: visibility; (* The visbility of function *)
deprecated_by : string option; (* function is deprecated, use .. instead *)
optional : string option; (* function is part of an optional group *)
progress : bool; (* function can generate progress messages *)
--
1.8.1
11 years, 9 months