Commit Graph

474 Commits

Author SHA1 Message Date
Richard W.M. Jones
2a8de9001e fish: Use guestfs_event_to_string instead of guestfish-specific generated functions. 2013-02-19 13:41:57 +00:00
Richard W.M. Jones
09c4f94c9d build: Separate out *_CPPFLAGS from *_CFLAGS.
This is pretty pointless.
2013-02-11 21:36:27 +00:00
Richard W.M. Jones
e527aed895 getline: Rename &n parameter as &allocsize.
The second parameter passed into getline(3) is the size of the
allocated buffer, *NOT* the length of the returned line.  This can be
confusing, so rename this parameter as 'allocsize' consistently
throughout the code.

This is just code motion.
2013-02-11 13:21:51 +00:00
Richard W.M. Jones
59b296fecc tools, tests: Use "guestfs-internal-frontend.h" header.
Instead of redefining STREQ, etc.
2013-02-08 16:15:25 +00:00
Richard W.M. Jones
a0a4ee5245 Use 'supermin' and 'supermin-helper' in preference to febootstrap.
Febootstrap has been renamed upstream to 'supermin':
https://www.redhat.com/archives/libguestfs/2013-February/msg00004.html

This commit changes libguestfs so it can use either program to build
the supermin appliance.
2013-02-05 15:31:05 +00:00
Richard W.M. Jones
4940bd9a9e fish: Be stricter about boolean values.
Previously I noticed that bfan used this command without any error:

><fs> hivex-open /WINDOWS/system32/config/software write:ture
                                                   ^^^^^^^^^^

This was because the code allowed any string to be evaluated as a
boolean.

The new code is stricter.  It allows the following strings only case
insensitive (everything else is an error):

  1
  true
  t
  yes
  y
  on

  0
  false
  f
  no
  n
  off
2013-02-04 12:45:02 +00:00
Richard W.M. Jones
0d18a8b407 Update copyright dates for 2013. 2013-02-02 13:56:19 +00:00
Richard W.M. Jones
791ad3e9e6 fish: Use CLEANUP_* macros in a lot of places. 2013-02-01 16:18:42 +00:00
Richard W.M. Jones
6c1aca5ae2 fish: Use CLEANUP_FREE in parse_config. 2013-02-01 15:54:13 +00:00
Richard W.M. Jones
4b20a20d33 Remove TMP_TEMPLATE_ON_STACK macro. 2013-02-01 14:48:35 +00:00
Richard W.M. Jones
42bffcd00a Remove all occurrences of the bad_cast (lowercase) function.
Not to be confused with the libxml2 macro 'BAD_CAST' which converts
from 'signed char *' to 'unsigned char *'.

The 'bad_cast' function was defined and used all over the place as a
replacement for a '(char *)' cast.  I think it is better to make these
casts explicit, instead of hiding them in an obscure function.
2013-02-01 14:16:51 +00:00
Richard W.M. Jones
ec3b75e5ff Rearrange internal header files.
This commit rearranges the internal header files.

"src/guestfs-internal.h" is just for the library, as before.

"src/guestfs-internal-frontend.h" is for use by all library, bindings,
tools C code, but NOT the daemon.

"src/guestfs-internal-all.h" is for use by all C code including the
daemon.

This is just code motion, but it has some important consequences:

(1) We can use the CLEANUP_* macros in bindings and tools code.

(2) We can get rid of TMP_TEMPLATE_ON_STACK.

(3) We will (in future) be able to stop bindings and tools code from
using the safe_* allocation functions (which are NOT safe to use
outside the library alone).
2013-02-01 14:07:25 +00:00
Richard W.M. Jones
364ee94b8d arm: Prevent -Wcast-align warnings.
See link below for a general description of the problem:

f8b62e4cd2
2012-12-27 18:08:55 +00:00
Richard W.M. Jones
359c8f8902 fish: Close 'sock' in remote control code (found by Coverity). 2012-12-08 16:42:38 +00:00
Richard W.M. Jones
6d94de3f20 fish: Don't leak stdout_saved_fd on error path (found by Coverity). 2012-12-08 16:42:38 +00:00
Richard W.M. Jones
489cb059c2 fish: Don't segfault here is 'words' happens to be NULL (found by Coverity). 2012-12-08 16:42:37 +00:00
Richard W.M. Jones
7941f6785e fish: copy-out: Fail on some errors when creating output directory (found by Coverity).
However it's not an error if the output directory already exists.
2012-12-08 16:42:37 +00:00
Richard W.M. Jones
baf5a06224 fish: Ignore failure of mkdir (noted by Coverity). 2012-12-08 16:40:54 +00:00
Richard W.M. Jones
59b51274eb Check for error from some guestfs_set_* calls (found by Coverity).
For some guestfs_set_* calls, add checks for error, when error might
possibly occur.  eg. It's plausible that guestfs_set_network might
fail if the attach-method being used doesn't support it (although this
doesn't happen at the moment).

