Compare commits

...

5 Commits

Author SHA1 Message Date
Richard W.M. Jones
8e30b9a955 Version 1.56.2. 2025-08-13 17:06:32 +01:00
Richard W.M. Jones
9c09d95dbd generator: Allow StringList(Pathname) parameters
This was previously not implemented.  It just requires us to call
ABS_PATH on each parameter.  ABS_PATH checks the parameter is an
absolute path.

(cherry picked from commit e4d9ee3fbc)
2025-08-13 16:09:40 +01:00
Richard W.M. Jones
396397ac8d generator: Implement StringList for OCaml functions
No existing OCaml functions have a StringList parameter, but we would
like to add one.

The original plan seems to have been to map these to 'string array'
types, but 'string list' is more natural, albeit marginally less
efficient.  The implementation here just has to convert the 'char **'
into the OCaml linked list of values.

(cherry picked from commit fd4db60cff)
2025-08-13 16:09:36 +01:00
Richard W.M. Jones
67a261c47a daemon: sysroot: Avoid copying the path every time we call sysroot ()
This path never changes once the daemon has started up, so we don't
need to call into C code and copy the string every time.

(cherry picked from commit c931ab3bc8)
2025-08-13 16:09:25 +01:00
Richard W.M. Jones
4a0a1e7cd7 daemon: sysroot: Avoid double-/ when creating sysroot paths in OCaml
Previously calling 'sysroot_path "/dev"' for example would return the
string "/sysroot//dev".  While this is not wrong, it confuses some
external programs (hello, setfiles), and it's not very "clean".  Be a
bit more careful to avoid doubling the '/' character in the common case.

(cherry picked from commit 1e0099671a)
2025-08-13 16:09:19 +01:00
10 changed files with 65 additions and 24 deletions

View File

@@ -20,8 +20,8 @@
# freeform string.
m4_define([libguestfs_major], [1])
m4_define([libguestfs_minor], [56])
m4_define([libguestfs_release], [1])
m4_define([release_date], [2025-06-16])
m4_define([libguestfs_release], [2])
m4_define([release_date], [2025-08-13])
AC_INIT([libguestfs],libguestfs_major.libguestfs_minor.libguestfs_release)
AC_SUBST([RELEASE_DATE],release_date)

View File

@@ -114,6 +114,30 @@ guestfs_int_daemon_copy_mountable (const mountable_t *mountable)
CAMLreturn (r);
}
/* Implement StringList(...) parameter. */
value
guestfs_int_daemon_copy_string_list (char * const *strs)
{
CAMLparam0 ();
CAMLlocal3 (v, tlv, rv);
size_t i;
/* We need to build the list backwards so start at the end. */
for (i = 0; strs[i] != NULL; ++i)
;
while (i > 0) {
--i;
v = caml_copy_string (strs[i]);
rv = caml_alloc (2, 0);
Store_field (rv, 0, v);
Store_field (rv, 1, tlv);
tlv = rv;
}
CAMLreturn (rv);
}
/* Implement RStringList. */
char **
guestfs_int_daemon_return_string_list (value retv)

View File

@@ -29,6 +29,7 @@
extern void guestfs_int_daemon_exn_to_reply_with_error (const char *func, value exn);
extern value guestfs_int_daemon_copy_mountable (const mountable_t *mountable);
extern value guestfs_int_daemon_copy_string_list (char * const *strs);
extern char **guestfs_int_daemon_return_string_list (value retv);
extern char *guestfs_int_daemon_return_string_mountable (value retv);
extern char **guestfs_int_daemon_return_string_mountable_list (value retv);

View File

@@ -28,10 +28,10 @@
#include "daemon.h"
extern value guestfs_int_daemon_sysroot (value unitv);
extern value guestfs_int_daemon_get_sysroot (value unitv);
value
guestfs_int_daemon_sysroot (value unitv)
guestfs_int_daemon_get_sysroot (value unitv)
{
return caml_copy_string (sysroot);
}

