Pino Toscano
2014-Oct-23 18:18 UTC
[Libguestfs] [PATCH 00/16] Small bits of non-Linux porting
Hi, from time to time, there have been requests (or attempts, like the mingw port posted on the list some months ago) to make libguestfs work on OSes different than Linux. Of course this would imply using a fixed appliance, since it is currently heavily dependent on Linux. The attached series provides some easy changes in this direction, resolving some of the easy issues found in porting to FreeBSD; while they don't solve all the build and runtime issues, at least they get libguestfs a bit closer to it, while causing no actual changes on Linux. Other issues (with partial solutions, or not dealt yet) w.r.t porting to non-Linux so far found are the following: a) lack of UNIX_PATH_MAX (which seems Linux-specific anyway) b) usage of meta /dev/fd/N files; while on (k)FreeBSD there's a fdescfs filesystem providing it, IMHO a better solution would be adding API using FDs, like download_fd, upload_fd, tar_in_fd, and tar_out_fd c) program_invocation_short_name is specific to GNU libc d) iconv outside of GNU libc, in an own libintl e) different cli tools, and different output for them Also, as mentioned in the mingw porting patch, https://www.redhat.com/archives/libguestfs/2014-February/msg00160.html a way to disable entirely the usage of supermin (thus leaving only the fixed appliance as appliance style) is needed too. Thanks, -- Pino Pino Toscano (16): build: use the ptsname_r gnulib module Include string.h where needed Include sys/wait.h where needed build: look for and use sys/endian.h fuse: test-fuse: enclose acl vars within HAVE_ACL p2v: remove unused variable normalize iconv handling builder: rename "program_name" into "progname" tests: isolate iso_system_id baseline string Include stdint.h where needed build: use $(SED) instead of sed when possible tests/c-api: add a way to skip test when host and appliance differ actions: mark as IfNotCrossAppliance tests of command and command_lines customize, mllib: use the libvirt CFLAGS tests: switch from get_current_dir_name to getcwd(0, NULL) configure: map also amd64 as host_cpu to x86_64 qemu bootstrap | 2 ++ builder/index-parse.y | 4 +-- builder/index-parser-c.c | 2 +- builder/index-struct.h | 2 +- configure.ac | 4 ++- customize/Makefile.am | 1 + daemon/ext2.c | 1 + daemon/hotplug.c | 1 + daemon/initrd.c | 1 + daemon/journal.c | 5 +++ daemon/ldm.c | 1 + daemon/lvm-filter.c | 1 + daemon/mktemp.c | 1 + daemon/utsname.c | 1 + diff/diff.c | 1 + fish/Makefile.am | 2 +- fish/file-edit.c | 1 + fuse/test-fuse.c | 2 ++ generator/actions.ml | 50 +++++++++++++++--------------- generator/c.ml | 1 + generator/tests_c_api.ml | 20 +++++++++++- generator/types.ml | 5 +++ m4/.gitignore | 3 ++ mllib/Makefile.am | 1 + p2v/Makefile.am | 2 +- p2v/ssh.c | 2 -- po-docs/Makefile.am | 2 +- run.in | 2 +- sparsify/statvfs-c.c | 1 + src/Makefile.am | 3 +- src/create.c | 1 + src/dbdump.c | 1 + src/file.c | 1 + src/filearch.c | 1 + src/fuse.c | 1 + src/info.c | 1 + src/inspect-apps.c | 3 ++ src/inspect-fs-windows.c | 5 ++- src/inspect-icon.c | 1 + src/journal.c | 3 ++ src/launch-direct.c | 1 + src/launch-libvirt.c | 1 + src/launch-unix.c | 1 + src/libvirt-auth.c | 1 + src/libvirt-domain.c | 1 + tests/c-api/test-pwd.c | 2 +- tests/c-api/tests-main.c | 39 +++++++++++++++++++++++ tests/c-api/tests.h | 1 + tests/events/test-libvirt-auth-callbacks.c | 4 +-- tests/guests/Makefile.am | 2 +- 50 files changed, 153 insertions(+), 43 deletions(-) -- 1.9.3
Pino Toscano
2014-Oct-23 18:18 UTC
[Libguestfs] [PATCH 01/16] build: use the ptsname_r gnulib module
virt-p2v uses ptsname_r, which is not portable but implemented by gnulib. --- bootstrap | 1 + m4/.gitignore | 3 +++ 2 files changed, 4 insertions(+) diff --git a/bootstrap b/bootstrap index b4afcdb..b7a45ff 100755 --- a/bootstrap +++ b/bootstrap @@ -77,6 +77,7 @@ openat perror pipe2 pread +ptsname_r read-file readlink select diff --git a/m4/.gitignore b/m4/.gitignore index ed73ab3..605cd26 100644 --- a/m4/.gitignore +++ b/m4/.gitignore @@ -271,3 +271,6 @@ /xstrtol.m4 /xvasprintf.m4 /yield.m4 +/isatty.m4 +/ptsname_r.m4 +/ttyname_r.m4 -- 1.9.3
Pino Toscano
2014-Oct-23 18:18 UTC
[Libguestfs] [PATCH 02/16] Include string.h where needed
Required for using strlen, memcpy, etc. Apparently implicitly pulled so far. --- daemon/hotplug.c | 1 + daemon/ldm.c | 1 + daemon/mktemp.c | 1 + daemon/utsname.c | 1 + generator/c.ml | 1 + src/create.c | 1 + src/file.c | 1 + src/fuse.c | 1 + src/info.c | 1 + src/launch-direct.c | 1 + src/launch-libvirt.c | 1 + src/launch-unix.c | 1 + src/libvirt-auth.c | 1 + src/libvirt-domain.c | 1 + 14 files changed, 14 insertions(+) diff --git a/daemon/hotplug.c b/daemon/hotplug.c index 7ff4ced..2f159c6 100644 --- a/daemon/hotplug.c +++ b/daemon/hotplug.c @@ -23,6 +23,7 @@ #include <unistd.h> #include <errno.h> #include <time.h> +#include <string.h> #include "guestfs_protocol.h" #include "daemon.h" diff --git a/daemon/ldm.c b/daemon/ldm.c index aad7f78..3563313 100644 --- a/daemon/ldm.c +++ b/daemon/ldm.c @@ -24,6 +24,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <glob.h> +#include <string.h> #if HAVE_YAJL #include <yajl/yajl_tree.h> diff --git a/daemon/mktemp.c b/daemon/mktemp.c index cacb48d..39231ad 100644 --- a/daemon/mktemp.c +++ b/daemon/mktemp.c @@ -21,6 +21,7 @@ #include <stdio.h> #include <stdlib.h> +#include <string.h> #include "guestfs_protocol.h" #include "daemon.h" diff --git a/daemon/utsname.c b/daemon/utsname.c index dc49226..17a82c3 100644 --- a/daemon/utsname.c +++ b/daemon/utsname.c @@ -21,6 +21,7 @@ #include <stdio.h> #include <stdlib.h> #include <sys/utsname.h> +#include <string.h> #include "guestfs_protocol.h" #include "daemon.h" diff --git a/generator/c.ml b/generator/c.ml index 1fa05ab..9e17d32 100644 --- a/generator/c.ml +++ b/generator/c.ml @@ -1221,6 +1221,7 @@ and generate_client_actions hash () #include <inttypes.h> #include <sys/types.h> #include <sys/stat.h> +#include <string.h> #include \"guestfs.h\" #include \"guestfs-internal.h\" diff --git a/src/create.c b/src/create.c index 0cfe6be..621ace5 100644 --- a/src/create.c +++ b/src/create.c @@ -29,6 +29,7 @@ #include <sys/wait.h> #include <sys/ioctl.h> #include <errno.h> +#include <string.h> #ifdef HAVE_LINUX_FS_H #include <linux/fs.h> diff --git a/src/file.c b/src/file.c index 91f7947..6a58bfe 100644 --- a/src/file.c +++ b/src/file.c @@ -26,6 +26,7 @@ #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> +#include <string.h> #include "full-read.h" #include "full-write.h" diff --git a/src/fuse.c b/src/fuse.c index 08a8784..258a863 100644 --- a/src/fuse.c +++ b/src/fuse.c @@ -24,6 +24,7 @@ #include <errno.h> #include <sys/types.h> #include <sys/wait.h> +#include <string.h> #if HAVE_FUSE /* See <attr/xattr.h> */ diff --git a/src/info.c b/src/info.c index 175c503..1bc079a 100644 --- a/src/info.c +++ b/src/info.c @@ -29,6 +29,7 @@ #include <sys/stat.h> #include <sys/wait.h> #include <assert.h> +#include <string.h> #if HAVE_YAJL #include <yajl/yajl_tree.h> diff --git a/src/launch-direct.c b/src/launch-direct.c index 5301176..021df94 100644 --- a/src/launch-direct.c +++ b/src/launch-direct.c @@ -34,6 +34,7 @@ #include <sys/un.h> #include <grp.h> #include <assert.h> +#include <string.h> #include <pcre.h> diff --git a/src/launch-libvirt.c b/src/launch-libvirt.c index f8f818a..7206b33 100644 --- a/src/launch-libvirt.c +++ b/src/launch-libvirt.c @@ -30,6 +30,7 @@ #include <sys/stat.h> #include <sys/wait.h> #include <assert.h> +#include <string.h> #ifdef HAVE_LIBVIRT #include <libvirt/libvirt.h> diff --git a/src/launch-unix.c b/src/launch-unix.c index 489a046..c5e4438 100644 --- a/src/launch-unix.c +++ b/src/launch-unix.c @@ -24,6 +24,7 @@ #include <fcntl.h> #include <sys/socket.h> #include <sys/un.h> +#include <string.h> #include "guestfs.h" #include "guestfs-internal.h" diff --git a/src/libvirt-auth.c b/src/libvirt-auth.c index f8ed1b1..1eeac75 100644 --- a/src/libvirt-auth.c +++ b/src/libvirt-auth.c @@ -21,6 +21,7 @@ #include <stdio.h> #include <stdlib.h> #include <stdbool.h> +#include <string.h> #ifdef HAVE_LIBVIRT #include <libvirt/libvirt.h> diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 7e0a0d9..59bb4bc 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -22,6 +22,7 @@ #include <stdlib.h> #include <stdbool.h> #include <assert.h> +#include <string.h> #ifdef HAVE_LIBVIRT #include <libvirt/libvirt.h> -- 1.9.3
Pino Toscano
2014-Oct-23 18:18 UTC
[Libguestfs] [PATCH 03/16] Include sys/wait.h where needed
Required for using WIFEXITED, WEXITSTATUS, etc. Apparently implicitly pulled so far. --- daemon/ext2.c | 1 + daemon/initrd.c | 1 + daemon/lvm-filter.c | 1 + diff/diff.c | 1 + fish/file-edit.c | 1 + src/dbdump.c | 1 + src/filearch.c | 1 + src/inspect-icon.c | 1 + 8 files changed, 8 insertions(+) diff --git a/daemon/ext2.c b/daemon/ext2.c index 2b3674c..31fef25 100644 --- a/daemon/ext2.c +++ b/daemon/ext2.c @@ -23,6 +23,7 @@ #include <inttypes.h> #include <string.h> #include <unistd.h> +#include <sys/wait.h> #include "guestfs_protocol.h" #include "daemon.h" diff --git a/daemon/initrd.c b/daemon/initrd.c index ea34000..ac14826 100644 --- a/daemon/initrd.c +++ b/daemon/initrd.c @@ -25,6 +25,7 @@ #include <unistd.h> #include <fcntl.h> #include <sys/stat.h> +#include <sys/wait.h> #include "guestfs_protocol.h" #include "daemon.h" diff --git a/daemon/lvm-filter.c b/daemon/lvm-filter.c index d82fde0..72fe6ac 100644 --- a/daemon/lvm-filter.c +++ b/daemon/lvm-filter.c @@ -24,6 +24,7 @@ #include <string.h> #include <unistd.h> #include <sys/stat.h> +#include <sys/wait.h> #include <augeas.h> diff --git a/diff/diff.c b/diff/diff.c index ad371b0..b113f29 100644 --- a/diff/diff.c +++ b/diff/diff.c @@ -30,6 +30,7 @@ #include <assert.h> #include <time.h> #include <libintl.h> +#include <sys/wait.h> #include "c-ctype.h" #include "human.h" diff --git a/fish/file-edit.c b/fish/file-edit.c index dd2272b..3efd46d 100644 --- a/fish/file-edit.c +++ b/fish/file-edit.c @@ -32,6 +32,7 @@ #include <sys/stat.h> #include <assert.h> #include <utime.h> +#include <sys/wait.h> #include "guestfs-internal-frontend.h" diff --git a/src/dbdump.c b/src/dbdump.c index 684b2cf..f44f2d4 100644 --- a/src/dbdump.c +++ b/src/dbdump.c @@ -27,6 +27,7 @@ #include <string.h> #include <sys/stat.h> #include <errno.h> +#include <sys/wait.h> #ifdef HAVE_ENDIAN_H #include <endian.h> diff --git a/src/filearch.c b/src/filearch.c index c0380d9..f7673a2 100644 --- a/src/filearch.c +++ b/src/filearch.c @@ -25,6 +25,7 @@ #include <unistd.h> #include <string.h> #include <sys/stat.h> +#include <sys/wait.h> #include <pcre.h> diff --git a/src/inspect-icon.c b/src/inspect-icon.c index 0ffca72..9871fde 100644 --- a/src/inspect-icon.c +++ b/src/inspect-icon.c @@ -27,6 +27,7 @@ #include <string.h> #include <sys/stat.h> #include <errno.h> +#include <sys/wait.h> #include "guestfs.h" #include "guestfs-internal.h" -- 1.9.3
Pino Toscano
2014-Oct-23 18:18 UTC
[Libguestfs] [PATCH 04/16] build: look for and use sys/endian.h
Some OSes have sys/endian.h instead of glibc's endian.h. --- configure.ac | 1 + daemon/journal.c | 5 +++++ src/inspect-apps.c | 3 +++ src/inspect-fs-windows.c | 3 +++ src/journal.c | 3 +++ 5 files changed, 15 insertions(+) diff --git a/configure.ac b/configure.ac index 6c33444..8cd29d7 100644 --- a/configure.ac +++ b/configure.ac @@ -288,6 +288,7 @@ AC_CHECK_HEADERS([\ attr/xattr.h \ byteswap.h \ endian.h \ + sys/endian.h \ errno.h \ linux/fs.h \ linux/raid/md_u.h \ diff --git a/daemon/journal.c b/daemon/journal.c index 3fd2135..a2a1c73 100644 --- a/daemon/journal.c +++ b/daemon/journal.c @@ -22,7 +22,12 @@ #include <stdlib.h> #include <inttypes.h> #include <string.h> +#ifdef HAVE_ENDIAN_H #include <endian.h> +#endif +#ifdef HAVE_SYS_ENDIAN_H +#include <sys/endian.h> +#endif #include "guestfs_protocol.h" #include "daemon.h" diff --git a/src/inspect-apps.c b/src/inspect-apps.c index a77e9ce..b62b432 100644 --- a/src/inspect-apps.c +++ b/src/inspect-apps.c @@ -31,6 +31,9 @@ #ifdef HAVE_ENDIAN_H #include <endian.h> #endif +#ifdef HAVE_SYS_ENDIAN_H +#include <sys/endian.h> +#endif /* be32toh is usually a macro definend in <endian.h>, but it might be * a function in some system so check both, and if neither is defined diff --git a/src/inspect-fs-windows.c b/src/inspect-fs-windows.c index 20e4d7f..6d430d1 100644 --- a/src/inspect-fs-windows.c +++ b/src/inspect-fs-windows.c @@ -32,6 +32,9 @@ #ifdef HAVE_ENDIAN_H #include <endian.h> #endif +#ifdef HAVE_SYS_ENDIAN_H +#include <sys/endian.h> +#endif #include <pcre.h> diff --git a/src/journal.c b/src/journal.c index 61ab352..1070067 100644 --- a/src/journal.c +++ b/src/journal.c @@ -31,6 +31,9 @@ #ifdef HAVE_ENDIAN_H #include <endian.h> #endif +#ifdef HAVE_SYS_ENDIAN_H +#include <sys/endian.h> +#endif #include "full-read.h" -- 1.9.3
Pino Toscano
2014-Oct-23 18:18 UTC
[Libguestfs] [PATCH 05/16] fuse: test-fuse: enclose acl vars within HAVE_ACL
Enclose the acl-related variables within a #ifdef HAVE_ACL block, so when building without acl support and -Werror it can build. --- fuse/test-fuse.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fuse/test-fuse.c b/fuse/test-fuse.c index b675a4c..a341994 100644 --- a/fuse/test-fuse.c +++ b/fuse/test-fuse.c @@ -251,8 +251,10 @@ test_fuse (void) int fd; struct timeval tv[2]; struct timespec ts[2]; +#ifdef HAVE_ACL acl_t acl; char *acl_text; +#endif STAGE ("checking initial files exist"); -- 1.9.3
--- p2v/ssh.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/p2v/ssh.c b/p2v/ssh.c index f3bfcf9..1c0f8b7 100644 --- a/p2v/ssh.c +++ b/p2v/ssh.c @@ -420,8 +420,6 @@ test_connection (struct config *config) } for (;;) { - CLEANUP_FREE char *feature = NULL; - switch (mexp_expect (h, (mexp_regexp[]) { { 100, .re = feature_libguestfs_rewrite_re }, -- 1.9.3
Since the signature of iconv() changes between implementations (the constness of the second parameter, in particular), make use of the iconv module of gnulib to handle these potential differences, including an external (out of libc) iconv implementation. --- bootstrap | 1 + src/Makefile.am | 1 + src/inspect-fs-windows.c | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/bootstrap b/bootstrap index b7a45ff..402ac4e 100755 --- a/bootstrap +++ b/bootstrap @@ -64,6 +64,7 @@ gnumakefile hash hash-pjw human +iconv ignore-value lock maintainer-makefile diff --git a/src/Makefile.am b/src/Makefile.am index 3d06203..e717251 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -161,6 +161,7 @@ libguestfs_la_LIBADD = \ $(LIB_CLOCK_GETTIME) \ $(LIBINTL) \ $(LTLIBTHREAD) \ + $(LTLIBICONV) \ $(SERVENT_LIB) # Force libtool to name the library 'libguestfs.so.0.$(MAX_PROC_NR).0'. diff --git a/src/inspect-fs-windows.c b/src/inspect-fs-windows.c index 6d430d1..619706c 100644 --- a/src/inspect-fs-windows.c +++ b/src/inspect-fs-windows.c @@ -669,7 +669,7 @@ utf16_to_utf8 (/* const */ char *input, size_t len) char *inp = input; char *outp = out; - size_t r = iconv (ic, &inp, &inlen, &outp, &outlen); + size_t r = iconv (ic, (ICONV_CONST char **) &inp, &inlen, &outp, &outlen); if (r == (size_t) -1) { if (errno == E2BIG) { int err = errno; -- 1.9.3
Pino Toscano
2014-Oct-23 18:18 UTC
[Libguestfs] [PATCH 08/16] builder: rename "program_name" into "progname"
"program_name" is already used as shorthand define for program_invocation_short_name. --- builder/index-parse.y | 4 ++-- builder/index-parser-c.c | 2 +- builder/index-struct.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/builder/index-parse.y b/builder/index-parse.y index 06e6a83..36f9f07 100644 --- a/builder/index-parse.y +++ b/builder/index-parse.y @@ -153,8 +153,8 @@ yyerror (YYLTYPE * yylloc, yyscan_t scanner, struct parse_context *context, cons int has_suffix = context->error_suffix != NULL && context->error_suffix[0] != 0; fprintf (stderr, "%s%s%s%ssyntax error at line %d: %s%s%s\n", - context->program_name ? context->program_name : "", - context->program_name ? ": " : "", + context->progname ? context->progname : "", + context->progname ? ": " : "", context->input_file ? context->input_file : "", context->input_file ? ": " : "", yylloc->first_line, msg, diff --git a/builder/index-parser-c.c b/builder/index-parser-c.c index 099bdf8..845abd7 100644 --- a/builder/index-parser-c.c +++ b/builder/index-parser-c.c @@ -56,7 +56,7 @@ virt_builder_parse_index (value progv, value error_suffixv, value filenamev) FILE *in; parse_context_init (&context); - context.program_name = String_val (progv); + context.progname = String_val (progv); context.input_file = String_val (filenamev); context.error_suffix = String_val (error_suffixv); diff --git a/builder/index-struct.h b/builder/index-struct.h index 150535d..ada35e3 100644 --- a/builder/index-struct.h +++ b/builder/index-struct.h @@ -44,7 +44,7 @@ struct parse_context { */ int seen_comments; const char *input_file; - const char *program_name; + const char *progname; const char *error_suffix; }; -- 1.9.3
Pino Toscano
2014-Oct-23 18:18 UTC
[Libguestfs] [PATCH 09/16] tests: isolate iso_system_id baseline string
Move the reference iso_system_id for the isoinfo_device test to an own define for Linux, with an error for unknown OSes. --- generator/actions.ml | 2 +- generator/tests_c_api.ml | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/generator/actions.ml b/generator/actions.ml index 4cfba0d..955f638 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@ -9883,7 +9883,7 @@ this will create the largest possible LV." }; tests = [ InitNone, Always, TestResult ( [["isoinfo_device"; "/dev/sdd"]], - "STREQ (ret->iso_system_id, \"LINUX\") && "^ + "STREQ (ret->iso_system_id, GUESTFS_ISO_SYSTEM_ID) && "^ "STREQ (ret->iso_volume_id, \"CDROM\") && "^ "STREQ (ret->iso_volume_set_id, \"\") && "^ "ret->iso_volume_set_size == 1 && "^ diff --git a/generator/tests_c_api.ml b/generator/tests_c_api.ml index 88aa07e..43a99e3 100644 --- a/generator/tests_c_api.ml +++ b/generator/tests_c_api.ml @@ -47,6 +47,12 @@ let rec generate_c_api_tests () #include \"tests.h\" +#ifdef __linux__ +#define GUESTFS_ISO_SYSTEM_ID \"LINUX\" +#else +#error Missing GUESTFS_ISO_SYSTEM_ID for the current OS +#endif + "; (* Generate a list of commands which are not tested anywhere. *) -- 1.9.3
Pino Toscano
2014-Oct-23 18:18 UTC
[Libguestfs] [PATCH 10/16] Include stdint.h where needed
Required for using int64_t, etc. Apparently implicitly pulled so far. --- sparsify/statvfs-c.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sparsify/statvfs-c.c b/sparsify/statvfs-c.c index 2ad8db3..76bff0b 100644 --- a/sparsify/statvfs-c.c +++ b/sparsify/statvfs-c.c @@ -21,6 +21,7 @@ #include <stdio.h> #include <stdlib.h> #include <sys/statvfs.h> +#include <stdint.h> #include <caml/alloc.h> #include <caml/fail.h> -- 1.9.3
Pino Toscano
2014-Oct-23 18:18 UTC
[Libguestfs] [PATCH 11/16] build: use $(SED) instead of sed when possible
Make use of the sed executable set at configure time. --- fish/Makefile.am | 2 +- p2v/Makefile.am | 2 +- po-docs/Makefile.am | 2 +- run.in | 2 +- src/Makefile.am | 2 +- tests/guests/Makefile.am | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fish/Makefile.am b/fish/Makefile.am index d28a94b..e633422 100644 --- a/fish/Makefile.am +++ b/fish/Makefile.am @@ -163,7 +163,7 @@ endif rc_protocol.c: rc_protocol.x rm -f $@-t $@-t2 $(RPCGEN) $(RPCGEN_DEFS) -c -o $@-t $< - sed 's,\.\./\(\.\./\)*fish,.,' < $@-t > $@-t2 + $(SED) 's,\.\./\(\.\./\)*fish,.,' < $@-t > $@-t2 rm $@-t mv $@-t2 $@ diff --git a/p2v/Makefile.am b/p2v/Makefile.am index cafad0b..3e22b4c 100644 --- a/p2v/Makefile.am +++ b/p2v/Makefile.am @@ -89,7 +89,7 @@ virtp2vdata_DATA = \ # Deal with stupid autotools libexecdir-not-expandable crap. launch-virt-p2v: launch-virt-p2v.in rm -f $@ $@-t - sed 's,@''libexecdir@,$(libexecdir),g' < $< > $@-t + $(SED) 's,@''libexecdir@,$(libexecdir),g' < $< > $@-t chmod 0555 $@-t mv $@-t $@ diff --git a/po-docs/Makefile.am b/po-docs/Makefile.am index 17823ab..8803891 100644 --- a/po-docs/Makefile.am +++ b/po-docs/Makefile.am @@ -57,7 +57,7 @@ libguestfs-docs.pot: po4a.conf --copyright-holder "Red Hat Inc." \ po4a.conf for f in `cd $(srcdir); find $(linguas) -name '*.pod'`; do \ - sed '0,/^=encoding/d' < $$f > $$f.new; \ + $(SED) '0,/^=encoding/d' < $$f > $$f.new; \ mv $$f.new $$f; \ done diff --git a/run.in b/run.in index 1cf7c20..760885f 100755 --- a/run.in +++ b/run.in @@ -267,7 +267,7 @@ else echo "$b/run: command failed with exit code $fail" fi if [ -n "$RUN_OUTPUT_FILE" ]; then - testname=`echo "$1" | sed -e 's,^./,,g'` + testname=`echo "$1" | @SED@ -e 's,^./,,g'` echo "<test rescode=\"$fail\" name=\"$testname\" time=\"$(($end_t - $start_t))\">" >> $RUN_OUTPUT_FILE echo "<![CDATA[" >> $RUN_OUTPUT_FILE # skip the results of test-virt-rescue.pl, as they contain diff --git a/src/Makefile.am b/src/Makefile.am index e717251..be8d3a3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -211,7 +211,7 @@ endif guestfs_protocol.c: guestfs_protocol.x rm -f $@-t $@-t2 $(RPCGEN) $(RPCGEN_DEFS) -c -o $@-t $< - sed 's,\.\./\(\.\./\)*src,.,' < $@-t > $@-t2 + $(SED) 's,\.\./\(\.\./\)*src,.,' < $@-t > $@-t2 rm $@-t mv $@-t2 $@ diff --git a/tests/guests/Makefile.am b/tests/guests/Makefile.am index 62f5d14..e58d563 100644 --- a/tests/guests/Makefile.am +++ b/tests/guests/Makefile.am @@ -67,7 +67,7 @@ blank-%.img: rm -f $@ $@-t $(top_builddir)/run \ ../../fish/guestfish \ - -N $@-t="$$(echo $@ | sed -e 's/blank-//' -e 's/.img//')" exit + -N $@-t="$$(echo $@ | $(SED) -e 's/blank-//' -e 's/.img//')" exit mv $@-t $@ # Make a (dummy) Fedora image. -- 1.9.3
Pino Toscano
2014-Oct-23 18:18 UTC
[Libguestfs] [PATCH 12/16] tests/c-api: add a way to skip test when host and appliance differ
Add a IfNotCrossAppliance prereq for tests, so a test using it can only be run when the appliance is a copy of the running host system; this can help marking tests which run stuff (usually built in the host) inside the appliance. --- generator/tests_c_api.ml | 14 +++++++++++++- generator/types.ml | 5 +++++ tests/c-api/tests-main.c | 39 +++++++++++++++++++++++++++++++++++++++ tests/c-api/tests.h | 1 + 4 files changed, 58 insertions(+), 1 deletion(-) diff --git a/generator/tests_c_api.ml b/generator/tests_c_api.ml index 43a99e3..17a6af9 100644 --- a/generator/tests_c_api.ml +++ b/generator/tests_c_api.ml @@ -67,7 +67,7 @@ let rec generate_c_api_tests () fun { tests = tests } -> let seqs = filter_map ( function - | (_, (Always|IfAvailable _), test, cleanup) -> + | (_, (Always|IfAvailable _|IfNotCrossAppliance), test, cleanup) -> Some (seq_of_test test @ cleanup) | (_, Disabled, _, _) -> None ) tests in @@ -151,6 +151,15 @@ static int pr "\n" in + let utsname_test () + pr " if (using_cross_appliance ()) {\n"; + pr " skipped (\"%s\", \"cannot run when appliance and host are different\");\n" + test_name; + pr " return 0;\n"; + pr " }\n"; + pr "\n" + in + (match optional with | Some group -> group_test group | None -> () @@ -165,6 +174,9 @@ static int generate_one_test_body name i test_name init cleanup | Always -> generate_one_test_body name i test_name init cleanup + | IfNotCrossAppliance -> + utsname_test (); + generate_one_test_body name i test_name init cleanup ); pr "}\n"; diff --git a/generator/types.ml b/generator/types.ml index 63aa235..59aa1a0 100644 --- a/generator/types.ml +++ b/generator/types.ml @@ -253,6 +253,11 @@ and c_api_test_prereq (* Run the test only if 'string' is available in the daemon. *) | IfAvailable of string + (* Run the test when the appliance and the OS differ - for example, + * when using a fixed appliance created in a different OS/distribution. + *) + | IfNotCrossAppliance + (* Some initial scenarios for testing. *) and c_api_test_init (* Do nothing, block devices could contain random stuff including diff --git a/tests/c-api/tests-main.c b/tests/c-api/tests-main.c index e81e15e..6f4816f 100644 --- a/tests/c-api/tests-main.c +++ b/tests/c-api/tests-main.c @@ -25,6 +25,7 @@ #include <unistd.h> #include <fcntl.h> #include <assert.h> +#include <sys/utsname.h> #include <pcre.h> @@ -38,6 +39,8 @@ #include "tests.h" +static int is_cross_appliance; + int init_none (guestfs_h *g) { @@ -395,6 +398,12 @@ substitute_srcdir (const char *path) return ret; } +int +using_cross_appliance (void) +{ + return is_cross_appliance; +} + static void next_test (guestfs_h *g, size_t test_num, const char *test_name) { @@ -475,6 +484,35 @@ create_handle (void) return g; } +static int +check_cross_appliance (guestfs_h *g) +{ + struct utsname host; + CLEANUP_FREE_UTSNAME struct guestfs_utsname *appliance = NULL; + int r; + struct guestfs_utsname host_utsname; + + r = uname (&host); + if (r == -1) { + fprintf (stderr, "call to uname failed\n"); + exit (EXIT_FAILURE); + } + + appliance = guestfs_utsname (g); + if (appliance == NULL) { + fprintf (stderr, "call to guestfs_utsname failed: %d, %s\n", + guestfs_last_errno (g), guestfs_last_error (g)); + exit (EXIT_FAILURE); + } + + host_utsname.uts_sysname = host.sysname; + host_utsname.uts_release = host.release; + host_utsname.uts_version = host.version; + host_utsname.uts_machine = host.machine; + + return guestfs_compare_utsname (appliance, &host_utsname); +} + static size_t perform_tests (guestfs_h *g) { @@ -505,6 +543,7 @@ main (int argc, char *argv[]) no_test_warnings (); g = create_handle (); + is_cross_appliance = check_cross_appliance (g); nr_failed = perform_tests (g); diff --git a/tests/c-api/tests.h b/tests/c-api/tests.h index 7959570..12fd316 100644 --- a/tests/c-api/tests.h +++ b/tests/c-api/tests.h @@ -43,6 +43,7 @@ extern int check_file_md5 (const char *ret, const char *filename); extern const char *get_key (char **hash, const char *key); extern int check_hash (char **ret, const char *key, const char *expected); extern int match_re (const char *str, const char *pattern); +extern int using_cross_appliance (void); extern char *substitute_srcdir (const char *path); extern void skipped (const char *test_name, const char *fs, ...) __attribute__((format (printf,2,3))); -- 1.9.3
Pino Toscano
2014-Oct-23 18:18 UTC
[Libguestfs] [PATCH 13/16] actions: mark as IfNotCrossAppliance tests of command and command_lines
All these tests copy to the appliance a tool built on the host, and run it. --- generator/actions.ml | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/generator/actions.ml b/generator/actions.ml index 955f638..ed36951 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@ -4236,67 +4236,67 @@ C<guestfs_is_file>, C<guestfs_is_blockdev> (etc), C<guestfs_is_zero>." }; proc_nr = Some 50; protocol_limit_warning = true; tests = [ - InitScratchFS, Always, TestResultString ( + InitScratchFS, IfNotCrossAppliance, TestResultString ( [["mkdir"; "/command"]; ["upload"; "test-command"; "/command/test-command"]; ["chmod"; "0o755"; "/command/test-command"]; ["command"; "/command/test-command 1"]], "Result1"), []; - InitScratchFS, Always, TestResultString ( + InitScratchFS, IfNotCrossAppliance, TestResultString ( [["mkdir"; "/command2"]; ["upload"; "test-command"; "/command2/test-command"]; ["chmod"; "0o755"; "/command2/test-command"]; ["command"; "/command2/test-command 2"]], "Result2\n"), []; - InitScratchFS, Always, TestResultString ( + InitScratchFS, IfNotCrossAppliance, TestResultString ( [["mkdir"; "/command3"]; ["upload"; "test-command"; "/command3/test-command"]; ["chmod"; "0o755"; "/command3/test-command"]; ["command"; "/command3/test-command 3"]], "\nResult3"), []; - InitScratchFS, Always, TestResultString ( + InitScratchFS, IfNotCrossAppliance, TestResultString ( [["mkdir"; "/command4"]; ["upload"; "test-command"; "/command4/test-command"]; ["chmod"; "0o755"; "/command4/test-command"]; ["command"; "/command4/test-command 4"]], "\nResult4\n"), []; - InitScratchFS, Always, TestResultString ( + InitScratchFS, IfNotCrossAppliance, TestResultString ( [["mkdir"; "/command5"]; ["upload"; "test-command"; "/command5/test-command"]; ["chmod"; "0o755"; "/command5/test-command"]; ["command"; "/command5/test-command 5"]], "\nResult5\n\n"), []; - InitScratchFS, Always, TestResultString ( + InitScratchFS, IfNotCrossAppliance, TestResultString ( [["mkdir"; "/command6"]; ["upload"; "test-command"; "/command6/test-command"]; ["chmod"; "0o755"; "/command6/test-command"]; ["command"; "/command6/test-command 6"]], "\n\nResult6\n\n"), []; - InitScratchFS, Always, TestResultString ( + InitScratchFS, IfNotCrossAppliance, TestResultString ( [["mkdir"; "/command7"]; ["upload"; "test-command"; "/command7/test-command"]; ["chmod"; "0o755"; "/command7/test-command"]; ["command"; "/command7/test-command 7"]], ""), []; - InitScratchFS, Always, TestResultString ( + InitScratchFS, IfNotCrossAppliance, TestResultString ( [["mkdir"; "/command8"]; ["upload"; "test-command"; "/command8/test-command"]; ["chmod"; "0o755"; "/command8/test-command"]; ["command"; "/command8/test-command 8"]], "\n"), []; - InitScratchFS, Always, TestResultString ( + InitScratchFS, IfNotCrossAppliance, TestResultString ( [["mkdir"; "/command9"]; ["upload"; "test-command"; "/command9/test-command"]; ["chmod"; "0o755"; "/command9/test-command"]; ["command"; "/command9/test-command 9"]], "\n\n"), []; - InitScratchFS, Always, TestResultString ( + InitScratchFS, IfNotCrossAppliance, TestResultString ( [["mkdir"; "/command10"]; ["upload"; "test-command"; "/command10/test-command"]; ["chmod"; "0o755"; "/command10/test-command"]; ["command"; "/command10/test-command 10"]], "Result10-1\nResult10-2\n"), []; - InitScratchFS, Always, TestResultString ( + InitScratchFS, IfNotCrossAppliance, TestResultString ( [["mkdir"; "/command11"]; ["upload"; "test-command"; "/command11/test-command"]; ["chmod"; "0o755"; "/command11/test-command"]; ["command"; "/command11/test-command 11"]], "Result11-1\nResult11-2"), []; - InitScratchFS, Always, TestLastFail ( + InitScratchFS, IfNotCrossAppliance, TestLastFail ( [["mkdir"; "/command12"]; ["upload"; "test-command"; "/command12/test-command"]; ["chmod"; "0o755"; "/command12/test-command"]; ["command"; "/command12/test-command"]]), []; - InitScratchFS, Always, TestResultString ( + InitScratchFS, IfNotCrossAppliance, TestResultString ( [["mkdir"; "/pwd"]; ["upload"; "test-pwd"; "/pwd/test-pwd"]; ["chmod"; "0o755"; "/pwd/test-pwd"]; @@ -4340,67 +4340,67 @@ locations." }; proc_nr = Some 51; protocol_limit_warning = true; tests = [ - InitScratchFS, Always, TestResult ( + InitScratchFS, IfNotCrossAppliance, TestResult ( [["mkdir"; "/command_lines"]; ["upload"; "test-command"; "/command_lines/test-command"]; ["chmod"; "0o755"; "/command_lines/test-command"]; ["command_lines"; "/command_lines/test-command 1"]], "is_string_list (ret, 1, \"Result1\")"), []; - InitScratchFS, Always, TestResult ( + InitScratchFS, IfNotCrossAppliance, TestResult ( [["mkdir"; "/command_lines2"]; ["upload"; "test-command"; "/command_lines2/test-command"]; ["chmod"; "0o755"; "/command_lines2/test-command"]; ["command_lines"; "/command_lines2/test-command 2"]], "is_string_list (ret, 1, \"Result2\")"), []; - InitScratchFS, Always, TestResult ( + InitScratchFS, IfNotCrossAppliance, TestResult ( [["mkdir"; "/command_lines3"]; ["upload"; "test-command"; "/command_lines3/test-command"]; ["chmod"; "0o755"; "/command_lines3/test-command"]; ["command_lines"; "/command_lines3/test-command 3"]], "is_string_list (ret, 2, \"\", \"Result3\")"), []; - InitScratchFS, Always, TestResult ( + InitScratchFS, IfNotCrossAppliance, TestResult ( [["mkdir"; "/command_lines4"]; ["upload"; "test-command"; "/command_lines4/test-command"]; ["chmod"; "0o755"; "/command_lines4/test-command"]; ["command_lines"; "/command_lines4/test-command 4"]], "is_string_list (ret, 2, \"\", \"Result4\")"), []; - InitScratchFS, Always, TestResult ( + InitScratchFS, IfNotCrossAppliance, TestResult ( [["mkdir"; "/command_lines5"]; ["upload"; "test-command"; "/command_lines5/test-command"]; ["chmod"; "0o755"; "/command_lines5/test-command"]; ["command_lines"; "/command_lines5/test-command 5"]], "is_string_list (ret, 3, \"\", \"Result5\", \"\")"), []; - InitScratchFS, Always, TestResult ( + InitScratchFS, IfNotCrossAppliance, TestResult ( [["mkdir"; "/command_lines6"]; ["upload"; "test-command"; "/command_lines6/test-command"]; ["chmod"; "0o755"; "/command_lines6/test-command"]; ["command_lines"; "/command_lines6/test-command 6"]], "is_string_list (ret, 4, \"\", \"\", \"Result6\", \"\")"), []; - InitScratchFS, Always, TestResult ( + InitScratchFS, IfNotCrossAppliance, TestResult ( [["mkdir"; "/command_lines7"]; ["upload"; "test-command"; "/command_lines7/test-command"]; ["chmod"; "0o755"; "/command_lines7/test-command"]; ["command_lines"; "/command_lines7/test-command 7"]], "is_string_list (ret, 0)"), []; - InitScratchFS, Always, TestResult ( + InitScratchFS, IfNotCrossAppliance, TestResult ( [["mkdir"; "/command_lines8"]; ["upload"; "test-command"; "/command_lines8/test-command"]; ["chmod"; "0o755"; "/command_lines8/test-command"]; ["command_lines"; "/command_lines8/test-command 8"]], "is_string_list (ret, 1, \"\")"), []; - InitScratchFS, Always, TestResult ( + InitScratchFS, IfNotCrossAppliance, TestResult ( [["mkdir"; "/command_lines9"]; ["upload"; "test-command"; "/command_lines9/test-command"]; ["chmod"; "0o755"; "/command_lines9/test-command"]; ["command_lines"; "/command_lines9/test-command 9"]], "is_string_list (ret, 2, \"\", \"\")"), []; - InitScratchFS, Always, TestResult ( + InitScratchFS, IfNotCrossAppliance, TestResult ( [["mkdir"; "/command_lines10"]; ["upload"; "test-command"; "/command_lines10/test-command"]; ["chmod"; "0o755"; "/command_lines10/test-command"]; ["command_lines"; "/command_lines10/test-command 10"]], "is_string_list (ret, 2, \"Result10-1\", \"Result10-2\")"), []; - InitScratchFS, Always, TestResult ( + InitScratchFS, IfNotCrossAppliance, TestResult ( [["mkdir"; "/command_lines11"]; ["upload"; "test-command"; "/command_lines11/test-command"]; ["chmod"; "0o755"; "/command_lines11/test-command"]; -- 1.9.3
Pino Toscano
2014-Oct-23 18:18 UTC
[Libguestfs] [PATCH 14/16] customize, mllib: use the libvirt CFLAGS
uri-c.c and perl_edit-c.c end up (directly or indirectly) including guestfs-internal-frontend.h, which in turns includes libvirt/libvirt.h; hence, make sure to use the libvirt CFLAGS. --- customize/Makefile.am | 1 + mllib/Makefile.am | 1 + 2 files changed, 2 insertions(+) diff --git a/customize/Makefile.am b/customize/Makefile.am index 0ea8d39..39759dc 100644 --- a/customize/Makefile.am +++ b/customize/Makefile.am @@ -150,6 +150,7 @@ endif # we do, so we have to provide it ourselves. DEFAULT_INCLUDES = \ + $(LIBVIRT_CFLAGS) \ -I. \ -I$(top_builddir) \ -I$(shell $(OCAMLC) -where) \ diff --git a/mllib/Makefile.am b/mllib/Makefile.am index 903a77d..2ad4eaa 100644 --- a/mllib/Makefile.am +++ b/mllib/Makefile.am @@ -137,6 +137,7 @@ libdir.ml: Makefile # we do, so we have to provide it ourselves. DEFAULT_INCLUDES = \ + $(LIBVIRT_CFLAGS) \ -I. \ -I$(top_builddir) \ -I$(shell $(OCAMLC) -where) \ -- 1.9.3
Pino Toscano
2014-Oct-23 18:18 UTC
[Libguestfs] [PATCH 15/16] tests: switch from get_current_dir_name to getcwd(0, NULL)
get_current_dir_name exists on GNU libc only, so not portable. On the other hand, while POSIX leaves a null buffer argument for getcwd as unspecified behaviour, basically the most used/important Unix implementations (GNU libc, FreeBSD's libc, etc) allow such value, returning a new allocated buffer with the current directory. In any case, the change just affects two tests, so even if it hits a libc not implementing this behaviour for getcwd, only tests are affected. --- tests/c-api/test-pwd.c | 2 +- tests/events/test-libvirt-auth-callbacks.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/c-api/test-pwd.c b/tests/c-api/test-pwd.c index 60b978c..61b88ec 100644 --- a/tests/c-api/test-pwd.c +++ b/tests/c-api/test-pwd.c @@ -28,7 +28,7 @@ int main (int argc, char *argv[]) { - char *cwd = get_current_dir_name(); + char *cwd = getcwd(NULL, 0); printf("%s", cwd); exit (EXIT_SUCCESS); diff --git a/tests/events/test-libvirt-auth-callbacks.c b/tests/events/test-libvirt-auth-callbacks.c index 7c26bbe..383f20f 100644 --- a/tests/events/test-libvirt-auth-callbacks.c +++ b/tests/events/test-libvirt-auth-callbacks.c @@ -70,9 +70,9 @@ main (int argc, char *argv[]) exit (EXIT_FAILURE); } - cwd = get_current_dir_name (); + cwd = getcwd (NULL, 0); if (cwd == NULL) { - perror ("get_current_dir_name"); + perror ("getcwd"); exit (EXIT_FAILURE); } -- 1.9.3
Pino Toscano
2014-Oct-23 18:18 UTC
[Libguestfs] [PATCH 16/16] configure: map also amd64 as host_cpu to x86_64 qemu
--- configure.ac | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 8cd29d7..6174c7c 100644 --- a/configure.ac +++ b/configure.ac @@ -733,7 +733,8 @@ dnl back to basic 'qemu'. Allow the user to override it. qemu_system="$( echo qemu-system-$host_cpu | $SED -e 's/-i@<:@456@:>@86/-i386/g' \ - -e 's/-arm.*/-arm/g' + -e 's/-arm.*/-arm/g' \ + -e 's/-amd64/-x86_64/g' )" default_qemu="qemu-kvm kvm $qemu_system qemu" AC_ARG_WITH([qemu], -- 1.9.3
Richard W.M. Jones
2014-Oct-23 20:26 UTC
Re: [Libguestfs] [PATCH 16/16] configure: map also amd64 as host_cpu to x86_64 qemu
On Thu, Oct 23, 2014 at 08:18:44PM +0200, Pino Toscano wrote:> --- > configure.ac | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/configure.ac b/configure.ac > index 8cd29d7..6174c7c 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -733,7 +733,8 @@ dnl back to basic 'qemu'. Allow the user to override it. > qemu_system="$( > echo qemu-system-$host_cpu | > $SED -e 's/-i@<:@456@:>@86/-i386/g' \ > - -e 's/-arm.*/-arm/g' > + -e 's/-arm.*/-arm/g' \ > + -e 's/-amd64/-x86_64/g' > )" > default_qemu="qemu-kvm kvm $qemu_system qemu" > AC_ARG_WITH([qemu], > -- > 1.9.3ACK whole series. Thanks, Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v
Apparently Analagous Threads
- [PATCH 0/6] generator: Split up generator/actions.ml
- [PATCH v7 00/10] tests: Introduce test harness for running tests.
- [PATCH 00/10] tests: Introduce test harness for running tests.
- [PATCH v4 00/17] tests: Introduce test harness for running tests.
- [PATCH v4 0/4] tests: Introduce test harness for running tests.