In other cases, don't check for errors, eg. if the error doesn't
matter or there's nothing we could plausibly do about it.
2012-12-08 13:25:59 +00:00
Richard W.M. Jones
5a2e320ec9 configure: Add --enable-code-profiling and --enable-code-coverage flags.
These configure flags enable code profiling (with gprof) and code
coverage (with gcov) respectively.

Although this is a nice idea, it's not currently very useful.

Libtool mangles filenames in such a way that gcov cannot locate its
datafiles.

Profiling is of dubious utility with libguestfs which is not CPU-bound
and relies extensively on running external programs (oprofile-like
system profiling that took into account libguestfs + qemu or
libguestfs + qemu + the appliance + filesystem tools *would* be
useful).

Also neither flag will help in capturing data from the appliance.
2012-12-04 14:11:14 +00:00
Richard W.M. Jones
b57ab59b8e doc: Document problems with hibernated Windows guests and Windows 8 "fast startup" (RHBZ#882299). 2012-12-01 13:25:56 +00:00
Richard W.M. Jones
380ce2eeaa fish: Make type == drv_N field private to guestfish.
The -N option / drv_N type only makes sense when we are compiling
guestfish, and just serves to complicate non-guestfish code.
2012-11-29 11:45:39 +00:00
Richard W.M. Jones
784e53287e fish: Fix test-remote-events test.
Because the shell script was missing a space, the final output test
was failing, although for some reason this didn't cause the whole test
to fail.

Fixing the missing space also revealed a bug in the test output, which
is also fixed.
2012-11-22 09:56:01 +00:00
Richard W.M. Jones
715afda341 fish: Add test for remote events.
This test was present in git, but not included in the tarball,
nor in the tests that guestfish actually runs.

This fixes commit 17182af3a6.
2012-11-13 15:26:29 +00:00
Richard W.M. Jones
3636c5fcff tests: Replace 'make extra-tests' with individual tests.
'make extra-tests' was a monolithic set of tests that did all sorts of
things: valgrind, tests over local guests, tests with upstream qemu,
tests with upstream libvirt, tests with the appliance attach method.

This made it hard to perform individual tests, eg. just valgrind
testing.  It was also hard to maintain because the tests were not
located in the same directories as the programs and sometimes
duplicated tests that were run elsewhere.

This commit splits up 'make extra-tests' into 5 separate targets:

 make check-valgrind              # run a subset of tests under valgrind
 make check-valgrind-local-guests # test under valgrind with local guests
 make check-with-appliance        # test with attach-method == appliance
 make check-with-upstream-qemu    # test with an alternate/upstream qemu
 make check-with-upstream-libvirt # test with an alternate/upstream libvirt

(You can also still run 'make extra-tests' which is now simply
a rule that runs the above 5 targets in order).

This replaces everything that was in the tests/extra directory,
so that has now gone.
2012-11-13 15:26:29 +00:00
Richard W.M. Jones
ac2ddfd90a fish: Add simple tests of starting up, inspection, using the prepared disks. 2012-11-13 15:26:29 +00:00
Richard W.M. Jones
2d220f5da2 tools: Modify existing tools to use guestfs_{push,pop}_error_handler.
This is a shorter and more convenient way to disable errors
temporarily across calls.
2012-11-09 19:51:09 +00:00
Richard W.M. Jones
1586bbb951 fish: Update documentation for environment variables.
This fixes commit 1efed122c0.
2012-11-09 13:34:45 +00:00
Richard W.M. Jones
1efed122c0 lib: Rework temporary and cache directory code.
New APIs: set-tmpdir, get-tmpdir, set-cachedir, get-cachedir.

The current code has evolved over time and has a number of problems:

(a) A single environment variable ($TMPDIR) controls the
location of several directories.

(b) It's hard for the library user to predict which directory
libguestfs will use, unless the user simulates the same internal steps
that libguestfs performs.

This commit fixes these issues.

(a) Now three environment variables control the location of all small
temporary files, and the appliance cache:

  For temporary files: $LIBGUESTFS_TMPDIR or $TMPDIR or /tmp.

  For the appliance cache: $LIBGUESTFS_CACHEDIR or $TMPDIR or /var/tmp.

The user can also set these directories explicitly through API calls
(guestfs_set_tmpdir and guestfs_set_cachedir).

(b) The user can also retrieve the actual directories that libguestfs
will use, by calling guestfs_get_tmpdir and guestfs_get_cachedir.
These functions are also used internally.

This commit also:

 - reworks the internal tmpdir code

 - removes the internal (undocumented) guestfs_tmpdir call (replacing
   it with calls to the documented guestfs_get_tmpdir API instead)

 - changes the ./run script to set LIBGUESTFS_TMPDIR and
   LIBGUESTFS_CACHEDIR

 - adds a test

 - fixes a few places like libguestfs-make-fixed-appliance which
   depended on $TMPDIR
2012-11-09 13:11:53 +00:00
Richard W.M. Jones
4bd61ed322 fish: Fix documentation quit | exit -> separate exit & quit headings. 2012-11-02 22:15:29 +00:00
Richard W.M. Jones
4f6060b9d9 fish: Clean up prompt documentation. 2012-11-02 22:13:22 +00:00
Richard W.M. Jones
46449f6894 fish: Use Unicode LOWER ONE QUARTER BLOCK to represent cursor.
'ls' (with no argument) is not a valid command.

This fixes commit bad5c7d5a5.
2012-11-02 22:05:43 +00:00
Richard W.M. Jones
bad5c7d5a5 fish: Add GUESTFISH_PS1 environment variable to control prompt. 2012-10-29 12:49:21 +00:00
Richard W.M. Jones
9de4dfddc7 fish: Make progress bars slightly lighter. 2012-10-27 16:19:53 +01:00
Richard W.M. Jones
91c07d2a06 fish: Fix test-events.sh because of new debug message.
Commit 2e90f43129 added a debug message
which isn't filtered out by the set of grep -v's in this test.
Therefore this test would fail when run with LIBGUESTFS_DEBUG=1.
2012-10-24 11:16:55 +01:00
Richard W.M. Jones
911a16a9fa fish: progress bar: Send interactive progress bar output to /dev/tty (RHBZ#859875). 2012-10-11 13:53:12 +00:00
Richard W.M. Jones
f4a2aecd5f fish: inspect: Canonicalize paths for printing (RHBZ#859876). 2012-10-11 13:18:46 +00:00
Richard W.M. Jones
c34dcf184e fish: inspect: Move variable decls to top of function.
This is just code motion.
2012-10-11 13:12:26 +00:00
Richard W.M. Jones
18b7f09f36 Add support for hotplugging (adding disks) to the libvirt attach-method.
When libvirt is used, we can allow disks to be hotplugged.
guestfs_add_drive can be called after launch to hot-add a disk.

When a disk is hot-added, we first ask libvirt to add the disk to the
appliance, then we make an internal call into the appliance to get it
to wait for the disk to appear (ie. udev_settle ()).

Hot-added disks are tracked in the g->drives array.

This also adds a test.
2012-10-08 20:04:53 +01:00
Richard W.M. Jones
4a4ca0c01d syntax: Use __PATTERNS__ instead of @PATTERNS@ in podwrapper man pages.
It is slightly dangerous to use @PATTERNS@, since these might
be substituted by autoconf when they appear in Makefile.am files.
2012-10-03 09:22:45 +01:00
Richard W.M. Jones
e128a627fb Fix multiple errors where jump skips variable initialization.
<file>: error: jump skips variable initialization [-Werror=jump-misses-init]

This has only just appeared, possibly related to previous gnulib
update.  In any case, this is just code motion / cleanup.
2012-09-17 13:37:06 +01:00
Richard W.M. Jones
cb13ffe190 syntax: Remove definitions of O_CLOEXEC, except in examples (thanks Jim Meyering).
The gnulib <fcntl.h> replacement header will now define this symbol if
it's not defined already.
2012-09-17 10:07:31 +01:00
Richard W.M. Jones
2383d7a78e syntax: Remove PATH_MAX-sized buffers allocated on the stack.
On Linux PATH_MAX is 4096, but on some platforms it can be much larger
or even not defined (ie. unlimited).  Therefore using a PATH_MAX-sized
stack buffer is not a great idea for portable programs.

This change removes use of PATH_MAX-sized stack-allocated buffers.

This change only applies to the library and standalone programs.
Inside the daemon, memory allocation is much more complicated so I
have not changed those (yet).

Found by 'make syntax-check'.
2012-09-15 13:01:10 +01:00
Richard W.M. Jones
9fce75aa13 syntax: Remove gnulib c-ctype.h in files that don't use it.
Found by 'make syntax-check'.
2012-09-15 12:34:41 +01:00
Richard W.M. Jones
6272e49f51 syntax: Remove include <assert.h> where assert is not used.
Found by 'make syntax-check'.
2012-09-15 12:32:41 +01:00
Richard W.M. Jones
2f97bf873b podwrapper: Add --license parameter, which is required.
This adds standard LICENSE and BUGS sections to all of the man pages
that are processed by podwrapper.

Modify all the calls to $(PODWRAPPER) to add the right --license
parameter according to the content.  Note that this relaxes the
license on some code example pages, making them effectively BSD-style
licensed.
2012-08-21 20:33:21 +01:00
Richard W.M. Jones
f1d98bbc79 man pages: Ensure consistent copyright/author sections, remove license
section.

Ensure each man page contains consistent COPYRIGHT and AUTHOR
sections.

Remove the LICENSE section.  We will add that back in podwrapper in a
later commit.
2012-08-21 20:16:29 +01:00
Richard W.M. Jones
d67e6ea75d Replace mount-options with mount where appropriate.
Since our minimum supported version is now 1.16 and mount was fixed in
1.13.16, it is now safe to replace mount-options + empty options with
mount wherever it occurs.
2012-08-18 22:08:29 +01:00
Richard W.M. Jones
a05623cd71 fish: Add --network option.
This enables the libguestfs user network, and is the equivalent of the
'virt-rescue --network' option.
2012-08-11 09:28:58 +01:00
Richard W.M. Jones
2a87261dfc fish: Fix 'copy-out /' (RHBZ#845522). 2012-08-03 12:54:18 +01:00