Richard W.M. Jones
2013-Oct-17 10:49 UTC
[Libguestfs] Notes on getting libguestfs to work on Mac OS X
Supplied by Pene on IRC who got libguestfs to compile and run on Mac OS X 10.9 with qemu 1.6.0. My notes in [] below. Rich. libguestfs on Mac OS X, recipe so far: -------------------------------------- - libtool-kill-dependency_libs.sh: replace chmod --reference="$output.tmp" "$output" -> chmod `stat -f "%p" "$output.tmp"` "$output" - src/proto.c: replace if (!(*xdrp) (&xdr, args)) -> if (!(*xdrp) (&xdr, args, 0)) - src/proto.c: replace if (xdrp && ret && !xdrp (&xdr, ret)) -> if (xdrp && ret && !xdrp (&xdr, ret, 0)) - src/launch-direct.c: comment out - if (qemu_supports (g, data, "-nodefaults")) ADD_CMDLINE ("-nodefaults"); [This works around a qemu bug: qemu: qemu_mutex_lock: Invalid argument when using the -nodefaults parameter] - fuse/guestunmount.c: replace execlp ("fusermount", "fusermount", "-u", mountpoint, NULL); -> execlp ("/sbin/umount", "fusermount", mountpoint, NULL); - fuse/guestunmount.c: replace execlp ("/sbin/fuser", "fuser", "-v", "-m", mountpoint, NULL); -> execlp ("/usr/bin/fuser", "fuser", "-c", mountpoint, NULL); - gnulib/lib/error.c: replace extern char *program_name; -> extern char *program_name = "libguestfs"; - gnulib/lib/open_memstream.c: add from http://lists.gnu.org/archive/html/bug-gnulib/2010-04/msg00379.html, remove check for #if !HAVE_FUNOPEN - gnulib/lib/stdio.in.h, gnulib/lib/Makefile.in: add new open_memstream.c [Mac OS X lacks open_memstream and gnulib doesn't supply it. Note that open_memstream is part of POSIX so this is a bug in OS X] - configure with: ./configure --disable-appliance --disable-daemon --disable-probes --disable-ruby --disable-php CFLAGS="-I/opt/local/include" LDFLAGS="-L/opt/local/lib" LIBS="-lintl" FUSE_CFLAGS="-I/usr/local/include/osxfuse/fuse -D_FILE_OFFSET_BITS=64" FUSE_LIBS="-losxfuse" -- 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://libguestfs.org
Daniel P. Berrange
2013-Oct-17 10:51 UTC
Re: [Libguestfs] Notes on getting libguestfs to work on Mac OS X
On Thu, Oct 17, 2013 at 11:49:04AM +0100, Richard W.M. Jones wrote:> Supplied by Pene on IRC who got libguestfs to compile and run on > Mac OS X 10.9 with qemu 1.6.0. My notes in [] below.> - src/launch-direct.c: comment out - if (qemu_supports (g, data, "-nodefaults")) ADD_CMDLINE ("-nodefaults"); > > [This works around a qemu bug: > qemu: qemu_mutex_lock: Invalid argument > when using the -nodefaults parameter]I believe this is addressed by this: https://lists.gnu.org/archive/html/qemu-devel/2013-10/msg02218.html Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
Richard W.M. Jones
2013-Oct-17 12:03 UTC
Re: [Libguestfs] Notes on getting libguestfs to work on Mac OS X
On Thu, Oct 17, 2013 at 11:49:04AM +0100, Richard W.M. Jones wrote:> - src/proto.c: replace if (!(*xdrp) (&xdr, args)) -> if (!(*xdrp) (&xdr, args, 0)) > - src/proto.c: replace if (xdrp && ret && !xdrp (&xdr, ret)) -> if (xdrp && ret && !xdrp (&xdr, ret, 0))On this point, don't use the {src,daemon}/guestfs_protocol.[ch] files that may be created by OS X's rpcgen (which is quite broken). Copy those files from a Linux box/VM. 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://people.redhat.com/~rjones/virt-top
Richard W.M. Jones
2013-Oct-17 14:04 UTC
Re: [Libguestfs] Notes on getting libguestfs to work on Mac OS X
More complete documentation below. Rich. ---------------------------------------------------------------------- libguestfs on Mac OS X (tested with libguestfs-1.23.33): -------------------------------------------------------- prerequisites: -------------- - install osxfuse, download from: http://osxfuse.github.io - install some dependencies using macports: sudo port install qemu cdrtools pcre augeas - extract appliance to /usr/local/lib/guestfs/, download from: http://libguestfs.org/download/binaries/appliance/ patches: -------- - libtool-kill-dependency_libs.sh: replace - chmod --reference="$output.tmp" "$output" -> chmod `stat -f "%p" "$output.tmp"` "$output" - src/proto.c: replace - if (!(*xdrp) (&xdr, args)) -> if (!(*xdrp) (&xdr, args, 0)) - src/proto.c: replace - if (xdrp && ret && !xdrp (&xdr, ret)) -> if (xdrp && ret && !xdrp (&xdr, ret, 0)) - src/launch-direct.c: comment out - if (qemu_supports (g, data, "-nodefaults")) ADD_CMDLINE ("-nodefaults"); - fuse/guestunmount.c: replace - execlp ("fusermount", "fusermount", "-u", mountpoint, NULL); -> execlp ("/sbin/umount", "fusermount", mountpoint, NULL); - fuse/guestunmount.c: replace - execlp ("/sbin/fuser", "fuser", "-v", "-m", mountpoint, NULL); -> execlp ("/usr/bin/fuser", "fuser", "-c", mountpoint, NULL); - gnulib/lib/error.c: replace - extern char *program_name; -> extern char *program_name = "libguestfs"; - gnulib/lib/open_memstream.c: add new file, from http://lists.gnu.org/archive/html/bug-gnulib/2010-04/msg00379.html, remove from it check for #if !HAVE_FUNOPEN (it exists on Mac OSX, but HAVE_FUNOPEN is not defined) - gnulib/lib/stdio.in.h: add somewhere (for example, before @GNULIB_PCLOSE@): _GL_FUNCDECL_SYS (open_memstream, FILE *, (char **, size_t *)); - gnulib/lib/Makefile.in, replace: openat-die.lo -> open_memstream.lo openat-die.lo - gnulib/lib/Makefile.in, replace: openat-die.c -> open_memstream.c openat-die.c configure: ---------- - use: ./configure --disable-appliance --disable-daemon --disable-probes --disable-ruby --disable-php CFLAGS="-I/opt/local/include" LDFLAGS="-L/opt/local/lib" LIBS="-lintl" FUSE_CFLAGS="-I/usr/local/include/osxfuse/fuse -D_FILE_OFFSET_BITS=64" FUSE_LIBS="-losxfuse" make, test & install: --------------------- - make - LIBGUESTFS_PATH=/usr/local/lib/guestfs/appliance make quickcheck - sudo make install use: ---- - LIBGUESTFS_PATH=/usr/local/lib/guestfs/appliance guestfish or - LIBGUESTFS_PATH=/usr/local/lib/guestfs/appliance guestmount ---------------------------------------------------------------------- -- 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://people.redhat.com/~rjones/virt-df/
Richard W.M. Jones
2013-Oct-17 14:28 UTC
Re: [Libguestfs] Notes on getting libguestfs to work on Mac OS X
On Thu, Oct 17, 2013 at 01:03:26PM +0100, Richard W.M. Jones wrote:> On this point, don't use the {src,daemon}/guestfs_protocol.[ch] files > that may be created by OS X's rpcgen (which is quite broken). Copy > those files from a Linux box/VM.Apparently this bit is not true. You can use the rpcgen-generated ones from OS X. 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#)
Apparently Analagous Threads
- Notes on getting libguestfs to work on Mac OS X
- Re: Notes on getting libguestfs to work on Mac OS X
- Re: Patchable build problems on OS X 10.10
- [PATCH] lib: Prefer tirpc for XDR, and rationlise how we search for alternatives.
- Re: [PATCH 1/5] macosx: Add required third parameter for xdrproc_t callbacks