Richard W.M. Jones
2009-Nov-20 10:50 UTC
[Libguestfs] [PATCH 0/6] Simple fixes for cross-compiling the daemon
As outlined here: https://www.redhat.com/archives/libguestfs/2009-November/msg00171.html These patches fix some of the simpler things. Some of the things (the missing headers) are genuine bugs. Note in order to cross-compile at all you have to comment out the section in the daemon/configure.ac where it detects custom format specifiers. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
Richard W.M. Jones
2009-Nov-20 10:52 UTC
[Libguestfs] [PATCH 1/6] daemon/Win32: Ignore mingw32-config.cache.
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://et.redhat.com/~rjones/libguestfs/ See what it can do: http://et.redhat.com/~rjones/libguestfs/recipes.html -------------- next part -------------->From 4d35cc2ff0589e786b0194b9cfdf3aa7b01f6b29 Mon Sep 17 00:00:00 2001From: Richard Jones <rjones at redhat.com> Date: Fri, 20 Nov 2009 10:33:27 +0000 Subject: [PATCH 1/6] daemon/Win32: Ignore mingw32-config.cache. The Fedora Windows cross-compiler 'mingw32-configure' script always uses a configure cache. Ignore that file. --- daemon/.gitignore | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/daemon/.gitignore b/daemon/.gitignore index 6a67b90..9752ad0 100644 --- a/daemon/.gitignore +++ b/daemon/.gitignore @@ -71,4 +71,5 @@ m4/wint_t.m4 m4/xalloc.m4 m4/xgetcwd.m4 m4/xstrndup.m4 +mingw32-config.cache tests -- 1.6.5.2
Richard W.M. Jones
2009-Nov-20 10:52 UTC
[Libguestfs] [PATCH 2/6] daemon: Missing #includes revealed by cross-compiling.
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw -------------- next part -------------->From 688bdc1a068a6c0bea58addd04d5bbe6dc1940c4 Mon Sep 17 00:00:00 2001From: Richard Jones <rjones at redhat.com> Date: Fri, 20 Nov 2009 10:36:21 +0000 Subject: [PATCH 2/6] daemon: Missing #includes revealed by cross-compiling. --- daemon/ext2.c | 1 + daemon/fill.c | 1 + daemon/find.c | 1 + daemon/initrd.c | 1 + 4 files changed, 4 insertions(+), 0 deletions(-) diff --git a/daemon/ext2.c b/daemon/ext2.c index f768440..f46bac9 100644 --- a/daemon/ext2.c +++ b/daemon/ext2.c @@ -20,6 +20,7 @@ #include <stdio.h> #include <stdlib.h> +#include <string.h> #include <unistd.h> #include "../src/guestfs_protocol.h" diff --git a/daemon/fill.c b/daemon/fill.c index b1b0f5e..9551502 100644 --- a/daemon/fill.c +++ b/daemon/fill.c @@ -20,6 +20,7 @@ #include <stdio.h> #include <stdlib.h> +#include <string.h> #include <unistd.h> #include <fcntl.h> diff --git a/daemon/find.c b/daemon/find.c index 98895ab..391b87b 100644 --- a/daemon/find.c +++ b/daemon/find.c @@ -23,6 +23,7 @@ #include <string.h> #include <unistd.h> #include <fcntl.h> +#include <limits.h> #include <sys/stat.h> #include "../src/guestfs_protocol.h" diff --git a/daemon/initrd.c b/daemon/initrd.c index 9431ef1..9c92fee 100644 --- a/daemon/initrd.c +++ b/daemon/initrd.c @@ -21,6 +21,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <limits.h> #include <unistd.h> #include "../src/guestfs_protocol.h" -- 1.6.5.2
Richard W.M. Jones
2009-Nov-20 10:53 UTC
[Libguestfs] [PATCH 3/6] daemon/Win32: NAME_MAX does not exist on Windows, use FILENAME_MAX instead.
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://et.redhat.com/~rjones/libguestfs/ See what it can do: http://et.redhat.com/~rjones/libguestfs/recipes.html -------------- next part -------------->From 7d8a3404b27fcd71f84dbe4c022c4435d0070d6b Mon Sep 17 00:00:00 2001From: Richard Jones <rjones at redhat.com> Date: Fri, 20 Nov 2009 10:36:59 +0000 Subject: [PATCH 3/6] daemon/Win32: NAME_MAX does not exist on Windows, use FILENAME_MAX instead. --- daemon/realpath.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/daemon/realpath.c b/daemon/realpath.c index 17e74ea..02a82d6 100644 --- a/daemon/realpath.c +++ b/daemon/realpath.c @@ -32,6 +32,11 @@ #include "daemon.h" #include "actions.h" +/* On Windows, NAME_MAX is not defined. */ +#ifndef NAME_MAX +#define NAME_MAX FILENAME_MAX +#endif + char * do_realpath (const char *path) { -- 1.6.5.2
Richard W.M. Jones
2009-Nov-20 10:53 UTC
[Libguestfs] [PATCH 4/6] daemon/Win32: make some functions and fields optional.
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://et.redhat.com/~rjones/virt-df/ -------------- next part -------------->From edb9b3abc03c0a0f84b1cbd9cf5920e3c84e5c18 Mon Sep 17 00:00:00 2001From: Richard Jones <rjones at redhat.com> Date: Fri, 20 Nov 2009 10:38:07 +0000 Subject: [PATCH 4/6] daemon/Win32: make some functions and fields optional. inotify: Make this optional on platforms that don't have this interface. mknod, mkfifo etc.: Make these optional on non-Unix platforms. readdir: If d_type field is missing on the platform, set the corresponding field to 'u'. stat: st_blocks and st_blksize are missing on non-Unix platforms, so set these fields to -1 in the corresponding structures. --- daemon/configure.ac | 34 ++++++++++++++++++++++++++++++---- daemon/inotify.c | 35 +++++++++++++++++++++++++++++++++++ daemon/mknod.c | 5 +++++ daemon/readdir.c | 4 ++++ daemon/stat.c | 24 ++++++++++++++++++++++++ 5 files changed, 98 insertions(+), 4 deletions(-) diff --git a/daemon/configure.ac b/daemon/configure.ac index 0deaa3c..92776c2 100644 --- a/daemon/configure.ac +++ b/daemon/configure.ac @@ -127,6 +127,14 @@ AM_PROG_CC_C_O dnl Check support for 64 bit file offsets. AC_SYS_LARGEFILE +dnl Check if dirent (readdir) supports d_type member. +AC_STRUCT_DIRENT_D_TYPE + +dnl Check if stat has the required fields. +AC_STRUCT_ST_BLOCKS +AC_CHECK_MEMBER([struct stat.st_blksize],[ + AC_DEFINE([HAVE_STRUCT_STAT_ST_BLKSIZE],[1],[Define to 1 if 'st_blksize' is a member of 'struct stat'])]) + dnl Check for Augeas (now optional). AC_CHECK_LIB([augeas],[aug_match],[ LIBS="-laugeas $LIBS" @@ -155,7 +163,28 @@ AC_CHECK_LIB([portablexdr],[xdrmem_create],[],[ ]) dnl Functions which may not be available in older distributions. -AC_CHECK_FUNCS([futimens listxattr llistxattr getxattr lgetxattr setxattr lsetxattr removexattr lremovexattr inotify_init1]) +AC_CHECK_FUNCS([\ + futimens \ + getxattr \ + inotify_init1 \ + lgetxattr \ + listxattr \ + llistxattr \ + lsetxattr \ + lremovexattr \ + mknod \ + removexattr \ + setxattr]) + +dnl Headers. +AC_CHECK_HEADERS([\ + attr/xattr.h \ + netdb.h \ + printf.h \ + sys/inotify.h \ + sys/select.h \ + sys/wait.h \ + sys/xattr.h]) dnl For modified printf, we need glibc either (old-style) dnl register_printf_function or (new-style) register_printf_specifier. @@ -173,9 +202,6 @@ AC_CHECK_FUNC([register_printf_specifier],[ This means you either have a very old glibc (pre-2.0) or you are using some other libc where this is not supported.])])]) -dnl Headers. -AC_CHECK_HEADERS([attr/xattr.h sys/xattr.h]) - dnl Produce output files. AC_CONFIG_HEADERS([config.h]) AC_CONFIG_FILES([Makefile lib/Makefile tests/Makefile]) diff --git a/daemon/inotify.c b/daemon/inotify.c index 3e314f0..465d0b6 100644 --- a/daemon/inotify.c +++ b/daemon/inotify.c @@ -23,17 +23,22 @@ #include <string.h> #include <unistd.h> #include <fcntl.h> + +#ifdef HAVE_SYS_INOTIFY_H #include <sys/inotify.h> +#endif #include "../src/guestfs_protocol.h" #include "daemon.h" #include "actions.h" +#ifdef HAVE_SYS_INOTIFY_H /* Currently open inotify handle, or -1 if not opened. */ static int inotify_fd = -1; static char inotify_buf[64*1024*1024]; /* Event buffer, [0..posn-1] is valid */ static size_t inotify_posn = 0; +#endif /* Because inotify_init does NEED_ROOT, NEED_INOTIFY implies NEED_ROOT. */ #define NEED_INOTIFY(errcode) \ @@ -49,6 +54,7 @@ static size_t inotify_posn = 0; int do_inotify_init (int max_events) { +#ifdef HAVE_SYS_INOTIFY_H FILE *fp; NEED_ROOT (return -1); @@ -99,11 +105,16 @@ do_inotify_init (int max_events) #endif return 0; +#else + reply_with_error ("%s is not available", __func__); + return -1; +#endif } int do_inotify_close (void) { +#ifdef HAVE_SYS_INOTIFY_H NEED_INOTIFY (-1); if (inotify_fd == -1) { @@ -120,11 +131,16 @@ do_inotify_close (void) inotify_posn = 0; return 0; +#else + reply_with_error ("%s is not available", __func__); + return -1; +#endif } int64_t do_inotify_add_watch (const char *path, int mask) { +#ifdef HAVE_SYS_INOTIFY_H int64_t r; char *buf; @@ -144,11 +160,16 @@ do_inotify_add_watch (const char *path, int mask) } return r; +#else + reply_with_error ("%s is not available", __func__); + return -1; +#endif } int do_inotify_rm_watch (int wd) { +#ifdef HAVE_SYS_INOTIFY_H NEED_INOTIFY (-1); if (inotify_rm_watch (inotify_fd, wd) == -1) { @@ -157,11 +178,16 @@ do_inotify_rm_watch (int wd) } return 0; +#else + reply_with_error ("%s is not available", __func__); + return -1; +#endif } guestfs_int_inotify_event_list * do_inotify_read (void) { +#ifdef HAVE_SYS_INOTIFY_H int space; guestfs_int_inotify_event_list *ret; @@ -267,11 +293,16 @@ do_inotify_read (void) xdr_free ((xdrproc_t) xdr_guestfs_int_inotify_event_list, (char *) ret); free (ret); return NULL; +#else + reply_with_error ("%s is not available", __func__); + return NULL; +#endif } char ** do_inotify_files (void) { +#ifdef HAVE_SYS_INOTIFY_H char **ret = NULL; int size = 0, alloc = 0; unsigned int i; @@ -339,4 +370,8 @@ do_inotify_files (void) error: unlink ("/tmp/inotify"); return NULL; +#else + reply_with_error ("%s is not available", __func__); + return NULL; +#endif } diff --git a/daemon/mknod.c b/daemon/mknod.c index adaeb80..6ff88ef 100644 --- a/daemon/mknod.c +++ b/daemon/mknod.c @@ -33,6 +33,7 @@ int do_mknod (int mode, int devmajor, int devminor, const char *path) { +#ifdef HAVE_MKNOD int r; CHROOT_IN; @@ -45,6 +46,10 @@ do_mknod (int mode, int devmajor, int devminor, const char *path) } return 0; +#else + reply_with_error ("%s is not available", __func__); + return -1; +#endif } int diff --git a/daemon/readdir.c b/daemon/readdir.c index ab42dfd..876041e 100644 --- a/daemon/readdir.c +++ b/daemon/readdir.c @@ -74,6 +74,7 @@ do_readdir (const char *path) ret->guestfs_int_dirent_list_val = p; v.ino = d->d_ino; +#ifdef HAVE_STRUCT_DIRENT_D_TYPE switch (d->d_type) { case DT_BLK: v.ftyp = 'b'; break; case DT_CHR: v.ftyp = 'c'; break; @@ -85,6 +86,9 @@ do_readdir (const char *path) case DT_UNKNOWN: v.ftyp = 'u'; break; default: v.ftyp = '?'; break; } +#else + v.ftyp = 'u'; +#endif ret->guestfs_int_dirent_list_val[i] = v; diff --git a/daemon/stat.c b/daemon/stat.c index 2441c9f..45d2cb8 100644 --- a/daemon/stat.c +++ b/daemon/stat.c @@ -61,8 +61,16 @@ do_stat (const char *path) ret->gid = statbuf.st_gid; ret->rdev = statbuf.st_rdev; ret->size = statbuf.st_size; +#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE ret->blksize = statbuf.st_blksize; +#else + ret->blksize = -1; +#endif +#ifdef HAVE_STRUCT_STAT_ST_BLOCKS ret->blocks = statbuf.st_blocks; +#else + ret->blocks = -1; +#endif ret->atime = statbuf.st_atime; ret->mtime = statbuf.st_mtime; ret->ctime = statbuf.st_ctime; @@ -100,8 +108,16 @@ do_lstat (const char *path) ret->gid = statbuf.st_gid; ret->rdev = statbuf.st_rdev; ret->size = statbuf.st_size; +#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE ret->blksize = statbuf.st_blksize; +#else + ret->blksize = -1; +#endif +#ifdef HAVE_STRUCT_STAT_ST_BLOCKS ret->blocks = statbuf.st_blocks; +#else + ret->blocks = -1; +#endif ret->atime = statbuf.st_atime; ret->mtime = statbuf.st_mtime; ret->ctime = statbuf.st_ctime; @@ -158,8 +174,16 @@ do_lstatlist (const char *path, char *const *names) ret->guestfs_int_stat_list_val[i].gid = statbuf.st_gid; ret->guestfs_int_stat_list_val[i].rdev = statbuf.st_rdev; ret->guestfs_int_stat_list_val[i].size = statbuf.st_size; +#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE ret->guestfs_int_stat_list_val[i].blksize = statbuf.st_blksize; +#else + ret->guestfs_int_stat_list_val[i].blksize = -1; +#endif +#ifdef HAVE_STRUCT_STAT_ST_BLOCKS ret->guestfs_int_stat_list_val[i].blocks = statbuf.st_blocks; +#else + ret->guestfs_int_stat_list_val[i].blocks = -1; +#endif ret->guestfs_int_stat_list_val[i].atime = statbuf.st_atime; ret->guestfs_int_stat_list_val[i].mtime = statbuf.st_mtime; ret->guestfs_int_stat_list_val[i].ctime = statbuf.st_ctime; -- 1.6.5.2
Richard W.M. Jones
2009-Nov-20 10:53 UTC
[Libguestfs] [PATCH 5/6] daemon/Win32: Don't include missing headers.
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top -------------- next part -------------->From 295a920f52911c4220dc51245f0cf9d0d2c41241 Mon Sep 17 00:00:00 2001From: Richard Jones <rjones at redhat.com> Date: Fri, 20 Nov 2009 10:41:07 +0000 Subject: [PATCH 5/6] daemon/Win32: Don't include missing headers. This is a partial fix for code in guestfsd.c where many of these header files are missing on Win32. --- daemon/guestfsd.c | 18 +++++++++++++++--- 1 files changed, 15 insertions(+), 3 deletions(-) diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c index 9375ede..4b91660 100644 --- a/daemon/guestfsd.c +++ b/daemon/guestfsd.c @@ -27,15 +27,27 @@ #include <rpc/types.h> #include <rpc/xdr.h> #include <getopt.h> -#include <netdb.h> #include <sys/param.h> -#include <sys/select.h> #include <sys/types.h> -#include <sys/wait.h> #include <sys/stat.h> #include <fcntl.h> #include <signal.h> + +#ifdef HAVE_NETDB_H +#include <netdb.h> +#endif + +#ifdef HAVE_SYS_SELECT_H +#include <sys/select.h> +#endif + +#ifdef HAVE_SYS_WAIT_H +#include <sys/wait.h> +#endif + +#ifdef HAVE_PRINTF_H #include <printf.h> +#endif #include "c-ctype.h" #include "ignore-value.h" -- 1.6.5.2
Richard W.M. Jones
2009-Nov-20 10:54 UTC
[Libguestfs] [PATCH 6/6] daemon/gnulib: Include glob module.
It may not be immediately obvious, but this is required to compile daemon/glob.c. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora -------------- next part -------------->From 0d5b38f1d957609f3f96739507f491a6672f01d5 Mon Sep 17 00:00:00 2001From: Richard Jones <rjones at redhat.com> Date: Fri, 20 Nov 2009 10:43:45 +0000 Subject: [PATCH 6/6] daemon/gnulib: Include glob module. --- daemon/.gitignore | 16 ++++++++++++++++ daemon/m4/gnulib-cache.m4 | 3 ++- 2 files changed, 18 insertions(+), 1 deletions(-) diff --git a/daemon/.gitignore b/daemon/.gitignore index 9752ad0..918f541 100644 --- a/daemon/.gitignore +++ b/daemon/.gitignore @@ -7,7 +7,9 @@ m4/canonicalize-lgpl.m4 m4/chdir-long.m4 m4/chown.m4 m4/close.m4 +m4/codeset.m4 m4/d-ino.m4 +m4/d-type.m4 m4/dirent_h.m4 m4/dirfd.m4 m4/dirname.m4 @@ -23,10 +25,14 @@ m4/fchdir.m4 m4/fclose.m4 m4/fcntl-safer.m4 m4/fcntl_h.m4 +m4/fnmatch.m4 m4/getcwd-abort-bug.m4 m4/getcwd-path-max.m4 m4/getcwd.m4 +m4/getlogin_r.m4 m4/getpagesize.m4 +m4/glibc21.m4 +m4/glob.m4 m4/gnulib-common.m4 m4/gnulib-comp.m4 m4/gnulib-tool.m4 @@ -35,11 +41,19 @@ m4/include_next.m4 m4/inline.m4 m4/inttostr.m4 m4/lchown.m4 +m4/localcharset.m4 +m4/locale-fr.m4 +m4/locale-ja.m4 +m4/locale-zh.m4 m4/longlong.m4 m4/lstat.m4 m4/malloc.m4 m4/malloca.m4 m4/manywarnings.m4 +m4/mbrtowc.m4 +m4/mbsinit.m4 +m4/mbsrtowcs.m4 +m4/mbstate_t.m4 m4/memchr.m4 m4/mempcpy.m4 m4/memrchr.m4 @@ -67,6 +81,8 @@ m4/unistd_h.m4 m4/warnings.m4 m4/wchar.m4 m4/wchar_t.m4 +m4/wctob.m4 +m4/wctype.m4 m4/wint_t.m4 m4/xalloc.m4 m4/xgetcwd.m4 diff --git a/daemon/m4/gnulib-cache.m4 b/daemon/m4/gnulib-cache.m4 index 2157ceb..3c5b85d 100644 --- a/daemon/m4/gnulib-cache.m4 +++ b/daemon/m4/gnulib-cache.m4 @@ -15,12 +15,13 @@ # Specification in the form of a command-line invocation: -# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --with-tests --no-libtool --macro-prefix=gl c-ctype hash ignore-value manywarnings openat warnings +# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --with-tests --no-libtool --macro-prefix=gl c-ctype glob hash ignore-value manywarnings openat warnings # Specification in the form of a few gnulib-tool.m4 macro invocations: gl_LOCAL_DIR([]) gl_MODULES([ c-ctype + glob hash ignore-value manywarnings -- 1.6.5.2
Seemingly Similar Threads
- [PATCH febootstrap 0/8] Add support for building an ext2-based appliance
- [PATCH 0/5] 5 conservative changes to errno handling
- [PATCH 0/9] Enhance virt-resize so it can really expand Linux and Windows guests
- [PATCH 0/8 v2 DISCUSSION ONLY] Connecting to live virtual machines
- [PATCH 0/13 v2] Prepare for adding write support to hivex (Windows registry) library