Richard W.M. Jones
2013-Aug-24 12:36 UTC
[Libguestfs] [PATCH 00/46] Proposed patches for libguestfs 1.20.11.
Tested with 'make check-release'. tests/parallel (in check-slow) failed, although it does regularly and that seems to be because of libvirt. Rich.
Richard W.M. Jones
2013-Aug-24 12:36 UTC
[Libguestfs] [PATCH 01/46] generator: Fix whitespace.
From: "Richard W.M. Jones" <rjones@redhat.com> (cherry picked from commit 559bd48960f795dc59d889e5776f545f2e0d494a) (cherry picked from commit a7f6822c1f05e2880900f997b8b487f76208354e) --- generator/xdr.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generator/xdr.ml b/generator/xdr.ml index 3b79b33..c59a30e 100644 --- a/generator/xdr.ml +++ b/generator/xdr.ml @@ -92,7 +92,7 @@ let generate_xdr () pr "/* Function arguments and return values. */\n"; pr "\n"; List.iter ( - fun { name =shortname; style = ret, args, optargs } -> + fun { name = shortname; style = ret, args, optargs } -> let name = "guestfs_" ^ shortname in (* Ordinary arguments and optional arguments are concatenated -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:36 UTC
[Libguestfs] [PATCH 02/46] generator: Fix the case where a daemon function has one FileIn/FileOut parameter and no other parameters.
From: "Richard W.M. Jones" <rjones@redhat.com> The FileIn/FileOut parameters are not passed through to the daemon. Previously we generated incorrect RPC code (an empty 'struct guestfs_<fn>_args') because we didn't account for these FileIn/FileOut parameters correctly. (cherry picked from commit e31c32ce1bc87d164103e79288effc64bb41181f) (cherry picked from commit 1af2e2c9de6920fb1ef9c83d9069cf9a573c5b8f) --- generator/c.ml | 12 +++++++----- generator/daemon.ml | 26 ++++++++++++++++---------- generator/xdr.ml | 11 +++++++---- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/generator/c.ml b/generator/c.ml index 143ce22..45dad8f 100644 --- a/generator/c.ml +++ b/generator/c.ml @@ -1305,7 +1305,10 @@ and generate_client_actions hash () handle_null_optargs optargs c_name; - (match args with + let args_passed_to_daemon + List.filter (function FileIn _ | FileOut _ -> false | _ -> true) + args in + (match args_passed_to_daemon with | [] -> () | _ -> pr " struct guestfs_%s_args args;\n" name ); @@ -1373,7 +1376,7 @@ and generate_client_actions hash () pr "\n"; (* Send the main header and arguments. *) - if args = [] && optargs = [] then ( + if args_passed_to_daemon = [] && optargs = [] then ( pr " serial = guestfs___send (g, GUESTFS_PROC_%s, progress_hint, 0,\n" (String.uppercase name); pr " NULL, NULL);\n" @@ -1393,7 +1396,6 @@ and generate_client_actions hash () pr " args.%s = %s;\n" n n | Int64 n -> pr " args.%s = %s;\n" n n - | FileIn _ | FileOut _ -> () | BufferIn n -> pr " /* Just catch grossly large sizes. XDR encoding will make this precise. */\n"; pr " if (%s_size >= GUESTFS_MESSAGE_MAX) {\n" n; @@ -1404,8 +1406,8 @@ and generate_client_actions hash () pr " }\n"; pr " args.%s.%s_val = (char *) %s;\n" n n n; pr " args.%s.%s_len = %s_size;\n" n n n - | Pointer _ -> assert false - ) args; + | FileIn _ | FileOut _ | Pointer _ -> assert false + ) args_passed_to_daemon; List.iter ( fun argt -> diff --git a/generator/daemon.ml b/generator/daemon.ml index 9362b3f..5b5504c 100644 --- a/generator/daemon.ml +++ b/generator/daemon.ml @@ -56,7 +56,11 @@ let generate_daemon_actions_h () List.iter ( fun { name = name; style = ret, args, optargs } -> - let style = ret, args @ args_of_optargs optargs, [] in + let args_passed_to_daemon = args @ args_of_optargs optargs in + let args_passed_to_daemon + List.filter (function FileIn _ | FileOut _ -> false | _ -> true) + args_passed_to_daemon in + let style = ret, args_passed_to_daemon, [] in generate_prototype ~single_line:true ~newline:true ~in_daemon:true ~prefix:"do_" name style; @@ -107,7 +111,11 @@ and generate_daemon_actions () pr " char *r;\n" ); - if args <> [] || optargs <> [] then ( + let args_passed_to_daemon = args @ args_of_optargs optargs in + let args_passed_to_daemon + List.filter (function FileIn _ | FileOut _ -> false | _ -> true) + args_passed_to_daemon in + if args_passed_to_daemon <> [] then ( pr " struct guestfs_%s_args args;\n" name; List.iter ( function @@ -120,12 +128,11 @@ and generate_daemon_actions () | Bool n -> pr " int %s;\n" n | Int n -> pr " int %s;\n" n | Int64 n -> pr " int64_t %s;\n" n - | FileIn _ | FileOut _ -> () | BufferIn n -> pr " const char *%s;\n" n; pr " size_t %s_size;\n" n - | Pointer _ -> assert false - ) (args @ args_of_optargs optargs) + | FileIn _ | FileOut _ | Pointer _ -> assert false + ) args_passed_to_daemon ); pr "\n"; @@ -175,7 +182,7 @@ and generate_daemon_actions () pr "\n"; (* Decode arguments. *) - if args <> [] || optargs <> [] then ( + if args_passed_to_daemon <> [] then ( pr " memset (&args, 0, sizeof args);\n"; pr "\n"; pr " if (!xdr_guestfs_%s_args (xdr_in, &args)) {\n" name; @@ -231,12 +238,11 @@ and generate_daemon_actions () | Bool n -> pr " %s = args.%s;\n" n n | Int n -> pr " %s = args.%s;\n" n n | Int64 n -> pr " %s = args.%s;\n" n n - | FileIn _ | FileOut _ -> () | BufferIn n -> pr " %s = args.%s.%s_val;\n" n n n; pr " %s_size = args.%s.%s_len;\n" n n n - | Pointer _ -> assert false - ) (args @ args_of_optargs optargs); + | FileIn _ | FileOut _ | Pointer _ -> assert false + ) args_passed_to_daemon; pr "\n" ); @@ -341,7 +347,7 @@ and generate_daemon_actions () (* Free the args. *) pr "done:\n"; - (match args with + (match args_passed_to_daemon with | [] -> () | _ -> pr " xdr_free ((xdrproc_t) xdr_guestfs_%s_args, (char *) &args);\n" diff --git a/generator/xdr.ml b/generator/xdr.ml index c59a30e..bbbfd8b 100644 --- a/generator/xdr.ml +++ b/generator/xdr.ml @@ -98,9 +98,13 @@ let generate_xdr () (* Ordinary arguments and optional arguments are concatenated * together in the XDR args struct. The optargs_bitmask field * in the header controls which optional arguments are - * meaningful. + * meaningful. FileIn/FileOut parameters are ignored here. *) - (match args @ args_of_optargs optargs with + let args_passed_to_daemon = args @ args_of_optargs optargs in + let args_passed_to_daemon + List.filter (function FileIn _ | FileOut _ -> false | _ -> true) + args_passed_to_daemon in + (match args_passed_to_daemon with | [] -> () | args -> pr "struct %s_args {\n" name; @@ -115,8 +119,7 @@ let generate_xdr () | Int64 n -> pr " int64_t %s;\n" n | BufferIn n -> pr " opaque %s<>;\n" n - | FileIn _ | FileOut _ -> () - | Pointer _ -> assert false + | FileIn _ | FileOut _ | Pointer _ -> assert false ) args; pr "};\n\n" ); -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:36 UTC
[Libguestfs] [PATCH 03/46] src/file.c: Be sure to call guestfs___lazy_make_tmpdir before using g->tmpdir.
From: "Richard W.M. Jones" <rjones@redhat.com> Although g->tmpdir is always set after launch, and none of these calls should be used before launch, it's always possible that a caller would use one of these APIs before launching the handle. If guestfs___lazy_make_tmpdir is not called, then g->tmpdir is NULL, and the constructed filename would look like "(null)/...". In fact it's possible to observe this error (although it seems to have no especially bad effects): $ strace guestfish ls / |& fgrep '(null)' unlink("(null)/ls1") = -1 ENOENT (No such file or directory) (cherry picked from commit 1937108a4a6070750f0d636f7dcc8725441cc4eb) (cherry picked from commit 749a2ccbf12865707927c34bc7d6b296bfa1717e) --- src/file.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/file.c b/src/file.c index f685936..3eef820 100644 --- a/src/file.c +++ b/src/file.c @@ -88,6 +88,9 @@ guestfs__read_file (guestfs_h *g, const char *path, size_t *size_r) char *ret = NULL; struct stat statbuf; + if (guestfs___lazy_make_tmpdir (g) == -1) + goto err; + tmpfile = safe_asprintf (g, "%s/cat%d", g->tmpdir, ++g->unique); if (guestfs_download (g, path, tmpfile) == -1) @@ -212,6 +215,9 @@ guestfs__find (guestfs_h *g, const char *directory) char **ret = NULL; size_t i, count, size; + if (guestfs___lazy_make_tmpdir (g) == -1) + goto err; + tmpfile = safe_asprintf (g, "%s/find%d", g->tmpdir, ++g->unique); if (guestfs_find0 (g, directory, tmpfile) == -1) @@ -313,6 +319,9 @@ write_or_append (guestfs_h *g, const char *path, (!append ? guestfs_internal_write : guestfs_internal_write_append) (g, path, content, size); + if (guestfs___lazy_make_tmpdir (g) == -1) + goto err; + /* Write the content out to a temporary file. */ tmpfile = safe_asprintf (g, "%s/write%d", g->tmpdir, ++g->unique); @@ -508,6 +517,9 @@ guestfs__ls (guestfs_h *g, const char *directory) char **ret = NULL; size_t i, count, size; + if (guestfs___lazy_make_tmpdir (g) == -1) + goto err; + tmpfile = safe_asprintf (g, "%s/ls%d", g->tmpdir, ++g->unique); if (guestfs_ls0 (g, directory, tmpfile) == -1) -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:36 UTC
[Libguestfs] [PATCH 04/46] resize: Link to information about dracut-modules-growroot.
From: "Richard W.M. Jones" <rjones@redhat.com> (cherry picked from commit fb282e677c015de65627790a02aceb6ed264ed80) (cherry picked from commit 64b67377b6536b09832ae7ee35573ce44c628365) --- resize/virt-resize.pod | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/resize/virt-resize.pod b/resize/virt-resize.pod index 6bb4612..7221fd5 100644 --- a/resize/virt-resize.pod +++ b/resize/virt-resize.pod @@ -701,6 +701,10 @@ hand-calculating sector offsets, which is something that virt-resize was designed to avoid. If you want to see the guestfish-equivalent commands that virt-resize runs, use the I<--debug> flag. +L<dracut(8)> includes a module called C<dracut-modules-growroot> which +can be used to grow the root partition when the guest first boots up. +There is documentation for this module in an associated README file. + =head1 SHELL QUOTING Libvirt guest names can contain arbitrary characters, some of which -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:36 UTC
[Libguestfs] [PATCH 05/46] daemon: cap-get-file: Return empty string if no capability on file (RHBZ#989356).
From: "Richard W.M. Jones" <rjones@redhat.com> Return an empty string (instead of an error) if no capabilities are set on a file, and document that in the API. (cherry picked from commit c663ab3bb9ab02fb3ca6209333c2d5402081c4de) (cherry picked from commit 01df523fffebfb586baac869f3e4febb8d79ce45) --- daemon/cap.c | 12 ++++++++++++ generator/actions.ml | 4 +++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/daemon/cap.c b/daemon/cap.c index d1f0398..1d732c5 100644 --- a/daemon/cap.c +++ b/daemon/cap.c @@ -48,6 +48,18 @@ do_cap_get_file (const char *path) CHROOT_OUT; if (cap == NULL) { + /* The getcap utility (part of libcap) ignores ENODATA. It just + * means there is no capability attached to the file (RHBZ#989356). + */ + if (errno == ENODATA) { + ret = strdup (""); + if (ret == NULL) { + reply_with_perror ("strdup"); + return NULL; + } + return ret; + } + reply_with_perror ("%s", path); return NULL; } diff --git a/generator/actions.ml b/generator/actions.ml index f202b9f..b0f93d2 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@ -10529,7 +10529,9 @@ attached to directory C<dir>." }; shortdesc = "get the Linux capabilities attached to a file"; longdesc = "\ This function returns the Linux capabilities attached to C<path>. -The capabilities set is returned in text form (see L<cap_to_text(3)>)." }; +The capabilities set is returned in text form (see L<cap_to_text(3)>). + +If no capabilities are attached to a file, an empty string is returned." }; { defaults with name = "cap_set_file"; -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:36 UTC
[Libguestfs] [PATCH 06/46] resize: Move isatty_stdout function to separate module (TTY.isatty_stdout).
From: "Richard W.M. Jones" <rjones@redhat.com> It was jammed into the Progress module just for convenience. (cherry picked from commit b56990ddf8aa4dc4db3da592783acfe055c05534) (cherry picked from commit 93daf42b52446eb442c595592a053caaa740ba42) --- po/POTFILES | 1 + po/POTFILES-ml | 1 + resize/Makefile.am | 7 ++++++- resize/progress-c.c | 9 --------- resize/progress.ml | 3 +-- resize/tTY.ml | 19 +++++++++++++++++++ resize/tTY.mli | 23 +++++++++++++++++++++++ resize/tty-c.c | 35 +++++++++++++++++++++++++++++++++++ sparsify/Makefile.am | 2 ++ 9 files changed, 88 insertions(+), 12 deletions(-) create mode 100644 resize/tTY.ml create mode 100644 resize/tTY.mli create mode 100644 resize/tty-c.c diff --git a/po/POTFILES b/po/POTFILES index e64492b..a98535e 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -220,6 +220,7 @@ python/guestfs-py.c rescue/test-virt-rescue.pl rescue/virt-rescue.c resize/progress-c.c +resize/tty-c.c ruby/ext/guestfs/_guestfs.c src/actions-0.c src/actions-1.c diff --git a/po/POTFILES-ml b/po/POTFILES-ml index 566c6ae..34533ea 100644 --- a/po/POTFILES-ml +++ b/po/POTFILES-ml @@ -3,6 +3,7 @@ resize/common_utils.ml resize/common_utils_tests.ml resize/progress.ml resize/resize.ml +resize/tTY.ml sparsify/sparsify.ml sysprep/firstboot.ml sysprep/main.ml diff --git a/resize/Makefile.am b/resize/Makefile.am index ca258b1..2431e34 100644 --- a/resize/Makefile.am +++ b/resize/Makefile.am @@ -32,16 +32,21 @@ SOURCES = \ progress-c.c \ progress.mli \ progress.ml \ - resize.ml + resize.ml \ + tty-c.c \ + tTY.mli \ + tTY.ml if HAVE_OCAML # Note this list must be in dependency order. OBJECTS = \ $(top_builddir)/fish/guestfish-progress.o \ + tty-c.o \ progress-c.o \ common_gettext.cmx \ common_utils.cmx \ + tTY.cmx \ progress.cmx \ resize.cmx diff --git a/resize/progress-c.c b/resize/progress-c.c index 2813d0c..67913eb 100644 --- a/resize/progress-c.c +++ b/resize/progress-c.c @@ -104,12 +104,3 @@ virt_resize_progress_bar_set (value barv, CAMLreturn (Val_unit); } - -/* RHEL 5-era ocaml didn't have Unix.isatty. */ -value -virt_resize_isatty_stdout (value unitv) -{ - CAMLparam1 (unitv); - - CAMLreturn (isatty(1) ? Val_true : Val_false); -} diff --git a/resize/progress.ml b/resize/progress.ml index 1ff73c2..e53e693 100644 --- a/resize/progress.ml +++ b/resize/progress.ml @@ -28,13 +28,12 @@ external progress_bar_reset : progress_bar -> unit = "virt_resize_progress_bar_reset" external progress_bar_set : progress_bar -> int64 -> int64 -> unit = "virt_resize_progress_bar_set" -external isatty_stdout : unit -> bool = "virt_resize_isatty_stdout" let set_up_progress_bar ?(machine_readable = false) (g : Guestfs.guestfs) (* Only display progress bars if the machine_readable flag is set or * the output is a tty. *) - if machine_readable || isatty_stdout () then ( + if machine_readable || TTY.isatty_stdout () then ( (* Initialize the C mini library. *) let bar = progress_bar_init ~machine_readable in diff --git a/resize/tTY.ml b/resize/tTY.ml new file mode 100644 index 0000000..32c1f54 --- /dev/null +++ b/resize/tTY.ml @@ -0,0 +1,19 @@ +(* virt-resize + * Copyright (C) 2013 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *) + +external isatty_stdout : unit -> bool = "virt_resize_isatty_stdout" diff --git a/resize/tTY.mli b/resize/tTY.mli new file mode 100644 index 0000000..69441f1 --- /dev/null +++ b/resize/tTY.mli @@ -0,0 +1,23 @@ +(* virt-resize + * Copyright (C) 2013 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + *) + +(** TTY utilities. *) + +val isatty_stdout : unit -> bool +(** RHEL 5-era ocaml didn't have Unix.isatty. This is not needed in + recent OCaml. *) diff --git a/resize/tty-c.c b/resize/tty-c.c new file mode 100644 index 0000000..040a132 --- /dev/null +++ b/resize/tty-c.c @@ -0,0 +1,35 @@ +/* virt-resize - interface to isatty + * Copyright (C) 2013 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include <config.h> + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +#include <caml/memory.h> +#include <caml/mlvalues.h> + +/* RHEL 5-era ocaml didn't have Unix.isatty. */ +value +virt_resize_isatty_stdout (value unitv) +{ + CAMLparam1 (unitv); + + CAMLreturn (isatty (1) ? Val_true : Val_false); +} diff --git a/sparsify/Makefile.am b/sparsify/Makefile.am index 61a560d..3bc1d0e 100644 --- a/sparsify/Makefile.am +++ b/sparsify/Makefile.am @@ -33,9 +33,11 @@ if HAVE_OCAML # Note this list must be in dependency order. OBJECTS = \ $(top_builddir)/fish/guestfish-progress.o \ + $(top_builddir)/resize/tty-c.o \ $(top_builddir)/resize/progress-c.o \ $(top_builddir)/resize/common_gettext.cmx \ $(top_builddir)/resize/common_utils.cmx \ + $(top_builddir)/resize/tTY.cmx \ $(top_builddir)/resize/progress.cmx \ sparsify.cmx -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:36 UTC
[Libguestfs] [PATCH 07/46] internal: Add CLEANUP_XMLFREEURI (cleanup function for xmlURIPtr).
From: "Richard W.M. Jones" <rjones@redhat.com> (cherry picked from commit 0e1ba00059b5ebbca2e137f2685b2eb65ed33b13) (cherry picked from commit acba583d18644bb0bb120f5c2302254c65d981dc) --- src/cleanup.c | 10 ++++++++++ src/guestfs-internal-frontend.h | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/src/cleanup.c b/src/cleanup.c index 000ce5e..ef2e8ed 100644 --- a/src/cleanup.c +++ b/src/cleanup.c @@ -24,6 +24,7 @@ #include <string.h> #ifdef HAVE_LIBXML2 +#include <libxml/uri.h> #include <libxml/tree.h> #include <libxml/xpath.h> #include <libxml/xmlwriter.h> @@ -97,6 +98,15 @@ guestfs___cleanup_xmlFreeDoc (void *ptr) } void +guestfs___cleanup_xmlFreeURI (void *ptr) +{ + xmlURIPtr uri = * (xmlURIPtr *) ptr; + + if (uri) + xmlFreeURI (uri); +} + +void guestfs___cleanup_xmlFreeTextWriter (void *ptr) { #ifdef HAVE_LIBXML2 diff --git a/src/guestfs-internal-frontend.h b/src/guestfs-internal-frontend.h index 85594be..e4bf50c 100644 --- a/src/guestfs-internal-frontend.h +++ b/src/guestfs-internal-frontend.h @@ -47,6 +47,8 @@ __attribute__((cleanup(guestfs___cleanup_xmlBufferFree))) #define CLEANUP_XMLFREEDOC \ __attribute__((cleanup(guestfs___cleanup_xmlFreeDoc))) +#define CLEANUP_XMLFREEURI \ + __attribute__((cleanup(guestfs___cleanup_xmlFreeURI))) #define CLEANUP_XMLFREETEXTWRITER \ __attribute__((cleanup(guestfs___cleanup_xmlFreeTextWriter))) #define CLEANUP_XMLXPATHFREECONTEXT \ @@ -60,6 +62,7 @@ #define CLEANUP_UNLINK_FREE #define CLEANUP_XMLBUFFERFREE #define CLEANUP_XMLFREEDOC +#define CLEANUP_XMLFREEURI #define CLEANUP_XMLFREETEXTWRITER #define CLEANUP_XMLXPATHFREECONTEXT #define CLEANUP_XMLXPATHFREEOBJECT @@ -102,6 +105,7 @@ extern void guestfs___cleanup_hash_free (void *ptr); extern void guestfs___cleanup_unlink_free (void *ptr); extern void guestfs___cleanup_xmlBufferFree (void *ptr); extern void guestfs___cleanup_xmlFreeDoc (void *ptr); +extern void guestfs___cleanup_xmlFreeURI (void *ptr); extern void guestfs___cleanup_xmlFreeTextWriter (void *ptr); extern void guestfs___cleanup_xmlXPathFreeContext (void *ptr); extern void guestfs___cleanup_xmlXPathFreeObject (void *ptr); -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:36 UTC
[Libguestfs] [PATCH 08/46] FAQ: Common problem with Debian is not running update-guestfs-appliance.
From: "Richard W.M. Jones" <rjones@redhat.com> (cherry picked from commit 9268f1487970eb9884ba674ab75dc99f91adc0a7) (cherry picked from commit 5bd7e6cca1c404d4a54f9ce3b231052bd98d86b4) --- examples/guestfs-faq.pod | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/examples/guestfs-faq.pod b/examples/guestfs-faq.pod index d083378..67e7c00 100644 --- a/examples/guestfs-faq.pod +++ b/examples/guestfs-faq.pod @@ -153,6 +153,13 @@ To get further information about the failure, you have to run: If, after using this, you still don't understand the failure, contact us (see previous section). +=head2 libguestfs: error: cannot find any suitable libguestfs supermin, fixed or old-style appliance on LIBGUESTFS_PATH + +If you see this error on Debian/Ubuntu, you need to run the following +command as root: + + update-guestfs-appliance + =head2 Non-ASCII characters don't appear on VFAT filesystems. Typical symptoms of this problem: -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:36 UTC
[Libguestfs] [PATCH 09/46] FAQ: Tips about using direct backend and fixed appliance on Fedora/RHEL.
From: "Richard W.M. Jones" <rjones@redhat.com> (cherry picked from commit 0c512a52bdc2a88296d04900625822b34d567112) (cherry picked from commit 790852397edf0c2a343e1125148a6909d0e4bb94) --- examples/guestfs-faq.pod | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/examples/guestfs-faq.pod b/examples/guestfs-faq.pod index 67e7c00..1440b53 100644 --- a/examples/guestfs-faq.pod +++ b/examples/guestfs-faq.pod @@ -532,6 +532,66 @@ to ensure libguestfs is basically working. =back +=head2 Errors during launch on Fedora E<ge> 18, RHEL E<ge> 7 + +In Fedora E<ge> 18 and RHEL E<ge> 7, libguestfs uses libvirt to manage +the appliance. Previously (and upstream) libguestfs runs qemu +directly: + + +----------------------------------+ + | libguestfs | + +----------------+-----------------+ + | direct backend | libvirt backend | + +----------------+-----------------+ + | | + v v + +-------+ +----------+ + | qemu | | libvirtd | + +-------+ +----------+ + | + v + +-------+ + | qemu | + +-------+ + + upstream Fedora 18+ + non-Fedora RHEL 7+ + non-RHEL + +The libvirt backend is more sophisticated, supporting SELinux/sVirt +(see above), hotplugging and more. It is, however, more complex and +so less robust. + +If you have permissions problems using the libvirt backend, you can +switch to the direct backend by setting this environment variable: + + export LIBGUESTFS_BACKEND=direct + +before running any libguestfs program or virt tool. + +=head2 How can I switch to a fixed / prebuilt appliance? + +This may improve the stability and performance of libguestfs on Fedora +and RHEL. + +Any time after installing libguestfs, run the following commands as +root: + + mkdir -p /usr/local/lib/guestfs/appliance + libguestfs-make-fixed-appliance /usr/local/lib/guestfs/appliance + ls -l /usr/local/lib/guestfs/appliance + +Now set the following environment variable before using libguestfs or +any virt tool: + + export LIBGUESTFS_PATH=/usr/local/lib/guestfs/appliance + +Of course you can change the path to any directory you want. You can +share the appliance across machines that have the same architecture +(eg. all x86-64), but note that libvirt will prevent you from sharing +the appliance across NFS because of permissions problems (so either +switch to the direct backend or don't use NFS). + =head2 How can I speed up libguestfs builds? By far the most important thing you can do is to install and properly -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:36 UTC
[Libguestfs] [PATCH 10/46] resize: Mark isatty function as "noalloc".
From: "Richard W.M. Jones" <rjones@redhat.com> This turns it into an ordinary C call without the unnecessary [in this case] GC frame overhead. See: http://camltastic.blogspot.co.uk/2008/08/tip-calling-c-functions-directly-with.html (cherry picked from commit 3d39549ded3e05df929547bb65ce620e6487a81b) (cherry picked from commit a08b4304d1fc0a02a18daa84d6747f432f495b67) --- resize/tTY.ml | 2 +- resize/tty-c.c | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/resize/tTY.ml b/resize/tTY.ml index 32c1f54..80f0e1e 100644 --- a/resize/tTY.ml +++ b/resize/tTY.ml @@ -16,4 +16,4 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) -external isatty_stdout : unit -> bool = "virt_resize_isatty_stdout" +external isatty_stdout : unit -> bool = "virt_resize_isatty_stdout" "noalloc" diff --git a/resize/tty-c.c b/resize/tty-c.c index 040a132..64fa884 100644 --- a/resize/tty-c.c +++ b/resize/tty-c.c @@ -25,11 +25,14 @@ #include <caml/memory.h> #include <caml/mlvalues.h> -/* RHEL 5-era ocaml didn't have Unix.isatty. */ +/* RHEL 5-era ocaml didn't have Unix.isatty. + * + * Note this function is marked as "noalloc" so it must not call any + * OCaml allocation functions: + * http://camltastic.blogspot.co.uk/2008/08/tip-calling-c-functions-directly-with.html + */ value virt_resize_isatty_stdout (value unitv) { - CAMLparam1 (unitv); - - CAMLreturn (isatty (1) ? Val_true : Val_false); + return isatty (1) ? Val_true : Val_false; } -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:36 UTC
[Libguestfs] [PATCH 11/46] resize: Mark progress bar functions as "noalloc".
From: "Richard W.M. Jones" <rjones@redhat.com> Avoids GC overhead and turns these into simple C calls. See: http://camltastic.blogspot.co.uk/2008/08/tip-calling-c-functions-directly-with.html (cherry picked from commit 67fd809ca3ec711d80e69ab32646899e7ca047eb) (cherry picked from commit 28049a4df751a954674439368788d5b7723e2c5c) --- resize/progress-c.c | 8 ++++---- resize/progress.ml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/resize/progress-c.c b/resize/progress-c.c index 67913eb..6d777b6 100644 --- a/resize/progress-c.c +++ b/resize/progress-c.c @@ -80,27 +80,27 @@ virt_resize_progress_bar_init (value machine_readablev) CAMLreturn (barv); } +/* NB: "noalloc" function. */ value virt_resize_progress_bar_reset (value barv) { - CAMLparam1 (barv); struct progress_bar *bar = Bar_val (barv); progress_bar_reset (bar); - CAMLreturn (Val_unit); + return Val_unit; } +/* NB: "noalloc" function. */ value virt_resize_progress_bar_set (value barv, value positionv, value totalv) { - CAMLparam3 (barv, positionv, totalv); struct progress_bar *bar = Bar_val (barv); uint64_t position = Int64_val (positionv); uint64_t total = Int64_val (totalv); progress_bar_set (bar, position, total); - CAMLreturn (Val_unit); + return Val_unit; } diff --git a/resize/progress.ml b/resize/progress.ml index e53e693..194120e 100644 --- a/resize/progress.ml +++ b/resize/progress.ml @@ -25,9 +25,9 @@ type progress_bar external progress_bar_init : machine_readable:bool -> progress_bar = "virt_resize_progress_bar_init" external progress_bar_reset : progress_bar -> unit - = "virt_resize_progress_bar_reset" + = "virt_resize_progress_bar_reset" "noalloc" external progress_bar_set : progress_bar -> int64 -> int64 -> unit - = "virt_resize_progress_bar_set" + = "virt_resize_progress_bar_set" "noalloc" let set_up_progress_bar ?(machine_readable = false) (g : Guestfs.guestfs) (* Only display progress bars if the machine_readable flag is set or -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:36 UTC
[Libguestfs] [PATCH 12/46] ./run: Omit timeout -k option on RHEL 6.
From: "Richard W.M. Jones" <rjones@redhat.com> If timeout doesn't have the -k option, don't use it. (cherry picked from commit 8d68f1c5ceb5ac613393654bde58127e50c0f7bf) (cherry picked from commit 2809754504ab5e7b7e5c8dff7c1e37f1568c8475) --- run.in | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/run.in b/run.in index ed74713..d82ba56 100755 --- a/run.in +++ b/run.in @@ -182,12 +182,17 @@ fi # Originally 1h, but that is not long enough to run the C API # tests on Koji. timeout_period=4h +timeout_kill=30s # Do we have Padraig's timeout utility (from coreutils)? if timeout --help >/dev/null 2>&1; then + # Does this version of timeout have the -k option? (Not on RHEL 6) + if timeout -k 10s 10s true >/dev/null 2>&1; then + timeout_k_opt="-k $timeout_kill" + fi # Timeout (SIGTERM) after $timeout_period. - # Then send a second SIGKILL 30 seconds later. - timeout="timeout -k 30s $timeout_period" + # Then send a second SIGKILL $timeout_kill seconds later. + timeout="timeout $timeout_k_opt $timeout_period" fi pid=$$ -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:36 UTC
[Libguestfs] [PATCH 13/46] launch: direct: Add drives after machine parameters.
From: "Richard W.M. Jones" <rjones@redhat.com> This is just code motion. It should affect the semantics of the code, nor how the appliance VM is created. (cherry picked from commit 568368cdf524d3ef96fb3905e39cc859c4bb4258) (cherry picked from commit 0fdc3f478d32e8c3d13df4f53e88e6eb3cad15f9) --- src/launch-appliance.c | 110 ++++++++++++++++++++++++------------------------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/src/launch-appliance.c b/src/launch-appliance.c index 3c6f206..6b142e6 100644 --- a/src/launch-appliance.c +++ b/src/launch-appliance.c @@ -294,56 +294,6 @@ launch_appliance (guestfs_h *g, const char *arg) add_cmdline (g, "-nographic"); - /* Add drives */ - struct drive *drv; - size_t i; - - if (virtio_scsi) { - /* Create the virtio-scsi bus. */ - add_cmdline (g, "-device"); - add_cmdline (g, "virtio-scsi-pci,id=scsi"); - } - - ITER_DRIVES (g, i, drv) { - /* Construct the final -drive parameter. */ - CLEANUP_FREE char *buf = qemu_drive_param (g, drv, i); - - add_cmdline (g, "-drive"); - add_cmdline (g, buf); - - if (virtio_scsi && drv->iface == NULL) { - char buf2[64]; - snprintf (buf2, sizeof buf2, "scsi-hd,drive=hd%zu", i); - add_cmdline (g, "-device"); - add_cmdline (g, buf2); - } - } - - /* Add the ext2 appliance drive (after all the drives). */ - if (has_appliance_drive) { - const char *cachemode = ""; - if (qemu_supports (g, "cache=")) { - if (qemu_supports (g, "unsafe")) - cachemode = ",cache=unsafe"; - else if (qemu_supports (g, "writeback")) - cachemode = ",cache=writeback"; - } - - size_t buf2_len = strlen (appliance) + 64; - char buf2[buf2_len]; - add_cmdline (g, "-drive"); - snprintf (buf2, buf2_len, "file=%s,snapshot=on,id=appliance,if=%s%s", - appliance, virtio_scsi ? "none" : "virtio", cachemode); - add_cmdline (g, buf2); - - if (virtio_scsi) { - add_cmdline (g, "-device"); - add_cmdline (g, "scsi-hd,drive=appliance"); - } - - appliance_dev = make_appliance_dev (g, virtio_scsi); - } - /* The qemu -machine option (added 2010-12) is a bit more sane * since it falls back through various different acceleration * modes, so try that first (thanks Markus Armbruster). @@ -397,6 +347,61 @@ launch_appliance (guestfs_h *g, const char *arg) if (qemu_supports (g, "-rtc-td-hack")) add_cmdline (g, "-rtc-td-hack"); + add_cmdline (g, "-kernel"); + add_cmdline (g, kernel); + add_cmdline (g, "-initrd"); + add_cmdline (g, initrd); + + /* Add drives */ + struct drive *drv; + size_t i; + + if (virtio_scsi) { + /* Create the virtio-scsi bus. */ + add_cmdline (g, "-device"); + add_cmdline (g, "virtio-scsi-pci,id=scsi"); + } + + ITER_DRIVES (g, i, drv) { + /* Construct the final -drive parameter. */ + CLEANUP_FREE char *buf = qemu_drive_param (g, drv, i); + + add_cmdline (g, "-drive"); + add_cmdline (g, buf); + + if (virtio_scsi && drv->iface == NULL) { + char buf2[64]; + snprintf (buf2, sizeof buf2, "scsi-hd,drive=hd%zu", i); + add_cmdline (g, "-device"); + add_cmdline (g, buf2); + } + } + + /* Add the ext2 appliance drive (after all the drives). */ + if (has_appliance_drive) { + const char *cachemode = ""; + if (qemu_supports (g, "cache=")) { + if (qemu_supports (g, "unsafe")) + cachemode = ",cache=unsafe"; + else if (qemu_supports (g, "writeback")) + cachemode = ",cache=writeback"; + } + + size_t buf2_len = strlen (appliance) + 64; + char buf2[buf2_len]; + add_cmdline (g, "-drive"); + snprintf (buf2, buf2_len, "file=%s,snapshot=on,id=appliance,if=%s%s", + appliance, virtio_scsi ? "none" : "virtio", cachemode); + add_cmdline (g, buf2); + + if (virtio_scsi) { + add_cmdline (g, "-device"); + add_cmdline (g, "scsi-hd,drive=appliance"); + } + + appliance_dev = make_appliance_dev (g, virtio_scsi); + } + /* Create the virtio serial bus. */ add_cmdline (g, "-device"); add_cmdline (g, "virtio-serial"); @@ -451,11 +456,6 @@ launch_appliance (guestfs_h *g, const char *arg) add_cmdline (g, "virtio-net-pci,netdev=usernet"); } - add_cmdline (g, "-kernel"); - add_cmdline (g, kernel); - add_cmdline (g, "-initrd"); - add_cmdline (g, initrd); - add_cmdline (g, "-append"); CLEANUP_FREE char *cmdline guestfs___appliance_command_line (g, appliance_dev, 0); -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:36 UTC
[Libguestfs] [PATCH 14/46] augeas: Improve error reporting.
From: "Richard W.M. Jones" <rjones@redhat.com> Display all the information from the handle about errors. (cherry picked from commit f26a0407d2a61ed334b4a9d42b1269feb3cab76e) (cherry picked from commit fde27df3c98ca65a90c82f8d82c9186777b7bb7f) --- daemon/augeas.c | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/daemon/augeas.c b/daemon/augeas.c index c0c97e3..54830c7 100644 --- a/daemon/augeas.c +++ b/daemon/augeas.c @@ -64,6 +64,23 @@ optgroup_augeas_available (void) return 1; } +/* Calls reply_with_error, but includes the Augeas error details. */ +#define AUGEAS_ERROR(fs,...) \ + do { \ + int code = aug_error (aug); \ + if (code == AUG_ENOMEM) \ + reply_with_error (fs ": augeas out of memory", ##__VA_ARGS__); \ + else { \ + const char *message = aug_error_message (aug); \ + const char *minor = aug_error_minor_message (aug); \ + const char *details = aug_error_details (aug); \ + reply_with_error (fs ": %s%s%s%s%s", ##__VA_ARGS__, \ + message, \ + minor ? ": " : "", minor ? minor : "", \ + details ? ": " : "", details ? details : ""); \ + } \ + } while (0) + /* We need to rewrite the root path so it is based at /sysroot. */ int do_aug_init (const char *root, int flags) @@ -112,7 +129,7 @@ do_aug_defvar (const char *name, const char *expr) r = aug_defvar (aug, name, expr); if (r == -1) { - reply_with_error ("Augeas defvar failed"); + AUGEAS_ERROR ("aug_defvar: %s: %s", name, expr); return -1; } return r; @@ -133,7 +150,7 @@ do_aug_defnode (const char *name, const char *expr, const char *val) i = aug_defnode (aug, name, expr, val, &created); if (i == -1) { - reply_with_error ("Augeas defnode failed"); + AUGEAS_ERROR ("aug_defnode: %s: %s: %s", name, expr, val); return NULL; } @@ -168,7 +185,7 @@ do_aug_get (const char *path) return NULL; } if (r != 1) { - reply_with_error ("Augeas get failed"); + AUGEAS_ERROR ("aug_get: %s", path); return NULL; } @@ -200,7 +217,7 @@ do_aug_set (const char *path, const char *val) r = aug_set (aug, path, val); if (r == -1) { - reply_with_error ("Augeas set failed"); + AUGEAS_ERROR ("aug_set: %s: %s", path, val); return -1; } @@ -216,7 +233,7 @@ do_aug_clear (const char *path) r = aug_set (aug, path, NULL); if (r == -1) { - reply_with_error ("Augeas clear failed"); + AUGEAS_ERROR ("aug_clear: %s", path); return -1; } @@ -232,7 +249,7 @@ do_aug_insert (const char *path, const char *label, int before) r = aug_insert (aug, path, label, before); if (r == -1) { - reply_with_error ("Augeas insert failed"); + AUGEAS_ERROR ("aug_insert: %s: %s [before=%d]", path, label, before); return -1; } @@ -248,7 +265,7 @@ do_aug_rm (const char *path) r = aug_rm (aug, path); if (r == -1) { - reply_with_error ("Augeas rm failed"); + AUGEAS_ERROR ("aug_rm: %s", path); return -1; } @@ -264,7 +281,7 @@ do_aug_mv (const char *src, const char *dest) r = aug_mv (aug, src, dest); if (r == -1) { - reply_with_error ("Augeas mv failed"); + AUGEAS_ERROR ("aug_mv: %s: %s", src, dest); return -1; } @@ -282,7 +299,7 @@ do_aug_match (const char *path) r = aug_match (aug, path, &matches); if (r == -1) { - reply_with_error ("Augeas match failed"); + AUGEAS_ERROR ("aug_match: %s", path); return NULL; } @@ -307,7 +324,7 @@ do_aug_save (void) NEED_AUG (-1); if (aug_save (aug) == -1) { - reply_with_error ("Augeas save failed"); + AUGEAS_ERROR ("aug_save"); return -1; } @@ -321,7 +338,7 @@ do_aug_load (void) NEED_AUG (-1); if (aug_load (aug) == -1) { - reply_with_error ("Augeas load failed"); + AUGEAS_ERROR ("aug_load"); return -1; } -- 1.8.3.1
From: "Richard W.M. Jones" <rjones@redhat.com> (cherry picked from commit f6b2efcdffe8688fc415b3f1cd9d608dd396f253) (cherry picked from commit fd32ca199da1bd30ca8024efe49bd571653ea214) --- TODO | 76 ++++++++++++++++++++++---------------------------------------------- 1 file changed, 24 insertions(+), 52 deletions(-) diff --git a/TODO b/TODO index 959d449..86b661c 100644 --- a/TODO +++ b/TODO @@ -95,10 +95,22 @@ two sides to a pty, and one has to be handled after the fork). work. qemu is implementing its own ptys, and they are broken. Need to fix qemu.] -Windows-based daemon/appliance ------------------------------- +Port to Windows +--------------- -See discussion on list: +"Port to Windows" means different things to different people. + +The easiest is to port the library to Windows, but reuse the Linux +appliance/daemon. This would allow people to use libguestfs on +Windows hosts and link libguestfs to Windows programs. Doing this is +just a matter of chugging through the code fixing portability issues, +using gnulib as far as possible as the portability layer. + +The hardest is probably a port of the daemon to Windows. The reason +to do this is so that you can use the native NTFS drivers (in Windows) +in order to edit Windows guests. Although back in 2009 we did some +work on this, I am now dubious about the utility of this, since +ntfs-3g works very well. See also discussion on list: https://www.redhat.com/archives/libguestfs/2009-November/msg00165.html virt-disk-explore @@ -141,11 +153,8 @@ http://sourceforge.net/projects/aide/ http://osiris.shmoo.com/ http://sourceforge.net/projects/tripwire/ -Freeze/thaw filesystems ------------------------ - -Access to these ioctls: -http://git.kernel.org/linus/fcccf502540e3d7 +See also: virt-aide; +https://rwmj.wordpress.com/2013/05/16/scanning-offline-guests-using-openscap-and-guestmount/#content Tips for new users in guestfish ------------------------------- @@ -198,7 +207,7 @@ There are some places where we call out to the 'blkid' program. This might be replaced by direct use of the library (if this is easier). But it is very hard to be compatible between RHEL6 and RHEL5 when -using direct library. +using the library directly. Visualization ------------- @@ -388,18 +397,8 @@ virt-sysprep ideas . run external guestfish script virt-sysprep --fish=/tmp/foo.fish - if drives are encrypted, then dm-crypt key should be changed and drives all re-encrypted - - /etc/pki - (Steve says ...) - Rpm uses nss. Nss sets up its crypto database in - /etc/pki. Depending on how long the machine ran before cloning, you - may have picked up some certificates or things. This is an area - that you would want to look into. - secure erase of inodes etc using scrub (Steve Grubb) - - other directories that could require cleaning include: - /var/run/* - (thanks Marko Myllynen, James Antill) - - remove or modify UUIDs in /etc/fstab (eg. on Ubuntu) - (thanks Joshua Daniel Franklin) + - fix the virt-sysprep fs-uuids plugin Kazuo Moriwaka adds: @@ -423,16 +422,9 @@ customized with the organization logo etc. Some ideas: - change the sign-on messages (/etc/issue.net etc) - Windows login script/service -Launch remote sessions over ssh -------------------------------- - -We had an idea you could add a launch method that uses ssh, ie. all -supermin and qemu commands happen the same as now, but prefixed by -ssh so it happens on a remote machine. - -Note that proper remote support and integration with libvirt is -different from this, and people are working on that. ssh would just -be "remote-lite". +Note that virt-sysprep has gradually gained some of these features, +eg. setting hostname, changing passwords. Since this precedent has +now been set, it could do more of the same. virt-make-fs and virt-win-reg need to not be in Perl ---------------------------------------------------- @@ -534,21 +526,6 @@ as data is reliably written out when g.sync, g.shutdown or g.close return. Also in libguestfs we effectively control the whole stack, so we can ensure write barriers happen when we want. -libvirt attach-method ---------------------- - -Since libguestfs 1.19.24 this mostly works. Here are some suggested -items to work on: - - - SELinux labelling of guestfsd.sock, console.sock - https://bugzilla.redhat.com/show_bug.cgi?id=842307 - Once this is fixed, remove <seclabel type=none> from libvirt XML - - - Check feature parity between src/launch-appliance.c and - src/launch-libvirt.c. - - - Remote support. (This requires work on libvirt) - virt-sparsify should use discard -------------------------------- @@ -558,19 +535,14 @@ throughout the entire stack. Reimplement some APIs to avoid protocol limits ---------------------------------------------- -We should reimplement the following APIs to avoid protocol limits. -These would be changed from daemon_functions to non_daemon_functions, -with the non-daemon versions implemented using guestfs_upload and -guestfs_download (and others). This change should be transparent from -the p.o.v of the API and ABI. +Mostly this item was done (eg. commits a69f44f56f and before). The +most notable API with a protocol limit remaining is: - guestfs_readdir hivex ----- -Add more of hivex to the API, especially for writing. - Reimplement virt-win-reg to use this API. (This is difficult because the Perl libraries underneath access the hivex API directly). -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:36 UTC
[Libguestfs] [PATCH 16/46] Update Transifex domain name from .net -> .com.
From: "Richard W.M. Jones" <rjones@redhat.com> (cherry picked from commit 56f613b13003b2ef44b25da360c5dac6eb5b0c71) (cherry picked from commit 7d1c54be145bd8f87d87cfc887c3647ffed723eb) --- .tx/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.tx/config b/.tx/config index 4e21dd5..26fb474 100644 --- a/.tx/config +++ b/.tx/config @@ -1,5 +1,5 @@ [main] -host = https://www.transifex.net +host = https://www.transifex.com [libguestfs.libguestfspot] file_filter = po/<lang>.po -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:36 UTC
[Libguestfs] [PATCH 17/46] Fix parsing of boot flag in do_part_get_bootable()
From: Paul Mackerras <paulus@samba.org> The code in do_part_get_bootable() assumes that if a partition has the bootable flag set, then that is the only flag. It compares the entire flags field with the string "boot". However, the boot flag isn't always the only flag. For instance, POWER systems typically have a bootable partition of type 0x41 (PPC PReP boot), which parted -m displays as: # parted -m -- f18.img unit b print BYT; /root/f18.img:16106127360B:file:512:512:msdos::; 1:1048576B:5242879B:4194304B:::boot, prep; That is, the flags field contains "boot, prep", and thus libguestfs fails to see that this partition is bootable. Ultimately this causes virt-resize to fail to set the bootable flag on the boot partition of the destination image, resulting in an image that won't boot. This patch fixes the problem by searching for the string "boot" within the flags field, instead of comparing the whole flags field. (cherry picked from commit 7c535c501b1ce131ae98dd948b22fc260d659d1b) (cherry picked from commit 6d80000dd69c2fb517ff294e1fb1fab7add578e6) --- daemon/parted.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daemon/parted.c b/daemon/parted.c index c101e8b..d69250d 100644 --- a/daemon/parted.c +++ b/daemon/parted.c @@ -626,7 +626,7 @@ do_part_get_bootable (const char *device, int partnum) if (boot == NULL) return -1; - return STREQ (boot, "boot"); + return strstr (boot, "boot") != NULL; } else { /* Old-style: First look for the line matching "^Number". */ -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:36 UTC
[Libguestfs] [PATCH 18/46] daemon: Close augeas, hivex handles in unmount_all.
From: "Richard W.M. Jones" <rjones@redhat.com> This is also called implicitly from internal_autosync, ensuring that exit won't fail because of an open handle. libguestfs: error: internal_autosync: umount: /sysroot: umount: /sysroot: target is busy. (In some cases useful info about processes that use the device is found by lsof(8) or fuser(1)) Cherry picked from commit ce6e5738fc4ca9533e73cfe6b5fe3db872b7ec9d and modified to remove references to the journal. (cherry picked from commit 4d5da455cca1e70810af868c523a872c746f45ec) --- daemon/augeas.c | 4 ++-- daemon/daemon.h | 4 ++++ daemon/hivex.c | 4 ++-- daemon/mount.c | 7 +++++++ 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/daemon/augeas.c b/daemon/augeas.c index 54830c7..b2d1eb2 100644 --- a/daemon/augeas.c +++ b/daemon/augeas.c @@ -39,8 +39,8 @@ static augeas *aug = NULL; /* Clean up the augeas handle on daemon exit. */ -static void aug_finalize (void) __attribute__((destructor)); -static void +void aug_finalize (void) __attribute__((destructor)); +void aug_finalize (void) { if (aug) { diff --git a/daemon/daemon.h b/daemon/daemon.h index 096a3af..8ca0593 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -198,6 +198,10 @@ extern void copy_lvm (void); /*-- in zero.c --*/ extern void wipe_device_before_mkfs (const char *device); +/*-- in augeas.c, hivex.c --*/ +extern void aug_finalize (void); +extern void hivex_finalize (void); + /*-- in proto.c --*/ extern void main_loop (int sock) __attribute__((noreturn)); diff --git a/daemon/hivex.c b/daemon/hivex.c index 92e8fc3..ce6164e 100644 --- a/daemon/hivex.c +++ b/daemon/hivex.c @@ -47,8 +47,8 @@ optgroup_hivex_available (void) static hive_h *h = NULL; /* Clean up the hivex handle on daemon exit. */ -static void hivex_finalize (void) __attribute__((destructor)); -static void +void hivex_finalize (void) __attribute__((destructor)); +void hivex_finalize (void) { if (h) { diff --git a/daemon/mount.c b/daemon/mount.c index af92834..2f4674d 100644 --- a/daemon/mount.c +++ b/daemon/mount.c @@ -343,6 +343,13 @@ do_umount_all (void) size_t i; int r; + /* This is called from internal_autosync and generally as a cleanup + * function, and since the umount will definitely fail if any + * handles are open, we may as well close them. + */ + aug_finalize (); + hivex_finalize (); + /* NB: Eventually we should aim to parse /proc/self/mountinfo, but * that requires custom parsing code. */ -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:36 UTC
[Libguestfs] [PATCH 19/46] appliance/init: Display uname -a in debug output.
From: "Richard W.M. Jones" <rjones@redhat.com> Useful for debugging kernel / architecture issues. Note this has no effect if debugging is disabled. (cherry picked from commit 6c2fad11ac9a68dcfd42ee18681dc9a552625be9) (cherry picked from commit 9fc75d4133840b213362da3d27abeed936e4dc9a) --- appliance/init | 1 + 1 file changed, 1 insertion(+) diff --git a/appliance/init b/appliance/init index 30d4f60..cfeb3a9 100755 --- a/appliance/init +++ b/appliance/init @@ -103,6 +103,7 @@ for f in /sys/block/vd*/queue/rotational; do echo 1 > $f; done # These are useful when debugging. if grep -sq guestfs_verbose=1 /proc/cmdline; then + uname -a ls -lR /dev cat /proc/mounts lvm pvs -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:36 UTC
[Libguestfs] [PATCH 20/46] daemon: Remove unnecessary sysroot_path (selinux).
From: "Richard W.M. Jones" <rjones@redhat.com> This fixes commit 72afcf450a78b7e58f65b4a7aaf94d71cd25fca5. (cherry picked from commit 7367729ec7a5d016878dd00b32cce45cec372931) (cherry picked from commit 576379a3478ced0483102c797935b57f454a1f7d) --- daemon/command.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/daemon/command.c b/daemon/command.c index fde3826..db82b52 100644 --- a/daemon/command.c +++ b/daemon/command.c @@ -44,7 +44,7 @@ do_command (char *const *argv) CLEANUP_FREE char *err; int r; CLEANUP_FREE char *sysroot_dev = NULL, *sysroot_dev_pts = NULL, - *sysroot_proc = NULL, *sysroot_selinux = NULL, *sysroot_sys = NULL; + *sysroot_proc = NULL, *sysroot_sys = NULL; int dev_ok, dev_pts_ok, proc_ok, sys_ok; /* We need a root filesystem mounted to do this. */ @@ -70,12 +70,10 @@ do_command (char *const *argv) sysroot_dev = sysroot_path ("/dev"); sysroot_dev_pts = sysroot_path ("/dev/pts"); sysroot_proc = sysroot_path ("/proc"); - sysroot_selinux = sysroot_path ("/sys/fs/selinux"); sysroot_sys = sysroot_path ("/sys"); if (sysroot_dev == NULL || sysroot_dev_pts == NULL || - sysroot_proc == NULL || sysroot_selinux == NULL || - sysroot_sys == NULL) { + sysroot_proc == NULL || sysroot_sys == NULL) { reply_with_perror ("malloc"); return NULL; } -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:36 UTC
[Libguestfs] [PATCH 21/46] daemon: ldm: Don't return an error if /dev/mapper doesn't exist.
From: "Richard W.M. Jones" <rjones@redhat.com> (cherry picked from commit 2089f7a21a307402c3efa43e5d10ee8d5ff554fb) (cherry picked from commit 1879ba2cb0adcadb0b9a24cede21fa5e39bd898f) --- daemon/daemon.h | 2 ++ daemon/guestfsd.c | 14 ++++++++++++-- daemon/ldm.c | 23 +++++++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/daemon/daemon.h b/daemon/daemon.h index 8ca0593..544feb2 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -89,6 +89,8 @@ extern char *join_strings (const char *separator, char *const *argv); extern char **split_lines (char *str); +extern char **empty_list (void); + #define command(out,err,name,...) commandf((out),(err),0,(name),__VA_ARGS__) #define commandr(out,err,name,...) commandrf((out),(err),0,(name),__VA_ARGS__) #define commandv(out,err,argv) commandvf((out),(err),0,(argv)) diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c index 254e0ea..bba13f8 100644 --- a/daemon/guestfsd.c +++ b/daemon/guestfsd.c @@ -1086,7 +1086,7 @@ split_lines (char *str) char *p, *pend; if (STREQ (str, "")) - goto empty_list; + return empty_list (); p = str; while (p) { @@ -1107,13 +1107,23 @@ split_lines (char *str) p = pend; } - empty_list: if (end_stringsbuf (&lines) == -1) return NULL; return lines.argv; } +char ** +empty_list (void) +{ + DECLARE_STRINGSBUF (ret); + + if (end_stringsbuf (&ret) == -1) + return NULL; + + return ret.argv; +} + /* Skip leading and trailing whitespace, updating the original string * in-place. */ diff --git a/daemon/ldm.c b/daemon/ldm.c index b7ef301..aed8a0d 100644 --- a/daemon/ldm.c +++ b/daemon/ldm.c @@ -20,6 +20,9 @@ #include <stdio.h> #include <stdlib.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> #include <glob.h> #if HAVE_YAJL @@ -91,6 +94,16 @@ get_devices (const char *pattern) char ** do_list_ldm_volumes (void) { + struct stat buf; + + /* If /dev/mapper doesn't exist at all, don't give an error. */ + if (stat ("/dev/mapper", &buf) == -1) { + if (errno == ENOENT) + return empty_list (); + reply_with_perror ("/dev/mapper"); + return NULL; + } + return get_devices ("/dev/mapper/ldm_vol_*"); } @@ -98,6 +111,16 @@ do_list_ldm_volumes (void) char ** do_list_ldm_partitions (void) { + struct stat buf; + + /* If /dev/mapper doesn't exist at all, don't give an error. */ + if (stat ("/dev/mapper", &buf) == -1) { + if (errno == ENOENT) + return empty_list (); + reply_with_perror ("/dev/mapper"); + return NULL; + } + return get_devices ("/dev/mapper/ldm_part_*"); } -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:36 UTC
[Libguestfs] [PATCH 22/46] utils: Remove duplicate inclusion of <string.h>.
From: "Richard W.M. Jones" <rjones@redhat.com> (cherry picked from commit 467fd96e7e7537a5aa706dd5ca2edb513aa833e9) (cherry picked from commit de5faac35b1c4d98f97857bb52bdb78f61662e03) --- src/utils.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/utils.c b/src/utils.c index 7391455..fa60011 100644 --- a/src/utils.c +++ b/src/utils.c @@ -22,7 +22,6 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> -#include <string.h> #include <sys/types.h> #include <sys/wait.h> #include <libintl.h> -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:36 UTC
[Libguestfs] [PATCH 23/46] lib: Turn 'random_chars' function used by libvirt backend into utility function.
From: "Richard W.M. Jones" <rjones@redhat.com> (cherry picked from commit e5285cc4210683887a5a4a853fe4e6a72c23e74d) (cherry picked from commit 0a22c69b7f7b7fda8dbfdf06db3fbdf9c2994c8f) --- src/guestfs-internal-frontend.h | 1 + src/launch-libvirt.c | 34 ++-------------------------------- src/utils.c | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 32 deletions(-) diff --git a/src/guestfs-internal-frontend.h b/src/guestfs-internal-frontend.h index e4bf50c..06ed37f 100644 --- a/src/guestfs-internal-frontend.h +++ b/src/guestfs-internal-frontend.h @@ -95,6 +95,7 @@ extern char *guestfs___safe_asprintf (guestfs_h *g, const char *fs, ...) extern void guestfs___free_string_list (char **); extern size_t guestfs___count_strings (char *const *); extern char *guestfs___exit_status_to_string (int status, const char *cmd_name, char *buffer, size_t buflen); +extern int guestfs___random_string (char *ret, size_t len); /* These functions are used internally by the CLEANUP_* macros. * Don't call them directly. diff --git a/src/launch-libvirt.c b/src/launch-libvirt.c index 5849421..6188671 100644 --- a/src/launch-libvirt.c +++ b/src/launch-libvirt.c @@ -133,7 +133,6 @@ static void debug_socket_permissions (guestfs_h *g); static void libvirt_error (guestfs_h *g, const char *fs, ...) __attribute__((format (printf,2,3))); static int is_custom_qemu (guestfs_h *g); static int is_blk (const char *path); -static int random_chars (char *ret, size_t len); static void ignore_errors (void *ignore, virErrorPtr ignore2); static char *make_qcow2_overlay (guestfs_h *g, const char *path, const char *format); static int make_qcow2_overlay_for_drive (guestfs_h *g, struct drive *drv); @@ -799,8 +798,8 @@ construct_libvirt_xml_name (guestfs_h *g, { char name[DOMAIN_NAME_LEN+1]; - if (random_chars (name, DOMAIN_NAME_LEN) == -1) { - perrorf (g, "/dev/urandom"); + if (guestfs___random_string (name, DOMAIN_NAME_LEN) == -1) { + perrorf (g, "guestfs___random_string"); return -1; } @@ -1325,35 +1324,6 @@ is_blk (const char *path) return S_ISBLK (statbuf.st_mode); } -static int -random_chars (char *ret, size_t len) -{ - int fd; - size_t i; - unsigned char c; - int saved_errno; - - fd = open ("/dev/urandom", O_RDONLY|O_CLOEXEC); - if (fd == -1) - return -1; - - for (i = 0; i < len; ++i) { - if (read (fd, &c, 1) != 1) { - saved_errno = errno; - close (fd); - errno = saved_errno; - return -1; - } - ret[i] = "0123456789abcdefghijklmnopqrstuvwxyz"[c % 36]; - } - ret[len] = '\0'; - - if (close (fd) == -1) - return -1; - - return 0; -} - static void ignore_errors (void *ignore, virErrorPtr ignore2) { diff --git a/src/utils.c b/src/utils.c index fa60011..01c31d6 100644 --- a/src/utils.c +++ b/src/utils.c @@ -22,6 +22,8 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <fcntl.h> +#include <errno.h> #include <sys/types.h> #include <sys/wait.h> #include <libintl.h> @@ -83,3 +85,40 @@ guestfs___exit_status_to_string (int status, const char *cmd_name, return buffer; } + +/* Notes: + * + * The 'ret' buffer must have length len+1 in order to store the final + * \0 character. + * + * There is about 5 bits of randomness per output character (so about + * 5*len bits of randomness in the resulting string). + */ +int +guestfs___random_string (char *ret, size_t len) +{ + int fd; + size_t i; + unsigned char c; + int saved_errno; + + fd = open ("/dev/urandom", O_RDONLY|O_CLOEXEC); + if (fd == -1) + return -1; + + for (i = 0; i < len; ++i) { + if (read (fd, &c, 1) != 1) { + saved_errno = errno; + close (fd); + errno = saved_errno; + return -1; + } + ret[i] = "0123456789abcdefghijklmnopqrstuvwxyz"[c % 36]; + } + ret[len] = '\0'; + + if (close (fd) == -1) + return -1; + + return 0; +} -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:37 UTC
[Libguestfs] [PATCH 24/46] launch: direct: Print \n after printing qemu command line.
From: "Richard W.M. Jones" <rjones@redhat.com> This makes it easier to see error messages printed by qemu. (cherry picked from commit 19ee64303e65766b4a1b1ac55adbbb646a1c3500) (cherry picked from commit 847c515043870bc7b1c785bad747462a84c43f35) --- src/launch-appliance.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/launch-appliance.c b/src/launch-appliance.c index 6b142e6..f0278ce 100644 --- a/src/launch-appliance.c +++ b/src/launch-appliance.c @@ -770,6 +770,8 @@ print_qemu_command_line (guestfs_h *g, char **argv) if (needs_quote) fputc ('\'', stderr); i++; } + + fputc ('\n', stderr); } static void parse_qemu_version (guestfs_h *g); -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:37 UTC
[Libguestfs] [PATCH 25/46] tests/md: Fix error path to display the correct output.
From: "Richard W.M. Jones" <rjones@redhat.com> (cherry picked from commit 42abbf096932bd1e6c9c1bef64f602a67107d088) (cherry picked from commit c55592a89443c8398b4521c3269e2fbc71486da2) --- tests/md/test-list-filesystems.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/md/test-list-filesystems.sh b/tests/md/test-list-filesystems.sh index 642e033..b4e41e9 100755 --- a/tests/md/test-list-filesystems.sh +++ b/tests/md/test-list-filesystems.sh @@ -73,7 +73,7 @@ expected="/dev/sda1: ext3 # Check the output of list-filesystems if [ "$(cat test.output)" != "$expected" ]; then echo "$0: error: output of list-filesystems did not match expected output" - printf "%s\n" "$output" + cat list-fs.output exit 1; fi -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:37 UTC
[Libguestfs] [PATCH 26/46] daemon: If /proc/modules doesn't exist, linuxmodules optgroup is disabled.
From: "Richard W.M. Jones" <rjones@redhat.com> It likely means the kernel was compiled without modules support. (cherry picked from commit 8ad634877cf315288497a8580fb4afc7658deae9) (cherry picked from commit 6503aa1681bb44d2beffa7cfd4f0c4c74ed6d820) --- daemon/modprobe.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/daemon/modprobe.c b/daemon/modprobe.c index 24d2a5b..0b7896a 100644 --- a/daemon/modprobe.c +++ b/daemon/modprobe.c @@ -20,6 +20,8 @@ #include <stdio.h> #include <stdlib.h> +#include <unistd.h> +#include <errno.h> #include "daemon.h" #include "actions.h" @@ -30,6 +32,13 @@ GUESTFSD_EXT_CMD(str_modprobe, modprobe); int optgroup_linuxmodules_available (void) { + /* If /proc/modules doesn't exist, then the appliance kernel + * probably has modules support compiled out. This means modprobe + * is not supported. + */ + if (access ("/proc/modules", R_OK) == -1 && errno == ENOENT) + return 0; + return prog_exists (str_modprobe); } @@ -37,7 +46,9 @@ int do_modprobe (const char *module) { CLEANUP_FREE char *err = NULL; - int r = command (NULL, &err, str_modprobe, module, NULL); + int r; + + r = command (NULL, &err, str_modprobe, module, NULL); if (r == -1) { reply_with_error ("%s", err); -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:37 UTC
[Libguestfs] [PATCH 27/46] daemon: md: Whitespace fixes.
From: "Richard W.M. Jones" <rjones@redhat.com> (cherry picked from commit 52188f1ea308225ab948141b1f23e0b47f7dcf4f) (cherry picked from commit b36a3c3f064edfd7f5f36523d46a4bdc97fa4a38) --- daemon/md.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/daemon/md.c b/daemon/md.c index b302a8c..e9a3f09 100644 --- a/daemon/md.c +++ b/daemon/md.c @@ -202,18 +202,21 @@ do_list_md_devices (void) } for (size_t i = 0; i < mds.gl_pathc; i++) { - size_t len = strlen (mds.gl_pathv[i]) - strlen (PREFIX) - strlen (SUFFIX); + size_t len; + char *dev, *n; + + len = strlen (mds.gl_pathv[i]) - strlen (PREFIX) - strlen (SUFFIX); #define DEV "/dev/md" - char *dev = malloc (strlen(DEV) + len + 1); + dev = malloc (strlen (DEV) + len + 1); if (NULL == dev) { - reply_with_perror("malloc"); + reply_with_perror ("malloc"); goto error; } - char *n = dev; - n = mempcpy(n, DEV, strlen(DEV)); - n = mempcpy(n, &mds.gl_pathv[i][strlen(PREFIX)], len); + n = dev; + n = mempcpy (n, DEV, strlen (DEV)); + n = mempcpy (n, &mds.gl_pathv[i][strlen(PREFIX)], len); *n = '\0'; if (add_string_nodup (&ret, dev) == -1) goto error; -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:37 UTC
[Libguestfs] [PATCH 28/46] virt-list-filesystems: Fix to use $g->canonical_device_name instead of homebrew function.
From: "Richard W.M. Jones" <rjones@redhat.com> The homebrew function didn't recognize /dev/ubd* device names, and in any case using the API function is shorter and clearer. (cherry picked from commit 42754046269806a6b6385fee0b72115c73461221) (cherry picked from commit b312c245d3efb458609f9064a75a2f02a5181af4) --- tools/virt-list-filesystems | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/tools/virt-list-filesystems b/tools/virt-list-filesystems index 1b58d63..9dcba24 100755 --- a/tools/virt-list-filesystems +++ b/tools/virt-list-filesystems @@ -167,7 +167,7 @@ foreach $dev (sort keys %fses) { $fstype = $fses{$dev}; if ($all || ($fstype ne "swap" && $fstype ne "unknown")) { - print canonicalize($dev); + print $g->canonical_device_name ($dev); if ($long) { print " $fstype"; } @@ -175,18 +175,6 @@ foreach $dev (sort keys %fses) { } } -# The reverse of device name translation, see -# BLOCK DEVICE NAMING in guestfs(3). -sub canonicalize -{ - local $_ = shift; - - if (m{^/dev/[hv]d([a-z]\d)$}) { - return "/dev/sd$1"; - } - $_; -} - =head1 SHELL QUOTING Libvirt guest names can contain arbitrary characters, some of which -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:37 UTC
[Libguestfs] [PATCH 29/46] Remove contrib/guestfsd-in-wine.sh.
From: "Richard W.M. Jones" <rjones@redhat.com> Added in 2009, unlikely it still works since I doubt it has been compiled since then. (cherry picked from commit 36d29700dcef01d681d41f0b593a16e7814e3ee1) (cherry picked from commit 18995c0857b62e395ab36e750dd477919dda34f5) --- contrib/README | 4 -- contrib/guestfsd-in-wine.sh | 117 -------------------------------------------- 2 files changed, 121 deletions(-) delete mode 100755 contrib/guestfsd-in-wine.sh diff --git a/contrib/README b/contrib/README index 081a116..6a7acca 100644 --- a/contrib/README +++ b/contrib/README @@ -5,10 +5,6 @@ autobuild/ The autobuild script that we use to build and test the tarballs on Debian and elsewhere. -guestfsd-in-wine.sh - Run a Windows-compiled guestfsd under Wine. Read the - instructions at the top of this file carefully. - intro/ "Slides" for an intro to libguestfs. This is a short (10-15 min) talk that I give to introduce the main features of libguestfs. The slides are in the form of a complete diff --git a/contrib/guestfsd-in-wine.sh b/contrib/guestfsd-in-wine.sh deleted file mode 100755 index 8cfd3c1..0000000 --- a/contrib/guestfsd-in-wine.sh +++ /dev/null @@ -1,117 +0,0 @@ -#!/bin/bash - -# Copyright (C) 2009 Red Hat Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -# INSTRUCTIONS -#---------------------------------------------------------------------- -# -# This is a QEMU wrapper script that allows you to run a -# Windows-compiled guestfsd.exe (daemon) under Wine from a Linux main -# program. You need to read and understand all the instructions below -# before use. -# -# To understand how to compile the daemon for Windows, please read: -# http://www.redhat.com/archives/libguestfs/2009-November/msg00255.html -# -# Adjust the Wine configuration so it can find the libraries, as -# described here: -# http://fedoraproject.org/wiki/MinGW/Configure_wine -# -# On Fedora 13 there is a serious bug in Wine. See: -# https://bugzilla.redhat.com/show_bug.cgi?id=533806#c11 -# -# If necessary, adjust the line 'guestfsd=...' below so it points to -# the correct location of the guestfsd.exe program. You can use an -# absolute path here if you want. -guestfsd=daemon/guestfsd.exe -# -# This script is a QEMU wrapper. It pretends to be qemu as far as -# libguestfs programs are concerned. Read this to understand the -# purpose of QEMU wrappers: -# http://libguestfs.org/guestfs.3.html#qemu_wrappers -# -# With this script, the qemu program is not actually run. Instead we -# pretend to be qemu, parse out the necessary parts of the long -# command line that libguestfs passes to qemu, and run the Windows -# daemon, under Wine, with the right command line. The Windows daemon -# then hopefully connects back to the libguestfs socket, and as far as -# the libguestfs program is concerned, it looks like a full appliance -# is running. -# -# To use this script, you must set the environment variable -# LIBGUESTFS_QEMU=/path/to/contrib/guestfsd-in-wine.sh (ie. the path -# to this script). -# -# You can then run libguestfs test programs, and (hopefully!) they'll -# use the Windows guestfsd.exe, simulating calls using Wine. -# -# For example from the top build directory: -# -# LIBGUESTFS_QEMU=contrib/guestfsd-in-wine.sh ./run ./fish/guestfish -# -# Another suggested environment variable is LIBGUESTFS_DEBUG=1 which -# will give you must more detail about what is going on. Also look at -# the contents of the log file 'guestfsd-in-wine.log' after each run. -# -#---------------------------------------------------------------------- - -# Note that stdout & stderr messages will get eaten by libguestfs -# early on in the process. Therefore write log messages to -# a log file. -exec 5>>guestfsd-in-wine.log -echo "Environment:" >&5 -printenv | grep LIBGUESTFS >&5 -echo "Command line:" >&5 -echo " $@" >&5 - -# We're called several times, first with -help and -version, and we -# have to pretend to be qemu! (At least enough to trick libguestfs). -if [ "$1" = "-help" ]; then - echo -- " -net user " - echo -- " -no-hpet " - echo -- " -rtc-td-hack " - exit 0 -elif [ "$1" = "-version" ]; then - echo -- "0.0.0" - exit 0 -fi - -# The interesting parameter is -append. -append-while [ $# -gt 0 ]; do - if [ $1 = "-append" ]; then - append="$2" - shift - fi - shift -done -echo "Append parameter:" >&5 -echo " $append" >&5 - -# guestfs_vmchannel parameter. -vmchannel_param=$(echo "$append" | grep -Eo 'guestfs_vmchannel=[^[:space:]]+') -echo "Vmchannel parameter:" >&5 -echo " $vmchannel_param" >&5 - -# Port number. -port=$(echo "$vmchannel_param" | grep -Eo '[[:digit:]]+$') -echo "Port number:" >&5 -echo " $vmchannel_param" >&5 - -# Run guestfsd.exe. -echo "Command:" >&5 -echo " $guestfsd -f -v -c tcp:localhost:$port" >&5 -$guestfsd -f -v -c tcp:127.0.0.1:$port -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:37 UTC
[Libguestfs] [PATCH 30/46] Remove contrib file from EXTRA_DIST.
From: "Richard W.M. Jones" <rjones@redhat.com> This fixes commit 36d29700dcef01d681d41f0b593a16e7814e3ee1. (cherry picked from commit b1a8733511836591bcf8931f25f0fb5cec7924ff) (cherry picked from commit fc42ba845e39f8583ae6b687fdda59eb0de659bf) --- Makefile.am | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 8fe27d6..b3fe403 100644 --- a/Makefile.am +++ b/Makefile.am @@ -134,7 +134,6 @@ EXTRA_DIST = \ autogen.sh \ bindtests \ contrib/autobuild/autobuild.sh \ - contrib/guestfsd-in-wine.sh \ contrib/intro/libguestfs-intro.html \ contrib/intro/overview.png \ contrib/intro/overview.svg \ -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:37 UTC
[Libguestfs] [PATCH 31/46] podwrapper: guestunmount is a libguestfs page, don't link it to he.net.
From: "Richard W.M. Jones" <rjones@redhat.com> Cherry picked from commit bd30d3a61ce9d14f2f744870a5d4ed8167d609e2 and commit 0087cf2531bfef7bec66d6cdfb1f8143ecd5ecb2. Note that libguestfs 1.20 does not use guestunmount. --- podwrapper.pl.in | 1 + 1 file changed, 1 insertion(+) diff --git a/podwrapper.pl.in b/podwrapper.pl.in index af21ef0..c14044c 100755 --- a/podwrapper.pl.in +++ b/podwrapper.pl.in @@ -447,6 +447,7 @@ SUBHTML: { return 1 if /^libguestf/; return 1 if /^guestf/; return 1 if /^guestmount/; + return 1 if /^guestunmount/; return 1 if /^hivex/; return 1 if /^febootstrap/; return 1 if /^supermin/; -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:37 UTC
[Libguestfs] [PATCH 32/46] utils: Move guestfs___drive_name function to the utilities library.
From: "Richard W.M. Jones" <rjones@redhat.com> For some historical reason, it was stuck in src/launch-direct.c and the comment referred to launch-appliance.c! (cherry picked from commit 00cbb5c1854a52a5b4742aa7ca9601a9aaaab529) (cherry picked from commit 750841e389b14318f698dd57b26bdfada5c0c78f) --- src/guestfs-internal-frontend.h | 1 + src/guestfs-internal.h | 3 --- src/launch-appliance.c | 12 ------------ src/utils.c | 23 +++++++++++++++++++++++ 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/guestfs-internal-frontend.h b/src/guestfs-internal-frontend.h index 06ed37f..ca1701f 100644 --- a/src/guestfs-internal-frontend.h +++ b/src/guestfs-internal-frontend.h @@ -96,6 +96,7 @@ extern void guestfs___free_string_list (char **); extern size_t guestfs___count_strings (char *const *); extern char *guestfs___exit_status_to_string (int status, const char *cmd_name, char *buffer, size_t buflen); extern int guestfs___random_string (char *ret, size_t len); +extern char *guestfs___drive_name (size_t index, char *ret); /* These functions are used internally by the CLEANUP_* macros. * Don't call them directly. diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h index 428fdb9..7c37e57 100644 --- a/src/guestfs-internal.h +++ b/src/guestfs-internal.h @@ -521,9 +521,6 @@ extern void guestfs___launch_failed_error (guestfs_h *g); extern char *guestfs___appliance_command_line (guestfs_h *g, const char *appliance_dev, int flags); #define APPLIANCE_COMMAND_LINE_IS_TCG 1 -/* launch-appliance.c */ -extern char *guestfs___drive_name (size_t index, char *ret); - /* inspect.c */ extern void guestfs___free_inspect_info (guestfs_h *g); extern int guestfs___feature_available (guestfs_h *g, const char *feature); diff --git a/src/launch-appliance.c b/src/launch-appliance.c index f0278ce..69c4145 100644 --- a/src/launch-appliance.c +++ b/src/launch-appliance.c @@ -1030,18 +1030,6 @@ qemu_drive_param (guestfs_h *g, const struct drive *drv, size_t index) return r; /* caller frees */ } -/* https://rwmj.wordpress.com/2011/01/09/how-are-linux-drives-named-beyond-drive-26-devsdz/ */ -char * -guestfs___drive_name (size_t index, char *ret) -{ - if (index >= 26) - ret = guestfs___drive_name (index/26 - 1, ret); - index %= 26; - *ret++ = 'a' + index; - *ret = '\0'; - return ret; -} - static int shutdown_appliance (guestfs_h *g, int check_for_errors) { diff --git a/src/utils.c b/src/utils.c index 01c31d6..54d9d7e 100644 --- a/src/utils.c +++ b/src/utils.c @@ -31,6 +31,11 @@ #include "guestfs.h" #include "guestfs-internal-frontend.h" +/* Note that functions in libutils are used by the tools and language + * bindings. Therefore these must not call internal library functions + * such as safe_*, error or perrorf. + */ + void guestfs___free_string_list (char **argv) { @@ -122,3 +127,21 @@ guestfs___random_string (char *ret, size_t len) return 0; } + +/* This turns a drive index (eg. 27) into a drive name (eg. "ab"). + * Drive indexes count from 0. The return buffer has to be large + * enough for the resulting string, and the returned pointer points to + * the *end* of the string. + * + * https://rwmj.wordpress.com/2011/01/09/how-are-linux-drives-named-beyond-drive-26-devsdz/ + */ +char * +guestfs___drive_name (size_t index, char *ret) +{ + if (index >= 26) + ret = guestfs___drive_name (index/26 - 1, ret); + index %= 26; + *ret++ = 'a' + index; + *ret = '\0'; + return ret; +} -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:37 UTC
[Libguestfs] [PATCH 33/46] cmd: Better type checking in CLEANUP_CMD_CLOSE macro.
From: "Richard W.M. Jones" <rjones@redhat.com> (cherry picked from commit d0a205778698ea3b70623ad73302e739cf631d3c) (cherry picked from commit db41261968c859d12f3217efe575b53963d6309a) --- src/command.c | 4 ++-- src/guestfs-internal.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/command.c b/src/command.c index 380bc16..38e1aaf 100644 --- a/src/command.c +++ b/src/command.c @@ -680,9 +680,9 @@ guestfs___cmd_close (struct command *cmd) } void -guestfs___cleanup_cmd_close (void *ptr) +guestfs___cleanup_cmd_close (struct command **ptr) { - guestfs___cmd_close (* (struct command **) ptr); + guestfs___cmd_close (*ptr); } /* Deal with buffering stdout for the callback. */ diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h index 7c37e57..c6b64fd 100644 --- a/src/guestfs-internal.h +++ b/src/guestfs-internal.h @@ -621,6 +621,6 @@ extern void guestfs___cmd_close (struct command *); #else #define CLEANUP_CMD_CLOSE #endif -extern void guestfs___cleanup_cmd_close (void *ptr); +extern void guestfs___cleanup_cmd_close (struct command **); #endif /* GUESTFS_INTERNAL_H_ */ -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:37 UTC
[Libguestfs] [PATCH 34/46] list-filesystems: Don't fail if there are no filesystems found (RHBZ#995711).
From: "Richard W.M. Jones" <rjones@redhat.com> list-filesystems was returning NULL (but not setting an error) if no filesystems were found. Instead return an empty list. (cherry picked from commit f1d2934216d3fca0501946c8ae0e5c7cd370e6b6) (cherry picked from commit 19309661008ef1d13c05fad5401d95f260fbdae2) --- src/listfs.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/listfs.c b/src/listfs.c index 4bcdf51..b87a021 100644 --- a/src/listfs.c +++ b/src/listfs.c @@ -46,7 +46,7 @@ char ** guestfs__list_filesystems (guestfs_h *g) { size_t i; - char **ret = NULL; + char **ret; size_t ret_size = 0; CLEANUP_FREE_STRING_LIST char **devices = NULL; @@ -56,6 +56,13 @@ guestfs__list_filesystems (guestfs_h *g) CLEANUP_FREE_STRING_LIST char **ldmvols = NULL; CLEANUP_FREE_STRING_LIST char **ldmparts = NULL; + /* We need to initialize this with an empty list so that if there + * are no filesystems at all, we return an empty list (not NULL). + * See also add_vfs function below. + */ + ret = safe_malloc (g, sizeof (char *)); + ret[0] = NULL; + /* Look to see if any devices directly contain filesystems * (RHBZ#590167). However vfs-type will fail to tell us anything * useful about devices which just contain partitions, so we also -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:37 UTC
[Libguestfs] [PATCH 35/46] lib: Add stringsbuf mini-library for constructing lists of strings.
From: "Richard W.M. Jones" <rjones@redhat.com> This is modelled on similar code in the daemon that we have used successfully for a long time. (cherry picked from commit 35278e4c186badb9e243628771da4cbd068ffaa0) (cherry picked from commit 7fd3b1cc8a485544eca61cc3c8b0f9f2a3c18bb2) --- po/POTFILES | 1 + src/Makefile.am | 1 + src/guestfs-internal.h | 24 ++++++++++++++ src/stringsbuf.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 114 insertions(+) create mode 100644 src/stringsbuf.c diff --git a/po/POTFILES b/po/POTFILES index a98535e..7b28d38 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -270,6 +270,7 @@ src/match.c src/osinfo.c src/private-data.c src/proto.c +src/stringsbuf.c src/tmpdirs.c src/utils.c test-tool/test-tool.c diff --git a/src/Makefile.am b/src/Makefile.am index 3473b01..359f79c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -113,6 +113,7 @@ libguestfs_la_SOURCES = \ osinfo.c \ private-data.c \ proto.c \ + stringsbuf.c \ tmpdirs.c \ libguestfs.syms diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h index c6b64fd..0675123 100644 --- a/src/guestfs-internal.h +++ b/src/guestfs-internal.h @@ -483,6 +483,30 @@ extern int guestfs___match6 (guestfs_h *g, const char *str, const pcre *re, char #define match3 guestfs___match3 #define match6 guestfs___match6 +/* stringsbuf.c */ +struct stringsbuf { + char **argv; + size_t size; + size_t alloc; +}; +#define DECLARE_STRINGSBUF(v) \ + struct stringsbuf (v) = { .argv = NULL, .size = 0, .alloc = 0 } + +extern void guestfs___add_string_nodup (guestfs_h *g, struct stringsbuf *sb, char *str); +extern void guestfs___add_string (guestfs_h *g, struct stringsbuf *sb, const char *str); +extern void guestfs___add_sprintf (guestfs_h *g, struct stringsbuf *sb, const char *fs, ...) + __attribute__((format (printf,3,4))); +extern void guestfs___end_stringsbuf (guestfs_h *g, struct stringsbuf *sb); + +extern void guestfs___free_stringsbuf (struct stringsbuf *sb); + +#ifdef HAVE_ATTRIBUTE_CLEANUP +#define CLEANUP_FREE_STRINGSBUF __attribute__((cleanup(guestfs___cleanup_free_stringsbuf))) +#else +#define CLEANUP_FREE_STRINGSBUF +#endif +extern void guestfs___cleanup_free_stringsbuf (struct stringsbuf *sb); + /* proto.c */ extern int guestfs___send (guestfs_h *g, int proc_nr, uint64_t progress_hint, uint64_t optargs_bitmask, xdrproc_t xdrp, char *args); extern int guestfs___recv (guestfs_h *g, const char *fn, struct guestfs_message_header *hdr, struct guestfs_message_error *err, xdrproc_t xdrp, char *ret); diff --git a/src/stringsbuf.c b/src/stringsbuf.c new file mode 100644 index 0000000..df1dfd6 --- /dev/null +++ b/src/stringsbuf.c @@ -0,0 +1,88 @@ +/* libguestfs + * Copyright (C) 2013 Red Hat Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* Note: Don't confuse this with stringsbuf in the daemon. */ + +#include <config.h> + +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> + +#include "guestfs.h" +#include "guestfs-internal.h" + +void +guestfs___add_string_nodup (guestfs_h *g, struct stringsbuf *sb, char *str) +{ + if (sb->size >= sb->alloc) { + sb->alloc += 64; + sb->argv = safe_realloc (g, sb->argv, sb->alloc * sizeof (char *)); + } + + sb->argv[sb->size] = str; + sb->size++; +} + +void +guestfs___add_string (guestfs_h *g, struct stringsbuf *sb, const char *str) +{ + guestfs___add_string_nodup (g, sb, safe_strdup (g, str)); +} + +void +guestfs___add_sprintf (guestfs_h *g, struct stringsbuf *sb, + const char *fs, ...) +{ + va_list args; + char *str; + int r; + + va_start (args, fs); + r = vasprintf (&str, fs, args); + va_end (args); + if (r == -1) + g->abort_cb (); + + guestfs___add_string_nodup (g, sb, str); +} + +void +guestfs___end_stringsbuf (guestfs_h *g, struct stringsbuf *sb) +{ + guestfs___add_string_nodup (g, sb, NULL); +} + +void +guestfs___free_stringsbuf (struct stringsbuf *sb) +{ + size_t i; + + if (sb->argv) { + for (i = 0; i < sb->size; ++i) + free (sb->argv[i]); + } + free (sb->argv); +} + +void +guestfs___cleanup_free_stringsbuf (struct stringsbuf *sb) +{ + guestfs___free_stringsbuf (sb); +} -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:37 UTC
[Libguestfs] [PATCH 36/46] cleanups: Use correct types for some cleanup functions.
From: "Richard W.M. Jones" <rjones@redhat.com> (cherry picked from commit f68d5ee16c88df4a3fe2233ba948fb4780fa2a09) (cherry picked from commit 61f4a56c9d8c17d9467ef902b96c5886222be661) --- src/cleanup.c | 8 ++++---- src/guestfs-internal-frontend.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cleanup.c b/src/cleanup.c index ef2e8ed..ebd3446 100644 --- a/src/cleanup.c +++ b/src/cleanup.c @@ -46,9 +46,9 @@ guestfs___cleanup_free (void *ptr) } void -guestfs___cleanup_free_string_list (void *ptr) +guestfs___cleanup_free_string_list (char ***ptr) { - guestfs___free_string_list (* (char ***) ptr); + guestfs___free_string_list (*ptr); } void @@ -61,9 +61,9 @@ guestfs___cleanup_hash_free (void *ptr) } void -guestfs___cleanup_unlink_free (void *ptr) +guestfs___cleanup_unlink_free (char **ptr) { - char *filename = * (char **) ptr; + char *filename = *ptr; if (filename) { unlink (filename); diff --git a/src/guestfs-internal-frontend.h b/src/guestfs-internal-frontend.h index ca1701f..eba1c0e 100644 --- a/src/guestfs-internal-frontend.h +++ b/src/guestfs-internal-frontend.h @@ -102,9 +102,9 @@ extern char *guestfs___drive_name (size_t index, char *ret); * Don't call them directly. */ extern void guestfs___cleanup_free (void *ptr); -extern void guestfs___cleanup_free_string_list (void *ptr); +extern void guestfs___cleanup_free_string_list (char ***ptr); extern void guestfs___cleanup_hash_free (void *ptr); -extern void guestfs___cleanup_unlink_free (void *ptr); +extern void guestfs___cleanup_unlink_free (char **ptr); extern void guestfs___cleanup_xmlBufferFree (void *ptr); extern void guestfs___cleanup_xmlFreeDoc (void *ptr); extern void guestfs___cleanup_xmlFreeURI (void *ptr); -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:37 UTC
[Libguestfs] [PATCH 37/46] FAQ: Delete section about Ubuntu 10.04.
From: "Richard W.M. Jones" <rjones@redhat.com> The link was broken, and we don't support Ubuntu 10.04 (maybe the 'oldlinux' branch does). (cherry picked from commit 937a9a35320edb781721de5537d750c004872c98) (cherry picked from commit 023dc6f23cb9b94e5c6ef20aae7314b36784fcbf) --- examples/guestfs-faq.pod | 5 ----- 1 file changed, 5 deletions(-) diff --git a/examples/guestfs-faq.pod b/examples/guestfs-faq.pod index 1440b53..defb9e1 100644 --- a/examples/guestfs-faq.pod +++ b/examples/guestfs-faq.pod @@ -319,11 +319,6 @@ So every user should do this: =over 4 -=item Ubuntu 10.04 - -See: -L<http://libguestfs.org/download/binaries/ubuntu1004-packages/> - =item Ubuntu 12.04 libguestfs in this version of Ubuntu works, but you need to update -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:37 UTC
[Libguestfs] [PATCH 38/46] FAQ: Move #debug anchor back to the right place.
From: "Richard W.M. Jones" <rjones@redhat.com> This was accidentally moved by this commit: commit b8b5ed65c26dd19a0bc9f8282a50c6dff90c456a Author: Richard W.M. Jones <rjones@redhat.com> Date: Wed May 23 11:46:23 2012 +0100 FAQ: Add section about using libguestfs in closed source programs. (cherry picked from commit 0a484e868f5f0b7f6245a80f67e09c8210721dac) (cherry picked from commit e02bbeabb1ca73328a94f63258615b48ceb48c51) --- examples/guestfs-faq.pod | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/guestfs-faq.pod b/examples/guestfs-faq.pod index defb9e1..a425678 100644 --- a/examples/guestfs-faq.pod +++ b/examples/guestfs-faq.pod @@ -731,13 +731,6 @@ Once you're familiar with the API overview, you should look at this list of starting points for other language bindings: L<guestfs(3)/USING LIBGUESTFS WITH OTHER PROGRAMMING LANGUAGES>. -=begin html - -<!-- old anchor for the next section --> -<a name="debug"/> - -=end html - =head2 Can I use libguestfs in my proprietary / closed source / commercial program? @@ -749,6 +742,13 @@ In the source tree the license is in the file C<COPYING.LIB> (LGPLv2+ for the library and bindings) and C<COPYING> (GPLv2+ for the standalone programs). +=begin html + +<!-- old anchor for the next section --> +<a name="debug"/> + +=end html + =head1 DEBUGGING LIBGUESTFS B<In summary:> enable debugging by setting these two environment -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:37 UTC
[Libguestfs] [PATCH 39/46] FAQ: Replace the debugging section (again) with a checklist of information we need to start to fix bugs.
From: "Richard W.M. Jones" <rjones@redhat.com> (cherry picked from commit abc59d776a12fb96de6ff927054f3db2a9ed4fc4) (cherry picked from commit a9f7bd6934ccfbbf472f2d71df9a67865fe06381) --- examples/guestfs-faq.pod | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/examples/guestfs-faq.pod b/examples/guestfs-faq.pod index a425678..aae04cc 100644 --- a/examples/guestfs-faq.pod +++ b/examples/guestfs-faq.pod @@ -751,26 +751,47 @@ standalone programs). =head1 DEBUGGING LIBGUESTFS -B<In summary:> enable debugging by setting these two environment -variables before running the program: +=head2 Help, it's not working! + +Please supply all the information in this checklist, in an +email sent to C<libguestfs> @ C<redhat.com>: + +=over 4 + +=item * + +What are you trying to achieve? + +=item * + +What exact commands did you run? + +=item * + +What was the precise error / output of these commands? + +=item * + +Enable debugging, run the commands again, and capture the B<complete> +output. B<Do not edit the output.> export LIBGUESTFS_DEBUG=1 export LIBGUESTFS_TRACE=1 -This will produce a lot of output. Put the B<complete> output in an -email message or pastebin and send it -L<to the mailing list|/What mailing lists or chat rooms are available?>. -B<Do not edit the output.> +=item * Include the version of libguestfs, the operating system version, and how you installed libguestfs (eg. from source, C<yum install>, etc.) -If no libguestfs program works, run the program below and paste the -B<complete, unedited> output into an email or pastebin and send it to -the mailing list: +=item * + +If no libguestfs program seems to work at all, run the program below +and paste the B<complete, unedited> output into the email: libguestfs-test-tool +=back + =head2 How do I debug when using any libguestfs program or tool (eg. virt-v2v or virt-df)? -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:37 UTC
[Libguestfs] [PATCH 40/46] Fix to src/proto.c in libguestfs so it will compile with portablexdr under mingw.
From: Or Goshen <oberonc@gmail.com> (cherry picked from commit 18b40a88925df737d3552fa646d35a185feb6c62) (cherry picked from commit 5fe8a679eef1339f25c5190bfc15709332c7f116) --- src/proto.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/proto.c b/src/proto.c index f3b27b6..93f5517 100644 --- a/src/proto.c +++ b/src/proto.c @@ -785,7 +785,7 @@ guestfs___send (guestfs_h *g, int proc_nr, { struct guestfs_message_header hdr; XDR xdr; - u_int32_t len; + uint32_t len; int serial = g->msg_next_serial++; int r; CLEANUP_FREE char *msg_out = NULL; @@ -962,7 +962,7 @@ send_file_complete (guestfs_h *g) static int send_file_chunk (guestfs_h *g, int cancel, const char *buf, size_t buflen) { - u_int32_t len; + uint32_t len; int r; guestfs_chunk chunk; XDR xdr; -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:37 UTC
[Libguestfs] [PATCH 41/46] launch: direct: Don't try to wait for qemu if parent process forked (RHBZ#998482).
From: "Richard W.M. Jones" <rjones@redhat.com> When using guestfish --remote, libguestfs is not the parent of qemu, so waitpid is expected to return -ECHILD. And indeed guestfish --remote would print a bogus error message in this case: libguestfs: error: waitpid (qemu): No child processes If the parent process forked into the background, then it should have called 'set_recovery_proc 0' so we can use this to determine if we need to wait for qemu. Thanks: Kazuya Saito for reporting and identifying the issue. (cherry picked from commit a843b5e5e32c151e7b0c74bb4f7be1030f9ac85b) (cherry picked from commit 8b354dbbfd412c860fb65c7674fe1f25059e3a31) --- src/launch-appliance.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/launch-appliance.c b/src/launch-appliance.c index 69c4145..bb9c832 100644 --- a/src/launch-appliance.c +++ b/src/launch-appliance.c @@ -1044,7 +1044,7 @@ shutdown_appliance (guestfs_h *g, int check_for_errors) if (g->app.recoverypid > 0) kill (g->app.recoverypid, 9); /* Wait for subprocess(es) to exit. */ - if (g->app.pid > 0) { + if (g->recovery_proc /* RHBZ#998482 */ && g->app.pid > 0) { if (waitpid (g->app.pid, &status, 0) == -1) { perrorf (g, "waitpid (qemu)"); ret = -1; -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:37 UTC
[Libguestfs] [PATCH 42/46] fish: Document that guestfish --remote --add won't work as expected (RHBZ#998513).
From: "Richard W.M. Jones" <rjones@redhat.com> (cherry picked from commit 7e396954611d827dc236a114ed22a781687c002d) (cherry picked from commit 23e9cc95fa9cb8046a75613e0cc9ac92ad647c04) --- fish/guestfish.pod | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/fish/guestfish.pod b/fish/guestfish.pod index d1d9827..8c34cbf 100644 --- a/fish/guestfish.pod +++ b/fish/guestfish.pod @@ -1027,6 +1027,24 @@ and cleans up guestfish when the script exits: # ... +=head2 REMOTE CONTROL DOES NOT WORK WITH I<-a> ETC. OPTIONS + +Options such as I<-a>, I<--add>, I<-N>, I<--new> etc don't interact +properly with remote support. They are processed locally, and not +sent through to the remote guestfish. In particular this won't do +what you expect: + + guestfish --remote --add disk.img + +Don't use these options. Use the equivalent commands instead, eg: + + guestfish --remote add-drive disk.img + +or: + + guestfish --remote + ><fs> add disk.img + =head2 REMOTE CONTROL RUN COMMAND HANGING Using the C<run> (or C<launch>) command remotely in a command -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:37 UTC
[Libguestfs] [PATCH 43/46] tests: change noinst to check
From: Olaf Hering <olaf@aepfle.de> This change avoids the hard requirement for qemu-tools during package build. Signed-off-by: Olaf Hering <olaf@aepfle.de> (cherry picked from commit cb7b1c56b7cf447dd9f2ea4dde5cf65e9f9f8cf8) (cherry picked from commit 9b62b700baf25e288a62a960fbe770bb90014c8b) --- tests/data/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index f2bfed4..b8f76b2 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -38,7 +38,7 @@ EXTRA_DIST = \ lib-x86_64.so \ test-grep.txt -noinst_DATA = test.iso +check_DATA = test.iso CLEANFILES = \ test.iso test.sqsh \ -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:37 UTC
[Libguestfs] [PATCH 44/46] daemon: hivex: Define empty hivex_finalize function in case !HAVE_HIVEX.
From: "Richard W.M. Jones" <rjones@redhat.com> Thanks: Olaf Hering (see previous commit). (cherry picked from commit d188594b11f2a16fe72b963a55edf41d4aa2e3aa) (cherry picked from commit 379ced49de0fc4e4fac3ed701b382e3b0e1bc48a) --- daemon/hivex.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/daemon/hivex.c b/daemon/hivex.c index ce6164e..b47329e 100644 --- a/daemon/hivex.c +++ b/daemon/hivex.c @@ -417,4 +417,9 @@ do_hivex_node_set_value (int64_t nodeh, OPTGROUP_HIVEX_NOT_AVAILABLE +void +hivex_finalize (void) +{ +} + #endif /* !HAVE_HIVEX */ -- 1.8.3.1
Richard W.M. Jones
2013-Aug-24 12:37 UTC
[Libguestfs] [PATCH 45/46] daemon: sh: Fix missing initializer which caused segfault (RHBZ#1000121).
From: "Richard W.M. Jones" <rjones@redhat.com> Thanks: Olaf Hering. (cherry picked from commit fc2947b1125aa34b5f04efd2d39cb82b2ebba586) (cherry picked from commit aea97611263140aa9efe38388bb0418b7f2344ef) --- daemon/command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daemon/command.c b/daemon/command.c index db82b52..99a58c1 100644 --- a/daemon/command.c +++ b/daemon/command.c @@ -41,7 +41,7 @@ char * do_command (char *const *argv) { char *out; - CLEANUP_FREE char *err; + CLEANUP_FREE char *err = NULL; int r; CLEANUP_FREE char *sysroot_dev = NULL, *sysroot_dev_pts = NULL, *sysroot_proc = NULL, *sysroot_sys = NULL; -- 1.8.3.1
From: "Richard W.M. Jones" <rjones@redhat.com> --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index e0984ed..c20b978 100644 --- a/configure.ac +++ b/configure.ac @@ -20,7 +20,7 @@ # freeform string. m4_define([libguestfs_major], [1]) m4_define([libguestfs_minor], [20]) -m4_define([libguestfs_release], [10]) +m4_define([libguestfs_release], [11]) AC_INIT([libguestfs],libguestfs_major.libguestfs_minor.libguestfs_release) AC_CONFIG_AUX_DIR([build-aux]) -- 1.8.3.1
Maybe Matching Threads
- [PATCH 00/67] Proposed patches for libguestfs 1.22.6.
- [PATCH 0/4] Not quite working User-Mode Linux backend.
- [PATCH v2 0/4] Experimental User-Mode Linux backend.
- [PATCH] [repost] build: Remove ./configure --enable-valgrind-daemon.
- [PATCH 00/14] Run the daemon under valgrind and fix resultant errors.