View File

@@ -18,6 +18,13 @@
open Std_utils
external sysroot : unit -> string = "guestfs_int_daemon_sysroot"
external get_sysroot : unit -> string = "guestfs_int_daemon_get_sysroot"
let sysroot_path path = sysroot () // path
let sysroot = lazy (get_sysroot ())
let sysroot () = Lazy.force sysroot
let sysroot_path path =
let sysroot = sysroot () in
if path = "" then sysroot
else if path.[0] = '/' then sysroot ^ path
else sysroot // path

View File

@@ -22,4 +22,4 @@ val sysroot : unit -> string
in default. *)
val sysroot_path : string -> string
(** Equivalent to calling [sysroot () // path] *)
(** Prepend [path] parameter with the sysroot. *)

View File

@@ -166,7 +166,6 @@ let () =
| StringList (FileIn, _)
| StringList (FileOut, _)
| StringList (Mountable, _)
| StringList (Pathname, _)
| StringList (Dev_or_Path, _)
| StringList (Mountable_or_Path, _)
| StringList (Key, _)

View File

@@ -173,7 +173,7 @@ let generate_daemon_stubs actions () =
| String ((Mountable|Mountable_or_Path), n) ->
pr " CLEANUP_FREE_MOUNTABLE mountable_t %s\n" n;
pr " = { .device = NULL, .volume = NULL };\n"
| StringList ((PlainString|Filename), n) ->
| StringList ((PlainString|Filename|Pathname), n) ->
pr " char **%s;\n" n
| StringList (Device, n) ->
pr " CLEANUP_FREE_STRING_LIST char **%s = NULL;\n" n
@@ -184,7 +184,7 @@ let generate_daemon_stubs actions () =
pr " const char *%s;\n" n;
pr " size_t %s_size;\n" n
| String ((FileIn|FileOut|Filename), _)
| StringList ((Mountable|Pathname|FileIn|FileOut|Key|GUID
| StringList ((Mountable|FileIn|FileOut|Key|GUID
|Dev_or_Path|Mountable_or_Path), _)
| Pointer _ -> assert false
) args_passed_to_daemon
@@ -260,7 +260,7 @@ let generate_daemon_stubs actions () =
n n is_filein;
| String ((PlainString|Key|GUID), n) -> pr_args n
| OptString n -> pr " %s = args.%s ? *args.%s : NULL;\n" n n n
| StringList ((PlainString|Filename) as arg, n) ->
| StringList ((PlainString|Filename|Pathname) as arg, n) ->
(match arg with
| Filename ->
pr " {\n";
@@ -275,6 +275,14 @@ let generate_daemon_stubs actions () =
pr " }\n";
pr " }\n";
pr " }\n"
| Pathname ->
pr " {\n";
pr " size_t i;\n";
pr " for (i = 0; i < args.%s.%s_len; ++i) {\n" n n;
pr " ABS_PATH (args.%s.%s_val[i], %b, return);\n"
n n is_filein;
pr " }\n";
pr " }\n"
| _ -> ()
);
pr " /* Ugly, but safe and avoids copying the strings. */\n";
@@ -307,7 +315,7 @@ let generate_daemon_stubs actions () =
pr " %s = args.%s.%s_val;\n" n n n;
pr " %s_size = args.%s.%s_len;\n" n n n
| String ((FileIn|FileOut|Filename), _)
| StringList ((Mountable|Pathname|FileIn|FileOut|Key|GUID
| StringList ((Mountable|FileIn|FileOut|Key|GUID
|Dev_or_Path|Mountable_or_Path), _)
| Pointer _ -> assert false
) args_passed_to_daemon;
@@ -558,7 +566,7 @@ and generate_ocaml_daemon_prototype name (ret, args, optargs) =
| OInt n -> pr "?%s:int -> " n
| OInt64 n -> pr "?%s:int64 -> " n
| OString n -> pr "?%s:string -> " n
| OStringList n -> pr "?%s:string array -> " n
| OStringList n -> pr "?%s:string list -> " n
) optargs;
if args <> [] then
List.iter (
@@ -566,7 +574,7 @@ and generate_ocaml_daemon_prototype name (ret, args, optargs) =
| String (typ, _) -> pr "%s -> " (type_for_stringt typ)
| BufferIn _ -> pr "string -> "
| OptString _ -> pr "string option -> "
| StringList (typ, _) -> pr "%s array -> " (type_for_stringt typ)
| StringList (typ, _) -> pr "%s list -> " (type_for_stringt typ)
| Bool _ -> pr "bool -> "
| Int _ -> pr "int -> "
| Int64 _ | Pointer _ -> pr "int64 -> "
@@ -820,6 +828,8 @@ let generate_daemon_caml_stubs () =
pr "guestfs_int_daemon_copy_mountable (%s)" n
| String _ -> assert false
| OptString _ -> assert false
| StringList ((PlainString|Filename|Pathname), n) ->
pr "guestfs_int_daemon_copy_string_list (%s)" n
| StringList _ -> assert false
| BufferIn _ -> assert false
| Pointer _ -> assert false

View File

@@ -6,9 +6,9 @@
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: libguestfs 1.56.1\n"
"Project-Id-Version: libguestfs 1.56.2\n"
"Report-Msgid-Bugs-To: guestfs@lists.libguestfs.org\n"
"POT-Creation-Date: 2025-06-16 16:52+0100\n"
"POT-Creation-Date: 2025-08-13 17:00+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -45585,8 +45585,8 @@ msgstr ""
#. type: textblock
#: fish/guestfish-actions.pod:1524 lib/guestfs-actions.pod:2561
msgid ""
"Bug or feature? You decide: "
"L<https://www.tuxera.com/community/ntfs-3g-faq/#posixfilenames1>"
"Bug or feature? You decide. See the relevant entry in the ntfs-3g FAQ: "
"L<https://github.com/tuxera/ntfs-3g/wiki/NTFS-3G-FAQ>"
msgstr ""
#. type: textblock
@@ -91279,7 +91279,7 @@ msgstr ""
#. type: textblock
#: lib/guestfs.pod:987
msgid "L<http://www.tuxera.com/community/ntfs-3g-advanced/junction-points-and-symbolic-links/>"
msgid "L<https://github.com/tuxera/ntfs-3g/wiki/Junctions-Points,-Symbolic-Links-and-Reparse-Points>"
msgstr ""
#. type: textblock
@@ -91315,7 +91315,7 @@ msgstr ""
#. type: textblock
#: lib/guestfs.pod:1006
msgid "L<http://www.tuxera.com/community/ntfs-3g-advanced/extended-attributes/>"
msgid "L<https://github.com/tuxera/ntfs-3g/wiki/Using-Extended-Attributes>"
msgstr ""
#. type: =head3

View File

@@ -6,10 +6,10 @@
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: libguestfs 1.56.1\n"
"Project-Id-Version: libguestfs 1.56.2\n"
"Report-Msgid-Bugs-To: https://bugzilla.redhat.com/enter_bug.cgi?"
"component=libguestfs&product=Virtualization+Tools\n"
"POT-Creation-Date: 2025-06-16 16:52+0100\n"
"POT-Creation-Date: 2025-08-13 17:00+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -4028,11 +4028,11 @@ msgstr ""
msgid "could not get UUID from libvirt secret"
msgstr ""
#: lib/launch-libvirt.c:2187
#: lib/launch-libvirt.c:2193
msgid "could not destroy libvirt domain"
msgstr ""
#: lib/launch-libvirt.c:2208 lib/launch-libvirt.c:2241
#: lib/launch-libvirt.c:2214 lib/launch-libvirt.c:2247
#, c-format
msgid "%s: internal error forming error message"
msgstr ""