Compare commits

...

1494 Commits

Author SHA1 Message Date
Richard W.M. Jones
45b4271579 Version 1.21.10. 2013-02-11 19:38:55 +00:00
Richard W.M. Jones
05444da983 tests: Add a regression test for stack overflow in events (RHBZ#909624).
Note this is a check-slow test since generating 1,000,000 progress
events take a few minutes.
2013-02-11 18:15:48 +00:00
Richard W.M. Jones
b3cf5d1d96 proto: Fix stack overflow when there are many progress events (RHBZ#909624).
Thanks: Eric Blake.
2013-02-11 18:15:48 +00:00
Richard W.M. Jones
a43f88b1c5 daemon: Allow rate to be specified in 'debug progress'.
There are now two forms of the 'debug progress' command:

(1) debug progress <n> (the original form) generates ordinary
rate-limited progress messages for <n> seconds.

(2) debug progress <n> <rate> generates progress messages every <rate>
microseconds for <n> seconds.

The second form omit the usual rate-limiting, and so wouldn't
be generated like this from an ordinary API call.  However this
is useful for testing events (see RHBZ#909624).
2013-02-11 18:02:55 +00:00
Matthew Booth
942e139562 mountable: Implement Mountable_or_Path
A Mountable_or_Path argument is passed as a mountable_t. A new type is
added to mountable_t to handle already mounted paths.
2013-02-11 16:54:42 +00:00
Richard W.M. Jones
93d4fddaef lib: Add format attribute for GCC 4.8 in two places. 2013-02-11 16:10:17 +00:00
Richard W.M. Jones
984431a9ef daemon: Force disable -Wsuggest-attribute=format warning around asprintf_nowarn, for GCC 4.8. 2013-02-11 16:10:17 +00:00
Richard W.M. Jones
f226133c1a lib: Define GUESTFS_GCC_VERSION in the internal header.
Note that you have to use this as follows:

#if defined(__GNUC__) && GUESTFS_GCC_VERSION >= x0y0z /* gcc >= x.y.z */

since GUESTFS_GCC_VERSION is not defined unless it's GCC.
2013-02-11 16:10:17 +00:00
Matthew Booth
ef2276654e generator: Create Mountable_or_Path, initially identical to Dev_or_Path 2013-02-11 15:43:53 +00:00
Matthew Booth
47b929b789 mountable: Implement Mountable support for all apis which take it
A Mountable is passed from the library to the daemon as a string. The daemon
stub parses it into a mountable_t, which it passes to the implementation.

Update all implementations which now take a mountable_t.
2013-02-11 15:42:58 +00:00
Matthew Booth
d5817537fa generator: Convert relevant arguments from Device to Mountable
This change updates the api style of all apis which should take Mountable
descriptions rather than block devices. It also updates the documentation
accordingly, but doesn't implement any functional changes.
2013-02-11 15:39:31 +00:00
Richard W.M. Jones
007c2f236d test-tool: Document how to change SELinux settings. 2013-02-11 14:14:36 +00:00
Richard W.M. Jones
b1a89d3b1c test-tool: Document how to run with alternate libvirt. 2013-02-11 14:13:44 +00:00
Richard W.M. Jones
3877cab329 test-tool: exec qemu in the wrapper script.
This ensures that libvirt can control qemu directly, eg. being able to
send it signals.
2013-02-11 13:41:40 +00:00
Richard W.M. Jones
20fd81147d test-tool: On i386, upstream qemu program is now called 'qemu-system-i386'.
For a while, the upstream qemu i386 emulator has been called
'qemu-system-i386' (instead of just 'qemu').  Fix test-tool so it
calls the right program.
2013-02-11 13:21:51 +00:00
Richard W.M. Jones
df983d1994 test-tool: Don't call guestfs_set_qemu before guestfs handle is initialized (RHBZ#909836).
Because of evolution of the code, if the user used the --qemu or
--qemudir options, libguestfs-test-tool would segfault because
guestfs_set_qemu was being called before the guestfs handle was
opened.

Change the code so this doesn't happen, and also remove the global 'g'
variable to make the code a bit more robust.

Bug found by Amit Shah.
2013-02-11 13:21:51 +00:00
Richard W.M. Jones
e4495b24bc daemon: link: Remove use of PATH_MAX.
Replace readlink calls with gnulib areadlink function.
2013-02-11 13:21:51 +00:00
Richard W.M. Jones
c3afef3eec daemon: xattr: Remove use of PATH_MAX. 2013-02-11 13:21:51 +00:00
Richard W.M. Jones
09f3913734 daemon: realpath: Remove use of both PATH_MAX and NAME_MAX. 2013-02-11 13:21:51 +00:00
Richard W.M. Jones
9c9ceec6b7 daemon: initrd: Remove use of PATH_MAX and other cleanups.
- Move variables to the top.
- Rearrange comments to make more sense.
2013-02-11 13:21:51 +00:00
Richard W.M. Jones
1703c6841b daemon: find0: Remove use of PATH_MAX. 2013-02-11 13:21:51 +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
e0a3a7c1e5 docs: Improve reasons for using libguestfs-make-fixed-appliance.
Thanks: Richard Harman.
2013-02-09 22:38:24 +00:00
Richard W.M. Jones
d6c0ff055d launch: libvirt: Make it clear that setsockcreatecon debug message is just a warning.
This was disturbing to some users, but other users saw the warning
when it was really something they should pay attention to.  Make it
clear that it's a warning, unless people are really using SELinux +
sVirt.

Thanks: Richard Harman.
2013-02-09 21:29:35 +00:00
Richard W.M. Jones
8ad8e1075b Version 1.21.9. 2013-02-09 21:02:11 +00:00
Richard W.M. Jones
d538af8a0a rescue: Count the mountable filesystems when displaying the 'suggest' message. 2013-02-09 20:53:18 +00:00
Richard W.M. Jones
4255db65e5 tools: Use CLEANUP_* macros in several C tools. 2013-02-09 20:37:03 +00:00
Richard W.M. Jones
20a562321c generator: Export libxml2 CLEANUP_* macros unconditionally.
These call abort() if libxml2 is not actually installed, but that
should never happen inside the library or tools.
2013-02-09 17:49:11 +00:00
Richard W.M. Jones
94d90f03e2 lib: Define CLEANUP_CMD_CLOSE macro and use it throughout the library. 2013-02-08 18:14:41 +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
30029b7ffb lib: Use CLEANUP_FREE_<struct>, CLEANUP_FREE_<struct>_LIST macros in a few places in the library. 2013-02-08 16:12:04 +00:00
Richard W.M. Jones
5f54da6fdf lib: Add CLEANUP_FREE_<struct>, CLEANUP_FREE_<struct>_LIST macros for API structs.
For example:

 {
   CLEANUP_FREE_STAT struct guestfs_stat *stat = guestfs_stat (g, "/foo");

   // stat is freed automatically when we leave the scope.
 }

The new header file "guestfs-internal-frontend-cleanups.h"
includes definitions for these.  It should not be included
directly.
2013-02-08 16:12:04 +00:00
Richard W.M. Jones
5e770c8f6a lib: Allow guestfs_free_* functions to be safely called with a NULL pointer.
This is so they work just like 'free'.
2013-02-08 16:12:04 +00:00
Richard W.M. Jones
7b7cfa62e3 lib: Remove explicit defines of _BSD_SOURCE.
An equivalent is defined already in <config.h>.
2013-02-08 16:12:04 +00:00
Richard W.M. Jones
cab1a0c1d9 generator: Add #ifndef defense around guestfs-internal-actions.h file. 2013-02-08 15:48:52 +00:00
Matthew Booth
8fb2306be4 generator: Add new Mountable argument type
This type is initially identical to Device.
2013-02-08 14:59:00 +00:00
Matthew Booth
6e7f95b669 inspect: Fix improperly ignored error in check_filesystem 2013-02-08 14:53:05 +00:00
Matthew Booth
7d6b5bb837 inspect: Don't re-implement list_filesystems in inspect_os 2013-02-08 14:42:37 +00:00
Matthew Booth
dd58db7329 Fix bogus partition number passed to guestfs___check_for_filesystem_on
Partition number was being passed to guestfs___check_for_filesystem_on
based on an index in list_partition. However, this ignores the
possibility of multiple block devices.

This change makes guestfs___check_for_filesystem_on examine the
passed-in device directly to determine if it is a whole device, or
what its partition number is.
2013-02-08 14:42:37 +00:00
Matthew Booth
a7d7e8176f New API: is_whole_device 2013-02-08 14:42:37 +00:00
Matthew Booth
3045c0cbaf btrfs: Fix btrfs_subvolume_list on F18 (RHBZ#903620).
The output of btrfs subvolume list has changed in F18 to include generation,
which breaks the parsing in btrfs_subvolume_list. This change replaces sscanf
with a more robust regular expression. The new regular expression should also
handle the addition of future unexpected columns.
2013-02-08 09:09:25 +00:00
Richard W.M. Jones
c78ec7e085 daemon: Check parameter of base64-out and tar-out before running external command (RHBZ#908322).
For base64-out, check the filename parameter exists and is not a
directory.

For tar-out, check the dir parameter exists and is a directory.
2013-02-06 14:56:56 +00:00
Matthew Booth
ca056d53bd generator: Add visibility to action struct
The visibility field in action replaces in_fish, in_docs and internal.
The defined types are:

VPublic:
  A public API. This is exported and documented in all language
  bindings, and in guestfish.

VStateTest:
  A public API which queries the library state machine. It is exported
  and documented in all language bindings, but not guestfish.

VBindTest:
  An internal API used only for testing language bindings. It is
  guarded by GUESTFS_PRIVATE in the C api, but exported by all other
  language bindings as it is required for testing. If language
  bindings offer any way to guard use of these apis, that mechanism
  should be used. It is not documented anywhere.

VDebug:
  A debugging API. It is exported by all language bindings, and in
  guestfish, but is not documented anywhere.

VInternal:
  An internal-only API. It is guarded by GUESTFS_PRIVATE in the C api,
  and not exported at all in any other language binding. It is not
  documented anywhere.
2013-02-06 13:53:28 +00:00
Richard W.M. Jones
f9bafde5e7 daemon: download: Add extra check that download file is not a directory (RHBZ#908321). 2013-02-06 13:27:26 +00:00
Richard W.M. Jones
f473a173b8 daemon: Add more information to certain calls to perror.
Replace selected calls to 'perror (filename)' with:

  fprintf (stderr, "syscall: %s: %m\n", filename);

so that more information is available about precisely which syscall
failed.

Note this is *not* reply_with_perror.  These messages are only printed
in verbose output, for the benefit of debugging.
2013-02-06 13:14:07 +00:00
Richard W.M. Jones
f631e84102 9p: Missing call to reply_with_perror. 2013-02-06 12:59:00 +00:00
Richard W.M. Jones
c98ef8d089 Version 1.21.8. 2013-02-05 20:27: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
72dd398679 daemon: Call wipefs before mkfs to work around pathological behaviour in btrfs.
See: RHBZ#907554, http://www.spinics.net/lists/linux-btrfs/msg21197.html
2013-02-04 21:54:15 +00:00
Richard W.M. Jones
7e25e0780e FAQ: Update section on sVirt. 2013-02-04 21:54:08 +00:00
Richard W.M. Jones
4075ed9247 build: Add src/guestfs-internal-{all,frontend}.h to EXTRA_DIST.
This fixes commit ec3b75e5ff.
2013-02-04 13:12:28 +00:00
Richard W.M. Jones
776ffbfaec Version 1.21.7. 2013-02-04 13:03:25 +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
d012b729fa ruby: Include "guestfs-internal-frontend.h" in extension.
Also undefine '_' symbol defined by Ruby's internal headers.

This fixes commit ec3b75e5ff.
2013-02-04 12:17:52 +00:00
Richard W.M. Jones
9e27a1556c perl: Include "guestfs-internal-frontend.h" in XS file.
Also undefine '_' symbol defined by Perl's internal headers.

This fixes commit ec3b75e5ff.
2013-02-04 11:49:04 +00:00
Richard W.M. Jones
5e4f03ccf2 README: Format the list of requirements better. 2013-02-02 15:24:23 +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
Cole Robinson
63c324e6c4 tests: Handle changing QEMUDIR
qemu-wrapper isn't regenerated if QEMUDIR is changed, so just
delete it and force regeneration.

Additionally we can drop the silent binary check, since
check-with-upstream-qemu-1 already does a similar test with --version
that will actually report an error to the user.
2013-01-31 16:30:28 +00:00
Matthew Booth
27b995c841 Make internal-only functions and structures private
Certain functions are intended to be internal only, but we currently
export them anyway. This change moves them into a separate section of
guestfs.h protected by a GUESTFS_PRIVATE variable. This change also
enables private structs, but doesn't implement any.

This change only affects the C api. Language bindings aren't affected,
but probably should be in the future.
2013-01-30 17:27:01 +00:00
Matthew Booth
1dd9bf73b7 build: Fix haskell dependencies and parallel build
Without this change all the tests in the haskell bindings are rebuilt
every time. The primary motivation for this change is to fix this.

The fix for the above also allows parallel builds to be re-enabled.
2013-01-30 10:53:02 +00:00
Matthew Booth
63c50c7847 build: Add common rule for sources shared between daemon and library 2013-01-29 16:24:08 +00:00
Richard W.M. Jones
be4a3d77c4 daemon: hivex: Rewrite filename param of hivex_commit to include sysroot (RHBZ#905341). 2013-01-29 10:21:51 +00:00
Richard W.M. Jones
908c45567c Version 1.21.6. 2013-01-28 18:42:05 +00:00
Richard W.M. Jones
950951c67d daemon: Use the new CLEANUP_* macros to simplify code. 2013-01-28 18:01:43 +00:00
Richard W.M. Jones
233055974d daemon: Add CLEANUP_* macros which automatically free memory when leaving scope.
cf commit 98b64650c8
2013-01-28 18:01:39 +00:00
Richard W.M. Jones
071de5ccfb daemon: Allow free_strings (NULL) and free_stringslen (NULL, ..).
Equivalent to free (NULL).
2013-01-28 18:01:20 +00:00
Richard W.M. Jones
3a8a62c3e4 lib: Further use of CLEANUP_* macros. 2013-01-28 18:01:19 +00:00
Richard W.M. Jones
cd3b626a33 launch: libvirt: Use CLEANUP_* macros.
Also implement macros for cleaning up libxml2 objects.
2013-01-28 18:01:19 +00:00
Richard W.M. Jones
5a3da36626 inspect: Use CLEANUP_* macros in inspection code. 2013-01-28 18:01:19 +00:00
Richard W.M. Jones
98b64650c8 lib: Add CLEANUP_* macros which automatically free things when leaving scope.
Use the macro like this to create temporary variables which are
automatically cleaned up when the scope is exited:

  {
    CLEANUP_FREE char *foo = safe_strdup (bar);
    ...
    // no need to call free (foo)!
  }

The following code is also valid.  The initialization of foo as 'NULL'
prevents any chance of free being called on an uninitialized pointer.
It may not be required in all cases.

  {
    CLEANUP_FREE char *foo = NULL;
    ...
    foo = safe_malloc (100);
    ...
    // no need to call free (foo)!
  }

This is also valid:

  {
    CLEANUP_FREE char *foo = ..., *bar = ...;
    ...
    // no need to call free (foo) or free (bar)!
  }

The CLEANUP_FREE_STRING_LIST macro calls guestfs___free_string_list
on its argument.  The argument may be NULL.

The CLEANUP_HASH_FREE macro calls hash_free on its argument.  The
argument may be NULL.

Important implementation note:
------------------------------

On GCC and LLVM, this is implemented using __attribute__((cleanup(...))).

There is no known way to implement this macro on other C compilers, so
this construct will cause a resource leak.

Important note about close/fclose:
----------------------------------

We did NOT implement 'CLEANUP_CLOSE' or 'CLEANUP_FCLOSE' macros.  The
reason is that I am not convinced that these can be used safely.  It
would be OK to use these to collect file handles along failure paths,
but you would still want a regular call to 'close'/'fclose' since you
must test for errors, and so you end up having to do:

  if (close (fd) == -1) {
    // failure case
    // avoid double-close in cleanup handler:
    fd = -1;
    ...
  }
  // avoid double-close in cleanup handler:
  fd = -1;
  ...
2013-01-28 18:01:19 +00:00
Richard W.M. Jones
acb85dafb1 Allow guestfs___free_string_list (NULL).
Equivalent to free (NULL).
2013-01-28 18:01:19 +00:00
Richard W.M. Jones
aab796c608 perl, python, ruby: Add definition of EVENT_ALL in these languages. 2013-01-28 18:01:19 +00:00
Richard W.M. Jones
27c81f3175 generator: Define all_events_bitmask.
In the C bindings, use this more accurate mask instead of 'all bits
set'.

In the Java bindings, use this instead of open coding.
2013-01-28 18:01:19 +00:00
Richard W.M. Jones
ded72a96f0 header: Minor whitespace fix. 2013-01-28 18:01:19 +00:00
Richard W.M. Jones
f3976de591 header: Deprecate LIBGUESTFS_HAVE_* in favour of GUESTFS_HAVE_*. 2013-01-28 18:01:19 +00:00
Richard W.M. Jones
d3068a3aff header: Link to guestfs-examples(3) man page from header file. 2013-01-28 18:01:19 +00:00
Matthew Booth
a0d874725d Update vim line length to 70
Apparently this makes it the same as emacs or something.
2013-01-24 15:00:49 +00:00
Richard W.M. Jones
abb1d46636 python: Inherit from 'object' base class.
This fixes the following Debian bug:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=698771

For an overview, see this question and the links from there:
http://stackoverflow.com/questions/4015417/python-class-inherits-object
2013-01-24 13:09:16 +00:00
Richard W.M. Jones
ec8939fd47 launch: libvirt: Add 'is_root' flag to the params struct.
This is just code motion, but it allows us to read this flag inside
the 'construct_libvirt_xml_seclabel' function in future (as a possible
way to fix RHBZ#890291).
2013-01-22 14:43:37 +00:00
Richard W.M. Jones
085b86a95a libvirt: Add debugging when opening libvirt handle.
When debugging is enabled, this produces output like below.  This is
useful when diagnosing what URI libguestfs is using.

libguestfs: opening libvirt handle: URI = NULL, auth = virConnectAuthPtrDefault, flags = 0
libguestfs: successfully opened libvirt handle: conn = 0xb05580
2013-01-22 13:50:57 +00:00
Richard W.M. Jones
875dc11364 launch: libvirt: Refactor seclabel code.
This is just code motion.
2013-01-22 13:45:11 +00:00
Richard W.M. Jones
ed5a083891 Version 1.21.5. 2013-01-21 22:16:07 +00:00
Richard W.M. Jones
4d8bdf0357 fuse: Use guestfs_rename to implement rename(2) syscall (RHBZ#895910). 2013-01-21 17:00:04 +00:00
Richard W.M. Jones
159e8f8c3a New API: rename: Rename file within the same filesystem (RHBZ#895910). 2013-01-21 17:00:04 +00:00
Matthew Booth
f956457b5d docs: Fix cut/paste error in pread_device 2013-01-21 15:57:23 +00:00
Richard W.M. Jones
28e34290ff fuse: If guestfs_last_errno returns 0, don't return no error to FUSE layer.
guestfs_last_errno (g) == 0 doesn't mean "no error".  It means the
errno was not captured.  In this case we have to substitute some sort
of errno, so choose EINVAL arbitrarily.
2013-01-21 14:42:48 +00:00
Richard W.M. Jones
533082e282 daemon: Change ln, ln-f (hard-link) APIs to use link(2) instead of external ln (RHBZ#895905).
The reasons to do this are twofold:

(a) It's probably a tiny bit faster.

(b) It lets us capture the real errno if the link(2) syscall fails.

The errno is also passed through guestmount, fixing RHBZ#895905:

+ guestmount -a test1.img -m /dev/sda1:/ -m /dev/sda2:/boot /tmp/mnt
+ touch /tmp/mnt/foo
+ cd /tmp/mnt
+ ln foo boot/foo
ln: failed to create hard link ‘boot/foo’ => ‘foo’: Invalid cross-device link
2013-01-21 14:23:07 +00:00
Richard W.M. Jones
ebc86ae6d7 Fix checksums-out command (RHBZ#895904).
This was broken by the earlier
commit 0306c98d31.

This commit also adds a regression test.
2013-01-21 11:14:56 +00:00
Richard W.M. Jones
e18e20793f tests: virt-make-fs: Allow btrfs to be skipped. 2013-01-21 08:15:54 +00:00
Richard W.M. Jones
2974b5d666 tests/qemu: Don't require LVM for these tests. 2013-01-18 17:23:43 +00:00
Richard W.M. Jones
64b229e8ff Version 1.21.4. 2013-01-18 08:18:24 +00:00
Richard W.M. Jones
d8f14591d1 daemon: lvm: Fix various paths relative to new lvm_system_dir.
This fixes commit 9fd41abd40.
2013-01-18 07:13:54 +00:00
Richard W.M. Jones
312d02afe4 tests: Don't construct the guests in parallel.
In automake 1.13, check_DATA is now built in parallel, resulting in it
trying to build 4 or 5 guests in parallel.
2013-01-18 07:13:53 +00:00
Hilko Bengen
aa83e7c7b8 Fix packagelist for current Debian-based systems 2013-01-18 07:02:15 +00:00
Hilko Bengen
111f444d69 inspector: Fix tests for out-of-tree builds 2013-01-18 07:01:09 +00:00
Hilko Bengen
9637bddc33 erlang: fix bindtests for out-of-tree build 2013-01-18 07:01:07 +00:00
Richard W.M. Jones
24c4178749 appliance: Add libcap to the appliance (thanks Skippy VonDrake). 2013-01-18 06:42:13 +00:00
Richard W.M. Jones
2c68aca9d7 automake: Force serial-tests.
automake 1.13 started to use stupid parallel tests by default,
breaking everything.
2013-01-17 18:21:20 +00:00
Richard W.M. Jones
9c8e47247b FAQ: Document "Could not allocate dynamic translator buffer" and how to fix it. 2013-01-17 18:10:14 +00:00
Matthew Booth
c61b589f9b gobject: Add pkg-config for gobject bindings 2013-01-17 15:06:09 +00:00
Olaf Hering
9fd41abd40 daemon: copy entire lvm directory
cp will fail if /etc/lvm is an empty directory. Copy the entire
directory and adjust environment variable.

Signed-off-by: Olaf Hering <olaf@aepfle.de>

RWMJ:
 - Fixed a couple of whitespace issues.
2013-01-17 14:13:03 +00:00
Richard W.M. Jones
a710c42f0f Version 1.21.3. 2013-01-17 09:43:59 +00:00
Richard W.M. Jones
a0e9d310d1 ruby: Use updated package names, but allow fallback to the old names (RHBZ#894545).
Thanks Dominic Cleal.
2013-01-16 14:33:49 +00:00
Richard W.M. Jones
d4763a2e24 daemon: Suppress two false positives from Coverity.
Using // coverity[...] or /* coverity[...] */ comments in the source
it is possible to suppress specific Coverity errors.  The suppressed
error should occur in the line following the comment.

In this case I have suppressed two false positives from Coverity:

(a) We deliberately assign to a NULL pointer in order to cause a
segfault, for testing how the library reacts when this happens.
Coverity flags this, but it is not an error in this case.

(b) Coverity does not model global variables (a known shortcoming).
Therefore the code 'errno = posix_memalign (...)' cannot be modelled
by Coverity, even though the code is correct.  Coverity raises a false
positive about this.

(Thanks Kamil Dudka, Coverity)
2013-01-16 11:30:07 +00:00
Richard W.M. Jones
ce828c6afc podwrapper: Refresh podwrapper man page.
This also adds a rule so you can do:

 make podwrapper.1

if you want to read the documentation as a man page.
2013-01-15 18:40:17 +00:00
Richard W.M. Jones
0d2d26d8e7 java: Implement the event API. 2013-01-15 18:40:17 +00:00
Richard W.M. Jones
3f08d50863 java: Use defined constants for flags in call to guestfs_create_flags. 2013-01-15 18:40:17 +00:00
Richard W.M. Jones
05a67bcc25 java: Change synopsis in man page to show use of add_drive. 2013-01-15 18:40:16 +00:00
Richard W.M. Jones
7d89baa3e9 java: Tidy up javadoc. 2013-01-15 18:40:16 +00:00
Richard W.M. Jones
f58b6c5953 Refresh README file. 2013-01-15 18:40:16 +00:00
Richard W.M. Jones
20e23ab2a3 Update copyright dates for 2013.
On generated files in git and README.
2013-01-15 18:40:16 +00:00
Richard W.M. Jones
e051b270a2 haskell: Use unused bogus data types. 2012-12-29 14:28:47 +00:00
Richard W.M. Jones
bff29314df haskell: Typo in man page, lists -> list. 2012-12-29 13:57:24 +00:00
Richard W.M. Jones
60d744e32f haskell: Implement 'head' and 'tail' by hiding the Prelude functions. 2012-12-29 13:38:13 +00:00
Richard W.M. Jones
406e372469 haskell: Use 'import Guestfs as G' in test code.
The code is equivalent but shorter.
2012-12-29 13:35:07 +00:00
Richard W.M. Jones
67d59d0153 haskell: Document current state of Haskell bindings. 2012-12-29 13:26:38 +00:00
Richard W.M. Jones
1881be1e56 haskell: Fix RHashtable in the generator. 2012-12-29 13:16:07 +00:00
Richard W.M. Jones
3a72944597 haskell: Use .NOTPARALLEL in this directory. 2012-12-29 13:16:07 +00:00
Richard W.M. Jones
7718cb5afe haskell: Fix RStringList in generator. 2012-12-28 21:36:07 +00:00
Richard W.M. Jones
5ede0b21b0 haskell: Add tests of config functions. 2012-12-28 20:44:36 +00:00
Richard W.M. Jones
c9e0ff8831 haskell: Allow non-appliance tests to run when !ENABLE_APPLIANCE. 2012-12-28 20:19:20 +00:00
Richard W.M. Jones
604f9a79db haskell: Renumber tests according to Perl scheme. 2012-12-28 20:17:31 +00:00
Richard W.M. Jones
3e7dcc384a haskell: Enable RString, RConstString in generator. 2012-12-28 20:11:23 +00:00
Richard W.M. Jones
beebade874 haskell: Enable RBool in generator. 2012-12-28 19:59:31 +00:00
Richard W.M. Jones
11e111ec01 haskell: Replace deprecated INCLUDE directive.
The INCLUDE directive is obsolete.  You must now put the name of the
include file before the C function name.
2012-12-28 19:55:01 +00:00
Richard W.M. Jones
9ae248e03f arm: Recomment vexpress-a15 instead of vexpress-a9.
Neither works (because of lack of PCI) but A15 emulation is probably
better than A9 emulation.
2012-12-27 20:02:31 +00:00
Richard W.M. Jones
6c9aaf394f launch: appliance: Fix parsing of QEMU_OPTIONS.
If there was no quoting character, the options could run off the end
of the string and into whatever string which happened to be following
in memory.

This bug was revealed when libguestfs was compiled on arm.
2012-12-27 20:01:15 +00:00
Richard W.M. Jones
bcdaa46313 launch: appliance: Small refactoring of virtio-scsi detection code.
This is just code motion.
2012-12-27 19:36:33 +00:00
Richard W.M. Jones
a9d70d1ae4 Fix whitespace in configure.ac.
Standardize on 4 spaces for indentation in configure.ac file.
This is just a change of whitespace.
2012-12-27 18:55:34 +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
5af94b5692 arm: Only use -device sga if qemu supports this device.
qemu-system-arm does not have the sgabios device.
2012-12-27 15:57:15 +00:00
Richard W.M. Jones
741c8606db lib: Remove useless cast.
'strings' is declared as char **, so the return type of
this expression will already be char *.  The cast is both
useless and potentially hides errors.
2012-12-27 15:27:20 +00:00
Richard W.M. Jones
4a877452f5 build: Fix ./configure --with-febootstrap-yum-config option.
This fixes commit bfddae7cee.

Also tested that all variants actually work.
2012-12-24 09:48:41 +00:00
Richard W.M. Jones
4b5d27869f Version 1.21.2. 2012-12-22 22:42:29 +00:00
Richard W.M. Jones
bfddae7cee build: Change --with-febootstrap-yum-config to --with-febootstrap-packager-config
For the rationale behind this renaming, see:
b8cbe191d0

You can still, for the time being, use
./configure --with-febootstrap-yum-config
but it's preferred to switch to the new option.  The new option is
identical, just renamed.

Qe still pass the deprecated --yum-config option to febootstrap
itself, since both old and new febootstrap support this.
2012-12-22 17:28:10 +00:00
Richard W.M. Jones
e73cf67762 inspection: Set fs->device field on swap devices.
For some reason the fs->device field was not set for swap devices.

Apparently this did not matter before (this bug has existed since at
least libguestfs 1.16), but in commit 6ee80b8dac we started to depend
on the fs->device field being non-NULL.  This resulted in segfaults
when inspecting any guest which had a swap device, eg:

 #0  __strcmp_sse42 () at ../sysdeps/x86_64/multiarch/strcmp-sse42.S:164
 #1  0x00007ffff7d740cb in parent_device_already_probed (g=0x703a70,
                        partition=0x6f79b0 "/dev/vda4") at inspect.c:156
 #2  0x00007ffff7d73e00 in guestfs__inspect_os (g=0x703a70) at inspect.c:83
 #3  0x00007ffff7cee11d in guestfs_inspect_os (g=0x703a70) at actions-1.c:397

This commit sets fs->device to the device name.

(Thanks Matthew Booth for first noticing this problem.)
2012-12-20 15:36:36 +00:00
Richard W.M. Jones
6628cc7ef6 Pass noapic on i686 kernel command line.
qemu 1.2 i686 TCG is buggy and hangs when emulating APIC.
https://bugzilla.redhat.com/show_bug.cgi?id=857026
2012-12-20 12:09:49 +00:00
Richard W.M. Jones
eca01c3105 faq: Suggest 'approx' (apt proxy) to speed up Debian builds.
Thanks Hilko Bengen.
2012-12-18 20:39:46 +00:00
Richard W.M. Jones
d1ad89520e tests: Skip windows.img tests if it is zero-sized.
If ntfs-3g is not installed, then tests/guests creates a 'windows.img'
file which is zero-sized.

This is problematical because other tests which use this image will
fail at best, or hit RHBZ#847549 (qemu/virtio-scsi bug) at worst.

Change the tests which use windows.img so they skip if 'windows.img'
has zero size.
2012-12-18 17:35:51 +00:00
Richard W.M. Jones
a34072e25b build: Add 'make print-subdirs' rule, useful for selectively running tests.
If you want to selectively run tests, or if the test suite fails half
way through, use:

  make print-subdirs

to print the subdirectories, select the ones you want to run / the
remaining ones, and do:

  make check SUBDIRS="..."
2012-12-18 16:28:23 +00:00
Richard W.M. Jones
fa162417ed daemon: Make gdisk into an optional dependency and optgroup.
Also document that gdisk is a dependency at all.

This fixes commit 956e30effa.
2012-12-18 11:52:41 +00:00
Richard W.M. Jones
2434a86da4 lua: tests: If $LUA is not set, set it to 'lua' instead of '/usr/bin/lua'. 2012-12-18 08:55:06 +00:00
Richard W.M. Jones
3f88f88c80 lua: Fix misapplied patch.
This fixes commit 5b70120293.
2012-12-18 08:53:34 +00:00
Richard W.M. Jones
8be9743e74 ruby: Disable -Wstrict-prototypes warning for Ruby headers. 2012-12-18 08:43:52 +00:00
Richard W.M. Jones
034d393bb1 docs: Properly document attach methods in the guestfs(3) man page. 2012-12-17 23:01:56 +00:00
Richard W.M. Jones
62f98d64a5 lua: Fix Lua configure test on Fedora.
On Debian, the lua pkg-config file is called "lua5.1.pc" (etc)
whereas on Fedora it's called "lua.pc" for all versions.
2012-12-17 23:01:56 +00:00
Hilko Bengen
5b70120293 lua: Use correct binary for tests 2012-12-17 22:24:53 +01:00
Hilko Bengen
f07e89c5f9 lua: Add ifdefs for Lua 5.2 compatibility 2012-12-17 22:24:53 +01:00
Hilko Bengen
05103cc693 lua: Use pkg-config to determine Lua version, parameters 2012-12-17 22:24:52 +01:00
Richard W.M. Jones
8237ac89c5 daemon: Use pvcreate --force option (RHBZ#887971).
pvcreate fails if the partition contains a swap space signature.  Use
more force to stop it from complaining.
2012-12-17 19:27:12 +00:00
Richard W.M. Jones
4ad6b28d83 Version 1.21.1. 2012-12-17 12:49:32 +00:00
Richard W.M. Jones
eab324bbbb list-filesystems: Ignore MBR type 0x42 (Windows dynamic disks) (RHBZ#887520). 2012-12-17 12:39:55 +00:00
Richard W.M. Jones
6f02e33c6f sparsify: Document that virt-sparsify doesn't work well on multi-disk VMs.
See: http://bugzilla.redhat.com/887826
2012-12-17 12:24:29 +00:00
Richard W.M. Jones
79339798b3 launch: libvirt: Improve loop invariant from previous commit.
This fixes commit 11b6293d1b.
2012-12-16 21:29:35 +00:00
Richard W.M. Jones
11b6293d1b launch: libvirt: Parse capabilities XML and fail early if qemu/KVM not supported (RHBZ#886915). 2012-12-16 20:56:39 +00:00
Richard W.M. Jones
c4ad2c0ce3 daemon: Fold stdout on stderr when running e2fsck.
User Phill Bandelow noted that virt-resize fails with an e2fsck error
on a host where the system clock had been accidentally set in the
past.

Unfortunately this was hard to diagnose because guestfsd 'ate' the
stdout of the e2fsck program.  I have verified by code inspection that
e2fsck prints messages on stdout.

Thus this changes the daemon to fold stdout and stderr together so we
get to see all error messages from e2fsck when it fails.
2012-12-16 18:38:41 +00:00
Richard W.M. Jones
22fe98ad9f build: Improve 'make help' output description of 'make extra-tests'. 2012-12-15 20:20:38 +00:00
Richard W.M. Jones
eca2dd2e8c build: Better formatting for 'make help' output.
This is just whitespace changes.
2012-12-15 20:15:12 +00:00
Richard W.M. Jones
486efb002a build: Show 'make -k check' as a possibility in 'make help' output.
Thanks to Cole Robinson for this suggestion.
2012-12-15 20:10:25 +00:00
Richard W.M. Jones
448a02373d ruby: Enable C compiler warnings.
This has the desirable side effect that the correct CFLAGS get passed
to the C compiler when building the Ruby extension.
2012-12-15 19:42:02 +00:00
Richard W.M. Jones
1571aef9cc python: Enable C compiler warnings. 2012-12-15 19:42:02 +00:00
Richard W.M. Jones
62e775c350 Change the handling of private functions, safe_malloc etc.
Rename guestfs_safe_malloc et al to guestfs___safe_malloc etc.

To use the private functions, code now has to define
-DGUESTFS_PRIVATE_FUNCTIONS=1.  This will make it easier for us in
future to work out which programs are using these functions and to
minimize both the number of programs and the functions they are
calling.

Note that the Perl, Python, OCaml, Ruby and Java bindings use
guestfs_safe_* calls.  None of the other bindings do.  This is a bug
(in the bindings using those functions): these functions will call the
out of memory callback on failure.  This function defaults to abort(),
and since this happens from a language binding, there is no way to
change this default.
2012-12-15 19:41:29 +00:00
Richard W.M. Jones
27f6878e2a guestfs.h: Fix use of __attribute__ and GCC < 4.
I guess no one uses GCC 3 any more, because if they did, including
<guestfs.h> would not work since GUESTFS_DLL_PUBLIC would not have
been defined.

At the same time, ensure that __attribute__((noreturn)) is only used
when the compiler is GCC >= 3.1.
2012-12-15 17:03:11 +00:00
Richard W.M. Jones
95df8a7c0c inspection: Don't call guestfs_hivex_close if previous guestfs_hivex_open call failed.
(Thanks Skippy VonDrake)
2012-12-14 22:04:25 +00:00
Matthew Booth
a9051eb98e daemon: Add sentinel attribute to commandf and commandrf
Causes a compiler warning to be emitted if you omit the trailing NULL argument.
2012-12-14 16:58:05 +00:00
Matthew Booth
956e30effa Add support for getting and setting GPT partition type GUIDs
New APIs:
  part_set_gpt_type
  part_get_gpt_type
2012-12-14 16:58:05 +00:00
Matthew Booth
2aa731e7c4 daemon: Remove redundant fork in commandrvf
Currently the code is doing a redundant fork when passed the
COMMAND_FLAG_CHROOT_COPY_FILE_TO_STDIN flag. The additional
sub-process does a chroot() which has no effect because all file
handles are already open at that point, then simply copies its input
to its output.

This change simply replaces the above with a dup2 of the passed file
handle to STDIN of the command process.

RWMJ:
  Don't initialize 'pid' variable.
2012-12-14 16:21:58 +00:00
Richard W.M. Jones
d7a806ca1a configure: Change minor from .20 to .21 for new development branch. 2012-12-13 17:53:36 +00:00
Matthew Booth
e92f9666de daemon: NFC Use symbolic names in commandrvf
Improve readability of commandrvf() by replacing bare int values for
file descriptors with their symbolic names STD{IN,OUT,ERR}_FILENO.

Also add PIPE_READ and PIPE_WRITE for referencing relevant ends of a pipe.
2012-12-13 17:53:20 +00:00
Matthew Booth
52cd07a0ac daemon: fix directory outside current root when executing commands
When executing a command, we temporarily chroot, fork and exec the
command, then chroot back. We intentionally don't chdir in the parent
process so that we can 'jailbreak' the chroot later. However, this has
the effect that commands are executed with a current working directory
which is outside the current root.  This unusual state can cause
errors in executed commands which don't anticipate it.

This change does a chdir("/") before executing and command. This
happens inside the fork, so the jailbreak isn't affected in the
parent.
2012-12-13 17:15:01 +00:00
Richard W.M. Jones
f784c87859 Version 1.20.0. 2012-12-13 14:18:30 +00:00
Richard W.M. Jones
25652a6d5c proto: Free drives array when qemu subprocess dies abruptly.
Commit ed7fda161e changed the g->drives
linked list into an array, and also made a subtle change to the
(undocumented) semantics of drives in the rare case when qemu is
relaunched.

Every time we go back to the CONFIG state, we should free the drives
array.  However there was one place where this was not happening.
This was caught by the tests of the protocol, but only when using the
default (appliance) method, not the libvirt method which we were more
interested in testing in Fedora.

When testing on Debian using the appliance method, we therefore hit
this bug for the first time.

This relates to or fixes the following commits:
  commit 9df159b34a
  commit 33f49d85c2
  commit ed7fda161e
2012-12-13 11:50:08 +00:00
Richard W.M. Jones
585dd44e17 debian: Allow test-disk-labels test to be skipped. 2012-12-13 11:50:08 +00:00
Richard W.M. Jones
14c7e9e52a launch: appliance: Disable virtio-scsi if qemu <= 1.1.
Debian Wheezy (7) ships with old qemu 1.1 which claims to support
virtio-scsi but in reality it's broken.

Disable virtio-scsi in this case.
2012-12-13 11:50:08 +00:00
Richard W.M. Jones
9508b750fd launch: appliance: Parse qemu version. 2012-12-13 10:38:45 +00:00
Richard W.M. Jones
c6558c75dd docs: Add website index.html.in to stable release documentation. 2012-12-13 08:50:12 +00:00
Richard W.M. Jones
5a293885a3 release notes: Update bugs list because one more bug was fixed. 2012-12-12 17:36:26 +00:00
Richard W.M. Jones
903e4864c0 Update gnulib to latest version for libguestfs 1.20 release. 2012-12-11 23:24:00 +00:00
Richard W.M. Jones
668683bd3d docs: Add gnulib update to stable release documentation. 2012-12-11 22:00:19 +00:00
Richard W.M. Jones
29cec9e235 build: Fix 'make help' output.
check-valgrind-local-tests -> check-valgrind-local-guests
2012-12-11 21:55:58 +00:00
Richard W.M. Jones
1a70df0ba6 Update API support ready for libguestfs 1.20 release. 2012-12-11 21:21:16 +00:00
Richard W.M. Jones
858bd9ffe0 launch: libvirt: Label sockets with svirt_socket_t (RHBZ#853393). 2012-12-11 20:33:28 +00:00
Richard W.M. Jones
966ebadb14 Update AUTHORS and BUGS files. 2012-12-11 17:16:13 +00:00
Richard W.M. Jones
436593f81f Push and pull latest translations from Transifex. 2012-12-11 17:15:49 +00:00
Richard W.M. Jones
557b8c6a0d Update ROADMAP for libguestfs 1.20 release. 2012-12-11 17:02:04 +00:00
Richard W.M. Jones
aeff59daa8 Update release notes and get ready for the libguestfs 1.20 release. 2012-12-11 16:58:57 +00:00
Richard W.M. Jones
0efe61b19d Add support for Windows dynamic disks (libldm / ldmtool) (RHBZ#782167).
New APIs:

  list-ldm-volumes
  list-ldm-partitions
  ldmtool-create-all
  ldmtool-remove-all
  ldmtool-scan
  ldmtool-scan-devices
  ldmtool-diskgroup-name
  ldmtool-diskgroup-volumes
  ldmtool-diskgroup-disks
  ldmtool-volume-type
  ldmtool-volume-hint
  ldmtool-volume-partitions
2012-12-11 15:20:19 +00:00
Matthew Booth
a93ea64959 inspect: Remove unused is_mountable field from filesystem struct 2012-12-11 15:20:19 +00:00
Matthew Booth
66ada9ed31 inspect: Remove unused is_swap field from filesystem struct 2012-12-11 15:20:19 +00:00
Matthew Booth
4fd5b89e36 inspect: Remove unused content field from filesystem struct
RWMJ: Don't remove entire if-clauses.
2012-12-11 15:20:09 +00:00
Richard W.M. Jones
91b3233e4a docs: Copy-edit documentation of the private data area. 2012-12-10 19:58:38 +00:00
Richard W.M. Jones
b554d7de82 guestfs-performance: Some copy-editing. 2012-12-10 17:23:57 +00:00
Richard W.M. Jones
7d2ae9f30f daemon: Generate the code when libraries are statically not available.
Since we as developers rarely test the case where some library is
statically not available, that side of the code was hardly tested,
except by unfortunate users in the field who often hit cases where
functions were missing or misdeclared.  In fact, when making this
change I noticed several bugs like that.

Change it so that this code is autogenerated, and therefore always
correct and up to date.

Previous code which looked like this:

  int
  optgroup_acl_available (void)
  {
    return 0;
  }

  char * __attribute__((noreturn))
  do_acl_get_file (const char *path, const char *acltype)
  {
    abort ();
  }

  /* etc */

is replaced by a single line:

  OPTGROUP_ACL_NOT_AVAILABLE
2012-12-10 16:20:34 +00:00
Richard W.M. Jones
5802b30ae5 generator: Change optgroups so second element is a list of functions.
Before this commit it was a list of function names (ie. strings)
making it hard if you wanted to get back to the original function
definition.
2012-12-10 16:14:42 +00:00
Richard W.M. Jones
2a2719d889 generate: Simplify generate_prototype ~single_line feature.
This is just code refactoring.
2012-12-10 16:13:15 +00:00
Richard W.M. Jones
74763eafa7 daemon: Make sure *.h files have guards against double-inclusion.
This is just code cleanup.
2012-12-10 15:49:48 +00:00
Richard W.M. Jones
82344085aa erlang: Add more tests.
Since I made lots of changes to the Erlang bindings (prompted by
Coverity), I wasn't confident that something didn't break because
there were no real tests before.
2012-12-10 13:21:06 +00:00
Richard W.M. Jones
bc05e91f0e ./run: Add Erlang support to run script. 2012-12-10 12:41:47 +00:00
Cole Robinson
cac8c56423 tests: Fix qemu-wrapper.sh generation 2012-12-09 12:12:04 +00:00
Richard W.M. Jones
6ab4d505f1 launch: libvirt: Avoid double-close of console socket on error path (found by Coverity). 2012-12-08 16:42:38 +00:00
Richard W.M. Jones
98391ab9c6 xfs: Remove potential double-free of 'buf' in multiple places (found by Coverity). 2012-12-08 16:42:38 +00:00
Richard W.M. Jones
ac6f94fb3e lua: Add comment about unsolved, hard to fix race (found by Coverity). 2012-12-08 16:42:38 +00:00
Richard W.M. Jones
0c6bc2f42f erlang: Avoid unintentional sign extension (found by Coverity).
Comment from Coverity:

  libguestfs-1.19.66/erlang/erl-guestfs-proto.c:115: sign_extension:
  Suspicious implicit sign extension: "buf[0]" with type "unsigned char"
  (8 bits, unsigned) is promoted in "(buf[0] << 24) | (buf[1] << 16) |
  (buf[2] << 8) | buf[3]" to type "int" (32 bits, signed), then
  sign-extended to type "unsigned long" (64 bits, unsigned).  If
  "(buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]" is greater
  than 0x7FFFFFFF, the upper bits of the result will all be 1.
2012-12-08 16:42:38 +00:00
Richard W.M. Jones
96e59eee66 lib: 'tmpfile' is never NULL (found by Coverity). 2012-12-08 16:42:38 +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
b18a1b4e66 md: Free up 'ret' along error path (found by Coverity). 2012-12-08 16:42:38 +00:00
Richard W.M. Jones
a23d065c49 lib: Free up the right list if guestfs_internal_lstatlist returns an error (found by Coverity).
We were freeing up a list, but not the right list.
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
855f023d2e lua: Don't leak memory for returned objects (found by Coverity). 2012-12-08 16:42:38 +00:00
Richard W.M. Jones
9733665bc6 python: Don't leak memory along error paths (found by Coverity). 2012-12-08 16:42:38 +00:00
Richard W.M. Jones
a1e37b7ea5 perl: Use safe_malloc instead of malloc (found by Coverity). 2012-12-08 16:42:37 +00:00
Richard W.M. Jones
3fe5f0a971 php: Return SUCCESS from PHP_MINIT_FUNCTION (found by Coverity). 2012-12-08 16:42:37 +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
40bfce7629 lib: Avoid segfault if guestfs_internal_readlinklist returns an error (found by Coverity). 2012-12-08 16:42:37 +00:00
Richard W.M. Jones
42e0cf77f3 inspect: Remove dead code (found by Coverity). 2012-12-08 16:42:37 +00:00
Richard W.M. Jones
9df159b34a launch: appliance: Really add dummy appliance slot (found by Coverity).
In the previous code, appliance was unconditionally set to NULL and so
we never added the dummy appliance slot to g->drives.  This probably
doesn't matter, since hotplugging doesn't work for the 'appliance'
attach-method.  Despite that, it's better to get this right.

This fixes commit ed7fda161e.
2012-12-08 16:42:37 +00:00
Richard W.M. Jones
e9e5a0f94e daemon: Fix error checking in function (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
15d5c94377 daemon: Explicitly ignore return value from modprobe command (found by Coverity). 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
091b98a9ea tmpdirs: Explicitly ignore return value from guestfs___cmd_run to keep Coverity happy.
We don't care if this command fails.
2012-12-08 13:26:04 +00:00
Richard W.M. Jones
aa785c85d9 lib: Explicitly ignore return value from guestfs_parse_environment in guestfs_create (found by Coverity).
The purpose of adding guestfs_create_flags was so that users could
check for errors from guestfs_parse_environment if they need to.
2012-12-08 13:26:04 +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
8331d46384 virt-rescue: Document a method to capture core dumps from within the rescue environment. 2012-12-07 15:25:04 +00:00
Richard W.M. Jones
bb0de6938a daemon: Fix noreturn error in acl and capabilities code.
This is an improvement over the original fix in
commit fe4cdb2a47.
2012-12-07 15:24:49 +00:00
Richard W.M. Jones
f5e9e2780b configure.ac: Fix comment.
I spent a lot of time looking at how gnulib "manywarnings" works, and
this comment reflects my improved understanding.
2012-12-07 15:24:18 +00:00
Richard W.M. Jones
47511ddbc9 Add NOT_SUPPORTED macro to daemon and library.
This convenience macro returns errno == ENOTSUP.
2012-12-07 15:24:06 +00:00
Richard W.M. Jones
77e9b1a9e8 appliance: Add (default commented out) section containing debugging tools. 2012-12-07 12:09:20 +00:00
Richard W.M. Jones
52744cc232 tests: charset: Fix broken Makefile.am escaping.
This fixes commit 5a2e320ec9.
2012-12-04 15:21:49 +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
Evaggelos Balaskas
f92b4a7d83 packagelist.in for archlinux
latest archlinux has some small changes:

btrfs-progs-unstable --> btrfs-progs
genisoimage --> cdrkit
iproute --> iproute2
module-init-tools --> kmod
procps --> procps-ng
udev --> systemd
util-linux-ng --> util-linux

and could you plz add the below packages

lrzip
less
sed

RWMJ: I took this opportunity to make some general cleanups to the file:

- add 'less' and 'sed' for everyone
- 'module-init-tools' & 'kmod'[1]
- 'procps' & 'procps-ng'[1]
- 'util-linux' & 'util-linux-ng'[1]
- sort the ArchLinux packages into order

[1] Note that febootstrap is supposed to ignore packages it doesn't
know about.
2012-12-03 22:15:39 +00:00
Richard W.M. Jones
57009f0136 build: Make 'check-valgrind' fail noisily if valgrind is not installed.
The way the existing configure script worked, @VG@ would be empty, and
it would run all the way through the check-valgrind rule successfully
without actually running anything under valgrind.
2012-12-03 18:45:59 +00:00
Richard W.M. Jones
3cced0950c docs: Minor copyedits to the release notes. 2012-12-01 19:01:31 +00:00
Richard W.M. Jones
e35045720b Update release notes. 2012-12-01 14:56:25 +00:00
Richard W.M. Jones
443ea95faf Version 1.19.66. 2012-12-01 13:38:58 +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
921b716b0b test-tool: Parse the environment separately.
This lets us report bugs when parsing the environment.
2012-12-01 12:04:13 +00:00
Richard W.M. Jones
e8d6d6f737 test-tool: Create the handle later.
Although this leads to a small amount of code duplication with the -V
option, the overall effect is cleaner.

This is just code motion.
2012-12-01 12:04:13 +00:00
Richard W.M. Jones
6b5f9221b4 tmpdirs: Make relative TMPDIR (etc) absolute, and check it's a directory (RHBZ#882417).
This fixes commit 1efed122c0.
2012-12-01 12:04:09 +00:00
Richard W.M. Jones
575895d8b0 test-tool: Print tmpdir properly.
It was actually printing cachedir.

This fixes commit f9ab256f0e.
2012-12-01 11:14:57 +00:00
Richard W.M. Jones
3d59ed5458 inspection: Get icon for Windows 8 (RHBZ#801117). 2012-12-01 09:41:33 +00:00
Richard W.M. Jones
c08fbc9cb4 contrib: Useful script to extract all logos/icons from a Windows guest. 2012-12-01 09:09:56 +00:00
Richard W.M. Jones
160977987f inspection: Temporary logo for Windows 8.
See the comment from the code:

  NB about Windows 8: No location we've found so far contains a
  suitable icon for Win8.  In particular, explorer.exe definitely
  does *not* contain any Windows logo as a resource (I checked).
  Therefore the "basket icon" that this produces is just a stand-in
  until we have a better idea for solving this problem.

and:

  https://bugzilla.redhat.com/show_bug.cgi?id=801117
2012-11-30 23:00:33 +00:00
Richard W.M. Jones
f5ae46dca7 inspection, virt-sysprep: Use /etc/hostname on F18+, RHEL7+ (RHBZ#881953, RHBZ#858696). 2012-11-30 12:37:48 +00:00
Richard W.M. Jones
fe4cdb2a47 daemon: Avoid gcc warning about noreturn function in acl & cap code.
acl.c: In function 'do_acl_get_file':
acl.c:158:1: error: function might be candidate for attribute 'noreturn' [-Werror=suggest-attribute=noreturn]
2012-11-30 09:01:05 +00:00
Richard W.M. Jones
a8f6e06b30 Version 1.19.65. 2012-11-29 19:40:00 +00:00
Richard W.M. Jones
6ee80b8dac inspection: Don't probe partitions when we've probed the whole device (RHBZ#798979).
So we don't get multiple <operatingsystem> entries, particularly for
install ISOs.
2012-11-29 18:27:26 +00:00
Richard W.M. Jones
90e7981082 inspection: Read libosinfo database in order to inspect OS install CD/DVD/ISOs (RHBZ#803650, RHBZ#805417). 2012-11-29 18:22:00 +00:00
Richard W.M. Jones
31101db4c7 lib: Indent CFLAGS in Makefile.am.
This is just a whitespace change.
2012-11-29 17:07:39 +00:00
Richard W.M. Jones
5693799614 inspection: Move variable decls to top of function.
This is just code motion.
2012-11-29 17:07:39 +00:00
Richard W.M. Jones
fc6f34d5cd inspection: Implement "openbsd" type and distro. 2012-11-29 17:07:39 +00:00
Richard W.M. Jones
0e5eef87d0 daemon: isoinfo: Fix parsing of bogus dates.
eg:

$ isoinfo --debug -d -i ubuntu-12.04-desktop-amd64.iso
CD-ROM is in ISO 9660 format
System id:
Volume id: Ubuntu 12.04 LTS amd64
Volume set id:
Publisher id:
[...]
Creation Date:     2012 04 25 16:13:46.00
Modification Date: 2012 04 25 16:13:46.00
Expiration Date:                :  :  .
Effective Date:                 :  :  .
[...]
2012-11-29 17:07:39 +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
9e7daf2ee8 virt-df: Better output when multiple -a/-d options are specified (RHBZ#880801).
This is very well explained in the bugzilla comments:
https://bugzilla.redhat.com/show_bug.cgi?id=880801#c1

With this change, the disk name has a one or more plus signs ('+')
appended to show that there are additional disks:

  $ virt-df -a Win7x32TwoDisks-a -a Win7x32TwoDisks-b
  Filesystem                   1K-blocks    Used  Available  Use%
  Win7x32TwoDisks-a+:/dev/sda1    102396   24712      77684   25%
  Win7x32TwoDisks-a+:/dev/sda2  12478460 7403416    5075044   60%
  Win7x32TwoDisks-a+:/dev/sdb1    521212   55728     465484   11%
2012-11-29 11:45:39 +00:00
Richard W.M. Jones
6255cc8343 Add .mailmap to EXTRA_DIST. 2012-11-27 08:48:39 +00:00
Wanlong Gao
36232b0bbe Add the .mailmap and change the method to generate AUTHORS
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-11-27 08:45:23 +00:00
Richard W.M. Jones
567747f78e lib: lpj: Refactor code.
Only run one grep command to grep any number of files.
2012-11-26 09:37:58 +00:00
Richard W.M. Jones
8243c0c6f6 lib: lpj: Only return first match in read_all function.
If there where several lpj=.. matches then the earlier matches would
be leaked.  Only return the first one and don't leak memory.
2012-11-26 08:58:26 +00:00
Richard W.M. Jones
d2c75dd0ff lib: Get lpj= from /var/log/boot.msg (thanks Olaf Hering). 2012-11-25 18:11:19 +00:00
Richard W.M. Jones
d7517360f2 Version 1.19.64. 2012-11-24 15:11:28 +00:00
Richard W.M. Jones
a4c0d7a82a launch: appliance: Handle non-\0 terminated buffer correctly.
The read_all function is used as a callback for

  guestfs___cmd_set_stdout_callback (cmd, read_all, [str],
                                     CMD_STDOUT_FLAG_WHOLE_BUFFER);

As noted in the documentation for CMD_STDOUT_FLAG_WHOLE_BUFFER, the
buffer returned is not \0-terminated, and so using memdup will create
an unterminated string, and therefore potentially a memory overrun
when reading or searching the string.

Use strndup instead so the final string is \0-terminated.
2012-11-24 14:17:35 +00:00
Richard W.M. Jones
aeea803ad0 appliance: Pass lpj=... on the appliance command line (thanks Marcelo Tosatti).
Try to get the host's loops_per_jiffy value and pass this on the
command line to the guest.  In theory this should avoid the appliance
having to recalculate this value in a VM with TCG (which is generally
error-prone).  This should avoid timing issues.

We only do this when we are certain that the guest will be TCG.
Currently we only have enough information to do this from the libvirt
attach-method.  So mostly this will only affect people using Fedora in
a VM.

The host loops_per_jiffy value is not exported by the kernel.  It is
only printed by the kernel early during boot, so if boot messages have
"scrolled off" the kernel ring buffer, it won't be available.  Some
operating systems save early kernel messages in /var/log/dmesg but (a)
Fedora 18+ seem to have abandoned this file and (b) on Ubuntu this
file is unreadable for spurious "security" reasons.

I have submitted a patch to make lpj available through /proc/cpuinfo.
2012-11-24 14:17:08 +00:00
Richard W.M. Jones
62895440bc launch: libvirt: Refactor parameter passing to construct_libvirt_xml* functions.
This is just code motion.
2012-11-24 13:09:53 +00:00
Olaf Hering
e987c038ea lua: fix build error due to LUA_GLOBALSINDEX usage
lua 5.2 changed API, LUA_GLOBALSINDEX is no longer available.
http://www.lua.org/manual/5.2/manual.html#8.3

Signed-off-by: Olaf Hering <olaf@aepfle.de>
2012-11-23 21:42:49 +00:00
Richard W.M. Jones
12acff5f56 Version 1.19.63. 2012-11-23 17:33:00 +00:00
Richard W.M. Jones
1ef9af9acb daemon: Ignore lvresize error "New size..matches existing size" (RHBZ#834712).
The lvresize command unnecessarily gives an error if you don't
change the size of the LV.  Suppress this error.
2012-11-23 17:17:57 +00:00
Richard W.M. Jones
dd4038c8a4 test-tool: Don't print banner when using --help, -V, etc options (RHBZ#879416). 2012-11-23 14:50:54 +00:00
Richard W.M. Jones
2272cccfd4 launch: Refactor duplicate code which constructs the appliance command line.
Move this into a common file.
2012-11-23 13:17:05 +00:00
Richard W.M. Jones
a6a0b9ba16 lib: Fix memory leak and simplify command code.
Fix the following memory leak found by valgrind:

==13629== 498 (112 direct, 386 indirect) bytes in 1 blocks are definitely lost in loss record 99 of 110
==13629==    at 0x4A06B2F: calloc (vg_replace_malloc.c:593)
==13629==    by 0x4CA564E: guestfs_safe_calloc (alloc.c:71)
==13629==    by 0x4CA9B02: guestfs___new_command (command.c:143)
==13629==    by 0x4CA66E9: guestfs___build_appliance (appliance.c:690)
==13629==    by 0x4CBD1B9: launch_libvirt (launch-libvirt.c:188)
==13629==    by 0x402E7E: main (virt-filesystems.c:349)

Also adjust the command code in several places to make it simpler.  We
can almost always call guestfs___cmd_close right after
guestfs___cmd_run, avoiding any need to close the handle along error
paths.

Tested by running the test suite under valgrind.
2012-11-23 12:12:33 +00:00
Richard W.M. Jones
fae8d7cafb New APIs: Implement Linux filesystem capabilities.
This adds the following new APIs:
 - cap_get_file
 - cap_set_file
2012-11-22 16:45:32 +00:00
Richard W.M. Jones
218b39acae New APIs: Implement POSIX ACLs.
This adds the following new APIs:
 - acl_get_file
 - acl_set_file
 - acl_delete_def_file
2012-11-22 16:19:21 +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
Wanlong Gao
9fb5a3ceaf sysprep: remove crash data generated by kexec-tools
Remove the kdump generated kernel crash data.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>

RWMJ:
 - Added /var/log/dump/* path for SLES (thanks Olaf Hering).
 - Update po/POTFILES-ml.
2012-11-22 08:30:21 +00:00
Richard W.M. Jones
30f202da43 Update API support. 2012-11-20 19:53:18 +00:00
Richard W.M. Jones
8ae8f1453b Update PO files from transifex. 2012-11-20 19:51:45 +00:00
Richard W.M. Jones
20d524f4fa Version 1.19.62. 2012-11-20 19:43:18 +00:00
Richard W.M. Jones
d0f89fed85 ./run: Ensure all paths are built up cumulatively. 2012-11-20 18:40:54 +00:00
Richard W.M. Jones
12905a9bbb lua: valgrinding Lua code doesn't work.
See comment.
2012-11-20 18:31:45 +00:00
Richard W.M. Jones
1e321b883b valgrind: Ignore init_libguestfs symbol.
It's not relevant, since the memory leak begins in libvirt.
2012-11-20 18:31:16 +00:00
Richard W.M. Jones
0ff561f332 lua: Replace internal lua_guestfs_* functions with guestfs_lua_*.
This is just code motion.  It just ensures there is no possible
conflict with lua_* symbols.
2012-11-20 17:34:23 +00:00
Richard W.M. Jones
1f98450995 lua: Attach __tostring functions exceptions.
This includes a test.
2012-11-20 17:32:37 +00:00
Richard W.M. Jones
4749bff379 lua: Fix whitespace. 2012-11-20 16:42:40 +00:00
Richard W.M. Jones
ca488a6d7b lua: Various fixes to the bindings (thanks Jerome Vuarand).
See http://article.gmane.org/gmane.comp.lang.lua.general/95065

Note that this is incompatible with existing code.  You
have to do:

  local G = require "guestfs"
  local g = G.create ()

ie. give the module your own name ("G" in that example).
2012-11-20 16:34:23 +00:00
Richard W.M. Jones
8f80f9fdae lua: Print the error thrown by callbacks. 2012-11-20 14:24:42 +00:00
Richard W.M. Jones
efb2d07ad6 lua: Add comment (not fix) for incorrect 'g' argument in callbacks.
Thanks Jerome Vuarand.
2012-11-20 14:15:45 +00:00
Richard W.M. Jones
7f1f7dd44f lua: Add bindtests. 2012-11-20 14:11:47 +00:00
Richard W.M. Jones
b19f007bd2 lua: Use lua_rawgeti to read elements from lists of strings.
This is faster, but more importantly it avoids the strange error
'lua: attempt to index a string value' which appears with (some)
single element lists.
2012-11-20 14:11:47 +00:00
Richard W.M. Jones
69c5f3045a lua: Add LuaStyle of commenting to the generator. 2012-11-20 13:55:50 +00:00
Richard W.M. Jones
74105fdab1 lua: Allow regular int to be passed as a 64 bit integer. 2012-11-20 13:45:34 +00:00
Richard W.M. Jones
3454cfb73c daemon: wipefs: Use --force option if available.
See https://bugzilla.redhat.com/show_bug.cgi?id=872831
and https://bugzilla.redhat.com/show_bug.cgi?id=865961
2012-11-20 10:44:10 +00:00
Richard W.M. Jones
b5b475ab82 lua: Simplify get_event function.
Use luaL_checkoption which is designed for this purpose.
2012-11-20 09:10:15 +00:00
Richard W.M. Jones
fdfdc883fc lua: Document Guestfs.event_all. 2012-11-19 18:19:29 +00:00
Richard W.M. Jones
e866ee7c79 erlang, lua: Fix links in man pages. 2012-11-19 18:16:08 +00:00
Richard W.M. Jones
556fc92e8a lua: Test globals in Guestfs.* namespace. 2012-11-19 17:13:14 +00:00
Richard W.M. Jones
bc03a48c71 lua: Add global Guestfs.event_all (list of all events). 2012-11-19 17:11:27 +00:00
Richard W.M. Jones
36e71e0cf4 Version 1.19.61. 2012-11-19 14:46:59 +00:00
Richard W.M. Jones
f77ddb9e11 lua: Various fixes and enhancements:
- add support for events (with test)
- test progress messages
- update documentation to describe events
- refactor handle closing code
- refactor error code
- use 'assert' in test code instead of 'if ... then error end'
2012-11-19 14:01:40 +00:00
Richard W.M. Jones
d14557d434 perl: Add test of multiple independent handles. 2012-11-19 09:39:30 +00:00
Richard W.M. Jones
6e5916e0f4 lua: examples: Boolean true shouldn't have quotes around it. 2012-11-18 19:24:20 +00:00
Richard W.M. Jones
6483c506b9 lua: Add another test to prove that the handles are really independent. 2012-11-18 16:45:44 +00:00
Richard W.M. Jones
6710296b7a lua: Don't use %m since Lua string formatter doesn't understand it.
Use %s + strerror as a replacement.
2012-11-18 16:45:08 +00:00
Richard W.M. Jones
4ba8b5a00d lua: Add some missing features.
- Remove default error handler.
- User cancel.
- Add the errno to the object which is thrown on error.

Still no events.
2012-11-17 21:28:43 +00:00
Richard W.M. Jones
a9c4efdcfd Version 1.19.60. 2012-11-17 20:03:57 +00:00
Richard W.M. Jones
ff8bfd3e92 Add Lua bindings.
These are relatively complete, although only lightly tested.  Missing:

 - events
 - last_errno
 - user_cancel
2012-11-17 20:02:42 +00:00
Richard W.M. Jones
4a2e8e8957 perl: Clean up and update the tests. 2012-11-17 18:14:20 +00:00
Richard W.M. Jones
3d0e937b84 perl: Small test of create with flags. 2012-11-17 17:55:06 +00:00
Richard W.M. Jones
43369e1bd4 sparsify: Better error when user specifies --compress + raw output (RHBZ#852194). 2012-11-15 16:37:23 +00:00
Richard W.M. Jones
2f321ced21 todo: We must implement ACLs and filesystem capabilities for SCAP.
Thanks Steve Grubb.
2012-11-15 15:35:46 +00:00
Richard W.M. Jones
a41629deb9 daemon: Perform device name translation on mke2fs journaldevice (RHBZ#876579).
Also various fixes:

 - remove fixed-size buffer
 - change if (err) free (err) -> free (err).
2012-11-15 10:16:28 +00:00
Richard W.M. Jones
5d9f10c312 recipes: Add sections about hexdumping, hexediting sectors. 2012-11-15 09:01:15 +00:00
Richard W.M. Jones
fd81d3f9b2 recipes: Add recipe for diffing two guests. 2012-11-14 22:34:06 +00:00
Richard W.M. Jones
5638cd3024 Version 1.19.59. 2012-11-13 15:36:30 +00:00
Richard W.M. Jones
e8ad3efbc4 dist: Add miscellaneous files to the tarball.
Lots of these had been omitted over time.
2012-11-13 15:26:29 +00:00
Richard W.M. Jones
2d89aef897 tests/protocol: Add test-qemudir-launchfail.sh to tarball (but don't run it).
This file was present in git, but missing from the tarball.

Don't actually run the test: it depends on details of how the
appliance is constructed which would fail for old-style appliances.
2012-11-13 15:26:29 +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
5c44c691f2 tests: Add a parallel launch test.
This is designed to reveal libvirt race conditions such as
bug 875741.

This is a "slow test" so it only runs if you do 'make check-slow'.
2012-11-13 15:26:29 +00:00
Richard W.M. Jones
ee5f18293b tests: Add 'make check-slow' rule to recursively run slow/long-running tests. 2012-11-13 15:26:29 +00:00
Richard W.M. Jones
cb4284b9e3 Add 'make help' rule.
This gives a short overview of the make targets.
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
c4a3ea066b extra-tests: Add $(libvirt_ro_uri) substitution to configure.
This is essentially just code motion.
2012-11-13 15:26:29 +00:00
Richard W.M. Jones
765d14dc05 Define whole valgrind command (as @VG@) in the configure script.
This is mostly just code motion, but it also changes the default
location where valgrind.log is written to be the top build directory
(instead of tests/extra/valgrind.log).
2012-11-13 15:26:29 +00:00
Richard W.M. Jones
ab360c48d4 align: Add a test for virt-alignment-scan. 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
73631705cf inspector: Add some real virt-inspector tests. 2012-11-13 15:26:29 +00:00
Richard W.M. Jones
e884abfd06 extra-tests: Move valgrind suppressions file to top source directory.
This is just code motion.
2012-11-12 15:49:08 +00:00
Richard W.M. Jones
b2663be064 Various fixes to API support script.
Remove internal structures, fix it so it works with the new
code layout under src/
2012-11-12 13:40:43 +00:00
Richard W.M. Jones
02ecd048d3 lib: Split up huge src/guestfs.c into logical compilation units.
This file had grown by accretion to include:

 - code related to handles (now in src/handle.c)

 - safe allocation (src/alloc.c)

 - debug, errors, warnings (src/errors.c)

 - private data (src/private-data.c)

 - miscellaneous functions (src/canonical-name.c, src/utils.c)

This commit also removes about a dozen #include files which were
probably not really used.

This is just code motion.
2012-11-12 13:40:25 +00:00
Richard W.M. Jones
f9ab256f0e test-tool: Print cachedir and tmpdir.
This fixes commit 1efed122c0.
2012-11-10 22:03:25 +00:00
Richard W.M. Jones
2c9e532566 Update release notes. 2012-11-10 14:04:09 +00:00
Richard W.M. Jones
17090bd09f Version 1.19.58. 2012-11-10 11:25:26 +00:00
Richard W.M. Jones
fcf8032cbd lib: Fix memory leak in tmpdir/cachedir code (found by valgrind).
This fixes commit 1efed122c0.
2012-11-10 08:55:38 +00:00
Richard W.M. Jones
99377e2748 tests: Remove double-test for availability.
If you have a function which is in the X optgroup, and also has
IfAvailable X, then two tests for the optgroup are added to the
output.

Check for this case and give an error.

This also fixes existing APIs.
2012-11-09 22:48:47 +00:00
Richard W.M. Jones
a74f168168 tests: More efficient use of strings in the object code.
No functional change.
2012-11-09 22:48:47 +00:00
Richard W.M. Jones
a270faefef tests: Use guestfs_{push,pop}_error_handler.
Replace the custom error handler with calls to
guestfs_{push,pop}_error_handler only where necessary.  This
simplifies the generated code.
2012-11-09 22:48:47 +00:00
Richard W.M. Jones
2deb235cf4 tests: Cleanup code that prints each test name.
This is just code motion.
2012-11-09 22:48:47 +00:00
Richard W.M. Jones
56c7967cad tests: Change code for printing warnings about untested functions.
Just code cleanup, no functional change.
2012-11-09 20:19:30 +00:00
Richard W.M. Jones
04a8cffee7 tests: Remove dead code in generated output. 2012-11-09 20:19:08 +00:00
Richard W.M. Jones
599a1930b0 tests: Format the generated code properly.
This is just whitespace changes in the output.
2012-11-09 20:18:54 +00:00
Richard W.M. Jones
25ff0db3b4 fuse: Use guestfs_{push,pop}_error_handler so we can see errors in shutdown.
In the fork (usual) case, we still won't see any errors since stderr
has been redirected to /dev/null, but this way is still a little more
correct.
2012-11-09 19:53:39 +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
b460d9f32e lib: Modify library code to use guestfs_{push,pop}_error_handler.
This is less efficient than directly manipulating g->error_cb, but
easier to maintain.
2012-11-09 19:51:08 +00:00
Richard W.M. Jones
a3b6751863 lib: Add new C API calls: guestfs_push_error_handler,
guestfs_pop_error_handler.

The addition of these calls makes it much simpler to temporarily
disable or ignore errors:

 guestfs_push_error_handler (g, NULL, NULL);
 guestfs_mkdir (g, "/foo"); /* We don't care if this fails. */
 guestfs_pop_error_handler (g);

Note these calls are used by the C API only.  They are not necessary
in other languages, because those map errors to exceptions.

The subsequent commits change existing code to use push/pop instead of
laboriously saving and restoring the error handler.
2012-11-09 19:50:57 +00:00
Richard W.M. Jones
2013e005bd lib: Break long line in definition of guestfs_set_error_handler.
This is just a whitespace change.
2012-11-09 19:50:57 +00:00
Richard W.M. Jones
692701f382 examples: Copy-editing instructions printed by the mount-local program. 2012-11-09 19:50:57 +00:00
Richard W.M. Jones
dedf10aaa9 header: Define LIBGUESTFS_HAVE_CREATE_FLAGS=1.
This fixes commit 9466060201.
2012-11-09 17:15:50 +01: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
e8d937bd73 lib: When parsing environment, handle LIBGUESTFS_TRACE first.
So that we can trace all the later calls.
2012-11-09 13:09:04 +00:00
Richard W.M. Jones
ebe5ca7771 Version 1.19.57. 2012-11-07 20:29:59 +00:00
Richard W.M. Jones
101fd44fc5 format: Allow virt-format test to be skipped by setting SKIP_TEST_VIRT_FORMAT_SH=1. 2012-11-06 13:05:49 +00:00
John Eckersberg
3b06bee2fb lib: debian support for package arch inspection 2012-11-05 16:20:26 +00:00
Richard W.M. Jones
6ac943fbef tests: wipefs: Don't try to wipe mounted filesystem.
Previously wipefs (the utility) allowed this, but it's obviously a bad
thing to do and the new wipefs gives an error if you try it:

wipefs: error: /dev/VG/LV: probing initialization failed: Device or resource busy
2012-11-03 10:16:01 +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
6c539fa0a6 Version 1.19.56. 2012-11-02 14:45:11 +00:00
Richard W.M. Jones
9a1a0c67ac generator: Split up huge src/actions.c into separate files.
Split the functions according to a simple hash across
C.nr_actions_files files (this number can be increased later if
necessary).

This is just code motion.
2012-11-02 14:38:03 +00:00
Richard W.M. Jones
58720cc968 generator: actions: Move variant functions to a separate file.
This is just code motion.
2012-11-02 14:36:36 +00:00
Richard W.M. Jones
6f34b81321 generator: actions: Move 3 helper functions to a separate file.
This is just code motion.
2012-11-02 14:36:31 +00:00
Richard W.M. Jones
f56bc8edd5 New API: mklost_and_found 2012-11-02 14:35:41 +00:00
Richard W.M. Jones
4cfc277674 todo: General updates. 2012-11-02 14:09:28 +00:00
Richard W.M. Jones
f39478424f ROADMAP: Remove some completed items. 2012-11-02 14:09:28 +00:00
Richard W.M. Jones
226457de3d sysprep: Don't fail when trying to remove /var/spool/at/spool (directory).
This fixes commit 1949016e89.
2012-11-01 19:31:17 +00:00
John Eckersberg
dd9bbeb060 inspect: Use new inspect_list_applications2 API call
RWMJ:
 - Update virt-inspector.rng.
2012-11-01 18:22:08 +00:00
John Eckersberg
bafd822914 lib: Add inspect_list_applications2 method (RHBZ#859949)
RWMJ:
- Fix memory leak in guestfs__inspect_list_applications wrapper.
- Don't document app2_spare* fields.
2012-11-01 18:22:01 +00:00
Hilko Bengen
4c285dd8f6 message catalogs don't need to be executable 2012-11-01 12:25:56 +00:00
Richard W.M. Jones
6871400223 Version 1.19.55. 2012-10-30 14:35:25 +00:00
Richard W.M. Jones
de129a1363 build: Source 'localenv' in top-level Makefile.
Also document 'local*' files.
2012-10-30 13:19:53 +00:00
Richard W.M. Jones
f5194e6b0a tests: Allow more tests to be skipped.
Specifically tests which involve btrfs, because btrfs is
currently broken upstream (RHBZ#863978).
2012-10-30 12:56:06 +00:00
Richard W.M. Jones
eb185eef29 generator: Use an OCaml struct to store the structs.
This just makes it simpler to add extra fields to each struct.

This is code motion.
2012-10-30 12:32:30 +00:00
Richard W.M. Jones
72e19deee7 lib: Force visibility default on public actions.
This is currently done implicitly because of the linker script.
However in order to do symbol versioning, we will have to do
this explicitly at each definition instead.
2012-10-30 10:32:57 +00:00
Richard W.M. Jones
8c66ba455d generator: Move struct-freeing functions to a separate source file.
This is just code motion.
2012-10-30 10:32:57 +00:00
Richard W.M. Jones
ccf5c6ae56 sysprep: Move a comment.
No change.
2012-10-30 08:31:38 +00:00
Wanlong Gao
f491f3a958 sysprep: remove man pages cache
Remove the cache files generated by man-db.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-10-30 07:59:49 +00:00
Wanlong Gao
3884bc7d7a sysprep: remove fontconfig cache
Remove the cache files generated by fontconfig.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-10-30 07:59:49 +00:00
John Eckersberg
63a091e21d lib: update inspect_list_applications to return all installed RPMs (RHBZ#859885).
Note that because of RHBZ#859949, this will return two identical
entries for RPMs which differ only by arch.
2012-10-29 21:56:45 +00:00
Richard W.M. Jones
269460770d build: Remove 'make bindist' rule.
We've not distributed binaries for quite a long time, and possibly
this is not advisable.
2012-10-29 15:40:33 +00:00
Richard W.M. Jones
e6f8a589ee Version 1.19.54. 2012-10-29 15:22:23 +00:00
Richard W.M. Jones
dd09744432 guestfs-testing: Use L<> around links. 2012-10-29 15:12:54 +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
3c1d85ae95 docs: Review and clarify ERROR HANDLING section of guestfs(3). 2012-10-25 22:23:49 +01:00
Richard W.M. Jones
7271c9146d launch: libvirt: Disable CPU host-model.
See the comment in the change.

This "fixes" commit f7a67914c0.
2012-10-25 16:16:17 +01:00
Richard W.M. Jones
835ae2c43c gitignore: Ignore config.cache file. 2012-10-25 14:23:00 +01:00
Richard W.M. Jones
f7a67914c0 launch: libvirt: Fix <cpu> element.
Use <cpu mode="host-model"> (not model=... which was a typo).

Also set fallback=allow so that libvirt knows it can use another
CPU model if it wants.

This fixes commit 890a4fbc87.
2012-10-25 14:13:42 +01:00
Richard W.M. Jones
5c8f073786 daemon: Mark some functions as attribute((noreturn)). 2012-10-25 14:13:42 +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
a66fd2fac2 resize: Depend explicitly on Unix module.
Commit a0722c7ad8 introduced a
dependency on the Unix module.  This was not listed in the list of
'-package's, but as long as you had ocaml-gettext installed it would
still work because that pulled in Unix implicitly.

Thanks Olaf Hering.
2012-10-22 12:20:27 +01:00
Richard W.M. Jones
6e63636869 Version 1.19.53. 2012-10-19 11:08:08 +01:00
Richard W.M. Jones
0e0bea70dd filearch: Use command mini-library to run external cpio command. 2012-10-18 22:12:28 +01:00
Richard W.M. Jones
af5ec9381e fuse: Use command mini-library to run the fusermount command. 2012-10-18 22:11:54 +01:00
Richard W.M. Jones
95b83ef9d4 info: Use command mini-library to run 'qemu-img info' commands. 2012-10-18 22:11:53 +01:00
Richard W.M. Jones
a3598aa257 inspect: Use command mini-library to parse the output of db_dump command. 2012-10-18 22:11:53 +01:00
Richard W.M. Jones
019b840e47 inspect: Change icon code to use command mini-lib instead of system(3). 2012-10-18 22:11:53 +01:00
Richard W.M. Jones
7917e55ddb launch: libvirt: Use command mini-library to run qemu-img create command. 2012-10-18 22:11:53 +01:00
Richard W.M. Jones
a0ead23016 launch: appliance: Use command mini-library to parse output of qemu -help etc. 2012-10-18 22:11:52 +01:00
Richard W.M. Jones
8d4f3f85f2 appliance: Use command mini-library to run febootstrap-supermin-helper (RHBZ#713678) 2012-10-18 22:11:52 +01:00
Richard W.M. Jones
fa209341f8 lib: Change guestfs___remove_tmpdir function to use command mini-library. 2012-10-18 22:11:49 +01:00
Richard W.M. Jones
2e90f43129 lib: Add a new 'command' mini-library for running external commands.
This is a wrapper or mini-library for running external command,
loosely based on libvirt's virCommand interface.

Amongst the advantages are:

 - Can redirect errors into the error log (RHBZ#713678).
 - Can redirect output into a callback function.
 - Handles shell quoting properly.
 - Safely resets signal handlers, closes file descriptors, etc.
 - Single place where we can implement other improvements in future.
2012-10-18 21:52:08 +01:00
Richard W.M. Jones
2dab72794e valgrind: Add suppression for memory leak in libdl:_dl_init function. 2012-10-18 17:43:38 +01:00
Wanlong Gao
773fa61141 NEW API: mktemp
Used to create temporary directory or file with an optional suffix.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>

RWMJ:

 - Split this out into a new file (daemon/mktemp.c).

 - I don't see a reason to deprecate the mkdtemp function which
   works fine.  Instead remove complex dir-making code from the
   new function.

 - Test and fix the patch (missing close(fd)).
2012-10-17 11:12:07 +01:00
Richard W.M. Jones
67e483689c configure: Add db5.1_dump, db5.1_load for Debian Wheezy. 2012-10-17 10:31:54 +01:00
Wanlong Gao
978d16ec76 TODO: remove the already implemented yum cache clean feature
The cleanup of package managers cache is already implemented
by sprep_operation_package_manager_cache.ml, so remove this
TODO item.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-10-17 10:27:38 +01:00
Richard W.M. Jones
25ec619a46 todo: Implement Ruby blocking calls. 2012-10-16 09:12:18 +01:00
Richard W.M. Jones
99bd15ad0e generator: Add 'blocking' flag to marking blocking (long-running) functions.
In languages like Python where we release a global lock around
long-running libguestfs functions, it is also useful to *not* release
this lock for small, non-blocking functions.

Therefore mark all functions with a 'blocking' boolean flag.  It
defaults to true, and is true by definition for all daemon functions.
For non-daemon functions, I have classified them manually.

Only when the blocking flag is set do we generate the code to release
and reacquire the lock around libguestfs calls.
2012-10-15 22:38:27 +01:00
Richard W.M. Jones
3d46f7dc03 ocaml: Get rid of CAMLprim.
It's wrong to use it, and in any case it doesn't do anything on Linux.
2012-10-15 22:38:27 +01:00
Richard W.M. Jones
8a89c72821 Update release notes. 2012-10-15 18:04:54 +01:00
Richard W.M. Jones
c164cc9bea lib: Add a test for environment parsing functions.
This updates commit 9466060201.
2012-10-15 16:35:13 +01:00
Richard W.M. Jones
ec1d239872 lib: Fix guestfs_create_flags example program in man page.
This fixes commit 9466060201.
2012-10-15 16:34:23 +01:00
Richard W.M. Jones
a0722c7ad8 resize, sparsify: Suppress progress bar when output is not a tty. 2012-10-15 15:51:55 +01:00
Richard W.M. Jones
c9acb029ed sparsify: Fix dependencies so they include resize/progress.*
This fixes commit 91b2238fc8.
2012-10-15 15:51:21 +01:00
Richard W.M. Jones
471f4e64d3 libvirt: auth: Some clarifications of the API from Dan Berrange.
This updates commit d83d17e9db.
2012-10-15 15:44:15 +01:00
Richard W.M. Jones
9466060201 New APIs: guestfs_create_flags, guestfs_parse_environment,
guestfs_parse_environment_list.

Add a new function for creating a handle:

 guestfs_h *guestfs_create_flags (unsigned flags [, ...]);

This variant lets you supply flags and extra arguments, although extra
arguments are not used at the moment.

Of particular interest is the ability to separate the creation of the
handle from the parsing of environment variables like
LIBGUESTFS_DEBUG.  guestfs_create does both together, which prevents
us from propagating errors from parsing environment variables back to
the caller (guestfs_create has always printed any errors on stderr and
then just ignored them).

If you are interested in these errors, you can now write:

 g = guestfs_create_flags (GUESTFS_CREATE_NO_ENVIRONMENT);
 if (!g)
   exit (EXIT_FAILURE);
 r = guestfs_parse_environment (g);
 if (!r)
   exit (EXIT_FAILURE);

Also you can *omit* the call to guestfs_parse_environment, which
creates a handle unaffected by the environment (which was not possible
before).

This commit also includes new (backwards compatible) changes to the
OCaml, Perl, Python, Ruby and Java constructors that let you use the
flags.
2012-10-15 15:04:43 +01:00
Richard W.M. Jones
389cb608df ruby: Add RUBYLIB to run script. 2012-10-15 14:51:40 +01:00
Richard W.M. Jones
f65c9bfcf2 Version 1.19.52. 2012-10-14 13:39:18 +01:00
Richard W.M. Jones
1c1630bb23 Update PO files from Transifex.
Also run 'make update-po'.
2012-10-14 13:39:08 +01:00
Richard W.M. Jones
c36456cf03 Update API support. 2012-10-14 13:23:00 +01:00
Richard W.M. Jones
626ca8e74f valgrind: Fix FUSE memory leak suppression. 2012-10-14 12:54:02 +01:00
Richard W.M. Jones
d83d17e9db New APIs: Model libvirt authentication events through the API.
This commit models libvirt authentication events through the API,
adding one new event (GUESTFS_EVENT_LIBVIRT_AUTH) and several new
APIs:

  guestfs_set_libvirt_supported_credentials
  guestfs_get_libvirt_requested_credentials
  guestfs_get_libvirt_requested_credential_prompt
  guestfs_get_libvirt_requested_credential_challenge
  guestfs_get_libvirt_requested_credential_defresult
  guestfs_set_libvirt_requested_credential

See the documentation and example which shows how to use the new API.

This commit also changes existing calls to virConnectOpen* within the
library so that the new API is used.

Also included is an example (but not a test, because it's hard to see
how to automatically test the libvirt API).
2012-10-13 20:54:07 +01:00
Richard W.M. Jones
07d0546f5d configure: Add --without-libvirt option.
Normally we check if libvirt is installed, and the default is still to
do this.

However having this option makes it simpler to check if a change to
the code has broken the case where libvirt is not installed.

In fact, this change revealed one such place, which is also fixed in
this commit.
2012-10-13 20:52:31 +01:00
Richard W.M. Jones
085bf7c97a docs: Make 'EVENTS' into its own =head1 section.
For some reason it was stuck under "CALLS WITH OPTIONAL ARGUMENTS",
which made no sense.
2012-10-13 16:04:21 +01:00
Richard W.M. Jones
96a76c79e4 launch: libvirt: Make handle data conditional on HAVE_LIBVIRT.
This means that we can use virConnectPtr and virDomainPtr instead of
using void* types.  In the case where libvirt support is disabled or
not present, effectively nothing changes.
2012-10-13 16:04:21 +01:00
Richard W.M. Jones
325d67c615 lib: Rename src/libvirtdomain.c -> src/libvirt-domain.c.
No change, just code motion.
2012-10-13 16:04:18 +01:00
Richard W.M. Jones
64e8e0011c lib: Pointer arg to safe_memdup function should be const. 2012-10-13 15:35:47 +01:00
Richard W.M. Jones
bdfe221671 configure: Fix capitalization in configure script.
Just make the output of ./configure --help and the <config.h>
file consistent.
2012-10-12 22:03:11 +01:00
Richard W.M. Jones
467fb589b9 configure: Fix C++ compiler test so it doesn't print random junk. 2012-10-12 22:02:55 +01:00
Richard W.M. Jones
e6e999eac2 Version 1.19.51. 2012-10-11 17:12:51 +01:00
Richard W.M. Jones
15b9ed3ed2 daemon: Call udev-settle at the start of the daemon. 2012-10-11 17:12:21 +01:00
Richard W.M. Jones
67e9572286 launch: libvirt: Always set <qemu:env> TMPDIR.
If TMPDIR is not set, we must choose one, because otherwise libvirt
will use a random TMPDIR: http://bugzilla.redhat.com/865464

The convenient guestfs___persistent_tmpdir function does everything
needed in this case.
2012-10-11 15:50:41 +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
91b2238fc8 sparsify: Re-use progress bar wrapper code from virt-resize.
The code was identical -- just copied with s/resize/sparsify/.
Instead of duplicating identical code, cause the Makefile.am to use
the code from the ../resize/ directory.

Unfortunately because there are two Utils modules (which are
different), this means we had to rename those modules to Resize_utils
and Sparsify_utils respectively.  So this is a rather larger change
than intended.  However it's just code motion.
2012-10-11 13:37:35 +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
77ce157db8 Version 1.19.50. 2012-10-10 21:22:43 +00:00
Richard W.M. Jones
316c2a6fc7 docs: Fix documentation about hotplugging. 2012-10-10 21:11:17 +00:00
Richard W.M. Jones
2e388e8a37 launch: Add warning not to avoid calling launch twice on the same handle.
For more information on this topic, see:
https://www.redhat.com/archives/libguestfs/2012-October/msg00045.html
2012-10-10 21:05:52 +00:00
Richard W.M. Jones
7376811983 Revert "btrfs: Add a workaround for btrfs failures seen with kernel 3.7.0."
Revert "btrfs: Add an extended workaround for btrfs failures seen with kernel 3.7.0."

Reverted these workaround, since we may have found a fix for the btrfs
bug itself (for details see RHBZ#863978).

This reverts commit d9e5b514aa
and commit a03f536f0d.
2012-10-10 18:26:18 +01:00
Richard W.M. Jones
33f49d85c2 tests: Fix test-qemudie-* so they re-adds the disk on second launch.
Commit ed7fda161e changed the
way that the drives are handled across appliance shutdowns.

Previously during the following sequence of calls:

  create the handle
  add drive(s)
  launch
  kill subprocess
  launch

the added drives are still in the handle at the second launch.

After the above commit, the added drives are removed from the handle,
which means the second launch happens with no drives (which could be
an error).

This was never actually defined either way, so in this case fix the
test to re-add the drive before the second launch.

Since hotplugging was added, it isn't really feasible to return to the
original semantics, since users might remove drives, in which case we
have lost information about those drives so we cannot restore them on
the second launch.

NOTE: PLEASE CALLERS DON'T DO THIS!  Always use a new handle for each
launch of the appliance.
2012-10-10 16:46:35 +00:00
Richard W.M. Jones
a03f536f0d btrfs: Add an extended workaround for btrfs failures seen with kernel 3.7.0.
See:
https://bugzilla.redhat.com/show_bug.cgi?id=863978
and:
http://thread.gmane.org/gmane.comp.file-systems.btrfs/20257

This extends the fix in commit d9e5b514aa
because I missed the case where mkfs.btrfs is called directly.
2012-10-10 11:15:39 +01:00
Richard W.M. Jones
0032c60336 docs: Fully document all subdirectories of the source. 2012-10-09 21:58:21 +01:00
Richard W.M. Jones
b54fa22cd0 docs: Add overview to guestfs(3)/EXTENDING LIBGUESTFS. 2012-10-09 21:57:54 +01:00
Richard W.M. Jones
e10647e334 appliance: Add 99-guestfs-serial.rules to EXTRA_DIST.
This fixes commit 7786d56db8.
2012-10-09 12:06:03 +01:00
Richard W.M. Jones
e4bca563b4 Version 1.19.49. 2012-10-09 11:21:17 +01:00
Richard W.M. Jones
d9e5b514aa btrfs: Add a workaround for btrfs failures seen with kernel 3.7.0.
See:
https://bugzilla.redhat.com/show_bug.cgi?id=863978
and:
http://thread.gmane.org/gmane.comp.file-systems.btrfs/20257
2012-10-09 11:09:17 +01:00
Olaf Hering
45c9fbd6f5 launch: appliance is optional
# virt-filesystems -v -d 6326ad4e-5805-2ab4-1338-d1dad8c76162 --all
libguestfs: libvirt version = 10002
libguestfs: [00000ms] connect to libvirt
libguestfs: [00001ms] get libvirt capabilities
libguestfs: [00234ms] build appliance
libguestfs: [00234ms] create libvirt XML
libguestfs: error: error constructing libvirt XML at "xmlTextWriterWriteAttribute (xo, BAD_CAST "file", BAD_CAST appliance)": No such file or directory
libguestfs: closing guestfs handle 0x656270 (state 0)

 # ls -lh /usr/lib64/guestfs/*
-rw-r--r-- 1 root root  13M Oct  8 16:15 /usr/lib64/guestfs/initramfs.x86_64.img
-rw-r--r-- 1 root root 3.7M Oct  6 09:25 /usr/lib64/guestfs/vmlinuz.x86_64

Signed-off-by: Olaf Hering <olaf@aepfle.de>
2012-10-09 09:45:42 +01:00
Richard W.M. Jones
0a85fbc946 Add support for hotplugging (removing disks).
New API: remove-drive.

Note because of a bug in fuser, this only works with psmisc >= 22.20.

This also updates the hotplugging tests.
2012-10-09 09:45:42 +01: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
7786d56db8 launch: Add add_drive 'label' option.
New API: list-disk-labels

Allow the user to pass an optional disk label when adding a drive.

This is passed through to qemu / libvirt using the disk serial field,
and from there to the appliance which exposes it through udev,
creating a special alias of the device /dev/disk/guestfs/<label>.
Partitions are named /dev/disk/guestfs/<label><partnum>.

virtio-blk and virtio-scsi limit the serial field to 20 bytes.  We
further limit the name to maximum 20 ASCII characters in [a-zA-Z].

list-devices and list-partitions are not changed: these calls still
return raw block device names.  However a new call, list-disk-labels,
returns a hash table allowing callers to map between disk labels, and
block device and partition names.

This commit also includes a test.
2012-10-08 20:04:47 +01:00
Richard W.M. Jones
3ad44c8660 launch: libvirt: Create qcow2 overlays for read-only drives and the appliance.
Instead of adding the snapshot=on option via <qemu:arg>, create qcow2
overlays for any read-only drives and the appliance using 'qemu-img
create' + a temporary file.

This is a workaround for missing support for <transient/> in libvirt's
qemu driver.  Also for the unpredictable way that libvirtd handles
$TMPDIR: we want to control where the temporary disk is created.

Currently it is also much slower, because qemu-img is slow.  However
we hope to fix qemu upstream.
2012-10-08 14:41:20 +01:00
Richard W.M. Jones
ed7fda161e launch: Make g->drives into an array (was a linked list).
Using an array simplifies the implementation of hotplugging.
2012-10-08 14:38:50 +01:00
Richard W.M. Jones
8354dc46fd Version 1.19.48.
We need to regenerate the tarball because the previous one
had the guestfsd man page missing.  Hence bumped version
number.
2012-10-07 11:58:36 +01:00
Richard W.M. Jones
62e56876c8 daemon: Add guestfsd.pod to EXTRA_DIST.
This fixes commit df2469a48f.
2012-10-07 11:55:01 +01:00
Richard W.M. Jones
63eae6fa6f Version 1.19.47. 2012-10-06 23:35:14 +01:00
Richard W.M. Jones
9f24ac2db0 launch: Add private data pointer to the struct drive.
This can be used by the attach-method, eg. for libvirt-only data.
2012-10-06 23:19:21 +01:00
Richard W.M. Jones
6867b0a3fb launch: add_null_drive: Force null drive to be writable.
Because we create a special file, there is no point forcing qemu
to create an overlay as well.  Save time by setting readonly = 0.
2012-10-06 23:19:20 +01:00
Richard W.M. Jones
328510121a launch: Rearrange code for adding drives to the g->drives list in the handle.
This is just code motion.
2012-10-06 23:15:49 +01:00
Richard W.M. Jones
92feed7d66 build: Use 'tmp-d' as name of temporary directory instead of 'tmp'.
When building supermin.d/daemon.img, use 'tmp-d' instead of 'tmp'
as the name of the temporary directory.

This is just code motion.
2012-10-06 23:15:49 +01:00
Richard W.M. Jones
1467ea00b8 docs: add_drive: Clean up documentation of the 'filename' parameter.
Also, remove duplicate documentation of using '/dev/null' as the
filename.
2012-10-06 23:15:48 +01:00
Richard W.M. Jones
013fb91a69 tests: Fix rhbz690819.sh to skip when attach-method is libvirt.
This sets the iface parameter (implicitly), which is not supported yet
by the libvirt backend.

This updates commit 8e198dc1c5.
2012-10-06 23:15:48 +01:00
Richard W.M. Jones
9bd3d5bc6d FAQ: Document debug* and internal* functions in the FAQ. 2012-10-06 17:42:05 +01:00
Richard W.M. Jones
8e198dc1c5 launch: libvirt: The drive 'iface' parameter is not yet supported.
We could add support, but at the moment return an error
if the user tries to use the iface parameter.
2012-10-03 11:15:30 +01:00
Richard W.M. Jones
60650da1ed docs: Minor cleanup of documentation for add_drive 'name' parameter. 2012-10-03 11:15:30 +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
df2469a48f docs: Add guestfsd(8) man page. 2012-10-03 08:55:24 +01:00
Richard W.M. Jones
378e5d6722 Version 1.19.46. 2012-10-01 13:36:43 +01:00
Richard W.M. Jones
572291c64e configure: Rearrange build options report in ./configure output.
This had accreted over a long period of time, so it wasn't
arranged very logically.
2012-10-01 13:36:42 +01:00
Richard W.M. Jones
6f53d49a27 daemon: When sorting devices, don't fail on mix of /dev/sd and /dev/vd
(RHBZ#858128).

If compare_device_names was given two devices with devices with
different interfaces (eg. /dev/sda and /dev/vda) then it would try to
compare the partition numbers, and fail when it could parse them.

It's arguable what we should be doing in this case (except for
strongly discouraging people from using the interface feature), but
let's at least not cause the daemon to assert-fail.

Found by Red Hat QA, thanks Mohua Li.
2012-09-28 15:09:51 +01:00
Richard W.M. Jones
9ea6e97014 inspection: Fix calls to case_sensitive_path (RHBZ#858126).
Don't assume that if guestfs_case_sensitive_path returns NULL, that it
means the file does not exist.

The (previously undefined) behaviour of case_sensitive_path was that a
NULL return meant "either the file doesn't exist or some other error".
However in commit 973581780d this was
changed so that if the last element of the path didn't exist, it was
assumed to be a new file and the (non-NULL) path of the new file is
returned.

This change breaks code (including in libguestfs) which tries to use
case_sensitive_path as a dual-purpose call to fix-up a path for
Windows and test if the file exists.  Such code should be rewritten so
that it explicitly tests for file existence after calling
case_sensitive_path.

I examined all the calls to case_sensitive_path in libguestfs and
modified them where necessary.
2012-09-28 15:09:50 +01:00
Richard W.M. Jones
55b7c4df78 virt-edit: If case_sensitive_path returns an error, exit.
The 'windows_path' function was blindly copied from virt-cat.  In
virt-cat, errors are checked by the caller to 'windows_path'.  But
virt-edit lacks this check.  Change the function in virt-edit to add a
check and exit on error.
2012-09-28 15:09:50 +01:00
Richard W.M. Jones
6cd040fcdf Version 1.19.45. 2012-09-26 21:21:02 +01:00
Richard W.M. Jones
8d63edaa93 sysprep: Typo in man page: resets -> reset. 2012-09-26 21:16:14 +01:00
Richard W.M. Jones
91617069b9 run: Label tmp directory.
There's not really any point just documenting that people
should label the tmp directory, when we can just label it.
So change the ./run script so it calls chcon.

However it's not a failure if chcon doesn't work.  If SELinux
is not installed or is disabled, then labelling will fail.
2012-09-26 21:03:37 +01:00
Richard W.M. Jones
f7e138835a recipes: Add a section about diagnosing hanging guests. 2012-09-26 20:56:44 +01:00
Richard W.M. Jones
4f3048c6be test-tool: Add prominent warning about including complete output.
Everyone ignores the documentation.  Everyone ignores me even
when I specifically tell them to include the complete output.

Place a prominent notice at the beginning of the output.
2012-09-26 12:26:33 +01:00
Richard W.M. Jones
ca2e65275d test-tool: guestfs_get_path might return NULL.
It would almost certainly indicate a bug if it happens, but
don't rely on printf not segfaulting if it did happen.
2012-09-26 12:26:28 +01:00
Richard W.M. Jones
b44d82ec8d Revert "test-launch-race: Add SELinux label to $TMPDIR."
Because RHBZ#860235 has been fixed in selinux-policy 3.11.1-25.fc18.

This reverts commit 7fc838cca3.
2012-09-26 12:04:02 +01:00
Richard W.M. Jones
9b7813c5bd guestfs-testing(1): Start by running libguestfs-test-tool. 2012-09-26 12:03:16 +01:00
Wanlong Gao
f7f746a98e remove the useless "h" option
"h" option is not enabled in virt-cat, remove it.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-09-26 10:26:01 +01:00
Richard W.M. Jones
19b29c3637 FAQ: Miscellaneous cleanups.
- Use S<...> for non-breaking spaces.
- Arrange the builds section better.
- Add a section on enabling sVirt.
- Other small fixes.
2012-09-25 19:00:50 +01:00
Richard W.M. Jones
d19e557df5 docs: Link to guestfs-recipes(1) from intro in guestfs(3). 2012-09-25 18:30:36 +01:00
Richard W.M. Jones
a8056050c0 gobject: No need to remove old API files.
In commit 3d84ca76fe we changed the
generator so it now automatically removes old API files.
2012-09-25 14:26:38 +01:00
Richard W.M. Jones
7fc838cca3 test-launch-race: Add SELinux label to $TMPDIR.
This is a temporary workaround for
https://bugzilla.redhat.com/show_bug.cgi?id=860235
which can be removed once this bug is fixed.
2012-09-25 12:16:25 +01:00
Richard W.M. Jones
b3bf53714b libvirt >= 0.10.2 required for libvirt backend. 2012-09-24 21:25:31 +01:00
Richard W.M. Jones
c9cccb776e Version 1.19.44. 2012-09-24 17:00:03 +01:00
Wanlong Gao
45d459f402 Fix tests/bigdirs/test-big-dirs.pl to use mke2fs
Let tests/bigdirs/test-big-dirs.pl uses mke2fs to create small
inode ratio files.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>

RWMJ:
 - Fix invocation of mke2fs with optional arguments.
 - Run the test to check it works.
2012-09-24 16:41:07 +01:00
Wanlong Gao
0c2aab966a NEW API:ext:mke2fs
New api mke2fs for full configuration of filesystem.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>

RWMJ:
 - Update description.
 - Run and fix the tests.
 - Remove bogus filename from po/POTFILES.
2012-09-24 16:40:46 +01:00
Richard W.M. Jones
a297a9348f tests/bigdirs: Add empty TESTS= rule.
Without this empty rule, automake doesn't generate the rest of the
testing infrastructure, so you can't enable the test yourself by doing
'make check TESTS=test-big-dirs.pl'.
2012-09-24 16:40:46 +01:00
Richard W.M. Jones
790c1a0c7b generator: xdr: Re-code procedure table.
This is just code motion.
2012-09-24 09:46:24 +01:00
Richard W.M. Jones
db6a851240 generator: Tidy up comments in guestfs_protocol.x. 2012-09-24 09:46:14 +01:00
Richard W.M. Jones
a95d4261b8 generator: Allow an optional emacs-mode at the top of generated files. 2012-09-24 09:34:37 +01:00
Richard W.M. Jones
a3d7f5bc17 generator: The default input files are 'generator/ *.ml' [sic].
Since generator source files were renamed, the comment at the
top of each generated file was wrong.

Unfortunately we cannot allow /* to appear within a comment,
so the space is necessary.
2012-09-24 09:34:33 +01:00
Olaf Hering
1949016e89 sysprep: handle at jobs in cron-spool operation
cron-spool claims to remove at jobs, but it has no code to actually do
that. Add patterns to remove files in known at spool locations.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
2012-09-22 12:58:13 +01:00
Olaf Hering
55fef0e4e6 sysprep: handle distro specific sysv scripts
Currently firstboot would only work on redhat-based images.
Handle redhat-based, suse-based and debian guests, error out in case of an
unknown distro.
Update firstboot.sh:
 - make sure scripts exists and can be executed
 - add LSB header to avoid insserv warnings later on
 - run script only if called with "start"
Update functions, pass only required options.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
2012-09-22 12:58:08 +01:00
Richard W.M. Jones
09c372ea25 test-launch-race: Add comment. 2012-09-22 10:47:11 +01:00
Richard W.M. Jones
ab0610d752 Version 1.19.43. 2012-09-21 16:31:05 +01:00
Olaf Hering
0e7d3de002 sysprep: handle suse-based in hostname operation
Signed-off-by: Olaf Hering <olaf@aepfle.de>
2012-09-21 14:09:10 +01:00
Richard W.M. Jones
1b364d74a8 launch: Handle guestfs_config qemu_value == NULL.
The second parameter to 'config' may be NULL.

In commit 52fa23d74f (refactoring of
guestfs_config) the code this got lost, and guestfs_config would
segfault if qemu_value was NULL.

Also this fixes the libvirt method to handle the same case.

I checked libguestfs-1.18 and -1.16 branches, and this problem does
NOT affect them.
2012-09-21 12:57:11 +01:00
Olaf Hering
763ec36cf0 Update SuSE Linux detection.
Update SuSE Linux detection. Up to now everything with a
/etc/SuSE-release file was treated as openSuSE. With this change SLES
based distributions such as "SUSE Linux Enterprise Server", "SUSE
Linux Enterprise Desktop" and "Novell Linux Desktop" will show up as
"sles". The 'opensuse' detection was updated to handle older openSuSE
releases as well as the well known SuSE Linux releases, starting from
6.0. Everything else with a /etc/SuSE-release file will show up as
"suse-based".

Here is a collection of release files:

==> Dist/6.0/etc/SuSE-release <==
SuSE Linux 6.0 (i386)
VERSION = 6.0

==> Dist/6.1/etc/SuSE-release <==
SuSE Linux 6.1 (i386)
VERSION = 6.1

==> Dist/6.2/etc/SuSE-release <==
SuSE Linux 6.2 (i386)
VERSION = 6.2

==> Dist/6.3/etc/SuSE-release <==
SuSE Linux 6.3 (i386)
VERSION = 6.3

==> Dist/6.4/etc/SuSE-release <==
SuSE Linux 6.4 (i386)
VERSION = 6.4

==> Dist/7.0/etc/SuSE-release <==
SuSE Linux 7.0 (i386)
VERSION = 7.0

==> Dist/7.1/etc/SuSE-release <==
SuSE Linux 7.1 (i386)
VERSION = 7.1

==> Dist/7.2/etc/SuSE-release <==
SuSE Linux 7.2 (i386)
VERSION = 7.2

==> Dist/7.3/etc/SuSE-release <==
SuSE Linux 7.3 (i386)
VERSION = 7.3

==> Dist/8.0/etc/SuSE-release <==
SuSE Linux 8.0 (i386)
VERSION = 8.0

==> Dist/8.1/etc/SuSE-release <==
SuSE Linux 8.1 (i386)
VERSION = 8.1

==> Dist/8.2/etc/SuSE-release <==
SuSE Linux 8.2 (x86-64)
VERSION = 8.2

==> Dist/9.0/etc/SuSE-release <==
SuSE Linux 9.0 (x86-64)
VERSION = 9.0

==> Dist/9.1/etc/SuSE-release <==
SuSE Linux 9.1 (x86-64)
VERSION = 9.1

==> Dist/9.2/etc/SuSE-release <==
SuSE Linux 9.2 (x86-64)
VERSION = 9.2

==> Dist/9.3/etc/SuSE-release <==
SuSE Linux 9.3 (x86-64)
VERSION = 9.3

==> Dist/10.0/etc/SuSE-release <==
SUSE LINUX 10.0 (X86-64) OSS
VERSION = 10.0

==> Dist/10.1-remastered/etc/SuSE-release <==
SUSE LINUX 10.1 (X86-64)
VERSION = 10.1

==> Dist/10.1/etc/SuSE-release <==
SUSE Linux 10.1 (X86-64) Beta8
VERSION = 10.1

==> Dist/10.2/etc/SuSE-release <==
openSUSE 10.2 (X86-64)
VERSION = 10.2

==> Dist/10.3/etc/SuSE-release <==
openSUSE 10.3 (X86-64)
VERSION = 10.3

==> Dist/11.0/etc/SuSE-release <==
openSUSE 11.0 (X86-64)
VERSION = 11.0

==> Dist/11.1/etc/SuSE-release <==
openSUSE 11.1 (x86_64)
VERSION = 11.1

==> Dist/11.2/etc/SuSE-release <==
openSUSE 11.2 (x86_64)
VERSION = 11.2

==> Dist/11.3/etc/SuSE-release <==
openSUSE 11.3 (x86_64)
VERSION = 11.3

==> Dist/11.4/etc/SuSE-release <==
openSUSE 11.4 (x86_64)
VERSION = 11.4
CODENAME = Celadon

==> Dist/12.1/etc/SuSE-release <==
openSUSE 12.1 (x86_64)
VERSION = 12.1
CODENAME = Asparagus

==> Dist/12.2/etc/SuSE-release <==
openSUSE 12.2 (x86_64)
VERSION = 12.2
CODENAME = Mantis

==> Dist/sles8/etc/SuSE-release <==
SuSE SLES-8 (AMD64)
VERSION = 8.1

==> Dist/sles9/etc/SuSE-release <==
SUSE LINUX Enterprise Server 9 (x86_64)
VERSION = 9

==> Dist/sles9sp2/etc/SuSE-release <==
SUSE LINUX Enterprise Server 9 (x86_64)
VERSION = 9
PATCHLEVEL = 2

==> Dist/sles9sp3/etc/SuSE-release <==
SUSE LINUX Enterprise Server 9 (x86_64)
VERSION = 9
PATCHLEVEL = 3

==> Dist/sles9sp4/etc/SuSE-release <==
SUSE LINUX Enterprise Server 9 (x86_64)
VERSION = 9
PATCHLEVEL = 4
==> Dist/sled10/etc/SuSE-release <==
SUSE Linux Enterprise Desktop 10 (x86_64)
VERSION = 10

==> Dist/sled10sp1/etc/SuSE-release <==
SUSE Linux Enterprise Desktop 10 (x86_64)
VERSION = 10
PATCHLEVEL = 1

==> Dist/sled10sp2/etc/SuSE-release <==
SUSE Linux Enterprise Desktop 10 (x86_64)
VERSION = 10
PATCHLEVEL = 2

==> Dist/sled10sp3/etc/SuSE-release <==
SUSE Linux Enterprise Desktop 10 (x86_64)
VERSION = 10
PATCHLEVEL = 3

==> Dist/sled10sp4/etc/SuSE-release <==
SUSE Linux Enterprise Desktop 10 (x86_64)
VERSION = 10
PATCHLEVEL = 4

==> Dist/sled11/etc/SuSE-release <==
SUSE Linux Enterprise Desktop 11 (x86_64)
VERSION = 11
PATCHLEVEL = 0

==> Dist/sled11sp1/etc/SuSE-release <==
SUSE Linux Enterprise Desktop 11 (x86_64)
VERSION = 11
PATCHLEVEL = 1

==> Dist/sled11sp2/etc/SuSE-release <==
SUSE Linux Enterprise Desktop 11 (x86_64)
VERSION = 11
PATCHLEVEL = 2

==> Dist/sles10/etc/SuSE-release <==
SUSE Linux Enterprise Server 10 (x86_64)
VERSION = 10

==> Dist/sles10sp1/etc/SuSE-release <==
SUSE Linux Enterprise Server 10 (x86_64)
VERSION = 10
PATCHLEVEL = 1

==> Dist/sles10sp2/etc/SuSE-release <==
SUSE Linux Enterprise Server 10 (x86_64)
VERSION = 10
PATCHLEVEL = 2

==> Dist/sles10sp3/etc/SuSE-release <==
SUSE Linux Enterprise Server 10 (x86_64)
VERSION = 10
PATCHLEVEL = 3

==> Dist/sles10sp4/etc/SuSE-release <==
SUSE Linux Enterprise Server 10 (x86_64)
VERSION = 10
PATCHLEVEL = 4

==> Dist/sles11/etc/SuSE-release <==
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 0

==> Dist/sles11sp1/etc/SuSE-release <==
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 1

==> Dist/sles11sp2/etc/SuSE-release <==
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 2

Signed-off-by: Olaf Hering <olaf@aepfle.de>
2012-09-21 11:43:48 +01:00
Hilko Bengen
71f87d9a8f ./run: Keep gnome-keyring from disturbing test script output 2012-09-20 21:12:38 +01:00
Hilko Bengen
e5d01c21d7 ./run: Make sure that the temporary directory exists so test scripts can produce output files 2012-09-20 21:12:38 +01:00
Hilko Bengen
e482f2faf0 python: PyInt_* no longer exists in python3, replace with PyLong_* 2012-09-20 21:12:38 +01:00
Olaf Hering
b36b44af9e rename local variable to avoid clash with match macro
match will expand to guestfs___match, rename the local variable to avoid clash.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
2012-09-20 21:08:22 +01:00
Richard W.M. Jones
64cc0dafd0 docs: Add links to various guestfs-* man pages from guestfs(3). 2012-09-20 17:56:40 +01:00
Richard W.M. Jones
8aa8eb205b recipes: Add section about uploading raw filesystem content. 2012-09-20 17:56:10 +01:00
Richard W.M. Jones
840deea120 launch: Make the "launched failed" message more explanatory.
Since this is the most common error seen by people who have
installation problems, buggy qemu, etc, and since no one reads the
FAQ, describe in this error message what resources are available to
debug launch problems.
2012-09-20 11:41:16 +01:00
Olaf Hering
181de70feb sysprep: handle SuSE in random-seed operation
Signed-off-by: Olaf Hering <olaf@aepfle.de>
2012-09-19 21:05:29 +01:00
Olaf Hering
d6c11b0a3d sysprep: add zypper to package-manager-cache operation
libzypp and zypper store their cache files in
/var/cache/zypp/{packages,raw,solv}/ and /var/cache/zypper/RPMS/
Add a single pattern to match both cases.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
2012-09-19 21:05:29 +01:00
Olaf Hering
245608a735 sysprep: remove apache2, audit and ntp in logfile operation
Add more entries to the dump ground of logfile patterns.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
2012-09-19 21:05:29 +01:00
Olaf Hering
ae0f60744b sysprep: handle SuSE in hostname operation
SuSE based installations store the hostname in /etc/HOSTNAME.
Add code to handle both opensuse and sles. Code to properly detect
the latter will be added with another patch.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
2012-09-19 18:18:29 +01:00
Richard W.M. Jones
88c406feba sysprep: Create /etc/sysconfig/network file if it doesn't exist (RHBZ#858696). 2012-09-19 17:34:58 +01:00
Richard W.M. Jones
aeb2f76a58 extra-tests: Re-run the tests against upstream libvirt. 2012-09-18 12:52:37 +01:00
Richard W.M. Jones
157b5006db extra-tests: Clean up some comments about the upstream qemu tests. 2012-09-18 12:48:36 +01:00
Richard W.M. Jones
7e4b197cb6 extra-tests: Add scripts used by these tests to EXTRA_DIST. 2012-09-18 12:47:50 +01:00
Richard W.M. Jones
e4ef926d6f Version 1.19.42. 2012-09-17 23:06:44 +01:00
Richard W.M. Jones
a3ce000599 tmp: Ignore libguestfsXXXXXX temporary files in tmp dir. 2012-09-17 22:52:53 +01:00
Richard W.M. Jones
5479b8db58 ./run: Write temporary file in tmp directory.
We have a new 'tmp' directory under the top level dir for temporary
files.  Use it for the temporary output from the ./run script.
2012-09-17 22:52:40 +01:00
Richard W.M. Jones
f9f0767e20 launch: libvirt: Pass TMPDIR to qemu subprocess. 2012-09-17 16:34:59 +01:00
Richard W.M. Jones
a2dc3dbad0 New API: rm-f: remove a file, ignoring errors if it doesn't exist. 2012-09-17 16:25:53 +01:00
Richard W.M. Jones
74283d58cf inspect: Fix segfault and error caused by earlier code cleanups.
This fixes commit e128a627fb.
2012-09-17 14:50:31 +01:00
Richard W.M. Jones
2e17d78178 launch: libvirt: Disable sVirt if using a custom qemu (ie. setting <emulator>).
See:
https://bugzilla.redhat.com/show_bug.cgi?id=857659
especially Dan's comment 4.
2012-09-17 13:45:19 +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
c387b69cba daemon: stubs: Move all arg decls to top of function.
For some reason, argument declarations were handled
inconsistently for strings and non-string arguments.
Non-string arguments were all declared at the top of the
function stub, where as string arguments were declared
in place.

Be consistent.

This is just code motion.
2012-09-17 13:32:49 +01:00
Jim Meyering
176bd182d3 maint: remove a subsumed syntax-check rule
* cfg.mk (sc_prohibit_trailing_blank_lines): Remove rule.  It is now
subsumed by the much more efficient sc_prohibit_empty_lines_at_EOF
rule in gnulib's maint.mk.
2012-09-17 11:05:34 +01:00
Richard W.M. Jones
3988dec9b7 syntax: Exclude examples and test program from <config.h> requirement
(thanks Jim Meyering).
2012-09-17 10:15:43 +01:00
Richard W.M. Jones
72ab351ace syntax: Allow strncpy in launch-*.c files (thanks Jim Meyering).
We use strncpy, justifiably, to copy the socket name into
the fixed length Unix domain sun_path buffer.
2012-09-17 10:13:16 +01:00
Richard W.M. Jones
369709177e syntax: Exclude examples from strcmp and strncmp checks (thanks Jim Meyering). 2012-09-17 10:11:13 +01:00
Richard W.M. Jones
552576c7f9 syntax: Ignore documentation when testing for magic number exit() calls (thanks Jim Meyering). 2012-09-17 10:07:32 +01:00
Richard W.M. Jones
2100ba14fb syntax: Exclude PO files from doubled words test (thanks Jim Meyering). 2012-09-17 10:07:31 +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
2337b9ccd7 syntax: Exclude period in error message checks from PHP programs (thanks: Jim Meyering). 2012-09-17 10:07:31 +01:00
Richard W.M. Jones
fbdcfe2b77 syntax: Disable cast arg to free test (thanks Jim Meyering). 2012-09-17 10:07:31 +01:00
Richard W.M. Jones
b95fff1357 syntax: Exclude certain files from bindtextdomain test (thanks Jim Meyering). 2012-09-17 10:07:31 +01:00
Richard W.M. Jones
e942c02a2e Update to latest gnulib. 2012-09-17 10:07:27 +01:00
Richard W.M. Jones
946ae89a78 Version 1.19.41. 2012-09-16 13:35:07 +01:00
Richard W.M. Jones
e6bd0b87eb extra-tests: Write a qemu wrapper script on the fly.
Passing the $upstream_qemu environment variable is not reliable when
libvirt is involved: Environment variables are passed to the first
instance of the session libvirtd, but because libvirt reuses the
session libvirtd, subsequent environment variable settings are lost
(this is filed as RHBZ#856619).

Bypass all of this by writing a custom qemu-wrapper.sh which contains
the hard-coded values we want.
2012-09-15 17:36:15 +01:00
Richard W.M. Jones
2fd51c28fd extra-tests: Rerun extra tests with regular appliance attach method.
If libvirt is being used as the backend, rerun all the extra-tests
again using the regular appliance backend.
2012-09-15 14:41:06 +01:00
Richard W.M. Jones
509dd90c43 extra-tests: The upstream qemu test now reruns all the extra tests. 2012-09-15 14:41:06 +01:00
Richard W.M. Jones
eeb0c598ec extra-tests: Fix libvirt URI so we can run tests with libvirt attach-method. 2012-09-15 14:41:06 +01:00
Richard W.M. Jones
2cac8d490e syntax: Remove trailing whitespace.
Found by 'make syntax-check'.
2012-09-15 13:36:02 +01:00
Richard W.M. Jones
44a11e955b generator: Remove inaccurate comment.
The correct way to extend functions is documented in generator/README.
This comment was no longer accurate.
2012-09-15 13:27:50 +01:00
Richard W.M. Jones
6361810b53 syntax: Replace test == with = or -eq as appropriate.
Found by 'make syntax-check'.
2012-09-15 13:21:55 +01:00
Richard W.M. Jones
d26f402361 syntax: xfs: Rewrite split_strdup function to avoid use of strncpy.
Found by 'make syntax-check'.
2012-09-15 13:19:12 +01:00
Richard W.M. Jones
b0cefb417d syntax: Use STREQ/STRNEQ in place of strcmp.
Found by 'make syntax-check'.
2012-09-15 13:11:45 +01:00
Richard W.M. Jones
90b7c53b70 syntax: Remove include <signal.h> in file that doesn't use it.
Found by 'make syntax-check'.
2012-09-15 13:08:08 +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
a67129b0fb syntax: Remove gnulib "ignore-value.h" in files that don't use it.
Found by 'make syntax-check'.
2012-09-15 12:38:07 +01:00
Richard W.M. Jones
d6bb49a172 syntax: Remove include <dirent.h> in files that don't use it.
Found by 'make syntax-check'.
2012-09-15 12:35:59 +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
da75618fb2 lib: Rearrange headers.
This is just code motion.
2012-09-15 12:31:07 +01:00
Richard W.M. Jones
8747ff7432 lib: Remove unused headers <arpa/inet.h> and <netinet/in.h>
These were used back in the day when we used TCP for the
communications channel with the guest.
2012-09-15 12:30:12 +01:00
Richard W.M. Jones
dec73f70fc syntax: Remove HAVE_*_H tests which are always true.
Gnulib supplies replacements for these headers, so there
is no need to test.
2012-09-15 12:25:28 +01:00
Richard W.M. Jones
cd8976a5b5 perl: Add <stdio.h> and <stdlib.h> for printf and malloc. 2012-09-15 12:22:44 +01:00
Richard W.M. Jones
188b44ee45 perl: Include <inttypes.h> and assume it always defines PRId64 and PRIu64.
If these are not defined in the header files, it's a problem on
the platform which we should fix with gnulib.  Our replacement
definitions might be wrong here.
2012-09-15 12:22:00 +01:00
Richard W.M. Jones
5a46eadd3d lib: These optargs structures are not modified, hence const. 2012-09-15 12:15:47 +01:00
Richard W.M. Jones
ae137124ca syntax: Remove test for TAB indentation.
Nothing particularly wrong with using TABs for indentation,
and this test also has a lot of false positives.
2012-09-15 11:54:17 +01:00
Richard W.M. Jones
57d089fd6d syntax: xfs: Remove useless if before free.
Found by running 'make syntax-check'.
2012-09-15 11:54:03 +01:00
Richard W.M. Jones
6951becfdb docs: Fix documentation of syntax-check target, add extra-tests. 2012-09-15 11:54:03 +01:00
Richard W.M. Jones
244e9a2ac4 faq: Make the legal section less unnecessarily legalistic. 2012-09-14 23:06:16 +01:00
Richard W.M. Jones
19da851610 faq: Tidy up headings. 2012-09-14 23:06:13 +01:00
Richard W.M. Jones
2c59af7754 faq: Add more answers about read-only disks. 2012-09-14 22:57:02 +01:00
Richard W.M. Jones
6575ac4c61 launch: libvirt: Enable sVirt. 2012-09-14 16:46:37 +01:00
Richard W.M. Jones
5b02c8d0bc test-9p: Disable this test with libvirt.
This test doesn't work with sVirt if SELinux is enforcing, because
qemu won't be able to access the 9p-exported directory on the host.
2012-09-14 16:46:37 +01:00
Richard W.M. Jones
834747a85d build: Create new 'tmp' directory for tests.
Having a separate directory means:

(1) It's easy to clean up orphaned temporary files, the appliance,
    etc.

(2) You can put an SELinux label on this directory so that qemu can
    write to it when you're using sVirt and SELinux is enforcing:

    chcon --reference=/tmp tmp
2012-09-14 15:53:53 +01:00
Richard W.M. Jones
aa9e0057b1 launch: libvirt: Mark appliance disk as <shareable/> (thanks Dan Berrange).
This is a fix for multiprogramming: If two instances of libguestfs
share the same appliance disk, then libvirt would unlabel the disk
when one of the instances closes the handle, resulting in the other
qemu being unable to continue accessing the appliance.

Adding the flag makes libvirt understand that the disk is shared so it
doesn't do this, and it apparently handles locking correctly too if we
were using sanlock.
2012-09-14 15:52:42 +01:00
Richard W.M. Jones
281b155800 test-tool: Print more environment variables.
This prints LIBVIRT_*, LIBVIRTD_*, LD_* and PATH, since these are all
useful for debugging and could affect libguestfs in some way.
2012-09-14 11:35:23 +01:00
Richard W.M. Jones
8acdc23622 fish: Replace '_' with '-' in deprecation cross-refs (thanks Olaf Hering). 2012-09-13 19:32:47 +01:00
Richard W.M. Jones
d9a98dc1cd lib: guestfs_disk_format: Set LC_ALL=C instead of LANG=C.
LC_ALL takes precedence over LANG.  See:

http://pubs.opengroup.org/onlinepubs/7908799/xbd/envvar.html
2012-09-12 21:40:03 +01:00
Richard W.M. Jones
97a1439d90 release-notes: Add 'draft' background image. 2012-09-06 12:46:57 +01:00
Richard W.M. Jones
81c682f129 extra-tests: Don't use $QEMU as a variable.
Since 'QEMU' is set (overwritten) by the autoconf-generated Makefile,
this test would always test installed qemu, not upstream qemu,
making it pretty useless.  Use another name for this variable.
2012-09-05 13:56:34 +01:00
Richard W.M. Jones
3d84ca76fe generator: Remove generated and unused files from previous runs of the generator.
If you go back in time in git (eg. git reset, git bisect) then you can
end up in a situation where a file that was generated by a later
version is left around unused in the earlier version.

This isn't a problem for most things, but gobject documentation
generation picks up any file in a directory, even unreferenced ones,
and breaks.  So the correct thing to do is to remove these files.
2012-09-05 11:45:41 +01:00
Richard W.M. Jones
169ac913e9 generator: gobject: Use a more normal way to output files.
The generator output is identical, verified by comparing the
output files before and after the change.
2012-09-05 11:26:52 +01:00
Richard W.M. Jones
dc8aca2cf9 Version 1.19.40. 2012-09-04 23:16:47 +01:00
Richard W.M. Jones
9c4097dfd8 sparsify: Fix use of closed handle (thanks Olaf Hering).
This fixes commit faaedeb343.

Also contains an update to the test which tests the format
auto-detect path.
2012-09-04 22:29:48 +01:00
Olaf Hering
bdb5689f58 fix fuse_opt_add_opt_escaped return type
I: Program returns random data in a function
E: libguestfs no-return-in-nonvoid-function guestmount.c:75

The function fuse_opt_add_opt_escaped has only one caller and a return
code is not checked.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
2012-09-04 17:26:04 +01:00
Richard W.M. Jones
853feb971f Version 1.19.39. 2012-09-04 17:10:23 +01:00
Richard W.M. Jones
c4171ad58f shutdown: Add 'check_for_errors' hint along the shutdown path.
This hint tells the backend whether anyone cares about errors when the
appliance is shut down.

Currently this only has any effect on the libvirt backend, where it
controls whether or not we use the VIR_DOMAIN_DESTROY_GRACEFUL flag.
2012-09-04 15:36:29 +01:00
Richard W.M. Jones
cc4b3139d1 launch: libvirt: Add VIR_DOMAIN_DESTROY_GRACEFUL flag.
We want libvirt to report failures when destroying the guest.  See:

https://bugzilla.redhat.com/show_bug.cgi?id=853369#c12
2012-09-04 15:36:06 +01:00
Richard W.M. Jones
05beac65e5 rescue: Add an expect-driven test for the virt-rescue command.
This command was not tested at all.  As a result we didn't notice that
it was broken for a long time (RHBZ#853159).

This adds a test that drives the command through a pty.  It uses the
perl 'Expect' module, although this is not required.
2012-09-04 14:43:26 +01:00
Richard W.M. Jones
8248a346d7 proto: Don't set g->fd[] to /dev/null in direct mode, fixing virt-rescue (RHBZ#853159).
https://bugzilla.redhat.com/show_bug.cgi?id=853159

git bisect pointed to the following commit:

  commit ec8e3b6cad
  Author: Richard W.M. Jones <rjones@redhat.com>
  Date:   Fri Jul 20 14:24:10 2012 +0100

    launch: Abstract attach method operations.

    g->attach_ops points to a structure which contains the
    operations supported by each attach method backend
    (ie. appliance, unix, etc.).

Since that commit was essentially just code motion, it wasn't clear
why virt-rescue should be affected by it.

In fact the reason is as follows:

(1) In direct mode, we don't need g->fd[] (which would normally be
connected to the stdin/stdout of qemu).  So we opened them on
/dev/null so they had some value.

(2) accept_from_daemon / read_log_message_or_eof reads from g->fd[1].
Since this is connected to /dev/null, it always reads EOF.

(3) This would cause child_cleanup to be called.  This is completely
unintentional: we don't want to cleanup the child at this point, even
in direct mode.

(4) Prior to the commit above, child_cleanup first waited for the
process to exit (ie. waitpid).  This happened to work, since we are
effectively waiting for the user to exit virt-rescue.

(5) After the commit above, the order of operations was changed so
that we first killed qemu before waiting for it.  This broke
virt-rescue.

The fix is to change direct mode so that it leaves g->fd[]'s as -1.
The rest of the protocol code can deal with this situation -- it
ignores the log fd instead of trying to read from it.
2012-09-04 14:43:26 +01:00
Richard W.M. Jones
2e36adf83c rescue: If attach-method is 'libvirt', force it to be 'appliance'.
The libvirt backend currently doesn't support direct mode.  We should
make that work in future.  As a workaround, force the attach-method to
be 'appliance' in this case.
2012-09-04 12:04:31 +01:00
Richard W.M. Jones
6fdf1f40fa rescue: If -v / debugging enabled, don't mask error messages.
We set the error handler to NULL in order to mask "normal" error
messages that we expect to see because of the unusual way that
virt-rescue runs the appliance.  However if the user selected -v /
enabled debugging, then it is reasonable to expect they want to see
every message, so do not mask anything.
2012-09-04 11:56:20 +01:00
Richard W.M. Jones
77f70a5f7c launch: libvirt: Direct mode flag is not (yet) supported, so give an error in this case.
We definitely intend to support this in future.
2012-09-04 11:55:35 +01:00
Richard W.M. Jones
381c067d54 Update release notes (text file).
This updates commit 9e4ac650e4.
2012-09-04 11:55:35 +01:00
Richard W.M. Jones
9e4ac650e4 Update release notes. 2012-09-04 11:31:28 +01:00
Richard W.M. Jones
d03361b1af lib: Add tests to the disk-{format,virtual-size,has-backing-file} APIs. 2012-09-04 10:02:57 +01:00
Richard W.M. Jones
4ed981bd5f New APIs: disk-virtual-size and disk-has-backing-file. 2012-09-04 10:02:53 +01:00
Richard W.M. Jones
e388c4f3fd lib: Reimplement qemu-img info parser for flexibility.
This allows other fields from the output of 'qemu-img info'
to be parsed out.

This updates commit 20902e7ce0.
2012-09-04 09:41:29 +01:00
Richard W.M. Jones
1030e8aba0 Fix guestfs_disk_image API to work with relative paths.
guestfs_disk_image makes a symbolic link to the real filename in order
to sanitize the filename.  However this fails if the filename is a
relative path.  Call realpath(3) to make the filename canonical.

This fixes commit 20902e7ce0.
2012-09-04 09:41:26 +01:00
Richard W.M. Jones
26732678c6 Version 1.19.38. 2012-09-03 18:35:17 +01:00
Olaf Hering
47ddb77fb1 daemon: provide list of checksum commands
While adding the list of external commands I missed the
various checksum tools.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
2012-09-03 17:45:14 +01:00
Richard W.M. Jones
faaedeb343 sparsify: Use guestfs_disk_format to autodetect input format (RHBZ#853762). 2012-09-03 17:45:14 +01:00
Richard W.M. Jones
9f8ba4e8d1 launch: libvirt: Use guestfs_disk_format API to autodetect input format. 2012-09-03 17:45:14 +01:00
Richard W.M. Jones
efdc2bae40 guestfs(3): Document disk image formats and how to detect them. 2012-09-03 17:45:10 +01:00
Richard W.M. Jones
20902e7ce0 New API: guestfs_disk_format
Detect the disk image format of a file, in a secure way.
2012-09-03 17:43:19 +01:00
Olaf Hering
b6413f8dbe daemon: remove call to obsolete udevsettle
udevadm is included in all reasonable recent distributions.
This avoids 'command not found' errors in verbose mode.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
2012-09-03 11:02:05 +01:00
Wanlong Gao
c659cf8ea6 TODO: remove the implemented hostname removing feature
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-09-03 10:32:18 +01:00
Wanlong Gao
98bf41d80d sysprep: remove hostname from ifcfg-*
Remove hostname from network interface configuration.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-09-03 09:39:48 +01:00
Richard W.M. Jones
3820a2578c generator: Test zero args, one optarg; and 63 optargs.
This just generates the code; it's not called.
2012-09-03 09:36:04 +01:00
Richard W.M. Jones
f65dee769d java: Fix >= 32 optargs (thanks Wanlong Gao). 2012-09-03 09:36:04 +01:00
Richard W.M. Jones
d331fd70e2 generator: Rename 'generator_*' as '*'.
This is a simple renaming of the files/modules.

Note that in OCaml, module names are derived from filenames by
capitalizing the first letter.  Thus the old module names had the form
"Generator_api_versions".  The new modules names have the form
"Api_versions".
2012-09-02 19:47:33 +01:00
Richard W.M. Jones
11d655ab83 TODO: Suggest removing hostname from ifcfg-eth* files. 2012-09-02 19:47:33 +01:00
Richard W.M. Jones
b799bc58a8 recipes: Checksum file/device. Download to stdout. 2012-09-02 16:33:59 +01:00
Richard W.M. Jones
a1d981edea tests: Attach copyright and license (GPLv2+) notices to various test scripts.
For some reason these tests did not have license notices.
2012-08-31 19:12:27 +01:00
Richard W.M. Jones
d754f4a5a3 tests/rsync: Allow rsync test to be skipped by setting SKIP_TEST_RSYNC_SH=1. 2012-08-31 19:06:38 +01:00
Richard W.M. Jones
42b892a8c5 Version 1.19.37. 2012-08-31 18:34:24 +01:00
Richard W.M. Jones
3ed3e23ed0 Copy the kernel so that libvirt can add an SELinux label to it. NB. This requires febootstrap >= 3.20 with --copy-kernel flag. 2012-08-31 16:17:24 +01:00
Richard W.M. Jones
3728c122f1 guestfs-internal.h: Organize functions by file.
This is almost just code motion.  While doing this I discovered two
prototypes for functions which no longer exist:

  * guestfs___launch_appliance
  * guestfs___launch_unix

so these prototypes have been removed.  The rest are rearranged more
logically.
2012-08-31 15:14:51 +01:00
Richard W.M. Jones
b17d189616 tests: Make mkswap and tar tests conditional on linuxfsuuid and xz features. 2012-08-31 14:31:22 +01:00
Richard W.M. Jones
87cb154976 tests/mount-local: Link test program with gnulib. 2012-08-31 10:26:40 +01:00
Richard W.M. Jones
4e6bf1ed65 src/dbdump.c: Shouldn't depend on HAVE_HIVEX (thanks Tao Zhou). 2012-08-31 09:53:44 +01:00
Olaf Hering
0306c98d31 daemon: collect list of called external commands
guestfsd calls many different tools. Keeping track of all of them is
error prone. This patch introduces a new helper macro to put the command
string into its own ELF section:

GUESTFSD_EXT_CMD(C_variable, command_name);

This syntax makes it still possible to grep for used command names.

The actual usage of the collected list could be like this:

  objcopy -j .guestfsd_ext_cmds -O binary daemon/guestfsd /dev/stdout |
  tr '\0' '\n' | sort -u

The resulting output will be used to tell mkinitrd which programs to
copy into the initrd.

Signed-off-by: Olaf Hering <olaf@aepfle.de>

RWMJ:
 - Move str_vgchange at request of author.
 - Fix snprintf call in daemon/debug.c
2012-08-30 20:57:07 +01:00
Richard W.M. Jones
4aa1464d42 launch: appliance: app.virtio_scsi must not be bool.
This is used to store values 0..3, so it mustn't be a bool.  Ooops.

RHEL 5's gcc revealed this bug.
2012-08-30 20:09:16 +01:00
Richard W.M. Jones
163e030ee1 daemon: Remove e2prog hack (only needed for RHEL 5).
Instead this patch will be carried out of tree in the oldlinux branch.
2012-08-30 17:29:36 +01:00
Richard W.M. Jones
0573c19950 Version 1.19.36. 2012-08-30 16:39:48 +01:00
Richard W.M. Jones
c945609ac9 launch: libvirt: Remove code for creating sockdir.
Create the sockets in g->tmpdir as usual.  It's a bug in libvirt that
it doesn't label the sockets correctly no matter where they are
located.
2012-08-30 15:35:16 +01:00
Richard W.M. Jones
a7de51b3c8 launch: libvirt: Avoid memory leak if sockdir is not created (found by valgrind). 2012-08-30 15:28:19 +01:00
Richard W.M. Jones
8af32b9d5f FAQ: Remove link to old RHEL 6.3 preview repo. 2012-08-30 13:29:49 +01:00
Wanlong Gao
7036a3bccf NEW API:xfs:xfs_repair
Add a new api xfs_repair for repairing an XFS filesystem.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>

RWMJ:
  - Fix non-error return path so it doesn't send two replies.
  - Document return code.
2012-08-30 10:47:26 +01:00
Richard W.M. Jones
bcbad66b18 docs: Add guestfs-release-notes.txt to Makefile deps. 2012-08-30 10:47:26 +01:00
Richard W.M. Jones
2d6bf3ba70 tests/big-dirs: Don't run this test by default. 2012-08-30 08:58:00 +01:00
Richard W.M. Jones
8742713050 run: Make --test flag print the time taken to run the test.
This is useful because it lets us see which tests take
the longest.
2012-08-29 20:59:06 +01:00
Richard W.M. Jones
1ac36e4f36 Version 1.19.35. 2012-08-29 19:00:02 +01:00
Richard W.M. Jones
9ef22fa921 python: Convert OInt64 using PyLong_AsLongLong so 64 bit ints work correctly.
This avoids the following error on 32 bit machines:

  OverflowError: Python int too large to convert to C long
2012-08-29 18:36:17 +01:00
Richard W.M. Jones
b2378a81bb Update inspection and example programs to use new hivex* APIs (RHBZ#852394).
I tested this by comparing the output of virt-inspector over Windows
guests before and after the change, which was identical:

$ md5sum `ls -1 /tmp/*.before /tmp/*.after`
c292d6629b5a761eccb4a279754399b4  /tmp/Win2003.after
c292d6629b5a761eccb4a279754399b4  /tmp/Win2003.before
eb1e1ff29208a9ee46e9c100dfec26b2  /tmp/Win2012.after
eb1e1ff29208a9ee46e9c100dfec26b2  /tmp/Win2012.before
d060a95d7ffe5dce6c4e66feb80c2837  /tmp/Win7x32.after
d060a95d7ffe5dce6c4e66feb80c2837  /tmp/Win7x32.before
8914eee70ac4f8a0317659e09e00dcdc  /tmp/Win7x32Dynamic.after
8914eee70ac4f8a0317659e09e00dcdc  /tmp/Win7x32Dynamic.before
a2dcdfc0f9d64054640875aa791889e0  /tmp/Win7x32TwoDisks.after
a2dcdfc0f9d64054640875aa791889e0  /tmp/Win7x32TwoDisks.before
5ed49568a5147dce7517c99de41ebf2e  /tmp/Win8previewx64.after
5ed49568a5147dce7517c99de41ebf2e  /tmp/Win8previewx64.before
fdfc7d272b79a665ae3313ae1ae30660  /tmp/WinXP.after
fdfc7d272b79a665ae3313ae1ae30660  /tmp/WinXP.before
3c705444be664f1316b21c5d8d3cb0be  /tmp/WinXPRecConsole.after
3c705444be664f1316b21c5d8d3cb0be  /tmp/WinXPRecConsole.before
2012-08-29 17:08:01 +01:00
Richard W.M. Jones
288cc74d77 New API: guestfs_hivex_value_utf8
A convenience function that reads a value from the registry
and returns it as UTF-8.
2012-08-29 17:08:01 +01:00
Richard W.M. Jones
8a723ca62e New APIs: hivex_*
Transscribe many hivex(3) APIs into the libguestfs API.

There is one hive handle per libguestfs handle, as with Augeas.

Note that hivex uses iconv_open for some APIs (eg. hivex_value_string).
But since we delete all the i18n files from the appliance, this
doesn't work -- iconv_open returns EINVAL.  Therefore hivex APIs which
require iconv cannot be bound in the daemon.
2012-08-29 17:08:01 +01:00
Richard W.M. Jones
228d49bb84 lib: Remove AUGEAS_CFLAGS, AUGEAS_LIBS.
The library doesn't actually use libaugeas, except indirectly via the
libguestfs API.  The libguestfs API implements this in the daemon, so
there's no need for the library to link to augeas at all.
2012-08-29 17:08:01 +01:00
Olaf Hering
044c5b26d7 remove ulockmgr from fuse LDFLAGS
libguestfs fails to build with --enable-fuse on openSuSE 11.4 and
earlier because the included fuse version does not include
libulockmgr.so. configure already used pkgconfig to retrieve the correct
CFLAGS, so there is no need to hardcode -lulockmgr.
With this change the build succeeds again.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
2012-08-29 16:42:51 +01:00
Richard W.M. Jones
684efb3706 java: Further java/java-home fixes.
In particular the JVM executable is now called $JAVA_EXE.

This fixes commit 40b9c14ca9.
2012-08-29 14:24:37 +01:00
Richard W.M. Jones
15cd9dde5e perl: bindtests: Fix 64 bit integers on input on 32 bit Perl interpreter. 2012-08-29 05:33:09 -04:00
Wulf C. Krueger
40b9c14ca9 Fix Java detection and rename --with-java-home to --with-java.
Without this patch, if JAVAC points to a valid executable, --with-java-home=no
is not respected but the build simply fails.
Furthermore, --with{,out}-java is a more common form and more in-line with all
other options.
2012-08-28 13:24:35 -04:00
Richard W.M. Jones
9ef36632ca launch: libvirt: Don't crash if shutdown_libvirt is called early in launch.
The assert (conn != NULL) was being triggered with this
stack trace:

    at launch-libvirt.c:1305
    fd=<optimized out>, error_if_eof=error_if_eof@entry=0) at proto.c:222
    size_rtn=size_rtn@entry=0x7fffffffdb34,
    buf_rtn=buf_rtn@entry=0x7fffffffdb58) at proto.c:548
    libvirt_uri=<optimized out>) at launch-libvirt.c:391
2012-08-28 17:49:46 +01:00
Wulf C. Krueger
cab48ce73c Fix disabling the Perl bindings.
--disable-perl isn't currently respected because $PERL correctly points
to the perl executable and $missing_perl_modules doesn't prevent the
perl parts to be installed either. Thus, a check for $enable_perl is
needed.
2012-08-28 10:20:47 -04:00
Richard W.M. Jones
81709b5b70 Version 1.19.34. 2012-08-28 13:31:09 +01:00
Richard W.M. Jones
512f21c965 po-docs: Copy all *.1 and *.3 files to the install dir. 2012-08-28 13:18:47 +01:00
Richard W.M. Jones
67a803e1f2 po-docs: Update the list of man pages. 2012-08-28 13:18:47 +01:00
Richard W.M. Jones
ddc67d94f3 po-docs: Fix podwrapper so it works on translated POD files.
These don't contain literal strings like "AUTHORS" (they have the
translated versions instead) and so checking for these English strings
is rather useless.

Also we don't usually have the '--license' parameter conveniently
around so don't enforce this section.
2012-08-28 13:18:47 +01:00
Richard W.M. Jones
540fbfcf34 po-docs: Don't output translated virt-sysprep page as HTML. 2012-08-28 13:18:47 +01:00
Richard W.M. Jones
23b7fe09e1 tools: Fix podwrapper errors in tools directory.
This also makes the test for license "code" less strict, so it should
only match POD, not Perl comments.

This fixes commit 2f97bf873b.
2012-08-28 13:18:40 +01:00
Masami HIRATA
0a275bd090 Mac OS X: Fixed combination of running autogen.sh on Linux and building on Mac OS X
Signed-off-by: Masami HIRATA <msmhrt@gmail.com>
2012-08-28 05:10:15 -04:00
Richard W.M. Jones
d555a68ca6 podwrapper: Ignore $parser->html_charset if it fails (thanks Wulf C. Krueger).
This method was added in Pod::Simple 3.16 so earlier versions of Perl
won't have it.  It's not the end of the world if we don't set it.
2012-08-28 04:46:04 -04:00
Richard W.M. Jones
f23a5c468e Modified API: mkswap now takes optional arguments.
Add optional label and uuid arguments, and deprecate mkswap-L and
mkswap-U.

This also adds a call to udev_settle after creating the swap device.
This is an attempt to workaround the following problem seen in Koji
and Rawhide:

libguestfs: trace: mkswap_L "swapit" "/dev/sda1"
libguestfs: send_to_daemon: 72 bytes: 00 00 00 44 | 20 00 f5 f5 | 00 00 00 04 | 00 00 00 83 | 00 00 00 00 | ...
guestfsd: main_loop: proc 210 (part_disk) took 2.28 seconds
guestfsd: main_loop: new request, len 0x44
mkswap -f -L swapit /dev/sda1
libguestfs: recv_from_daemon: 40 bytes: 20 00 f5 f5 | 00 00 00 04 | 00 00 00 83 | 00 00 00 01 | 00 12 37 cf | ...
libguestfs: trace: mkswap_L = 0
libguestfs: trace: swapon_label "swapit"
libguestfs: send_to_daemon: 56 bytes: 00 00 00 34 | 20 00 f5 f5 | 00 00 00 04 | 00 00 00 ae | 00 00 00 00 | ...
guestfsd: main_loop: proc 131 (mkswap_L) took 0.77 seconds
guestfsd: main_loop: new request, len 0x34
swapon -L swapit
swapon: cannot find the device for swapit
guestfsd: error: swapit: swapon: cannot find the device for swapit
libguestfs: recv_from_daemon: 100 bytes: 20 00 f5 f5 | 00 00 00 04 | 00 00 00 ae | 00 00 00 01 | 00 12 37 d0 | ...
libguestfs: trace: swapon_label = -1 (error)
swapon_label: swapit: swapon: cannot find the device for swapit
test_swapon_label_0 FAILED
2012-08-28 04:44:05 -04:00
Richard W.M. Jones
c2ac512f12 docs: Revise README file. 2012-08-25 17:28:37 -04:00
Masami HIRATA
670e4f7f12 python: Fixed syntax errors in python/guestfs-py.c
Signed-off-by: Masami HIRATA <msmhrt@gmail.com>
2012-08-25 10:56:13 -04:00
Richard W.M. Jones
c638e1f03d docs: Use man page name as default title in HTML output. 2012-08-21 22:02:21 +01:00
Richard W.M. Jones
52a60349ab release-notes: Add more visible separation between sections in the source file. 2012-08-21 21:12:47 +01:00
Richard W.M. Jones
20ba04d83e Update release notes. 2012-08-21 20:53:09 +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
e89e180d2b podwrapper: Ensure the input file is printed in some error messages. 2012-08-21 20:11:15 +01:00
Richard W.M. Jones
e1e8b3a1cf docs: Document null disks.
It's always been possible to use /dev/null as a disk image.
Document this formally in the API.
2012-08-21 17:44:42 +01:00
Richard W.M. Jones
e3bb1f7c92 launch: libvirt: Always create /var/run/libguestfs.
This directory won't necessarily exist (esp. if /var/run is
really /run).  So create it each time.
2012-08-21 16:50:08 +01:00
Richard W.M. Jones
dcd35cb55c Version 1.19.33. 2012-08-21 13:56:18 +01:00
Richard W.M. Jones
984044043d FAQ: Re-add #backup anchor for section on backups. 2012-08-21 13:21:55 +01:00
Richard W.M. Jones
52e38c7bdc recipes: Update dumping filesystem content to mention that we now support MD/RAID. 2012-08-21 13:19:50 +01:00
Richard W.M. Jones
1e4c6e36a6 recipes: Refer to virt-format, virt-make-fs for creating disk images. 2012-08-21 13:19:50 +01:00
Richard W.M. Jones
5f234548ed recipes: Cloning Windows: plans for virt-sysprep. 2012-08-21 13:19:50 +01:00
Richard W.M. Jones
9fd4d16819 recipes: For auditing for setuid files, point to virt-ls examples. 2012-08-21 13:19:50 +01:00
Richard W.M. Jones
0d2e70b1c7 recipes: For sparsifying guests, point to virt-sparsify. 2012-08-21 13:19:50 +01:00
Richard W.M. Jones
d944a491ac recipes: For listing files, point to virt-ls. 2012-08-21 13:19:50 +01:00
Richard W.M. Jones
ad6870102f recipes: Mention virt-sysprep firstboot feature. 2012-08-21 13:19:50 +01:00
Richard W.M. Jones
87cf749cde recipes: Most guests now use grub2, so change the example. 2012-08-21 13:19:50 +01:00
Richard W.M. Jones
10d48bef30 recipes: Add a section on deleting a file and other common file operations. 2012-08-21 13:19:47 +01:00
Richard W.M. Jones
1454751b73 recipes: Update cloning section. 2012-08-21 13:13:41 +01:00
Richard W.M. Jones
9f59d11625 launch: libvirt: Minimum libvirt version is now 0.10.0. 2012-08-21 12:29:25 +01:00
Wanlong Gao
faf548a4bd xfs_growfs: drop the unstructed output
Just drop the unstructed output since we can get the structed info
from xfs_info instead.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-08-21 10:19:01 +01:00
Wanlong Gao
11b78a7107 New API: xfs: xfs_admin
Add new api xfs_admin to change parameters of an XFS filesystem.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>

RWMJ:
 - Remove printuuid, printlabel, since they don't change any settings.
 - Adjusted the documentation.
 - Fix the tests.
2012-08-21 10:18:23 +01:00
Richard W.M. Jones
5e67277463 run: Disable 'memory optimizations' in glib programs, for valgrind (thanks Dan Berrange). 2012-08-20 16:46:09 +01:00
Richard W.M. Jones
cd1627e804 FAQ: virt-sparsify and raw sparse output. 2012-08-19 15:35:14 +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
781d72f558 Update API support. 2012-08-18 13:09:27 +01:00
Richard W.M. Jones
64098f18d0 Version 1.19.32. 2012-08-18 12:09:47 +01:00
Richard W.M. Jones
8f3c0fd98d sysprep: docs: virt-sysprep can now be used to customize a guest. 2012-08-18 11:47:23 +01:00
Richard W.M. Jones
99cfc1f36e sysprep: Add --firstboot functionality.
This allows you to add scripts that run in the context of
the guest the first time it boots.
2012-08-18 11:47:19 +01:00
Richard W.M. Jones
99759da25c docs: Rewrite section on protocol limits again.
This updates commit 92e241440d.
2012-08-17 17:30:48 +01:00
Richard W.M. Jones
92e241440d docs: Update documentation to reflect no 2/4 MB protocol limits. 2012-08-17 16:08:14 +01:00
Richard W.M. Jones
d6e1d82267 todo: Suggest full mke2fs API call. 2012-08-17 16:08:14 +01:00
Richard W.M. Jones
92a0ac5037 tests: Add a test for large directories.
This also tests the reimplemented APIs:
 - ls
 - lstatlist
 - lxattrlist
 - readlinklist
2012-08-17 16:08:14 +01:00
Richard W.M. Jones
07eb702163 New API: fill-dir: Fill a directory with files (for testing). 2012-08-17 16:08:14 +01:00
Richard W.M. Jones
6952505694 guestfs_readdir: Note that this suffers from protocol limits. 2012-08-17 16:08:14 +01:00
Richard W.M. Jones
a69f44f56f guestfs_ls: Reimplement to avoid protocol limits. 2012-08-17 16:08:13 +01:00
Richard W.M. Jones
1b4d8e2cca New API: ls0 - List files, separated by \0 characters.
This API is not especially useful on its own.  It will be used to
reimplement guestfs_ls to work without protocol limits.
2012-08-17 16:08:13 +01:00
Richard W.M. Jones
8ee5190768 guestfs_readlinklist: Reimplement to avoid protocol limits. 2012-08-17 16:08:13 +01:00
Richard W.M. Jones
dc66dd32c2 guestfs_lstatlist, guestfs_lxattrlist: Reimplement to avoid protocol limits.
Note that the code to do this was already in virt-ls, so this is
change is mostly just moving the code into the core library.
2012-08-17 16:08:13 +01:00
Richard W.M. Jones
118932fbea guestfs_write, guestfs_write_append: Reimplement to avoid protocol limits.
Note that we keep the old daemon calls, but rename them as
"internal_write" and "internal_write_append".  This lets us implement
the new library-side calls more efficiently in the common case when
the uploaded content is smaller than the message buffer.  In most
cases the new calls won't end up using a temporary file.
2012-08-17 16:08:13 +01:00
Richard W.M. Jones
735ce57cda guestfs_read_lines: Reimplement to avoid protocol limits.
This also makes a larger test suite for this command.
2012-08-17 16:08:13 +01:00
Richard W.M. Jones
96d3ac28d6 guestfs_read_file: Reimplement to avoid protocol limits. 2012-08-17 16:08:13 +01:00
Richard W.M. Jones
9d85eba3c3 guestfs_find: Reimplement to avoid protocol limits.
This also reimplements the virt-ls -R option to use the replacement
guestfs_find API, which is simpler (though actually less efficient).
2012-08-17 16:08:13 +01:00
Richard W.M. Jones
294bee38bc guestfs_cat: Reimplement to avoid protocol limits. 2012-08-17 16:08:13 +01:00
Richard W.M. Jones
50d904c018 generator: Fix error message in checks of proc_nr. 2012-08-17 13:00:13 +01:00
Richard W.M. Jones
0f33a1d90c sysprep: Improve error messages. 2012-08-16 18:21:07 +01:00
Richard W.M. Jones
6f5447abe3 Update TODO. 2012-08-16 18:21:07 +01:00
Richard W.M. Jones
e9ef74ebc2 Version 1.19.31. 2012-08-15 17:57:40 +01:00
Richard W.M. Jones
856e78a2ce subdir-rules.mk: Remove rules that recursively build src/ and daemon/.
These are unnecessary, and slow down the whole build.
2012-08-15 17:49:49 +01:00
Richard W.M. Jones
cc25afcc35 gobject: Disable bindtests.
- gint64 cannot be reliably sent.  It seems to try to convert it
  via a 32 bit int, and fails if it overflows.

- OStringList is not implemented yet.
2012-08-15 17:49:48 +01:00
Richard W.M. Jones
5abd7bfc4c launch: For /dev/null drives, create a temporary disk.
This is a workaround for a bug with virtio-scsi in qemu 1.2:
https://bugzilla.redhat.com/show_bug.cgi?id=847549
2012-08-15 17:49:48 +01:00
Richard W.M. Jones
7f9f281865 test-launch-race: Use /dev/null instead of hand-made zero-length file.
There seems to be no reason why creating a zero-length
file is necessary for this test.
2012-08-15 17:49:48 +01:00
Richard W.M. Jones
46cf4a7e87 launch: Move code to add a drive to the list to separate add_drive utility function.
This is just code motion / simplification.
2012-08-15 17:49:48 +01:00
Richard W.M. Jones
4b8ac43729 launch: Add utility function guestfs___lazy_make_tmpdir.
This lets us create g->tmpdir lazily earlier if needed.

This commit is just code motion.
2012-08-15 17:49:48 +01:00
Richard W.M. Jones
22607a97cd lib: Add 'g->unique' to handle, for making unique IDs. 2012-08-15 17:49:48 +01:00
Richard W.M. Jones
8fd6f1bebe inspect: Clarify comment about uniqueness of cache. 2012-08-15 17:49:48 +01:00
Richard W.M. Jones
ba61236d0d close: Check if g->tmpdir is non-NULL before removing tmpdir.
This happens, by chance, to work.
2012-08-15 17:49:48 +01:00
Richard W.M. Jones
16f22d89eb bindtests: Test sending min and max 64 bit integers. 2012-08-15 17:49:48 +01:00
Richard W.M. Jones
704e46af9c java: Fix bindtests when passing 64 bit integer literals. 2012-08-15 17:49:48 +01:00
Richard W.M. Jones
9526f632d8 ocaml: Fix bindtests when passing negative optional arguments. 2012-08-15 17:49:48 +01:00
Richard W.M. Jones
f6de298d04 erlang: Add tests.
Add bindtests and general tests for Erlang.
2012-08-15 17:49:48 +01:00
Richard W.M. Jones
bd35b3c055 erlang: Fix 64 bit integers in parameters. 2012-08-15 17:49:48 +01:00
Richard W.M. Jones
e3f356bda1 erlang: Fix BufferIn parameters.
These would break if the buffer contained a \0 character.
2012-08-15 17:49:48 +01:00
Richard W.M. Jones
fad0f53dc8 New internal APIs: internal-test-set-output, internal-test-close-output.
These internal (testing) APIs allow the bindtests output to
be sent to some other place than stdout.

This is necessary for Erlang, since stdout is used to communicate with
the Erlang interpreter.
2012-08-15 17:49:48 +01:00
Richard W.M. Jones
7dd2389359 python: Fix comment referring to Perl(!) 2012-08-15 17:49:48 +01:00
Richard W.M. Jones
449bd4b50f generator: Allow permission of output files to be specified. 2012-08-15 17:49:48 +01:00
Hilko Bengen
3234a1f903 Even on Debian, the package containing the diff binary it has been diffutils for two years.
There had been a virtual package "diff" that depended on diffutils, but that's gone in wheezy/sid, too.
2012-08-15 13:34:54 +02:00
Richard W.M. Jones
42e8c093b7 python: Fix optargs so we don't use special sentinel values.
Previously with Python it was impossible to set a boolean or integer
optarg to -1 because that was used as a special sentinel value to
indicate that the optarg was not set.

Instead, use None as the sentinel value, since that cannot be a
boolean or integer type.
2012-08-15 12:16:54 +01:00
Richard W.M. Jones
e990e80c26 python: Before freeing OStringList, cast it to char ** to avoid a compiler warning.
This fixes commit c1a269513c.
2012-08-15 12:14:06 +01:00
Richard W.M. Jones
94f133f25b Remove unnecessary comment from <guestfs.h>.
Read guestfs(3) for documentation, and don't discourage people from
doing that by putting these comments into the header file.
2012-08-14 18:21:05 +01:00
Richard W.M. Jones
5ea795aa48 docs: Fix '= head' -> '=head' in back compat entries in guestfs(3). 2012-08-14 18:17:40 +01:00
Richard W.M. Jones
f5208ab865 Version 1.19.30. 2012-08-14 17:51:24 +01:00
Richard W.M. Jones
ce35eb90a2 tar-out: Add list of excluded patterns (--exclude=...) (RHBZ#847881). 2012-08-14 16:40:14 +01:00
Richard W.M. Jones
c1a269513c generator: Add new OStringList optional arg type.
This allows lists of strings to be passed as an optional argument.
2012-08-14 16:40:11 +01:00
Richard W.M. Jones
637b06ab13 daemon: New utility functions 'join_strings', 'concat_strings'.
Useful functions for concatenating strings together.
2012-08-14 16:40:07 +01:00
Richard W.M. Jones
690bdaa392 bindtests: Space before parens in call. 2012-08-14 11:14:10 +01:00
Richard W.M. Jones
d23293db7e todo: Suggestion: Add sh-in, sh-out, debug sh-in, debug sh-out. 2012-08-14 10:01:40 +01:00
Richard W.M. Jones
4dbae7cc06 tar-out: Add optional numericowner flag (RHBZ#847880).
This is equivalent to the tar option --numeric-owner.
2012-08-14 10:00:27 +01:00
Richard W.M. Jones
864ef706a8 Add optional compress flag to tar-in, tar-out APIs.
The compress flag can be used to control compression, one of: (none),
"compress", "gzip", "bzip2", "xz", "lzop".  Thus these calls can now
be used instead of tgz-in/tgz-out/txz-in/txz-out, and also support
more compression types.

Mark these APIs as once_had_no_optargs so that compatibility code is
generated.
2012-08-14 09:53:37 +01:00
Richard W.M. Jones
84c897c93a docs: Add a section describing how to use gdb + qemu wrappers to debug the appliance. 2012-08-13 13:51:29 +01:00
Richard W.M. Jones
22da2cb0ae docs: Show how to use 'annotate-output' command to collect timings. 2012-08-12 22:51:45 +01:00
Richard W.M. Jones
769a6f24c6 ocaml: Use Store_field macro instead of caml_modify.
Use the safer, higher level Store_field macro when constructing arrays
of structs to return.

I don't know if it is strictly necessary in this case, but it's safer.
2012-08-12 17:03:24 +01:00
Richard W.M. Jones
2c046c0d6f virt-make-fs: Don't display output of 'qemu-img' except on error path. 2012-08-11 20:53:00 +01:00
Richard W.M. Jones
2295b09f25 virt-make-fs: Remove note about vfat and ownership of tarball files.
This problem has been fixed in
commit 50780a84f6.
2012-08-11 20:51:28 +01:00
Richard W.M. Jones
f3b21b4da5 Include guestfs-release-notes.txt in the tarball.
This fixes commit 589db4e42a.
2012-08-11 19:08:33 +01:00
Richard W.M. Jones
32e5bab3ee tests/9p: Add test to EXTRA_DIST.
This fixes commit 499497fab0.
2012-08-11 18:35:13 +01:00
Richard W.M. Jones
42d404fa64 Version 1.19.29. 2012-08-11 14:18:42 +01:00
Wanlong Gao
159b1479cc sysprep: remove the process accounting log files
We just remove the process accounting files previously without
touch a empty file, this will cause psacct runs error.
Restart the service can't help us create this file auto.

couldn't open file '/var/account/pacct': No such file or directory

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-08-11 14:18:42 +01:00
Wanlong Gao
9fab546206 xfs: fix a possible memory leak
free out when failure.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-08-11 14:18:42 +01:00
Wanlong Gao
b93d004c7c Fix typo in release notes.
Fix typo.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-08-11 14:18:32 +01:00
Richard W.M. Jones
589db4e42a Convert release notes to a POD file / man page.
Note that we add the text version to git so that it's available for
people to read without requiring any special tools.
2012-08-11 14:18:29 +01:00
Richard W.M. Jones
198cc630f0 New APIs: rsync, rsync-in, rsync-out
Implement rsync.
2012-08-11 09:28:58 +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
7d6f76709e generator: 'delete' is a reserved word (in C++). 2012-08-11 09:28:58 +01:00
Richard W.M. Jones
04b475b414 tests/extra: Add workaround for memory leak in libvirt.
See: https://bugzilla.redhat.com/show_bug.cgi?id=847429
2012-08-11 09:28:58 +01:00
Richard W.M. Jones
1fe6f1f7bb Update release notes for libguestfs 1.20. 2012-08-04 17:24:42 +01:00
Richard W.M. Jones
47410e7999 appliance: Add rsync and openssh-client{,s} to the appliance.
This adds ~10M to the appliance (328M -> 338M).

However for virt-rescue these are frequently requested tools.
2012-08-04 11:48:46 +01:00
Richard W.M. Jones
87602b09ea fuse: guestmount doesn't let you pass '-- [FUSE options]'.
I don't think it ever did, so the --help text was always
wrong, and definitely didn't match the real behaviour of
the program.
2012-08-03 22:38:41 +01:00
Richard W.M. Jones
083125f709 ruby: Mark all VALUEs as volatile. 2012-08-03 19:24:44 +01:00
Richard W.M. Jones
2a87261dfc fish: Fix 'copy-out /' (RHBZ#845522). 2012-08-03 12:54:18 +01:00
Richard W.M. Jones
7fa67427c6 Document problems copying long filenames from NTFS to Linux filesystems (RHBZ#845488). 2012-08-03 11:53:44 +01:00
Richard W.M. Jones
1394d4a69b Version 1.19.28. 2012-08-02 17:35:32 +01:00
Richard W.M. Jones
863168467f examples: Use add_drive_opts function in examples.
In libguestfs 1.20, you will be able to use 'add_drive'
instead of 'add_drive_opts' (except in the C bindings).

However until libguestfs 1.20 is the minimum stable version
people will still be using old versions where you have to use
'add_drive_opts'.  This makes the examples confusing.

Therefore continue to use 'add_drive_opts' in the examples
for now.
2012-08-02 17:21:47 +01:00
Richard W.M. Jones
b3d0cc0588 grep: Add optargs to grep API and deprecate fgrep etc.
This commit makes grep into an optargs API, with flags for extended,
fixed, [case-]insensitive and compressed.

At the same time it deprecates: egrep, fgrep, grepi, egrepi, fgrepi,
zgrep, zegrep, zfgrep, zgrepi, zegrepi and zfgrepi.
2012-08-02 14:05:54 +01:00
Wanlong Gao
d40b502876 xfs: add new api xfs-growfs
New api xfs_growfs for expanding a XFS filesystem.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-08-02 10:20:57 +01:00
Richard W.M. Jones
9b9c372114 Revert "appliance: Add '-drive detect-zero=on' flag if qemu supports it."
This reverts commit fe2253088f.
2012-08-01 18:44:19 +01:00
Richard W.M. Jones
981c7b7310 Reviewed and revised TODO file. 2012-07-31 22:55:58 +01:00
Richard W.M. Jones
4efa0f8f38 m4: Sort .gitignore with LANG=C. Also add pipe2.m4 (used by RHEL 6). 2012-07-31 13:41:51 +01:00
Richard W.M. Jones
f21b866f31 build: On x86 search for qemu-system-i386 not qemu-system-i686.
host_cpu can be set to i686.  The qemu binary is called
qemu-system-i386.  Apply some sed to fix this.
2012-07-31 13:36:01 +01:00
Eric Blake
06780a92b3 build: Allow building with new glibc headers and -O0.
This is a patch taken from libvirt.  See:

http://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=2af63b1c349
2012-07-31 13:15:34 +01:00
Richard W.M. Jones
499497fab0 9p: Add a regression test for 9p functionality in qemu. 2012-07-30 23:49:47 +01:00
Richard W.M. Jones
77326fa4ad appliance: Exclude kernel* packages explicitly.
febootstrap >= 3.19 will no longer exclude the kernel package
by default.
2012-07-30 23:49:47 +01:00
Richard W.M. Jones
54db02b60a Version 1.19.27. 2012-07-30 19:27:09 +01:00
Richard W.M. Jones
7b2f6bd665 libguestfs-make-fixed-appliance: Don't reference obsolete development version. 2012-07-30 17:32:10 +01:00
Richard W.M. Jones
b075b4d1fe New API: utsname
Typical output:

><fs> utsname
uts_sysname: Linux
uts_release: 3.5.0-1.fc18.x86_64
uts_version: #1 SMP Mon Jul 23 17:43:39 UTC 2012
uts_machine: x86_64
2012-07-30 15:16:45 +01:00
Richard W.M. Jones
b61a8a50bc sysprep: Describe more directly how to use qemu-img for snapshotting. 2012-07-28 21:28:23 +01:00
Richard W.M. Jones
dcc0ebc8e0 tests: Consistent use of $(top_builddir)/run --test when building test guests. 2012-07-26 22:02:07 +01:00
Richard W.M. Jones
590774ed9e build: Use $(top_builddir)/run in Makefile.am's.
Not necessary, but this makes all invocations of 'run' consistent.
There is no functional change.
2012-07-26 21:58:17 +01:00
Richard W.M. Jones
96d34d883f Version 1.19.26. 2012-07-26 19:01:28 +01:00
Richard W.M. Jones
fe2253088f appliance: Add '-drive detect-zero=on' flag if qemu supports it.
NB: The patch to implement this feature in qemu is not upstream, and
may never make it upstream.  However this is so useful for
virt-sparsify that I decided to add this to libguestfs while we see
what qemu decides to do.
2012-07-26 18:33:37 +01:00
Richard W.M. Jones
0f837ec068 ruby: Allow optional arguments hash to be really optional.
Allow optargs functions to be called as either:

  g.mkfs_opts(fs, device)

or:

  g.mkfs_opts(fs, device, { optargs hash })

This also preserves backwards compatibility with once_has_no_optargs
functions such as mkfs.
2012-07-26 11:57:02 +01:00
Richard W.M. Jones
5f30912d74 ruby: In event wrapper, ignore callback functions which have type T_ZOMBIE.
Note that in old versions of Ruby, T_ZOMBIE was not defined.
2012-07-26 11:56:49 +01:00
Richard W.M. Jones
7b84b49603 ruby: Set LD_LIBRARY_PATH for Ruby libs in run script.
This lets you use './run gdb ruby ...' and get accurate
debugging information.
2012-07-25 22:56:54 +01:00
Richard W.M. Jones
208d1c1a09 sparsify: Detect qemu-img version and use qcow2 v3 for overlay if available.
qcow2 v3 is generally more efficient, although unfortunately it
doesn't support automatically sparsifying zero writes.

Note this *only* uses qcow2 v3 for the intermediate overlay file, not
for the final output (since we want the output to be broadly
compatible with old hypervisors).
2012-07-25 16:51:42 +01:00
Richard W.M. Jones
0b3b5f984c sparsify: Change code that generates qemu-img -o argument.
This is just code motion.
2012-07-25 16:28:12 +01:00
Richard W.M. Jones
42bf3274e4 sysprep: Generate new random UUIDs for LVM2 PVs and VGs (thanks Kazuo Moriwaka). 2012-07-25 14:47:15 +01:00
Richard W.M. Jones
e64bf3fb29 New APIs: pvchange-uuid, pvchange-uuid-all, vgchange-uuid, vgchange-uuid-all.
These APIs will allow sysprep to change the UUIDs of all PVs and VGs
in the system.

LVs don't have UUIDs AFAICT, or at least there seems to be no way to
change them if they do have them.
2012-07-25 14:47:15 +01:00
Richard W.M. Jones
2b59b5f1d2 sysprep: Change perform callback to perform_on_filesystems and perform_on_devices.
Operations that need to work directly on guest block devices will fail
because the block devices are busy.  Therefore add a phase with the
filesystems unmounted, and allow operations to specify that they need
to work in this phase.
2012-07-25 14:47:15 +01:00
Matthew Booth
1fb95e6566 fish: Use minimal permissions when initially creating history file 2012-07-25 14:17:37 +01:00
Richard W.M. Jones
b7ff02354d sysprep: Tidy up the Makefile.
This is just code motion.
2012-07-25 10:15:47 +01:00
Richard W.M. Jones
4fa51f11da sysprep: operation machine-id: return `Created_files.
This operation can create the /etc/machine-id file, so it may need to
be relabelled by SELinux.

This fixes commit e68336d72a.
2012-07-25 10:09:28 +01:00
Wanlong Gao
e68336d72a sysprep: remove the local machine ID
remove the local machine ID, leave it empty, let it be generated
during next booting.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>

RWMJ:
 - Whitespace change.
 - Remove completed items from TODO.
2012-07-25 08:56:38 +01:00
Wanlong Gao
a121f1d654 sysprep: remove the auto generated abrt data
remove the automatically generated abrt data.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>

RWMJ:
 - Remove copy and pasted line.
 - Use C<> in description.
2012-07-25 08:55:20 +01:00
Masami HIRATA
d74e7fad28 Mac OS X: Use u_int64_t/uint64_t instead of unsigned hyper in .x file
Signed-off-by: Masami HIRATA <msmhrt@gmail.com>

RWMJ:
  Fixed whitespace in generator_xdr.ml
2012-07-24 19:40:40 +01:00
Masami HIRATA
61c9ea496e Mac OS X: Use libtool --mode=execute instead of LD_LIBRARY_PATH
because Mac OS X doesn't support LD_LIBRARY_PATH

Signed-off-by: Masami HIRATA <msmhrt@gmail.com>
2012-07-24 19:40:40 +01:00
Masami HIRATA
7d3f190d90 Mac OS X: Use gnulib stat-time module explicitly.
Signed-off-by: Masami HIRATA <msmhrt@gmail.com>
2012-07-24 19:40:40 +01:00
Masami HIRATA
a887dd5109 lib: Use <sys/socket.h> and <sys/un.h> for sockaddr_un
Signed-off-by: Masami HIRATA <msmhrt@gmail.com>
2012-07-24 19:40:39 +01:00
Masami HIRATA
399887defd Mac OS X: Use real files for gtk-doc (not the symlink)
Signed-off-by: Masami HIRATA <msmhrt@gmail.com>
2012-07-24 19:40:39 +01:00
Masami HIRATA
9519c60ce5 Mac OS X: don't check glibc-style extended printf formatters unless --enable-daemon
Signed-off-by: Masami HIRATA <msmhrt@gmail.com>

RWMJ:
 - Test was in the wrong place (before --enable-daemon had been
   detected) so I moved it later.
2012-07-24 19:40:14 +01:00
Masami HIRATA
7dab208765 Mac OS X: #define UNIX_PATH_MAX 104
See http://developer.apple.com/library/mac/documentation/Darwin/Reference/Manpages/man4/unix.4.html

Signed-off-by: Masami HIRATA <msmhrt@gmail.com>
2012-07-24 19:18:37 +01:00
Masami HIRATA
6e3f8d2511 Mac OS X: Added check of #include <endian.h>
Mac OS X doesn't have endian.h

Signed-off-by: Masami HIRATA <msmhrt@gmail.com>
2012-07-24 19:18:37 +01:00
Masami HIRATA
a47fa7a65e Mac OS X: Use gnulib fstatat module explicitly.
Signed-off-by: Masami HIRATA <msmhrt@gmail.com>
2012-07-24 19:18:37 +01:00
Masami HIRATA
d6ef91d7c4 Mac OS X: Use gnulib memmem module explicitly.
m4/.gitignore: Update.

Signed-off-by: Masami HIRATA <msmhrt@gmail.com>
2012-07-24 19:18:37 +01:00
Masami HIRATA
ef1a8446a6 configure: Use $(PERL) instead of perl
Signed-off-by: Masami HIRATA <msmhrt@gmail.com>
2012-07-24 19:18:36 +01:00
Masami HIRATA
8f3a839aa8 configure: Add -nographic command line option to qemu.
Without this option, configure will fail when there is no display.

Signed-off-by: Masami HIRATA <msmhrt@gmail.com>
2012-07-24 19:18:36 +01:00
Richard W.M. Jones
ebe826f23f Version 1.19.25. 2012-07-24 14:48:39 +01:00
Richard W.M. Jones
67e1c90605 launch: libvirt: Suppress printing of libvirt errors to stderr and other cleanups. 2012-07-24 14:26:55 +01:00
Richard W.M. Jones
493e80ab4e launch: libvirt: Use SELinux-mandated directory for sockets (RHBZ#842307).
Note this does not yet enable sVirt confinement of the appliance.
That requires at least that SELinux policy goes upstream, plus there
may still be bugs.
2012-07-24 14:03:36 +01:00
Richard W.M. Jones
97aeaa86d0 todo: More suggestions for virt-sysprep (thanks Kazuo Moriwaka). 2012-07-24 13:42:06 +01:00
Richard W.M. Jones
5d0ef09963 launch: libvirt: Move free to end of function.
This is just code motion.
2012-07-24 13:01:08 +01:00
Richard W.M. Jones
507aa9ac35 launch: libvirt: Add is_blk utility.
This is just code motion.
2012-07-24 13:01:08 +01:00
Wanlong Gao
d8b2c1afee umount: use Dev_or_Path for the argument type
Use Dev_or_Path instead of String.

Remove the RESOLVE_DEVICE since Dev_or_Path will generate
REQUIRE_ROOT_OR_RESOLVE_DEVICE instead.

RWMJ:
Note a change in semantics: this now requires root.  However this is
OK and still works with mkmountpoint and friends because
'is_root_mounted' works even if something is mounted below the root.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-07-24 13:01:08 +01:00
Richard W.M. Jones
c03cdcc25c launch: libvirt: Set <emulator> in libvirt XML if g->qemu is not the default. 2012-07-24 10:21:32 +01:00
Richard W.M. Jones
40e5317cfb xfs-info: Fix description to refer to 'pathordevice' param. 2012-07-24 10:16:31 +01:00
Wanlong Gao
f4094b91d2 xfs_info: resolve device when doing xfs_info on a device
Resolve device first, like do_umount.
Use Dev_or_Path.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-07-24 10:10:30 +01:00
Wanlong Gao
bda974e64c umount: add force umount and lazy umount
Add the option force and lazy for force and lazy umount.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-07-24 09:06:27 +01:00
Richard W.M. Jones
6bdc4b30ea Version 1.19.24. 2012-07-23 21:53:55 +01:00
Richard W.M. Jones
2b059535b1 tests: Skip regression test for 790721 if attach-method is not 'appliance'. 2012-07-23 21:41:47 +01:00
Richard W.M. Jones
941ec968b8 lib: Initialize libvirt and libxml2 once when the library loads. 2012-07-23 21:26:18 +01:00
Richard W.M. Jones
bf00be0e17 launch: Make get-pid and max-disks APIs into virtual methods of the current attach-method. 2012-07-23 20:17:25 +01:00
Richard W.M. Jones
3614d76b37 tests: Move debug-drives testing API to launch.c and change the output.
It should work with any attach-method.
2012-07-23 20:17:24 +01:00
Richard W.M. Jones
a6366f5dae python: Set file encoding to utf-8. 2012-07-23 20:17:24 +01:00
Richard W.M. Jones
bc917a0efc tests/protocol: Skip these tests if default attach-method is not 'appliance'. 2012-07-23 18:44:07 +01:00
Richard W.M. Jones
b6afb98a79 tests: Fix get-attach-method test.
If ./configure --with-default-attach-method is set to something other
than 'appliance', then this will legitimately return a different
string.  Simply test that it runs, rather than testing the output.

This fixes commit 20a5b4de7d.
2012-07-23 18:44:07 +01:00
Richard W.M. Jones
c65ee25a75 tests: Remove get-pid test.
If the libvirt attach-method is used, then there is no known PID
(libvirt hides it).
2012-07-23 18:44:02 +01:00
Richard W.M. Jones
0a1b2f85e6 launch: libvirt: Use <driver name="qemu" type=[format] />.
We were using format= which was bogus and libvirt was ignoring it and
forcing raw format instead.

Also in its default configuration libvirt won't do disk format
autodetection at all, so we must do it instead.
2012-07-23 18:08:16 +01:00
Richard W.M. Jones
f9e484ca45 launch: libvirt: You can't set O_CLOEXEC flag using fcntl + F_SETFL.
And in any case there is no point, since proto.c already sets the
SOCK_CLOEXEC flag (using accept4) on this socket.

The code now matches the code in launch-appliance.c.
2012-07-23 18:08:16 +01:00
Richard W.M. Jones
793a482015 launch: libvirt: Use accept4 to set socket flags correctly. 2012-07-23 18:08:16 +01:00
Richard W.M. Jones
5fb0f4e07e launch: libvirt: Add <on_reboot>destroy</on_reboot> to libvirt XML.
This causes libvirt to add the qemu -no-reboot option, which
reflects existing behaviour.
2012-07-23 16:43:14 +01:00
Richard W.M. Jones
20a5b4de7d launch: Allow default attach-method to be set in environment or configure.
You can now choose the default attach method in two ways:

(1) Set the LIBGUESTFS_ATTACH_METHOD environment variable.

(2)  ./configure --with-default-attach-method=appliance|libvirt|...

Note that (1) overrides (2).
2012-07-23 15:24:57 +01:00
Richard W.M. Jones
7a691e6665 java: Set '-encoding utf8' for javac and javadoc commands. 2012-07-23 15:24:07 +01:00
Richard W.M. Jones
7f519bdc06 java: JAVAC_FLAGS -> EXTRA_JAVAC_FLAGS.
This is just a rename.
2012-07-23 15:18:12 +01:00
Richard W.M. Jones
99f108b840 launch: libvirt: Move remaining to-do items to TODO file. 2012-07-23 14:28:03 +01:00
Richard W.M. Jones
68836022d2 launch: libvirt: Add a hack to detect if KVM is available.
We need to select the <domain type=...> attribute depending on whether
KVM is detected in the libvirt capabilities.

This is a hack because it doesn't try to parse the libvirt
capabilities XML.
2012-07-23 13:14:16 +01:00
Richard W.M. Jones
890a4fbc87 launch: libvirt: Use <cpu model="host-model"/> (thanks Dan Berrange).
This ensures maximum performance of the appliance, particularly for
things like MD where the guest needs to use optimal SSE instructions.
2012-07-23 13:05:46 +01:00
Richard W.M. Jones
67f7a30cc9 launch: libvirt: Change disk XML according to whether host path is device or file (thanks Dan Berrange). 2012-07-23 13:02:25 +01:00
Richard W.M. Jones
f2d7305091 launch: libvirt: Use "guestfs-" prefix on random names (thanks Dan Berrange). 2012-07-23 12:46:37 +01:00
Richard W.M. Jones
ef75c4c568 launch: libvirt: Enforce minimum version of libvirt 0.9.13. 2012-07-23 12:45:31 +01:00
Richard W.M. Jones
524bb29526 launch: libvirt: Use snapshot=on instead of <readonly/>.
For compatibility with the appliance backend, devices added readonly
are in fact added writable with snapshots on top.  This is necessary
because options like 'mount -o ro' usually require write access to the
disk (eg. to replay journals).
2012-07-23 12:37:22 +01:00
Richard W.M. Jones
abcd6f0c15 Version 1.19.23. 2012-07-22 14:40:43 +01:00
Richard W.M. Jones
aa0efa9eb4 launch: Add libvirt backend.
Complete the attach-method libvirt backend.

This backend uses libvirt to create a transient KVM domain to run the
appliance.

Note that this still will only work with local libvirt URIs since the
<kernel>, <initrd> and appliance links in the libvirt XML refer to
local files, and virtio serial only works locally (limitation of
libvirt).  Remote support will be added later.
2012-07-22 09:32:04 +01:00
Richard W.M. Jones
42ba262003 Add attach-method "libvirt" or "libvirt:<URI>".
With this commit, you can set the attach method to libvirt,
but calling launch will give an error.
2012-07-21 15:47:50 +01:00
Richard W.M. Jones
f32b93416a launch: Make 'drive_name' into a common function.
This is just code motion.
2012-07-21 15:47:50 +01:00
Richard W.M. Jones
fa3b204f4a appliance: Push appliance building lock into guestfs___build_appliance.
Since we will be calling guestfs___build_appliance from the libvirt
code in future, there's no point having two places where we have to
acquire the lock.  Push the lock down into this function instead.

Because "glthread/lock.h" includes <errno.h> we have to add this
header to the file too.
2012-07-21 14:26:24 +01:00
Wanlong Gao
a58368b3db fuse:remove the unused macro when fuse is not available
Just make gcc happy when fuse is not available.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-07-21 08:30:44 +01:00
Richard W.M. Jones
ec8e3b6cad launch: Abstract attach method operations.
g->attach_ops points to a structure which contains the
operations supported by each attach method backend
(ie. appliance, unix, etc.).
2012-07-20 15:10:46 +01:00
Richard W.M. Jones
08cad54349 launch: Move the command line building code entirely into launch-appliance.c.
Although we still use the handle as convenient temporary
storage.
2012-07-20 13:49:10 +01:00
Richard W.M. Jones
52fa23d74f launch: Move guestfs_config API and build list of qemu parameters in handle.
Move and rewrite guestfs_config so it accumulates a list of qemu
parameters in the handle.  These are added to the appliance at launch
time (with attach method == unix:...  you'll now get an error).
2012-07-20 13:43:55 +01:00
Richard W.M. Jones
4df6beee54 launch: Move launch timing / messages code into launch.c. 2012-07-20 13:43:13 +01:00
Richard W.M. Jones
54fd9a10a6 lib: Use bool (from <stdbool.h>) for a few fields in the handle. 2012-07-20 13:43:13 +01:00
Richard W.M. Jones
709e28e6d5 lib: Rearrange fields in guestfs handle.
Arrange the fields more logically.  This is just code motion.
2012-07-20 13:43:13 +01:00
Richard W.M. Jones
a6e0e0d6bf add-cdrom: Rewrite description emphasising that this API should not be used. 2012-07-20 13:43:13 +01:00
Richard W.M. Jones
184b9d7c11 ocaml: Skip mount-local test if /dev/fuse is not writable. 2012-07-20 08:35:13 +01:00
Richard W.M. Jones
9d314c7c3f launch: Remove some dead code from the appliance method. 2012-07-19 19:06:23 +01:00
Richard W.M. Jones
4c261da5ba lib: Split launch.c into separate files.
launch-appliance.c contains the code associated with the 'appliance'
attach-method.  Mostly.  In fact there are a few APIs which don't fit
so nicely:

 - config: deprecated API which fiddles with the qemu command
   line directly

 - max-disks: depends on the qemu implementation (virtio-scsi
   or not)

 - debug-drives: used for testing only

launch-unix.c contains the code associated with 'unix:<path>'.

launch.c is the common code for launching, along with a few other APIs
such as guestfs_add_drive_opts.

This commit also reduces the number of headers to just those
which are required.
2012-07-19 17:49:25 +01:00
Richard W.M. Jones
80d102c49d Remove debug-cmdline API.
Note that debug* calls are not part of the stable API and can be
removed or changed at any time.
2012-07-19 17:12:44 +01:00
Richard W.M. Jones
eca544d87d lib: Use safe_asprintf when constructing attach_method.
Just a small code cleanup / simplification.
2012-07-19 16:26:06 +01:00
Richard W.M. Jones
2e4089f300 build: Rename most C files that contain underscore with dash.
This is just code motion.

Some files cannot be renamed.  Notably rpcgen input and output files
must not contain dash characters, else rpcgen breaks.
2012-07-19 16:11:47 +01:00
Richard W.M. Jones
6054051a9d fish: Rename fish/virt.c to fish/domain.c
This file handles the -d option for guestfish and other C command line
utilities.  Renaming this file makes it less confusing.
2012-07-19 16:11:26 +01:00
Richard W.M. Jones
d1d29ab488 build: Rename src/virt.c to src/libvirtdomain.c
This file contains the code implementing guestfs_add_domain
(for adding a libvirt domain) so this name is less confusing.
2012-07-19 16:11:26 +01:00
Richard W.M. Jones
d88f4ca634 build: Arrange libguestfs_la_SOURCES in order. 2012-07-19 16:11:26 +01:00
Richard W.M. Jones
a8b4ea1f0c Remove references to long-obsolete Ocaml_inspector module from .gitignore. 2012-07-19 16:11:24 +01:00
Richard W.M. Jones
f514d462cd podwrapper: Fix setting of GIT_DIR in git subcommand.
This fixes commit 1e17a32060.
2012-07-19 16:10:48 +01:00
Richard W.M. Jones
805d642565 license: Use latest license files from gnu.org.
COPYING from https://www.gnu.org/licenses/gpl-2.0.txt
COPYING.LIB from https://www.gnu.org/licenses/lgpl-2.1.txt

(Note this change shouldn't alter the licensing of libguestfs)
2012-07-19 14:17:31 +01:00
Richard W.M. Jones
719297a220 Version 1.19.22.
Includes rebuilt gnulib to work around test problems with
test-getlogin_r.
2012-07-19 13:51:16 +01:00
Richard W.M. Jones
6e1b5f0fea gnulib: Don't include or run getlogin_r test (thanks Jim Meyering).
See:
https://lists.gnu.org/archive/html/bug-gnulib/2012-07/msg00194.html
2012-07-19 12:43:55 +01:00
Richard W.M. Jones
fc86db3b3b build: Return 77 from skipped tests. 2012-07-19 11:22:40 +01:00
Richard W.M. Jones
1b94ea204d Version 1.19.21. 2012-07-18 21:51:20 +01:00
Richard W.M. Jones
a0a517869c tests: Rewrite parallel mount-local test in C. 2012-07-18 20:09:40 +01:00
Richard W.M. Jones
eef11f33f9 ocaml: Test mount-local, without parallel test.
Unfortunately the parallel test keeps hitting this bug:
https://bugzilla.redhat.com/show_bug.cgi?id=838081
which could be a bug in the OCaml runtime.

Just test simple mount-local.  We will write a parallel test in C to
replace this.
2012-07-18 13:45:21 +01:00
Richard W.M. Jones
50780a84f6 tar-in: Add --no-same-owner flag to tar command when target filesystem doesn't support chown (RHBZ#840572).
When using tar-in or tools built around it such as virt-make-fs, if
the target filesystem is vfat then unpacking the tarball would fail
because tar tries to chown(2) files and fails.

You would see errors such as:

tar: <file>: Cannot change ownership to uid 500, gid 500: Operation not permitted

This change detects whether the target filesystem supports chown(2).
If not, it adds the --no-same-owner flag to tar to stop it from trying
to change the ownership of newly created files.
2012-07-18 12:33:16 +01:00
Richard W.M. Jones
781857a86b daemon: Make 'random_name' into a utility function.
This is mostly code motion, although the precise contract of this
function changes slightly to make it more generally useful
2012-07-18 12:32:21 +01:00
Richard W.M. Jones
9c2b9c2df6 virt-make-fs: Suggest guestfish for complex layouts in man page. 2012-07-18 11:14:19 +01:00
Richard W.M. Jones
b25aea33fa build: Change how make.sh, packagelist, excludelist are updated.
Add proper dependencies for these files, but also use 'cmp' to ensure
they only get overwritten if the new files have actually changed, so
we don't rebuild the appliance unnecessarily.
2012-07-18 10:03:29 +01:00
Wanlong Gao
87206e4e9e New API: add new api xfs_info
Add xfs_info to show the geometry of the xfs filesystem.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>

RWMJ:
 - Updated po/POTFILES.
 - Use xfs_ prefix for all struct fields.
 - Return uninitialized fields as -1 / empty string.
 - Copyedit the description.
2012-07-18 09:37:17 +01:00
Wanlong Gao
2f89f584c0 augeas: make functions as noreturn
Just make gcc happy.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-07-18 09:05:32 +01:00
Richard W.M. Jones
8e75e21b23 podwrapper: Use UTF8 in output, send errors to stderr.
This fixes commit 1e17a32060.
2012-07-17 20:04:24 +01:00
Richard W.M. Jones
d76ea07814 Version 1.19.20. 2012-07-17 15:38:52 +01:00
Richard W.M. Jones
973581780d case_sensitive_path: Allow trailing path element to be missing (RHBZ#840115).
case_sensitive_path is undefined when the final path element doesn't
exist.  Currently it returns an error, but this means that creating a
new file doesn't work as expected:

  $ guestfish --rw -i -d windows touch 'win:c:\blah'
  libguestfs: error: case_sensitive_path: blah no file or directory found with this name

We should allow this case (provided there is no trailing slash) so
that new files or directories can be created.
2012-07-17 14:37:03 +01:00
Richard W.M. Jones
ac0373bdec case_sensitive_path: Move variables to top of function.
This is just code motion.
2012-07-17 13:46:48 +01:00
Richard W.M. Jones
4bc110e2bc docs: Use L<...> for links.
Instead of working around bugs, podwrapper has been fixed so that
links work in all output formats.
2012-07-17 13:18:39 +01:00
Richard W.M. Jones
182b4a6660 podwrapper: Subclass Pod::Man so we can fix the way links are generated. 2012-07-17 13:18:34 +01:00
Richard W.M. Jones
9967ad3fa1 podwrapper: Define $VERSION in subclass.
The superclass sometimes uses this and will give an undefined
error if it's missing.
2012-07-17 13:18:34 +01:00
Richard W.M. Jones
60c42dd2a1 podwrapper: Tidy up the program name.
Messages now look like this:

  podwrapper.pl: wrote guestfs-examples.3
  podwrapper.pl: wrote ../html/guestfs-examples.3.html
2012-07-17 13:18:34 +01:00
Richard W.M. Jones
f6846d74c9 perl: In examples, call $g->shutdown, $g->close. 2012-07-17 12:34:51 +01:00
Richard W.M. Jones
a99ea198b2 perl: Use $g instead of $h in documentation.
$g is the "standard" name for libguestfs handles.
2012-07-17 12:33:45 +01:00
Richard W.M. Jones
8d0baf7b85 docs: febootstrap is in section 8 of the manual, not section 1. 2012-07-16 23:04:17 +01:00
Richard W.M. Jones
1e17a32060 Replace podwrapper shell script with custom Perl script.
This uses Pod::Simple so it properly parses the input POD and can
generate proper custom output as required specifically by libguestfs.

One immediate benefit is that links between and within manual pages
now work mostly correctly.
2012-07-16 22:53:01 +01:00
Richard W.M. Jones
0bf1e5b665 Fix pod.css for new HTML output from Perl 5.16.
There used to be a <div> around the table of contents, but that
is no longer present.
2012-07-16 22:13:24 +01:00
Richard W.M. Jones
3a442e6617 configure: Make generated files read-only.
Some of the generated files anyway.
2012-07-16 21:58:34 +01:00
Richard W.M. Jones
f2ea617e22 build: Change calls to podwrapper.sh to use $(PODWRAPPER).
This will allow us to easily change the location of this
script in future.
2012-07-16 18:56:57 +01:00
Richard W.M. Jones
c7d342a94a virt-make-fs: Add --floppy option to make preconfigured vfd's. 2012-07-16 16:47:44 +01:00
Richard W.M. Jones
24b7979ea2 virt-make-fs: Recognize "msdos" as a partition or filesystem type.
Set MBR partition type byte accordingly.
2012-07-16 16:26:26 +01:00
Richard W.M. Jones
d69a03e448 Revert "ocaml: Calling Gc.compact before g#mount_local works around RHBZ#838081."
This reverts commit ad7c4498f6.

Reverted because we still see core dumps.
2012-07-16 14:01:46 +01:00
Richard W.M. Jones
2bd080fd5a Version 1.19.19. 2012-07-16 13:29:40 +01:00
Richard W.M. Jones
98f2d221cf run: Update comments. 2012-07-16 13:29:39 +01:00
Richard W.M. Jones
95d26f0240 generator: Rename 'ntfsresize_opts' API to 'ntfsresize'.
By using the once_had_no_optargs flag, this change is backwards
compatible for callers.
2012-07-14 13:08:21 +01:00
Richard W.M. Jones
e055bf4cab generator: Rename 'mkfs_opts' API to 'mkfs'.
By using the once_had_no_optargs flag, this change is backwards
compatible for callers.
2012-07-14 12:43:13 +01:00
Richard W.M. Jones
7486fc6f43 generator: Rename 'add_drive_opts' API to 'add_drive'.
By using the once_had_no_optargs flag, this change is backwards
compatible for callers (except Haskell, PHP and GObject as discussed
in earlier commit).
2012-07-14 12:42:24 +01:00
Richard W.M. Jones
b48ae2eadf generator: In non-C bindings, generate '*_opts' alias.
In C, a function called 'func' which has once_had_no_optargs=true will
(because of the previous commit) generate 'func_opts' and a
backwards-compatibility function called 'func'.

This commit changes some of the non-C bindings so that they also
generate 'func_opts' which is merely a wrapper that calls 'func'.

This avoids incompatibility when we rename 'mkfs_opts' etc back to
plain 'mkfs', and it also makes it easier to translate between other
language bindings and C code.

NB: Some bindings do not include aliases:

  PHP:     There's no way to easily alias methods in PHP < 5.3, and we
           can't assume everyone has this minimum version.

  GObject: Very complex to add aliases, but we should probably do this
           at some point.

  Haskell: No support for optargs in these bindings.  Unfortunately
           this means that we can no longer bind 'Guestfs.add_drive'
           (since it will be changed to add optional arguments) making
           the Haskell bindings even less useful than they were already.
2012-07-14 11:13:49 +01:00
Richard W.M. Jones
98757e151a generator: Allow non-optargs functions to gain optargs.
This commit adds a flag (once_had_no_optargs) which can be used to add
optargs to functions that currently don't have any.

The idea is that if 'func' currently has no optargs, we can safely add
optargs provided we are backwards compatible for existing callers.

In C that means we leave 'guestfs_func' alone and provide an extra
function 'guestfs_func_opts' that takes the optargs ('guestfs_func'
becomes a wrapper that calls 'guestfs_func_opts').

In the C generator this means there are two names for each function
(although the two names are normally identical).  'c_name' is the name
that we export publicly (eg. [guestfs_] 'func_opts').  'name' is the
internal name of the function (eg. 'func') which is used for
everything apart from the public interface, and also to generate the
no-optargs compat function.

In other languages that can add optional arguments safely, we simply
add the arguments to the existing 'func', so for example in Perl:

  $g->func (required_args)
  $g->func (required_args, optional_args)

can be used.

Note that this commit does not cause any change to the output of the
generator.  I verified this by diffing the output before and after.
2012-07-14 10:20:58 +01:00
Richard W.M. Jones
9eb6060456 generator: Rearrange some C generator code into sub-functions.
This is just code motion.  I verified this by comparing the
generator output before and after this commit.
2012-07-13 14:02:43 +01:00
Richard W.M. Jones
0da2dbef26 java: Generate overloaded non-optargs method for each optargs method.
For example the existing method:

  public void mkfs_opts (String fstype, String device, Map<..> optargs);

is now accompanied by this overloaded method which is a simple wrapper:

  public void mkfs_opts (String fstype, String device)
    throws LibGuestFSException
  {
    mkfs_opts (fstype, device, null);
  }
2012-07-13 14:02:43 +01:00
Richard W.M. Jones
60805c9217 generator: Add c_optarg_prefix for each action.
This updates commit 9286f556c6.
2012-07-13 09:00:25 +01:00
Richard W.M. Jones
9286f556c6 generator: Add c_function (C function name) to each action struct.
This field, which is generated internally by the generator, is the
name of the C function corresponding to each action.

For actions that have NO optional arguments, it's just "guestfs_<name>".

For actions that have any optional arguments, it is
"guestfs_<name>_argv" (since any binding has to construct the optional
argument struct explicitly).

In a future commit, this mapping may become more complex.

This commit also "fixes" the C# bindings which didn't handle optional
arguments properly at all.  In fact, it doesn't fix this, it just
changes it enough that it probably now compiles.  We should either
compile and test the bindings routinely with Mono, or drop them, since
they are starting to bit-rot.

In the GObject bindings, I have added a space between the C function
name and the first paren.

Apart from the C# and GObject changes, this is just code motion.  It
was verified by diffing the output of the generator before and after.
2012-07-12 12:50:49 +01:00
Richard W.M. Jones
e80f368732 generator: Change the way that camel-case names are generated.
Store the camel-case name directly in the struct instead
of generating it on the fly in only the GObject bindings.

This is just code motion.  Tested by verifying that the generator
output is identical.
2012-07-12 11:11:31 +01:00
Richard W.M. Jones
e452a0b8ca tests: Rename test0* functions as internal_test*.
The internal_* prefix is reserved for internal functions
such as these tests.
2012-07-11 23:56:10 +01:00
Richard W.M. Jones
7a0478bed0 tests: Better way to ensure 'g' is used and return success or error. 2012-07-11 23:55:11 +01:00
Richard W.M. Jones
39d1a7dbc9 generator: Use a struct instead of a tuple to describe each action.
Each action changes from a tuple like this:

  ("cat", (RString "content", [Pathname "path"], []), 4,
   [ProtocolLimitWarning],
   [InitISOFS, Always, TestOutput (
      [["cat"; "/known-2"]], "abcdef\n")],
   "list the contents of a file",
   "[...]");

to a slightly longer but more readable struct:

  { defaults with
    name = "cat";
    style = RString "content", [Pathname "path"], [];
    proc_nr = Some 4;
    protocol_limit_warning = true;
    tests = [
      InitISOFS, Always, TestOutput (
      [["cat"; "/known-2"]], "abcdef\n")
    ];
    shortdesc = "list the contents of a file";
    longdesc = "[...]" };

["defaults" is a struct which contains the defaults for every field,
allowing us to use the "{ defaults with ... }" syntax to just update
the fields we want to be different from the defaults.]

This is a mechanical change and there is no change to the output of
the generator.  I checked the output before and after with diff to
verify this.  There are no changes in the output apart from UUIDs
which are expected to change with each run.
2012-07-11 19:55:16 +01:00
Richard W.M. Jones
7b619d47f6 todo: Tidy up test0 functions. 2012-07-11 15:05:57 +01:00
Richard W.M. Jones
196742cd46 generator: Add a note in generator/README about safely extending functions. 2012-07-11 10:47:18 +01:00
Richard W.M. Jones
cf0defedb8 generator: Move note in comment to generator/README file. 2012-07-11 10:46:56 +01:00
Richard W.M. Jones
ec0c7e0a1a fuse: Cleaner code and documentation for safe cleanups. 2012-07-10 19:03:19 +01:00
Richard W.M. Jones
f883e4d8d3 tests/guests: Add temp files to CLEANFILES. 2012-07-10 18:59:04 +01:00
Richard W.M. Jones
1c8403885c Update translations from Transifex. 2012-07-10 18:44:45 +01:00
Richard W.M. Jones
33bb7408f6 podwrapper: Fix shell script.
This fixes commit f9a5e3ed86.
2012-07-10 13:46:17 +01:00
Hilko Bengen
f9a5e3ed86 podwrapper.sh: Take date from ChangeLog or from the latest git commit. 2012-07-10 10:34:37 +02:00
Richard W.M. Jones
afb30b1b8a Version 1.19.18. 2012-07-09 18:36:46 +01:00
Richard W.M. Jones
8df259496a fuse: Add regression test for RHBZ#838592. 2012-07-09 17:44:50 +01:00
Richard W.M. Jones
5546ea6d68 fuse: Add guestmount --pid-file option (RHBZ#838592). 2012-07-09 16:10:24 +01:00
Richard W.M. Jones
bfbfe6dd78 fuse: Link to mount-local documentation in guestmount man page. 2012-07-09 15:24:26 +01:00
Richard W.M. Jones
1cde66165a fuse: Document race condition possible with fusermount.
See also:
https://bugzilla.redhat.com/show_bug.cgi?id=835466#c9
2012-07-09 15:23:52 +01:00
Richard W.M. Jones
b749dc7074 fuse: Document Device or resource busy errors from fusermount. 2012-07-09 15:23:09 +01:00
Richard W.M. Jones
bd3e42a8de Revert "launch: Correction in comment."
This reverts commit 6e5a85bb9b.

It turns out this is a bug in QEMU after all.
2012-07-08 12:55:44 +01:00
Richard W.M. Jones
e6dec15948 extra-tests: Add a test using upstream qemu. 2012-07-07 16:19:55 +01:00
Richard W.M. Jones
6e5a85bb9b launch: Correction in comment.
https://bugs.launchpad.net/qemu/+bug/1021649 is invalid, probably
caused by a Fedora ROM.

This updates commit 52d188e32f.
2012-07-07 15:49:22 +01:00
Richard W.M. Jones
1596b6026d Update gnulib to latest version. 2012-07-07 12:39:46 +01:00
Richard W.M. Jones
ac25512175 Version 1.19.17. 2012-07-06 14:11:38 +01:00
Richard W.M. Jones
ad7c4498f6 ocaml: Calling Gc.compact before g#mount_local works around RHBZ#838081. 2012-07-06 13:47:07 +01:00
Richard W.M. Jones
52d188e32f qemu: Use sgabios by default (thanks Dan Berrange). 2012-07-06 10:29:26 +01:00
Richard W.M. Jones
1b87f89b5c todo: Investigate qemu caching modes. 2012-07-04 16:44:35 +01:00
Richard W.M. Jones
a95fc92388 Version 1.19.16. 2012-07-04 16:17:44 +01:00
Richard W.M. Jones
7996e08824 qemu or qemu-kvm >= 1.1.0 is required.
Earlier versions of qemu contained a bug in the qcow2 code which
causes qemu to segfault when shutting down and flushing its internal
cache, and this can result in data loss.
2012-07-04 16:17:44 +01:00
Richard W.M. Jones
ffbf1475f7 New API: guestfs_shutdown: Cleanly shutdown the backend.
The new API splits orderly close into a two-step process:

  if (guestfs_shutdown (g) == -1) {
    /* handle the error, eg. qemu error */
  }
  guestfs_close (g);

Note that the explicit shutdown step is only necessary in the case
where you have made changes to the disk image and want to handle write
errors.  Read the documentation for further information.

This change also:

 - deprecates guestfs_kill_subprocess

 - turns guestfs_kill_subprocess into the same as guestfs_shutdown

 - changes guestfish and other tools to call shutdown + close
   where necessary (not for read-only tools)

 - updates documentation

 - updates examples
2012-07-03 21:27:29 +01:00
Richard W.M. Jones
bcc4ffb52b close: Warn if qemu exits unsuccessfully.
Currently guestfs_close has no method to return an error indication,
so this commit simply prints the error on stderr.
2012-07-03 18:14:06 +01:00
Richard W.M. Jones
fc3c6fff4b close: Rearrange the order in which the handle is closed and freed.
The order is now:

 - remove the handle from the list of handles
 - send close trace message
 - sync and shutdown qemu
 - run user close callback
 - free temporary directory
 - free memory

This commit ought to be no functional change.
2012-07-03 14:45:42 +01:00
Richard W.M. Jones
27ebf517fa perl, python, ruby: Fix comments on call to close method.
Make the comments consistent.

Also make the Perl example call $g->close explicitly so it is
consistent with the other examples.
2012-07-03 14:45:42 +01:00
Richard W.M. Jones
917550a117 examples: In create_disk example, don't call set_autosync.
This is now set by default in all supported versions of libguestfs.
It's just confusing if the examples refer to it.
2012-07-03 14:45:42 +01:00
Richard W.M. Jones
c0a3c9ce70 daemon: Run fsync on block devices after sync (RHBZ#836710).
On Linux, sync(2) does not actually issue a write barrier, thus it
doesn't force a flush of the underlying hardware write cache (or
qemu's disk cache in the virtual case).

This can be a problem, because libguestfs relies on running sync in
the appliance, followed by killing qemu (using SIGTERM).

In most cases, this is fine, because killing qemu with SIGTERM should
cause it to flush out the disk cache before it exits.  However we have
found various bugs in qemu which cause qemu to crash while doing the
flush, leaving the data unwritten (see RHBZ#836913).

The solution is to issue fsync(2) to the block devices.  This has a
write barrier, so it ensures that qemu writes out its cache long
before we get around to killing qemu.
2012-07-02 21:13:21 +01:00
Richard W.M. Jones
cb24ceedd8 daemon: Code tidy up in devsparts.
No functional change.
2012-07-02 16:42:17 +01:00
Richard W.M. Jones
0437a79056 Add notes about how qemu cache=none works internally.
This is just a comment and has no functional effect.
2012-07-02 14:16:35 +01:00
Richard W.M. Jones
1608ca182b Rename qemu option cache=off to cache=none.
Note that qemu treats these identically, so this change has
no functional effect.
2012-07-02 14:16:35 +01:00
Richard W.M. Jones
906f8e3ae2 appliance: Update paths to udevd.
systemd is playing a WTF game with udevd, moving it around and
renaming it unnecessarily in each release.  Chase all known locations.
2012-07-02 12:34:11 +01:00
Richard W.M. Jones
100271c7bc appliance: Update comment to note that systemd package now contains udevd. 2012-07-02 12:33:42 +01:00
Richard W.M. Jones
757b089053 Version 1.19.15. 2012-06-29 21:03:42 +01:00
Richard W.M. Jones
5489304c8d tests: Add a test of /dev/disk/by-id paths (RHBZ#627675). 2012-06-29 20:19:13 +01:00
Richard W.M. Jones
339f3647f8 tests: Use qemu-img to create an overlay for testing, instead of copying.
Replace:

  cp tests/guests/fedora.img test.img

with the longer but possibly more space-efficient equivalent:

  qemu-img create -F raw -b tests/guests/fedora.img -f qcow2 test.qcow2
2012-06-29 20:19:13 +01:00
Richard W.M. Jones
ea8421c5d2 inspect: Check partition exists when doing fstab mapping.
If the partition name we're about to return doesn't really exist,
then don't perform the mapping.
2012-06-29 20:19:13 +01:00
Richard W.M. Jones
7eaa99994e inspect: Guess device name from /dev/disk/by-id/*-partN path (RHBZ#627675).
See https://bugzilla.redhat.com/show_bug.cgi?id=836573#c3
for an explanation.

Useful function 'is_partition' shows how to tell if a device name
represents a partition.
2012-06-29 20:19:09 +01:00
Richard W.M. Jones
47b8225b05 inspect: Refactor resolve_fstab_device code into multiple functions.
This is mostly code motion, although it also fixes a memory leak in an
extremely rare failure case, and it generally tidies up the existing
code.
2012-06-29 19:04:21 +01:00
Richard W.M. Jones
152b179a19 New API: guestfs_nr_devices
This returns the number of whole block devices added.  It is usually
simpler to call this than to list the devices and count them, which
is what we do in some places in the current codebase.
2012-06-29 19:04:21 +01:00
Richard W.M. Jones
cba4916909 ruby: Fix detection of library (thanks Hilko Bengen).
On Debian, the Ruby C extensions library isn't '-lruby', it's
something like '-lruby1.8' or '-lruby-1.9.1' and these can even be
parallel-installed.

Fix detection so we use Ruby's own rbconfig.rb file to find the right
library to use.
2012-06-29 14:54:44 +01:00
Richard W.M. Jones
b07d096882 ruby: Changing spacing in configure file.
No functional change.
2012-06-29 14:54:05 +01:00
Richard W.M. Jones
b9f858e5ee ruby: Remove useless AC_SUBST in configure file. 2012-06-29 14:18:10 +01:00
Richard W.M. Jones
a176f508cb Update API support from tarballs. 2012-06-28 17:19:14 +01:00
Richard W.M. Jones
27efd99ddb tests: Reformat TESTS_ENVIRONMENT so all use a standard format.
No functional change.
2012-06-28 13:49:32 +01:00
Richard W.M. Jones
2f1a602c4b python: Set PYTHON in run script. 2012-06-28 13:47:35 +01:00
Richard W.M. Jones
04a533ca8c ocaml: Set CAML_LD_LIBRARY_PATH in run script. 2012-06-28 13:46:31 +01:00
Richard W.M. Jones
e7d2d3cb89 ruby: Use run --tests for tests. 2012-06-28 13:41:40 +01:00
Richard W.M. Jones
8439e97f76 java: Use run --tests for tests.
Java-specific environment variables are set in the run script.
2012-06-28 13:40:33 +01:00
Richard W.M. Jones
1b56aedc2b gobject: Use run --test for tests, and set GJS in run script. 2012-06-28 13:35:55 +01:00
Richard W.M. Jones
2d56e5af90 run: Rearrangement and add comments.
No functional change.
2012-06-28 13:32:53 +01:00
Richard W.M. Jones
927ef14c58 run: Set MALLOC_PERTURB_ to a random value.
MALLOC_PERTURB_ is a glibc feature which causes malloc to wipe memory
before and after it is used, allowing both use-after-free and
uninitialized reads to be detected with relatively little performance
penalty:

  http://udrepper.livejournal.com/11429.html?nojs=1

Modify the ./run script so that it always sets this.

We were already using MALLOC_PERTURB_ in most tests.  Since ./run is
now setting this, we can remove it from individual Makefiles.  Most
TESTS_ENVIRONMENT will now simply look like this:

  TESTS_ENVIRONMENT = $(top_builddir)/run --test
2012-06-28 13:19:39 +01:00
Richard W.M. Jones
b3df3ba5c8 Version 1.19.14. 2012-06-28 08:56:18 +01:00
Richard W.M. Jones
cadfab1a20 tests: Fix 'run --test' so it cleans up its temporary file.
This fixes commit 05d4e07918.
2012-06-27 16:34:23 +01:00
Richard W.M. Jones
1d17a6e9d8 Ensure #include <config.h> occurs in every C file. 2012-06-27 15:49:06 +01:00
Richard W.M. Jones
6777425636 src/actions.c: Include <config.h> in this generated file.
On RHEL 5, because _GNU_SOURCE was not defined, open_memstream was not
being declared, resulting in miscompilation and a segfault in the
trace code whenever open_memstream returned a pointer >= 0x80000000
(which would be truncated to a 32 bit int and then sign-extended).
2012-06-27 15:37:03 +01:00
Richard W.M. Jones
6afb7336e3 gobject: bindtests: gjs exception behaviour changed, fix test.
When libguestfs calls 'error (g, "error")', gjs in F17 throws
error.message == "Error invoking Guestfs.test0rinterr: error"

In F18, error.message is simply the string "error".

Fix the test so it works for both cases.
2012-06-27 10:55:59 +01:00
Richard W.M. Jones
b3a5403cda Version 1.19.13. 2012-06-26 23:49:00 +01:00
Richard W.M. Jones
2eacd4a191 fuse: Use the ./run --test script to run tests. 2012-06-26 23:43:06 +01:00
Richard W.M. Jones
05d4e07918 tests: Add ./run --test option.
This option, when added via
  TESTS_ENVIRONMENT = [...] $(top_builddir)/run --test
allows us to run the tests and only print the full output (including
debugging etc) when the test fails.
2012-06-26 23:34:30 +01:00
Richard W.M. Jones
bbb7d75c91 ./run: Fix indenting for shell script. 2012-06-26 23:00:29 +01:00
Richard W.M. Jones
0977c8408a ocaml: Allow parallel mount-local test to be skipped.
FUSE is not very reliable on RHEL 5.
2012-06-26 18:39:05 +01:00
Richard W.M. Jones
8d88b06277 FAQ: Add Gentoo (thanks Agostino Sarubbo). 2012-06-26 17:46:05 +01:00
Richard W.M. Jones
eb8eb3b9d5 Version 1.19.12. 2012-06-26 15:32:36 +01:00
Richard W.M. Jones
c87956837e launch: Avoid double-close when qemu exits early.
The stdin and stdout of the qemu process are aliased to g->fd:

  g->fd[0] = wfd[1];
  g->fd[1] = rfd[0];

However if the child exits early, then child_cleanup closes g->fd[0],
g->fd[1], AND the code at the cleanup1 label closes wfd[1], rfd[0],
resulting in a double-close.

Avoid this case by setting wfd[1], rfd[0] to -1.  In the cleanup1
label, only close wfd[1], rfd[0] if they are not -1, and add the same
for g->fd[0], g->fd[1].
2012-06-26 14:53:33 +01:00
Richard W.M. Jones
9e221e55b6 launch: Ensure errno from test_qemu_cmd is captured and printed. 2012-06-26 13:38:57 +01:00
Richard W.M. Jones
11317b5d12 launch: Set g->sock = -1 to avoid double-close.
This fixes commit ef5c02c6ee.
2012-06-26 13:31:58 +01:00
Richard W.M. Jones
ef5c02c6ee launch: Log errors from close syscall. 2012-06-26 11:50:12 +01:00
Richard W.M. Jones
90d0beb3c5 tests: Add thread IDs to test of bug 790721. 2012-06-26 09:17:56 +01:00
Richard W.M. Jones
8fc2127975 sysprep: Don't check for /dev/fuse before running the test.
The program doesn't actually require FUSE when used without
any --script options.
2012-06-25 15:21:32 +01:00
Richard W.M. Jones
f27770e141 fish: Allow mount-local test to be skipped with environment variable.
The test uses FUSE, so we need a way to disable it on RHEL 5.
2012-06-25 15:21:32 +01:00
Richard W.M. Jones
2afa0eeb90 tests: Allow SELinux tests to be skipped with an environment variable. 2012-06-25 15:21:32 +01:00
Richard W.M. Jones
030e318049 Version 1.19.11. 2012-06-25 11:29:16 +01:00
Richard W.M. Jones
729bb9c6b5 launch: Treat /dev/null specially, for old KVM.
Old KVM can't add /dev/null readonly.  Treat /dev/null as a special
case.

We also fix a few tests where /dev/null was being used with
format=qcow2.  This was always incorrect behaviour, but qemu appears
to tolerate it.
2012-06-25 11:20:35 +01:00
Richard W.M. Jones
78a515ec4a lib: Remove obsolete NETWORK, ROUTER definitions in header file.
These haven't been used since we switched over to virtio-serial.
2012-06-25 09:02:18 +01:00
Richard W.M. Jones
a0a86484be Version 1.19.10. 2012-06-22 22:06:30 +01:00
Richard W.M. Jones
461455ca7c tests/xml: Fix compilation of test on RHEL 5 with old libvirt.
Old <libvirt.h> had a conflicting definition of virDomainGetXMLDesc:

fake_libvirt_xml.c:36: error: conflicting types for 'virDomainGetXMLDesc'
/usr/include/libvirt/libvirt.h:715: error: previous declaration of 'virDomainGetXMLDesc' was here

The difference is not material ('int' vs. 'unsigned int').

Avoid the error by not including <libvirt.h>.
2012-06-22 13:18:58 +01:00
Richard W.M. Jones
9e7644346d tests: Add workaround for missing O_CLOEXEC. 2012-06-22 13:18:52 +01:00
Richard W.M. Jones
35882ba977 tests: Fix broken workarounds for missing O_CLOEXEC. 2012-06-22 13:18:49 +01:00
Richard W.M. Jones
ef1514aa1e test-virt-resize: Replace truncate with guestfish sparse.
Another instance of 'truncate' command.

See commit 39df80dcc0 for an
explanation.
2012-06-22 13:18:43 +01:00
Richard W.M. Jones
4d3ec25b47 part-get-bootable: Fix when partitions are missing or unordered (RHBZ#602997).
The original fix for this in
commit 511c82df46 was not complete, in
that it did not fix the case of the old (pre '-m' option) parted.
This doesn't matter for Fedora, but it matters for RHEL 5 which has
this ancient parted.
2012-06-22 11:30:00 +01:00
Richard W.M. Jones
8098d062b4 ruby: Add a replacement rb_hash_lookup function for Ruby 1.8.5.
This function was first added to Ruby in 1.8.7.
2012-06-22 11:29:57 +01:00
Richard W.M. Jones
823ba05ebd ruby: Fix libruby test.
If -lruby was not available, this used to define HAVE_LIBRUBY=0.
However this meant that the later test -n "$HAVE_LIBRUBY" would
be successful, whereas it should fail in this case.
2012-06-22 10:58:00 +01:00
Richard W.M. Jones
6cb74d46ba virt-format: Don't call wipefs unless API is available.
This API is optional.  Don't call it unless it's available
in the appliance.
2012-06-22 10:57:55 +01:00
Richard W.M. Jones
145f35badf tests: Add SKIP_TEST_* variables to allow these tests to be skipped.
By setting these variables, we can skip tests that fail on
RHEL 5.
2012-06-22 10:57:47 +01:00
Richard W.M. Jones
6352953ea9 FAQ: Mention update-guestfs-appliance (thanks Steven Dake). 2012-06-19 08:31:45 +01:00
Richard W.M. Jones
489da3ccdf build: Workaround for AC_PROG_SED not existing.
This didn't exist on ancient autoconf in RHEL 5.
2012-06-18 23:00:43 +01:00
Richard W.M. Jones
bc7f1a5ef1 build: Define abs_builddir if not defined already.
This is missing on RHEL 5.

This updates commit 50aa9533e4.
2012-06-18 21:45:13 +01:00
Richard W.M. Jones
baee3f52ef Version 1.19.9. 2012-06-18 16:33:15 +01:00
Richard W.M. Jones
d7c9c6a0d9 fuse: Skip 'truncate' tests if this command is missing. 2012-06-18 15:33:10 +01:00
Richard W.M. Jones
39df80dcc0 tests: Replace truncate command with 'guestfish sparse'.
RHEL 5 didn't have the truncate command, but we can replace:

  truncate -s SIZE FILE

with the roughly equivalent command:

  guestfish sparse FILE SIZE
2012-06-18 15:33:04 +01:00
Richard W.M. Jones
4846b84476 fuse: Add replacement for fuse_opt_add_opt_escaped.
RHEL 5-era FUSE didn't have this function.

I copied the function out of upstream FUSE, since the license is
compatible.
2012-06-18 15:32:52 +01:00
Richard W.M. Jones
50aa9533e4 build: Define builddir and abs_srcdir when they are missing.
RHEL 5-era autoconf did not define these, so define them manually
when they are missing.

Define builddir as '.'  The scripts require this.  It won't work
in the srcdir != builddir case, but we don't care about that for
RHEL 5.

This commit also moves the builddir / abs_srcdir variable setting
above the include of subdir-rules.mk, in case that include uses
these variables.

Useful script:

  for f in $(find -name Makefile.am | xargs fgrep '$(abs_srcdir)' -l) ; do
    if ! grep -q '^abs_srcdir' $f; then
      echo missing in $f
    fi
  done
2012-06-18 15:32:47 +01:00
Richard W.M. Jones
dd216fedbd ocaml: Use OCAMLOPTFLAGS when compiling .cmx (ie. native code) files. 2012-06-18 15:32:38 +01:00
Richard W.M. Jones
87de366701 configure: Look for mkisofs as well as genisoimage.
For our purposes, the two tools are compatible.
2012-06-18 15:32:12 +01:00
Richard W.M. Jones
60a2f8706b Ignore .gdb_history file. 2012-06-14 17:37:11 +01:00
Richard W.M. Jones
7b1cd65c44 ppc64: is_openable function needed on all platforms now.
This fixes commit 295d6af48d.
2012-06-14 17:36:17 +01:00
Richard W.M. Jones
cd6005128d Version 1.19.8. 2012-06-14 16:21:09 +01:00
Richard W.M. Jones
81ee155b9d tests: Add tests for extended attrs and SELinux, direct and via FUSE.
Note that the SELinux + FUSE test is disabled because of:

https://bugzilla.redhat.com/show_bug.cgi?id=811217
https://bugzilla.redhat.com/show_bug.cgi?id=812798#c42
2012-06-14 16:12:57 +01:00
Richard W.M. Jones
abbace6888 virtio-scsi: Increase udev timeout.
In Koji, when you've got 200+ disks, udev times out before all the
udev events have been processed.
2012-06-14 14:22:07 +01:00
Richard W.M. Jones
d43e3d63de virt-edit: Document CVE-2012-2690. 2012-06-14 12:25:06 +01:00
Richard W.M. Jones
199cc2853c Require febootstrap >= 3.17. 2012-06-14 09:57:28 +01:00
Richard W.M. Jones
8b15fb3e22 Version 1.19.7. 2012-06-13 23:25:50 +01:00
Richard W.M. Jones
4c828dc568 tests: Add a test which adds the maximum number of disks and uses them. 2012-06-13 23:17:13 +01:00
Richard W.M. Jones
8735e92a1d virt-df: Use guestfs_max_disks instead of hard-coding limit of 25.
And comprehensively fix it so it works with > 26 disks.
2012-06-13 23:07:26 +01:00
Richard W.M. Jones
a9d7d044f5 New API: device-index.
This returns the index of the device, eg. /dev/sdb => 1.
Or you can think of it as the order that the device was
added, or the index of the device in guestfs_list_devices.
2012-06-13 23:07:26 +01:00
Richard W.M. Jones
46ed232dc2 New API: guestfs_canonical_device_name.
This API makes device names canonical, eg. /dev/vda1 -> /dev/sda1.
2012-06-13 23:07:26 +01:00
Richard W.M. Jones
998ebc333d lvm-filter: Make it work with > 26 devices.
Thanks Alasdair Kergon.
2012-06-13 23:07:26 +01:00
Richard W.M. Jones
c0a087b823 daemon: Fix order of devices in guestfs_list_devices when > 26 disks.
Sort the device names correctly, not just treating them as
strings.  As a result, /dev/sdz < /dev/sdaa.
2012-06-13 22:10:36 +01:00
Richard W.M. Jones
4165e28b53 New API: guestfs_max_disks.
Returns the maximum number of disks that may be added to a handle.
2012-06-13 22:05:45 +01:00
Richard W.M. Jones
919b7e3f6c Update documentation on maximum number of disks. 2012-06-13 22:05:44 +01:00
Richard W.M. Jones
cef979b289 appliance: Add lsscsi to package list. 2012-06-13 22:05:44 +01:00
Richard W.M. Jones
dbd489f95d virtio-scsi: Fix disk name calculation.
This fixes commit 0c0a7d0d86.
2012-06-13 22:05:39 +01:00
Richard W.M. Jones
69e2616b6c Require febootstrap >= 3.16. 2012-06-13 11:27:50 +01:00
Richard W.M. Jones
6e981fe586 Version 1.19.6. 2012-06-12 23:04:16 +01:00
Richard W.M. Jones
320adf4778 tests/md: Don't hard code /dev/vda in expected output of tests.
Use a small sed script to canonicalize the device names.
2012-06-12 22:31:28 +01:00
Richard W.M. Jones
9a5c0d3908 tests: Fix spelling in comment. 2012-06-12 22:31:28 +01:00
Richard W.M. Jones
7509cdf18e tests/lvm: Don't hard-code /dev/vda in test.
Hard-coding it breaks virtio-scsi because the devices are called
/dev/sda etc.
2012-06-12 22:31:05 +01:00
Richard W.M. Jones
62c5b6db58 daemon: Always pass -F option to mke2fs.
Apparently e2fsprogs only knows that "/dev/sda" is a whole device, but
doesn't think that "/dev/vda" is.  On switching the default device
over to virtio-scsi, that causes mke2fs without -F option to complain
and ask for an interactive prompt.  Adding -F forces it to go ahead
anyway.

This caused several less-used APIs to break with virtio-scsi.
2012-06-12 21:16:35 +01:00
Richard W.M. Jones
0c0a7d0d86 appliance: Add support for virtio-scsi.
This requires febootstrap >= 3.15.
2012-06-12 21:16:32 +01:00
Richard W.M. Jones
e0b5ecc801 Record output of qemu -device '?'.
This allows us to find out what qemu devices are supported
at runtime.
2012-06-12 19:19:03 +01:00
Richard W.M. Jones
295d6af48d Require QEMU >= 1.0.
QEMU 1.0 was released at the end of 2011.

Remove all the cruft about detecting broken -machine type which
was only required for QEMU 0.15.

This also reverts commit 30ecbf3ec2.
Even on ARM you can pass -machine accel=kvm:tcg and qemu does the
right thing, so I'm not sure why we wanted to disable that.
2012-06-12 16:02:10 +01:00
Richard W.M. Jones
7652b5aece Remove ./configure --with-drive-if and --with-net-if options.
These were used to select the default drive and network interface.
They both default to 'virtio'.

These were added back in the day when virtio was buggy, so that
packagers could revert to using ide/ne2k_pci to work around distro
bugs.  However virtio has been stable in qemu for a very long time, so
it seems unlikely that any packager would need to use these, and in
any case it would be better to do this detection at runtime (cf. for
virtio-scsi).
2012-06-12 14:52:21 +01:00
Richard W.M. Jones
7590924022 New API: fstrim - allow filesystem trim. 2012-06-12 14:33:57 +01:00
Richard W.M. Jones
668a0cebdf Version 1.19.5. 2012-06-09 22:00:46 +01:00
Richard W.M. Jones
251b131e0a tests: Allow regression test for bug 690819 to be skipped. 2012-06-09 21:13:09 +01:00
Richard W.M. Jones
42475dd21f blockdev_getbsz: Remove test.
The output of this test depends on page size, so on ppc64
it returns 64K.
2012-06-09 20:50:25 +01:00
Richard W.M. Jones
20137c8731 fish: Change test-escapes so test is not endian-sensitive.
The test used the external 'od' command to compare the output of
guestfish with what it's supposed to be.  Unfortunately by default
this outputs groups of 2-byte words, with the words' endianness
affected by the current hardware endianness.  For example:

x86-64$ echo -n ab | od
0000000 061141
0000002

ppc64$ echo -n ab | od
0000000 060542
0000002

By using 'od -b' instead we can output bytes instead of words, and
there is no endianness issue, and the output is clearer:

x86-64$ echo -n ab | od -b
0000000 141 142
0000002

ppc64$ echo -n ab | od -b
0000000 141 142
0000002
2012-06-09 20:18:09 +01:00
Richard W.M. Jones
ac2f9a42fb btrfs: Modify test to correctly detect btrfs availability. 2012-06-09 14:52:39 +01:00
Richard W.M. Jones
011666ae77 btrfs: Modify btrfs availability to test if the kernel supports btrfs.
This is closer to the real meaning of "availability of btrfs", since
just having the btrfs tool doesn't help much if it's not supported by
the kernel too.
2012-06-09 14:52:39 +01:00
Richard W.M. Jones
4ba6aa3eae New API: filesystem-available: tests for filesystem availability.
This also creates an internal filesystem_available function within the
daemon.
2012-06-09 14:52:39 +01:00
Richard W.M. Jones
4f671c829e ppc64: Update README with notes about ppc64 support. 2012-06-08 19:36:34 +01:00
Hilko Bengen
6cf15e8841 out-of-tree build/install fix for translations 2012-06-08 01:24:39 +02:00
Richard W.M. Jones
52af9a88b8 Version 1.19.4. 2012-06-07 14:42:13 +01:00
Richard W.M. Jones
f90c01a5dc Enhance BUGS script.
Since RHBZ was updated, the old python-bugzilla program broke.  When
it was fixed, I found the (undocumented) ordering of the results from
the old tool was no longer true.

This commit adds a small Perl script to sort the output predictably.
Now bugs are sorted by both bug state and bug number, so the output
should be more stable than before.

Re-enable creation of the BUGS file in 'make dist'
(this reverts commit 91f3456244).

Also the BUGS file has been updated.
2012-06-07 09:21:23 +01:00
Richard W.M. Jones
4e5d3b06fb arm: Use #if defined instead of #ifdef.
No functional change.
2012-06-06 23:09:47 +01:00
Richard W.M. Jones
1bdfc88eba ocaml: Fix parameters to ocaml_guestfs_create.
The first parameter (not used) is a unit, so declare it properly.
2012-06-06 13:42:17 +01:00
Richard W.M. Jones
450493cf6b ppc64: Avoid "defined by not used" warning for is_openable function. 2012-06-02 10:35:06 +01:00
Richard W.M. Jones
bbb21f923a Version 1.19.3. 2012-05-31 23:24:22 +01:00
Hilko Bengen
3893dc0b94 Split off GObject tests that require an appliance 2012-05-28 20:01:47 +02:00
Hilko Bengen
148e806826 Fix out-of-tree build for GObject bindings 2012-05-28 20:01:47 +02:00
Richard W.M. Jones
bcbb6bb760 xattr: Refuse to set or get oversized extended attributes.
See:
https://www.redhat.com/archives/libguestfs/2012-May/msg00152.html
2012-05-28 17:55:07 +01:00
Richard W.M. Jones
a7868dd3c9 appliance: 'udevd' has been renamed, since it joined systemd. 2012-05-28 16:09:40 +01:00
Richard W.M. Jones
a7e4a6c692 appliance: Move udev (common package name) to the common section.
This should be just code motion.
2012-05-28 10:01:45 -04:00
Richard W.M. Jones
a81165eb00 Version 1.19.2. 2012-05-27 21:53:21 +01:00
Richard W.M. Jones
42dd5fa5b9 Update to latest gnulib. 2012-05-26 23:07:03 +01:00
Richard W.M. Jones
fe68cd77cb Version 1.19.1. 2012-05-25 16:52:19 +01:00
Richard W.M. Jones
8e8a576429 tests: Add a test of non-ASCII character fidelity on various filesystem types (RHBZ#823887).
Thanks Laszlo Ersek.
2012-05-25 16:38:54 +01:00
Richard W.M. Jones
6445bc5952 doc: Add documentation covering use of utf8 option when mounting vfat (RHBZ#823887). 2012-05-25 15:46:26 +01:00
Richard W.M. Jones
73071b3163 trace: Fix display of non-printing characters.
Previously the code would drop the first character in any sequence of
non-printing characters that occurred within a string.

Fix for commit e6f18c59d5.
2012-05-25 15:46:18 +01:00
Richard W.M. Jones
fba81add94 trace: Fix escaping of non-printable signed characters.
Fix for commit e6f18c59d5.
2012-05-25 15:46:08 +01:00
Wanlong Gao
3936412e33 sysprep: remove the data and log files of puppet
Remove the data(keys) and log files of puppet.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-05-25 08:34:03 +01:00
Richard W.M. Jones
f00066d22b inspection: Don't fail if /etc/HOSTNAME or /etc/hostname are empty files (RHBZ#823821).
Change guestfs___first_line_of_file so that if the file is empty this
returns an empty string instead of an error.  This is consistent with
the behaviour of this function in the case where the file starts with
a \n character, where it would previously have returned an empty
string.

Change all callers so that they handle this case.

Then change the hostname parsing code so that it doesn't give up when
/etc/HOSTNAME is empty, but falls through to the next alternative, and
similarly for /etc/hostname.

Thanks Todd Mummert for finding and diagnosing this bug.
2012-05-24 15:40:36 +01:00
Richard W.M. Jones
cffb7fefc8 inspection: Use parse_release_file to parse ttylinux release file.
parse_release_file should be used to set fs->product_name, instead of
calling guestfs___first_line_of_file directory, although currently the
two are equivalent.

This is code motion and fixes
commit b648b1813f.
2012-05-24 15:38:46 +01:00
Richard W.M. Jones
ee9ab52bc3 fish/mount: Add better error message when -m (mount) fails (RHBZ#824043). 2012-05-24 14:54:54 +01:00
Richard W.M. Jones
216a6d16ab fish: Remove inaccurate comment from code. 2012-05-24 14:50:00 +01:00
Richard W.M. Jones
d5d9ceee8b virt-make-fs: When writing vfat, add utf8 option to mount (RHBZ#823885). 2012-05-24 14:40:52 +01:00
Richard W.M. Jones
975a41db20 virt-make-fs: Provide a clearer error message when mkfs fails (RHBZ#823883). 2012-05-24 12:30:50 +01:00
Richard W.M. Jones
f904fa8223 appliance: Include 'bzip2' in appliance (RHBZ#824716).
Missing package caused this error in compress-device-out:

libguestfs: error: compress_device_out: compression type bzip2 is not supported

Thanks Mohua Li.
2012-05-24 08:48:51 +01:00
Richard W.M. Jones
b8b5ed65c2 FAQ: Add section about using libguestfs in closed source programs. 2012-05-23 11:46:23 +01:00
Richard W.M. Jones
144d7cd988 FAQ: Add a note about "child process died unexpectedly".
This is a common search term on the main website, and there is no good
information provided by Google at present.
2012-05-23 11:19:34 +01:00
Richard W.M. Jones
c7d3aa9cd6 FAQ: Update Ubuntu instructions. 2012-05-23 11:16:19 +01:00
Wanlong Gao
0e05e9f6ce TODO: sysprep todo list clearance
Remove the implemented features from TODO list.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-05-22 15:34:01 +01:00
Richard W.M. Jones
54028b9b66 java: Remove unnecessary imports from the generated Java code. 2012-05-22 14:55:50 +01:00
Richard W.M. Jones
87d604f88c debug: Add setenv debugging command. 2012-05-22 13:50:19 +01:00
Richard W.M. Jones
f774f8fd8d Version 1.19.0. 2012-05-21 16:27:04 +01:00
Richard W.M. Jones
1f3b8b395b New stable branch: Version 1.18.0. 2012-05-21 16:18:41 +01:00
Richard W.M. Jones
91f3456244 build: Temporarily disable generation of 'BUGS' file.
Red Hat Bugzilla is broken: RHBZ#823510.
2012-05-21 15:24:32 +01:00
Richard W.M. Jones
d51631034a Update API support. 2012-05-21 14:35:07 +01:00
Richard W.M. Jones
695b3c9633 Update PO files from Transifex. 2012-05-21 14:34:46 +01:00
Richard W.M. Jones
27b9c1c755 Update road map for 1.18 branch. 2012-05-21 14:18:43 +01:00
Richard W.M. Jones
d1f6325e10 Update release notes for 1.18 branch. 2012-05-21 14:16:58 +01:00
Richard W.M. Jones
a119e057d1 sysprep: Credit Wanlong Gao, Fujitsu under 'AUTHORS' section. 2012-05-18 11:15:39 +01:00
Wanlong Gao
f5e0c0e3ee sysprep: remove kerberos data in the guest
Remove the generated kerberos data in the guest.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-05-18 11:12:07 +01:00
Wanlong Gao
b6d4c29212 sysprep: remove ca certificates in the guest
Remove the ca certificates.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-05-18 11:12:03 +01:00
Richard W.M. Jones
020e7aa505 Version 1.17.43. 2012-05-17 19:52:03 +01:00
Richard W.M. Jones
88a854cf7f virt-ls: Don't initialize path = NULL. 2012-05-17 17:19:09 +01:00
Richard W.M. Jones
32765e440c virt-ls: Fix --checksum option (RHBZ#822490). 2012-05-17 17:11:16 +01:00
Wanlong Gao
b9331a2d73 NEW API: add new api btrfs-fsck
Add the new API btrfs-fsck to check the btrfs filesystem.
Btrfs is currently under heavy development, and not suitable for
any uses other than benchmarking and review. But it'll be useful
in the near future.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-05-15 16:07:45 +01:00
Wanlong Gao
a84d02e8d8 btrfs: change the return value of btrfs-set-seeding
Change the return value from "r" to "0".

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-05-15 16:04:22 +01:00
Wanlong Gao
e9f6ce2492 gobject: remove old generated files further
also remove guestfs-gobject.c

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-05-15 09:13:12 +01:00
Richard W.M. Jones
7fffaf204e gobject: Remove old generated files. 2012-05-15 08:38:46 +01:00
Richard W.M. Jones
2040a15ac7 sysprep: Add missing 'utils.mli' to SOURCES.
Consequently this file was also missing from the tarball.
2012-05-14 23:03:54 +01:00
Richard W.M. Jones
2fd2c85f6a doc: Add notes on how GPT works on 4k sector disks.
I used scsi_debug to create a 4k sector virtual disk:

  modprobe scsi_debug dev_size_mb=128 sector_size=4096

I then used 'gdisk' to create lots of partitions, and used 'hexdump'
to examine what was written to disk.
2012-05-14 17:47:57 +01:00
Richard W.M. Jones
e8ec521dc6 todo: Notes about partitioning tools. 2012-05-14 15:33:21 +01:00
Wanlong Gao
18451abdf5 New API: add new api btrfs-set-seeding to enable or disable seeding.
Add the new API btrfs-set-seeding to support the seeding-device
feature for btrfs.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-05-14 13:21:53 +01:00
Wanlong Gao
a75020a066 TODO: add note for libblkid
Add the note about compatible in TODO for libblkid.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-05-14 13:13:32 +01:00
Richard W.M. Jones
b42dcb05dc examples: Further fixes to mount-local example program.
* Set PS1 prompt properly for bash shells.
* Touch a file into the root directory of the new filesystem.

This fixes commit 46b6766156.
2012-05-14 12:19:31 +01:00
Richard W.M. Jones
2c50a5da46 example: Various fixes to mount-local example program.
* Move MOUNT_OPTIONS to #define at top.
* Move SIZE_MB to #define at top.
* Set PS1 in subshell (doesn't work - why?).
* Hide libguestfs errors from guestfs_mount_local_run.

This fixes commit 46b6766156.
2012-05-14 10:49:16 +01:00
Richard W.M. Jones
a219fede92 debian: examples: Don't break when O_CLOEXEC is not defined.
This affected Debian 6.

This fixes commit 46b6766156.
2012-05-14 10:24:53 +01:00
Richard W.M. Jones
9cf19466f0 Version 1.17.42. 2012-05-13 23:18:44 +01:00
Richard W.M. Jones
034733e981 examples: Add mount options "acl,user_xattr" to mount-local example.
This fixes commit 46b6766156.
2012-05-13 23:01:15 +01:00
Richard W.M. Jones
46b6766156 examples: Add an example of using the mount-local API from C. 2012-05-13 22:53:01 +01:00
Richard W.M. Jones
7201a48d18 examples: Add if HAVE_HIVEX ... endif around virt_dhcp_address example. 2012-05-13 22:20:32 +01:00
Richard W.M. Jones
157f6fb18b qemu: Move -nodefaults etc logically together.
This is just code motion.
2012-05-12 17:22:36 +01:00
Richard W.M. Jones
eb29a9424c arm: Add configure flag '--with-qemu-options'.
This flag allows extra QEMU options to be passed on the command line.

This is useful mainly on arm (see the notes in the updated README
file).
2012-05-12 17:21:24 +01:00
Richard W.M. Jones
30ecbf3ec2 arm: Disable -machine, -enable-kvm options except on x86, x86-64.
Presently KVM is only applicable to x86 and x86-64 (although that will
change in future, and there are rumoured to be implementations for
some current non-x86 architectures).  In any case having these options
breaks ARM, so disable them for non-x86 architectures at the moment.
2012-05-12 16:59:48 +01:00
Richard W.M. Jones
10725acf96 arm: On Linux ARM kernels, the serial console is ttyAMA0.
Cope with unnecessary lack of standardization.
2012-05-12 16:59:48 +01:00
Richard W.M. Jones
5c59790845 arm: Disable test for -no-hpet during launch. 2012-05-12 16:59:48 +01:00
Richard W.M. Jones
a3718c6b8b arm: Set minimum LIBGUESTFS_MEMSIZE at 128.
For ARM Versatile ("versatilepb") architecture, memsize must be set to
256 (megabytes) else the appliance is unable to boot.  Previously
setting LIBGUESTFS_MEMSIZE=256 was not allowed.

Versatile Express has larger limits.
2012-05-12 16:59:48 +01:00
Richard W.M. Jones
77afc92fcd configure: Fix valgrind --vgdb test. 2012-05-12 16:59:48 +01:00
Richard W.M. Jones
0e960614ab configure: Add a comment about vmchannel_test. 2012-05-12 16:59:47 +01:00
Richard W.M. Jones
e275786cb2 Version 1.17.41. 2012-05-11 14:20:23 +01:00
Richard W.M. Jones
a50db3be60 doc: Add a note about compiling under clang. 2012-05-11 13:50:56 +01:00
Richard W.M. Jones
a1680f03b7 configure: Allow systemtap/DTrace userspace probes to be disabled.
'./configure --disable-probes' will disable these probes.  Otherwise
they are autodetected as before.

The <sys/sdt.h> produces lots of errors when you try to compile with
these probes enabled under clang, so it is necessary to provide a way
to disable them for clang users.
2012-05-11 13:47:29 +01:00
Richard W.M. Jones
042a0b063b FAQ: Fix typo in download (thanks badnews@IRC) 2012-05-10 23:00:31 +01:00
Wanlong Gao
1581dbe79f sysprep: remove blkid tab in the guest
Remove blkid tab cache in the guest.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-05-10 16:27:59 +01:00
Richard W.M. Jones
5647567826 configure: Replace 'echo -n' with 'AS_ECHO_N' macro (thanks Eric Blake). 2012-05-09 16:29:39 +01:00
Richard W.M. Jones
7b72c12428 Update to latest gnulib. 2012-05-09 16:13:57 +01:00
Richard W.M. Jones
5764ac12cf bootstrap: Remove autopoint, po stuff from bootstrap script.
It's not needed since we no longer use gettextize cruft.
2012-05-09 16:13:57 +01:00
Richard W.M. Jones
d0ec0b4c8c Version 1.17.40. 2012-05-08 22:58:05 +01:00
Richard W.M. Jones
af1439bc9f Updated PO files from Transifex. 2012-05-08 17:32:49 +01:00
Wanlong Gao
a79b22a613 sysprep: remove pam data
Remove the generated pam data in the guest.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-05-08 12:31:12 +01:00
Richard W.M. Jones
dd23234f73 test-tool: Implement -V / --version option. 2012-05-05 14:55:03 +01:00
Richard W.M. Jones
3ea36903f2 Update API support. 2012-05-03 18:05:32 +01:00
Richard W.M. Jones
eaa05ff012 Version 1.17.39. 2012-05-03 16:50:25 +01:00
Richard W.M. Jones
e0f36898cb virt-df: Don't fail immediately if a disk is not accessible (RHBZ#789504). 2012-05-03 15:38:08 +01:00
Richard W.M. Jones
bd91bd76d1 virt-alignment-scan: Don't fail immediately if a disk is not accessible (RHBZ#789504). 2012-05-03 15:37:59 +01:00
Richard W.M. Jones
9e2cdd309b virt-alignment-scan, virt-df: Add newlines after error messages. 2012-05-03 15:23:14 +01:00
Richard W.M. Jones
a2cc317c03 virt-make-fs: Add a test of btrfs (regression test for RHBZ#816098). 2012-05-03 14:32:25 +01:00
Richard W.M. Jones
c53ea071c6 virt-make-fs: Simplify test code.
This is just code motion.
2012-05-03 14:32:24 +01:00
Richard W.M. Jones
0cc3525142 virt-make-fs: Fix estimation when making btrfs (RHBZ#816098).
This also disables data and metadata duplication, which is not very
useful on a constructed filesystem on a virtual disk.
2012-05-03 14:32:24 +01:00
Richard W.M. Jones
93734c78d8 virt-make-fs: Use mount instead of mount_options. 2012-05-03 14:32:24 +01:00
Richard W.M. Jones
e60556d927 virt-make-fs: Fix filesystem type check when estimating ntfs. 2012-05-03 14:32:24 +01:00
Richard W.M. Jones
00202b9c29 tests: Regression test for RHBZ#701814.
This commit adds a tests/xml directory, and an LD_PRELOAD module which
can fake arbitrary libvirt XML from an external file (and is therefore
a much more flexible test than using the libvirt test:// driver
alone).

Also added is one regression test for:
https://bugzilla.redhat.com/show_bug.cgi?id=701814

Loading the given libvirt XML using Sys::Guestfs::Lib::open_guest
used to fail with the error:

  format parameter is empty or contains disallowed characters at /home/rjones/d/libguestfs/perl/blib/lib/Sys/Guestfs/Lib.pm line 256.

Thanks to Tom Horsley for supplying the test data.
2012-05-03 12:30:05 +01:00
Richard W.M. Jones
f072a21f3a perl: Don't fail if 'type' (disk format) attribute is missing in libvirt XML (RHBZ#701814).
Old versions of libvirt allowed you to define disks like this:

    <disk type='file' device='disk'>
      <driver name='qemu'/>
      ...

Since the <driver> element does not have a 'type' attribute (which
defines the format), we are supposed to do autodetection, so the
format should be undefined.

However what actually happened was that the code in
Sys::Guestfs::Lib::open_guest received format as an empty string from
the xpath query, causing libguestfs to give an error.

If the xpath query returns the format as an empty string, undefine it.
2012-05-03 12:30:05 +01:00
Richard W.M. Jones
66a525ce5a fish: Add a regression test for the 'glob' command. 2012-05-02 16:35:43 +01:00
Richard W.M. Jones
620ad8eb1a fish: glob command now expands /dev/ patterns (RHBZ#635971).
For example:

><fs> glob echo /dev/*
/dev/vda
/dev/vda1
/dev/vda2
/dev/vda3
><fs> glob echo /dev/v*/*
/dev/vg_f16x64/lv_root
/dev/vg_f16x64/lv_swap
2012-05-02 16:33:23 +01:00
Richard W.M. Jones
79bf966cea fish: Move 'feature_available' function to global.
This is just code motion.
2012-05-02 15:34:02 +01:00
Richard W.M. Jones
29c5e052e4 fish: Clean up glob code and make it return error if malloc fails.
This commit tidies up the code for the 'glob' command.  It also makes
the command return an error if malloc fails (previously it would just
print a message but not return any error indication).
2012-05-02 14:44:54 +01:00
Richard W.M. Jones
1304236c6c fish: Add --pipe-error flag to allow detection of errors in pipe commands (RHBZ#803533).
For a test case, see:
https://bugzilla.redhat.com/show_bug.cgi?id=803533

In guestfish, we use the gnulib closeout module which sets up an
atexit handler to detect if there were any errors on stdout when the
program exits.  This is so we can fail correctly in out of disk space
cases like:

 guestfish [...] > output

However the atexit handler just checks that there was any error on
stdout (using ferror).  If a pipe command such as:

 ><fs> command_with_lots_of_output | head

ran at any time during the session, the error flag would be set
(because the underlying writes failed with EPIPE errors).

So the commit first adds a test for ferror (stdout) after each command
that we issue.  This brings error handling closer to the point of
failure, and so is generally a good thing.

Secondly we reset the error flag after detecting and dealing with the
error, so that avoids the redundant 'guestfish: write error' message
produced by gnulib closeout.

Thirdly we add a --pipe-error flag which causes guestfish commands to
fail on pipe commands line the one above.  The default is off for
backwards compatibility reasons.
2012-05-02 13:55:18 +01:00
Richard W.M. Jones
95a67b1e6a Update release notes. 2012-05-01 19:49:54 +01:00
Richard W.M. Jones
500cc67f29 Version 1.17.38. 2012-05-01 14:08:39 +01:00
Richard W.M. Jones
e6bfb55f65 Turn libguestfs FAQ into a man page: guestfs-faq(1). 2012-05-01 13:55:53 +01:00
Richard W.M. Jones
922052c70f doc: Rewrite description section in man page guestfs(3).
Make the introduction in the man page shorter and punchier, so it
leads readers directly to other pages of interest.
2012-05-01 11:18:57 +01:00
Richard W.M. Jones
51f43402f6 Version 1.17.37. 2012-05-01 09:44:10 +01:00
Richard W.M. Jones
027fefd517 Add gettext support for OCaml tools (virt-resize, virt-sparsify, virt-sysprep).
Note that this support is optional: To enable it, install the
ocaml-gettext library from
http://forge.ocamlcore.org/projects/ocaml-gettext .  If this library
is not installed, then configure detects this and inserts dummy
gettext functions that do nothing.
2012-05-01 09:39:35 +01:00
Richard W.M. Jones
75514ab57a Remove gettextize.
Replace the sociopathic nonsense in gettextize with a simple
Makefile.am which does the same ... and is faster.
2012-05-01 08:58:15 +01:00
Richard W.M. Jones
6aa95e87c1 Remove "convenience header" "gettext.h" and use <libintl.h> instead.
gettextize provides a local file called "gettext.h".  Remove this and
use <libintl.h> from glibc headers instead.

Most of this change is mechanical: #include <libintl.h> in every C
file which uses any gettext function.  But also we remove the
gettext.h file, and adjust the "_" macros.

Note that this effectively removes the ./configure --disable-nls
option, although we don't know if that ever worked.
2012-05-01 08:57:55 +01:00
Richard W.M. Jones
ea74856d95 configure: There are now more OCaml tools than just virt-resize.
virt-resize, virt-sparsify, virt-sysprep are all OCaml tools, so
change what is printed in the report.
2012-04-30 15:08:34 +01:00
Richard W.M. Jones
79822d46e3 configure: Comment fix. 2012-04-30 15:08:34 +01:00
Richard W.M. Jones
bb73cf0941 Move 'libguestfs.pc' (pkgconfig file) to src/ directory.
Since it describes the C library, it's better in the src/ directory.
2012-04-30 15:08:34 +01:00
Richard W.M. Jones
a23e84ee02 todo: virt-sparsify whitelist option. 2012-04-30 09:42:36 +01:00
Richard W.M. Jones
cc79854037 debug: 'progress' (unsupported debug command) now checks argument is reasonable (RHBZ#816839).
Thanks Yuyu Zhou.
2012-04-27 15:35:50 +01:00
Richard W.M. Jones
d448ae0c2b gobject: Fix installation of headers.
RPM build errors:
error: Installed (but unpackaged) file(s) found:
   /usr/include/optargs-add_domain.h
   /usr/include/optargs-add_drive_opts.h
   /usr/include/optargs-btrfs_filesystem_resize.h
   /usr/include/optargs-compress_device_out.h
   /usr/include/optargs-compress_out.h
   /usr/include/optargs-copy_device_to_device.h
   /usr/include/optargs-copy_device_to_file.h
   /usr/include/optargs-copy_file_to_device.h
   /usr/include/optargs-copy_file_to_file.h
   /usr/include/optargs-e2fsck.h
   /usr/include/optargs-inspect_get_icon.h
   /usr/include/optargs-md_create.h
   /usr/include/optargs-mkfs_btrfs.h
   /usr/include/optargs-mkfs_opts.h
   /usr/include/optargs-mount_9p.h
   /usr/include/optargs-mount_local.h
   /usr/include/optargs-ntfsclone_out.h
   /usr/include/optargs-ntfsfix.h
   /usr/include/optargs-ntfsresize_opts.h
   /usr/include/optargs-set_e2attrs.h
   /usr/include/optargs-test0.h
   /usr/include/optargs-tune2fs.h
   /usr/include/optargs-umount_local.h
   /usr/include/session.h
   /usr/include/struct-application.h
   /usr/include/struct-btrfssubvolume.h
   /usr/include/struct-dirent.h
   /usr/include/struct-inotify_event.h
   /usr/include/struct-int_bool.h
   /usr/include/struct-isoinfo.h
   /usr/include/struct-lvm_lv.h
   /usr/include/struct-lvm_pv.h
   /usr/include/struct-lvm_vg.h
   /usr/include/struct-mdstat.h
   /usr/include/struct-partition.h
   /usr/include/struct-stat.h
   /usr/include/struct-statvfs.h
   /usr/include/struct-version.h
   /usr/include/struct-xattr.h
   /usr/include/tristate.h

We want to put these headers into the subdirectory, but not
guestfs-gobject.h.  This isn't easy with automake.
2012-04-27 09:11:33 +01:00
Richard W.M. Jones
1f0964536b gobject: Fix whitespace in Makefile.am. 2012-04-27 09:10:33 +01:00
Wanlong Gao
23f8cab1e8 sysprep: Remove the data of dovecot
Remove the data of dovecot.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-04-27 08:51:03 +01:00
Wanlong Gao
ac75e46c5a sysprep: remove the logfiles configured by logrotate
Remove the logfiles configured by /etc/logrotate.d/*.
Omit the logfile of "samba" and "sssd" which we removed
them separately .

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-04-27 08:49:07 +01:00
Richard W.M. Jones
e493884a76 Version 1.17.36. 2012-04-26 18:03:58 +01:00
Richard W.M. Jones
819cba54e6 btrfs: Fix btrfs test so it works with btrfs-progs in Rawhide.
See: http://bugzilla.redhat.com/816346
2012-04-26 17:55:54 +01:00
Richard W.M. Jones
a505423e58 lib: Remove the BUSY state.
Originally this state was intended so that in some way you could find
out if the appliance was running a command.  However there was never a
thread-safe way to access the state of the handle, so in effect you
could never do anything useful safely with this information.

This commit completely removes the BUSY state.

The only visible change is to the guestfs_is_busy API.  Previously you
could never call this safely from another thread.  If you called it
from the same thread it would always return false (since the current
thread can't be running a libguestfs command at that point by
definition).  Now it always returns false.
2012-04-26 16:48:47 +01:00
Richard W.M. Jones
eafefab937 gobject: Use generator_built macro to ensure generated files are rebuilt properly. 2012-04-26 15:52:59 +01:00
Matthew Booth
d58cb029a3 gobject: Move headers into a subdirectory
The gobject bindings generate a large number of header files, which pollute
/usr/include when installed. This patch moves them all into a guestfs-gobject/
subdirectory. guestfs-gobject.h remains in the same place.

This change also moves generated source files into src/, because it makes the
gobject directory a bit tidier.
2012-04-26 14:02:26 +01:00
Richard W.M. Jones
317ba894b3 btrfs: Fix docs for btrfs_subvolume_set_default (thanks Matt Booth).
This fixes commit 87ea7a0409.
2012-04-26 13:55:30 +01:00
Matthew Booth
8fb67ee66a gobject: Implement libguestfs events as signals
Implement libguestfs events as GObject signals. Callback arguments are passed in
a boxed object.

Note that this patch fixes the length of the uint64_t array in the callback
arguments at 16, whereas it is actually arbitrary length. This is to make it
introspectable. There is currently no way to pass an arbitrary length array to a
callback, and have its type introspected.
2012-04-26 13:35:34 +01:00
Matthew Booth
6c88c3758b gobject: Wrap literal sections in POD in CDATA sections 2012-04-26 13:35:33 +01:00
Matthew Booth
a2dc83cf03 gobject: NFC generated code formatting fix 2012-04-26 13:35:33 +01:00
Richard W.M. Jones
8cb30dc805 rescue: Add --scratch option.
This lets you create temporary scratch disks.
2012-04-26 12:56:34 +01:00
Richard W.M. Jones
39d79e677b fish: Add opaque field to the drives list for programs to use.
Not used at present.
2012-04-26 12:56:01 +01:00
Richard W.M. Jones
2cc4314ecc Version 1.17.35. 2012-04-25 23:08:24 +01:00
Richard W.M. Jones
beaa528855 appliance: Remove some unnecessary errors.
virt-rescue prints errors such as:

  rm: cannot remove `/proc': Is a directory
  mkdir: cannot create directory `/proc': File exists
  rm: cannot remove `/sys': Is a directory
  mkdir: cannot create directory `/sys': File exists

People have reported these errors (which are nothing to worry about)
as bugs in the past, so avoid them where possible.
2012-04-25 22:58:25 +01:00
Richard W.M. Jones
2d414112f7 btrfs: Enhance the btrfs device test.
This enhances commit 87ea7a0409.
2012-04-25 19:42:26 +01:00
Richard W.M. Jones
12c5394d4c tests: Add some more substantial test data.
The two tarballs:

  8252 bytes   tests/data/filesanddirs-10M.tar.xz
 41152 bytes   tests/data/filesanddirs-100M.tar.xz

contain, as their names suggest, highly compressed files and
directories, with unpacked size respectively around 10M and 100M (the
precise size after unpacking depends on the filesystem).

These can be used for testing purposes.
2012-04-25 19:26:57 +01:00
Richard W.M. Jones
e188eb8268 btrfs-device-delete: Use correct (sysroot-prefixed) path to filesystem.
This fixes commit 87ea7a0409.
2012-04-25 19:08:56 +01:00
Richard W.M. Jones
87ea7a0409 New btrfs APIs.
Bind the easy parts of the 'btrfs' program.

The new APIs are:

btrfs-device-add: add devices to a btrfs filesystem
btrfs-device-delete: remove devices from a btrfs filesystem
btrfs-filesystem-sync: sync a btrfs filesystem
btrfs-filesystem-balance: balance a btrfs filesystem
btrfs-subvolume-create: create a btrfs snapshot
btrfs-subvolume-delete: delete a btrfs snapshot
btrfs-subvolume-list: list btrfs snapshots and subvolumes
btrfs-subvolume-set-default: set default btrfs subvolume
btrfs-subvolume-snapshot: create a writable btrfs snapshot
2012-04-25 17:32:30 +01:00
Richard W.M. Jones
3cc9703f90 btrfs: Modify mkfs-btrfs API so it takes a list of devices.
btrfs filesystems can span multiple filesystems.

Note this changes the API, but this API has not yet been released in a
stable version of libguestfs.
2012-04-25 16:33:31 +01:00
Wanlong Gao
bd1a699c15 TODO: remove sssd and samba in sysprep
remove the TODO of sssd and samba in sysprep.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-04-25 11:53:04 +01:00
Wanlong Gao
046d6c20e7 sysprep: fix typo of the object
Fix the typo of the OBJECT.
I'm sorry for the copy and paste typo.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-04-25 11:53:04 +01:00
Wanlong Gao
303b159134 sysprep: remove the db and log of samba
Remove the db and log of samba.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-04-25 11:53:01 +01:00
Wanlong Gao
580ae3297a sysprep: remove the db and log of sssd
Remove the db and log of sssd.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-04-25 11:52:56 +01:00
Richard W.M. Jones
a98d9f4840 todo: Suggest 'virt-customize' tool. 2012-04-24 19:36:33 +01:00
Richard W.M. Jones
0e49186814 todo: Debian APT cache is now removed (thanks Wanlong Gao).
This updates commit 7fc7c3aa5b.
2012-04-24 19:26:09 +01:00
Richard W.M. Jones
5fab4db8de bugs: Update BUGS file. 2012-04-24 19:24:10 +01:00
Richard W.M. Jones
d16868b938 bugs: Print count of bugs in each section. 2012-04-24 19:24:00 +01:00
Richard W.M. Jones
37a3cdbc13 generator: Add explicit types to pod memoization code.
This is just code motion.
2012-04-24 17:38:48 +01:00
Richard W.M. Jones
a2d30626cb Version 1.17.34. 2012-04-24 17:17:59 +01:00
Wanlong Gao
7fc7c3aa5b sysprep: remove the cache of package manager
Remove the cache of package manager like yum and apt.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>

RWMJ:
- Small code cleanup.
2012-04-24 08:32:08 +01:00
Wanlong Gao
95515c4576 sysprep: flag the system for reconfiguration
Flag the system for reconfiguration by touching /.unconfigured .

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>

RWMJ:
- Updated so this is disabled by default, since it requires
  user intervention at next boot.
2012-04-23 15:37:28 +01:00
Wanlong Gao
148b51fe0b sysprep: remove user accounts
Remove user accounts from /etc/passwd, /etc/group,
/etc/shadow, and the home directory of the user,
except the root user.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>

RWMJ:
- Updated to use Augeas to delete accounts.
- Disable this by default, since it is very invasive.
2012-04-23 15:37:24 +01:00
Richard W.M. Jones
7916f5d43c Version 1.17.33. 2012-04-22 23:32:21 +01:00
Richard W.M. Jones
8d41470b6f sysprep: Don't enable every option by default.
All current operations are enabled by default.

Also:

* The POD description is split into a heading and the description body.

* An 'enabled_by_default' flag is added to the structure.
2012-04-21 22:28:15 +01:00
Richard W.M. Jones
97ef9afca7 build: Change comment above OCaml tools. 2012-04-21 21:43:32 +01:00
Richard W.M. Jones
03d321d022 guests: Add /etc/shadow file to fedora.img.
This is used for testing file permissions and SELinux contexts.
2012-04-21 15:37:43 +01:00
Richard W.M. Jones
c844a38d6e tests: Space before parens in perl code. 2012-04-21 14:39:21 +01:00
Richard W.M. Jones
2152affd30 Update release notes. 2012-04-19 23:05:53 +01:00
Richard W.M. Jones
36f1eb9225 configure: Test for tgetent, tputs and 'UP' symbols (from libtinfo). 2012-04-19 10:50:44 +01:00
Jim Meyering
e97b6a1bb1 maint: fix doc typos
Fix typos spotted by http://github.com/lyda/misspell-check.
* configure.ac: As above.
* ocaml/examples/guestfs-ocaml.pod: Likewise.
* fish/guestfish.pod: Likewise.
2012-04-18 20:04:38 +01:00
Richard W.M. Jones
c253c69d09 Remove obsolete valgrind rule from C API tests. 2012-04-18 17:29:13 +01:00
Richard W.M. Jones
58a5b5bd94 extra-tests: Check if valgrind supports --vgdb=no option.
This option didn't exist in RHEL 6 valgrind.
2012-04-18 17:28:47 +01:00
Richard W.M. Jones
5d6a323b93 Check library still compiles without libvirt. 2012-04-18 14:25:15 +01:00
Richard W.M. Jones
b0b5fdc69f sparsify: Add a note about sparsify on tmpfs. 2012-04-18 10:51:04 +01:00
Matthew Booth
4542401fee Don't abort inspection if mdadm.conf ARRAY doesn't have a uuid 2012-04-18 10:10:03 +01:00
Richard W.M. Jones
158479ffc0 Version 1.17.32. 2012-04-17 18:33:23 +01:00
Richard W.M. Jones
255882a3f6 python: Remove 'del g' from the docs, replace with 'g.close ()'.
'del g' is a trap for the unwary.  If the handle has any other
references, it does nothing (in fact, it can be actively dangerous if
the user was expecting the appliance to go away).  In non-CPython it
can be delayed arbitrarily long.

Using 'g.close()' on the other hand is always safe.
2012-04-17 17:41:43 +01:00
Richard W.M. Jones
7995c513ba todo: Note about -cpu host. 2012-04-17 17:41:33 +01:00
Richard W.M. Jones
6065f21b10 virt-alignment-scan: Fix error code.
This fixes commit fb401ebff8.
2012-04-17 16:24:27 +01:00
Richard W.M. Jones
84d450210b resize, sparsify: Add a simple-minded check to stop indisk = outdisk. 2012-04-17 15:03:02 +01:00
Richard W.M. Jones
8d3d5a52d2 sparsify: Fix comma/colon and quoting in qemu-img command.
Colon characters are not allowed in qemu/qemu-img filenames.  There's
no way to quote them.

Comma characters CAN be used.  However they must be quoted (by
doubling) when used in the '-o' option.

Fix general quoting problems in the external command.
2012-04-17 14:58:40 +01:00
Richard W.M. Jones
fb401ebff8 virt-alignment-scan: Add ability to list all domains.
The output looks like this:

 F16x64:/dev/sda1      1048576         1024K   ok
 F16x64:/dev/sda2      2097152         2048K   ok
 F16x64:/dev/sda3    526385152         2048K   ok

If the --uuid option is used, then UUIDs are shown instead of names.
2012-04-17 10:38:07 +01:00
Richard W.M. Jones
5ec0fba56e gitignore: Move cscope.out to second section.
This fixes commit 3c843e2129.
2012-04-16 15:53:34 +01:00
Matthew Booth
3c843e2129 .gitignore: cscope.out isn't always at the top-level 2012-04-16 15:48:16 +01:00
Richard W.M. Jones
63cb25236b fuse: Improve reporting in mount-local when verbose is enabled. 2012-04-16 13:30:07 +01:00
Richard W.M. Jones
6c2b8340c3 Version 1.17.31. 2012-04-15 21:53:43 +01:00
Richard W.M. Jones
8104b2dfab New APIs for reading and writing ext2 file attributes and file generation.
The new APIs are:

  get-e2attrs: List ext2 file attributes of a file.
  set-e2attrs: Set or clear ext2 file attributes of a file.
  get-e2generation: Get ext2 file generation of a file.
  set-e2generation: Set ext2 file generation of a file.

These are implemented using the lsattr and chattr programs from
e2fsprogs.
2012-04-13 15:44:17 +01:00
Richard W.M. Jones
9ccde76f61 todo: Remove obsolete sections from the TODO file. 2012-04-13 12:41:04 +01:00
Richard W.M. Jones
2a5a5e15e2 sysprep: Make the tests run quietly. 2012-04-13 09:35:08 +01:00
Wanlong Gao
1f373aa246 sysprep: bash_history: fix copyright
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-04-13 09:00:35 +01:00
Wanlong Gao
ecdfd2c8cc sysprep: remove .ssh directory in users' directory
Remove the .ssh directory of user "root" and any other
users who have a .ssh directory in their home directory.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-04-13 08:59:25 +01:00
Richard W.M. Jones
b288f21e0c Version 1.17.30. 2012-04-13 08:43:37 +01:00
Richard W.M. Jones
4b0e525d1d tests: Fix reference to guestfish in test for RHBZ#811649.
This fixes commit a9bd90abfb.
2012-04-13 08:31:01 +01:00
Richard W.M. Jones
e14f545f81 Version 1.17.29. 2012-04-12 21:35:14 +01:00
Richard W.M. Jones
a9bd90abfb Add regression test to test funny filenames (RHBZ#811649). 2012-04-12 18:59:14 +01:00
Richard W.M. Jones
d2183a62aa lib: Escape , as ,, on qemu command line (RHBZ#811649). 2012-04-12 18:59:14 +01:00
Richard W.M. Jones
4be630edb3 lib: Remove check_path function, limitation is colon, not comma (RHBZ#811649).
Remove the bogus check_path function and move the functionality into
the two places where it was being used.

  qemu -cdrom ,

works fine, I tested it.

Colon cannot be used in a block device filename anywhere, since the
qemu block driver interprets it as a prefix.  There is no known way to
work around this problem.  I checked this is true with kwolf.

Comma is fine in -drive options, provided it is escaped by doubling it.
2012-04-12 18:59:13 +01:00
Richard W.M. Jones
4dba0e1e9d Revert "launch: don't add a drive twice"
This reverts commit be47b66c30.
2012-04-12 18:59:13 +01:00
Richard W.M. Jones
a97e9429ea extra-tests: Add suppression for memory leak in FUSE. 2012-04-12 18:59:04 +01:00
Richard W.M. Jones
5b414f581f extra-tests: ocaml: Use a short delay instead of Thread.yield.
On the new faster computer, Thread.yield wasn't yielding, so the
second thread would block the main test from proceeding (only when run
under valgrind however).
2012-04-12 18:43:59 +01:00
Richard W.M. Jones
681377f1b2 inspector: Update example XML. 2012-04-12 10:21:15 +01:00
Richard W.M. Jones
96b6504b09 inspection: Remove spurious warning for Ubuntu 10.04 with encrypted swap (RHBZ#811872). 2012-04-12 10:21:15 +01:00
Richard W.M. Jones
a996f0d370 inspector: Fix incorrect arch in example-ubuntu.xml. 2012-04-12 10:21:15 +01:00
Wanlong Gao
6c276606d7 sysprep: remove the bash history of users
Remove the bash history of users in home directory,
and history of root.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-04-12 09:38:35 +01:00
Richard W.M. Jones
ed2a06708c website: typo: guestfs-performance.3 -> guestfs-performance.1 2012-04-12 08:22:53 +01:00
Richard W.M. Jones
292664c3ac Version 1.17.28. 2012-04-11 23:00:39 +01:00
Richard W.M. Jones
287d5a126e New man page: guestfs-performance(1).
This contains tips for engineering libguestfs for greatest performance.
2012-04-11 22:45:32 +01:00
Richard W.M. Jones
307e8bc51a docs: Add libguestfs-test-tool(1) and libguestfs-make-fixed-appliance(1) to guestfs(3) man page.
Inexplicably these were not included before.
2012-04-11 22:04:14 +01:00
Richard W.M. Jones
3e164f15b7 po-docs: Allow parallel builds in po-docs directory.
The first time the directory is checked out from git, there are no
*.pod files.  In a parallel build, the first thread notices this and
runs the 'make -C .. update-po' rule, but the other threads also try
to run at the same time and fail.
2012-04-11 18:46:41 +01:00
Richard W.M. Jones
c1fb89e7fc po-docs: No need to touch virt-sysprep.1 output file. 2012-04-11 18:36:24 +01:00
Richard W.M. Jones
de2dc9f71d extra-tests: Add suppression for libvirt/gnutls leak.
https://www.redhat.com/archives/libvir-list/2012-April/msg00322.html
2012-04-11 18:20:33 +01:00
Richard W.M. Jones
b6dd7e7250 python: Add a regression test for RHBZ#811650. 2012-04-11 17:56:12 +01:00
Richard W.M. Jones
0f7de2279a launch: Set error when qemu fails early during launch (RHBZ#811650).
This caused the Python bindings (and probably others) to
segfault because guestfs_last_error(g) would return NULL.
2012-04-11 17:43:47 +01:00
Richard W.M. Jones
f237ae2ad6 python: Add PYTHONPATH to './run' script.
Also:

 - tidy up the script
 - use the ./run script when running Python tests
2012-04-11 17:27:25 +01:00
Richard W.M. Jones
4ee518508f sysprep: Sort and align all arguments (thanks Wanlong Gao). 2012-04-11 16:27:00 +01:00
Richard W.M. Jones
16b2ffa97e sysprep: Make a common Utils.compare_command_line_args function.
This isn't quite code motion, since the new function also ignores case
(which previously we didn't ignore).
2012-04-11 16:26:32 +01:00
Richard W.M. Jones
a3d6629a0b sysprep: Move skip_dashes function into Utils module.
This is mostly code motion, but I also changed the function to use
String.unsafe_get and raise Invalid_argument on failure.
2012-04-11 16:22:58 +01:00
Richard W.M. Jones
edca57b49e sysprep: Add utils.mli (interface) file. 2012-04-11 16:14:57 +01:00
Richard W.M. Jones
b8fbbcf791 sysprep: Print some logging by default.
It can be disabled using the --quiet option.

The logging looks like:

Examining the guest ...
Performing "cron-spool" ...
Performing "dhcp-client-state" ...
Performing "dhcp-server-state" ...
Performing "hostname" ...
Performing "logfiles" ...
Performing "mail-spool" ...
Performing "net-hwaddr" ...
Performing "random-seed" ...
Performing "rhn-systemid" ...
Performing "script" ...
Performing "smolt-uuid" ...
Performing "ssh-hostkeys" ...
Performing "udev-persistent-net" ...
Performing "utmp" ...
Performing "yum-uuid" ...

Reviewed-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-04-11 13:50:53 +01:00
Richard W.M. Jones
b10a3d718e extra-tests: Disable valgrind vgdb.
This leaves files called 'vgdb-pipe-*' in .
2012-04-10 18:14:16 +01:00
Richard W.M. Jones
7fe9905c4b Version 1.17.27. 2012-04-10 15:44:02 +01:00
Qin Guan
5e054f8731 sysprep: Allow hwaddr to be removed on other Red Hat derivatives (RHBZ#811117). 2012-04-10 14:15:18 +01:00
Qin Guan
60b87d0a5c sysprep: Allow hostname to be set on other Red Hat derivatives (RHBZ#811112). 2012-04-10 14:15:08 +01:00
Richard W.M. Jones
8ae322e5a7 Use posix_fadvise when uploading or downloading files.
But ignore it if the call fails, since the file descriptor could be a
non-file (eg. /dev/stdout).
2012-04-09 17:36:56 +01:00
Richard W.M. Jones
669c0bd407 Fix libguestfs-make-fixed-appliance --help option so it displays usage.
Previously it printed 'Internal error!'
2012-04-09 15:53:37 +01:00
Richard W.M. Jones
12a56dfc8a gobject: Remove guestfs-gobject.c from POTFILES.in.
This file no longer exists after the sources were split across
multiple files for the benefit of gtk-doc.
2012-04-06 20:09:18 +01:00
Richard W.M. Jones
f2ac7c18a7 tests: Fix guest building so parallel 'make -jN check' works.
This means renaming various temporary files (eg. fstab.tmp) that
several of the scripts were using so they don't conflict
(eg. fstab.tmp.$$).

Also the rule:

  fedora-md1.img fedora-md2.img: guest-aux/make-fedora-img.pl

causes the script to run twice in parallel when using 'make -jN'.
Replace this with a stamp file so it runs once:

  fedora-md1.img fedora-md2.img: stamp-fedora-md.img
  stamp-fedora-md.img: guest-aux/make-fedora-img.pl
2012-04-06 18:49:45 +01:00
Richard W.M. Jones
418a048215 tests: Don't print "4" when running make-windows-img.sh
The return value of the pwrite-device command -- 4 (bytes) -- is
printed out.  Hide it instead.
2012-04-06 18:48:58 +01:00
Matthew Booth
d9f77f214b fuse: Add missing #include to guestmount.c
Fix compilation failure on F17
2012-04-04 14:26:51 +01:00
Richard W.M. Jones
4b86f1ad03 debian: Suggest 'apt-get build-dep' to install dependencies. 2012-04-04 12:46:40 +01:00
Richard W.M. Jones
ec162e7d58 Update RELEASE-NOTES file for future 1.18 release. 2012-04-03 23:10:05 +01:00
Richard W.M. Jones
19494b1988 Version 1.17.26. 2012-04-03 12:58:24 +01:00
Richard W.M. Jones
465c97ebf4 parallel mount-local test: Don't run more than 12 threads.
On the Koji builder that has lots of memory, this was trying to run
something like 20 threads.
2012-04-03 10:52:27 +01:00
Richard W.M. Jones
999aac63eb Use absolute paths where necessary in .gitignore file. 2012-04-03 10:48:55 +01:00
Richard W.M. Jones
5c8a241e5c inspection: Support Fedora 17+ (RHBZ#809361).
Recognize grub2 as a bootloader, and /bin being a symlink to
/usr/bin (ie. UsrMove feature added in Fedora 17+).
2012-04-03 10:24:27 +01:00
Richard W.M. Jones
04ddf3cfa2 sysprep: Add GDM and session preferences to logfiles. 2012-04-03 09:54:50 +01:00
Richard W.M. Jones
25d156f262 sysprep: Remove installation logfiles in /root. 2012-04-03 09:48:45 +01:00
Richard W.M. Jones
a1d88b60e3 sysprep: Include logfile glob list in the man page. 2012-04-03 09:43:12 +01:00
Richard W.M. Jones
817cebe3ad Version 1.17.25. 2012-04-02 19:09:52 +01:00
Richard W.M. Jones
50009403b3 New API: mkfs-btrfs for creating btrfs filesystems (RHBZ#807905).
This allows all parameters from btrfs to be accessed.
2012-04-02 10:12:38 +01:00
Richard W.M. Jones
77ac6b73cd mkfs: Don't allow blocksize to be set on btrfs (RHBZ#807905). 2012-04-02 08:46:23 +01:00
Richard W.M. Jones
f8a88def14 extra-tests: Test virt-sysprep. 2012-04-01 21:55:09 +01:00
Richard W.M. Jones
95123a9144 sysprep: Add a test of the --script option. 2012-04-01 20:02:25 +01:00
Richard W.M. Jones
6282d92b1b sysprep: Simplify and tidy up the test. 2012-04-01 20:01:08 +01:00
Richard W.M. Jones
9cb976ab5f sysprep: script: Documentation fix. 2012-04-01 20:00:36 +01:00
Richard W.M. Jones
b1f997164e sysprep: script: Miscellaneous fixes and cleanups to shell script. 2012-04-01 20:00:28 +01:00
Richard W.M. Jones
de656448f7 sysprep: script: Wait for child process to exit. 2012-04-01 20:00:06 +01:00
Richard W.M. Jones
6c88ae851f sysprep: script: Remove useless check that script is executable.
This check will fail if the script is on the path.  Also document
that script must be on the path or else the full path to the script
must be given.
2012-04-01 19:59:32 +01:00
Richard W.M. Jones
65e20e34dd sysprep: Add some debug code when performing operations. 2012-04-01 19:57:41 +01:00
Richard W.M. Jones
64550dcad2 Version 1.17.24. 2012-04-01 16:06:54 +01:00
Richard W.M. Jones
94e94550ed sysprep: Add more files to CLEANFILES. 2012-04-01 13:17:32 +01:00
Richard W.M. Jones
7ed21d9a5c sysprep: When generating man pages, use 'run' script. 2012-04-01 13:15:56 +01:00
Richard W.M. Jones
3a58a00483 Add po/remove-potcdate.sin to git and EXTRA_DIST.
This file is produced by gettextize and required by 'make dist'.
2012-04-01 09:28:24 +01:00
Richard W.M. Jones
3b94cf5046 Version 1.17.23. 2012-03-31 23:17:41 +01:00
Richard W.M. Jones
6e3de76278 Ensure that SOURCES are always in EXTRA_DIST, even if OCaml not available. 2012-03-31 23:17:41 +01:00
Richard W.M. Jones
ad43dde9c8 sysprep: Implement 'script' operation for running general scripts against the guest. 2012-03-31 23:02:47 +01:00
Richard W.M. Jones
026f616650 Rewrite virt-sysprep. 2012-03-31 22:55:33 +01:00
Richard W.M. Jones
d00596dfbb fish: Add a regression test for mount-local, mount-local-run commands. 2012-03-31 10:28:49 +01:00
Richard W.M. Jones
e430ce8908 Update translations from Transifex. 2012-03-30 18:42:02 +01:00
Richard W.M. Jones
dd126109e5 Update API support. 2012-03-30 18:27:26 +01:00
Richard W.M. Jones
ed96872bd2 Version 1.17.22. 2012-03-29 20:31:54 +01:00
Richard W.M. Jones
b2cddfe2f5 Add test of parallel mount-local calls. 2012-03-29 17:13:28 +01:00
Richard W.M. Jones
c6f09fac06 New APIs: mount-local, mount-local-run, umount-local (FUSE support in the API).
Add FUSE support directly to the API.  Instead of needing to use the
external 'guestmount' command, you can mount the libguestfs filesystem
space on a local mountpoint using an API call from any language.

Note that although mount-local-run is marked as Cancellable, the
current implementation does not support it, but it would be relatively
simple to add it.
2012-03-29 16:45:01 +01:00
Matthew Booth
49fdba0ae9 gobject: Ignore generated guestfs-sections.txt 2012-03-29 13:42:02 +01:00
Matthew Booth
1c5dc612bd gobject: Add split-out files to POTFILES.in 2012-03-29 13:41:54 +01:00
Richard Jones
b9cb387a10 test: Thread function is a candidate for attribute noreturn.
The start_test_thread function never returns, it is always
cancelled by the main thread.
2012-03-29 13:35:48 +01:00
Richard Jones
d67da6419a Partially revert "generator: Fix unescaped '<' and '>' in api descriptions"
Don't escape < and > in verbatim sections.

This partially reverts commit 09a4e7664b.
2012-03-29 09:34:28 +01:00
Hilko Bengen
0c9361a356 Fix out-of-tree build for GObject bindings
guestfs-gobject.h (in the source directory) was not found.

In file included from <stdin>:4:0:
/path/to/libguestfs/gobject/guestfs-gobject.h:23:37: fatal error: guestfs-gobject-session.h: No such file or directory
compilation terminated.
Error while processing the source.
make[2]: *** [Guestfs-1.0.gir] Error 1
2012-03-28 23:30:59 +02:00
Hilko Bengen
4db251048b Fix out-of-tree build for Java bindings 2012-03-28 22:11:00 +02:00
Hilko Bengen
17c828d995 Fix out-of-tree build for appliance 2012-03-28 22:10:04 +02:00
Matthew Booth
2b9167540f gobject: Remove gtk-doc from TODO 2012-03-28 20:05:41 +01:00
Matthew Booth
3b0cb4dfdc gobject: Split sources into 1 file per class
This greatly improves the usability of the generated gtk-doc.

Although there is a lot of churn in generator_gobject.ml, this is almost
exclusively code motion.
2012-03-28 20:04:21 +01:00
Matthew Booth
3311e110c7 gobject: Add gtk-doc for GuestfsSession and GuestfsSessionClass 2012-03-28 20:04:21 +01:00
Matthew Booth
321748d3c2 gobject: Add gtk-doc field descriptions for generated structs 2012-03-28 20:04:21 +01:00
Matthew Booth
e49bd34fb7 gobject: Add gtk-doc for optarg wrapper classes 2012-03-28 20:04:21 +01:00
Matthew Booth
574d104b15 gobject: Drop references to Guestfs::<foo> in comments 2012-03-28 20:04:20 +01:00
Matthew Booth
e3758fc430 gobject: Handle various problem content in gtk-doc API descriptions
Produce better gtk-doc for:
* URLs
* RHBZ# references
* CVE references
* API cross-references
* Parameter references
* Escaped characters
2012-03-28 20:04:20 +01:00
Matthew Booth
6b13952657 gobject: Add basic gtk-doc for all parameters 2012-03-28 20:04:20 +01:00
Matthew Booth
ed5cc90ed5 gobject: Add basic gtk-doc for properties 2012-03-28 20:04:20 +01:00
Matthew Booth
9863dd387f gobject: gtk-doc SECTION must be named after a source file 2012-03-28 20:04:20 +01:00
Matthew Booth
1004b2ec25 gobject: Include explicit types for all parameters 2012-03-28 20:04:20 +01:00
Matthew Booth
b0ebf37a94 gobject: Add infrastructure to build gtk-doc 2012-03-28 20:04:20 +01:00
Richard Jones
4d0aa08b00 java: Delete target file before running javah.
javah from old GNU classpath won't overwrite the target *.h file,
instead leaving the old one which results in a predictable build
failure.  Delete the target so this won't happen.
2012-03-28 19:19:58 +01:00
Richard Jones
5ea27d740e fish: Fix compilation when libconfig is not available. 2012-03-28 19:06:01 +01:00
Richard Jones
3d174b39bf Don't provoke -Wstrict-overflow warning from map_app_md_devices function.
Unclear if this is a real bug or not.
2012-03-28 19:03:30 +01:00
Richard Jones
f2fae5151f Work around -Wstrict-overflow warning on gcc 4.5.1. 2012-03-28 19:01:56 +01:00
Richard Jones
b169b03dd4 m4: Update .gitignore for old Fedora. 2012-03-28 18:55:38 +01:00
Richard Jones
8111b108d2 configure: Don't fail if GOBJECT_INTROSPECTION_CHECK is not defined. 2012-03-28 18:19:54 +01:00
Richard W.M. Jones
f35aadcd86 tests: Don't include internal guestfs header in tests. 2012-03-27 17:40:28 +01:00
Richard W.M. Jones
a33ea71601 generator: Allow functions with no requires args, and with some optional args.
Previously the generator disallowed such functions.
2012-03-27 17:27:21 +01:00
Richard W.M. Jones
a138063acb Ignore guestfs.pyo.
This fixes commit e8ef35df26.
2012-03-27 17:27:21 +01:00
Matthew Booth
e8ef35df26 Only ignore guestfs.* at the top level
The guestfs.* rule appears to be for temporary appliance directories, which are
only at the top level. It was matching more than that.
2012-03-27 15:50:38 +01:00
Matthew Booth
13e5f1a3b1 generator: Remove doc reference to non-existent guestfs_inotify_watch_all 2012-03-27 15:50:38 +01:00
Matthew Booth
09a4e7664b generator: Fix unescaped '<' and '>' in api descriptions 2012-03-27 15:50:38 +01:00
Richard W.M. Jones
f5c31db5ed fuse: Fix documentation for call to virt-filesystems.
virt-filesystems requires -a/-d option.
2012-03-26 18:28:24 +01:00
Richard W.M. Jones
f1d10672c7 df: Avoid a compilation error if libxml2 is not available.
virt_df-domains.o: In function `add_domain':
/home/feeliwood/Downloads/libguestfs-1.17.21/df/domains.c:274: undefined reference to `guestfs___for_each_disk'

guestfs___for_each_disk is only available when libvirt _and_ libxml2
dependencies are available at compile time.

Thanks Tho Huynh.
2012-03-25 19:35:43 +01:00
Richard W.M. Jones
88b5ee9d95 Revert "ruby: Replace deprecated rdoc/task and rake/gempackagetask."
This reverts commit fd7a5a8bbd.

This breaks Ruby 1.8.7 in Fedora 16.
2012-03-25 19:20:07 +01:00
Richard W.M. Jones
fc198a3b9a Remove references to obsolete directory appliance/debian.
This directory has not existed for a long time.
2012-03-22 10:05:27 +00:00
Richard W.M. Jones
a14021078b Remove debian/ subdirectory. 2012-03-22 10:05:12 +00:00
Richard W.M. Jones
55c4e7a0d3 Version 1.17.21. 2012-03-21 12:34:01 +00:00
Richard W.M. Jones
7d2027295f filesystems: Implement parents of MD and VG devices (RHBZ#805070). 2012-03-21 12:08:37 +00:00
Richard W.M. Jones
a8f8af950d filesystems: Allow the parents column to contain multiple parents.
A list of parents is passed for this column.

This column is rendered as an (internally) comma-separated list.
2012-03-20 19:38:05 +00:00
Richard W.M. Jones
3f6cc550ff New API: md-stat.
This returns information about the underlying devices of an MD
(software RAID) device.
2012-03-20 18:50:24 +00:00
Richard W.M. Jones
65ebec4a7a generator: Generate a .gitignore file specifically for java structs. 2012-03-20 17:14:56 +00:00
Richard W.M. Jones
f62db21d8b daemon: Set last errno to ENOTSUP when APIs are not available. 2012-03-20 12:27:44 +00:00
Richard W.M. Jones
7526df547c daemon: Add reply_with_error_errno function.
This function allows you to pass an explicit errno back to the
library.  reply_with_error is redefined as a macro that calls
reply_with_error_errno with errno == 0.
2012-03-20 12:25:40 +00:00
Richard W.M. Jones
c7dff02ccb inspection: Set last errno to ENOTSUP when inspection APIs are not available.
Previously there was no programmatic way to tell if inspection APIs
were unavailable because they are not compiled in (because hivex isn't
around).  This contrasts with daemon APIs where the availability is
covered by the guestfs_available API.

Change the inspection APIs so that when they are not available, the
last errno is set to ENOTSUP.  (Note that ENOTSUP must be defined on
all POSIX platforms).

This allows programs to detect if they are using a version of
libguestfs that was compiled without support for inspection, without
having to parse error messages.
2012-03-20 09:11:29 +00:00
Richard W.M. Jones
b8fc61bd9b todo: Document proposed attach-method fd:N 2012-03-20 09:11:29 +00:00
Richard W.M. Jones
e1ffb10115 po-docs: Rename LINGUAS -> linguas (RHBZ#804464). 2012-03-19 10:20:08 +00:00
Richard W.M. Jones
752bd8f632 Make HTML from libguestfs-test-tool man page. 2012-03-17 22:11:32 +00:00
Richard W.M. Jones
7c2ebad357 Version 1.17.20. 2012-03-17 20:55:09 +00:00
Richard W.M. Jones
a4fd393663 New API: vgmeta: Download volume group metadata. 2012-03-17 14:36:28 +00:00
Richard W.M. Jones
05461175c4 appliance: Add a tool to make fixed appliances. 2012-03-17 10:00:59 +00:00
Richard W.M. Jones
fd7a5a8bbd ruby: Replace deprecated rdoc/task and rake/gempackagetask. 2012-03-16 22:14:44 +00:00
Richard W.M. Jones
f9c4fdfeea todo: Suggestion for virt-sysprep. 2012-03-16 18:27:52 +00:00
Richard W.M. Jones
a6f47c285f Version 1.17.19. 2012-03-16 15:18:48 +00:00
Richard W.M. Jones
14938b46a7 generator: Sort camel-case structs. 2012-03-16 14:42:30 +00:00
Richard W.M. Jones
a43f35f5bb New APIs: isoinfo and isoinfo-device.
Get ISO primary volume descriptor information for either ISO devices
or ISO files.
2012-03-16 14:40:20 +00:00
Richard W.M. Jones
d17218c210 appliance: Include genisoimage in the appliance.
This is mainly useful for the 'isoinfo' tool, but 'genisoimage'
itself may be interesting to have in future.
2012-03-16 14:11:02 +00:00
Richard W.M. Jones
6bee63beb4 generator: Fix CompareWithString test.
This type of test was not used, and in fact the generated test
simply didn't work.
2012-03-16 14:11:02 +00:00
Richard W.M. Jones
c8630300b8 generator: Fix FUInt{32,64} struct field types.
We were not using an unsigned type in the XDR.  This doesn't
affect data integrity or the protocol, but it makes it more
complicated for the daemon to set these fields.
2012-03-16 14:11:02 +00:00
Richard W.M. Jones
710ec49bac daemon: Don't call reply_with_* after split_lines fails.
split_lines already sets reply_with_*, so calling it again would lose
protocol synchronization.
2012-03-16 14:11:02 +00:00
Richard W.M. Jones
974dffc676 inspect: Fedora/RHEL CDs are multipart if totaldiscs > 1, not > 0. 2012-03-16 10:44:04 +00:00
Richard W.M. Jones
553e50c105 inspect: Parse isolinux menu title from RHEL 6.2 Live CD. 2012-03-16 10:43:40 +00:00
Richard W.M. Jones
5749de39c2 inspect: Add comment documenting findings of RHEL 5, 6 install CDs. 2012-03-16 10:43:27 +00:00
Richard W.M. Jones
5411f3fd45 Version 1.17.18. 2012-03-15 16:45:37 +00:00
Richard W.M. Jones
85a701c10c todo: Document further virt-sparsify improvements. 2012-03-15 16:15:49 +00:00
Richard W.M. Jones
98f066e274 sparsify: Implement --zero option.
This unconditionally zeroes the named partition or filesystem.
2012-03-15 16:15:46 +00:00
Richard W.M. Jones
1c1ecb2c41 sparsify: Add a note about encrypted disks to the man page. 2012-03-15 16:15:45 +00:00
Richard W.M. Jones
7283a5a276 sparsify: Unlink temporary overlay file if user presses ^C.
Add a signal handler so this potentially large temporary file
is removed when the user hits ^C.
2012-03-15 16:15:45 +00:00
Richard W.M. Jones
31c26be91f sparsify: Support sparsifying Linux swap partitions. 2012-03-15 16:15:45 +00:00
Richard W.M. Jones
8c9f6a64be sparsify: Use zero-device instead of dd if=/dev/zero to zero device.
zero-device is more efficient in general, and avoids writing to blocks
which are already zero.
2012-03-15 16:15:45 +00:00
Richard W.M. Jones
b05611d8ef Use the new lvcreate-free API to create largest possible LVs. 2012-03-15 16:15:45 +00:00
Richard W.M. Jones
79c4ecc0f3 New API: lvcreate-free: Create logical volume as % of free space. 2012-03-15 16:15:44 +00:00
Richard W.M. Jones
03d4345c8c sparsify: Use new zero_free_space API. 2012-03-15 16:15:44 +00:00
Richard W.M. Jones
d9bdb9587b New API: zero_free_space: zero free space in a filesystem.
Add an API for doing what virt-sparsify was doing: freeing up free
space in a filesystem.

The current implementation is simple-minded: we create a file, fill it
with zeroes until we run out of space, then delete the file.  However
the description leaves it open to do a better implementation, eg.
using sparsification support that is currently being worked on in ext4
and qemu.

The implementation also sends progress notifications, which is an
advantage over the old 'dd' method.
2012-03-15 16:15:44 +00:00
Richard W.M. Jones
7934ea2395 sparsify: Only print qemu-img command if verbose. 2012-03-15 16:15:44 +00:00
Richard W.M. Jones
91cede3465 inspect: Ignore missing HKLM\SYSTEM\MountedDevices (RHBZ#803664).
When a Windows guest doesn't have a HKLM\SYSTEM\MountedDevices node,
inspection fails.  However inspection should not completely fail just
because we cannot get the drive letter mapping from a guest.
2012-03-15 13:55:55 +00:00
Richard W.M. Jones
2bc922dd8e inspector: Update man page to describe how to access inspection info from other languages and guestfish. 2012-03-14 23:13:41 +00:00
Richard W.M. Jones
c23f3b8e52 Add guestfsd.suppressions file to EXTRA_DIST. 2012-03-14 21:13:43 +00:00
Richard W.M. Jones
e743eb3984 Version 1.17.17. 2012-03-14 19:57:36 +00:00
Richard W.M. Jones
606732d02e Use O_CLOEXEC / SOCK_CLOEXEC for almost all file descriptors.
The presumption is that all file descriptors should be created with
the close-on-exec flag set.  The only exception are file descriptors
that we want passed through to exec'd subprocesses (mainly pipes and
stdin/stdout/stderr).

For open calls, we pass O_CLOEXEC as an extra flag, eg:

  fd = open ("foo", O_RDONLY|O_CLOEXEC);

This is a Linux-ism, but using a macro we can easily make it portable.

For sockets, similarly:

  sock = socket (..., SOCK_STREAM|SOCK_CLOEXEC, ...);

For accepted sockets, we use the Linux accept4 system call which
allows flags to be supplied, but we use the Gnulib 'accept4' module to
make this portable.

For dup, dup2, we use the Linux dup3 system call, and the Gnulib
modules 'dup3' and 'cloexec'.
2012-03-14 19:30:46 +00:00
Richard W.M. Jones
13e7a1b400 java: Make sure generator is rerun when necessary to rebuild generated files. 2012-03-14 19:29:52 +00:00
Richard W.M. Jones
d042e56f2a java: Enable -Xlint:all and fix all warnings. 2012-03-14 19:29:11 +00:00
Richard W.M. Jones
6b233bd39e todo: More ongoing code cleanups. 2012-03-14 19:28:13 +00:00
Richard W.M. Jones
302309921a appliance: Enhance --enable-valgrind-daemon with a suppressions file.
This lets us suppress errors in system libraries.
2012-03-14 16:13:40 +00:00
Richard W.M. Jones
5da61d3052 daemon: When copy subprocess fails, print return code.
Useful for debugging.
2012-03-14 16:12:54 +00:00
Richard W.M. Jones
9974c42a29 todo: Document ongoing code cleanups. 2012-03-14 12:53:37 +00:00
Richard W.M. Jones
f876271521 daemon: labels: Memory leak in 'set_label'.
This fixes commit d1711dae9d.
2012-03-14 12:52:55 +00:00
Richard W.M. Jones
7e32d892d7 Version 1.17.16. 2012-03-13 08:45:49 +00:00
Richard W.M. Jones
f76a88011a Replace 'int' with 'size_t' passim.
Analyze all uses of 'int' in the code, and replace with 'size_t' where
appropriate.
2012-03-13 08:23:56 +00:00
Richard W.M. Jones
14df5fa5d1 daemon: Implement a growable strings buffer type.
Previously a lot of daemon code used three variables (a string list,
'int size' and 'int alloc') to track growable strings buffers.  This
commit implements a simple struct containing the same variables, but
using size_t instead of int:

  struct stringsbuf {
    char **argv;
    size_t size;
    size_t alloc;
  };

Use it like this:

  DECLARE_STRINGSBUF (ret);
//...
  if (add_string (&ret, str) == -1)
    return NULL;
//...
  if (end_stringsbuf (&ret) == -1)
    return NULL;
  return ret.argv;
2012-03-13 08:19:11 +00:00
Richard W.M. Jones
d66dd2260c Fix strict-overflow bugs and reenable this warning.
In two places, we were counting things in an array using an 'int'.  In
theory, the int could overflow, so gcc determines this to be undefined
behaviour.

The fix is to use size_t or ssize_t instead.
2012-03-12 16:27:10 +00:00
Richard W.M. Jones
17182af3a6 fish: remote: Output from close event now passed over stdout (RHBZ#802389). 2012-03-12 15:21:35 +00:00
Richard W.M. Jones
f7c744bbf8 fish: remote: Make sure global cleanups are called for guestfish --listen.
Return to the main program ('fish.c') and perform global cleanups when
the guestfish remote server exits.
2012-03-12 15:13:29 +00:00
Richard W.M. Jones
b3a9e81868 fish: remote: Move close_stdout just before accept() call.
This is just code motion.
2012-03-12 15:11:33 +00:00
Richard W.M. Jones
1f603bfd6d fish: Rename tests and make test paths relative.
When these tests were originally in the old regressions/ directory,
they used to refer to guestfish via the path '../fish/guestfish'.
Some of the tests were also called 'test-guestfish-*'.

Now that the tests have been moved into the fish/ directory, neither
of these things make sense.  So change the relative path to
'./guestfish' and rename all 'test-guestfish-*' as 'test-*'.
2012-03-12 15:09:15 +00:00
Richard W.M. Jones
2c8ead5aa0 tests: Remove/fix unused variables warnings. 2012-03-12 14:10:05 +00:00
Richard W.M. Jones
100e30763e Version 1.17.15. 2012-03-12 12:22:25 +00:00
Richard W.M. Jones
099e3dd9f1 tests: Remove unused variable. 2012-03-12 12:22:25 +00:00
Richard W.M. Jones
5cad29043f configure: Enable more warnings, and some cleanup.
However -Wstrict-overflow is still disabled, see:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52560
2012-03-12 11:53:05 +00:00
Richard W.M. Jones
6292e630da erlang: Remove unused variables. 2012-03-12 11:53:05 +00:00
Richard W.M. Jones
e9e0920c00 format: Remove unused variables. 2012-03-12 11:53:04 +00:00
Richard W.M. Jones
13c2db39ab daemon: Remove unused variables. 2012-03-12 11:53:04 +00:00
Richard W.M. Jones
46d1280100 inspect: Move variable decl to top of function. 2012-03-12 11:53:04 +00:00
Richard W.M. Jones
4bcd0b3c17 inspect: Use 1/0 instead of true/false, and fix a bug in UUID parsing.
UUID parsing returned 'false' (ie. 0 == OK) when the UUID contained
illegal characters.  Now it returns -1 == failure.
2012-03-12 11:53:04 +00:00
Richard W.M. Jones
cd3f2986ee lib: Remove some unused variables. 2012-03-12 11:53:04 +00:00
Richard W.M. Jones
1aa72017ca lib: Use size_t instead of int for array iterator. 2012-03-12 11:53:03 +00:00
Richard W.M. Jones
3d279d15c1 inspect: Use uint64_t for maximum file size in bytes. 2012-03-12 11:53:03 +00:00
Richard W.M. Jones
b8cdf6c2b9 lib: Use size_t for allocation size in safe realloc function. 2012-03-12 11:53:03 +00:00
Richard W.M. Jones
24413ac4d8 bindtests: Use size_t instead of int for array iterators. 2012-03-12 11:53:03 +00:00
Richard W.M. Jones
e6f18c59d5 Coalesce printable characters in debug and trace messages (RHBZ#802109). 2012-03-11 20:12:41 +00:00
Richard W.M. Jones
5b7b1c43ab Document error message from resize2fs (RHBZ#755729, RHBZ#801640). 2012-03-09 18:05:35 +00:00
Richard W.M. Jones
2fb545b840 resize2fs: Run 'e2fsck -f' automatically if filesystem is not mounted. 2012-03-09 18:05:31 +00:00
Richard W.M. Jones
4c9218658e e2fsck: Comment, whitespace, error message cleanups. 2012-03-09 16:52:28 +00:00
Richard W.M. Jones
99923c7cd0 Mark e2fsck-f as deprecated, replaced by e2fsck API. 2012-03-09 16:15:41 +00:00
Richard W.M. Jones
dfe30bdfe7 Revert "ext2: tweak the error returned message of resize2fs-M(BZ755729)"
This reverts commit 0eaf06e673.
2012-03-09 16:13:49 +00:00
Richard W.M. Jones
d0cf52b911 Version 1.17.14. 2012-03-09 16:01:17 +00:00
Richard W.M. Jones
baa5e1ea51 example: Copying a directory between two guests using threads. 2012-03-09 15:13:08 +00:00
Richard W.M. Jones
f1f045adf8 Close all file descriptors and remove all signal handlers in the recovery process.
If the parent process uses a pipe (or any fd, but pipes are a
particular problem), then the recovery process would hold open the
file descriptor(s) of the pipe, meaning that it could not be fully
closed in the parent.  Because the recovery process doesn't use
exec(2), this wasn't avoidable even using FD_CLOEXEC.

Avoid this by closing all file descriptors when starting the recovery
process.

After discussion with Dan Berrange, he points out that it's also a
good idea to set signal handlers to the default after forking, so that
any signal handlers set up in the parent don't affect the child.
2012-03-09 13:48:01 +00:00
Richard W.M. Jones
99702fe443 extra-tests: Export LIBVIRT_DEFAULT_URI to pick-guests.pl.
This fixes commit 2912e4e117.
2012-03-08 19:27:37 +00:00
Richard W.M. Jones
f8e7a41e67 Version 1.17.13. 2012-03-08 17:39:11 +00:00
Richard W.M. Jones
2912e4e117 extra-tests: Check that guests are accessible before picking them. 2012-03-08 16:19:20 +00:00
Richard W.M. Jones
0721464b83 fish: Document that guestfish sets pgroup to true (RHBZ#801273). 2012-03-08 15:02:55 +00:00
Richard W.M. Jones
270daae52b inspect_apps: Avoid double-close on error path (found by Coverity) (RHBZ#801298).
Error: USE_AFTER_FREE:
/builddir/build/BUILD/libguestfs-1.16.5/src/inspect_apps.c:392: freed_arg: "fclose" frees "fp".
/builddir/build/BUILD/libguestfs-1.16.5/src/inspect_apps.c:404: deref_arg: Calling "fclose" dereferences freed pointer "fp".
2012-03-08 15:02:41 +00:00
Richard W.M. Jones
3f3b08a6bc dbdump: Avoid double-close on error path (found by Coverity).
Error: USE_AFTER_FREE:
/builddir/build/BUILD/libguestfs-1.16.5/src/dbdump.c:132: freed_arg: "pclose" frees "pp".
/builddir/build/BUILD/libguestfs-1.16.5/src/dbdump.c:142: deref_arg: Calling "pclose" dereferences freed pointer "pp".
2012-03-08 14:36:25 +00:00
Richard W.M. Jones
b2c1d8be39 daemon: glob: Initialize glob buffer (quiet Coverity warning).
Error: UNINIT:
/builddir/build/BUILD/libguestfs-1.16.5/daemon/glob.c:32: var_decl: Declaring variable "buf" without initializer.
/builddir/build/BUILD/libguestfs-1.16.5/daemon/glob.c:36: uninit_use_in_call: Using uninitialized value "buf.gl_offs" when calling "rpl_glob".
/builddir/build/BUILD/libguestfs-1.16.5/gnulib/lib/glob.c:557: read_parm_fld: Reading a parameter field.
/builddir/build/BUILD/libguestfs-1.16.5/daemon/glob.c:36: uninit_use_in_call: Using uninitialized value "buf.gl_pathc" when calling "rpl_glob".
/builddir/build/BUILD/libguestfs-1.16.5/gnulib/lib/glob.c:557: read_parm_fld: Reading a parameter field.
2012-03-08 14:30:10 +00:00
Richard W.M. Jones
3345444ccc comment: Note time-of-check to time-of-use race found by Coverity. 2012-03-08 14:12:45 +00:00
Richard W.M. Jones
ae0f9f149b daemon: inotify: Check event->len in inotify struct is reasonable.
The Coverity error is this (which I think is wrong):

Error: TAINTED_SCALAR:
/builddir/build/BUILD/libguestfs-1.16.5/daemon/inotify.c:211: tainted_data_argument: Calling function "read" taints argument "inotify_buf".
/builddir/build/BUILD/libguestfs-1.16.5/daemon/inotify.c:232: var_assign_var: Assigning: "event" = "(struct inotify_event *)&inotify_buf[n]". Both are now tainted.
/builddir/build/BUILD/libguestfs-1.16.5/daemon/inotify.c:258: lower_bounds: Checking lower bounds of unsigned scalar "event->len" by "event->len > 0U".
/builddir/build/BUILD/libguestfs-1.16.5/daemon/inotify.c:272: var_assign_var: Compound assignment involving tainted variable "16UL + event->len" to variable "n" taints "n".
/builddir/build/BUILD/libguestfs-1.16.5/daemon/inotify.c:228: lower_bounds: Checking lower bounds of unsigned scalar "n" by "n < inotify_posn".
/builddir/build/BUILD/libguestfs-1.16.5/daemon/inotify.c:281: tainted_data: Using tainted variable "n" as an index into an array "inotify_buf".

Adding a sanity check of event->len is prudent.
2012-03-08 13:53:04 +00:00
Richard W.M. Jones
3b3d9ca4e1 daemon: debug: Close fd along error path (found by Coverity).
Error: RESOURCE_LEAK:
/builddir/build/BUILD/libguestfs-1.16.5/daemon/debug.c:469: open_fn: Calling opening function "open".
/builddir/build/BUILD/libguestfs-1.16.5/daemon/debug.c:469: var_assign: Assigning: "fd" =  handle returned from "open("/proc/sys/kernel/core_pattern", 1)".
/builddir/build/BUILD/libguestfs-1.16.5/daemon/debug.c:474: noescape: Variable "fd" is not closed or saved in function "write".
/builddir/build/BUILD/libguestfs-1.16.5/daemon/debug.c:476: leaked_handle: Handle variable "fd" going out of scope leaks the handle.
2012-03-08 13:23:15 +00:00
Richard W.M. Jones
4dd26c28a3 fish: Properly free up strings, lists along all error paths (found by Coverity).
This also includes some tidying up of the generated code.

Error: RESOURCE_LEAK:
/builddir/build/BUILD/libguestfs-1.16.5/fish/cmds.c:13254: alloc_fn: Calling allocation function "parse_string_list".
/builddir/build/BUILD/libguestfs-1.16.5/fish/fish.c:1386: alloc_fn: Storage is returned from allocation function "realloc".
/builddir/build/BUILD/libguestfs-1.16.5/fish/fish.c:1386: var_assign: Assigning: "argv_new" = "realloc(argv, 8UL * argv_len)".
/builddir/build/BUILD/libguestfs-1.16.5/fish/fish.c:1392: var_assign: Assigning: "argv" = "argv_new".
/builddir/build/BUILD/libguestfs-1.16.5/fish/fish.c:1396: return_alloc: Returning allocated memory "argv".
/builddir/build/BUILD/libguestfs-1.16.5/fish/cmds.c:13254: var_assign: Assigning: "devices" =  storage returned from "parse_string_list(argv[i++])".
/builddir/build/BUILD/libguestfs-1.16.5/fish/cmds.c:13271: leaked_storage: Variable "devices" going out of scope leaks the storage it points to.
/builddir/build/BUILD/libguestfs-1.16.5/fish/cmds.c:13288: leaked_storage: Variable "devices" going out of scope leaks the storage it points to.
/builddir/build/BUILD/libguestfs-1.16.5/fish/cmds.c:13293: leaked_storage: Variable "devices" going out of scope leaks the storage it points to.
/builddir/build/BUILD/libguestfs-1.16.5/fish/cmds.c:13311: leaked_storage: Variable "devices" going out of scope leaks the storage it points to.
/builddir/build/BUILD/libguestfs-1.16.5/fish/cmds.c:13316: leaked_storage: Variable "devices" going out of scope leaks the storage it points to.
/builddir/build/BUILD/libguestfs-1.16.5/fish/cmds.c:13334: leaked_storage: Variable "devices" going out of scope leaks the storage it points to.
/builddir/build/BUILD/libguestfs-1.16.5/fish/cmds.c:13349: leaked_storage: Variable "devices" going out of scope leaks the storage it points to.
/builddir/build/BUILD/libguestfs-1.16.5/fish/cmds.c:13355: leaked_storage: Variable "devices" going out of scope leaks the storage it points to.
2012-03-08 13:21:59 +00:00
Richard W.M. Jones
d0453c0254 daemon: proto: Close fd along error paths (found by Coverity).
Error: RESOURCE_LEAK:
/builddir/build/BUILD/libguestfs-1.16.5/src/proto.c:894: open_fn: Calling opening function "open".
/builddir/build/BUILD/libguestfs-1.16.5/src/proto.c:894: var_assign: Assigning: "fd" =  handle returned from "open(filename, 0)".
/builddir/build/BUILD/libguestfs-1.16.5/src/proto.c:903: noescape: Variable "fd" is not closed or saved in function "read".
/builddir/build/BUILD/libguestfs-1.16.5/src/proto.c:911: leaked_handle: Handle variable "fd" going out of scope leaks the handle.
/builddir/build/BUILD/libguestfs-1.16.5/src/proto.c:918: leaked_handle: Handle variable "fd" going out of scope leaks the handle.
2012-03-08 13:21:59 +00:00
Richard W.M. Jones
fbf10d7f68 daemon: upload: Close fd along error path (found by Coverity).
Error: RESOURCE_LEAK:
/builddir/build/BUILD/libguestfs-1.16.5/daemon/upload.c:225: open_fn: Calling opening function "open".
/builddir/build/BUILD/libguestfs-1.16.5/daemon/upload.c:225: var_assign: Assigning: "fd" =  handle returned from "open(filename, 0)".
/builddir/build/BUILD/libguestfs-1.16.5/daemon/upload.c:233: noescape: Variable "fd" is not closed or saved in function "lseek".
/builddir/build/BUILD/libguestfs-1.16.5/daemon/upload.c:235: leaked_handle: Handle variable "fd" going out of scope leaks the handle.
2012-03-08 13:21:58 +00:00
Richard W.M. Jones
cba36e7305 daemon: 9p: Close fd along error paths (found by Coverity).
Error: RESOURCE_LEAK:
/builddir/build/BUILD/libguestfs-1.16.5/daemon/9p.c:130: open_fn: Calling opening function "open".
/builddir/build/BUILD/libguestfs-1.16.5/daemon/9p.c:130: var_assign: Assigning: "fd" =  handle returned from "open(filename, 0)".
/builddir/build/BUILD/libguestfs-1.16.5/daemon/9p.c:142: leaked_handle: Handle variable "fd" going out of scope leaks the handle.
/builddir/build/BUILD/libguestfs-1.16.5/daemon/9p.c:149: noescape: Variable "fd" is not closed or saved in function "read".
/builddir/build/BUILD/libguestfs-1.16.5/daemon/9p.c:153: leaked_handle: Handle variable "fd" going out of scope leaks the handle.
2012-03-08 13:21:58 +00:00
Richard W.M. Jones
855aaf414a proto: Close file along error and cancel paths (found by Coverity).
Error: RESOURCE_LEAK:
/builddir/build/BUILD/libguestfs-1.16.5/src/proto.c:1125: open_fn: Calling opening function "open".
/builddir/build/BUILD/libguestfs-1.16.5/src/proto.c:1125: var_assign: Assigning: "fd" =  handle returned from "open(filename, 833, 438)".
/builddir/build/BUILD/libguestfs-1.16.5/src/proto.c:1133: noescape: Variable "fd" is not closed or saved in function "xwrite".
/builddir/build/BUILD/libguestfs-1.16.5/src/proto.c:1146: leaked_handle: Handle variable "fd" going out of scope leaks the handle.
/builddir/build/BUILD/libguestfs-1.16.5/src/proto.c:1173: leaked_handle: Handle variable "fd" going out of scope leaks the handle.
2012-03-08 13:21:58 +00:00
Richard W.M. Jones
618954a6b0 Check return values of guestfs_inspect_get_{type,distro} (found by Coverity).
Error: NULL_RETURNS:
/builddir/build/BUILD/libguestfs-1.16.5/examples/virt-dhcp-address.c:129: var_assigned: Assigning: "guest_distro" = null return value from "guestfs_inspect_get_distro".
/builddir/build/BUILD/libguestfs-1.16.5/examples/virt-dhcp-address.c:131: dereference: Dereferencing a pointer that might be null "guest_distro" when calling "__coverity_strcmp".
[...]
/builddir/build/BUILD/libguestfs-1.16.5/examples/virt-dhcp-address.c:126: var_assigned: Assigning: "guest_type" = null return value from "guestfs_inspect_get_type".
/builddir/build/BUILD/libguestfs-1.16.5/examples/virt-dhcp-address.c:128: dereference: Dereferencing a pointer that might be null "guest_type" when calling "__coverity_strcmp".
2012-03-08 13:21:58 +00:00
Richard W.M. Jones
35d5be22b1 Check return values from calloc (found by Coverity).
Error: NULL_RETURNS:
/builddir/build/BUILD/libguestfs-1.16.5/src/inspect.c:417: returned_null: Function "calloc" returns null (checked 67 out of 81 times).
/builddir/build/BUILD/libguestfs-1.16.5/src/inspect.c:417: var_assigned: Assigning: "ret" = null return value from "calloc".
/builddir/build/BUILD/libguestfs-1.16.5/src/inspect.c:418: dereference: Dereferencing a null pointer "ret".
[...]
/builddir/build/BUILD/libguestfs-1.16.5/src/inspect.c:374: returned_null: Function "calloc" returns null (checked 67 out of 81 times).
/builddir/build/BUILD/libguestfs-1.16.5/src/inspect.c:374: var_assigned: Assigning: "ret" = null return value from "calloc".
/builddir/build/BUILD/libguestfs-1.16.5/src/inspect.c:375: dereference: Dereferencing a null pointer "ret".
2012-03-08 13:21:52 +00:00
Richard W.M. Jones
0ffa223a75 Dead code: Remove comma-check in first if-clause (found by Coverity).
Error: DEADCODE:
/builddir/build/BUILD/libguestfs-1.16.5/fish/event-names.c:65: dead_error_condition: On this path, the condition "comma" cannot be true.
/builddir/build/BUILD/libguestfs-1.16.5/fish/event-names.c:57: const: After this line, the value of "comma" is equal to 0.
/builddir/build/BUILD/libguestfs-1.16.5/fish/event-names.c:57: assignment: Assigning: "comma" = "0".
/builddir/build/BUILD/libguestfs-1.16.5/fish/event-names.c:65: dead_error_line: Execution cannot reach this statement "fputc(44, fp);".
2012-03-08 13:21:51 +00:00
Richard W.M. Jones
109d3ad34a Dead code: 'lvs' cannot be true here (found by Coverity).
Remove dead code; however only comment it out since if we change the
preceeding code we may need this line again.

Error: DEADCODE:
/builddir/build/BUILD/libguestfs-1.16.5/src/listfs.c:107: dead_error_condition: On this path, the condition "lvs" cannot be true.
/builddir/build/BUILD/libguestfs-1.16.5/src/listfs.c:54: const: After this line, the value of "lvs" is equal to 0.
/builddir/build/BUILD/libguestfs-1.16.5/src/listfs.c:91: const: After this line, the value of "lvs" is equal to 0.
/builddir/build/BUILD/libguestfs-1.16.5/src/listfs.c:54: assignment: Assigning: "lvs" = "NULL".
/builddir/build/BUILD/libguestfs-1.16.5/src/listfs.c:91: new_values: Noticing condition "lvs == NULL".
/builddir/build/BUILD/libguestfs-1.16.5/src/listfs.c:107: dead_error_line: Execution cannot reach this statement "guestfs___free_string_list(...".
2012-03-08 13:21:51 +00:00
Richard W.M. Jones
07a8c3c0c2 Ignore return values from some functions in guestfs_close (Coverity warning).
Error: CHECKED_RETURN:
/builddir/build/BUILD/libguestfs-1.16.5/java/com_redhat_et_libguestfs_GuestFS.c:9552: example_assign: Assigning: "r" = return value from "guestfs_internal_autosync(g)".
/builddir/build/BUILD/libguestfs-1.16.5/java/com_redhat_et_libguestfs_GuestFS.c:9555: example_checked: "r" has its value checked in "r == -1".
/builddir/build/BUILD/libguestfs-1.16.5/ocaml/guestfs_c_actions.c:5584: example_assign: Assigning: "r" = return value from "guestfs_internal_autosync(g)".
/builddir/build/BUILD/libguestfs-1.16.5/ocaml/guestfs_c_actions.c:5586: example_checked: "r" has its value checked in "r == -1".
/builddir/build/BUILD/libguestfs-1.16.5/perl/Guestfs.xs:5990: example_assign: Assigning: "r" = return value from "guestfs_internal_autosync(g)".
/builddir/build/BUILD/libguestfs-1.16.5/perl/Guestfs.xs:5991: example_checked: "r" has its value checked in "r == -1".
/builddir/build/BUILD/libguestfs-1.16.5/python/guestfs-py.c:13702: example_assign: Assigning: "r" = return value from "guestfs_internal_autosync(g)".
/builddir/build/BUILD/libguestfs-1.16.5/python/guestfs-py.c:13707: example_checked: "r" has its value checked in "r == -1".
/builddir/build/BUILD/libguestfs-1.16.5/ruby/ext/guestfs/_guestfs.c:16000: example_assign: Assigning: "r" = return value from "guestfs_internal_autosync(g)".
/builddir/build/BUILD/libguestfs-1.16.5/ruby/ext/guestfs/_guestfs.c:16001: example_checked: "r" has its value checked in "r == -1".
/builddir/build/BUILD/libguestfs-1.16.5/src/guestfs.c:191: check_return: Calling function "guestfs_internal_autosync" without checking return value (as is done elsewhere 5 out of 6 times).
/builddir/build/BUILD/libguestfs-1.16.5/src/guestfs.c:191: unchecked_value: No check of the return value of "guestfs_internal_autosync(g)".
2012-03-08 13:21:51 +00:00
Richard W.M. Jones
10f240a07f tests/md: Number the errors so we can easily see which test fails. 2012-03-08 13:21:51 +00:00
Richard W.M. Jones
5503d95e1b Update translations from Transifex. 2012-03-08 10:46:13 +00:00
Richard W.M. Jones
0fdcc76901 Update API support. 2012-03-07 22:32:14 +00:00
Richard W.M. Jones
4504f424f5 dist: Distribute all tests, even when configured with --disable-appliance. 2012-03-07 19:21:14 +00:00
Richard W.M. Jones
2f126e07bb Version 1.17.12. 2012-03-07 18:36:48 +00:00
Richard W.M. Jones
cfa0f9b381 inspection: Add detection of FreeDOS install CDs (RHBZ#786188). 2012-03-07 18:36:47 +00:00
Richard W.M. Jones
a9510b7b22 inspection: Add detection of FreeDOS (RHBZ#786215).
FreeDOS is returned as type="dos", distro="freedos".  No version or
application information is returned at present.
2012-03-07 18:36:47 +00:00
Richard W.M. Jones
518cdb596e Add 'display_icon' example program.
Running this on a disk image displays the guest icon
(using external 'display' program).
2012-03-07 18:36:46 +00:00
Richard W.M. Jones
4d8ae8f5a2 Comment change. 2012-03-07 18:36:46 +00:00
Richard W.M. Jones
e40f408fae Hide stderr of bmptopng.
This program is noisy on stderr.  Send that to /dev/null.
2012-03-07 18:36:46 +00:00
Richard W.M. Jones
2c9c0525eb build: Make netpbm and icoutils into proper optional dependencies.
Netpbm and icoutils (wrestool) have always been dependencies.  Since
they are not always present, make these into optional dependencies
(which they were, sort of, before).

Also document these dependencies in the README file.
2012-03-07 18:36:46 +00:00
Richard W.M. Jones
b9061ddf2d Add support for Buildroot and Cirros distributions. 2012-03-07 18:36:46 +00:00
Richard W.M. Jones
b106dda97c Whitespace change. 2012-03-07 18:36:46 +00:00
Matthew Booth
3bf5d0d0e4 gobject: Update TODO with details of inspect_get_type fix 2012-03-06 14:48:41 +00:00
Richard W.M. Jones
deaae55072 Version 1.17.11. 2012-03-05 09:36:34 +00:00
Richard W.M. Jones
715f7e2809 Remove ConfigOnly flag from set-autosync.
guestfs_set_autosync sets a flag which affects guestfs_close, and so
this call can be made at any time before the handle is closed, not
just in the config state.
2012-03-05 08:58:00 +00:00
Richard W.M. Jones
705971b509 Test header file under C++. 2012-03-04 14:41:37 +00:00
Marcin Gibula
49611f121f Make "template" a reserved word.
Function guestfs_mkdtemp uses c++ keyword "template" as a parameter
name. In result, attempt to use guestfs.h header in c++ program
results in compile error.
2012-03-04 11:54:19 +00:00
Richard W.M. Jones
b11e9f4919 Version 1.17.10. 2012-03-03 18:41:01 +00:00
Richard W.M. Jones
3b78b3a849 ruby: Use RbConfig instead of Config.
I have checked, and this works with Ruby 1.8 as well.
2012-03-03 18:40:42 +00:00
Richard W.M. Jones
5e8a4627d9 Add a 'fixed' style of appliance.
This is just the 'kernel', 'initrd' and 'root' files, copied from one
machine to another, along with a 'README.fixed' file which is also
used for identification.

This allows the appliance to be copied from one machine to another,
making it easier for us to distribute a starter appliance for people
who cannot get febootstrap or appliance-building working.
2012-03-03 16:58:48 +00:00
Richard W.M. Jones
49726b9269 Rebrand 'ordinary appliance' as 'old-style appliance'.
This is just code motion.
2012-03-03 16:58:05 +00:00
Nikos Skalkotos
ba468e9c5e Test fails in arch linux
--20cf303ea4a84a7a7c04ba331375
Content-Type: text/plain; charset=ISO-8859-1

Hello Richard,

I found what the problem was and the udev symlinks where not created. The
init script in the appliance uses a full paths for udevadm (/sbin/udevadm)
which in my case was wrong. In Arch Linux udevadm is hosted under /usr/bin,
not /sbin. When I fixed this, libguestfs was able to communicate with the
appliance VM.

Since PATH variable is defined and exported in init, there is no need in
using full paths for external programs. As far as I've seen this affects
all the git branches in libguestfs's repository. Please find attached a
patch for the master branch.

Nikos Skalkotos,
Athens, Greece

On 24 February 2012 10:25, Richard W.M. Jones <rjones@redhat.com> wrote:

> On Thu, Feb 23, 2012 at 08:50:12PM +0200, Nikos Skalkotos wrote:
> [...]
>
> I don't know specifically why it fails with ArchLinux, but the problem
> is caused by the /dev/virtio-ports/* symlinks not getting created by
> udev.
>
> /dev/vport0p1 exists:
>
> > crw------- 1 root root 252,   1 Feb 23 18:17 vport0p1
>
> but udev doesn't make the corresponding /dev/virtio-ports symlink:
>
> > /dev/virtio-ports/org.libguestfs.channel.0: No such file or directory
>
> The symlink is supposed to be created by this udev rule:
>
> /lib/udev/rules.d/50-udev-default.rules:KERNEL=="vport*",
> ATTR{name}=="?*", SYMLINK+="virtio-ports/$attr{name}"
>
> So I'd start by looking to see if that rule exists in the udev rules
> that Arch is using.  Secondly if it does exist, is the corresponding
> *.rules being copied into the appliance?  (Check appliance/supermin.d/
> hostfiles)
>
> In an old Ubuntu that has udev that predates having this rule, we add
> the following patch:
>
>
> http://libguestfs.org/download/binaries/ubuntu1004-packages/0002-ubuntu-10.04-Use-dev-vport0p1.patch
>
> Rich.
>
> --
> Richard Jones, Virtualization Group, Red Hat
> http://people.redhat.com/~rjones
> virt-p2v converts physical machines to virtual machines.  Boot with a
> live CD or over the network (PXE) and turn machines into Xen guests.
> http://et.redhat.com/~rjones/virt-p2v
>

Hello Richard,<br><br>I found what the problem was and the udev symlinks where not created. The init script in the appliance uses a full paths for udevadm (/sbin/udevadm) which in my case was wrong. In Arch Linux udevadm is hosted under /usr/bin, not /sbin. When I fixed this, libguestfs was able to communicate with the appliance VM.<br>
<br>Since PATH variable is defined and exported in init, there is no need in using full paths for external programs. As far as I&#39;ve seen this affects all the git branches in libguestfs&#39;s repository. Please find attached a patch for the master branch.<br>
<br>Nikos Skalkotos,<br>Athens, Greece<br><br><div class="gmail_quote">On 24 February 2012 10:25, Richard W.M. Jones <span dir="ltr">&lt;<a href="mailto:rjones@redhat.com">rjones@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Thu, Feb 23, 2012 at 08:50:12PM +0200, Nikos Skalkotos wrote:<br>
[...]<br>
<br>
I don&#39;t know specifically why it fails with ArchLinux, but the problem<br>
is caused by the /dev/virtio-ports/* symlinks not getting created by<br>
udev.<br>
<br>
/dev/vport0p1 exists:<br>
<div class="im"><br>
&gt; crw------- 1 root root 252,   1 Feb 23 18:17 vport0p1<br>
<br>
</div>but udev doesn&#39;t make the corresponding /dev/virtio-ports symlink:<br>
<div class="im"><br>
&gt; /dev/virtio-ports/org.libguestfs.channel.0: No such file or directory<br>
<br>
</div>The symlink is supposed to be created by this udev rule:<br>
<br>
/lib/udev/rules.d/50-udev-default.rules:KERNEL==&quot;vport*&quot;, ATTR{name}==&quot;?*&quot;, SYMLINK+=&quot;virtio-ports/$attr{name}&quot;<br>
<br>
So I&#39;d start by looking to see if that rule exists in the udev rules<br>
that Arch is using.  Secondly if it does exist, is the corresponding<br>
*.rules being copied into the appliance?  (Check appliance/supermin.d/<br>
hostfiles)<br>
<br>
In an old Ubuntu that has udev that predates having this rule, we add<br>
the following patch:<br>
<br>
<a href="http://libguestfs.org/download/binaries/ubuntu1004-packages/0002-ubuntu-10.04-Use-dev-vport0p1.patch" target="_blank">http://libguestfs.org/download/binaries/ubuntu1004-packages/0002-ubuntu-10.04-Use-dev-vport0p1.patch</a><br>

<br>
Rich.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Richard Jones, Virtualization Group, Red Hat <a href="http://people.redhat.com/%7Erjones%0Avirt-p2v" target="_blank">http://people.redhat.com/~rjones<br>
virt-p2v</a> converts physical machines to virtual machines.  Boot with a<br>
live CD or over the network (PXE) and turn machines into Xen guests.<br>
<a href="http://et.redhat.com/%7Erjones/virt-p2v" target="_blank">http://et.redhat.com/~rjones/virt-p2v</a><br>
</font></span></blockquote></div><br>
2012-03-01 19:47:34 +00:00
Wanlong Gao
d6f736ab18 virt-sysprep: add the hostname and net_hwaddr support for rhel
Add the support for rhel.
Change the hostname and delete the HWADDR for rhel.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-02-29 10:11:37 +00:00
Richard W.M. Jones
48a5cb2a2c Version 1.17.9. 2012-02-28 10:34:51 +00:00
Richard W.M. Jones
88ba4da4d6 resize: Fix --output-format flag (RHBZ#798196).
Update the test to use the --format and --output-format flags.
2012-02-28 10:30:57 +00:00
Richard W.M. Jones
a93d4a9dc1 resize: Document steps to avoid UNMOUNTABLE_BOOT_VOLUME BSOD (RHBZ#797986).
(Thanks Grant Williamson for finding and fixing this problem)
2012-02-27 19:39:43 +00:00
Richard W.M. Jones
d1711dae9d New API: set-label, for setting a label on any filesystem.
Currently only ext2/3/4 and (newly) NTFS are supported.

This change also deprecates set-e2label.
2012-02-27 17:26:09 +00:00
Richard W.M. Jones
e567f064e2 New APIs: ntfsclone-in, ntfsclone-out. 2012-02-27 13:43:35 +00:00
Richard W.M. Jones
51aa51884e New API: ntfsfix for fixing problems on NTFS.
Note this is not a "chkdsk" equivalent tool.
2012-02-27 11:13:45 +00:00
Richard W.M. Jones
2e788ca45e Update TODO. 2012-02-27 10:51:45 +00:00
Wanlong Gao
b5cc1fa049 set-smp: limit the number of cpus below 255
Limit the number of cpus below 255, since qemu can't support.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-02-25 15:01:50 +00:00
Wanlong Gao
9e5c0b39c6 Add a flag to make some functions called only at CONFIG state (RHBZ#796520).
Add a flag "ConfigOnly" to make sure that some non-daemon functions
should be called only at CONFIG state (RHBZ#796520).

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-02-23 17:03:07 +00:00
Richard W.M. Jones
db2cb21a85 Version 1.17.8. 2012-02-15 20:58:47 +00:00
Richard W.M. Jones
5fa7aace20 sysprep: Try unmounting the filesystem a few times when busy.
tracker-miner-fs jumps into newly mounted filesystems.  This prevents
the filesystem from being unmounted, so retry a few times.
2012-02-15 19:25:52 +00:00
Richard W.M. Jones
afed7e493d appliance: Make appliance building thread-safe (RHBZ#790721).
Appliance building can be called from multiple processes, but this is
only safe if each process holds a lock on the 'checksum' file.
However threads within a process are not excluded by a file lock, and
so this strategy completely failed for a multithreaded program calling
guestfs_launch in parallel.

Since it makes no sense for threads in a single program to race each
other to try to create the appliance, add a lock around appliance
building.

This serialises building the appliance, but the rest of guestfs_launch
(eg. starting up qemu) can run in parallel.
2012-02-15 16:59:18 +00:00
Richard W.M. Jones
c9ea94810e tests: Test parallel launch from multiple threads. 2012-02-15 16:59:15 +00:00
Richard W.M. Jones
6a70cb337c test-user-cancel: Add \n to fprintf error messages. 2012-02-15 10:39:50 +00:00
Richard W.M. Jones
84a4160fd3 Version 1.17.7. 2012-02-13 14:44:03 +00:00
Richard W.M. Jones
cd06ddf442 tests: Add a regression test for RHBZ#789960.
Test all the ways that the 'mount' command can fail.  Ensure that none
of them result in failures or desynchronization.
2012-02-13 13:49:21 +00:00
Richard W.M. Jones
1b15e543a8 regressions: One test is not being run.
rhbz727178.sh exists, but historically was never added to the list of
tests, so it doesn't run.  Create a special variable for this test and
ensure it is added to EXTRA_DIST.

Test was originally added in
commit d7356a2801.
2012-02-13 13:49:21 +00:00
Richard W.M. Jones
07081591cf daemon: Return error properly when user tries to mount appliance root (RHBZ#789960).
In the case where the caller attempts to mount the "hidden"
appliance root device (eg. /dev/vdb if /dev/vda is the only
normal block device added), we were calling reply_with_error
but not actually returning immediately, resulting in protocol
desynchronization.

This commit fixes this obvious mistake.
2012-02-13 13:49:21 +00:00
Richard W.M. Jones
ba443ae048 daemon: Don't xdr_free uninitialized args struct on error paths.
For stubs of functions that had arguments, code did this:

static void
mount_stub (XDR *xdr_in)
{
  int r;
  struct guestfs_mount_args args;

  if (optargs_bitmask != 0) {
    //...
    goto done;
  }
  // possibly other tests here

  memset (&args, 0, sizeof args);

  [...]

done:
  xdr_free ((xdrproc_t) xdr_guestfs_mount_args, (char *) &args);
  return;
}

This caused xdr_free to be called on uninitialized 'args' struct,
causing a segfault.

The fix is to add another label, so the code looks like:

static void
mount_stub (XDR *xdr_in)
{
  int r;
  struct guestfs_mount_args args;

  if (optargs_bitmask != 0) {
    //...
    goto done_no_free;
  }
  // possibly other tests here

  memset (&args, 0, sizeof args);

  [...]

done:
  xdr_free ((xdrproc_t) xdr_guestfs_mount_args, (char *) &args);
done_no_free:
  return;
}

This fixes commit 330fbea5b2
and commit 0344248af5.
2012-02-13 13:49:21 +00:00
Hilko Bengen
c8a11468c4 Do not run test-virt-format.sh if appliance has not been built 2012-02-12 12:35:26 +01:00
Richard W.M. Jones
9403c5516f Version 1.17.6. 2012-02-10 14:01:42 +00:00
Richard W.M. Jones
badf2d6c4d virt-format: Add a test. 2012-02-10 14:01:38 +00:00
Richard W.M. Jones
7c21e49c2c fish: edit: Preserve permissions, UID, GID, SELinux context when editing files (RHBZ#788641). 2012-02-10 11:27:13 +00:00
Richard W.M. Jones
ddae5abf80 fish: In edit command, upload to a new file.
If the upload fails, this means we don't leave a partially
written file.

Also add a test for the edit command.
2012-02-10 11:27:13 +00:00
Richard W.M. Jones
ca80e44904 fish: Refactor error handling in the 'edit' command.
This is just code motion.
2012-02-10 11:27:13 +00:00
Richard W.M. Jones
ac58ddcd1a wipefs: Fix documentation.
This fixes commit a2b3e0900e.
2012-02-10 11:27:13 +00:00
Richard W.M. Jones
39625b59ee ocaml: Ensure bindings are recompiled whenever there is an API change. 2012-02-10 10:06:49 +00:00
Richard W.M. Jones
df3c6acacd wipefs: Include "optgroups.h".
This fixes commit a2b3e0900e.
2012-02-10 09:56:24 +00:00
Wanlong Gao
088546af9d virt-format: erase the filesystem signatures before erase partitions
erase the filesystem signatures on each device, then erase
the partitions, avoid to list all the partitions here.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-02-10 09:34:17 +00:00
Wanlong Gao
a2b3e0900e NEW API: add a new api wipefs
Add the new api wipefs to erase the filesystem signatures
on a device but now erase any data.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-02-10 09:34:13 +00:00
Richard W.M. Jones
6ca8a2db6d docs: Note that JRuby should use the Java bindings. 2012-02-09 15:46:15 +00:00
Richard W.M. Jones
a915d78ef9 New API: llz: This runs ls -laZ and is useful for showing SELinux contexts. 2012-02-09 15:46:14 +00:00
Richard W.M. Jones
24d7889eba edit: Preserve file permissions, UID, GID, SELinux context on edited files. (RHBZ#788641) 2012-02-09 15:46:14 +00:00
Hilko Bengen
016ae77e6c java: Make use of JAR_INSTALL_DIR, JNI_INSTALL_DIR 2012-02-08 22:47:22 +01:00
Richard W.M. Jones
2cbf5ea543 Version 1.17.5. 2012-02-08 14:35:55 +00:00
Richard W.M. Jones
f504cb02e1 findfs: Remove /run/blkid/blkid.tab.
See this util-linux commit:
b82590ad46
2012-02-08 14:35:55 +00:00
Richard W.M. Jones
518edc506f extra-tests: Add suppression for uninitialized memory bug in latest glibc. 2012-02-08 14:02:51 +00:00
Richard W.M. Jones
0559f038ad extra-tests: libnl moved from /lib64 to /usr/lib64 on Fedora.
Update suppressions file to match.
2012-02-08 14:02:14 +00:00
Richard W.M. Jones
825b5e65c0 perl: Ignore perl/MYMETA.json 2012-02-07 08:13:50 +00:00
Richard W.M. Jones
21a9efcad5 blockdev, parted: Call udev_settle before and after commands. (RHBZ#769304)
See comments in the code for details.

This is an alternate fix to
commit a9c8123c72.
2012-02-06 21:40:38 +00:00
Richard W.M. Jones
a98170e0e2 Revert "daemon: Run udev_settle after pwrite-device finishes."
This reverts commit a9c8123c72.
2012-02-06 18:24:52 +00:00
Richard W.M. Jones
3c9ef0e978 build: Choose a virtual directory for the daemon which is not a symlink.
Check /sbin, /usr/sbin, /bin and /usr/bin to ensure that neither the
directory nor the parent (eg. /usr) is a symlink, and use this
directory for the virtual directory used to store guestfsd in the
appliance.
2012-02-06 18:07:57 +00:00
Richard W.M. Jones
590d8c3c37 build: Remove 'run' from EXTRA_DIST.
This file shouldn't be included in the tarball as it contains
hard-coded paths from the maintainer's machine which cannot be
relevant to the target machine.
2012-02-03 20:57:28 +00:00
Richard W.M. Jones
b7a7ad1d11 Version 1.17.4. 2012-02-01 17:36:19 +00:00
Richard W.M. Jones
330fbea5b2 Clarify the error message when unavailable functions are called (RHBZ#679737).
Callers are supposed to use the availability API to check for
functions that may not be available in particular builds of
libguestfs.  If they don't do this, currently they tend to get obscure
error messages, eg:

  libguestfs: error: zerofree: /dev/vda1: zerofree: No such file or directory

This commit changes the error message to explain what callers ought to
be doing instead:

  libguestfs: error: zerofree: feature 'zerofree' is not available in this
  build of libguestfs.  Read 'AVAILABILITY' in the guestfs(3) man page for
  how to check for the availability of features.

This patch makes the stubs check for availability.  The stub code
changes to:

  static void
  zerofree_stub (XDR *xdr_in)
  {
  [...]

    /* The caller should have checked before calling this. */
    if (! optgroup_zerofree_available ()) {
      reply_with_error ("feature '%s' is not available in this\n"
                        "build of libguestfs.  Read 'AVAILABILITY' in the guestfs(3) man page for\n"
                        "how to check for the availability of features.",
                        "zerofree");
      goto done;
    }
  [...]
2012-02-01 15:09:09 +00:00
Wanlong Gao
90d6386c13 examples: code cleanups
do a code cleanup by removing the tailing spaces

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-01-31 13:27:52 +00:00
Wanlong Gao
d60d5c091f guestmount: use O_ACCMODE instead of hard coding
Change hard code 3 to O_ACCMODE.
it'll be more sensible.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-01-30 10:56:59 +00:00
Wanlong Gao
0042898880 guestmount: remove tailing spaces
just do a cleanup.
remove the tailing spaces.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
2012-01-30 10:56:11 +00:00
Richard W.M. Jones
e3f15780c8 daemon: Fix crash in aug-defnode (RHBZ#785668). 2012-01-30 10:47:47 +00:00
Richard W.M. Jones
6e703c1316 virt-alignment-scan: Fix typo in man page (thanks yurchor). 2012-01-28 19:14:57 +00:00
Richard W.M. Jones
03684e7a61 ocaml: Various fixes for bytecode compilation.
Set LD_LIBRARY_PATH so we link against the just-built library, not
the installed library.

Use OCAMLCFLAGS instead of OCAMLOPTFLAGS where appropriate.

Remove unnecessary -cclib option for bytecode linking (gcc is not used
in this case).

This fixes commit eb68a31413.
2012-01-28 17:35:52 +00:00
837 changed files with 292347 additions and 70773 deletions

807
.gitignore vendored
View File

@@ -1,397 +1,450 @@
*~
*.a
ABOUT-NLS
aclocal.m4
align/stamp-virt-alignment-scan.pod
align/virt-alignment-scan
align/virt-alignment-scan.1
appliance/excludelist
appliance/make.sh
appliance/packagelist
appliance/stamp-supermin
appliance/supermin.d
autom4te.cache
*.bak
bindtests.tmp
/build-aux
cat/stamp-virt-*.pod
cat/virt-cat
cat/virt-cat.1
cat/virt-filesystems
cat/virt-filesystems.1
cat/virt-ls
cat/virt-ls.1
ChangeLog
*.class
clone/stamp-virt-sysprep.pod
clone/virt-sysprep
clone/virt-sysprep.1
*.cma
*.cmi
*.cmo
*.cmx
*.cmxa
compile
config.guess
config.h
config.h.in
config.log
config.status
config.sub
configure
cscope.out
csharp/Libguestfs.cs
daemon/actions.h
daemon/errnostring.c
daemon/errnostring_gperf.c
daemon/errnostring_gperf.gperf
daemon/errnostring.h
daemon/guestfsd
daemon/guestfsd.exe
daemon/guestfs_protocol.c
daemon/guestfs_protocol.h
daemon/install-sh
daemon/missing
daemon/names.c
daemon/optgroups.c
daemon/optgroups.h
daemon/stubs.c
depcomp
.deps
df/stamp-virt-df.pod
df/virt-df
df/virt-df.1
*.diff
edit/stamp-virt-*.pod
edit/virt-edit
edit/virt-edit.1
*.eml
emptydisk
erlang/erl-guestfs
erlang/erl-guestfs.c
erlang/examples/guestfs-erlang.3
erlang/examples/stamp-guestfs-erlang.pod
erlang/guestfs.beam
erlang/guestfs.erl
examples/create_disk
examples/guestfs-examples.3
examples/guestfs-recipes.1
examples/guestfs-testing.1
examples/inspect_vm
examples/stamp-guestfs-examples.pod
examples/stamp-guestfs-recipes.pod
examples/stamp-guestfs-testing.pod
examples/virt-dhcp-address
fish/cmds.c
fish/cmds_gperf.c
fish/cmds_gperf.gperf
fish/completion.c
fish/event-names.c
fish/fish-cmds.h
fish/guestfish
fish/guestfish.1
fish/guestfish-actions.pod
fish/guestfish-commands.pod
fish/prepopts.c
fish/prepopts.h
fish/rc_protocol.c
fish/rc_protocol.h
fish/stamp-guestfish.pod
fish/stamp-virt-copy-in.pod
fish/stamp-virt-copy-out.pod
fish/stamp-virt-tar-in.pod
fish/stamp-virt-tar-out.pod
fish/virt-copy-in.1
fish/virt-copy-out.1
fish/virt-tar-in.1
fish/virt-tar-out.1
format/stamp-virt-format.pod
format/virt-format
format/virt-format.1
fuse/guestmount
fuse/guestmount.1
fuse/stamp-guestmount.pod
generator/.depend
generator/files-generated.txt
generator/generator
generator/.pod2text.data*
generator/stamp-generator
.gitattributes
.git-module-status
/gnulib
/GNUmakefile
gobject/bindtests.js
gobject/Guestfs-1.0.gir
gobject/Guestfs-1.0.typelib
gobject/guestfs-gobject.c
gobject/guestfs-gobject.h
.guestfs-*
guestfs.*
guestfsd-in-wine.log
haskell/Bindtests
haskell/Bindtests.hs
haskell/Guestfs005Load
haskell/Guestfs010Basic
haskell/Guestfs.hs
*.gcda
*.gcno
*.gcov
*.hi
html/guestfish.1.html
html/guestfs.3.html
html/guestfs-erlang.3.html
html/guestfs-examples.3.html
html/guestfs-java.3.html
html/guestfs-ocaml.3.html
html/guestfs-perl.3.html
html/guestfs-python.3.html
html/guestfs-recipes.1.html
html/guestfs-ruby.3.html
html/guestfs-testing.1.html
html/guestmount.1.html
html/virt-alignment-scan.1.html
html/virt-cat.1.html
html/virt-copy-in.1.html
html/virt-copy-out.1.html
html/virt-df.1.html
html/virt-edit.1.html
html/virt-filesystems.1.html
html/virt-format.1.html
html/virt-inspector.1.html
html/virt-list-filesystems.1.html
html/virt-list-partitions.1.html
html/virt-ls.1.html
html/virt-make-fs.1.html
html/virt-rescue.1.html
html/virt-resize.1.html
html/virt-sparsify.1.html
html/virt-sysprep.1.html
html/virt-tar.1.html
html/virt-tar-in.1.html
html/virt-tar-out.1.html
html/virt-win-reg.1.html
inspector/stamp-virt-inspector.pod
inspector/virt-inspector
inspector/virt-inspector.1
install-sh
*.jar
java/api
java/Bindtests.java
java/com/redhat/et/libguestfs/Application.java
java/com/redhat/et/libguestfs/Dirent.java
java/com_redhat_et_libguestfs_GuestFS.c
java/com_redhat_et_libguestfs_GuestFS.h
java/com/redhat/et/libguestfs/GuestFS.java
java/com/redhat/et/libguestfs/INotifyEvent.java
java/com/redhat/et/libguestfs/IntBool.java
java/com/redhat/et/libguestfs/LV.java
java/com/redhat/et/libguestfs/Partition.java
java/com/redhat/et/libguestfs/PV.java
java/com/redhat/et/libguestfs/Stat.java
java/com/redhat/et/libguestfs/StatVFS.java
java/com/redhat/et/libguestfs/Version.java
java/com/redhat/et/libguestfs/VG.java
java/com/redhat/et/libguestfs/XAttr.java
java/doc-stamp
java/examples/guestfs-java.3
java/examples/stamp-guestfs-java.pod
*.la
libguestfs.pc
libguestfs.spec
libguestfs-*.tar.gz
.libs
libtool
*.lo
/local*
ltmain.sh
m4/gnulib-cache.m4
m4/intmax.m4
m4/libtool.m4
m4/lt~obsolete.m4
m4/ltoptions.m4
m4/ltsugar.m4
m4/ltversion.m4
/maint.mk
Makefile
Makefile.in
missing
*.o
ocaml/bindtests.bc
ocaml/bindtests.opt
ocaml/bindtests.ml
ocaml/.depend
ocaml/dllmlguestfs.so
ocaml/examples/create_disk
ocaml/examples/guestfs-ocaml.3
ocaml/examples/inspect_vm
ocaml/examples/stamp-guestfs-ocaml.pod
ocaml/guestfs_c_actions.c
ocaml/guestfs_inspector.ml
ocaml/guestfs_inspector.mli
ocaml/guestfs.ml
ocaml/guestfs.mli
ocamlinit-stamp
ocaml/META
ocaml/t/guestfs_005_load.bc
ocaml/t/guestfs_005_load.opt
ocaml/t/guestfs_010_basic.bc
ocaml/t/guestfs_010_basic.opt
ocaml/t/guestfs_070_threads.bc
ocaml/t/guestfs_070_threads.opt
ocaml/t/guestfs_080_optargs.bc
ocaml/t/guestfs_080_optargs.opt
ocaml/t/guestfs_400_events.bc
ocaml/t/guestfs_400_events.opt
ocaml/t/guestfs_400_progress.bc
ocaml/t/guestfs_400_progress.opt
*.orig
*.patch
perl/bindtests.pl
perl/blib
perl/examples/guestfs-perl.3
perl/examples/stamp-guestfs-perl.pod
perl/Guestfs.bs
perl/Guestfs.c
perl/Guestfs.xs
perl/lib/Sys/Guestfs.pm
perl/Makefile-pl
perl/Makefile.PL
perl/Makefile-pl.old
perl/MYMETA.yml
perl/pm_to_blib
php/extension/acinclude.m4
php/extension/build/
php/extension/config.nice
php/extension/configure.in
php/extension/guestfs_php.c
php/extension/guestfs_php_*.diff
php/extension/guestfs_php_*.exp
php/extension/guestfs_php_*.log
php/extension/guestfs_php_*.out
php/extension/guestfs_php_*.php
php/extension/guestfs_php_*.sh
php/extension/Makefile.fragments
php/extension/Makefile.global
php/extension/Makefile.objects
php/extension/mkinstalldirs
php/extension/modules/
php/extension/php_guestfs_php.h
php/extension/run-tests.php
php/extension/tmp-php.ini
po/boldquot.sed
pod2htm?.tmp
po-docs/*/*.1
po-docs/*/*.3
po-docs/*/*.pl
po-docs/po4a.conf
po-docs/*/*.pod
podwrapper.sh
po/en@boldquot.header
po/en@quot.header
po/*.gmo
po/insert-header.sin
po/LINGUAS
po/Makevars.template
po/POTFILES
po/quot.sed
po/remove-potcdate.sed
po/remove-potcdate.sin
po/Rules-quot
po/stamp-it
po/stamp-po
python/bindtests.py
python/examples/guestfs-python.3
python/examples/stamp-guestfs-python.pod
python/guestfs.py
python/guestfs-py.c
python/guestfs.pyc
python/__pycache__
*.rej
rescue/stamp-virt-rescue.pod
rescue/virt-rescue
rescue/virt-rescue.1
resize/.depend
resize/stamp-virt-resize.pod
resize/utils_tests
resize/virt-resize
resize/virt-resize.1
ruby/bindtests.rb
ruby/doc/site/api
ruby/examples/guestfs-ruby.3
ruby/examples/stamp-guestfs-ruby.pod
ruby/ext/guestfs/extconf.h
ruby/ext/guestfs/_guestfs.bundle
ruby/ext/guestfs/_guestfs.c
ruby/ext/guestfs/_guestfs.so
ruby/ext/guestfs/mkmf.log
ruby/Rakefile
run
sparsify/.depend
sparsify/stamp-virt-sparsify.pod
sparsify/virt-sparsify
sparsify/virt-sparsify.1
src/actions.c
src/bindtests.c
src/errnostring.c
src/errnostring_gperf.c
src/errnostring_gperf.gperf
src/errnostring.h
src/guestfs.3
src/guestfs-actions.pod
src/guestfs-availability.pod
src/guestfs.h
src/guestfs-internal-actions.h
src/guestfs_protocol.c
src/guestfs_protocol.h
src/guestfs_protocol.x
src/guestfs-structs.pod
src/libguestfs.syms
src/.libs/libguestfs.so
src/stamp-guestfs.pod
stamp-h1
*.swp
test1.img
test2.img
test.err
test.out
tests/c-api/test-add-drive-opts
tests/c-api/test-add-libvirt-dom
tests/c-api/test-command
tests/c-api/test-config
tests/c-api/test-create-handle
tests/c-api/test-debug-to-file
tests/c-api/test*.img
tests/c-api/test-just-header
tests/c-api/test-last-errno
tests/c-api/test.log
tests/c-api/test-private-data
tests/c-api/tests
tests/c-api/tests.c
tests/c-api/test*.tmp
tests/c-api/test-user-cancel
tests/data/100kallnewlines
tests/data/100kallspaces
tests/data/100kallzeroes
tests/data/100krandom
tests/data/10klines
tests/data/abssymlink
tests/data/hello.b64
tests/data/initrd
tests/data/initrd-x86_64.img
tests/data/initrd-x86_64.img.gz
tests/data/test-grep.txt.gz
tests/data/test.iso
tests/extra/valgrind.log
tests/guests/debian.img
tests/guests/fedora.img
tests/guests/fedora-md1.img
tests/guests/fedora-md2.img
tests/guests/guest-aux/fedora-name.db
tests/guests/guest-aux/fedora-packages.db
tests/guests/ubuntu.img
tests/guests/windows.img
tests/regressions/rhbz501893
test-tool/libguestfs-test-tool
test-tool/libguestfs-test-tool.1
test-tool/libguestfs-test-tool-helper
tools/test.img
tools/virt-*.1
tools/virt-*.pl
/valgrind.log.*
bindtests.tmp
cscope.out
.deps
.gdb_history
gmon.out
.libs
Makefile
Makefile.in
/ABOUT-NLS
/aclocal.m4
/align/stamp-virt-alignment-scan.pod
/align/virt-alignment-scan
/align/virt-alignment-scan.1
/appliance/excludelist
/appliance/libguestfs-make-fixed-appliance
/appliance/libguestfs-make-fixed-appliance.1
/appliance/make.sh
/appliance/packagelist
/appliance/stamp-libguestfs-make-fixed-appliance.pod
/appliance/stamp-supermin
/appliance/supermin.d
/autom4te.cache
/build-aux
/cat/stamp-virt-*.pod
/cat/virt-cat
/cat/virt-cat.1
/cat/virt-filesystems
/cat/virt-filesystems.1
/cat/virt-ls
/cat/virt-ls.1
/ChangeLog
/compile
/config.cache
/config.guess
/config.h
/config.h.in
/config.log
/config.status
/config.sub
/configure
/csharp/Libguestfs.cs
/daemon/actions.h
/daemon/errnostring.c
/daemon/errnostring-gperf.c
/daemon/errnostring-gperf.gperf
/daemon/errnostring.h
/daemon/guestfsd
/daemon/guestfsd.8
/daemon/guestfsd.exe
/daemon/guestfs_protocol.c
/daemon/guestfs_protocol.h
/daemon/install-sh
/daemon/missing
/daemon/names.c
/daemon/optgroups.c
/daemon/optgroups.h
/daemon/stamp-guestfsd.pod
/daemon/stubs.c
/depcomp
/df/stamp-virt-df.pod
/df/virt-df
/df/virt-df.1
/edit/stamp-virt-*.pod
/edit/virt-edit
/edit/virt-edit.1
/erlang/bindtests.erl
/erlang/erl-guestfs
/erlang/erl-guestfs.c
/erlang/examples/guestfs-erlang.3
/erlang/examples/stamp-guestfs-erlang.pod
/erlang/guestfs.beam
/erlang/guestfs.erl
/erlang/test.img
/examples/copy_over
/examples/create_disk
/examples/display_icon
/examples/guestfs-examples.3
/examples/guestfs-faq.1
/examples/guestfs-performance.1
/examples/guestfs-recipes.1
/examples/guestfs-testing.1
/examples/inspect_vm
/examples/libvirt_auth
/examples/mount_local
/examples/stamp-guestfs-examples.pod
/examples/stamp-guestfs-faq.pod
/examples/stamp-guestfs-performance.pod
/examples/stamp-guestfs-recipes.pod
/examples/stamp-guestfs-testing.pod
/examples/virt-dhcp-address
/fish/cmds.c
/fish/cmds-gperf.c
/fish/cmds-gperf.gperf
/fish/completion.c
/fish/event-names.c
/fish/fish-cmds.h
/fish/guestfish
/fish/guestfish.1
/fish/guestfish-actions.pod
/fish/guestfish-commands.pod
/fish/prepopts.c
/fish/prepopts.h
/fish/rc_protocol.c
/fish/rc_protocol.h
/fish/stamp-guestfish.pod
/fish/stamp-virt-copy-in.pod
/fish/stamp-virt-copy-out.pod
/fish/stamp-virt-tar-in.pod
/fish/stamp-virt-tar-out.pod
/fish/virt-copy-in.1
/fish/virt-copy-out.1
/fish/virt-tar-in.1
/fish/virt-tar-out.1
/format/stamp-virt-format.pod
/format/virt-format
/format/virt-format.1
/fuse/guestmount
/fuse/guestmount.1
/fuse/stamp-guestmount.pod
/generator/.depend
/generator/files-generated.txt
/generator/generator
/generator/.pod2text.data*
/generator/stamp-generator
/.gitattributes
/.git-module-status
/gnulib
/GNUmakefile
/gobject/bindtests.js
/gobject/Guestfs-1.0.gir
/gobject/Guestfs-1.0.typelib
/gobject/guestfs-gobject*.c
/gobject/guestfs-gobject*.h
/guestfs-release-notes.1
/guestfsd-in-wine.log
/haskell/Bindtests
/haskell/Bindtests.hs
/haskell/Guestfs010Load
/haskell/Guestfs030Config
/haskell/Guestfs050LVCreate
/haskell/Guestfs.hs
/html/guestfish.1.html
/html/guestfs.3.html
/html/guestfs-erlang.3.html
/html/guestfs-examples.3.html
/html/guestfs-faq.1.html
/html/guestfs-java.3.html
/html/guestfs-lua.3.html
/html/guestfs-ocaml.3.html
/html/guestfs-performance.1.html
/html/guestfs-perl.3.html
/html/guestfs-python.3.html
/html/guestfs-recipes.1.html
/html/guestfs-release-notes.1.html
/html/guestfs-ruby.3.html
/html/guestfs-testing.1.html
/html/guestfsd.8.html
/html/guestmount.1.html
/html/libguestfs-make-fixed-appliance.1.html
/html/libguestfs-test-tool.1.html
/html/virt-alignment-scan.1.html
/html/virt-cat.1.html
/html/virt-copy-in.1.html
/html/virt-copy-out.1.html
/html/virt-df.1.html
/html/virt-edit.1.html
/html/virt-filesystems.1.html
/html/virt-format.1.html
/html/virt-inspector.1.html
/html/virt-list-filesystems.1.html
/html/virt-list-partitions.1.html
/html/virt-ls.1.html
/html/virt-make-fs.1.html
/html/virt-rescue.1.html
/html/virt-resize.1.html
/html/virt-sparsify.1.html
/html/virt-sysprep.1.html
/html/virt-tar.1.html
/html/virt-tar-in.1.html
/html/virt-tar-out.1.html
/html/virt-win-reg.1.html
/inspector/stamp-virt-inspector.pod
/inspector/test-xmllint.sh
/inspector/virt-inspector
/inspector/virt-inspector.1
/install-sh
/java/api
/java/Bindtests.java
/java/com_redhat_et_libguestfs_GuestFS.c
/java/com_redhat_et_libguestfs_GuestFS.h
/java/com/redhat/et/libguestfs/GuestFS.java
/java/doc-stamp
/java/examples/guestfs-java.3
/java/examples/stamp-guestfs-java.pod
/libguestfs.spec
/libguestfs-*.tar.gz
/libtool
/local*
/ltmain.sh
/lua/bindtests.lua
/lua/examples/guestfs-lua.3
/lua/examples/stamp-guestfs-lua.pod
/lua/guestfs.so
/lua/lua-guestfs.c
/lua/test.img
/m4/ChangeLog
/m4/gnulib-cache.m4
/m4/intmax.m4
/m4/libtool.m4
/m4/lt~obsolete.m4
/m4/ltoptions.m4
/m4/ltsugar.m4
/m4/ltversion.m4
/maint.mk
/missing
/ocaml/bindtests.bc
/ocaml/bindtests.opt
/ocaml/bindtests.ml
/ocaml/.depend
/ocaml/dllmlguestfs.so
/ocaml/examples/create_disk
/ocaml/examples/guestfs-ocaml.3
/ocaml/examples/inspect_vm
/ocaml/examples/stamp-guestfs-ocaml.pod
/ocaml/guestfs-c-actions.c
/ocaml/guestfs.ml
/ocaml/guestfs.mli
/ocamlinit-stamp
/ocaml/META
/ocaml/t/guestfs_005_load.bc
/ocaml/t/guestfs_005_load.opt
/ocaml/t/guestfs_010_basic.bc
/ocaml/t/guestfs_010_basic.opt
/ocaml/t/guestfs_070_threads.bc
/ocaml/t/guestfs_070_threads.opt
/ocaml/t/guestfs_080_optargs.bc
/ocaml/t/guestfs_080_optargs.opt
/ocaml/t/guestfs_400_events.bc
/ocaml/t/guestfs_400_events.opt
/ocaml/t/guestfs_400_progress.bc
/ocaml/t/guestfs_400_progress.opt
/ocaml/t/guestfs_500_mount_local.bc
/ocaml/t/guestfs_500_mount_local.opt
/perl/bindtests.pl
/perl/blib
/perl/examples/guestfs-perl.3
/perl/examples/stamp-guestfs-perl.pod
/perl/Guestfs.bs
/perl/Guestfs.c
/perl/Guestfs.xs
/perl/lib/Sys/Guestfs.pm
/perl/Makefile-pl
/perl/Makefile.PL
/perl/Makefile-pl.old
/perl/MYMETA.json
/perl/MYMETA.yml
/perl/pm_to_blib
/php/extension/acinclude.m4
/php/extension/aclocal.m4
/php/extension/autom4te.cache
/php/extension/build/
/php/extension/config.guess
/php/extension/config.h
/php/extension/config.h.in
/php/extension/config.log
/php/extension/config.nice
/php/extension/config.status
/php/extension/config.sub
/php/extension/configure
/php/extension/configure.in
/php/extension/guestfs_php.c
/php/extension/guestfs_php_*.diff
/php/extension/guestfs_php_*.exp
/php/extension/guestfs_php_*.log
/php/extension/guestfs_php_*.out
/php/extension/guestfs_php_*.php
/php/extension/guestfs_php_*.sh
/php/extension/install-sh
/php/extension/libtool
/php/extension/ltmain.sh
/php/extension/Makefile.fragments
/php/extension/Makefile.global
/php/extension/Makefile.objects
/php/extension/mkinstalldirs
/php/extension/missing
/php/extension/modules/
/php/extension/php_guestfs_php.h
/php/extension/run-tests.php
/php/extension/tmp-php.ini
/pick-guests.pl
/po-docs/*/*.1
/po-docs/*/*.3
/po-docs/*/*.8
/po-docs/*/*.pl
/po-docs/po4a.conf
/po-docs/*/*.pod
/po-docs/*/stamp-update-po
/podwrapper.1
/podwrapper.pl
/po/*.gmo
/python/bindtests.py
/python/examples/guestfs-python.3
/python/examples/stamp-guestfs-python.pod
/python/guestfs.py
/python/guestfs-py.c
/python/guestfs.pyc
/python/guestfs.pyo
/python/__pycache__
/qemu-wrapper.sh
/rescue/stamp-virt-rescue.pod
/rescue/virt-rescue
/rescue/virt-rescue.1
/resize/.depend
/resize/resize_gettext.ml
/resize/resize_utils_tests
/resize/stamp-virt-resize.pod
/resize/virt-resize
/resize/virt-resize.1
/ruby/bindtests.rb
/ruby/doc/site/api
/ruby/examples/guestfs-ruby.3
/ruby/examples/stamp-guestfs-ruby.pod
/ruby/ext/guestfs/extconf.h
/ruby/ext/guestfs/extconf.rb
/ruby/ext/guestfs/_guestfs.bundle
/ruby/ext/guestfs/_guestfs.c
/ruby/ext/guestfs/_guestfs.so
/ruby/ext/guestfs/mkmf.log
/ruby/Rakefile
/run
/sparsify/.depend
/sparsify/sparsify_gettext.ml
/sparsify/stamp-virt-sparsify.pod
/sparsify/virt-sparsify
/sparsify/virt-sparsify.1
/src/actions-?.c
/src/actions-variants.c
/src/bindtests.c
/src/errnostring.c
/src/errnostring-gperf.c
/src/errnostring-gperf.gperf
/src/errnostring.h
/src/free-structs.c
/src/guestfs.3
/src/guestfs-actions.pod
/src/guestfs-availability.pod
/src/guestfs.h
/src/guestfs-internal-actions.h
/src/guestfs-internal-frontend-cleanups.h
/src/guestfs_protocol.c
/src/guestfs_protocol.h
/src/guestfs_protocol.x
/src/guestfs-structs.pod
/src/libguestfs.pc
/src/libguestfs.syms
/src/.libs/libguestfs.so
/src/stamp-guestfs.pod
/stamp-guestfs-release-notes.pod
/stamp-h1
/sysprep/.depend
/sysprep/stamp-script1.sh
/sysprep/stamp-script2.sh
/sysprep/stamp-virt-sysprep.pod
/sysprep/sysprep-extra-options.pod
/sysprep/sysprep_gettext.ml
/sysprep/sysprep-operations.pod
/sysprep/virt-sysprep
/sysprep/virt-sysprep.1
/test1.img
/test2.img
/test.err
/test.out
/tests/c-api/test-add-drive-opts
/tests/c-api/test-add-libvirt-dom
/tests/c-api/test-command
/tests/c-api/test-config
/tests/c-api/test-create-handle
/tests/c-api/test-debug-to-file
/tests/c-api/test-environment
/tests/c-api/test*.img
/tests/c-api/test-just-header
/tests/c-api/test-just-header-cxx
/tests/c-api/test-last-errno
/tests/c-api/test.log
/tests/c-api/test-private-data
/tests/c-api/test-pwd
/tests/c-api/tests
/tests/c-api/tests.c
/tests/c-api/test*.tmp
/tests/c-api/test-user-cancel
/tests/charsets/test-charset-fidelity
/tests/data/100kallnewlines
/tests/data/100kallspaces
/tests/data/100kallzeroes
/tests/data/100krandom
/tests/data/10klines
/tests/data/abssymlink
/tests/data/hello.b64
/tests/data/initrd
/tests/data/initrd-x86_64.img
/tests/data/initrd-x86_64.img.gz
/tests/data/test-grep.txt.gz
/tests/data/test.iso
/tests/guests/debian.img
/tests/guests/fedora.img
/tests/guests/fedora-md1.img
/tests/guests/fedora-md2.img
/tests/guests/guest-aux/fedora-name.db
/tests/guests/guest-aux/fedora-packages.db
/tests/guests/stamp-fedora-md.img
/tests/guests/ubuntu.img
/tests/guests/windows.img
/tests/mount-local/test-parallel-mount-local
/tests/parallel/test-parallel
/tests/regressions/rhbz501893
/tests/regressions/rhbz790721
/tests/rsync/rsyncd.pid
/test-tool/libguestfs-test-tool
/test-tool/libguestfs-test-tool.1
/test-tool/libguestfs-test-tool-helper
/test-tool/stamp-libguestfs-test-tool.pod
/tools/test.img
/tools/virt-*.1
/tools/virt-*.pl
/valgrind.log*

Submodule .gnulib updated: b64318247b...4a8c422f31

View File

@@ -5,5 +5,5 @@
set sw=2
set ts=2
set tw=80
set tw=70
set expandtab

13
.mailmap Normal file
View File

@@ -0,0 +1,13 @@
Jim Meyering <meyering@redhat.com> <jim@meyering.net>
Jim Meyering <meyering@redhat.com> <meyering@vv.meyering.net.meyering.net>
Richard W.M. Jones <rjones@redhat.com> Richard Jones <rich@hakodate.home.annexia.org>
Richard W.M. Jones <rjones@redhat.com> Richard Jones <rich@koneko.home.annexia.org>
Richard W.M. Jones <rjones@redhat.com> Richard Jones <rich@koneko.local>
Richard W.M. Jones <rjones@redhat.com> Richard Jones <rjones@centos5x32.home.annexia.org>
Richard W.M. Jones <rjones@redhat.com> Richard Jones <rjones@debian5x64.home.annexia.org>
Richard W.M. Jones <rjones@redhat.com> Richard Jones <rjones@redhat.com>
Richard W.M. Jones <rjones@redhat.com> Richard Jones <rjones@trick.home.annexia.org>
Richard W.M. Jones <rjones@redhat.com> Richard Jones <rjones@ubuntu910x64.home.annexia.org>
Richard W.M. Jones <rjones@redhat.com> <rich@annexia.org>
Richard W.M. Jones <rjones@redhat.com> rjones <rjones>
Wanlong Gao <gaowanlong@cn.fujitsu.com> <wanlong.gao@gmail.com>

View File

@@ -10,4 +10,3 @@ source_lang = en
file_filter = po-docs/<lang>.po
source_file = po-docs/libguestfs-docs.pot
source_lang = en

View File

@@ -1,4 +1,3 @@
^appliance/debian/modules/
^tests/data/
^COPYING(.LIB)?$
^\.gitmodules$

14
AUTHORS
View File

@@ -1,25 +1,35 @@
Angus Salkeld <asalkeld@redhat.com>
Ani Peter <apeter@redhat.com>
Charles Duffy <cduffy@messageone.com>
Cole Robinson <crobinso@redhat.com>
Daniel Berrange <berrange@redhat.com>
Daniel Cabrera <logan@fedoraproject.org>
Douglas Schilling Landgraf <dougsland@redhat.com>
Eric Blake <eblake@redhat.com>
Erik Nolte <erik_nolte@acm.org>
Evaggelos Balaskas <ebalaskas@ebalaskas.gr>
Geert Warrink <geert.warrink@onsnet.nu>
Guido Günther <agx@sigxcpu.org>
Hilko Bengen <bengen@hilluzination.de>
Jaswinder Singh <jsingh@redhat.com>
Jim Meyering <jim@meyering.net>
Jim Meyering <meyering@redhat.com>
Jiri Popelka <jpopelka@redhat.com>
John Eckersberg <jeckersb@redhat.com>
Karel Klíč <kklic@redhat.com>
Marcin Gibula <m.gibula@e24cloud.com>
Masami HIRATA <msmhrt@gmail.com>
Matthew Booth <mbooth@redhat.com>
Maxim Koltsov <kolmax94@gmail.com>
Michael Scherer <misc@zarb.org>
Nikita A Menkovich <menkovich@gmail.com>
Nikos Skalkotos <skalkoto@gmail.com>
Olaf Hering <olaf@aepfle.de>
Piotr Drąg <piotrdrag@gmail.com>
Qin Guan <qguan@redhat.com>
Rajesh Ranjan <rranjan@redhat.com>
Richard W.M. Jones <rich@annexia.org>
Richard W.M. Jones <rjones@redhat.com>
Sandeep Shedmake <sshedmak@redhat.com>
Shankar Prasad <svenkate@redhat.com>
Thomas S Hatch <thatch45@gmail.com>
Wanlong Gao <gaowanlong@cn.fujitsu.com>
Wulf C. Krueger <philantrop@exherbo.org>

378
BUGS
View File

@@ -1,5 +1,5 @@
NOTE: This file is automatically generated from "update-bugs.sh".
Last updated: 2012-01-28
Last updated: 2013-02-11
This contains a local list of the bugs that are open against
libguestfs. Bugs are tracked in the Red Hat Bugzilla database
@@ -20,98 +20,17 @@ When reporting a new bug, please check:
--------------------------------------------------
Bugs in NEW or ASSIGNED state are open and waiting for someone to fix.
676020 NEW https://bugzilla.redhat.com/show_bug.cgi?id=676020
After using virt-resize with an ntfs partition windows is not booting
684486 NEW https://bugzilla.redhat.com/show_bug.cgi?id=684486
Guest fails to boot after virt-resize
691659 NEW https://bugzilla.redhat.com/show_bug.cgi?id=691659
libguestfs fails to run under JRuby 1.6.0
693064 NEW https://bugzilla.redhat.com/show_bug.cgi?id=693064
Symbolic links on ntfs-3g are not followed correctly by some commands
701814 NEW https://bugzilla.redhat.com/show_bug.cgi?id=701814
virt-win-reg fails on a libvirt guest that has no defined disk format: "format parameter is empty or contains disallowed characters"
709326 NEW https://bugzilla.redhat.com/show_bug.cgi?id=709326
virt-inspector cannot detect ReactOS
728224 NEW https://bugzilla.redhat.com/show_bug.cgi?id=728224
configure can't find qemu on PPC
729076 NEW https://bugzilla.redhat.com/show_bug.cgi?id=729076
libguestfs confuses Hp_recovery partition with Windows root filesystem
731742 NEW https://bugzilla.redhat.com/show_bug.cgi?id=731742
libguestfs should escape special/non-printing characters in debug output
737261 NEW https://bugzilla.redhat.com/show_bug.cgi?id=737261
libguestfs grub-install API needs grub1
745576 NEW https://bugzilla.redhat.com/show_bug.cgi?id=745576
libguestfs (or qemu?) hangs if sparse file runs out of disk space
745606 NEW https://bugzilla.redhat.com/show_bug.cgi?id=745606
libguestfs: error: part_list: could not parse row from output of parted print command
760221 NEW https://bugzilla.redhat.com/show_bug.cgi?id=760221
RFE: Support inspection of cciss devices
761565 NEW https://bugzilla.redhat.com/show_bug.cgi?id=761565
Missing deps on netpbm-progs and icoutils
767852 NEW https://bugzilla.redhat.com/show_bug.cgi?id=767852
dependency on fuse suggested
769304 NEW https://bugzilla.redhat.com/show_bug.cgi?id=769304
virt-resize on RHEL 6 kernel fails to re-read the partition table
769359 NEW https://bugzilla.redhat.com/show_bug.cgi?id=769359
virt-resize on RHEL 6 kernel fails to re-read the partition table
770075 NEW https://bugzilla.redhat.com/show_bug.cgi?id=770075
FEBOOTSTRAP_MODULES fails if modules directory is not under /lib
770076 NEW https://bugzilla.redhat.com/show_bug.cgi?id=770076
FEBOOTSTRAP_KERNEL causes appliance build to fail
782167 NEW https://bugzilla.redhat.com/show_bug.cgi?id=782167
libguestfs doesn't recognize Windows Dynamic disks in some configurations, eg. spanned
785290 NEW https://bugzilla.redhat.com/show_bug.cgi?id=785290
ocaml (bytecode) bindings segfault in 'add_drive_opts'
785305 NEW https://bugzilla.redhat.com/show_bug.cgi?id=785305
ocaml (bytecode) bindings segfault in 'add_drive_opts'
563450 NEW https://bugzilla.redhat.com/show_bug.cgi?id=563450
list-devices returns devices of different types out of order
696445 NEW https://bugzilla.redhat.com/show_bug.cgi?id=696445
Backport virt-inspector for virt-v2v
507278 NEW https://bugzilla.redhat.com/show_bug.cgi?id=507278
libguestfs fails to build on Fedora sparc64
547488 NEW https://bugzilla.redhat.com/show_bug.cgi?id=547488
guestfish cannot tab complete filenames that contain spaces
672485 NEW https://bugzilla.redhat.com/show_bug.cgi?id=672485
[RFE] virt-edit/tar/inspector do not support encrypted system
679737 NEW https://bugzilla.redhat.com/show_bug.cgi?id=679737
libguestfs: improve error message when zerofree is not available in the appliance
745282 NEW https://bugzilla.redhat.com/show_bug.cgi?id=745282
[RFE] Support to use virt-filesystems with remote libvirt systems
507278 NEW https://bugzilla.redhat.com/show_bug.cgi?id=507278
libguestfs fails to build on Fedora sparc64
554829 NEW https://bugzilla.redhat.com/show_bug.cgi?id=554829
SELinux handling could be done better.
555803 NEW https://bugzilla.redhat.com/show_bug.cgi?id=555803
guestfs_tgz_out does not detect failure of tar command
563450 NEW https://bugzilla.redhat.com/show_bug.cgi?id=563450
list-devices returns devices of different types out of order
572337 NEW https://bugzilla.redhat.com/show_bug.cgi?id=572337
libguestfs should support gptsync
@@ -119,15 +38,9 @@ Bugs in NEW or ASSIGNED state are open and waiting for someone to fix.
578103 NEW https://bugzilla.redhat.com/show_bug.cgi?id=578103
[RFE] Tool to Compare Windows Registry Entries
592910 NEW https://bugzilla.redhat.com/show_bug.cgi?id=592910
'guestfish --remote run' hangs in a shell command substitution context
593511 NEW https://bugzilla.redhat.com/show_bug.cgi?id=593511
[RFE] function to get partition name
596354 NEW https://bugzilla.redhat.com/show_bug.cgi?id=596354
guestfish.1.html and guestfs.3.html declared "XHTML 1.0 Strict" but are not in fact well-formed XML
604041 NEW https://bugzilla.redhat.com/show_bug.cgi?id=604041
guestmount absolute symlinks don't work
@@ -137,77 +50,286 @@ Bugs in NEW or ASSIGNED state are open and waiting for someone to fix.
624335 NEW https://bugzilla.redhat.com/show_bug.cgi?id=624335
blockdev-setbsz succeeds, but does not affect blockdev-getbsz
627675 NEW https://bugzilla.redhat.com/show_bug.cgi?id=627675
libguestfs inspector code cannot handle /dev/disk/by-id/* paths
635971 NEW https://bugzilla.redhat.com/show_bug.cgi?id=635971
glob mkfs ext2 /dev/vd[b-t]1 does not expand
637251 NEW https://bugzilla.redhat.com/show_bug.cgi?id=637251
virt-inspector fails to recognize data-only NTFS disk image
646036 NEW https://bugzilla.redhat.com/show_bug.cgi?id=646036
libguestfs fails to launch
660687 NEW https://bugzilla.redhat.com/show_bug.cgi?id=660687
guestmount: "touch" command fails: touch: setting times of `timestamp': Invalid argument
672485 NEW https://bugzilla.redhat.com/show_bug.cgi?id=672485
[RFE] virt-edit/tar/inspector do not support encrypted system
693064 NEW https://bugzilla.redhat.com/show_bug.cgi?id=693064
Symbolic links on ntfs-3g are not followed correctly by some commands
696445 NEW https://bugzilla.redhat.com/show_bug.cgi?id=696445
Backport virt-inspector for virt-v2v
696451 NEW https://bugzilla.redhat.com/show_bug.cgi?id=696451
libguestfs: unknown filesystem label SWAP-sda2
696484 NEW https://bugzilla.redhat.com/show_bug.cgi?id=696484
[RFE] virt-v2v show the warning info after convert rhel4u8 guest if comment a line of swap in the fstab
700342 NEW https://bugzilla.redhat.com/show_bug.cgi?id=700342
virt-inspector resports unknown filesystem UUID
741183 NEW https://bugzilla.redhat.com/show_bug.cgi?id=741183
[RFE] Write a tool to align the partition(s) in a Windows XP image to a multiple of 8 sectors
709326 NEW https://bugzilla.redhat.com/show_bug.cgi?id=709326
virt-inspector cannot detect ReactOS
713678 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=713678
Not all febootstrap messages are redirected to log callbacks
737261 NEW https://bugzilla.redhat.com/show_bug.cgi?id=737261
libguestfs grub-install API needs grub1
721160 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=721160
Missing btrfs support
745282 NEW https://bugzilla.redhat.com/show_bug.cgi?id=745282
[RFE] Support to use virt-filesystems with remote libvirt systems
583974 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=583974
mount hangs there when you lack proper permission to guest image
745576 NEW https://bugzilla.redhat.com/show_bug.cgi?id=745576
libguestfs (or qemu?) hangs if sparse file runs out of disk space
647174 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=647174
RHEL6: virt-clone should remove old udev rules when changing MAC address
770075 NEW https://bugzilla.redhat.com/show_bug.cgi?id=770075
FEBOOTSTRAP_MODULES fails if modules directory is not under /lib
539746 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=539746
launch fails when run inside a Xen guest, when no non-PV kernels are installed
770076 NEW https://bugzilla.redhat.com/show_bug.cgi?id=770076
FEBOOTSTRAP_KERNEL causes appliance build to fail
785603 NEW https://bugzilla.redhat.com/show_bug.cgi?id=785603
copy-out "No such file or directory"
790837 NEW https://bugzilla.redhat.com/show_bug.cgi?id=790837
Use of atexit to clean up handles is wrong in multithreaded programs
803650 NEW https://bugzilla.redhat.com/show_bug.cgi?id=803650
inspect-is-live return false when inspection results should be true
803657 NEW https://bugzilla.redhat.com/show_bug.cgi?id=803657
[RFE] inspect-is-netinst : support more distributions
805417 NEW https://bugzilla.redhat.com/show_bug.cgi?id=805417
RFE: support inspection of installation ISOs of WinVista, Win7, Win2008 & Win2008r2
806179 NEW https://bugzilla.redhat.com/show_bug.cgi?id=806179
RFE: support inspection of icon for more Windows guests
808193 NEW https://bugzilla.redhat.com/show_bug.cgi?id=808193
g.launch() crashes on RHEL 5
812970 NEW https://bugzilla.redhat.com/show_bug.cgi?id=812970
virt-rescue cannot set ><rescue> prompt, on Ubuntu 12.04
813290 NEW https://bugzilla.redhat.com/show_bug.cgi?id=813290
mdadm (md-detail) test occasionally fails with 'md device /dev/md125 does not appear to be active.'
815149 NEW https://bugzilla.redhat.com/show_bug.cgi?id=815149
virt-alignment-scan gives error "part_list: could not parse row from output of parted print command: /dev/vda:4194304B:virtblk:512:512:msdos:Virtio Block Device"
819086 NEW https://bugzilla.redhat.com/show_bug.cgi?id=819086
look for qemu-kvm on /usr/libexec
822538 NEW https://bugzilla.redhat.com/show_bug.cgi?id=822538
libguestfs tools hang on qcow2 encrypted disks
824021 NEW https://bugzilla.redhat.com/show_bug.cgi?id=824021
inspection cannot recognize guest which uses btrfs subvolumes for root
824782 NEW https://bugzilla.redhat.com/show_bug.cgi?id=824782
virt-resize cannot resize PowerPC guests
832602 NEW https://bugzilla.redhat.com/show_bug.cgi?id=832602
"error in chunked encoding" when trying to extract (tar-out) a truncated ISO image
833362 NEW https://bugzilla.redhat.com/show_bug.cgi?id=833362
virt-make-fs test fails on ppc64 because filesystem block size is 64k
835622 NEW https://bugzilla.redhat.com/show_bug.cgi?id=835622
RFE: virt-sparsify should be able to sparsify onto a thin-provisioned LV
837941 NEW https://bugzilla.redhat.com/show_bug.cgi?id=837941
Data loss when writing to qcow2-format disk files
838081 NEW https://bugzilla.redhat.com/show_bug.cgi?id=838081
ocaml/t/guestfs_500_parallel_mount_local crashes in caml_thread_reinitialize
845234 NEW https://bugzilla.redhat.com/show_bug.cgi?id=845234
RFE: virt-ls on Windows guest doesn't support drive letters
846676 NEW https://bugzilla.redhat.com/show_bug.cgi?id=846676
guestfs_launch() hangs with Debian qemu-kvm 1.1.0
848464 NEW https://bugzilla.redhat.com/show_bug.cgi?id=848464
gobject javascript bindings cannot use 64 bit integers
857763 NEW https://bugzilla.redhat.com/show_bug.cgi?id=857763
libguestfs 'file-architecture' returns 'ARM' for arm binaries
863696 NEW https://bugzilla.redhat.com/show_bug.cgi?id=863696
[F18] libguestfs fails to mount a disk image file(in this case qcow2) as 'root'
864871 NEW https://bugzilla.redhat.com/show_bug.cgi?id=864871
libvirt error: could not create appliance through libvirt: unable to set security context 'unconfined_u:object_r:svirt_image_t:s0:cXXX,cYYY' on '.../console.sock'
866994 NEW https://bugzilla.redhat.com/show_bug.cgi?id=866994
tgz-out causes memory leak in guestfsd
869179 NEW https://bugzilla.redhat.com/show_bug.cgi?id=869179
libguestfs fail to startup on latest rhel7 tree
880806 NEW https://bugzilla.redhat.com/show_bug.cgi?id=880806
virt-df with two -a options displays incorrect disk image name
887826 NEW https://bugzilla.redhat.com/show_bug.cgi?id=887826
RFE: virt-sparsify cannot handle multi-disk virtual machines (eg. if they use LVM, MD, LDM, etc)
889089 NEW https://bugzilla.redhat.com/show_bug.cgi?id=889089
Block device /dev/sd* didn't translate to /dev/vd*
890027 NEW https://bugzilla.redhat.com/show_bug.cgi?id=890027
virt-sysprep: Setting the hostname on Fedora 18 is stupidly over-complicated
891909 NEW https://bugzilla.redhat.com/show_bug.cgi?id=891909
Can't make install with non-standard prefix as non-root
892271 NEW https://bugzilla.redhat.com/show_bug.cgi?id=892271
virt-format fail to format the same disk more than twice with lvm enable
892272 NEW https://bugzilla.redhat.com/show_bug.cgi?id=892272
Specify QEMU interface emulation will break libguestfs
892275 NEW https://bugzilla.redhat.com/show_bug.cgi?id=892275
checksums-out fail to compute the checksums of all regular files in directory
892291 NEW https://bugzilla.redhat.com/show_bug.cgi?id=892291
guestmount: link() incorrectly returns ENOENT, when it should be EXDEV
892834 NEW https://bugzilla.redhat.com/show_bug.cgi?id=892834
guestmount: rename() incorrectly follows symbolic links
895898 NEW https://bugzilla.redhat.com/show_bug.cgi?id=895898
RFE: Allow interface to be specified with libvirt attach-method
895946 NEW https://bugzilla.redhat.com/show_bug.cgi?id=895946
Got incorrect block count number when resize ntfs file system via "ntfsresize_opts"
903890 NEW https://bugzilla.redhat.com/show_bug.cgi?id=903890
scrub-freespace didn't remove the scrub file, cause the file system 100% full
903972 NEW https://bugzilla.redhat.com/show_bug.cgi?id=903972
Command "acl-set-file" is inconvenient to use
903987 NEW https://bugzilla.redhat.com/show_bug.cgi?id=903987
Command "acl-set-file" is inconvenient to use
905322 NEW https://bugzilla.redhat.com/show_bug.cgi?id=905322
"No such file or directory" when execute "hivex-commit"
906190 NEW https://bugzilla.redhat.com/show_bug.cgi?id=906190
Need add a line break behind the output of command "hivex-value-value"
906766 NEW https://bugzilla.redhat.com/show_bug.cgi?id=906766
virt-resize cannot resize RHEL 5 guest with GPT partition table type
906777 NEW https://bugzilla.redhat.com/show_bug.cgi?id=906777
In tests, set_label sometimes fails
908255 NEW https://bugzilla.redhat.com/show_bug.cgi?id=908255
error message didn't translate to user language
909573 NEW https://bugzilla.redhat.com/show_bug.cgi?id=909573
patch libguestfs to use 'supermin' instead of 'febootstrap' in RHEL 7
909598 NEW https://bugzilla.redhat.com/show_bug.cgi?id=909598
libguestfs test failed: error: xfs_growfs: /: xfs_growfs: XFS_IOC_FSGROWFSDATA xfsctl failed: Cannot allocate memory
909619 NEW https://bugzilla.redhat.com/show_bug.cgi?id=909619
Unprivileged use of libguestfs fails with monitor socket permission denied
909666 NEW https://bugzilla.redhat.com/show_bug.cgi?id=909666
Unexpected non-tail recursion in recv_from_daemon results in stack overflow in very long-running API calls that send progress messages
909667 NEW https://bugzilla.redhat.com/show_bug.cgi?id=909667
Unexpected non-tail recursion in recv_from_daemon results in stack overflow in very long-running API calls that send progress messages
503134 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=503134
guestfish's list splitting does not recognize internal quoting
539746 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=539746
launch fails when run inside a Xen guest, when no non-PV kernels are installed
541618 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=541618
guestfish not able to mount freebsd ufs2 partitions automatically
619334 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=619334
RFE: Enable coredump capture in the appliance
691389 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=691389
Extended attributes don't work over guestmount (FUSE)
803643 ASSIGNED https://bugzilla.redhat.com/show_bug.cgi?id=803643
inspect-is-multipart return false when inspection results should be true
(81 bugs)
--------------------------------------------------
Bugs in MODIFIED, POST or ON_QA state are fixed.
You can help by testing the fixes.
691389 MODIFIED https://bugzilla.redhat.com/show_bug.cgi?id=691389
Extended attributes don't work over guestmount (FUSE)
889536 MODIFIED https://bugzilla.redhat.com/show_bug.cgi?id=889536
[RFE]It's better to emphasize "libguestfs-winsupport" in V2V manpage or error output
719879 MODIFIED https://bugzilla.redhat.com/show_bug.cgi?id=719879
Rebase libguestfs in RHEL 6.3
889537 MODIFIED https://bugzilla.redhat.com/show_bug.cgi?id=889537
Libguestfs live support should be disabled in RHEL 7 packages
750889 MODIFIED https://bugzilla.redhat.com/show_bug.cgi?id=750889
Python code incompatible with Python v3.
889538 MODIFIED https://bugzilla.redhat.com/show_bug.cgi?id=889538
libguestfs can not be installed with recent iptables
784647 MODIFIED https://bugzilla.redhat.com/show_bug.cgi?id=784647
Libguestfs uses deprecated net-tools
(3 bugs)
657499 MODIFIED https://bugzilla.redhat.com/show_bug.cgi?id=657499
checksum: wrong check sum type causes umount to fail
--------------------------------------------------
These bugs are in the VERIFIED state.
749828 ON_QA https://bugzilla.redhat.com/show_bug.cgi?id=749828
p2v does not support raid devices
865923 VERIFIED https://bugzilla.redhat.com/show_bug.cgi?id=865923
Check that new qemu -machine option doesn't break libguestfs.
(1 bugs)
--------------------------------------------------
These bugs are in the RELEASE_PENDING state.
801640 RELEASE_PENDING https://bugzilla.redhat.com/show_bug.cgi?id=801640
[RFE] the error reported by resize2fs-M need to be more clear
816839 RELEASE_PENDING https://bugzilla.redhat.com/show_bug.cgi?id=816839
data overflow error when debug progress -1
822626 RELEASE_PENDING https://bugzilla.redhat.com/show_bug.cgi?id=822626
virt-ls error: "libguestfs: error: checksum: path: parameter cannot be NULL"
830135 RELEASE_PENDING https://bugzilla.redhat.com/show_bug.cgi?id=830135
libguestfs should support mount-local APIs in RHEL 6 (for OpenStack)
836501 RELEASE_PENDING https://bugzilla.redhat.com/show_bug.cgi?id=836501
dependency on fuse suggested
837691 RELEASE_PENDING https://bugzilla.redhat.com/show_bug.cgi?id=837691
Data loss when writing to qcow2-format disk files
838609 RELEASE_PENDING https://bugzilla.redhat.com/show_bug.cgi?id=838609
guestmount + fusermount allows a race condition when unmounting and immediately using the disk image
853763 RELEASE_PENDING https://bugzilla.redhat.com/show_bug.cgi?id=853763
virt-sparsify should use a more robust method to detect the input format
858126 RELEASE_PENDING https://bugzilla.redhat.com/show_bug.cgi?id=858126
virt-inspector fail to work with some windows guests
858128 RELEASE_PENDING https://bugzilla.redhat.com/show_bug.cgi?id=858128
libguestfs fail to list devices added by add-drive-ro-with-if twice
858648 RELEASE_PENDING https://bugzilla.redhat.com/show_bug.cgi?id=858648
libguestfs can not be installed with recent iptables
880805 RELEASE_PENDING https://bugzilla.redhat.com/show_bug.cgi?id=880805
virt-df with two -a options displays incorrect disk image name
883338 RELEASE_PENDING https://bugzilla.redhat.com/show_bug.cgi?id=883338
Missing #include <locale.h> in fuse/guestmount.c
(13 bugs)
End of BUGS file.

14
COPYING
View File

@@ -1,12 +1,12 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
@@ -56,7 +56,7 @@ patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
@@ -255,7 +255,7 @@ make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
@@ -277,9 +277,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it

View File

@@ -1,112 +1,125 @@
GNU LIBRARY GENERAL PUBLIC LICENSE
Version 2, June 1991
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the library GPL. It is
numbered 2 because it goes with version 2 of the ordinary GPL.]
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Library General Public License, applies to some
specially designated Free Software Foundation software, and to any
other libraries whose authors decide to use it. You can use it for
your libraries, too.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if
you distribute copies of the library, or if you modify it.
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link a program with the library, you must provide
complete object files to the recipients so that they can relink them
with the library, after making changes to the library and recompiling
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
Our method of protecting your rights has two steps: (1) copyright
the library, and (2) offer you this license which gives you legal
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
Also, for each distributor's protection, we want to make certain
that everyone understands that there is no warranty for this free
library. If the library is modified by someone else and passed on, we
want its recipients to know that what they have is not the original
version, so that any problems introduced by others will not reflect on
the original authors' reputations.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that companies distributing free
software will individually obtain patent licenses, thus in effect
transforming the program into proprietary software. To prevent this,
we have made it clear that any patent must be licensed for everyone's
free use or not licensed at all.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the ordinary
GNU General Public License, which was designed for utility programs. This
license, the GNU Library General Public License, applies to certain
designated libraries. This license is quite different from the ordinary
one; be sure to read it in full, and don't assume that anything in it is
the same as in the ordinary license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
The reason we have a separate public license for some libraries is that
they blur the distinction we usually make between modifying or adding to a
program and simply using it. Linking a program with a library, without
changing the library, is in some sense simply using the library, and is
analogous to running a utility program or application program. However, in
a textual and legal sense, the linked executable is a combined work, a
derivative of the original library, and the ordinary General Public License
treats it as such.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
Because of this blurred distinction, using the ordinary General
Public License for libraries did not effectively promote software
sharing, because most developers did not use the libraries. We
concluded that weaker conditions might promote sharing better.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
However, unrestricted linking of non-free programs would deprive the
users of those programs of all benefit from the free status of the
libraries themselves. This Library General Public License is intended to
permit developers of non-free programs to use free libraries, while
preserving your freedom as a user of such programs to change the free
libraries that are incorporated in them. (We have not seen how to achieve
this as regards changes in header files, but we have achieved it as regards
changes in the actual functions of the Library.) The hope is that this
will lead to faster development of free libraries.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, while the latter only
works together with the library.
Note that it is possible for a library to be covered by the ordinary
General Public License rather than by this special one.
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LIBRARY GENERAL PUBLIC LICENSE
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library which
contains a notice placed by the copyright holder or other authorized
party saying it may be distributed under the terms of this Library
General Public License (also called "this License"). Each licensee is
addressed as "you".
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
@@ -255,7 +268,7 @@ distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also compile or
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
@@ -282,23 +295,31 @@ of these things:
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Accompany the work with a written offer, valid for at
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
c) If distribution of the work is made by offering access to copy
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
d) Verify that the user has already received a copy of these
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the source code distributed need not include anything that is normally
distributed (in either source or binary form) with the major
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
@@ -347,7 +368,7 @@ Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
@@ -390,7 +411,7 @@ excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Library General Public License from time to time.
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
@@ -411,7 +432,7 @@ decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
@@ -434,9 +455,9 @@ FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Libraries
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
@@ -453,19 +474,18 @@ convey the exclusion of warranty; and each file should have at least the
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
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.
version 2.1 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
Library General Public License for more details.
Lesser General Public License for more details.
You should have received a copy of the GNU Library 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
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
Also add information on how to contact you by electronic and paper mail.

View File

@@ -1,5 +1,5 @@
# libguestfs
# Copyright (C) 2009-2012 Red Hat Inc.
# Copyright (C) 2009-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
@@ -15,6 +15,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-include $(top_builddir)/localenv
include $(top_srcdir)/subdir-rules.mk
ACLOCAL_AMFLAGS = -I m4
@@ -37,16 +39,27 @@ if ENABLE_APPLIANCE
SUBDIRS += tests/qemu
SUBDIRS += tests/guests
SUBDIRS += tests/c-api
SUBDIRS += tests/tmpdirs
SUBDIRS += tests/protocol
SUBDIRS += tests/parallel
SUBDIRS += tests/disks
SUBDIRS += tests/lvm
SUBDIRS += tests/luks
SUBDIRS += tests/md
SUBDIRS += tests/selinux
SUBDIRS += tests/ntfsclone
SUBDIRS += tests/btrfs
SUBDIRS += tests/charsets
SUBDIRS += tests/xml
SUBDIRS += tests/mount-local
SUBDIRS += tests/9p
SUBDIRS += tests/rsync
SUBDIRS += tests/bigdirs
SUBDIRS += tests/disk-labels
SUBDIRS += tests/hotplug
SUBDIRS += tests/regressions
endif
# Extra tests don't run by default. You have to do 'make extra-tests'.
SUBDIRS += tests/extra
# libguestfs-test-tool
SUBDIRS += test-tool
@@ -81,6 +94,9 @@ endif
if HAVE_ERLANG
SUBDIRS += erlang erlang/examples
endif
if HAVE_LUA
SUBDIRS += lua lua/examples
endif
if HAVE_GOBJECT
SUBDIRS += gobject
endif
@@ -88,9 +104,9 @@ endif
# Unconditional because nothing is built yet.
SUBDIRS += csharp
# virt-resize (new version) and virt-sparsify are written in OCaml.
# OCaml tools.
if HAVE_OCAML
SUBDIRS += resize sparsify
SUBDIRS += resize sparsify sysprep
endif
# Perl tools.
@@ -103,11 +119,6 @@ if HAVE_FUSE
SUBDIRS += fuse
endif
# virt-tools in shell. This uses guestmount and virt-inspector.
if HAVE_FUSE
SUBDIRS += clone
endif
# po-docs must come after tools, inspector.
if HAVE_PO4A
SUBDIRS += po-docs
@@ -115,17 +126,27 @@ endif
EXTRA_DIST = \
$(generator_built) \
BUGS HACKING RELEASE-NOTES ROADMAP TODO \
BUGS HACKING ROADMAP TODO \
.gitignore \
.lvimrc \
.mailmap \
.tx/config \
bugs-in-changelog.sh \
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 \
contrib/intro/talk.txt \
contrib/intro/tools.png \
contrib/intro/tools.svg \
contrib/intro/virt-manager-t.png \
contrib/intro/virt-manager.png \
contrib/intro/vmm-icons-t.png \
contrib/intro/vmm-icons.png \
contrib/intro/win7.xml \
contrib/make-check-on-installed.pl \
contrib/README \
contrib/visualize-alignment/.gitignore \
@@ -138,55 +159,40 @@ EXTRA_DIST = \
contrib/visualize-alignment/qemu-0.13-trace-block-device-access.patch \
contrib/visualize-alignment/README \
contrib/visualize-alignment/tracetops.ml \
debian/.gitignore \
debian/changelog \
debian/compat \
debian/control \
debian/copyright \
debian/docs \
debian/guestfish.dirs \
debian/guestfish.install \
debian/guestfsd.dirs \
debian/guestfsd.install \
debian/guestmount.dirs \
debian/guestmount.install \
debian/libguestfs-dev.dirs \
debian/libguestfs-dev.install \
debian/libguestfs-doc.docs \
debian/libguestfs-perl.examples \
debian/libguestfs-perl.install \
debian/libguestfs-tools.dirs \
debian/libguestfs-tools.install \
debian/libguestfs0.dirs \
debian/libguestfs0.install \
debian/patches/series \
debian/python-guestfs.install \
debian/pyversions \
debian/rules \
debian/shlibs.local \
debian/watch \
guestfs-release-notes.pod \
guestfs-release-notes.txt \
html/draft.png \
html/draft.svg \
html/pod.css \
libguestfs.pc libguestfs.pc.in \
libtool-kill-dependency_libs.sh \
logo/fish.svg logo/fish.png \
m4/.gitignore \
run \
update-bugs.sh
tmp/.gitignore \
tx-pull.sh \
update-bugs.sh \
valgrind-suppressions
# The website.
HTMLFILES = \
html/guestfs.3.html \
html/guestfs-examples.3.html \
html/guestfs-erlang.3.html \
html/guestfs-faq.1.html \
html/guestfs-java.3.html \
html/guestfs-lua.3.html \
html/guestfs-ocaml.3.html \
html/guestfs-performance.1.html \
html/guestfs-perl.3.html \
html/guestfs-python.3.html \
html/guestfs-recipes.1.html \
html/guestfs-release-notes.1.html \
html/guestfs-ruby.3.html \
html/guestfs-testing.1.html \
html/guestfsd.8.html \
html/guestfish.1.html \
html/guestmount.1.html \
html/libguestfs-make-fixed-appliance.1.html \
html/libguestfs-test-tool.1.html \
html/virt-alignment-scan.1.html \
html/virt-cat.1.html \
html/virt-copy-in.1.html \
@@ -209,7 +215,9 @@ HTMLFILES = \
html/virt-tar-out.1.html \
html/virt-win-reg.1.html
TEXTFILES = BUGS README RELEASE-NOTES ROADMAP TODO
HTMLSUPPORTFILES = html/draft.png html/pod.css
TEXTFILES = BUGS README ROADMAP TODO
WEBSITEDIR = $(HOME)/d/redhat/websites/libguestfs
@@ -218,7 +226,7 @@ WEBSITEDIR = $(HOME)/d/redhat/websites/libguestfs
website: $(HTMLFILES) $(TEXTFILES)
find -name 'stamp-*.pod' -delete
$(MAKE)
cp $(HTMLFILES) $(WEBSITEDIR)
cp $(HTMLFILES) $(HTMLSUPPORTFILES) $(WEBSITEDIR)
for f in $(TEXTFILES); do cp $$f $(WEBSITEDIR)/$$f.txt; done
cd $(WEBSITEDIR) && \
date=`date +%F`; \
@@ -233,14 +241,13 @@ dist-hook:
$(top_srcdir)/update-bugs.sh > BUGS-t
mv BUGS-t BUGS
cp BUGS $(distdir)/BUGS
git log --pretty="format:%an <%ae>" | sort -u | uniq -w 10 | \
grep -v rjones | \
grep -v "Richard Jones" \
> AUTHORS-t
git shortlog -se | awk -F'\t' '{print $$2}' > AUTHORS-t
mv AUTHORS-t AUTHORS
cp AUTHORS $(distdir)/AUTHORS
# Update the list of translatable files in po/POTFILES.in.
# Update the list of translatable files (po/POTFILES po/POTFILES-ml).
# This has to be in the top-level Makefile.am so that we have access
# to DIST_SUBDIRS.
all-local:
cd $(srcdir); \
find $(DIST_SUBDIRS) \
@@ -254,43 +261,164 @@ all-local:
grep -v '^perl/examples/' | \
grep -v '/guestfs_protocol.c' | \
grep -v '/rc_protocol.c' | \
grep -v 'appliance/debian/root' | \
grep -v '^po-docs/' | \
grep -v '^images/' | \
LC_ALL=C sort | \
sed 's,^\./,,' > po/POTFILES.in
sed 's,^\./,,' > po/POTFILES
cd $(srcdir); \
find resize sparsify sysprep -name '*.ml' | \
LC_ALL=C sort > po/POTFILES-ml
# Pkgconfig.
# Manual pages in top level directory.
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libguestfs.pc
man_MANS = \
guestfs-release-notes.1
noinst_DATA = \
$(top_builddir)/html/guestfs-release-notes.1.html
guestfs-release-notes.1 guestfs-release-notes.txt $(top_builddir)/html/guestfs-release-notes.1.html: stamp-guestfs-release-notes.pod
stamp-guestfs-release-notes.pod: guestfs-release-notes.pod
$(PODWRAPPER) \
--section 1 \
--man guestfs-release-notes.1 \
--text guestfs-release-notes.txt \
--html $(top_builddir)/html/guestfs-release-notes.1.html \
--license GPLv2+ \
$<
touch $@
# NB. podwrapper is an internal tool, so the man page mustn't be installed.
noinst_MANS = podwrapper.1
podwrapper.1: podwrapper.pl
$(PODWRAPPER) \
--section 1 \
--man $@-t \
--license GPLv2+ \
$<
mv $@-t $@
# Make clean.
CLEANFILES = \
html/*.html \
pod2htm?.tmp \
html/*.html
podwrapper.1 \
qemu-wrapper.sh \
stamp-guestfs-release-notes.pod
# If you don't want to run all of the tests ('make check') then this
# will just run libguestfs-test-tool for a quick check. Note this
# is NOT a substitute for proper testing!
quickcheck:
./run test-tool/libguestfs-test-tool $(QUICKCHECK_TEST_TOOL_ARGS)
$(top_builddir)/run test-tool/libguestfs-test-tool $(QUICKCHECK_TEST_TOOL_ARGS)
# Run extra-tests in tests/extra/ subdirectory.
# Non-standard tests.
extra-tests:
make -C tests/extra $@
$(MAKE) -j1 \
valgrind \
valgrind-local-guests \
check-with-appliance \
check-with-upstream-qemu \
check-with-upstream-libvirt \
check-slow
# Make binary distribution.
check-valgrind: build-test-guests
@for f in `grep -l '^$@:' $(SUBDIRS:%=%/Makefile.am)`; do \
echo $(MAKE) -C `dirname $$f` $@; \
$(MAKE) -C `dirname $$f` $@ || exit $$?; \
done
BINTMPDIR = /tmp/libguestfs-bin
bindist:
rm -rf $(BINTMPDIR)
mkdir $(BINTMPDIR)
$(MAKE)
$(MAKE) DESTDIR=$(BINTMPDIR) install
-find $(BINTMPDIR) -type d -exec rmdir --ignore-fail-on-non-empty {} \;
(cd $(BINTMPDIR) && tar cf - .) | \
gzip -c -9 > libguestfs-$(VERSION)-$(DISTRO)-$(host_cpu).tar.gz
check-valgrind-local-guests:
@GUESTS=`$(top_builddir)/run ./pick-guests.pl 5`; \
for f in `grep -l '^$@:' $(SUBDIRS:%=%/Makefile.am)`; do \
echo $(MAKE) GUESTS="$$GUESTS" -C `dirname $$f` $@; \
$(MAKE) GUESTS="$$GUESTS" -C `dirname $$f` $@ || exit $$?; \
done
check-slow: build-test-guests
for f in `grep -l '^$@:' $(SUBDIRS:%=%/Makefile.am)`; do \
echo $(MAKE) -C `dirname $$f` $@; \
$(MAKE) -C `dirname $$f` $@ || exit $$?; \
done
build-test-guests:
$(MAKE) -C tests/guests check
check-with-appliance:
@method=`$(top_builddir)/run ./fish/guestfish get-attach-method`; \
if [ "$$method" != "appliance" ]; then \
$(MAKE) LIBGUESTFS_ATTACH_METHOD=appliance check || exit $$?; \
fi
QEMUDIR = $(HOME)/d/qemu
QEMUBINARY = $(QEMUDIR)/x86_64-softmmu/qemu-system-x86_64
check-with-upstream-qemu:
rm -f $(top_builddir)/qemu-wrapper.sh
$(MAKE) check-with-upstream-qemu-1 || exit $$?
check-with-upstream-qemu-1: $(top_builddir)/qemu-wrapper.sh
$(QEMUBINARY) --version
$(MAKE) LIBGUESTFS_QEMU=$(abs_top_builddir)/qemu-wrapper.sh check
$(top_builddir)/qemu-wrapper.sh: Makefile
rm -f $@ $@-t
echo -e "#!/bin/sh\nexec" "$(QEMUBINARY)" -L "$(QEMUDIR)/pc-bios" \"\$$@\" > $@-t
chmod +x,-w $@-t
mv $@-t $@
LIBVIRTDIR = $(HOME)/d/libvirt
check-with-upstream-libvirt:
@method=`$(top_builddir)/run ./fish/guestfish get-attach-method`; \
if [ "$$method" = "libvirt" ] && [ -x "$(LIBVIRTDIR)/run" ]; then \
$(LIBVIRTDIR)/run $(MAKE) check || exit $$?; \
fi
# Print subdirs.
#
# If you want to selectively run tests, or if the test suite fails half
# way through, use:
#
# make print-subdirs
#
# to print the subdirectories, select the ones you want to run / the
# remaining ones, and do:
#
# make check SUBDIRS="..."
print-subdirs:
@echo $(SUBDIRS)
# Provide help on common Makefile targets.
help:
@echo
@echo "make Build everything."
@echo
@echo "make check Run the standard tests"
@echo "make -k check ... and display all errors at once."
@echo
@echo "make extra-tests ... runs all of the following tests:"
@echo " make check-valgrind Run a subset of the tests under valgrind."
@echo " make check-valgrind-local-guests Test under valgrind using local guests."
@echo " make check-with-appliance Test using appliance attach-method."
@echo " make check-with-upstream-qemu Test using upstream qemu."
@echo " make check-with-upstream-libvirt Test using upstream libvirt."
@echo " make check-slow Slow/long-running tests."
@echo
@echo "make syntax-check Check syntax and style problems in the code."
@echo "make print-subdirs Print subdirectories."
@echo
@echo "make install Install everything."
@echo
@echo "make clean Clean everything."
@echo
@echo "To run programs without installing:"
@echo " ./run ./fish/guestfish [or any other program]"
@echo
@echo "For more information, see EXTENDING LIBGUESTFS in guestfs(3); and README."
@echo

371
README
View File

@@ -26,134 +26,218 @@ Fedora/RHEL users:
Debian/Ubuntu users:
Take a look at the debian/control file and install everything listed
in "Build-Depends". If that is successful, you don't need to bother
with the rest of this section.
Use:
apt-get build-dep libguestfs
to install all build dependencies. If that doesn't work, take a
look at the Debian source package:
http://packages.debian.org/source/libguestfs
at the list of 'build-depends' and 'build-depends-indep', and
install everything listed there.
If either of those techniques is successful, you don't need to
bother with the rest of this section.
The full requirements are described below.
For basic functionality and the C tools:
- look at appliance/packagelist.in and install as many of the packages
that apply to your distro as possible
- recent QEMU >= 0.13 (0.14 or later is better) with virtio-serial support
- kernel >= 2.6.34 with virtio-serial support enabled.
- virtio-block and virtio-net drivers should be compiled into your
host kernel (strictly speaking this is optional, but you will have
to make complex changes to the ./configure command line to get it
to work if you don't have virtio)
- febootstrap >= 3.3 (it is best to use the latest version)
Notes: (1) febootstrap 2.x WILL NOT WORK
(2) febootstrap 3.x is distro-independent, and is required on
Debian and other distros as well as Fedora
- XDR, rpcgen (on Linux these are provided by glibc)
- cpio
- gperf
- pcre (Perl Compatible Regular Expressions C library)
- genisoimage (NOT mkisofs any more)
- hivex >= 1.2.7 (http://libguestfs.org/download) (optional)
- libmagic (the library that corresponds to the 'file' command) (optional)
- libvirt (optional)
- libxml2 (optional)
- libconfig (optional)
- augeas >= 0.5.0 (http://augeas.net/) (optional)
- Berkeley DB 'db_dump' and 'db_load' utilities
(db4-utils or db4.X-util or similar) (optional)
- systemtap/DTrace userspace probes (optional)
http://sourceware.org/systemtap/wiki/AddingUserSpaceProbingToApps
- perldoc (pod2man, pod2text, pod2html) to generate the manual pages
and other documentation.
- Readline to have nicer command-line editing in guestfish (optional)
- xmllint (part of libxml2) to validate virt-inspector
RELAX NG schema (optional)
- OCaml if you want to rebuild the generated files, and
also to build the OCaml bindings (optional)
- po4a for translating manpages and POD files.
This is optional when compiling from the tarball, but mandatory
if you compile from git.
- getfacl, getfattr libraries and programs (optional)
To build FUSE support (guestmount):
- FUSE libraries and kernel module (optional)
To build language bindings:
- Perl if you want to build the perl bindings (optional)
- Python if you want to build the python bindings (optional)
- Ruby, rake if you want to build the ruby bindings (optional)
- Java, JNI, jpackage-utils if you want to build the java
bindings (optional)
- GHC if you want to build the Haskell bindings (optional)
- PHP, phpize if you want to build the PHP bindings (optional)
To build the Perl tools:
- Perl Sys::Virt module (optional)
- Perl Win::Hivex module (optional)
- Perl Pod::Usage module (optional)
- Perl Test::More module (from perl Test::Simple) (optional)
- Perl String::ShellQuote module (optional)
- perl-libintl for translating perl code (optional)
To run virt-sysprep:
- virt-sysprep requires FUSE support since it uses guestmount
R = Required
O = Optional
+==============+=============+===+=========================================+
| Package name | Min.version | | Notes |
+==============+=============+===+=========================================+
| Install as many packages listed in appliance/packagelist.in as possible. |
| This installs the disk management tools required by the appliance. The |
| list below is *additional* packages needed on the host. |
+--------------+-------------+---+-----------------------------------------+
| qemu | 1.2.0 | R | 1.1 may work, but has broken virtio-scsi|
+--------------+-------------+---+-----------------------------------------+
| qemu-img | | R | |
+--------------+-------------+---+-----------------------------------------+
| kernel | 2.6.34 | R | Make sure the following are enabled |
| | | | compiled in or as a module: |
| | | | - virtio-pci |
| | | | - virtio-serial |
| | | | - virtio-block |
| | | | - virtio-net |
+--------------+-------------+---+-----------------------------------------+
| supermin | 4.1.0 | R | This is required on all distros. |
| febootstrap | 3.20 | | 'supermin' is the new name for |
| | | | 'febootstrap'. |
| | | | For alternatives, see: |
| | | | libguestfs.org/download/binaries/appliance/
| | | | febootstrap 2.x WILL NOT WORK |
+--------------+-------------+---+-----------------------------------------+
| glibc | | R | We use various glibc-isms. |
| | | | Also glibc provides XDR, rpcgen. |
+--------------+-------------+---+-----------------------------------------+
| GCC or LLVM | | R | We use __attribute__((cleanup)). |
+--------------+-------------+---+-----------------------------------------+
| Perl | | R | Various build and test programs need |
| | | | Perl. Not needed at runtime except if |
| | | | you need to run a handful of virt-* |
| | | | tools that are still written in Perl. |
+--------------+-------------+---+-----------------------------------------+
| Pod::Man | | R | Part of Perl core. |
+--------------+-------------+---+-----------------------------------------+
| Pod::Simple | | R | Part of Perl core. |
+--------------+-------------+---+-----------------------------------------+
| OCaml | |R/O| Required if compiling from git. |
| | | | Optional if compiling from tarball. |
| | | | To build generated files and OCaml bindings.
+--------------+-------------+---+-----------------------------------------+
| autotools | |R/O| Required if compiling from git. |
| | | | Optional if compiling from tarball. |
| | | | Autotools-based build system. |
+--------------+-------------+---+-----------------------------------------+
| cpio | | R | |
+--------------+-------------+---+-----------------------------------------+
| gperf | | R | |
+--------------+-------------+---+-----------------------------------------+
| PCRE | | R | Perl-compatible Regular Expression lib. |
+--------------+-------------+---+-----------------------------------------+
| genisoimage | | R | mkisofs may work. |
+--------------+-------------+---+-----------------------------------------+
| po4a | |R/O| Required if compiling from git. |
| | | | Optional if compiling from tarball. |
| | | | For localizing man pages. |
+--------------+-------------+---+-----------------------------------------+
| hivex | 1.2.7 | O | Windows Registry hive parser. |
+--------------+-------------+---+-----------------------------------------+
| libmagic | | O | The library used by the 'file' command. |
+--------------+-------------+---+-----------------------------------------+
| libvirt | | O | >= 0.10.2 is needed if you want to use |
| | | | libvirt to manage transient VMs. |
+--------------+-------------+---+-----------------------------------------+
| libxml2 | | O | Popular XML library. |
+--------------+-------------+---+-----------------------------------------+
| xmllint | | O | Part of libxml2. Used for tests only. |
+--------------+-------------+---+-----------------------------------------+
| libconfig | | O | Used to parse libguestfs's own config |
| | | | files eg. /etc/libguestfs-tools.conf. |
+--------------+-------------+---+-----------------------------------------+
| libselinux | | O | Used by the libvirt attach-method to |
| | | | securely confine the appliance (sVirt). |
+--------------+-------------+---+-----------------------------------------+
| augeas | 0.5.0 | O | To inspect configuration of Linux guests.
+--------------+-------------+---+-----------------------------------------+
| db utils | | O | db_dump, db_load etc. Usually found in |
| | | | a package called db-utils, db4-utils, |
| | | | db4.X-utils, Berkeley DB utils, etc. |
+--------------+-------------+---+-----------------------------------------+
| systemtap | | O | For userspace probes. |
+--------------+-------------+---+-----------------------------------------+
| readline | | O | For nicer command line in guestfish. |
+--------------+-------------+---+-----------------------------------------+
| acl | | O | Library (libacl) and programs for |
| | | | handling POSIX ACLs. |
+--------------+-------------+---+-----------------------------------------+
| libcap | | O | Library (libcap) and programs for |
| | | | handling Linux capabilities. |
+--------------+-------------+---+-----------------------------------------+
| libldm | | O | Library (libldm) and 'ldmtool' for |
| | | | handling Windows Dynamic Disks. |
+--------------+-------------+---+-----------------------------------------+
| yajl | 2 | O | JSON parser for parsing output of ldmtool.
+--------------+-------------+---+-----------------------------------------+
| gdisk | | O | GPT disk support. |
+--------------+-------------+---+-----------------------------------------+
| netpbm | | O | Render icons from guests. |
+--------------+-------------+---+-----------------------------------------+
| icoutils | | O | Render icons from Windows guests. |
+--------------+-------------+---+-----------------------------------------+
| Expect | | O | Perl module used to test virt-rescue. |
+--------------+-------------+---+-----------------------------------------+
| FUSE | | O | fusermount, libfuse, and kernel module |
| | | | are all needed if you want guestmount |
| | | | and/or 'mount-local' support. |
+--------------+-------------+---+-----------------------------------------+
| static glibc | | O | Used for testing only. |
+--------------+-------------+---+-----------------------------------------+
| findlib | | O | For the OCaml bindings. |
+--------------+-------------+---+-----------------------------------------+
| ocaml-gettext| | O | For localizing OCaml virt-* tools. |
+--------------+-------------+---+-----------------------------------------+
| Python | 2.2 | O | For the Python bindings. |
+--------------+-------------+---+-----------------------------------------+
| Ruby | | O | >= 1.9 is better than 1.8. |
+--------------+-------------+---+-----------------------------------------+
| rake | | O | For the Ruby bindings. |
+--------------+-------------+---+-----------------------------------------+
| rubygem-minitest | O | For the Ruby bindings. |
+--------------+-------------+---+-----------------------------------------+
| Java | | O | Java + JNI + jpackage-utils are needed |
| | | | for the Java bindings. |
+--------------+-------------+---+-----------------------------------------+
| GHC | | O | For the Haskell bindings. |
+--------------+-------------+---+-----------------------------------------+
| PHP | | O | For the PHP bindings. |
+--------------+-------------+---+-----------------------------------------+
| phpize | | O | For the PHP bindings. |
+--------------+-------------+---+-----------------------------------------+
| glib2 | | O | For the GObject bindings. |
+--------------+-------------+---+-----------------------------------------+
| gobject-introspection | O | For the GObject bindings. |
+--------------+-------------+---+-----------------------------------------+
| gjs | | O | For testing the GObject bindings. |
+--------------+-------------+---+-----------------------------------------+
| LUA | | O | For the LUA bindings. |
+--------------+-------------+---+-----------------------------------------+
| Erlang | | O | For the Erlang bindings. |
+--------------+-------------+---+-----------------------------------------+
| erl_interface| | O | For the Erlang bindings. |
+--------------+-------------+---+-----------------------------------------+
| valgrind | | O | For testing for memory problems. |
+--------------+-------------+---+-----------------------------------------+
| Sys::Virt | | O | Perl bindings for libvirt. |
+--------------+-------------+---+-----------------------------------------+
| Win::Hivex | | O | Perl bindings for hivex. |
+--------------+-------------+---+-----------------------------------------+
| Pod::Usage | | O | Perl module used by tests. |
+--------------+-------------+---+-----------------------------------------+
| Test::More | | O | Perl module used by tests. |
+--------------+-------------+---+-----------------------------------------+
| String::Shellquote | O | Perl module used by some virt-* tools. |
+--------------+-------------+---+-----------------------------------------+
| XML::XPath | | O | Perl module used by some virt-* tools. |
+--------------+-------------+---+-----------------------------------------+
| XML::XPath::XMLParser | O | Perl module used by some virt-* tools. |
+--------------+-------------+---+-----------------------------------------+
| perl-libintl | | O | Perl module for localization. |
+==============+=============+===+=========================================+
R = Required
O = Optional
Building
----------------------------------------------------------------------
Then make the daemon, library and root filesystem:
Build the daemon, library and root filesystem:
./configure
make
Finally run the tests:
Run the tests:
make check
There are some extra tests, but these require that you have some
libvirt guests installed, that these guests' disks are accessible by
the current user, and these tests may fail for other reasons which are
not necessarily because of real problems. If you want to run these
extra tests do:
Also:
make extra-tests
make check-valgrind
runs a subset of the test suite under valgrind (requires valgrind to
be installed obviously).
make extra-tests
runs check-valgrind + even more tests, but these require that you have
some libvirt guests installed, that these guests' disks are accessible
by the current user, and these tests may fail for other reasons which
are not necessarily because of real problems.
make help
lists all 'make' targets.
If everything works, you can install the library and tools by running
this command as root:
@@ -161,8 +245,8 @@ this command as root:
make install
You can run guestfish, guestmount and the virt tools without needing
to install, using the "run" script in the top directory. This script
sets up some environment variables. For example:
to install, using the "./run" script in the top directory. This
script sets up some environment variables. For example:
./run ./fish/guestfish [usual guestfish args ...]
@@ -185,6 +269,10 @@ You can also run the C programs under valgrind like this:
./run valgrind [valgrind opts...] ./cat/virt-cat [virt-cat opts...]
or under gdb:
./run gdb --args ./cat/virt-cat [virt-cat opts...]
This also works with sudo (eg. if you need root access for libvirt or
to access a block device):
@@ -220,7 +308,7 @@ these instructions:
On some systems, this will work too:
chmod o+rw /dev/kvm
chmod 0666 /dev/kvm
On some systems, the chmod will not survive a reboot, and you will
need to make edits to the udev configuration.
@@ -254,15 +342,64 @@ distributions. Non-Linux ports are trickier, but we will accept
patches if they aren't too invasive.
The main porting issues are with the dependencies needed to build the
appliance. You will need to port the febootstrap first
appliance. You will need to port febootstrap first
(http://people.redhat.com/~rjones/febootstrap/).
Note on using clang (from LLVM) instead of GCC
----------------------------------------------------------------------
export CC=clang
./configure --disable-probes
make
SystemTap/DTrace-style userspace probe points don't work under the
clang compiler, which is why you may need to disable them.
Don't enable GCC warnings (ie. *don't* use
'./configure --enable-gcc-warnings').
Note on using non-x86 architectures
----------------------------------------------------------------------
In theory libguestfs should work on non-x86 architectures. Usually if
it doesn't it's because qemu isn't available or cannot boot the
kernel.
For ARM you will need to specify the exact machine type and CPU
variant that is required to boot the Linux kernel (there's no way to
know this except by looking at how the Linux kernel was configured).
For example:
./configure \
--with-qemu="qemu-system-arm" \
--with-qemu-options="-M versatilepb -cpu arm926"
./configure \
--with-qemu="qemu-system-arm" \
--with-qemu-options="-M vexpress-a15 -cpu cortex-a15"
Note that since virtio is required by libguestfs, and virtio is a
PCI-based architecture, whatever architecture qemu emulates MUST
support PCI.
For PPC64 you will need to specify the IBM pSeries machine type:
./configure \
--with-qemu="qemu-system-ppc64" \
--with-qemu-options="-M pseries"
After building libguestfs, run 'make quickcheck' and pay close
attention to the qemu command line and kernel output.
Copyright and license information
----------------------------------------------------------------------
Copyright (C) 2009-2012 Red Hat Inc.
Copyright (C) 2009-2013 Red Hat Inc.
The library is distributed under the LGPLv2+. The programs are
distributed under the GPLv2+. Please see the files COPYING and
COPYING.LIB for full license information.
The examples are under a very liberal license.

23
ROADMAP
View File

@@ -3,7 +3,7 @@ Roadmap for future releases
Before you read this:
(1) To see what's in the current release, read 'RELEASE-NOTES'.
(1) To see what's in the current release, read 'guestfs-release-notes(1)'.
(2) To see the list of bugs, read 'BUGS'.
@@ -12,19 +12,19 @@ Before you read this:
(4) For general "might be good to have" items, see 'TODO'.
For next major stable release (1.18)
For next major stable release (1.22)
------------------------------------
* Allow remote libvirt volumes to be accessed. This requires some
enhancements to libvirt which have been agreed but not yet
implemented.
Bugs assigned to 1.18 (put "1.18" in the Devel Whiteboard field in
Bugs assigned to 1.22 (put "1.22" in the Devel Whiteboard field in
Bugzilla):
https://bugzilla.redhat.com/buglist.cgi?query_format=advanced&field0-0-0=cf_devel_whiteboard&bug_status=NEW&bug_status=ASSIGNED&bug_status=MODIFIED&bug_status=ON_DEV&bug_status=ON_QA&bug_status=VERIFIED&bug_status=FAILS_QA&bug_status=RELEASE_PENDING&bug_status=POST&bug_status=PASSES_QA&type0-0-0=anywords&value0-0-0=1.18&component=libguestfs&product=Virtualization%20Tools
https://bugzilla.redhat.com/buglist.cgi?query_format=advanced&field0-0-0=cf_devel_whiteboard&bug_status=NEW&bug_status=ASSIGNED&bug_status=MODIFIED&bug_status=ON_DEV&bug_status=ON_QA&bug_status=VERIFIED&bug_status=FAILS_QA&bug_status=RELEASE_PENDING&bug_status=POST&bug_status=PASSES_QA&type0-0-0=anywords&value0-0-0=1.22&component=libguestfs&product=Virtualization%20Tools
Beyond 1.18
Beyond 1.22
-----------
* Make 'guestfish --ro' be the default, and get users to use
@@ -33,20 +33,7 @@ Beyond 1.18
for 1.10 but there's not nearly enough adoption of the new
'guestfish --rw' option out there to do this yet.
* Allow alternate methods to start the appliance, including through
libvirt, by connecting to an existing appliance, and remotely over
ssh. Libvirt integration was originally planned for 1.10 but we
didn't get patches in time.
* Write a new partition handling library to replace parted, and use it
instead of parted. (RHBZ#593511, RHBZ#642821).
* Hot plugging of disks using QMP. This would allow more efficient
reuse of the appliance in some circumstances: multiple disks
(ie. VMs) can be added in turn to the same appliance. In particular
this would help virt-df.
[Note this requires upstream work on QMP, see:
https://www.redhat.com/archives/libguestfs/2011-March/msg00124.html]
See TODO and BUGS files.

352
TODO
View File

@@ -43,75 +43,36 @@ data, at least partially. This would be just another output type so:
Note that recent versions of libvirt/virt-install allow guests to be
imported, so this is not so useful any more.
"Standalone/local mode"
-----------------------
Instead of running guestfsd (the daemon) inside qemu, there should be
an option to just run guestfsd directly.
The architecture in this mode would look like:
+------------------+
| main program |
|------------------|
| libguestfs |
+--------^---------+
| | reply
cmd | |
+----v-------------+
| guestfsd |
+------------------+
Notes:
(1) This only makes sense if we are running as root.
(2) There is no console / kernel messages in this configuration, but
we might consider capturing stderr from the daemon.
(3) guestfs_config and guestfs_add_drive become no-ops.
Obviously in this configuration, commands are run directly on the
local machine's disks. You could just run the commands themselves
directly, but libguestfs provides a convenient API and language
bindings. Also deals with tricky stuff like parsing the output of the
LVM commands. Also we get to leverage other code such as
virt-inspector.
This is mainly useful from live CDs, ie. virt-p2v.
Should we bother having the daemon at all and just link the guestfsd
code directly into libguestfs?
Ideas for extra commands
------------------------
General glibc / core programs:
chgrp
more mk*temp calls
ext2 properties:
chattr
lsattr
badblocks
debugfs
dumpe2fs
e2image
e2undo
filefrag
findfs
logsave
mklost+found
SELinux:
chcat
restorecon
ch???
[Wanlong Gao submitted patches for restorecon, but
there are problems with using the restorecon binary
from the host on the guest. Most of the time it
would do more harm than good.]
setfiles
Oddball:
pivot_root
fts(3) / ftw(3)
sh-in, sh-out: run shell command with large input/output
debug sh-in, debug sh-out: debug versions of the above
Other initrd-* commands
-----------------------
@@ -120,74 +81,6 @@ Such as:
initrd-extract
initrd-replace
Simple editing of configuration files
-------------------------------------
Some easy non-Augeas methods to edit configuration files.
I'm thinking:
replace /etc/file key value
which would look in /etc/file for any instances of
key=...
key ...
key:...
and replace them with
key=value
key value
key:value
That would solve about 50% of reconfiguration needs, and for the
rest you'd use Augeas, 'download'+'upload' or 'edit'.
RWMJ: I had a go at implementing this, but it's quite error-prone to
do this sort of editing inside the C-based daemon code. It's far
better to do it with Augeas, or else to use an external language like
Perl.
Quick Perl scripts
------------------
Currently we can't do Perl "one-liners". ie. The current syntax for
any short Perl one-liner would be:
perl -MSys::Guestfs -e '$g = Sys::Guestfs->new(); $g->add_drive ("foo"); $g->launch; $g->mount ("/dev/sda1", "/"); ....'
You can see we're well beyond a single line just getting to the point
of adding drives and mounting.
First suggestion:
$h = create ($filename, \"/dev/sda1\" => \"/\");
$h = create ([$file1, $file2], \"/dev/sda1\" => \"/\");
To mount read-only, add C<ro =E<gt> 1> like this:
$h = create ($filename, \"/dev/sda1\" => \"/\", ro => 1);
which is equivalent to the following sequence of calls:
$h = Sys::Guestfs->new ();
$h->add_drive_ro ($filename);
$h->launch ();
$h->mount_ro (\"/dev/sda1\", \"/\");
Command-line form would be:
perl -MSys::Guestfs=:all -e '$_=create("guest.img", "/dev/sda1" => "/"); $_->cat ("/etc/fstab");'
That's not brief enough for one-liners, so we could have an extra
autogenerated module which creates a Sys::Guestfs handle singleton
(the handle is an implicit global variable as in guestfish), eg:
perl -MSys::Guestfs::One -e 'inspect("guest.img"); cat ("/etc/fstab");'
How would editing files work?
virt-rescue pty
---------------
@@ -208,14 +101,6 @@ Windows-based daemon/appliance
See discussion on list:
https://www.redhat.com/archives/libguestfs/2009-November/msg00165.html
qemu locking
------------
Add -drive file=...,lock=exclusive and -drive file=...,lock=shared
Change libguestfs and libvirt to do the right thing, so that multiple
instances of qemu cannot stomp on each other.
virt-disk-explore
-----------------
@@ -256,12 +141,6 @@ http://sourceforge.net/projects/aide/
http://osiris.shmoo.com/
http://sourceforge.net/projects/tripwire/
Fix 'file'
----------
https://www.redhat.com/archives/libguestfs/2010-June/msg00053.html
https://www.redhat.com/archives/libguestfs/2010-June/msg00079.html
Freeze/thaw filesystems
-----------------------
@@ -293,13 +172,6 @@ Could we make guestfish interactive if commands are used without params?
Image name? disk.img
Size of image? 10M
Common problems
---------------
How can we solve these common user problems?
[space for common problems here]
Better support for encrypted devices
------------------------------------
@@ -318,8 +190,6 @@ Display the structure of an image file as a PS.
Greater use of blkid / libblkid
-------------------------------
guestfs_zero should use wipefs. See wipefs(8).
There are various useful functions in libblkid for listing partitions,
devices etc which we are essentially duplicating in the daemon. It
would make more sense to just use libblkid for this.
@@ -327,6 +197,9 @@ would make more sense to just use libblkid for this.
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.
Visualization
-------------
@@ -371,23 +244,13 @@ $EDITOR without any corresponding ability to set them.
echo $EDITOR # or %{EDITOR}
edit /etc/resolv.conf
live CD inspection for Windows 7
--------------------------------
Windows 7 install CDs are quite different and pretty impenetrable.
There are no obvious files to parse.
More ntfs tools
---------------
ntfsprogs actually has a lot more useful tools than we currently
use. Interesting ones are:
ntfslabel: display or change filesystem label (we should unify all
set*label APIs into a single set_vfs_label which can deal with any
filesystem)
ntfsclone: clone, image, restore, rescue NTFS
ntfscluster: display file(s) that occupy a cluster or sector
ntfsinfo: print various information about NTFS volume and files
@@ -510,23 +373,6 @@ would be some sort of modified attach method (see link above).
The complexity here is that we would no longer have access to
stdin/stdout (or we'd have to direct that somewhere else).
GObject Introspection
---------------------
We periodically get asked to implement gobject-introspection (it's a
GNOME thing):
http://live.gnome.org/GObjectIntrospection
This would require a separate Gtk C API since the main guestfs handle
would have to be encapsulated in a GObject. However the main
difficulty is that the annotations supported to define types are not
very rich. Notably missing are support for optional arguments
(defined but not implemented), support for structs (unless mapped to
other objects).
Also note that the libguestfs API is not "object oriented".
libosinfo mappings for virt-inspector
-------------------------------------
@@ -535,21 +381,11 @@ Return libosinfo mappings from inspection API.
virt-sysprep ideas
------------------
- touch /.unconfigured ?
- other Spacewalk / RHN IDs (?)
- Kerberos keys
- Puppet registration
- user accounts
- Windows sysprep
(see: https://github.com/clalancette/oz/blob/e74ce83283d468fd987583d6837b441608e5f8f0/oz/Windows.py )
- blue skies: change the background image
- (librarian suggests ...)
. install a firstboot script virt-sysprep --script=/tmp/foo.sh
. run an external shell script
. run external guestfish script virt-sysprep --fish=/tmp/foo.fish
. rm /var/cache/apt/archives/*
- /var/run/* and pam_faillock's data files
- homedirs/.ssh directory, especially /root/.ssh (Steve Grubb)
- if drives are encrypted, then dm-crypt key should be changed
and drives all re-encrypted
- /etc/pki
@@ -560,22 +396,38 @@ virt-sysprep ideas
that you would want to look into.
- secure erase of inodes etc using scrub (Steve Grubb)
- other directories that could require cleaning include:
/var/cache/gdm/*
/var/lib/fprint/*
/var/run/*
/var/lib/AccountService/users/*
/var/lib/sss/db/*
/var/lib/samba/*
/var/lib/samba/*/*
(thanks Marko Myllynen, James Antill)
- remove or modify UUIDs in /etc/fstab (eg. on Ubuntu)
(thanks Joshua Daniel Franklin)
Kazuo Moriwaka adds:
- swap devices (both of block device and file) should be wiped. This may
good for security purpose, and size. I found virt-sparsify can clear
swap partition.
- --script is nice. Defining default sysprep script directory
like /usr/lib/guestfs/sysprep-scripts.d/ may be useful to integrate
other package maintainer(or ISV)'s effort.
- To achieve better (or crazy) coverage, a simple examination will be
help:
Install the same kickstart into VM twice, and diff the trees.
Many autogenerated IDs and configs can be found :)
As well as 'virt-sysprep' there is a case for a 'virt-customize' tool
which can customize templated guests. This would be useful within
companies/organizations that want to offer multiple guests, but all
customized with the organization logo etc. Some ideas:
- change the background image to some custom desktop
- 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
febootstrap and qemu commands happen the same as now, but prefixed by
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
@@ -601,3 +453,137 @@ to do a kind of migration of guests by simply recreating the guest
from the description on the target machine.
It would be ideal to integrate this and/or use inspection to do this.
Ongoing code cleanups
---------------------
Examine every use of 'int' in C code for signed overflow problems.
All file descriptors in the library and daemon should normally be
opened with O_CLOEXEC. Therefore we need to examine every call to:
- open, openat
- creat
- pipe (see also: pipe2)
- dup, dup2 (see also: dup3)
- socket, socketpair
- accept (see also: accept4)
- signalfd, timerfd, epoll_create
virt-sparsify enhancements
--------------------------
TMPDIR should be checked to ensure that we won't run out of space
during the conversion, since current behaviour is very bad when this
happens (it usually causes virt-sparsify to hang). This requires
writing a small C binding to statvfs for OCaml.
'virt-sparsify --whitelist' option to generate skeletons (for
debugging, bug forensics, diagnosis). The whilelist option would
specify a list of files to be *preserved*. All other files in the
image would be replaced by equivalent files of zeroes, thus minimizing
the size of the debug image that needs to be shipped to us by the
customer.
Optimize the appliance
----------------------
Pass -cpu host. Anything else?
[The libvirt attach-method uses 'host-model' which is basically
the same as this]
Sort out partitioning
---------------------
Ignoring some legacy APIs, we currently have a mixed selection of
'part-*' APIs, implemented using parted. We don't like parted or
libparted very much, and would love to replace it with something else.
The part-* APIs are quirky, but not too bad and we should maintain and
extend them instead of making another set of APIs.
One option is to write "libmbr" and "libgpt" libraries that would just
do MBR and GPT respectively, and do it directly and do it well. They
wouldn't try to abstract anything (so, unlike libparted). We could
then reimplement the part-* APIs on top of these hopefully sensible
libraries. This is a lot of work.
Another option is to look for tools or libraries to replace parted.
For GPT there is a fairly obvious candidate: Rod Smith's GPT fdisk
(http://www.rodsbooks.com/gdisk/). Rod has spent a lot of time
studying GPT, and seems to know more about it than any sane man
should. There is a command line tool designed for scripts called
'sgdisk'. The tools are packaged for many Linux distros. Even if
this approach works, it doesn't solve the MBR problem, so likely we'd
have to write a library for that (or perhaps go back to sfdisk but
using a very abstracted interface over sfdisk).
qemu caching
------------
(Suggested by Paolo Bonzini and Kevin Wolf)
Measure the effect of cache=none, cache=directsync,
cache=writethrough, cache=writeback.
It's doubtful that using cache=none is useful, since it disables the
host cache making read-heavy workloads slower (they rely entirely on
the smaller appliance kernel's cache). And in libguestfs we don't
necessarily care about ongoing data integrity while writing, as long
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
--------------------------------
This requires some changes to qemu to make discard work properly
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.
- 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).
ruby
----
Implement blocking calls. The API for this:
http://www.spacevatican.org/2012/7/5/whos-afraid-of-the-big-bad-lock/
is very poorly designed and essentially impossible for us to use:
https://bugs.ruby-lang.org/issues/5543
particularly if we also want to maintain backwards compatibility with
Ruby 1.8, and/or maintain volatile VALUEs on the stack.

View File

@@ -18,6 +18,7 @@
include $(top_srcdir)/subdir-rules.mk
EXTRA_DIST = \
test-virt-alignment-scan.sh \
virt-alignment-scan.pod
CLEANFILES = stamp-virt-alignment-scan.pod
@@ -26,23 +27,27 @@ bin_PROGRAMS = virt-alignment-scan
SHARED_SOURCE_FILES = \
../fish/config.c \
../fish/domain.c \
../fish/inspect.c \
../fish/keys.c \
../fish/options.h \
../fish/options.c \
../fish/virt.c
../fish/options.c
virt_alignment_scan_SOURCES = \
$(SHARED_SOURCE_FILES) \
scan.c
domains.c \
scan.c \
scan.h
virt_alignment_scan_CFLAGS = \
-DGUESTFS_WARN_DEPRECATED=1 \
-DGUESTFS_PRIVATE=1 \
-I$(top_srcdir)/src -I$(top_builddir)/src \
-I$(top_srcdir)/fish \
-I$(srcdir)/../gnulib/lib -I../gnulib/lib \
-DLOCALEBASEDIR=\""$(datadir)/locale"\" \
$(WARN_CFLAGS) $(WERROR_CFLAGS) \
$(GPROF_CFLAGS) $(GCOV_CFLAGS) \
$(LIBCONFIG_CFLAGS) \
$(LIBVIRT_CFLAGS)
@@ -60,18 +65,23 @@ noinst_DATA = $(top_builddir)/html/virt-alignment-scan.1.html
virt-alignment-scan.1 $(top_builddir)/html/virt-alignment-scan.1.html: stamp-virt-alignment-scan.pod
stamp-virt-alignment-scan.pod: virt-alignment-scan.pod
$(top_builddir)/podwrapper.sh \
$(PODWRAPPER) \
--man virt-alignment-scan.1 \
--html $(top_builddir)/html/virt-alignment-scan.1.html \
--license GPLv2+ \
$<
touch $@
# Tests.
# random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null)
TESTS_ENVIRONMENT = $(top_builddir)/run --test
# TESTS_ENVIRONMENT = \
# MALLOC_PERTURB_=$(random_val) \
# $(top_builddir)/run
TESTS =
# TESTS = test-virt-alignment-scan.sh
if ENABLE_APPLIANCE
TESTS += \
test-virt-alignment-scan.sh
endif
check-valgrind:
$(MAKE) VG="$(top_builddir)/run @VG@" check

355
align/domains.c Normal file
View File

@@ -0,0 +1,355 @@
/* virt-alignment-scan
* Copyright (C) 2012 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 <string.h>
#include <libintl.h>
#ifdef HAVE_LIBVIRT
#include <libvirt/libvirt.h>
#include <libvirt/virterror.h>
#endif
#include "progname.h"
#include "guestfs.h"
#include "options.h"
#include "scan.h"
#if defined(HAVE_LIBVIRT) && defined(HAVE_LIBXML2)
/* The list of domains and disks that we build up in
* get_domains_from_libvirt.
*/
struct disk {
struct disk *next;
char *filename;
char *format; /* could be NULL */
};
struct domain {
char *name;
char *uuid;
struct disk *disks;
size_t nr_disks;
};
struct domain *domains = NULL;
size_t nr_domains;
static int
compare_domain_names (const void *p1, const void *p2)
{
const struct domain *d1 = p1;
const struct domain *d2 = p2;
return strcmp (d1->name, d2->name);
}
static void
free_domain (struct domain *domain)
{
struct disk *disk, *next;
for (disk = domain->disks; disk; disk = next) {
next = disk->next;
free (disk->filename);
free (disk->format);
free (disk);
}
free (domain->name);
free (domain->uuid);
}
static void add_domains_by_id (virConnectPtr conn, int *ids, size_t n);
static void add_domains_by_name (virConnectPtr conn, char **names, size_t n);
static void add_domain (virDomainPtr dom);
static int add_disk (guestfs_h *g, const char *filename, const char *format, int readonly, void *domain_vp);
static size_t add_disks_to_handle_reverse (struct disk *disk, size_t *errors_r);
static void reset_guestfs_handle (void);
void
get_domains_from_libvirt (int uuid, size_t *worst_alignment_ptr)
{
virErrorPtr err;
virConnectPtr conn;
int n;
size_t i, count, errors;
const char *prefix;
nr_domains = 0;
domains = NULL;
/* Get the list of all domains. */
conn = virConnectOpenReadOnly (libvirt_uri);
if (!conn) {
err = virGetLastError ();
fprintf (stderr,
_("%s: could not connect to libvirt (code %d, domain %d): %s\n"),
program_name, err->code, err->domain, err->message);
exit (EXIT_FAILURE);
}
n = virConnectNumOfDomains (conn);
if (n == -1) {
err = virGetLastError ();
fprintf (stderr,
_("%s: could not get number of running domains (code %d, domain %d): %s\n"),
program_name, err->code, err->domain, err->message);
exit (EXIT_FAILURE);
}
int ids[n];
n = virConnectListDomains (conn, ids, n);
if (n == -1) {
err = virGetLastError ();
fprintf (stderr,
_("%s: could not list running domains (code %d, domain %d): %s\n"),
program_name, err->code, err->domain, err->message);
exit (EXIT_FAILURE);
}
add_domains_by_id (conn, ids, n);
n = virConnectNumOfDefinedDomains (conn);
if (n == -1) {
err = virGetLastError ();
fprintf (stderr,
_("%s: could not get number of inactive domains (code %d, domain %d): %s\n"),
program_name, err->code, err->domain, err->message);
exit (EXIT_FAILURE);
}
char *names[n];
n = virConnectListDefinedDomains (conn, names, n);
if (n == -1) {
err = virGetLastError ();
fprintf (stderr,
_("%s: could not list inactive domains (code %d, domain %d): %s\n"),
program_name, err->code, err->domain, err->message);
exit (EXIT_FAILURE);
}
add_domains_by_name (conn, names, n);
/* You must free these even though the libvirt documentation doesn't
* mention it.
*/
for (i = 0; i < (size_t) n; ++i)
free (names[i]);
virConnectClose (conn);
/* No domains? */
if (nr_domains == 0)
return;
/* Sort the domains alphabetically by name for display. */
qsort (domains, nr_domains, sizeof (struct domain), compare_domain_names);
errors = 0;
for (i = 0; i < nr_domains; ++i) {
if (domains[i].disks == NULL)
continue;
count = add_disks_to_handle_reverse (domains[i].disks, &errors);
if (count == 0)
continue;
if (guestfs_launch (g) == -1)
exit (EXIT_FAILURE);
prefix = !uuid ? domains[i].name : domains[i].uuid;
/* Perform the scan. */
scan (worst_alignment_ptr, prefix);
if (i < nr_domains - 1)
reset_guestfs_handle ();
}
/* Free up domains structure. */
for (i = 0; i < nr_domains; ++i)
free_domain (&domains[i]);
free (domains);
if (errors > 0) {
fprintf (stderr, _("%s: failed to analyze a disk, see error(s) above\n"),
program_name);
exit (EXIT_FAILURE);
}
}
static void
add_domains_by_id (virConnectPtr conn, int *ids, size_t n)
{
size_t i;
virDomainPtr dom;
for (i = 0; i < n; ++i) {
if (ids[i] != 0) { /* RHBZ#538041 */
dom = virDomainLookupByID (conn, ids[i]);
if (dom) { /* transient errors are possible here, ignore them */
add_domain (dom);
virDomainFree (dom);
}
}
}
}
static void
add_domains_by_name (virConnectPtr conn, char **names, size_t n)
{
size_t i;
virDomainPtr dom;
for (i = 0; i < n; ++i) {
dom = virDomainLookupByName (conn, names[i]);
if (dom) { /* transient errors are possible here, ignore them */
add_domain (dom);
virDomainFree (dom);
}
}
}
static void
add_domain (virDomainPtr dom)
{
struct domain *domain;
domains = realloc (domains, (nr_domains + 1) * sizeof (struct domain));
if (domains == NULL) {
perror ("realloc");
exit (EXIT_FAILURE);
}
domain = &domains[nr_domains];
nr_domains++;
domain->name = strdup (virDomainGetName (dom));
if (domain->name == NULL) {
perror ("strdup");
exit (EXIT_FAILURE);
}
char uuid[VIR_UUID_STRING_BUFLEN];
if (virDomainGetUUIDString (dom, uuid) == 0) {
domain->uuid = strdup (uuid);
if (domain->uuid == NULL) {
perror ("strdup");
exit (EXIT_FAILURE);
}
}
else
domain->uuid = NULL;
domain->disks = NULL;
int n = guestfs___for_each_disk (g, dom, add_disk, domain);
if (n == -1)
exit (EXIT_FAILURE);
domain->nr_disks = n;
}
static int
add_disk (guestfs_h *g,
const char *filename, const char *format, int readonly,
void *domain_vp)
{
struct domain *domain = domain_vp;
struct disk *disk;
disk = malloc (sizeof *disk);
if (disk == NULL) {
perror ("malloc");
return -1;
}
disk->next = domain->disks;
domain->disks = disk;
disk->filename = strdup (filename);
if (disk->filename == NULL) {
perror ("malloc");
return -1;
}
if (format) {
disk->format = strdup (format);
if (disk->format == NULL) {
perror ("malloc");
return -1;
}
}
else
disk->format = NULL;
return 0;
}
static size_t
add_disks_to_handle_reverse (struct disk *disk, size_t *errors_r)
{
size_t nr_disks_added;
if (disk == NULL)
return 0;
nr_disks_added = add_disks_to_handle_reverse (disk->next, errors_r);
struct guestfs_add_drive_opts_argv optargs = { .bitmask = 0 };
optargs.bitmask |= GUESTFS_ADD_DRIVE_OPTS_READONLY_BITMASK;
optargs.readonly = 1;
if (disk->format) {
optargs.bitmask |= GUESTFS_ADD_DRIVE_OPTS_FORMAT_BITMASK;
optargs.format = disk->format;
}
if (guestfs_add_drive_opts_argv (g, disk->filename, &optargs) == -1) {
(*errors_r)++;
return nr_disks_added;
}
return nr_disks_added+1;
}
/* Close and reopen the libguestfs handle. */
static void
reset_guestfs_handle (void)
{
/* Copy the settings from the old handle. */
int verbose = guestfs_get_verbose (g);
int trace = guestfs_get_trace (g);
guestfs_close (g);
g = guestfs_create ();
if (g == NULL) {
fprintf (stderr, _("guestfs_create: failed to create handle\n"));
exit (EXIT_FAILURE);
}
guestfs_set_verbose (g, verbose);
guestfs_set_trace (g, trace);
}
#endif

View File

@@ -35,10 +35,10 @@
#endif
#include "progname.h"
#include "c-ctype.h"
#include "guestfs.h"
#include "options.h"
#include "scan.h"
/* These globals are shared with options.c. */
guestfs_h *g;
@@ -53,14 +53,6 @@ int inspector = 0;
static int quiet = 0; /* --quiet */
static int scan (void);
static inline char *
bad_cast (char const *s)
{
return (char *) s;
}
static void __attribute__((noreturn))
usage (int status)
{
@@ -111,6 +103,7 @@ main (int argc, char *argv[])
{ "format", 2, 0, 0 },
{ "help", 0, 0, HELP_OPTION },
{ "quiet", 0, 0, 'q' },
{ "uuid", 0, 0, 0, },
{ "verbose", 0, 0, 'v' },
{ "version", 0, 0, 'V' },
{ 0, 0, 0, 0 }
@@ -120,6 +113,9 @@ main (int argc, char *argv[])
const char *format = NULL;
int c;
int option_index;
int uuid = 0;
/* This just needs to be larger than any alignment we care about. */
size_t worst_alignment = UINT_MAX;
int exit_code;
g = guestfs_create ();
@@ -128,7 +124,7 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
argv[0] = bad_cast (program_name);
argv[0] = (char *) program_name;
for (;;) {
c = getopt_long (argc, argv, options, long_options, &option_index);
@@ -141,6 +137,8 @@ main (int argc, char *argv[])
format = NULL;
else
format = optarg;
} else if (STREQ (long_options[option_index].name, "uuid")) {
uuid = 1;
} else {
fprintf (stderr, _("%s: unknown long option: %s (%d)\n"),
program_name, long_options[option_index].name, option_index);
@@ -197,59 +195,82 @@ main (int argc, char *argv[])
usage (EXIT_FAILURE);
/* The user didn't specify any drives to scan. */
if (drvs == NULL)
usage (EXIT_FAILURE);
/* Add domains/drives from the command line (for a single guest). */
add_drives (drvs, 'a');
if (guestfs_launch (g) == -1)
if (drvs == NULL) {
#if defined(HAVE_LIBVIRT) && defined(HAVE_LIBXML2)
get_domains_from_libvirt (uuid, &worst_alignment);
#else
fprintf (stderr, _("%s: compiled without support for libvirt and/or libxml2.\n"),
program_name);
exit (EXIT_FAILURE);
#endif
} else {
if (uuid) {
fprintf (stderr, _("%s: --uuid option cannot be used with -a or -d\n"),
program_name);
exit (EXIT_FAILURE);
}
/* Free up data structures, no longer needed after this point. */
free_drives (drvs);
/* Add domains/drives from the command line (for a single guest). */
add_drives (drvs, 'a');
/* Perform the scan. */
exit_code = scan ();
if (guestfs_launch (g) == -1)
exit (EXIT_FAILURE);
guestfs_close (g);
/* Free up data structures, no longer needed after this point. */
free_drives (drvs);
/* Perform the scan. */
scan (&worst_alignment, NULL);
guestfs_close (g);
}
/* Decide on an appropriate exit code. */
if (worst_alignment < 10) /* 2^10 = 4096 */
exit_code = 3;
else if (worst_alignment < 16) /* 2^16 = 65536 */
exit_code = 2;
else
exit_code = 0;
exit (exit_code);
}
static int
scan (void)
void
scan (size_t *worst_alignment, const char *prefix)
{
int exit_code = 0;
char **devices;
size_t i, j;
size_t alignment;
uint64_t start;
struct guestfs_partition_list *parts;
devices = guestfs_list_devices (g);
CLEANUP_FREE_STRING_LIST char **devices = guestfs_list_devices (g);
if (devices == NULL)
exit (EXIT_FAILURE);
for (i = 0; devices[i] != NULL; ++i) {
parts = guestfs_part_list (g, devices[i]);
CLEANUP_FREE char *name = NULL;
CLEANUP_FREE_PARTITION_LIST struct guestfs_partition_list *parts =
guestfs_part_list (g, devices[i]);
if (parts == NULL)
exit (EXIT_FAILURE);
/* Canonicalize the name of the device for printing. */
if (STRPREFIX (devices[i], "/dev/") &&
(devices[i][5] == 'h' || devices[i][5] == 'v') &&
devices[i][6] == 'd' &&
c_isalpha (devices[i][7]))
devices[i][5] = 's';
name = guestfs_canonical_device_name (g, devices[i]);
if (name == NULL)
exit (EXIT_FAILURE);
for (j = 0; j < parts->len; ++j) {
/* Start offset of the partition in bytes. */
start = parts->val[j].part_start;
if (!quiet)
if (!quiet) {
if (prefix)
printf ("%s:", prefix);
printf ("%s%d %12" PRIu64 " ",
devices[i], (int) parts->val[j].part_num, start);
name, (int) parts->val[j].part_num, start);
}
/* What's the alignment? */
if (start == 0) /* Probably not possible, but anyway. */
@@ -267,13 +288,13 @@ scan (void)
printf ("- ");
}
if (alignment < *worst_alignment)
*worst_alignment = alignment;
if (alignment < 12) { /* Bad in general: < 4K alignment */
exit_code = 3;
if (!quiet)
printf ("bad (%s)\n", _("alignment < 4K"));
} else if (alignment < 16) { /* Bad on NetApps: < 64K alignment */
if (exit_code < 2)
exit_code = 2;
if (!quiet)
printf ("bad (%s)\n", _("alignment < 64K"));
} else {
@@ -281,11 +302,5 @@ scan (void)
printf ("ok\n");
}
}
guestfs_free_partition_list (parts);
free (devices[i]);
}
free (devices);
return exit_code;
}

30
align/scan.h Normal file
View File

@@ -0,0 +1,30 @@
/* virt-alignment-scan
* Copyright (C) 2012 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.
*/
#ifndef GUESTFS_VIRT_ALIGNMENT_SCAN_H_
#define GUESTFS_VIRT_ALIGNMENT_SCAN_H_
/* domains.c */
#if defined(HAVE_LIBVIRT) && defined(HAVE_LIBXML2)
extern void get_domains_from_libvirt (int uuid, size_t *worst_alignment);
#endif
/* scan.c */
extern void scan (size_t *worst_alignment, const char *prefix);
#endif /* GUESTFS_VIRT_ALIGNMENT_SCAN_H_ */

View File

@@ -0,0 +1,25 @@
#!/bin/bash -
# libguestfs
# Copyright (C) 2012 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.
$VG ./virt-alignment-scan -a ../tests/guests/fedora.img
r=$?
# 0, 2 and 3 are reasonable non-error exit codes. Others are errors.
if [ $r -ne 0 -a $r -ne 2 -a $r -ne 3 ]; then
exit $r
fi

View File

@@ -10,6 +10,8 @@ virt-alignment-scan - Check alignment of virtual machine partitions
virt-alignment-scan [--options] -a disk.img [-a disk.img ...]
virt-alignment-scan [--options]
=head1 DESCRIPTION
When older operating systems install themselves, the partitioning
@@ -51,16 +53,28 @@ possibly the I<-c> option:
/dev/sda2 105906176 1024K ok
/dev/sdb1 65536 64K ok
Run virt-alignment-scan without any I<-a> or I<-d> options to scan all
libvirt domains.
# virt-alignment-scan
F16x64:/dev/sda1 1048576 1024K ok
F16x64:/dev/sda2 2097152 2048K ok
F16x64:/dev/sda3 526385152 2048K ok
The output consists of 4 or more whitespace-separated columns. Only
the first 4 columns are signficant if you want to parse this from a
the first 4 columns are significant if you want to parse this from a
program. The columns are:
=over 4
=item col 1
the device and partition name (eg. C</dev/sda1> meaning the
first partition on the first block device)
The device and partition name (eg. C</dev/sda1> meaning the
first partition on the first block device).
When listing all libvirt domains (no I<-a> or I<-d> option given) this
column is prefixed by the libvirt name or UUID (if I<--uuid> is
given). eg: C<WinXP:/dev/sda1>
=item col 2
@@ -151,6 +165,15 @@ security problem with malicious guests (CVE-2010-3851).
Don't produce any output. Just set the exit code
(see L</EXIT STATUS> below).
=item B<--uuid>
Print UUIDs instead of names. This is useful for following a guest
even when the guest is migrated or renamed, or when two guests happen
to have the same name.
This option only applies when listing all libvirt domains (when no
I<-a> or I<-d> options are specified).
=item B<-v>
=item B<--verbose>
@@ -365,17 +388,3 @@ Richard W.M. Jones L<http://people.redhat.com/~rjones/>
=head1 COPYRIGHT
Copyright (C) 2011 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.

View File

@@ -0,0 +1,17 @@
# For libguestfs, create /dev/disk/guestfs/<serial>
# and /dev/disk/guestfs/<serial><partnum>
KERNEL=="sd*[!0-9]", ENV{DEVTYPE}=="disk", ENV{ID_SCSI_SERIAL}=="?*", \
SYMLINK+="disk/guestfs/$env{ID_SCSI_SERIAL}"
KERNEL=="sd*", ENV{DEVTYPE}=="partition", ENV{ID_SCSI_SERIAL}=="?*", \
SYMLINK+="disk/guestfs/$env{ID_SCSI_SERIAL}%n"
# As written, it's likely the above only works with virtio-scsi
# because ID_SCSI_SERIAL is specific to the output of the 'scsi_id'
# program. The following will not work because ID_SERIAL contains
# some unwanted text.
#KERNEL=="vd*[!0-9]", ATTRS{serial}=="?*", ENV{ID_SERIAL}="$attr{serial}", \
# SYMLINK+="disk/guestfs/$env{ID_SERIAL}"
#KERNEL=="vd*[0-9]", ATTRS{serial}=="?*", ENV{ID_SERIAL}="$attr{serial}", \
# SYMLINK+="disk/guestfs/$env{ID_SERIAL}%n"

View File

@@ -15,13 +15,20 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# Old RHEL 5 autoconf doesn't have builddir.
builddir ?= .
include $(top_srcdir)/subdir-rules.mk
EXTRA_DIST = \
packagelist.in \
99-guestfs-serial.rules \
excludelist.in \
guestfsd.suppressions \
init \
make.sh.in
libguestfs-make-fixed-appliance.in \
libguestfs-make-fixed-appliance.pod \
make.sh.in \
packagelist.in
fsdir = $(libdir)/guestfs
superminfsdir = $(libdir)/guestfs/supermin.d
@@ -31,31 +38,35 @@ superminfs_DATA = \
supermin.d/base.img \
supermin.d/daemon.img \
supermin.d/init.img \
supermin.d/hostfiles
supermin.d/hostfiles \
supermin.d/udev-rules.img
# This used to be a configure-generated file (as is update.sh still).
# However config.status always touches the destination file, which
# means the appliance got rebuilt too often.
make.sh: make.sh.in
make.sh: make.sh.in $(top_builddir)/config.log $(top_builddir)/config.status
cd $(top_builddir) && \
./config.status --file=appliance/$@-t:appliance/$<
chmod +x $@-t
mv $@-t $@
cmp -s $@ $@-t || mv $@-t $@
rm -f $@-t
PACKAGELIST_CPP_FLAGS = -D$(DISTRO)=1
if VALGRIND_DAEMON
PACKAGELIST_CPP_FLAGS += -DVALGRIND_DAEMON=1
endif
packagelist: packagelist.in
packagelist: packagelist.in Makefile
cpp -undef $(PACKAGELIST_CPP_FLAGS) < $< | \
grep -v '^[[:space:]]*$$' | grep -v '^#' > $@-t
mv $@-t $@
cmp -s $@ $@-t || mv $@-t $@
rm -f $@-t
excludelist: excludelist.in
excludelist: excludelist.in Makefile
cpp -undef $(PACKAGELIST_CPP_FLAGS) < $< | \
grep -v '^[[:space:]]*$$' | grep -v '^#' > $@-t
mv $@-t $@
cmp -s $@ $@-t || mv $@-t $@
rm -f $@-t
supermin.d/base.img supermin.d/hostfiles: stamp-supermin
stamp-supermin: make.sh packagelist excludelist
@@ -64,13 +75,15 @@ stamp-supermin: make.sh packagelist excludelist
./make.sh
touch $@
supermin.d/daemon.img: ../daemon/guestfsd
supermin.d/daemon.img: ../daemon/guestfsd guestfsd.suppressions
mkdir -p supermin.d
rm -f $@ $@-t
mkdir sbin
cd sbin && ln ../../daemon/guestfsd
echo -e "sbin\nsbin/guestfsd" | cpio --quiet -o -H newc > $@-t
rm -r sbin
rm -rf tmp-d
mkdir -p tmp-d$(DAEMON_SUPERMIN_DIR) tmp-d/etc
ln ../daemon/guestfsd tmp-d$(DAEMON_SUPERMIN_DIR)/guestfsd
ln $(srcdir)/guestfsd.suppressions tmp-d/etc/guestfsd.suppressions
( cd tmp-d && find | cpio --quiet -o -H newc ) > $@-t
rm -rf tmp-d
mv $@-t $@
supermin.d/init.img: init
@@ -80,9 +93,46 @@ supermin.d/init.img: init
echo "init" | cpio --quiet -o -H newc > $@-t
mv $@-t $@
# We should put this file in /lib/udev/rules.d, but put it in /etc so
# we don't have to deal with all the UsrMove crap in Fedora.
supermin.d/udev-rules.img: 99-guestfs-serial.rules
mkdir -p supermin.d
rm -f $@ $@-t
rm -rf tmp-u
mkdir -p tmp-u/etc/udev/rules.d
for f in $^; do ln $$f tmp-u/etc/udev/rules.d/$$f; done
( cd tmp-u && find | cpio --quiet -o -H newc ) > $@-t
rm -rf tmp-u
mv $@-t $@
# If installing the daemon, install the udev rules too.
if INSTALL_DAEMON
udevrulesdir = /lib/udev/rules.d
udevrules_DATA = 99-guestfs-serial.rules
endif
# libguestfs-make-fixed-appliance script and man page.
sbin_SCRIPTS = libguestfs-make-fixed-appliance
man_MANS = libguestfs-make-fixed-appliance.1
libguestfs-make-fixed-appliance.1 $(top_builddir)/html/libguestfs-make-fixed-appliance.1.html: stamp-libguestfs-make-fixed-appliance.pod
stamp-libguestfs-make-fixed-appliance.pod: libguestfs-make-fixed-appliance.pod
$(PODWRAPPER) \
--man libguestfs-make-fixed-appliance.1 \
--html $(top_builddir)/html/libguestfs-make-fixed-appliance.1.html \
--license GPLv2+ \
$<
touch $@
# Make clean.
CLEANFILES = packagelist excludelist
CLEANFILES = packagelist excludelist \
libguestfs-make-fixed-appliance.1 \
stamp-libguestfs-make-fixed-appliance.pod
clean-local:
rm -rf supermin.d

View File

@@ -32,19 +32,24 @@
/* Plymouth is a graphical boot thing - not needed. */
^plymouth
/* Linux firmware. Note that febootstrap itself excludes the kernel
* which is also not needed since we get the kernel, modules etc
* from the host at appliance boot.
*/
/* Linux firmware. */
^linux-firmware
/* Keyboard maps - appliance is not interactive. */
^kbd-misc
#ifdef REDHAT
/* Linux kernel. febootstrap <= 3.18 used to exclude the kernel
* package (only) by default, but since 3.19 it doesn't do this any
* longer.
*/
^kernel
^fedora-logos
^redhat-logos
^dracut
#endif
#ifdef DEBIAN

View File

@@ -0,0 +1,19 @@
# This file is only used when libguestfs is configured with
#
# ./configure --enable-valgrind-daemon
#
# (only used for development, and only used in the regular supermin
# appliance, not libguestfs live).
#
# If there are any valgrind errors in the base libraries such as
# glibc, then we can suppress them here, so we only see errors in
# libguestfs daemon code.
# libdl
{
libdl_index_cond
Memcheck:Cond
fun:index
fun:expand_dynamic_string_token
fun:_dl_map_object
}

View File

@@ -12,9 +12,11 @@ export RUNLEVEL PREVLEVEL
mkdir -p /sysroot
rm -f /proc; mkdir /proc
if [ ! -d /proc ]; then rm -f /proc; fi
mkdir -p /proc
mount -t proc /proc /proc
rm -f /sys; mkdir /sys
if [ ! -d /sys ]; then rm -f /sys; fi
mkdir -p /sys
mount -t sysfs /sys /sys
mkdir -p /run/lock
@@ -29,36 +31,39 @@ if [ ! -L /etc/init.d/udev -a -x /etc/init.d/udev ]; then
fi
elif [ -x /sbin/start_udev ] && /sbin/start_udev; then
:
elif [ -x /sbin/udevd ]; then
echo -e '\000\000\000\000' > /proc/sys/kernel/hotplug
/sbin/udevd --daemon
/sbin/udevadm trigger
/sbin/udevadm settle
elif [ -x /lib/udev/udevd ]; then
echo -e '\000\000\000\000' > /proc/sys/kernel/hotplug
/lib/udev/udevd --daemon
/sbin/udevadm trigger
/sbin/udevadm settle
else
echo No udev, creating /dev manually
mount -t tmpfs none /dev
mkdir /dev/pts /dev/shm /dev/mapper
mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts
# Must do each MAKEDEV individually, because if one device fails,
# MAKEDEV will quit without creating the rest (RHBZ#507374).
for dev in mem null port zero core full ram tty console fd \
hda hdb hdc hdd sda sdb sdc sdd loop sd; do
MAKEDEV $dev ||:
# Find udevd and run it directly.
for f in /sbin/udevd /lib/udev/udevd \
/lib/systemd/systemd-udevd /usr/lib/systemd/systemd-udevd \
/usr/lib/udev/udevd; do
if [ -x "$f" ]; then UDEVD="$f"; fi
done
mknod /dev/ptmx c 5 2; chmod 0666 /dev/ptmx
mknod /dev/random c 1 8; chmod 0666 /dev/random
mknod /dev/urandom c 1 9; chmod 0444 /dev/urandom
ln -sf /proc/self/fd/0 /dev/stdin
ln -sf /proc/self/fd/1 /dev/stdout
ln -sf /proc/self/fd/2 /dev/stderr
if [ -n "$UDEVD" ]; then
echo -e '\000\000\000\000' > /proc/sys/kernel/hotplug
$UDEVD --daemon
udevadm trigger
udevadm settle --timeout=600
else
echo No udevd, creating /dev manually.
mount -t tmpfs none /dev
mkdir /dev/pts /dev/shm /dev/mapper
mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts
# Must do each MAKEDEV individually, because if one device fails,
# MAKEDEV will quit without creating the rest (RHBZ#507374).
for dev in mem null port zero core full ram tty console fd \
hda hdb hdc hdd sda sdb sdc sdd loop sd; do
MAKEDEV $dev ||:
done
mknod /dev/ptmx c 5 2; chmod 0666 /dev/ptmx
mknod /dev/random c 1 8; chmod 0666 /dev/random
mknod /dev/urandom c 1 9; chmod 0444 /dev/urandom
ln -sf /proc/self/fd/0 /dev/stdin
ln -sf /proc/self/fd/1 /dev/stdout
ln -sf /proc/self/fd/2 /dev/stderr
modprobe virtio_pci
modprobe virtio_net
modprobe virtio_pci
modprobe virtio_net
fi
fi
if grep -sq selinux=1 /proc/cmdline; then
@@ -86,6 +91,9 @@ modprobe dm_mod ||:
lvm vgscan --ignorelockingfailure
lvm vgchange -ay --ignorelockingfailure
# Scan for Windows dynamic disks.
ldmtool create all
# Improve virtio-blk performance (RHBZ#509383).
for f in /sys/block/vd*/queue/rotational; do echo 1 > $f; done
@@ -116,8 +124,11 @@ if ! grep -sq guestfs_rescue=1 /proc/cmdline; then
# Run the daemon under valgrind if ./configure --enable-valgrind-daemon
vg_channel=/dev/virtio-ports/org.libguestfs.valgrind
if [ -w $vg_channel ]; then
if [ -r /etc/guestfsd.suppressions ]; then
suppressions="--suppressions=/etc/guestfsd.suppressions"
fi
exec 3>$vg_channel
vg="valgrind --leak-check=full --log-fd=3 --error-exitcode=119 --max-stackframe=8388608 --child-silent-after-fork=yes"
vg="valgrind --leak-check=full --log-fd=3 --error-exitcode=119 --max-stackframe=8388608 --child-silent-after-fork=yes $suppressions"
echo "enabling valgrind: $vg"
fi
@@ -147,4 +158,4 @@ else
fi
sync
/sbin/reboot -f
reboot -f

View File

@@ -0,0 +1,161 @@
#!/bin/bash -
# @configure_input@
# libguestfs-make-fixed-appliance tool
# Copyright (C) 2012 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.
unset CDPATH
program="libguestfs-make-fixed-appliance"
version="@PACKAGE_VERSION@"
TEMP=`getopt \
-o V \
--long help,version,xz \
-n $program -- "$@"`
if [ $? != 0 ]; then
echo "$program: problem parsing the command line arguments"
exit 1
fi
eval set -- "$TEMP"
usage ()
{
echo "Usage:"
echo " $program [--options] OUTPUTDIR"
echo " $program [--options] --xz"
echo
echo "Read $program(1) man page for more information."
exit $1
}
while true; do
case "$1" in
-V|--version)
echo "$program $version"
exit 0;;
--xz)
xz_mode=1
shift;;
--help)
usage 0;;
--)
shift
break;;
*)
echo "internal error ($1)"
exit 1;;
esac
done
# Either xz_mode or we expect one extra parameter (output directory).
if [ -n "$xz_mode" ]; then
if [ $# -gt 0 ]; then
echo "error: $program: extra parameters on the command line"
echo
usage 1
fi
else
if [ $# -ne 1 ]; then
echo "error: $program: missing output directory"
echo
usage 1
fi
outputdir="$1"
fi
# end of command line parsing
#----------------------------------------------------------------------
set -e
# The two ways to build the appliance are roughly the same, except for
# --xz we build into a temporary directory and tar it up at the end.
if [ -n "$xz_mode" ]; then
tmpdir="$(mktemp -d)"
outputdir="$tmpdir/appliance"
cleanup ()
{
rm -rf $tmpdir ||:
}
trap cleanup EXIT ERR
fi
# Create the output directory.
mkdir -p "$outputdir"
# Build the supermin appliance, if not already.
guestfish -a /dev/null run
# Find the location of the appliance.
cachedir="$(guestfish get-cachedir)"
euid="$(id -u)"
appliancedir="$cachedir/.guestfs-$euid"
cp "$appliancedir/kernel" "$outputdir/kernel"
cp "$appliancedir/initrd" "$outputdir/initrd"
cp --sparse=always "$appliancedir/root" "$outputdir/root"
cat <<EOF >"$outputdir/README.fixed"
This is the "fixed appliance", a pre-built binary appliance for
libguestfs. This was built using $program.
Unpack the appliance directory:
tar -Jxvf appliance-<VERSION>.tar.xz
Then copy all four files:
* kernel
* initrd
* root
* README.fixed
into a directory somewhere, eg. /usr/local/lib/guestfs/appliance/
Then build libguestfs (>= 1.16.7 or >= 1.18) from source, disabling
the normal appliance and daemon:
./configure --disable-appliance --disable-daemon
make
sudo make install
Set LIBGUESTFS_PATH to the path where you unpacked these files, eg:
export LIBGUESTFS_PATH=/usr/local/lib/guestfs/appliance/
and run the libguestfs programs and virt tools in the normal way.
LICENSE
-------
This appliance contains software under a variety of open source
licenses. The software is from Fedora (https://fedoraproject.org/),
and to rebuild it you need to download Fedora 17+ and
libguestfs >= 1.17.10, and build libguestfs from source in the usual
way.
EOF
# If --xz, compress the result. Note -S option to preserve sparseness.
if [ -n "$xz_mode" ]; then
tar -C "$tmpdir" -S -cf - appliance | xz --best > "appliance-$version.tar.xz"
rm -rf "$tmpdir" ||:
trap - EXIT ERR
fi

View File

@@ -0,0 +1,181 @@
=encoding utf8
=head1 NAME
libguestfs-make-fixed-appliance - Make a "fixed appliance" for libguestfs
=head1 SYNOPSIS
libguestfs-make-fixed-appliance [--options] OUTPUTDIR
libguestfs-make-fixed-appliance [--options] --xz
=head1 DESCRIPTION
libguestfs-make-fixed-appliance lets you make a pre-built binary
appliance for libguestfs.
B<Note that ordinary users should not need to run this tool>.
Some reasons why you I<might> want to use this include:
=over 4
=item *
You want to make a self-contained libguestfs appliance that can be
copied to another machine or platform that doesn't support
L<supermin(8)>.
=item *
You have multiple users on the same machine and want to avoid the
storage duplication and start-up overhead of having multiple cached
copies of the appliance.
=item *
You want to have very predictable performance from libguestfs (see
L<guestfs-performance(1)>).
=back
For deeper understanding of why you might need this tool, read the
section L</FIXED APPLIANCE> below.
Instead of running this tool, you can download fixed appliances from
L<http://libguestfs.org/download/binaries/appliance/>. These
appliances were made using this tool.
There are two ways to use this tool.
=over 4
=item *
Specify an output directory, for example:
libguestfs-make-fixed-appliance /usr/local/lib/guestfs/appliance
The output directory is created if it does not exist. Four files are
created in this directory:
<OUTPUTDIR>/kernel
<OUTPUTDIR>/initrd
<OUTPUTDIR>/root
<OUTPUTDIR>/README.fixed
Note that C<I<OUTPUTDIR>/root> is a sparse file, so take care when
copying it.
You can then run libguestfs (possibly after copying this directory to
another machine) by setting the environment variable LIBGUESTFS_PATH
to C<OUTPUTDIR>.
=item *
The alternative method is to use the I<--xz> option to create a
compressed tarball:
libguestfs-make-fixed-appliance --xz
This creates a tarball in the I<current> directory called:
appliance-<VERSION>.tar.xz
(where C<VERSION> is the version of libguestfs). The tarball contains
the four files:
appliance/kernel
appliance/initrd
appliance/root
appliance/README.fixed
Note that C<appliance/root> is a sparse file, so take care when
copying it.
=back
=head1 OPTIONS
=over 4
=item B<--help>
Display short usage information and exit.
=item B<-V>
=item B<--version>
Display the version number and exit.
=item B<--xz>
Instead of creating the appliance in an output directory, create a
compressed tarball of the appliance in the current directory called
C<appliance-I<VERSION>.tar.xz> where C<VERSION> is the version of
libguestfs.
Using I<--xz> can take some time. If working normally, the tool is
completely silent when it is running.
=back
=head1 FIXED APPLIANCE
When libguestfs (or libguestfs tools) are run, they search a path
looking for an appliance. The path is built into libguestfs, or can
be set using the C<LIBGUESTFS_PATH> environment variable.
Normally a supermin appliance is located on this path (see
L<supermin(8)/SUPERMIN APPLIANCE>). libguestfs reconstructs this
into a full appliance by running L<supermin-helper(8)>.
However, a simpler "fixed appliance" can also be used. libguestfs
detects this by looking for a directory on the path containing four
files called C<kernel>, C<initrd>, C<root> and C<README.fixed> (note
the C<README.fixed> file must be present as well).
If the fixed appliance is found, libguestfs skips supermin entirely
and just runs qemu with the kernel, initrd and root disk from the
fixed appliance.
Thus the fixed appliance can be used when a platform or Linux distro
does not support supermin. You build the fixed appliance on a
platform that does support supermin, and copy it over, and use that
to run libguestfs.
=head1 LICENSING
The fixed appliance is a complete Linux binary distro. If you
distribute it, you may need to distribute corresponding source files
to remain in legal compliance with the licenses of the software in the
appliance (such as the GNU General Public License).
=head1 EXIT STATUS
libguestfs-make-fixed-appliance returns I<0> if the appliance was
built without errors.
=head1 ENVIRONMENT VARIABLES
For the full list of environment variables which may affect
libguestfs, please see the L<guestfs(3)> manual page.
=head1 SEE ALSO
L<guestfs(3)>,
L<supermin(8)>,
L<supermin-helper(8)>,
L<xz(1)>,
L<http://libguestfs.org/>,
L<http://qemu.org/>.
=head1 AUTHORS
Richard W.M. Jones (C<rjones at redhat dot com>)
=head1 COPYRIGHT
Copyright (C) 2009-2013 Red Hat Inc.

View File

@@ -1,6 +1,6 @@
#!/bin/bash -
# @configure_input@
# Copyright (C) 2009-2012 Red Hat Inc.
# Copyright (C) 2009-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
@@ -27,13 +27,15 @@ while read regexp <&5; do
done
exec 5<&-
# Run febootstrap on the package list.
if [ "x@FEBOOTSTRAP_YUM_CONFIG@" != "xno" ]; then
extra="--yum-config @FEBOOTSTRAP_YUM_CONFIG@"
# Run supermin on the package list.
# NB: Keep using --yum-config (deprecated alias) here since both old
# and new supermin still support it.
if [ "x@SUPERMIN_PACKAGER_CONFIG@" != "xno" ]; then
extra="--yum-config @SUPERMIN_PACKAGER_CONFIG@"
fi
echo @FEBOOTSTRAP@ -v -o supermin.d --names $(< packagelist ) $excludes $extra
@FEBOOTSTRAP@ -v -o supermin.d --names $(< packagelist ) $excludes $extra
echo @SUPERMIN@ -v -o supermin.d --names $(< packagelist ) $excludes $extra
@SUPERMIN@ -v -o supermin.d --names $(< packagelist ) $excludes $extra
# Remove some things that we don't want in the appliance. This is
# copied from the old febootstrap-minimize. However minimization is

View File

@@ -23,27 +23,32 @@
btrfs-progs
cryptsetup
cryptsetup-luks /* old name used before Fedora 17 */
diffutils
e2fsprogs
/* e4fsprogs only exists on RHEL 5, will be ignored everywhere else. */
e4fsprogs
genisoimage
gfs-utils
gfs2-utils
grub
hfsplus-tools
hivex
iproute
iputils
kernel
libcap
libldm /* only Fedora has this for now, but we should add it to others later*/
MAKEDEV
nilfs-utils
ntfsprogs
ntfs-3g
openssh-clients
pcre
reiserfs-utils
libselinux
systemd /* for /sbin/reboot */
udev
util-linux-ng
systemd /* for /sbin/reboot and udevd */
vim-minimal
xz
yajl
zfs-fuse
#endif /* REDHAT */
@@ -51,63 +56,77 @@
bsdmainutils
btrfs-tools
cryptsetup
diff
e2fsprogs
genisoimage
gfs-tools
gfs2-tools
grub-pc
hfsplus
iproute
libaugeas0
libcap2
libhivex0
libpcre3
libyajl2
linux-image
nilfs-tools
ntfs-3g
ntfsprogs
openssh-client
reiserfsprogs
udev
sysvinit /* for /sbin/reboot */
ufsutils
util-linux
vim-tiny
xz-utils
zfs-fuse
#endif /* DEBIAN */
#ifdef ARCHLINUX
linux
vim
btrfs-progs-unstable
cryptsetup
diffutils
augeas
zfs-fuse
btrfs-progs
cdrkit
cryptsetup
e2fsprogs
grub
hivex
iproute2
iputils
libcap
linux
lrzip
nilfs-utils
ntfsprogs
ntfs-3g
pcre
reiserfsprogs
udev
util-linux-ng
systemd
vim
xz
yajl
zfs-fuse
#endif /* ARCHLINUX */
acl
attr
bash
binutils
bzip2
coreutils
cpio
diffutils
dosfstools
file
findutils
gawk
gdisk
grep
gzip
iproute
jfsutils
kmod
less
libxml2
lsof
lsscsi
lvm2
lzop
mdadm
@@ -119,10 +138,16 @@ ocfs2-tools
*/
parted
procps
procps-ng
psmisc
rsync
scrub
sed
strace
tar
udev
util-linux
util-linux-ng
#ifndef UBUNTU
/* on Ubuntu contains a file in /lib64 which conflicts with libc6 that has
* /lib64 as a symbolic link
@@ -134,3 +159,8 @@ zerofree
#ifdef VALGRIND_DAEMON
valgrind
#endif
/* Enable this to add useful debugging tools to the appliance. */
#if 0
gdb
#endif

View File

@@ -44,7 +44,7 @@ fi
# If no arguments were specified and configure has run before, use the previous
# arguments
if test $# == 0 && test -x ./config.status; then
if test $# -eq 0 && test -x ./config.status; then
./config.status --recheck
else
$CONFIGUREDIR/configure "$@"

View File

@@ -9,8 +9,9 @@ false
<61><62><63><00><61><62><63>
obool: true
oint: 1
oint64: unset
oint64: 9223372036854775807
ostring: unset
ostringlist: unset
abc
null
[]
@@ -24,6 +25,7 @@ obool: unset
oint: unset
oint64: 1
ostring: string
ostringlist: unset
def
[]
@@ -35,8 +37,9 @@ false
<61><62><63><00><61><62><63>
obool: false
oint: unset
oint64: unset
oint64: -9223372036854775808
ostring: unset
ostringlist: unset
[]
@@ -50,6 +53,7 @@ obool: unset
oint: unset
oint64: unset
ostring: unset
ostringlist: unset
abc
def
["1"]
@@ -63,6 +67,7 @@ obool: unset
oint: unset
oint64: unset
ostring: unset
ostringlist: unset
abc
def
["1", "2"]
@@ -76,6 +81,7 @@ obool: unset
oint: unset
oint64: unset
ostring: unset
ostringlist: unset
abc
def
["1"]
@@ -89,6 +95,7 @@ obool: unset
oint: unset
oint64: unset
ostring: unset
ostringlist: unset
abc
def
["1"]
@@ -102,6 +109,7 @@ obool: unset
oint: unset
oint64: unset
ostring: unset
ostringlist: unset
abc
def
["1"]
@@ -115,6 +123,7 @@ obool: unset
oint: unset
oint64: unset
ostring: unset
ostringlist: unset
abc
def
["1"]
@@ -128,6 +137,7 @@ obool: unset
oint: unset
oint64: unset
ostring: unset
ostringlist: unset
abc
def
["1"]
@@ -141,12 +151,13 @@ obool: unset
oint: unset
oint64: unset
ostring: unset
ostringlist: unset
abc
def
["1"]
false
4095
4095
9223372036854775807
123
456
<61><62><63><00><61><62><63>
@@ -154,12 +165,13 @@ obool: unset
oint: unset
oint64: unset
ostring: unset
ostringlist: unset
abc
def
["1"]
false
0
0
-9223372036854775808
<61><62><63><00><61><62><63>
@@ -167,4 +179,61 @@ obool: unset
oint: unset
oint64: unset
ostring: unset
ostringlist: unset
abc
def
[]
false
0
0
123
456
<61><62><63><00><61><62><63>
obool: unset
oint: unset
oint64: unset
ostring: unset
ostringlist: []
abc
def
[]
false
0
0
123
456
<61><62><63><00><61><62><63>
obool: unset
oint: unset
oint64: unset
ostring: unset
ostringlist: ["optelem1"]
abc
def
[]
false
0
0
123
456
<61><62><63><00><61><62><63>
obool: unset
oint: unset
oint64: unset
ostring: unset
ostringlist: ["optelem1", "optelem2"]
abc
def
[]
false
0
0
123
456
<61><62><63><00><61><62><63>
obool: unset
oint: unset
oint64: unset
ostring: unset
ostringlist: ["optelem1", "optelem2", "optelem3"]
EOF

View File

@@ -26,13 +26,6 @@ git submodule init || exit $?
git submodule update || exit $?
GNULIB_SRCDIR=.gnulib
ls po/*.po 2>/dev/null | sed 's|.*/||; s|\.po$||' > po/LINGUAS
# Run autopoint, to get po/Makevars.template:
# Also, released autopoint has the tendency to install macros that have
# been obsoleted in current gnulib, so run this before gnulib-tool.
autopoint --force
# Autoreconf runs aclocal before libtoolize, which causes spurious
# warnings if the initial aclocal is confused by the libtoolized
# (or worse out-of-date) macro directory.
@@ -44,13 +37,19 @@ gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
(cd daemon && mkdir -p tests lib && ../$gnulib_tool --update)
modules='
accept4
areadlink
areadlinkat
arpa_inet
byteswap
c-ctype
cloexec
closeout
connect
dup3
error
filevercmp
fstatat
fsusage
fts
full-read
@@ -69,11 +68,13 @@ ignore-value
lock
maintainer-makefile
manywarnings
memmem
mkdtemp
netdb
netinet_in
openat
perror
pipe2
pread
progname
read-file
@@ -82,6 +83,7 @@ select
setenv
sleep
socket
stat-time
strchrnul
strerror
strndup
@@ -98,8 +100,12 @@ xstrtoll
xvasprintf
'
# If any tests fail, avoid including them by adding them to
# this list.
avoid="--avoid=dummy --avoid=getlogin_r-tests"
$gnulib_tool \
--avoid=dummy \
$avoid \
--with-tests \
--m4-base=m4 \
--source-base=gnulib/lib \

View File

@@ -1,6 +1,6 @@
#!/bin/bash -
# bugs-in-changelog.sh
# Copyright (C) 2009-2012 Red Hat Inc.
# Copyright (C) 2009-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
@@ -16,10 +16,10 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# Used when preparing the RELEASE-NOTES file. This script looks at
# the bugs noted in the git changelog since the last stable release
# (or any release). To use it, the only parameter should be the git
# commit range, eg:
# Used when preparing the guestfs-release-notes(1) man page. This
# script looks at the bugs noted in the git changelog since the last
# stable release (or any release). To use it, the only parameter
# should be the git commit range, eg:
#
# ./bugs-in-changelog.sh "1.0.89.."
@@ -42,5 +42,10 @@ bugids=$(
# Filter out any bugs which may still be in NEW or ASSIGNED:
bugzilla query -b "$bugids" \
-t MODIFIED,POST,ON_QA,PASSES_QA,VERIFIED,RELEASE_PENDING,CLOSED \
--outputformat=' - %{bug_id} %{short_desc}' |
sort -n -r
--outputformat='%{bug_id} %{short_desc}' |
sort -n -r |
perl -pe '
s{([0-9]+)\s+(.*)}{
sprintf ("=item L<https://bugzilla.redhat.com/%s>\n\n%s\n",
$1, $2)
}xe'

View File

@@ -31,11 +31,11 @@ bin_PROGRAMS = virt-cat virt-filesystems virt-ls
SHARED_SOURCE_FILES = \
../fish/config.c \
../fish/domain.c \
../fish/inspect.c \
../fish/keys.c \
../fish/options.h \
../fish/options.c \
../fish/virt.c
../fish/options.c
virt_cat_SOURCES = \
$(SHARED_SOURCE_FILES) \
@@ -48,6 +48,7 @@ virt_cat_CFLAGS = \
-I$(srcdir)/../gnulib/lib -I../gnulib/lib \
-DLOCALEBASEDIR=\""$(datadir)/locale"\" \
$(WARN_CFLAGS) $(WERROR_CFLAGS) \
$(GPROF_CFLAGS) $(GCOV_CFLAGS) \
$(LIBCONFIG_CFLAGS)
virt_cat_LDADD = \
@@ -66,6 +67,7 @@ virt_filesystems_CFLAGS = \
-I$(srcdir)/../gnulib/lib -I../gnulib/lib \
-DLOCALEBASEDIR=\""$(datadir)/locale"\" \
$(WARN_CFLAGS) $(WERROR_CFLAGS) \
$(GPROF_CFLAGS) $(GCOV_CFLAGS) \
$(LIBCONFIG_CFLAGS)
virt_filesystems_LDADD = \
@@ -84,6 +86,7 @@ virt_ls_CFLAGS = \
-I$(srcdir)/../gnulib/lib -I../gnulib/lib \
-DLOCALEBASEDIR=\""$(datadir)/locale"\" \
$(WARN_CFLAGS) $(WERROR_CFLAGS) \
$(GPROF_CFLAGS) $(GCOV_CFLAGS) \
$(LIBCONFIG_CFLAGS)
virt_ls_LDADD = \
@@ -102,38 +105,48 @@ noinst_DATA = \
virt-cat.1 $(top_builddir)/html/virt-cat.1.html: stamp-virt-cat.pod
stamp-virt-cat.pod: virt-cat.pod
$(top_builddir)/podwrapper.sh \
$(PODWRAPPER) \
--man virt-cat.1 \
--html $(top_builddir)/html/virt-cat.1.html \
--license GPLv2+ \
$<
touch $@
virt-ls.1 $(top_builddir)/html/virt-ls.1.html: stamp-virt-ls.pod
stamp-virt-ls.pod: virt-ls.pod
$(top_builddir)/podwrapper.sh \
$(PODWRAPPER) \
--man virt-ls.1 \
--html $(top_builddir)/html/virt-ls.1.html \
--license GPLv2+ \
$<
touch $@
virt-filesystems.1 $(top_builddir)/html/virt-filesystems.1.html: stamp-virt-filesystems.pod
stamp-virt-filesystems.pod: virt-filesystems.pod
$(top_builddir)/podwrapper.sh \
$(PODWRAPPER) \
--man virt-filesystems.1 \
--html $(top_builddir)/html/virt-filesystems.1.html \
--license GPLv2+ \
$<
touch $@
# Tests.
random_val := $(shell awk 'BEGIN{srand(); print 1+int(255*rand())}' < /dev/null)
TESTS_ENVIRONMENT = \
MALLOC_PERTURB_=$(random_val) \
$(top_builddir)/run
TESTS_ENVIRONMENT = $(top_builddir)/run --test
if ENABLE_APPLIANCE
TESTS = test-virt-cat.sh test-virt-filesystems.sh test-virt-ls.sh
TESTS = \
test-virt-cat.sh \
test-virt-filesystems.sh \
test-virt-ls.sh
endif ENABLE_APPLIANCE
check-valgrind:
$(MAKE) VG="$(top_builddir)/run @VG@" check
check-valgrind-local-guests:
for g in $(GUESTS); do \
$(top_builddir)/run --test @VG@ ./virt-filesystems -c "$(libvirt_ro_uri)" -d "$$g" --all --long -h --uuid || exit $$?; \
done

View File

@@ -1,14 +1,30 @@
#!/bin/bash -
# libguestfs
# Copyright (C) 2009-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.
export LANG=C
set -e
# Read out the test files from the image using virt-cat.
if [ "$(./virt-cat ../tests/guests/fedora.img /etc/test1)" != "abcdefg" ]; then
if [ "$($VG ./virt-cat ../tests/guests/fedora.img /etc/test1)" != "abcdefg" ]; then
echo "$0: error: mismatch in file test1"
exit 1
fi
if [ "$(./virt-cat ../tests/guests/fedora.img /etc/test2)" != "" ]; then
if [ "$($VG ./virt-cat ../tests/guests/fedora.img /etc/test2)" != "" ]; then
echo "$0: error: mismatch in file test2"
exit 1
fi

View File

@@ -1,9 +1,25 @@
#!/bin/bash -
# libguestfs
# Copyright (C) 2009-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.
export LANG=C
set -e
output="$(./virt-filesystems -a ../tests/guests/fedora.img | sort)"
output="$($VG ./virt-filesystems -a ../tests/guests/fedora.img | sort)"
expected="/dev/VG/LV1
/dev/VG/LV2
/dev/VG/LV3
@@ -16,7 +32,7 @@ if [ "$output" != "$expected" ]; then
exit 1
fi
output="$(./virt-filesystems -a ../tests/guests/fedora.img --all --long --uuid -h --no-title | awk '{print $1}' | sort -u)"
output="$($VG ./virt-filesystems -a ../tests/guests/fedora.img --all --long --uuid -h --no-title | awk '{print $1}' | sort -u)"
expected="/dev/VG
/dev/VG/LV1
/dev/VG/LV2

View File

@@ -1,10 +1,26 @@
#!/bin/bash -
# libguestfs
# Copyright (C) 2012 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.
export LANG=C
set -e
# Read out the test directory using virt-ls.
if [ "$(./virt-ls ../tests/guests/fedora.img /bin)" != "ls
if [ "$($VG ./virt-ls ../tests/guests/fedora.img /bin)" != "ls
test1
test2
test3
@@ -17,7 +33,7 @@ test7" ]; then
fi
# Try the -lR option.
output="$(./virt-ls -lR ../tests/guests/fedora.img /boot | awk '{print $1 $2 $4}')"
output="$($VG ./virt-ls -lR ../tests/guests/fedora.img /boot | awk '{print $1 $2 $4}')"
expected="d0755/boot
d0755/boot/grub
-0644/boot/grub/grub.conf
@@ -31,3 +47,7 @@ if [ "$output" != "$expected" ]; then
echo "--------------------------------------------------"
exit 1
fi
# Try the -l and -R options. XXX Should check the output.
$VG ./virt-ls -l ../tests/guests/fedora.img /
$VG ./virt-ls -R ../tests/guests/fedora.img /

View File

@@ -45,15 +45,10 @@ int echo_keys = 0;
const char *libvirt_uri = NULL;
int inspector = 1;
static int do_cat (int argc, char *argv[]);
static int is_windows (guestfs_h *g, const char *root);
static char *windows_path (guestfs_h *g, const char *root, const char *filename);
static inline char *
bad_cast (char const *s)
{
return (char *) s;
}
static void __attribute__((noreturn))
usage (int status)
{
@@ -114,6 +109,7 @@ main (int argc, char *argv[])
struct drv *drv;
const char *format = NULL;
int c;
int r;
int option_index;
g = guestfs_create ();
@@ -122,7 +118,7 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
argv[0] = bad_cast (program_name);
argv[0] = (char *) program_name;
for (;;) {
c = getopt_long (argc, argv, options, long_options, &option_index);
@@ -158,9 +154,6 @@ main (int argc, char *argv[])
OPTION_d;
break;
case 'h':
usage (EXIT_SUCCESS);
case 'v':
OPTION_v;
break;
@@ -243,24 +236,34 @@ main (int argc, char *argv[])
/* Free up data structures, no longer needed after this point. */
free_drives (drvs);
r = do_cat (argc - optind, &argv[optind]);
guestfs_close (g);
exit (r == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
static int
do_cat (int argc, char *argv[])
{
unsigned errors = 0;
int windows;
char *root, **roots;
int windows, i;
char *root;
/* Get root mountpoint. See: fish/inspect.c:inspect_mount */
roots = guestfs_inspect_get_roots (g);
CLEANUP_FREE_STRING_LIST char **roots = guestfs_inspect_get_roots (g);
assert (roots);
assert (roots[0] != NULL);
assert (roots[1] == NULL);
root = roots[0];
free (roots);
/* Windows? Special handling is required. */
windows = is_windows (g, root);
for (; optind < argc; optind++) {
char *filename_to_free = NULL;
const char *filename = argv[optind];
for (i = 0; i < argc; ++i) {
CLEANUP_FREE char *filename_to_free = NULL;
const char *filename = argv[i];
if (windows) {
filename = filename_to_free = windows_path (g, root, filename);
@@ -272,15 +275,9 @@ main (int argc, char *argv[])
if (guestfs_download (g, filename, "/dev/stdout") == -1)
errors++;
free (filename_to_free);
}
free (root);
guestfs_close (g);
exit (errors == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
return errors == 0 ? 0 : -1;
}
static int

View File

@@ -256,17 +256,3 @@ Richard W.M. Jones L<http://people.redhat.com/~rjones/>
=head1 COPYRIGHT
Copyright (C) 2010-2012 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.

View File

@@ -36,15 +36,6 @@
#include "guestfs.h"
#include "options.h"
#define DISABLE_GUESTFS_ERRORS_FOR(stmt) do { \
guestfs_error_handler_cb old_error_cb; \
void *old_error_data; \
old_error_cb = guestfs_get_error_handler (g, &old_error_data); \
guestfs_set_error_handler (g, NULL, NULL); \
stmt; \
guestfs_set_error_handler (g, old_error_cb, old_error_data); \
} while (0)
/* These globals are shared with options.c. */
guestfs_h *g;
@@ -77,21 +68,17 @@ static int output = 0;
#define COLUMN_VFS_LABEL 8 /* if --filesystems */
#define COLUMN_MBR 16
#define COLUMN_SIZE 32 /* bytes, or human-readable if -h */
#define COLUMN_PARENT_NAME 64 /* only for partitions, LVs */
#define COLUMN_PARENTS 64
#define COLUMN_UUID 128 /* if --uuid */
#define NR_COLUMNS 8
static int columns;
static char *canonical_device (const char *dev);
static void do_output_title (void);
static void do_output (void);
static void do_output_end (void);
static inline char *
bad_cast (char const *s)
{
return (char *) s;
}
static struct guestfs_lvm_pv_list *get_pvs (void);
static void free_pvs (void);
static void __attribute__((noreturn))
usage (int status)
@@ -204,7 +191,7 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
argv[0] = bad_cast (program_name);
argv[0] = (char *) program_name;
for (;;) {
c = getopt_long (argc, argv, options, long_options, &option_index);
@@ -334,8 +321,7 @@ main (int argc, char *argv[])
columns |= COLUMN_VFS_TYPE;
columns |= COLUMN_VFS_LABEL;
}
if ((output & (OUTPUT_PARTITIONS|OUTPUT_LVS)))
columns |= COLUMN_PARENT_NAME;
columns |= COLUMN_PARENTS;
if ((output & OUTPUT_PARTITIONS))
columns |= COLUMN_MBR;
if (uuid)
@@ -365,6 +351,8 @@ main (int argc, char *argv[])
do_output ();
do_output_end ();
free_pvs ();
guestfs_close (g);
exit (EXIT_SUCCESS);
@@ -376,9 +364,17 @@ static void do_output_vgs (void);
static void do_output_pvs (void);
static void do_output_partitions (void);
static void do_output_blockdevs (void);
static void write_row (const char *name, const char *type, const char *vfs_type, const char *vfs_label, int mbr_id, int64_t size, const char *parent_name, const char *uuid);
static void write_row (const char *name, const char *type, const char *vfs_type, const char *vfs_label, int mbr_id, int64_t size, char **parents, const char *uuid);
static void write_row_strings (char **strings, size_t len);
static char **no_parents (void);
static int is_md (char *device);
static char **parents_of_md (char *device);
static char **parents_of_vg (char *vg);
static size_t count_strings (char **strings);
static void
do_output_title (void)
{
@@ -398,7 +394,7 @@ do_output_title (void)
headings[len++] = "MBR";
if ((columns & COLUMN_SIZE))
headings[len++] = "Size";
if ((columns & COLUMN_PARENT_NAME))
if ((columns & COLUMN_PARENTS))
headings[len++] = "Parent";
if ((columns & COLUMN_UUID))
headings[len++] = "UUID";
@@ -435,31 +431,33 @@ do_output (void)
static void
do_output_filesystems (void)
{
char **fses;
size_t i;
fses = guestfs_list_filesystems (g);
CLEANUP_FREE_STRING_LIST char **fses = guestfs_list_filesystems (g);
if (fses == NULL)
exit (EXIT_FAILURE);
for (i = 0; fses[i] != NULL; i += 2) {
char *dev, *vfs_label = NULL, *vfs_uuid = NULL;
CLEANUP_FREE char *dev = NULL, *vfs_label = NULL, *vfs_uuid = NULL;
CLEANUP_FREE_STRING_LIST char **parents = NULL;
int64_t size = -1;
/* Skip swap and unknown, unless --extra flag was given. */
if (!(output & OUTPUT_FILESYSTEMS_EXTRA) &&
(STREQ (fses[i+1], "swap") || STREQ (fses[i+1], "unknown")))
goto next;
continue;
dev = canonical_device (fses[i]);
dev = guestfs_canonical_device_name (g, fses[i]);
if (dev == NULL)
exit (EXIT_FAILURE);
/* Only bother to look these up if we will be displaying them,
* otherwise pass them as NULL.
*/
if ((columns & COLUMN_VFS_LABEL)) {
DISABLE_GUESTFS_ERRORS_FOR (
vfs_label = guestfs_vfs_label (g, fses[i]);
);
guestfs_push_error_handler (g, NULL, NULL);
vfs_label = guestfs_vfs_label (g, fses[i]);
guestfs_pop_error_handler (g);
if (vfs_label == NULL) {
vfs_label = strdup ("");
if (!vfs_label) {
@@ -469,9 +467,9 @@ do_output_filesystems (void)
}
}
if ((columns & COLUMN_UUID)) {
DISABLE_GUESTFS_ERRORS_FOR (
vfs_uuid = guestfs_vfs_uuid (g, fses[i]);
);
guestfs_push_error_handler (g, NULL, NULL);
vfs_uuid = guestfs_vfs_uuid (g, fses[i]);
guestfs_pop_error_handler (g);
if (vfs_uuid == NULL) {
vfs_uuid = strdup ("");
if (!vfs_uuid) {
@@ -486,33 +484,28 @@ do_output_filesystems (void)
exit (EXIT_FAILURE);
}
if (is_md (fses[i]))
parents = parents_of_md (fses[i]);
else
parents = no_parents ();
write_row (dev, "filesystem",
fses[i+1], vfs_label, -1, size, NULL, vfs_uuid);
free (dev);
free (vfs_label);
free (vfs_uuid);
next:
free (fses[i]);
free (fses[i+1]);
fses[i+1], vfs_label, -1, size, parents, vfs_uuid);
}
free (fses);
}
static void
do_output_lvs (void)
{
char **lvs;
size_t i;
lvs = guestfs_lvs (g);
CLEANUP_FREE_STRING_LIST char **lvs = guestfs_lvs (g);
if (lvs == NULL)
exit (EXIT_FAILURE);
for (i = 0; lvs[i] != NULL; ++i) {
char *uuid = NULL, *parent_name = NULL;
CLEANUP_FREE char *uuid = NULL, *parent_name = NULL;
const char *parents[2];
int64_t size = -1;
if ((columns & COLUMN_SIZE)) {
@@ -525,7 +518,7 @@ do_output_lvs (void)
if (uuid == NULL)
exit (EXIT_FAILURE);
}
if ((columns & COLUMN_PARENT_NAME)) {
if ((columns & COLUMN_PARENTS)) {
parent_name = strdup (lvs[i]);
if (parent_name == NULL) {
perror ("strdup");
@@ -534,94 +527,110 @@ do_output_lvs (void)
char *p = strrchr (parent_name, '/');
if (p)
*p = '\0';
parents[0] = parent_name;
parents[1] = NULL;
}
write_row (lvs[i], "lv",
NULL, NULL, -1, size, parent_name, uuid);
free (uuid);
free (parent_name);
free (lvs[i]);
NULL, NULL, -1, size, (char **) parents, uuid);
}
free (lvs);
}
static void
do_output_vgs (void)
{
struct guestfs_lvm_vg_list *vgs;
size_t i;
vgs = guestfs_vgs_full (g);
CLEANUP_FREE_LVM_VG_LIST struct guestfs_lvm_vg_list *vgs =
guestfs_vgs_full (g);
if (vgs == NULL)
exit (EXIT_FAILURE);
for (i = 0; i < vgs->len; ++i) {
char name[PATH_MAX];
CLEANUP_FREE char *name = NULL;
char uuid[33];
CLEANUP_FREE_STRING_LIST char **parents = NULL;
if (asprintf (&name, "/dev/%s", vgs->val[i].vg_name) == -1) {
perror ("asprintf");
exit (EXIT_FAILURE);
}
strcpy (name, "/dev/");
strcpy (&name[5], vgs->val[i].vg_name);
memcpy (uuid, vgs->val[i].vg_uuid, 32);
uuid[32] = '\0';
parents = parents_of_vg (vgs->val[i].vg_name);
write_row (name, "vg",
NULL, NULL, -1, (int64_t) vgs->val[i].vg_size, NULL, uuid);
NULL, NULL, -1, (int64_t) vgs->val[i].vg_size, parents, uuid);
}
}
guestfs_free_lvm_vg_list (vgs);
/* Cache the output of guestfs_pvs_full, since we use it in a few places. */
static struct guestfs_lvm_pv_list *pvs_ = NULL;
static struct guestfs_lvm_pv_list *
get_pvs (void)
{
if (pvs_)
return pvs_;
pvs_ = guestfs_pvs_full (g);
if (pvs_ == NULL)
exit (EXIT_FAILURE);
return pvs_;
}
static void
free_pvs (void)
{
if (pvs_)
guestfs_free_lvm_pv_list (pvs_);
pvs_ = NULL;
}
static void
do_output_pvs (void)
{
struct guestfs_lvm_pv_list *pvs;
size_t i;
pvs = guestfs_pvs_full (g);
if (pvs == NULL)
exit (EXIT_FAILURE);
struct guestfs_lvm_pv_list *pvs = get_pvs ();
for (i = 0; i < pvs->len; ++i) {
char *dev;
char uuid[33];
const char *parents[1] = { NULL };
dev = canonical_device (pvs->val[i].pv_name);
CLEANUP_FREE char *dev =
guestfs_canonical_device_name (g, pvs->val[i].pv_name);
if (!dev)
exit (EXIT_FAILURE);
memcpy (uuid, pvs->val[i].pv_uuid, 32);
uuid[32] = '\0';
write_row (dev, "pv",
NULL, NULL, -1, (int64_t) pvs->val[i].pv_size, NULL, uuid);
free (dev);
NULL, NULL, -1, (int64_t) pvs->val[i].pv_size,
(char **) parents, uuid);
}
guestfs_free_lvm_pv_list (pvs);
}
static int
get_mbr_id (const char *dev, const char *parent_name)
{
char *parttype = NULL;
CLEANUP_FREE char *parttype = NULL;
int mbr_id = -1, partnum;
DISABLE_GUESTFS_ERRORS_FOR (
parttype = guestfs_part_get_parttype (g, parent_name);
);
guestfs_push_error_handler (g, NULL, NULL);
parttype = guestfs_part_get_parttype (g, parent_name);
if (parttype && STREQ (parttype, "msdos")) {
DISABLE_GUESTFS_ERRORS_FOR (
partnum = guestfs_part_to_partnum (g, dev);
);
if (partnum >= 0) {
DISABLE_GUESTFS_ERRORS_FOR (
mbr_id = guestfs_part_get_mbr_id (g, parent_name, partnum);
);
}
partnum = guestfs_part_to_partnum (g, dev);
if (partnum >= 0)
mbr_id = guestfs_part_get_mbr_id (g, parent_name, partnum);
}
free (parttype);
guestfs_pop_error_handler (g);
return mbr_id;
}
@@ -629,26 +638,28 @@ get_mbr_id (const char *dev, const char *parent_name)
static void
do_output_partitions (void)
{
char **parts;
size_t i;
parts = guestfs_list_partitions (g);
CLEANUP_FREE_STRING_LIST char **parts = guestfs_list_partitions (g);
if (parts == NULL)
exit (EXIT_FAILURE);
for (i = 0; parts[i] != NULL; ++i) {
char *dev, *parent_name = NULL;
CLEANUP_FREE char *dev = NULL, *parent_name = NULL, *canonical_name = NULL;
const char *parents[2];
int64_t size = -1;
int mbr_id = -1;
dev = canonical_device (parts[i]);
dev = guestfs_canonical_device_name (g, parts[i]);
if (!dev)
exit (EXIT_FAILURE);
if ((columns & COLUMN_SIZE)) {
size = guestfs_blockdev_getsize64 (g, parts[i]);
if (size == -1)
exit (EXIT_FAILURE);
}
if ((columns & COLUMN_PARENT_NAME)) {
if ((columns & COLUMN_PARENTS)) {
parent_name = guestfs_part_to_dev (g, parts[i]);
if (parent_name == NULL)
exit (EXIT_FAILURE);
@@ -656,37 +667,36 @@ do_output_partitions (void)
if ((columns & COLUMN_MBR))
mbr_id = get_mbr_id (parts[i], parent_name);
char *p = canonical_device (parent_name);
free (parent_name);
parent_name = p;
canonical_name = guestfs_canonical_device_name (g, parent_name);
if (!canonical_name)
exit (EXIT_FAILURE);
parents[0] = canonical_name;
parents[1] = NULL;
}
write_row (dev, "partition",
NULL, NULL, mbr_id, size, parent_name, NULL);
free (dev);
free (parent_name);
free (parts[i]);
NULL, NULL, mbr_id, size, (char **) parents, NULL);
}
free (parts);
}
static void
do_output_blockdevs (void)
{
char **devices;
size_t i;
devices = guestfs_list_devices (g);
CLEANUP_FREE_STRING_LIST char **devices = guestfs_list_devices (g);
if (devices == NULL)
exit (EXIT_FAILURE);
for (i = 0; devices[i] != NULL; ++i) {
int64_t size = -1;
char *dev;
CLEANUP_FREE_STRING_LIST char **parents = NULL;
CLEANUP_FREE char *dev;
dev = canonical_device (devices[i]);
dev = guestfs_canonical_device_name (g, devices[i]);
if (!dev)
exit (EXIT_FAILURE);
if ((columns & COLUMN_SIZE)) {
size = guestfs_blockdev_getsize64 (g, devices[i]);
@@ -694,32 +704,175 @@ do_output_blockdevs (void)
exit (EXIT_FAILURE);
}
if (is_md (devices[i]))
parents = parents_of_md (devices[i]);
else
parents = no_parents ();
write_row (dev, "device",
NULL, NULL, -1, size, NULL, NULL);
free (dev);
free (devices[i]);
NULL, NULL, -1, size, parents, NULL);
}
free (devices);
}
/* /dev/vda1 -> /dev/sda. Returns a string which the caller must free. */
static char *
canonical_device (const char *dev)
/* Returns an empty list of parents. Note this must be freed. */
static char **
no_parents (void)
{
char *ret = strdup (dev);
if (ret == NULL) {
perror ("strdup");
char **ret;
ret = malloc (sizeof (char *));
if (!ret) {
perror ("malloc");
exit (EXIT_FAILURE);
}
if (STRPREFIX (ret, "/dev/") &&
(ret[5] == 'h' || ret[5] == 'v') &&
ret[6] == 'd' &&
c_isalpha (ret[7]) &&
(c_isdigit (ret[8]) || ret[8] == '\0'))
ret[5] = 's';
ret[0] = NULL;
return ret;
}
/* XXX Should be a better test than this. */
static int
is_md (char *device)
{
char *p;
if (!STRPREFIX (device, "/dev/md"))
return 0;
p = device + 7;
while (*p) {
if (!c_isdigit (*p))
return 0;
p++;
}
return 1;
}
static char **
parents_of_md (char *device)
{
char **ret;
size_t i;
CLEANUP_FREE_MDSTAT_LIST struct guestfs_mdstat_list *stats =
guestfs_md_stat (g, device);
if (!stats)
exit (EXIT_FAILURE);
ret = malloc ((stats->len + 1) * sizeof (char *));
if (!ret) {
perror ("malloc");
exit (EXIT_FAILURE);
}
for (i = 0; i < stats->len; ++i) {
ret[i] = guestfs_canonical_device_name (g, stats->val[i].mdstat_device);
if (!ret[i])
exit (EXIT_FAILURE);
}
ret[stats->len] = NULL;
return ret;
}
/* Specialized PV UUID comparison function.
* pvuuid1: from vgpvuuids, this may contain '-' characters which
* should be ignored.
* pvuuid2: from pvs-full, this is 32 characters long and NOT
* terminated by \0
*/
static int
compare_pvuuids (const char *pvuuid1, const char *pvuuid2)
{
size_t i;
const char *p = pvuuid1;
for (i = 0; i < 32; ++i) {
while (*p && !c_isalnum (*p))
p++;
if (!*p)
return 0;
if (*p != pvuuid2[i])
return 0;
}
return 1;
}
static char **
parents_of_vg (char *vg)
{
struct guestfs_lvm_pv_list *pvs = get_pvs ();
char **ret;
size_t n, i, j;
CLEANUP_FREE_STRING_LIST char **pvuuids = guestfs_vgpvuuids (g, vg);
if (!pvuuids)
exit (EXIT_FAILURE);
n = count_strings (pvuuids);
ret = malloc ((n + 1) * sizeof (char *));
if (!ret) {
perror ("malloc");
exit (EXIT_FAILURE);
}
/* Resolve each PV UUID back to a PV. */
for (i = 0; i < n; ++i) {
for (j = 0; j < pvs->len; ++j) {
if (compare_pvuuids (pvuuids[i], pvs->val[j].pv_uuid) == 0)
break;
}
if (j < pvs->len) {
ret[i] = guestfs_canonical_device_name (g, pvs->val[j].pv_name);
if (!ret[i])
exit (EXIT_FAILURE);
}
else {
fprintf (stderr, "%s: warning: unknown PV UUID ignored\n", __func__);
ret[i] = strndup (pvuuids[i], 32);
if (!ret[i]) {
perror ("strndup");
exit (EXIT_FAILURE);
}
}
}
ret[i] = NULL;
return ret;
}
static char *
join_comma (char **strings)
{
size_t i, count;
char *ret;
for (count = i = 0; strings[i] != NULL; ++i) {
if (i > 0)
count++;
count += strlen (strings[i]);
}
ret = malloc (count + 1);
if (ret == NULL) {
perror ("malloc");
exit (EXIT_FAILURE);
}
for (count = i = 0; strings[i] != NULL; ++i) {
if (i > 0)
ret[count++] = ',';
strcpy (&ret[count], strings[i]);
count += strlen (strings[i]);
}
ret[count] = 0;
return ret;
}
@@ -727,9 +880,10 @@ canonical_device (const char *dev)
static void
write_row (const char *name, const char *type,
const char *vfs_type, const char *vfs_label, int mbr_id,
int64_t size, const char *parent_name, const char *uuid)
int64_t size, char **parents, const char *uuid)
{
const char *strings[NR_COLUMNS];
CLEANUP_FREE char *parents_str = NULL;
size_t len = 0;
char hum[LONGEST_HUMAN_READABLE];
char num[256];
@@ -767,8 +921,11 @@ write_row (const char *name, const char *type,
else
strings[len++] = NULL;
}
if ((columns & COLUMN_PARENT_NAME))
strings[len++] = parent_name;
if ((columns & COLUMN_PARENTS)) {
/* Internally comma-separated field. */
parents_str = join_comma (parents);
strings[len++] = parents_str;
}
if ((columns & COLUMN_UUID))
strings[len++] = uuid;
assert (len <= NR_COLUMNS);
@@ -942,3 +1099,13 @@ do_output_end (void)
}
free (rows);
}
static size_t
count_strings (char **strings)
{
size_t i;
for (i = 0; strings[i] != NULL; ++i)
;
return i;
}

View File

@@ -332,10 +332,14 @@ then the size is displayed in a human-readable form.
=item B<Parent>
The parent column records the parent relationship between objects.
For example, if the object is a partition, then this column contains
the name of the containing device. If the object is a logical volume,
then this column is the name of the volume group.
If there is more than one parent, then this column is (internal to the
column) a comma-separated list, eg. C</dev/sda,/dev/sdb>.
=item B<UUID>
If the object has a UUID (used for identifying and mounting
@@ -399,18 +403,4 @@ Richard W.M. Jones L<http://people.redhat.com/~rjones/>
=head1 COPYRIGHT
Copyright (C) 2010 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.
Copyright (C) 2010-2012 Red Hat Inc.

View File

@@ -82,16 +82,6 @@ static int is_fifo (int64_t mode);
static int is_lnk (int64_t mode);
static int is_sock (int64_t mode);
static size_t count_strings (char **);
static void free_strings (char **);
static char **take_strings (char **, size_t n, char ***);
static inline char *
bad_cast (char const *s)
{
return (char *) s;
}
static void __attribute__((noreturn))
usage (int status)
{
@@ -193,7 +183,7 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
argv[0] = bad_cast (program_name);
argv[0] = (char *) program_name;
for (;;) {
c = getopt_long (argc, argv, options, long_options, &option_index);
@@ -410,18 +400,14 @@ main (int argc, char *argv[])
static int
do_ls (const char *dir)
{
char **lines;
size_t i;
CLEANUP_FREE_STRING_LIST char **lines = guestfs_ls (g, dir);
if ((lines = guestfs_ls (g, dir)) == NULL) {
if (lines == NULL)
return -1;
}
for (i = 0; lines[i] != NULL; ++i) {
for (i = 0; lines[i] != NULL; ++i)
printf ("%s\n", lines[i]);
free (lines[i]);
}
free (lines);
return 0;
}
@@ -429,13 +415,12 @@ do_ls (const char *dir)
static int
do_ls_l (const char *dir)
{
char *out;
CLEANUP_FREE char *out = guestfs_ll (g, dir);
if ((out = guestfs_ll (g, dir)) == NULL)
if (out == NULL)
return -1;
printf ("%s", out);
free (out);
return 0;
}
@@ -443,71 +428,22 @@ do_ls_l (const char *dir)
static int
do_ls_R (const char *dir)
{
/* This is TMP_TEMPLATE_ON_STACK expanded from fish.h. */
const char *tmpdir = guestfs_tmpdir ();
char tmpfile[strlen (tmpdir) + 32];
sprintf (tmpfile, "%s/virtlsXXXXXX", tmpdir);
size_t i;
CLEANUP_FREE_STRING_LIST char **dirs = guestfs_find (g, dir);
int fd = mkstemp (tmpfile);
if (fd == -1) {
perror ("mkstemp");
exit (EXIT_FAILURE);
}
char buf[BUFSIZ]; /* also used below */
snprintf (buf, sizeof buf, "/dev/fd/%d", fd);
if (guestfs_find0 (g, dir, buf) == -1)
if (dirs == NULL)
return -1;
if (close (fd) == -1) {
perror (tmpfile);
exit (EXIT_FAILURE);
}
for (i = 0; dirs[i] != NULL; ++i)
puts (dirs[i]);
/* The output of find0 is a \0-separated file. Turn each \0 into
* a \n character.
*/
fd = open (tmpfile, O_RDONLY);
if (fd == -1) {
perror (tmpfile);
exit (EXIT_FAILURE);
}
ssize_t r;
while ((r = read (fd, buf, sizeof buf)) > 0) {
size_t i;
for (i = 0; i < (size_t) r; ++i)
if (buf[i] == '\0')
buf[i] = '\n';
size_t n = r;
while (n > 0) {
r = write (1, buf, n);
if (r == -1) {
perror ("write");
exit (EXIT_FAILURE);
}
n -= r;
}
}
if (r == -1 || close (fd) == -1) {
perror (tmpfile);
exit (EXIT_FAILURE);
}
unlink (tmpfile);
return 0;
return 0;
}
/* Adapted from
https://rwmj.wordpress.com/2010/12/15/tip-audit-virtual-machine-for-setuid-files/
*/
static char *full_path (const char *dir, const char *name);
static struct guestfs_stat_list *lstatlist (const char *dir, char **names);
static struct guestfs_xattr_list *lxattrlist (const char *dir, char **names);
static int show_file (const char *dir, const char *name, const struct guestfs_stat *stat, const struct guestfs_xattr_list *xattrs);
typedef int (*visitor_function) (const char *dir, const char *name, const struct guestfs_stat *stat, const struct guestfs_xattr_list *xattrs);
@@ -520,8 +456,8 @@ visit (int depth, const char *dir, visitor_function f)
* case.
*/
if (depth == 0) {
struct guestfs_stat *stat;
struct guestfs_xattr_list *xattrs;
CLEANUP_FREE_STAT struct guestfs_stat *stat = NULL;
CLEANUP_FREE_XATTR_LIST struct guestfs_xattr_list *xattrs = NULL;
int r;
stat = guestfs_lstat (g, dir);
@@ -529,40 +465,35 @@ visit (int depth, const char *dir, visitor_function f)
return -1;
xattrs = guestfs_lgetxattrs (g, dir);
if (xattrs == NULL) {
guestfs_free_stat (stat);
if (xattrs == NULL)
return -1;
}
r = f (dir, NULL, stat, xattrs);
guestfs_free_stat (stat);
guestfs_free_xattr_list (xattrs);
if (r == -1)
return -1;
}
int ret = -1;
char **names = NULL;
char *path = NULL;
size_t i, xattrp;
struct guestfs_stat_list *stats = NULL;
struct guestfs_xattr_list *xattrs = NULL;
CLEANUP_FREE_STRING_LIST char **names = NULL;
CLEANUP_FREE_STAT_LIST struct guestfs_stat_list *stats = NULL;
CLEANUP_FREE_XATTR_LIST struct guestfs_xattr_list *xattrs = NULL;
names = guestfs_ls (g, dir);
if (names == NULL)
goto out;
return -1;
stats = lstatlist (dir, names);
stats = guestfs_lstatlist (g, dir, names);
if (stats == NULL)
goto out;
return -1;
xattrs = lxattrlist (dir, names);
xattrs = guestfs_lxattrlist (g, dir, names);
if (xattrs == NULL)
goto out;
return -1;
/* Call function on everything in this directory. */
for (i = 0, xattrp = 0; names[i] != NULL; ++i, ++xattrp) {
CLEANUP_FREE char *path = NULL;
struct guestfs_xattr_list file_xattrs;
size_t nr_xattrs;
@@ -575,13 +506,17 @@ visit (int depth, const char *dir, visitor_function f)
if (xattrs->val[xattrp].attrval_len == 0) {
fprintf (stderr, _("%s: error getting extended attrs for %s %s\n"),
program_name, dir, names[i]);
goto out;
return -1;
}
/* lxattrlist function made sure attrval was \0-terminated, so we can do */
if (sscanf (xattrs->val[xattrp].attrval, "%zu", &nr_xattrs) != 1) {
/* attrval is not \0-terminated. */
char attrval[xattrs->val[xattrp].attrval_len+1];
memcpy (attrval, xattrs->val[xattrp].attrval,
xattrs->val[xattrp].attrval_len);
attrval[xattrs->val[xattrp].attrval_len] = '\0';
if (sscanf (attrval, "%zu", &nr_xattrs) != 1) {
fprintf (stderr, _("%s: error: cannot parse xattr count for %s %s\n"),
program_name, dir, names[i]);
goto out;
return -1;
}
file_xattrs.len = nr_xattrs;
@@ -590,28 +525,17 @@ visit (int depth, const char *dir, visitor_function f)
/* Call the function. */
if (f (dir, names[i], &stats->val[i], &file_xattrs) == -1)
goto out;
return -1;
/* Recursively call visit, but only on directories. */
if (is_dir (stats->val[i].mode)) {
path = full_path (dir, names[i]);
if (visit (depth + 1, path, f) == -1)
goto out;
free (path); path = NULL;
return -1;
}
}
ret = 0;
out:
free (path);
if (names)
free_strings (names);
if (stats)
guestfs_free_stat_list (stats);
if (xattrs)
guestfs_free_xattr_list (xattrs);
return ret;
return 0;
}
static char *
@@ -635,129 +559,6 @@ full_path (const char *dir, const char *name)
return path;
}
/* This calls guestfs_lstatlist, but it splits the names list up so that we
* don't overrun the libguestfs protocol limit.
*/
#define LSTATLIST_MAX 1000
static struct guestfs_stat_list *
lstatlist (const char *dir, char **names)
{
size_t len = count_strings (names);
char **first;
size_t old_len;
struct guestfs_stat_list *ret, *stats;
ret = malloc (sizeof *ret);
if (ret == NULL) {
perror ("malloc");
exit (EXIT_FAILURE);
}
ret->len = 0;
ret->val = NULL;
while (len > 0) {
first = take_strings (names, LSTATLIST_MAX, &names);
len = len <= LSTATLIST_MAX ? 0 : len - LSTATLIST_MAX;
stats = guestfs_lstatlist (g, dir, first);
/* Note we don't need to free up the strings because take_strings
* does not do a deep copy.
*/
free (first);
if (stats == NULL) {
free (ret);
return NULL;
}
/* Append stats to ret. */
old_len = ret->len;
ret->len += stats->len;
ret->val = realloc (ret->val, ret->len * sizeof (struct guestfs_stat));
if (ret->val == NULL) {
perror ("realloc");
exit (EXIT_FAILURE);
}
memcpy (&ret->val[old_len], stats->val,
stats->len * sizeof (struct guestfs_stat));
guestfs_free_stat_list (stats);
}
return ret;
}
/* Same as above, for lxattrlist. Note the rather peculiar format
* used to return the list of extended attributes (see
* guestfs_lxattrlist documentation).
*/
#define LXATTRLIST_MAX 1000
static struct guestfs_xattr_list *
lxattrlist (const char *dir, char **names)
{
size_t len = count_strings (names);
char **first;
size_t i, old_len;
struct guestfs_xattr_list *ret, *xattrs;
ret = malloc (sizeof *ret);
if (ret == NULL) {
perror ("malloc");
exit (EXIT_FAILURE);
}
ret->len = 0;
ret->val = NULL;
while (len > 0) {
first = take_strings (names, LXATTRLIST_MAX, &names);
len = len <= LXATTRLIST_MAX ? 0 : len - LXATTRLIST_MAX;
xattrs = guestfs_lxattrlist (g, dir, first);
/* Note we don't need to free up the strings because take_strings
* does not do a deep copy.
*/
free (first);
if (xattrs == NULL) {
free (ret);
return NULL;
}
/* Append xattrs to ret. */
old_len = ret->len;
ret->len += xattrs->len;
ret->val = realloc (ret->val, ret->len * sizeof (struct guestfs_xattr));
if (ret->val == NULL) {
perror ("realloc");
exit (EXIT_FAILURE);
}
for (i = 0; i < xattrs->len; ++i, ++old_len) {
/* We have to make a deep copy of the attribute name and value.
* The attrval contains 8 bit data. However make sure also that
* it is \0-terminated, because that makes the calling code
* simpler.
*/
ret->val[old_len].attrname = strdup (xattrs->val[i].attrname);
ret->val[old_len].attrval = malloc (xattrs->val[i].attrval_len + 1);
if (ret->val[old_len].attrname == NULL ||
ret->val[old_len].attrval == NULL) {
perror ("malloc");
exit (EXIT_FAILURE);
}
ret->val[old_len].attrval_len = xattrs->val[i].attrval_len;
memcpy (ret->val[old_len].attrval, xattrs->val[i].attrval,
xattrs->val[i].attrval_len);
ret->val[i].attrval[ret->val[i].attrval_len] = '\0';
}
guestfs_free_xattr_list (xattrs);
}
return ret;
}
static int
do_ls_lR (const char *dir)
{
@@ -777,7 +578,7 @@ show_file (const char *dir, const char *name,
const struct guestfs_xattr_list *xattrs)
{
char filetype[2];
char *path = NULL, *csum = NULL, *link = NULL;
CLEANUP_FREE char *path = NULL, *csum = NULL, *link = NULL;
/* Display the basic fields. */
output_start_line ();
@@ -829,6 +630,8 @@ show_file (const char *dir, const char *name,
output_xattrs (xattrs);
*/
path = full_path (dir, name);
if (checksum && is_reg (stat->mode)) {
csum = guestfs_checksum (g, checksum, path);
if (!csum)
@@ -837,7 +640,6 @@ show_file (const char *dir, const char *name,
output_string (csum);
}
path = full_path (dir, name);
output_string (path);
if (is_lnk (stat->mode))
@@ -848,10 +650,6 @@ show_file (const char *dir, const char *name,
output_end_line ();
free (path);
free (csum);
free (link);
return 0;
}
@@ -1131,50 +929,3 @@ is_sock (int64_t mode)
{
return (mode & 0170000) == 0140000;
}
/* String functions. */
static size_t
count_strings (char **names)
{
size_t ret = 0;
while (names[ret] != NULL)
ret++;
return ret;
}
static void
free_strings (char **names)
{
size_t i;
for (i = 0; names[i] != NULL; ++i)
free (names[i]);
free (names);
}
/* Take the first 'n' names, returning a newly allocated list. The
* strings themselves are not duplicated. If 'lastp' is not NULL,
* then it is updated with the pointer to the list of remaining names.
*/
static char **
take_strings (char **names, size_t n, char ***lastp)
{
size_t i;
char **ret = malloc ((n+1) * sizeof (char *));
if (ret == NULL) {
perror ("malloc");
exit (EXIT_FAILURE);
}
for (i = 0; names[i] != NULL && i < n; ++i)
ret[i] = names[i];
ret[i] = NULL;
if (lastp)
*lastp = &names[i];
return ret;
}

View File

@@ -510,18 +510,4 @@ Richard W.M. Jones L<http://people.redhat.com/~rjones/>
=head1 COPYRIGHT
Copyright (C) 2009-2012 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.
Copyright (C) 2009-2013 Red Hat Inc.

34
cfg.mk
View File

@@ -1,5 +1,5 @@
# Customize Makefile.maint. -*- makefile -*-
# Copyright (C) 2003-2009 Free Software Foundation, Inc.
# Copyright (C) 2003-2012 Free Software Foundation, 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
@@ -24,6 +24,17 @@ gnu_rel_host = $(gnu_ftp_host-$(RELEASE_TYPE))
url_dir_list = \
ftp://$(gnu_rel_host)/gnu/coreutils
# Exclude some filenames.
exclude_file_name_regexp--sc_bindtextdomain = ^(daemon|erlang|examples|tests)/
exclude_file_name_regexp--sc_error_message_period = ^php/
exclude_file_name_regexp--sc_prohibit_always-defined_macros = ^examples/
exclude_file_name_regexp--sc_prohibit_doubled_word = ^po/
exclude_file_name_regexp--sc_prohibit_magic_number_exit = ^(po|po-docs)/|\.pod$
exclude_file_name_regexp--sc_prohibit_strcmp = ^examples/
exclude_file_name_regexp--sc_prohibit_strcmp_and_strncmp = ^examples/
exclude_file_name_regexp--sc_prohibit_strncpy = ^src/launch-.*\.c$
exclude_file_name_regexp--sc_require_config_h = ^examples/|^tests/c-api/test-just-header\.c$
# Tests not to run as part of "make distcheck".
local-checks-to-skip = \
sc_po_check \
@@ -41,7 +52,8 @@ local-checks-to-skip = \
sc_error_message_uppercase \
sc_program_name \
$(disable_temporarily) \
sc_useless_cpp_parens
sc_useless_cpp_parens \
sc_cast_of_argument_to_free
disable_temporarily = \
sc_makefile_check \
@@ -82,14 +94,6 @@ sc_prohibit_ctype_h:
{ echo "$(ME): don't use ctype.h; instead, use c-ctype.h" \
1>&2; exit 1; } || :
# Ensure that no C source file uses TABs for indentation.
# Exclude some version-controlled symlinks.
sc_TAB_in_indentation:
@grep -lE '^ * ' /dev/null \
$$($(VC_LIST_EXCEPT)) && \
{ echo '$(ME): found TAB(s) used for indentation in C sources;'\
'use spaces' 1>&2; exit 1; } || :
ctype_re = isalnum|isalpha|isascii|isblank|iscntrl|isdigit|isgraph|islower\
|isprint|ispunct|isspace|isupper|isxdigit|tolower|toupper
@@ -111,16 +115,6 @@ sc_prohibit_gethostby:
halt='use getaddrinfo, not gethostby*' \
$(_sc_search_regexp)
# Disallow trailing blank lines.
sc_prohibit_trailing_blank_lines:
@$(VC_LIST_EXCEPT) \
| xargs perl -ln -0777 -e \
'-f $$ARGV or next; /\n\n+$$/ and print $$ARGV' > $@-t
@found=0; test -s $@-t && { found=1; cat $@-t 1>&2; \
echo '$(ME): found trailing blank line(s)' 1>&2; }; \
rm -f $@-t; \
test $$found = 0
# We don't use this feature of maint.mk.
prev_version_file = /dev/null

View File

@@ -1,398 +0,0 @@
#!/bin/bash -
# @configure_input@
# libguestfs virt-sysprep tool
# Copyright (C) 2011 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.
unset CDPATH
program="virt-sysprep"
version="@PACKAGE_VERSION@"
# Uncomment this to see every shell command that is executed.
#set -x
TEMP=`getopt \
-o a:c:d:vVx \
--long help,add:,connect:,domain:,enable:,format::,hostname:,list-operations,selinux-relabel,no-selinux-relabel,verbose,version \
-n $program -- "$@"`
if [ $? != 0 ]; then
echo "$program: problem parsing the command line arguments"
exit 1
fi
eval set -- "$TEMP"
# This array accumulates the arguments we pass through to guestmount.
declare -a params
i=0
verbose=
add_params=0
enable=
hostname_param=localhost.localdomain
selinux_relabel=auto
usage ()
{
echo "Usage:"
echo " $program [--options] -d domname"
echo " $program [--options] -a disk.img [-a disk.img ...]"
echo
echo "Read $program(1) man page for more information."
echo
echo "NOTE: $program modifies the guest or disk image *in place*."
exit $1
}
while true; do
case "$1" in
-a|--add)
params[i++]="-a"
params[i++]="$2"
((add_params++))
shift 2;;
-c|--connect)
params[i++]="-c"
params[i++]="$2"
shift 2;;
-d|--domain)
params[i++]="-d"
params[i++]="$2"
((add_params++))
shift 2;;
--enable)
if [ -n "$enable" ]; then
echo "error: --enable option can only be given once"
exit 1
fi
enable="$2"
shift 2;;
--format)
if [ -n "$2" ]; then
params[i++]="--format=$2"
else
params[i++]="--format"
fi
shift 2;;
--help)
usage 0;;
--hostname)
hostname_param="$2"
shift 2;;
--list-operations)
enable=list
shift;;
--selinux-relabel)
selinux_relabel=yes
shift;;
--no-selinux-relabel)
selinux_relabel=no
shift;;
-v|--verbose)
params[i++]="-v"
verbose=yes
shift;;
-V|--version)
echo "$program $version"
exit 0;;
-x)
# Can't pass the -x option directly to guestmount because
# that stops guestmount from forking, which means we can't
# coordinate with guestmount when it has finished
# initializing. So instead set just the underlying option
# in libguestfs by exporting LIBGUESTFS_TRACE.
# Unfortunately (a) this omits FUSE calls, but don't worry
# about that for now, and more importantly (b) trace
# messages disappear into never-never land after the fork.
export LIBGUESTFS_TRACE=1
shift;;
--)
shift
break;;
*)
echo "Internal error!"
exit 1;;
esac
done
# Different sysprep operations that can be enabled. Default is to
# enable all of these, although some of them are only done on certain
# guest types (see details below).
if [ -z "$enable" ]; then
cron_spool=yes
dhcp_client_state=yes
dhcp_server_state=yes
hostname=yes
logfiles=yes
mail_spool=yes
net_hwaddr=yes
random_seed=yes
rhn_systemid=yes
smolt_uuid=yes
ssh_hostkeys=yes
udev_persistent_net=yes
utmp=yes
yum_uuid=yes
elif [ "$enable" = "list" ]; then
echo "cron-spool"
echo "dhcp-client-state"
echo "dhcp-server-state"
echo "hostname"
echo "logfiles"
echo "mail-spool"
echo "net-hwaddr"
echo "random-seed"
echo "rhn-systemid"
echo "smolt-uuid"
echo "ssh-hostkeys"
echo "udev-persistent-net"
echo "utmp"
echo "yum-uuid"
exit 0
else
for opt in $(echo "$enable" | sed 's/,/ /g'); do
case "$opt" in
cron-spool) cron_spool=yes ;;
dhcp-client-state) dhcp_client_state=yes ;;
dhcp-server-state) dhcp_server_state=yes ;;
hostname) hostname=yes ;;
logfiles) logfiles=yes ;;
mail-spool) mail_spool=yes ;;
net-hwaddr) net_hwaddr=yes ;;
random-seed) random_seed=yes ;;
rhn-systemid) rhn_systemid=yes ;;
smolt-uuid) smolt_uuid=yes ;;
ssh-hostkeys) ssh_hostkeys=yes ;;
udev-persistent-net) udev_persistent_net=yes ;;
utmp) utmp=yes ;;
yum-uuid) yum_uuid=yes ;;
*)
echo "error: unknown --enable feature: $opt"
exit 1
esac
done
fi
# Make sure there were no extra parameters on the command line.
if [ $# -gt 0 ]; then
echo "error: $program: extra parameters on the command line"
echo
usage 1
fi
# Did the user specify at least one -a or -d option?
if [ $add_params -eq 0 ]; then
echo "error: $program: you need at least one -a or -d option"
echo
usage 1
fi
# end of command line parsing
#----------------------------------------------------------------------
set -e
if [ "$verbose" = "yes" ]; then
echo params: "${params[@]}"
fi
# Create a temporary directory for general purpose use during operations.
tmpdir="$(mktemp -d)"
cleanup ()
{
if [ -d $tmpdir/mnt ]; then
fusermount -u $tmpdir/mnt >/dev/null 2>&1 ||:
fi
rm -rf $tmpdir ||:
}
trap cleanup EXIT ERR
# Run virt-inspector and grab inspection information about this guest.
virt-inspector "${params[@]}" > $tmpdir/xml
virt-inspector --xpath \
"string(/operatingsystems/operatingsystem[position()=1]/name)" \
< $tmpdir/xml > $tmpdir/type
virt-inspector --xpath \
"string(/operatingsystems/operatingsystem[position()=1]/distro)" \
< $tmpdir/xml > $tmpdir/distro ||:
virt-inspector --xpath \
"string(/operatingsystems/operatingsystem[position()=1]/package_format)" \
< $tmpdir/xml > $tmpdir/package_format ||:
virt-inspector --xpath \
"string(/operatingsystems/operatingsystem[position()=1]/package_management)" \
< $tmpdir/xml > $tmpdir/package_management ||:
type="$(cat $tmpdir/type)"
distro="$(cat $tmpdir/distro)"
package_format="$(cat $tmpdir/package_format)"
package_management="$(cat $tmpdir/package_management)"
# Mount the disk.
mkdir $tmpdir/mnt
guestmount --rw -i "${params[@]}" $tmpdir/mnt
mnt="$tmpdir/mnt"
#----------------------------------------------------------------------
# The sysprep operations.
if [ "$cron_spool" = "yes" ]; then
rm -rf $mnt/var/spool/cron/*
fi
if [ "$dhcp_client_state" = "yes" ]; then
case "$type" in
linux)
rm -rf $mnt/var/lib/dhclient/*
# RHEL 3:
rm -rf $mnt/var/lib/dhcp/*
;;
esac
fi
if [ "$dhcp_server_state" = "yes" ]; then
case "$type" in
linux)
rm -rf $mnt/var/lib/dhcpd/*
;;
esac
fi
if [ "$hostname" = "yes" ]; then
case "$type/$distro" in
linux/fedora)
echo "HOSTNAME=$hostname_param" > $mnt/etc/sysconfig/network.new
sed '/^HOSTNAME=/d' < $mnt/etc/sysconfig/network >> $mnt/etc/sysconfig/network.new
mv -f $mnt/etc/sysconfig/network.new $mnt/etc/sysconfig/network
created_files=yes
;;
linux/debian|linux/ubuntu)
echo "$hostname_param" > $mnt/etc/hostname
created_files=yes
;;
esac
fi
if [ "$logfiles" = "yes" ]; then
case "$type" in
linux)
rm -rf $mnt/var/log/*.log*
rm -rf $mnt/var/log/audit/*
rm -rf $mnt/var/log/btmp*
rm -rf $mnt/var/log/cron*
rm -rf $mnt/var/log/dmesg*
rm -rf $mnt/var/log/lastlog*
rm -rf $mnt/var/log/maillog*
rm -rf $mnt/var/log/mail/*
rm -rf $mnt/var/log/messages*
rm -rf $mnt/var/log/secure*
rm -rf $mnt/var/log/spooler*
rm -rf $mnt/var/log/tallylog*
rm -rf $mnt/var/log/wtmp*
;;
esac
fi
if [ "$mail_spool" = "yes" ]; then
rm -rf $mnt/var/spool/mail/*
rm -rf $mnt/var/mail/*
fi
if [ "$net_hwaddr" = "yes" ]; then
case "$type/$distro" in
linux/fedora)
if [ -d $mnt/etc/sysconfig/network-scripts ]; then
rm_hwaddr ()
{
sed '/^HWADDR=/d' < "$1" > "$1.new"
mv -f "$1.new" "$1"
}
export -f rm_hwaddr
find $mnt/etc/sysconfig/network-scripts \
-name 'ifcfg-*' -type f \
-exec bash -c 'rm_hwaddr "$0"' {} \;
created_files=yes
fi
;;
esac
fi
if [ "$random_seed" = "yes" -a "$type" = "linux" ]; then
f=
if [ -f $mnt/var/lib/random-seed ]; then
# Fedora
f=$mnt/var/lib/random-seed
elif [ -f $mnt/var/lib/urandom/random-seed ]; then
# Debian
f=$mnt/var/lib/urandom/random-seed
fi
if [ -n "$f" ]; then
dd if=/dev/urandom of="$f" bs=8 count=1 conv=nocreat,notrunc 2>/dev/null
fi
fi
if [ "$rhn_systemid" = "yes" -a "$type/$distro" = "linux/rhel" ]; then
rm -f $mnt/etc/sysconfig/rhn/systemid
fi
if [ "$smolt_uuid" = "yes" -a "$type" = "linux" ]; then
rm -f $mnt/etc/sysconfig/hw-uuid
rm -f $mnt/etc/smolt/uuid
rm -f $mnt/etc/smolt/hw-uuid
fi
if [ "$ssh_hostkeys" = "yes" -a "$type" != "windows" ]; then
rm -rf $mnt/etc/ssh/*_host_*
fi
if [ "$udev_persistent_net" = "yes" -a "$type" = "linux" ]; then
rm -f $mnt/etc/udev/rules.d/70-persistent-net.rules
fi
if [ "$utmp" = "yes" -a "$type" != "windows" ]; then
rm -f $mnt/var/run/utmp
fi
if [ "$yum_uuid" = "yes" -a "$package_management" = "yum" ]; then
rm -f $mnt/var/lib/yum/uuid
fi
#----------------------------------------------------------------------
# Clean up and close down.
# If we created any new files and the guest uses SELinux, then we have
# to relabel the filesystem on boot. Could do with a better way to
# test "guest uses SELinux" (XXX).
case "$selinux_relabel/$created_files" in
yes/*)
touch $mnt/.autorelabel;;
auto/yes)
case "$type/$distro" in
linux/fedora|linux/rhel|linux/centos|linux/scientificlinux|linux/redhat-based)
touch $mnt/.autorelabel
;;
esac
;;
esac
sync
fusermount -u $tmpdir/mnt
rm -rf $tmpdir
trap - EXIT ERR
exit 0

File diff suppressed because it is too large Load Diff

View File

@@ -22,6 +22,11 @@ make-check-on-installed.pl
we release them. Note that a checked out copy of the source
from git is required. Read the top of the file before using.
windows-icons.pl
This script lets you extract all the icons from a Windows
guest. We use this to locate the Windows logo in new releases
of Windows (see src/inspect-icon.c).
visualize-alignment/
Tests for visualizing block device reads and writes and
alignment using a patched qemu. See the README file in that

View File

@@ -1,6 +1,6 @@
#!/bin/bash -
# libguestfs autobuild script
# Copyright (C) 2009-2012 Red Hat Inc.
# Copyright (C) 2009-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

View File

@@ -119,6 +119,7 @@ char *
return get_blkid_tag (device, "TYPE");
}
GUESTFSD_EXT_CMD(str_blkid, blkid);
static char *
get_blkid_tag (const char *device, const char *tag)
{
@@ -126,7 +127,7 @@ get_blkid_tag (const char *device, const char *tag)
int r;
r = commandr (&amp;out, &amp;err,
"blkid",
str_blkid,
"-c", "/dev/null",
"-o", "value", "-s", tag, device, NULL);
if (r != 0 &amp;&amp; r != 2) {
@@ -182,9 +183,9 @@ get_blkid_tag (const char *device, const char *tag)
<tr><td valign="top" style="padding-bottom: 1.5em;" colspan="2">
<pre>
<b>guestfish -N bootrootlv:/dev/VG/LV:ext4:ext4:10G:256M &lt;&lt;EOF</b>
<font style="color: green;">mount-options "" /dev/VG/LV /
<font style="color: green;">mount /dev/VG/LV /
mkdir /boot
mount-options "" /dev/sda1 /boot
mount /dev/sda1 /boot
txz-in filesystem.tar.xz /
write /etc/HOSTNAME "test01.example.com\n"
upload /etc/resolv.conf /etc/resolv.conf</font>

View File

@@ -159,4 +159,3 @@ screenshots shown. But many people will simply want to mount
a filesystem on the host using guestmount, and then use
ordinary tools. At the bottom is a screenshot of GNOME
Nautilus browsing into a guest filesystem.

View File

@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
# libguestfs
# Copyright (C) 2009-2012 Red Hat Inc.
# Copyright (C) 2009-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
@@ -80,7 +80,7 @@ my %mapping = (
'/bin/virt-rescue$' => "rescue",
'/bin/virt-resize$' => "resize",
'/bin/virt-sparsify$' => "sparsify",
'/bin/virt-sysprep$' => "clone",
'/bin/virt-sysprep$' => "sysprep",
'/bin/virt-tar$' => "tools",
'/bin/virt-tar-in$' => "fish",
'/bin/virt-tar-out$' => "fish",

View File

@@ -1,7 +1,7 @@
#!/usr/bin/ocamlrun /usr/bin/ocaml
(* Convert *.qtr (qemu block device trace) to Postscript.
* Copyright (C) 2009-2012 Red Hat Inc.
* Copyright (C) 2009-2013 Red Hat Inc.
* By Richard W.M. Jones <rjones@redhat.com>.
*
* This program is free software; you can redistribute it and/or modify

120
contrib/windows-icons.pl Executable file
View File

@@ -0,0 +1,120 @@
#!/usr/bin/perl -w
# libguestfs
# Copyright (C) 2012 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.
# This script lets you extract all the icons from a Windows guest. We
# use this to locate the Windows logo in new releases of Windows (see
# src/inspect-icon.c).
#
# Use it like this:
# ./run ./contrib/windows-icons.pl /path/to/windows-disk.img
use strict;
use Sys::Guestfs;
use File::Temp qw{tempdir};
# Check that the tools we need are installed.
system ("wrestool --help >/dev/null 2>&1") == 0 or
die "'wrestool' program is not installed\n";
#system ("icotool --help >/dev/null 2>&1") == 0 or
# die "'icotool' program is not installed\n";
# Check user provided disk image argument(s).
if (@ARGV == 0) {
print STDERR "usage: $0 /path/to/windows-disk.img\n";
exit 1
}
# Assume libguestfs >= 1.19.32, because that means we don't
# have to worry about protocol limits in various calls.
my $g = Sys::Guestfs->new;
my %version = $g->version ();
unless ($version{minor} >= 20 ||
$version{minor} >= 19 && $version{release} >= 32) {
die "$0: version of libguestfs is too old, use >= 1.19.32\n"
}
# Open the disk image(s).
$g->add_drive ($_, readonly => 1) foreach @ARGV;
$g->launch ();
# Check it's Windows.
my @roots = $g->inspect_os ();
if (@roots == 0) {
die "$0: no operating system found in disk image\n"
}
my $root = $roots[0];
if ($g->inspect_get_type ($root) ne "windows") {
die "$0: disk image is not Windows (type = ", $g->inspect_get_type ($root),
")\n"
}
# Mount it up.
my %mps = $g->inspect_get_mountpoints ($root);
my @mps = sort { length $a <=> length $b } (keys %mps);
for my $mp (@mps) {
eval { $g->mount_ro ($mps{$mp}, $mp) };
if ($@) {
print "$@ (ignored)\n"
}
}
# Create an output directory.
my $output = tempdir (CLEANUP => 0);
print "writing icons to $output\n";
chdir $output or die "chdir: $output: $!";
# Get a list of all files.
my @files = $g->find ("/");
@files = map { "/$_" } @files;
print "writing list of files to $output/files\n";
open FILES, ">files" or die "open: files: $!";
print FILES join("\n", @files) or die "write: files: $!";
close FILES or die "close: files: $!";
# Find all *.exe files. (XXX Can other file types contain resources?)
my @exe_files = grep { $_ =~ /\.exe$/i && $g->is_file ($_) } @files;
foreach (@exe_files) {
# Download each *.exe file.
my $basename = $_;
$basename =~ s{.*/}{};
$g->download ($_, $basename);
# Extract any icon (2) or group-icon (14) resources it may contain.
system ("wrestool", "-x", "--type=2", "-o", "./", $basename);
system ("wrestool", "-x", "--type=14", "-o", "./", $basename);
unlink $basename;
}
# Find and download all other image files.
foreach (@files) {
my $basename = $_;
$basename =~ s{.*/}{};
if ($g->is_file ($_) &&
$basename =~ /\.(png|git|jpeg|jpg|bmp|ico)$/i) {
$g->download ($_, $basename);
}
}
$g->close;

View File

@@ -33,6 +33,7 @@
#include "actions.h"
#define BUS_PATH "/sys/bus/virtio/drivers/9pnet_virtio"
GUESTFSD_EXT_CMD(str_mount, mount);
static char *read_whole_file (const char *filename);
@@ -40,26 +41,26 @@ static char *read_whole_file (const char *filename);
char **
do_list_9p (void)
{
char **r = NULL;
int size = 0, alloc = 0;
DECLARE_STRINGSBUF (r);
DIR *dir;
int err = 0;
dir = opendir (BUS_PATH);
if (!dir) {
perror ("opendir: " BUS_PATH);
if (errno != ENOENT)
if (errno != ENOENT) {
reply_with_perror ("opendir: " BUS_PATH);
return NULL;
}
/* If this directory doesn't exist, it probably means that
* the virtio driver isn't loaded. Don't return an error
* in this case, but return an empty list.
*/
if (add_string (&r, &size, &alloc, NULL) == -1)
if (end_stringsbuf (&r) == -1)
return NULL;
return r;
return r.argv;
}
while (1) {
@@ -76,24 +77,21 @@ do_list_9p (void)
* the mount tag length to be unlimited (or up to 65536 bytes).
* See: linux/include/linux/virtio_9p.h
*/
char *mount_tag = read_whole_file (mount_tag_path);
CLEANUP_FREE char *mount_tag = read_whole_file (mount_tag_path);
if (mount_tag == 0)
continue;
if (add_string (&r, &size, &alloc, mount_tag) == -1) {
free (mount_tag);
if (add_string (&r, mount_tag) == -1) {
closedir (dir);
return NULL;
}
free (mount_tag);
}
}
/* Check readdir didn't fail */
if (errno != 0) {
reply_with_perror ("readdir: /sys/block");
free_stringslen (r, size);
free_stringslen (r.argv, r.size);
closedir (dir);
return NULL;
}
@@ -101,19 +99,19 @@ do_list_9p (void)
/* Close the directory handle */
if (closedir (dir) == -1) {
reply_with_perror ("closedir: /sys/block");
free_stringslen (r, size);
free_stringslen (r.argv, r.size);
return NULL;
}
/* Sort the tags. Note that r might be NULL if there are no tags. */
if (r != NULL)
sort_strings (r, size);
/* Sort the tags. */
if (r.size > 0)
sort_strings (r.argv, r.size);
/* NULL terminate the list */
if (add_string (&r, &size, &alloc, NULL) == -1)
if (end_stringsbuf (&r) == -1)
return NULL;
return r;
return r.argv;
}
/* Read whole file into dynamically allocated array. If there is an
@@ -127,7 +125,7 @@ read_whole_file (const char *filename)
size_t alloc = 0, size = 0;
int fd;
fd = open (filename, O_RDONLY);
fd = open (filename, O_RDONLY|O_CLOEXEC);
if (fd == -1) {
perror (filename);
return NULL;
@@ -139,6 +137,7 @@ read_whole_file (const char *filename)
if (r2 == NULL) {
perror ("realloc");
free (r);
close (fd);
return NULL;
}
r = r2;
@@ -148,8 +147,9 @@ read_whole_file (const char *filename)
*/
ssize_t n = read (fd, r + size, alloc - size - 1);
if (n == -1) {
perror (filename);
fprintf (stderr, "read: %s: %m\n", filename);
free (r);
close (fd);
return NULL;
}
if (n == 0)
@@ -158,7 +158,7 @@ read_whole_file (const char *filename)
}
if (close (fd) == -1) {
perror (filename);
fprintf (stderr, "close: %s: %m\n", filename);
free (r);
return NULL;
}
@@ -172,26 +172,26 @@ read_whole_file (const char *filename)
int
do_mount_9p (const char *mount_tag, const char *mountpoint, const char *options)
{
char *mp = NULL, *opts = NULL, *err = NULL;
CLEANUP_FREE char *mp = NULL, *opts = NULL, *err = NULL;
struct stat statbuf;
int r = -1;
int r;
ABS_PATH (mountpoint, , return -1);
mp = sysroot_path (mountpoint);
if (!mp) {
reply_with_perror ("malloc");
goto out;
return -1;
}
/* Check the mountpoint exists and is a directory. */
if (stat (mp, &statbuf) == -1) {
reply_with_perror ("%s", mountpoint);
goto out;
return -1;
}
if (!S_ISDIR (statbuf.st_mode)) {
reply_with_perror ("%s: mount point is not a directory", mountpoint);
goto out;
return -1;
}
/* Add trans=virtio to the options. */
@@ -199,28 +199,23 @@ do_mount_9p (const char *mount_tag, const char *mountpoint, const char *options)
STRNEQ (options, "")) {
if (asprintf (&opts, "trans=virtio,%s", options) == -1) {
reply_with_perror ("asprintf");
goto out;
return -1;
}
}
else {
opts = strdup ("trans=virtio");
if (opts == NULL) {
reply_with_perror ("strdup");
goto out;
return -1;
}
}
r = command (NULL, &err,
"mount", "-o", opts, "-t", "9p", mount_tag, mp, NULL);
str_mount, "-o", opts, "-t", "9p", mount_tag, mp, NULL);
if (r == -1) {
reply_with_error ("%s on %s: %s", mount_tag, mountpoint, err);
goto out;
return -1;
}
r = 0;
out:
free (err);
free (opts);
free (mp);
return r;
return 0;
}

View File

@@ -17,6 +17,8 @@
include $(top_srcdir)/subdir-rules.mk
CLEANFILES = stamp-guestfsd.pod
libsrcdir = $(top_builddir)/src
generator_built = \
@@ -28,12 +30,25 @@ BUILT_SOURCES = \
$(generator_built) \
guestfs_protocol.c \
guestfs_protocol.h \
errnostring_gperf.c \
errnostring_gperf.gperf \
errnostring-gperf.c \
errnostring-gperf.gperf \
errnostring.c \
errnostring.h
EXTRA_DIST = $(BUILT_SOURCES)
EXTRA_DIST = \
$(BUILT_SOURCES) \
guestfsd.pod
shared_with_library = \
guestfs_protocol.c \
guestfs_protocol.h \
errnostring-gperf.gperf \
errnostring.c \
errnostring.h
$(shared_with_library): %: $(libsrcdir)/%
rm -f $@
ln $< $@
noinst_LIBRARIES = libprotocol.a
@@ -42,12 +57,6 @@ noinst_LIBRARIES = libprotocol.a
libprotocol_a_SOURCES = guestfs_protocol.c guestfs_protocol.h
libprotocol_a_CFLAGS = -Wall -Wno-unused -fno-strict-aliasing
guestfs_protocol.c: $(libsrcdir)/guestfs_protocol.c
rm -f $@
ln $< $@
guestfs_protocol.h: $(libsrcdir)/guestfs_protocol.h
rm -f $@
ln $< $@
$(libsrcdir)/guestfs_protocol.c: force
$(MAKE) -C $(libsrcdir) guestfs_protocol.c
$(libsrcdir)/guestfs_protocol.h: force
@@ -57,24 +66,15 @@ $(libsrcdir)/guestfs_protocol.h: force
# of warnings so we must compile it in a separate mini-library.
noinst_LIBRARIES += liberrnostring.a
liberrnostring_a_SOURCES = \
errnostring_gperf.c \
errnostring-gperf.c \
errnostring.h \
errnostring.c
liberrnostring_a_CFLAGS =
errnostring_gperf.c: errnostring_gperf.gperf
errnostring-gperf.c: errnostring-gperf.gperf
rm -f $@
$(GPERF) -t $< > $@-t
mv $@-t $@
errnostring_gperf.gperf: $(libsrcdir)/errnostring_gperf.gperf
rm -f $@
ln $< $@
errnostring.c: $(libsrcdir)/errnostring.c
rm -f $@
ln $< $@
errnostring.h: $(libsrcdir)/errnostring.h
rm -f $@
ln $< $@
if INSTALL_DAEMON
sbin_PROGRAMS = guestfsd
@@ -84,6 +84,7 @@ endif
guestfsd_SOURCES = \
9p.c \
acl.c \
actions.h \
available.c \
augeas.c \
@@ -91,6 +92,7 @@ guestfsd_SOURCES = \
blkid.c \
blockdev.c \
btrfs.c \
cap.c \
checksum.c \
cmp.c \
command.c \
@@ -106,7 +108,7 @@ guestfsd_SOURCES = \
dmesg.c \
dropcaches.c \
du.c \
echo_daemon.c \
echo-daemon.c \
ext2.c \
fallocate.c \
file.c \
@@ -114,17 +116,23 @@ guestfsd_SOURCES = \
fill.c \
find.c \
fsck.c \
fstrim.c \
glob.c \
grep.c \
grub.c \
guestfsd.c \
headtail.c \
hexdump.c \
hotplug.c \
hivex.c \
htonl.c \
initrd.c \
inotify.c \
internal.c \
is.c \
isoinfo.c \
labels.c \
ldm.c \
link.c \
ls.c \
luks.c \
@@ -133,10 +141,12 @@ guestfsd_SOURCES = \
md.c \
mkfs.c \
mknod.c \
mktemp.c \
modprobe.c \
mount.c \
names.c \
ntfs.c \
ntfsclone.c \
optgroups.c \
optgroups.h \
parted.c \
@@ -144,6 +154,8 @@ guestfsd_SOURCES = \
proto.c \
readdir.c \
realpath.c \
rename.c \
rsync.c \
scrub.c \
selinux.c \
sfdisk.c \
@@ -159,15 +171,22 @@ guestfsd_SOURCES = \
umask.c \
upload.c \
utimens.c \
utsname.c \
wc.c \
xattr.c \
xfs.c \
zero.c \
zerofree.c
guestfsd_LDADD = \
liberrnostring.a \
libprotocol.a \
$(ACL_LIBS) \
$(CAP_LIBS) \
$(YAJL_LIBS) \
$(SELINUX_LIB) \
$(AUGEAS_LIBS) \
$(HIVEX_LIBS) \
$(top_builddir)/gnulib/lib/.libs/libgnu.a \
$(GETADDRINFO_LIB) \
$(HOSTENT_LIB) \
@@ -175,9 +194,33 @@ guestfsd_LDADD = \
$(LIBSOCKET) \
$(LIB_CLOCK_GETTIME) \
$(LIBINTL) \
$(SERVENT_LIB)
$(SERVENT_LIB) \
$(PCRE_LIBS)
guestfsd_CPPFLAGS = -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib
guestfsd_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS) $(AUGEAS_CFLAGS)
guestfsd_CPPFLAGS = \
-I$(top_srcdir)/gnulib/lib \
-I$(top_builddir)/gnulib/lib \
-I$(top_builddir)/src
guestfsd_CFLAGS = \
$(WARN_CFLAGS) $(WERROR_CFLAGS) \
$(AUGEAS_CFLAGS) \
$(HIVEX_CFLAGS) \
$(YAJL_CFLAGS) \
$(PCRE_CFLAGS)
# Manual pages and HTML files for the website.
man_MANS = guestfsd.8
noinst_DATA = $(top_builddir)/html/guestfsd.8.html
guestfsd.8 $(top_builddir)/html/guestfsd.8.html: stamp-guestfsd.pod
stamp-guestfsd.pod: guestfsd.pod
$(PODWRAPPER) \
--section 8 \
--man guestfsd.8 \
--html $(top_builddir)/html/guestfsd.8.html \
--license GPLv2+ \
$<
touch $@
.PHONY: force

149
daemon/acl.c Normal file
View File

@@ -0,0 +1,149 @@
/* libguestfs - the guestfsd daemon
* Copyright (C) 2012 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 <limits.h>
#include <unistd.h>
#include "guestfs_protocol.h"
#include "daemon.h"
#include "actions.h"
#include "optgroups.h"
#if defined(HAVE_ACL)
#include <sys/types.h>
#include <sys/acl.h>
int
optgroup_acl_available (void)
{
return 1;
}
char *
do_acl_get_file (const char *path, const char *acltype)
{
acl_type_t t;
acl_t acl;
char *r, *ret;
if (STREQ (acltype, "access"))
t = ACL_TYPE_ACCESS;
else if (STREQ (acltype, "default"))
t = ACL_TYPE_DEFAULT;
else {
reply_with_error ("invalid acltype parameter: %s", acltype);
return NULL;
}
CHROOT_IN;
acl = acl_get_file (path, t);
CHROOT_OUT;
if (acl == NULL) {
reply_with_perror ("%s", path);
return NULL;
}
r = acl_to_text (acl, NULL);
if (r == NULL) {
reply_with_perror ("acl_to_text");
acl_free (acl);
return NULL;
}
acl_free (acl);
/* 'r' is not an ordinary pointer that can be freed with free(3)!
* In the current implementation of libacl, if you try to do that it
* will segfault. We have to duplicate this into an ordinary
* buffer, then call acl_free (r).
*/
ret = strdup (r);
if (ret == NULL) {
reply_with_perror ("strdup");
acl_free (r);
return NULL;
}
acl_free (r);
return ret; /* caller frees */
}
int
do_acl_set_file (const char *path, const char *acltype, const char *aclstr)
{
acl_type_t t;
acl_t acl;
int r;
if (STREQ (acltype, "access"))
t = ACL_TYPE_ACCESS;
else if (STREQ (acltype, "default"))
t = ACL_TYPE_DEFAULT;
else {
reply_with_error ("invalid acltype parameter: %s", acltype);
return -1;
}
acl = acl_from_text (aclstr);
if (acl == NULL) {
reply_with_perror ("could not parse acl string: %s: acl_from_text", aclstr);
return -1;
}
CHROOT_IN;
r = acl_set_file (path, t, acl);
CHROOT_OUT;
if (r == -1) {
reply_with_perror ("%s", path);
acl_free (acl);
return -1;
}
acl_free (acl);
return 0;
}
int
do_acl_delete_def_file (const char *dir)
{
int r;
CHROOT_IN;
r = acl_delete_def_file (dir);
CHROOT_OUT;
if (r == -1) {
reply_with_perror ("%s", dir);
return -1;
}
return 0;
}
#else /* no acl library */
OPTGROUP_ACL_NOT_AVAILABLE
#endif /* no acl library */

View File

@@ -63,20 +63,12 @@ optgroup_augeas_available (void)
{
return 1;
}
#else /* !HAVE_AUGEAS */
int
optgroup_augeas_available (void)
{
return 0;
}
#endif
/* We need to rewrite the root path so it is based at /sysroot. */
int
do_aug_init (const char *root, int flags)
{
#ifdef HAVE_AUGEAS
char *buf;
CLEANUP_FREE char *buf = NULL;
if (aug) {
aug_close (aug);
@@ -90,7 +82,6 @@ do_aug_init (const char *root, int flags)
}
aug = aug_init (buf, NULL, flags);
free (buf);
if (!aug) {
reply_with_error ("Augeas initialization failed");
@@ -98,24 +89,17 @@ do_aug_init (const char *root, int flags)
}
return 0;
#else
NOT_AVAILABLE (-1);
#endif
}
int
do_aug_close (void)
{
#ifdef HAVE_AUGEAS
NEED_AUG(-1);
aug_close (aug);
aug = NULL;
return 0;
#else
NOT_AVAILABLE (-1);
#endif
}
int
@@ -133,7 +117,8 @@ do_aug_defvar (const char *name, const char *expr)
}
return r;
#else
NOT_AVAILABLE (-1);
reply_with_error ("function not available");
return -1;
#endif
}
@@ -141,27 +126,36 @@ guestfs_int_int_bool *
do_aug_defnode (const char *name, const char *expr, const char *val)
{
#ifdef HAVE_AUG_DEFNODE
static guestfs_int_int_bool r;
int created;
guestfs_int_int_bool *r;
int i, created;
NEED_AUG (NULL);
r.i = aug_defnode (aug, name, expr, val, &created);
if (r.i == -1) {
i = aug_defnode (aug, name, expr, val, &created);
if (i == -1) {
reply_with_error ("Augeas defnode failed");
return NULL;
}
r.b = created;
return &r;
r = malloc (sizeof *r);
if (r == NULL) {
reply_with_perror ("malloc");
return NULL;
}
r->i = i;
r->b = created;
return r;
#else
NOT_AVAILABLE (NULL);
reply_with_error ("function not available");
return NULL;
#endif
}
char *
do_aug_get (const char *path)
{
#ifdef HAVE_AUGEAS
const char *value = NULL;
char *v;
int r;
@@ -195,15 +189,11 @@ do_aug_get (const char *path)
}
return v; /* Caller frees. */
#else
NOT_AVAILABLE (NULL);
#endif
}
int
do_aug_set (const char *path, const char *val)
{
#ifdef HAVE_AUGEAS
int r;
NEED_AUG (-1);
@@ -215,15 +205,11 @@ do_aug_set (const char *path, const char *val)
}
return 0;
#else
NOT_AVAILABLE (-1);
#endif
}
int
do_aug_clear (const char *path)
{
#ifdef HAVE_AUGEAS
int r;
NEED_AUG (-1);
@@ -235,15 +221,11 @@ do_aug_clear (const char *path)
}
return 0;
#else
NOT_AVAILABLE (-1);
#endif
}
int
do_aug_insert (const char *path, const char *label, int before)
{
#ifdef HAVE_AUGEAS
int r;
NEED_AUG (-1);
@@ -255,15 +237,11 @@ do_aug_insert (const char *path, const char *label, int before)
}
return 0;
#else
NOT_AVAILABLE (-1);
#endif
}
int
do_aug_rm (const char *path)
{
#ifdef HAVE_AUGEAS
int r;
NEED_AUG (-1);
@@ -275,15 +253,11 @@ do_aug_rm (const char *path)
}
return r;
#else
NOT_AVAILABLE (-1);
#endif
}
int
do_aug_mv (const char *src, const char *dest)
{
#ifdef HAVE_AUGEAS
int r;
NEED_AUG (-1);
@@ -295,15 +269,11 @@ do_aug_mv (const char *src, const char *dest)
}
return 0;
#else
NOT_AVAILABLE (-1);
#endif
}
char **
do_aug_match (const char *path)
{
#ifdef HAVE_AUGEAS
char **matches = NULL;
void *vp;
int r;
@@ -329,15 +299,11 @@ do_aug_match (const char *path)
matches[r] = NULL;
return matches; /* Caller frees. */
#else
NOT_AVAILABLE (NULL);
#endif
}
int
do_aug_save (void)
{
#ifdef HAVE_AUGEAS
NEED_AUG (-1);
if (aug_save (aug) == -1) {
@@ -346,9 +312,6 @@ do_aug_save (void)
}
return 0;
#else
NOT_AVAILABLE (-1);
#endif
}
int
@@ -364,7 +327,8 @@ do_aug_load (void)
return 0;
#else
NOT_AVAILABLE (-1);
reply_with_error ("function not available");
return -1;
#endif
}
@@ -372,10 +336,8 @@ do_aug_load (void)
char **
do_aug_ls (const char *path)
{
#ifdef HAVE_AUGEAS
char **matches;
char *buf;
int len;
size_t len;
NEED_AUG (NULL);
@@ -394,6 +356,8 @@ do_aug_ls (const char *path)
if (STREQ (path, "/"))
matches = do_aug_match ("/*");
else {
CLEANUP_FREE char *buf;
len += 3; /* / * + terminating \0 */
buf = malloc (len);
if (buf == NULL) {
@@ -403,7 +367,6 @@ do_aug_ls (const char *path)
snprintf (buf, len, "%s/*", path);
matches = do_aug_match (buf);
free (buf);
}
if (matches == NULL)
@@ -411,7 +374,10 @@ do_aug_ls (const char *path)
sort_strings (matches, count_strings ((void *) matches));
return matches; /* Caller frees. */
#else
NOT_AVAILABLE (NULL);
#endif
}
#else /* !HAVE_AUGEAS */
OPTGROUP_AUGEAS_NOT_AVAILABLE
#endif

View File

@@ -22,9 +22,16 @@
#include <stdlib.h>
#include <string.h>
#include "c-ctype.h"
#include "ignore-value.h"
#include "guestfs_protocol.h"
#include "daemon.h"
#include "actions.h"
#include "optgroups.h"
GUESTFSD_EXT_CMD(str_grep, grep);
GUESTFSD_EXT_CMD(str_modprobe, modprobe);
int
do_available (char *const *groups)
@@ -58,16 +65,89 @@ char **
do_available_all_groups (void)
{
size_t i;
char **groups = NULL;
int size = 0, alloc = 0;
DECLARE_STRINGSBUF (groups);
for (i = 0; optgroups[i].group != NULL; ++i) {
if (add_string (&groups, &size, &alloc, optgroups[i].group) == -1)
if (add_string (&groups, optgroups[i].group) == -1)
return NULL;
}
if (add_string (&groups, &size, &alloc, NULL) == -1)
if (end_stringsbuf (&groups) == -1)
return NULL;
return groups; /* caller frees */
return groups.argv; /* caller frees */
}
/* Search for filesystem in /proc/filesystems, ignoring "nodev". */
static int
test_proc_filesystems (const char *filesystem)
{
size_t len = strlen (filesystem) + 32;
char regex[len];
CLEANUP_FREE char *err = NULL;
int r;
snprintf (regex, len, "^[[:space:]]*%s$", filesystem);
r = commandr (NULL, &err, str_grep, regex, "/proc/filesystems", NULL);
if (r == -1 || r >= 2) {
fprintf (stderr, "grep /proc/filesystems: %s", err);
return -1;
}
return r == 0;
}
/* Do modprobe, ignore any errors. */
static void
modprobe (const char *module)
{
ignore_value (command (NULL, NULL, str_modprobe, module, NULL));
}
/* Internal function for testing if a filesystem is available. Note
* this must not call reply_with_error functions.
*/
int
filesystem_available (const char *filesystem)
{
int r;
r = test_proc_filesystems (filesystem);
if (r == -1 || r > 0)
return r;
/* Not found: try to modprobe the module, then test again. */
if (optgroup_linuxmodules_available ()) {
modprobe (filesystem);
r = test_proc_filesystems (filesystem);
if (r == -1)
return -1;
}
return r;
}
int
do_filesystem_available (const char *filesystem)
{
size_t i, len = strlen (filesystem);
int r;
for (i = 0; i < len; ++i) {
if (!c_isalnum (filesystem[i]) && filesystem[i] != '_') {
reply_with_error ("filesystem name contains non-alphanumeric characters");
return -1;
}
}
r = filesystem_available (filesystem);
if (r == -1) {
reply_with_error ("error testing for filesystem availability; "
"enable verbose mode and look at preceeding output");
return -1;
}
return r;
}

View File

@@ -22,11 +22,16 @@
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "guestfs_protocol.h"
#include "daemon.h"
#include "actions.h"
GUESTFSD_EXT_CMD(str_base64, base64);
static int
write_cb (void *fd_ptr, const void *buf, size_t len)
{
@@ -40,9 +45,9 @@ do_base64_in (const char *file)
{
int err, r;
FILE *fp;
char *cmd;
CLEANUP_FREE char *cmd = NULL;
if (asprintf_nowarn (&cmd, "base64 -d -i > %R", file) == -1) {
if (asprintf_nowarn (&cmd, "%s -d -i > %R", str_base64, file) == -1) {
err = errno;
cancel_receive ();
errno = err;
@@ -59,10 +64,8 @@ do_base64_in (const char *file)
cancel_receive ();
errno = err;
reply_with_perror ("%s", cmd);
free (cmd);
return -1;
}
free (cmd);
/* The semantics of fwrite are too undefined, so write to the
* file descriptor directly instead.
@@ -97,12 +100,32 @@ do_base64_in (const char *file)
int
do_base64_out (const char *file)
{
CLEANUP_FREE char *buf = NULL;
struct stat statbuf;
int r;
FILE *fp;
char *cmd;
char buf[GUESTFS_MAX_CHUNK_SIZE];
CLEANUP_FREE char *cmd = NULL;
char buffer[GUESTFS_MAX_CHUNK_SIZE];
if (asprintf_nowarn (&cmd, "base64 %R", file) == -1) {
/* Check the filename exists and is not a directory (RHBZ#908322). */
buf = sysroot_path (file);
if (buf == NULL) {
reply_with_perror ("malloc");
return -1;
}
if (stat (buf, &statbuf) == -1) {
reply_with_perror ("stat: %s", file);
return -1;
}
if (S_ISDIR (statbuf.st_mode)) {
reply_with_error ("%s: is a directory", file);
return -1;
}
/* Construct the command. */
if (asprintf_nowarn (&cmd, "%s %s", str_base64, buf) == -1) {
reply_with_perror ("asprintf");
return -1;
}
@@ -113,10 +136,8 @@ do_base64_out (const char *file)
fp = popen (cmd, "r");
if (fp == NULL) {
reply_with_perror ("%s", cmd);
free (cmd);
return -1;
}
free (cmd);
/* Now we must send the reply message, before the file contents. After
* this there is no opportunity in the protocol to send any error
@@ -124,22 +145,22 @@ do_base64_out (const char *file)
*/
reply (NULL, NULL);
while ((r = fread (buf, 1, sizeof buf, fp)) > 0) {
if (send_file_write (buf, r) < 0) {
while ((r = fread (buffer, 1, sizeof buffer, fp)) > 0) {
if (send_file_write (buffer, r) < 0) {
pclose (fp);
return -1;
}
}
if (ferror (fp)) {
perror (file);
fprintf (stderr, "fread: %s: %m\n", file);
send_file_end (1); /* Cancel. */
pclose (fp);
return -1;
}
if (pclose (fp) != 0) {
perror (file);
fprintf (stderr, "pclose: %s: %m\n", file);
send_file_end (1); /* Cancel. */
return -1;
}

View File

@@ -27,14 +27,17 @@
#include "daemon.h"
#include "actions.h"
GUESTFSD_EXT_CMD(str_blkid, blkid);
static char *
get_blkid_tag (const char *device, const char *tag)
{
char *out, *err;
char *out;
CLEANUP_FREE char *err = NULL;
int r;
r = commandr (&out, &err,
"blkid",
str_blkid,
/* Adding -c option kills all caching, even on RHEL 5. */
"-c", "/dev/null",
"-o", "value", "-s", tag, device, NULL);
@@ -44,12 +47,9 @@ get_blkid_tag (const char *device, const char *tag)
else
reply_with_error ("%s: %s", device, err);
free (out);
free (err);
return NULL;
}
free (err);
if (r == 2) { /* means UUID etc not found */
free (out);
out = strdup ("");
@@ -67,21 +67,21 @@ get_blkid_tag (const char *device, const char *tag)
}
char *
do_vfs_type (const char *device)
do_vfs_type (const mountable_t *mountable)
{
return get_blkid_tag (device, "TYPE");
return get_blkid_tag (mountable->device, "TYPE");
}
char *
do_vfs_label (const char *device)
do_vfs_label (const mountable_t *mountable)
{
return get_blkid_tag (device, "LABEL");
return get_blkid_tag (mountable->device, "LABEL");
}
char *
do_vfs_uuid (const char *device)
do_vfs_uuid (const mountable_t *mountable)
{
return get_blkid_tag (device, "UUID");
return get_blkid_tag (mountable->device, "UUID");
}
/* RHEL5 blkid doesn't have the -p (low-level probing) option and the
@@ -94,33 +94,27 @@ static int
test_blkid_p_i_opt (void)
{
int r;
int result;
char *err;
CLEANUP_FREE char *err = NULL, *err2 = NULL;
r = commandr (NULL, &err, "blkid", "-p", "/dev/null", NULL);
r = commandr (NULL, &err, str_blkid, "-p", "/dev/null", NULL);
if (r == -1) {
/* This means we couldn't run the blkid command at all. */
command_failed:
reply_with_error ("could not run 'blkid' command: %s", err);
free (err);
return -1;
}
if (strstr (err, "invalid option --")) {
free (err);
return 0;
}
free (err);
r = commandr (NULL, &err, "blkid", "-i", NULL);
r = commandr (NULL, &err2, str_blkid, "-i", NULL);
if (r == -1)
goto command_failed;
if (strstr (err, "invalid option --")) {
free (err);
if (strstr (err2, "invalid option --")) {
return 0;
}
free (err);
/* We have both options. */
return 1;
@@ -131,12 +125,11 @@ blkid_with_p_i_opt (const char *device)
{
size_t i;
int r;
char *out = NULL, *err = NULL;
char **lines = NULL;
char **ret = NULL;
int size = 0, alloc = 0;
CLEANUP_FREE char *out = NULL, *err = NULL;
CLEANUP_FREE_STRING_LIST char **lines = NULL;
DECLARE_STRINGSBUF (ret);
r = command (&out, &err, "blkid", "-c", "/dev/null",
r = command (&out, &err, str_blkid, "-c", "/dev/null",
"-p", "-i", "-o", "export", device, NULL);
if (r == -1) {
reply_with_error ("%s", err);
@@ -145,10 +138,8 @@ blkid_with_p_i_opt (const char *device)
/* Split the command output into lines */
lines = split_lines (out);
if (lines == NULL) {
reply_with_perror ("malloc");
if (lines == NULL)
goto error;
}
/* Parse the output of blkid -p -i -o export:
* UUID=b6d83437-c6b4-4bf0-8381-ef3fc3578590
@@ -177,28 +168,20 @@ blkid_with_p_i_opt (const char *device)
*eq = '\0'; eq++;
/* Add the key/value pair to the output */
if (add_string (&ret, &size, &alloc, line) == -1 ||
add_string (&ret, &size, &alloc, eq) == -1) goto error;
if (add_string (&ret, line) == -1 ||
add_string (&ret, eq) == -1) goto error;
} else {
fprintf (stderr, "blkid: unexpected blkid output ignored: %s", line);
}
}
if (add_string (&ret, &size, &alloc, NULL) == -1) goto error;
if (end_stringsbuf (&ret) == -1) goto error;
free (out);
free (err);
free_strings (lines);
return ret;
return ret.argv;
error:
free (out);
free (err);
if (lines)
free_strings (lines);
if (ret)
free_strings (ret);
if (ret.argv)
free_strings (ret.argv);
return NULL;
}
@@ -207,33 +190,32 @@ static char **
blkid_without_p_i_opt(const char *device)
{
char *s;
char **ret = NULL;
int size = 0, alloc = 0;
DECLARE_STRINGSBUF (ret);
if (add_string (&ret, &size, &alloc, "TYPE") == -1) goto error;
if (add_string (&ret, "TYPE") == -1) goto error;
s = get_blkid_tag (device, "TYPE");
if (s == NULL) goto error;
if (add_string (&ret, &size, &alloc, s) == -1)
if (add_string (&ret, s) == -1)
goto error;
if (add_string (&ret, &size, &alloc, "LABEL") == -1) goto error;
if (add_string (&ret, "LABEL") == -1) goto error;
s = get_blkid_tag (device, "LABEL");
if (s == NULL) goto error;
if (add_string (&ret, &size, &alloc, s) == -1)
if (add_string (&ret, s) == -1)
goto error;
if (add_string (&ret, &size, &alloc, "UUID") == -1) goto error;
if (add_string (&ret, "UUID") == -1) goto error;
s = get_blkid_tag (device, "UUID");
if (s == NULL) goto error;
if (add_string (&ret, &size, &alloc, s) == -1)
if (add_string (&ret, s) == -1)
goto error;
if (add_string (&ret, &size, &alloc, NULL) == -1) goto error;
if (end_stringsbuf (&ret) == -1) goto error;
return ret;
return ret.argv;
error:
if (ret)
free_strings (ret);
if (ret.argv)
free_strings (ret.argv);
return NULL;
}
@@ -241,12 +223,6 @@ char **
do_blkid (const char *device)
{
static int blkid_has_p_i_opt = -1;
int r;
char *out = NULL, *err = NULL;
char **lines = NULL;
char **ret = NULL;
int size = 0, alloc = 0;
if (blkid_has_p_i_opt == -1) {
blkid_has_p_i_opt = test_blkid_p_i_opt ();

View File

@@ -28,6 +28,8 @@
#include "daemon.h"
#include "actions.h"
GUESTFSD_EXT_CMD(str_blockdev, blockdev);
/* These functions are all about using the blockdev command, so
* we centralize it in one call.
*/
@@ -36,9 +38,9 @@ call_blockdev (const char *device, const char *switc, int extraarg, int prints)
{
int r;
int64_t rv;
char *out, *err;
CLEANUP_FREE char *out = NULL, *err = NULL;
const char *argv[] = {
"blockdev",
str_blockdev,
switc,
NULL,
NULL,
@@ -46,6 +48,20 @@ call_blockdev (const char *device, const char *switc, int extraarg, int prints)
};
char buf[64];
/* When you call close on any block device, udev kicks off a rule
* which runs blkid to reexamine the device. We need to wait for
* this rule to finish running (from a previous operation) since it
* holds the device open and can cause other operations to fail,
* notably BLKRRPART.
*
* This is particularly a problem where we have just written to a
* device (eg. zeroing it) and immediately call blockdev --rereadpt.
*
* Therefore, wait for udev to finish all outstanding events before
* performing any blockdev command.
*/
udev_settle ();
if (extraarg > 0) {
snprintf (buf, sizeof buf, "%d", extraarg);
argv[2] = buf;
@@ -57,8 +73,6 @@ call_blockdev (const char *device, const char *switc, int extraarg, int prints)
if (r == -1) {
reply_with_error ("%s: %s", argv[0], err);
free (err);
free (out);
return -1;
}
@@ -67,15 +81,10 @@ call_blockdev (const char *device, const char *switc, int extraarg, int prints)
if (prints) {
if (sscanf (out, "%" SCNi64, &rv) != 1) {
reply_with_error ("%s: expected output, but got nothing", argv[0]);
free (out);
free (err);
return -1;
}
}
free (out);
free (err);
return rv;
}

View File

@@ -1,5 +1,5 @@
/* libguestfs - the guestfsd daemon
* Copyright (C) 2011 Red Hat Inc.
* Copyright (C) 2011-2012 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
@@ -21,33 +21,38 @@
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <pcre.h>
#include <string.h>
#include <unistd.h>
#include "daemon.h"
#include "actions.h"
#include "optgroups.h"
#include "xstrtol.h"
#define MAX_ARGS 64
GUESTFSD_EXT_CMD(str_btrfs, btrfs);
GUESTFSD_EXT_CMD(str_btrfstune, btrfstune);
GUESTFSD_EXT_CMD(str_btrfsck, btrfsck);
GUESTFSD_EXT_CMD(str_mkfs_btrfs, mkfs.btrfs);
int
optgroup_btrfs_available (void)
{
return prog_exists ("btrfs");
return prog_exists (str_btrfs) && filesystem_available ("btrfs") > 0;
}
/* Takes optional arguments, consult optargs_bitmask. */
int
do_btrfs_filesystem_resize (const char *filesystem, int64_t size)
{
char *buf;
char *err;
const size_t MAX_ARGS = 64;
CLEANUP_FREE char *buf = NULL, *err = NULL;
int r;
const char *argv[MAX_ARGS];
size_t i = 0;
char size_str[32];
ADD_ARG (argv, i, "btrfs");
ADD_ARG (argv, i, str_btrfs);
ADD_ARG (argv, i, "filesystem");
ADD_ARG (argv, i, "resize");
@@ -73,14 +78,602 @@ do_btrfs_filesystem_resize (const char *filesystem, int64_t size)
ADD_ARG (argv, i, NULL);
r = commandv (NULL, &err, argv);
free (buf);
if (r == -1) {
reply_with_error ("%s: %s", filesystem, err);
free (err);
return -1;
}
free (err);
return 0;
}
/* Takes optional arguments, consult optargs_bitmask. */
int
do_mkfs_btrfs (char *const *devices,
int64_t allocstart, int64_t bytecount, const char *datatype,
int leafsize, const char *label, const char *metadata,
int nodesize, int sectorsize)
{
size_t nr_devices = count_strings (devices);
if (nr_devices == 0) {
reply_with_error ("list of devices must be non-empty");
return -1;
}
size_t MAX_ARGS = nr_devices + 64;
const char *argv[MAX_ARGS];
size_t i = 0, j;
int r;
CLEANUP_FREE char *err = NULL;
char allocstart_s[64];
char bytecount_s[64];
char leafsize_s[64];
char nodesize_s[64];
char sectorsize_s[64];
ADD_ARG (argv, i, str_mkfs_btrfs);
/* Optional arguments. */
if (optargs_bitmask & GUESTFS_MKFS_BTRFS_ALLOCSTART_BITMASK) {
if (allocstart < 0) {
reply_with_error ("allocstart must be >= 0");
return -1;
}
snprintf (allocstart_s, sizeof allocstart_s, "%" PRIi64, allocstart);
ADD_ARG (argv, i, "--alloc-start");
ADD_ARG (argv, i, allocstart_s);
}
if (optargs_bitmask & GUESTFS_MKFS_BTRFS_BYTECOUNT_BITMASK) {
if (bytecount <= 0) { /* actually the minimum is 256MB */
reply_with_error ("bytecount must be > 0");
return -1;
}
snprintf (bytecount_s, sizeof bytecount_s, "%" PRIi64, bytecount);
ADD_ARG (argv, i, "--byte-count");
ADD_ARG (argv, i, bytecount_s);
}
if (optargs_bitmask & GUESTFS_MKFS_BTRFS_DATATYPE_BITMASK) {
if (STRNEQ (datatype, "raid0") && STRNEQ (datatype, "raid1") &&
STRNEQ (datatype, "raid10") && STRNEQ (datatype, "single")) {
reply_with_error ("datatype not one of the allowed values");
return -1;
}
ADD_ARG (argv, i, "--data");
ADD_ARG (argv, i, datatype);
}
if (optargs_bitmask & GUESTFS_MKFS_BTRFS_LEAFSIZE_BITMASK) {
if (!is_power_of_2 (leafsize) || leafsize <= 0) {
reply_with_error ("leafsize must be > 0 and a power of two");
return -1;
}
snprintf (leafsize_s, sizeof leafsize_s, "%d", leafsize);
ADD_ARG (argv, i, "--leafsize");
ADD_ARG (argv, i, leafsize_s);
}
if (optargs_bitmask & GUESTFS_MKFS_BTRFS_LABEL_BITMASK) {
ADD_ARG (argv, i, "--label");
ADD_ARG (argv, i, label);
}
if (optargs_bitmask & GUESTFS_MKFS_BTRFS_METADATA_BITMASK) {
if (STRNEQ (metadata, "raid0") && STRNEQ (metadata, "raid1") &&
STRNEQ (metadata, "raid10") && STRNEQ (metadata, "single")) {
reply_with_error ("metadata not one of the allowed values");
return -1;
}
ADD_ARG (argv, i, "--metadata");
ADD_ARG (argv, i, metadata);
}
if (optargs_bitmask & GUESTFS_MKFS_BTRFS_NODESIZE_BITMASK) {
if (!is_power_of_2 (nodesize) || nodesize <= 0) {
reply_with_error ("nodesize must be > 0 and a power of two");
return -1;
}
snprintf (nodesize_s, sizeof nodesize_s, "%d", nodesize);
ADD_ARG (argv, i, "--nodesize");
ADD_ARG (argv, i, nodesize_s);
}
if (optargs_bitmask & GUESTFS_MKFS_BTRFS_SECTORSIZE_BITMASK) {
if (!is_power_of_2 (sectorsize) || sectorsize <= 0) {
reply_with_error ("sectorsize must be > 0 and a power of two");
return -1;
}
snprintf (sectorsize_s, sizeof sectorsize_s, "%d", sectorsize);
ADD_ARG (argv, i, "--sectorsize");
ADD_ARG (argv, i, sectorsize_s);
}
for (j = 0; j < nr_devices; ++j)
ADD_ARG (argv, i, devices[j]);
ADD_ARG (argv, i, NULL);
for (j = 0; j < nr_devices; ++j)
wipe_device_before_mkfs (devices[j]);
r = commandv (NULL, &err, argv);
if (r == -1) {
reply_with_error ("%s: %s", devices[0], err);
return -1;
}
return 0;
}
int
do_btrfs_subvolume_snapshot (const char *source, const char *dest)
{
const size_t MAX_ARGS = 64;
const char *argv[MAX_ARGS];
size_t i = 0;
CLEANUP_FREE char *source_buf = NULL, *dest_buf = NULL;
CLEANUP_FREE char *err = NULL;
int r;
source_buf = sysroot_path (source);
if (source_buf == NULL) {
reply_with_perror ("malloc");
return -1;
}
dest_buf = sysroot_path (dest);
if (dest_buf == NULL) {
reply_with_perror ("malloc");
return -1;
}
ADD_ARG (argv, i, str_btrfs);
ADD_ARG (argv, i, "subvolume");
ADD_ARG (argv, i, "snapshot");
ADD_ARG (argv, i, source_buf);
ADD_ARG (argv, i, dest_buf);
ADD_ARG (argv, i, NULL);
r = commandv (NULL, &err, argv);
if (r == -1) {
reply_with_error ("%s: %s: %s", source, dest, err);
return -1;
}
return 0;
}
int
do_btrfs_subvolume_delete (const char *subvolume)
{
const size_t MAX_ARGS = 64;
const char *argv[MAX_ARGS];
size_t i = 0;
CLEANUP_FREE char *subvolume_buf = NULL;
CLEANUP_FREE char *err = NULL;
int r;
subvolume_buf = sysroot_path (subvolume);
if (subvolume_buf == NULL) {
reply_with_perror ("malloc");
return -1;
}
ADD_ARG (argv, i, str_btrfs);
ADD_ARG (argv, i, "subvolume");
ADD_ARG (argv, i, "delete");
ADD_ARG (argv, i, subvolume_buf);
ADD_ARG (argv, i, NULL);
r = commandv (NULL, &err, argv);
if (r == -1) {
reply_with_error ("%s: %s", subvolume, err);
return -1;
}
return 0;
}
int
do_btrfs_subvolume_create (const char *dest)
{
const size_t MAX_ARGS = 64;
const char *argv[MAX_ARGS];
size_t i = 0;
CLEANUP_FREE char *dest_buf = NULL;
CLEANUP_FREE char *err = NULL;
int r;
dest_buf = sysroot_path (dest);
if (dest_buf == NULL) {
reply_with_perror ("malloc");
return -1;
}
ADD_ARG (argv, i, str_btrfs);
ADD_ARG (argv, i, "subvolume");
ADD_ARG (argv, i, "create");
ADD_ARG (argv, i, dest_buf);
ADD_ARG (argv, i, NULL);
r = commandv (NULL, &err, argv);
if (r == -1) {
reply_with_error ("%s: %s", dest, err);
return -1;
}
return 0;
}
guestfs_int_btrfssubvolume_list *
do_btrfs_subvolume_list (const char *fs)
{
char **lines;
/* Execute 'btrfs subvolume list <fs>', and split the output into lines */
{
CLEANUP_FREE char *fs_buf = sysroot_path (fs);
if (fs_buf == NULL) {
reply_with_perror ("malloc");
return NULL;
}
size_t i = 0;
const size_t MAX_ARGS = 64;
const char *argv[MAX_ARGS];
ADD_ARG (argv, i, str_btrfs);
ADD_ARG (argv, i, "subvolume");
ADD_ARG (argv, i, "list");
ADD_ARG (argv, i, fs_buf);
ADD_ARG (argv, i, NULL);
CLEANUP_FREE char *out = NULL, *err = NULL;
int r = commandv (&out, &err, argv);
if (r == -1) {
reply_with_error ("%s: %s", fs, err);
return NULL;
}
lines = split_lines (out);
if (!lines)
return NULL;
}
/* Output is:
*
* ID 256 gen 30 top level 5 path test1
* ID 257 gen 30 top level 5 path dir/test2
* ID 258 gen 30 top level 5 path test3
*
* "ID <n>" is the subvolume ID.
* "gen <n>" is the generation when the root was created or last
* updated.
* "top level <n>" is the top level subvolume ID.
* "path <str>" is the subvolume path, relative to the top of the
* filesystem.
*
* Note that the order that each of the above is fixed, but
* different versions of btrfs may display different sets of data.
* Specifically, older versions of btrfs do not display gen.
*/
guestfs_int_btrfssubvolume_list *ret = NULL;
pcre *re = NULL;
size_t nr_subvolumes = count_strings (lines);
ret = malloc (sizeof *ret);
if (!ret) {
reply_with_perror ("malloc");
goto error;
}
ret->guestfs_int_btrfssubvolume_list_len = nr_subvolumes;
ret->guestfs_int_btrfssubvolume_list_val =
calloc (nr_subvolumes, sizeof (struct guestfs_int_btrfssubvolume));
if (ret->guestfs_int_btrfssubvolume_list_val == NULL) {
reply_with_perror ("malloc");
goto error;
}
const char *errptr;
int erroffset;
re = pcre_compile ("ID\\s+(\\d+).*\\s"
"top level\\s+(\\d+).*\\s"
"path\\s(.*)",
0, &errptr, &erroffset, NULL);
if (re == NULL) {
reply_with_error ("pcre_compile (%i): %s", erroffset, errptr);
goto error;
}
for (size_t i = 0; i < nr_subvolumes; ++i) {
/* To avoid allocations, reuse the 'line' buffer to store the
* path. Thus we don't need to free 'line', since it will be
* freed by the calling (XDR) code.
*/
char *line = lines[i];
#define N_MATCHES 4
int ovector[N_MATCHES * 3];
if (pcre_exec (re, NULL, line, strlen (line), 0, 0,
ovector, N_MATCHES * 3) < 0)
#undef N_MATCHES
{
unexpected_output:
reply_with_error ("unexpected output from 'btrfs subvolume list' command: %s", line);
goto error;
}
struct guestfs_int_btrfssubvolume *this =
&ret->guestfs_int_btrfssubvolume_list_val[i];
#if __WORDSIZE == 64
#define XSTRTOU64 xstrtoul
#else
#define XSTRTOU64 xstrtoull
#endif
if (XSTRTOU64 (line + ovector[2], NULL, 10,
&this->btrfssubvolume_id, NULL) != LONGINT_OK)
goto unexpected_output;
if (XSTRTOU64 (line + ovector[4], NULL, 10,
&this->btrfssubvolume_top_level_id, NULL) != LONGINT_OK)
goto unexpected_output;
#undef XSTRTOU64
memmove (line, line + ovector[6], ovector[7] + 1);
this->btrfssubvolume_path = line;
}
free (lines);
pcre_free (re);
return ret;
error:
free_stringslen (lines, nr_subvolumes);
if (ret) free (ret->guestfs_int_btrfssubvolume_list_val);
free (ret);
if (re) pcre_free (re);
return NULL;
}
int
do_btrfs_subvolume_set_default (int64_t id, const char *fs)
{
const size_t MAX_ARGS = 64;
const char *argv[MAX_ARGS];
size_t i = 0;
CLEANUP_FREE char *fs_buf = NULL;
char buf[64];
CLEANUP_FREE char *err = NULL;
int r;
snprintf (buf, sizeof buf, "%" PRIi64, id);
fs_buf = sysroot_path (fs);
if (fs_buf == NULL) {
reply_with_perror ("malloc");
return -1;
}
ADD_ARG (argv, i, str_btrfs);
ADD_ARG (argv, i, "subvolume");
ADD_ARG (argv, i, "set-default");
ADD_ARG (argv, i, buf);
ADD_ARG (argv, i, fs_buf);
ADD_ARG (argv, i, NULL);
r = commandv (NULL, &err, argv);
if (r == -1) {
reply_with_error ("%s: %s", fs, err);
return -1;
}
return 0;
}
int
do_btrfs_filesystem_sync (const char *fs)
{
const size_t MAX_ARGS = 64;
const char *argv[MAX_ARGS];
size_t i = 0;
CLEANUP_FREE char *fs_buf = NULL;
CLEANUP_FREE char *err = NULL;
int r;
fs_buf = sysroot_path (fs);
if (fs_buf == NULL) {
reply_with_perror ("malloc");
return -1;
}
ADD_ARG (argv, i, str_btrfs);
ADD_ARG (argv, i, "filesystem");
ADD_ARG (argv, i, "sync");
ADD_ARG (argv, i, fs_buf);
ADD_ARG (argv, i, NULL);
r = commandv (NULL, &err, argv);
if (r == -1) {
reply_with_error ("%s: %s", fs, err);
return -1;
}
return 0;
}
int
do_btrfs_filesystem_balance (const char *fs)
{
const size_t MAX_ARGS = 64;
const char *argv[MAX_ARGS];
size_t i = 0;
CLEANUP_FREE char *fs_buf = NULL;
CLEANUP_FREE char *err = NULL;
int r;
fs_buf = sysroot_path (fs);
if (fs_buf == NULL) {
reply_with_perror ("malloc");
return -1;
}
ADD_ARG (argv, i, str_btrfs);
ADD_ARG (argv, i, "filesystem");
ADD_ARG (argv, i, "balance");
ADD_ARG (argv, i, fs_buf);
ADD_ARG (argv, i, NULL);
r = commandv (NULL, &err, argv);
if (r == -1) {
reply_with_error ("%s: %s", fs, err);
return -1;
}
return 0;
}
int
do_btrfs_device_add (char *const *devices, const char *fs)
{
size_t nr_devices = count_strings (devices);
if (nr_devices == 0)
return 0;
size_t MAX_ARGS = nr_devices + 8;
const char *argv[MAX_ARGS];
size_t i = 0, j;
CLEANUP_FREE char *fs_buf = NULL;
CLEANUP_FREE char *err = NULL;
int r;
fs_buf = sysroot_path (fs);
if (fs_buf == NULL) {
reply_with_perror ("malloc");
return -1;
}
ADD_ARG (argv, i, str_btrfs);
ADD_ARG (argv, i, "device");
ADD_ARG (argv, i, "add");
for (j = 0; j < nr_devices; ++j)
ADD_ARG (argv, i, devices[j]);
ADD_ARG (argv, i, fs_buf);
ADD_ARG (argv, i, NULL);
r = commandv (NULL, &err, argv);
if (r == -1) {
reply_with_error ("%s: %s", fs, err);
return -1;
}
return 0;
}
int
do_btrfs_device_delete (char *const *devices, const char *fs)
{
size_t nr_devices = count_strings (devices);
if (nr_devices == 0)
return 0;
size_t MAX_ARGS = nr_devices + 8;
const char *argv[MAX_ARGS];
size_t i = 0, j;
CLEANUP_FREE char *fs_buf = NULL;
CLEANUP_FREE char *err = NULL;
int r;
fs_buf = sysroot_path (fs);
if (fs_buf == NULL) {
reply_with_perror ("malloc");
return -1;
}
ADD_ARG (argv, i, str_btrfs);
ADD_ARG (argv, i, "device");
ADD_ARG (argv, i, "delete");
for (j = 0; j < nr_devices; ++j)
ADD_ARG (argv, i, devices[j]);
ADD_ARG (argv, i, fs_buf);
ADD_ARG (argv, i, NULL);
r = commandv (NULL, &err, argv);
if (r == -1) {
reply_with_error ("%s: %s", fs, err);
return -1;
}
return 0;
}
int
do_btrfs_set_seeding (const char *device, int svalue)
{
CLEANUP_FREE char *err = NULL;
int r;
const char *s_value = svalue ? "1" : "0";
r = commandr (NULL, &err, str_btrfstune, "-S", s_value, device, NULL);
if (r == -1) {
reply_with_error ("%s: %s", device, err);
return -1;
}
return 0;
}
/* Takes optional arguments, consult optargs_bitmask. */
int
do_btrfs_fsck (const char *device, int64_t superblock, int repair)
{
CLEANUP_FREE char *err = NULL;
int r;
size_t i = 0;
const size_t MAX_ARGS = 64;
const char *argv[MAX_ARGS];
char super_s[64];
ADD_ARG (argv, i, str_btrfsck);
/* Optional arguments. */
if (optargs_bitmask & GUESTFS_BTRFS_FSCK_SUPERBLOCK_BITMASK) {
if (superblock < 0) {
reply_with_error ("super block offset must be >= 0");
return -1;
}
snprintf (super_s, sizeof super_s, "%" PRIi64, superblock);
ADD_ARG (argv, i, "--super");
ADD_ARG (argv, i, super_s);
}
if (!(optargs_bitmask & GUESTFS_BTRFS_FSCK_REPAIR_BITMASK))
repair = 0;
if (repair)
ADD_ARG (argv, i, "--repair");
ADD_ARG (argv, i, device);
ADD_ARG (argv, i, NULL);
r = commandv (NULL, &err, argv);
if (r == -1) {
reply_with_error ("%s: %s", device, err);
return -1;
}
return 0;
}

111
daemon/cap.c Normal file
View File

@@ -0,0 +1,111 @@
/* libguestfs - the guestfsd daemon
* Copyright (C) 2012 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 <limits.h>
#include <unistd.h>
#include "guestfs_protocol.h"
#include "daemon.h"
#include "actions.h"
#include "optgroups.h"
#if defined(HAVE_CAP)
#include <sys/capability.h>
int
optgroup_linuxcaps_available (void)
{
return 1;
}
char *
do_cap_get_file (const char *path)
{
cap_t cap;
char *r, *ret;
CHROOT_IN;
cap = cap_get_file (path);
CHROOT_OUT;
if (cap == NULL) {
reply_with_perror ("%s", path);
return NULL;
}
r = cap_to_text (cap, NULL);
if (r == NULL) {
reply_with_perror ("cap_to_text");
cap_free (cap);
return NULL;
}
cap_free (cap);
/* 'r' is not an ordinary pointer that can be freed with free(3)!
* In the current implementation of libcap, if you try to do that it
* will segfault. We have to duplicate this into an ordinary
* buffer, then call cap_free (r).
*/
ret = strdup (r);
if (ret == NULL) {
reply_with_perror ("strdup");
cap_free (r);
return NULL;
}
cap_free (r);
return ret; /* caller frees */
}
int
do_cap_set_file (const char *path, const char *capstr)
{
cap_t cap;
int r;
cap = cap_from_text (capstr);
if (cap == NULL) {
reply_with_perror ("could not parse cap string: %s: cap_from_text", capstr);
return -1;
}
CHROOT_IN;
r = cap_set_file (path, cap);
CHROOT_OUT;
if (r == -1) {
reply_with_perror ("%s", path);
cap_free (cap);
return -1;
}
cap_free (cap);
return 0;
}
#else /* no libcap */
OPTGROUP_LINUXCAPS_NOT_AVAILABLE
#endif /* no libcap */

View File

@@ -1,5 +1,5 @@
/* libguestfs - the guestfsd daemon
* Copyright (C) 2009-2012 Red Hat Inc.
* Copyright (C) 2009-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
@@ -29,23 +29,33 @@
#include "daemon.h"
#include "actions.h"
GUESTFSD_EXT_CMD(str_find, find);
GUESTFSD_EXT_CMD(str_xargs, xargs);
GUESTFSD_EXT_CMD(str_cksum, cksum);
GUESTFSD_EXT_CMD(str_md5sum, md5sum);
GUESTFSD_EXT_CMD(str_sha1sum, sha1sum);
GUESTFSD_EXT_CMD(str_sha224sum, sha224sum);
GUESTFSD_EXT_CMD(str_sha256sum, sha256sum);
GUESTFSD_EXT_CMD(str_sha384sum, sha384sum);
GUESTFSD_EXT_CMD(str_sha512sum, sha512sum);
static const char *
program_of_csum (const char *csumtype)
{
if (STRCASEEQ (csumtype, "crc"))
return "cksum";
return str_cksum;
else if (STRCASEEQ (csumtype, "md5"))
return "md5sum";
return str_md5sum;
else if (STRCASEEQ (csumtype, "sha1"))
return "sha1sum";
return str_sha1sum;
else if (STRCASEEQ (csumtype, "sha224"))
return "sha224sum";
return str_sha224sum;
else if (STRCASEEQ (csumtype, "sha256"))
return "sha256sum";
return str_sha256sum;
else if (STRCASEEQ (csumtype, "sha384"))
return "sha384sum";
return str_sha384sum;
else if (STRCASEEQ (csumtype, "sha512"))
return "sha512sum";
return str_sha512sum;
else {
reply_with_error ("unknown checksum type, expecting crc|md5|sha1|sha224|sha256|sha384|sha512");
return NULL;
@@ -56,9 +66,10 @@ static char *
checksum (const char *csumtype, int fd)
{
const char *program;
char *out, *err;
char *out;
CLEANUP_FREE char *err = NULL;
int flags, r;
int len;
size_t len;
program = program_of_csum (csumtype);
if (program == NULL) {
@@ -74,12 +85,9 @@ checksum (const char *csumtype, int fd)
pulse_mode_cancel ();
reply_with_error ("%s: %s", program, err);
free (out);
free (err);
return NULL;
}
free (err);
/* Split it at the first whitespace. */
len = strcspn (out, " \t\n");
out[len] = '\0';
@@ -95,7 +103,7 @@ do_checksum (const char *csumtype, const char *path)
int fd;
CHROOT_IN;
fd = open (path, O_RDONLY);
fd = open (path, O_RDONLY|O_CLOEXEC);
CHROOT_OUT;
if (fd == -1) {
@@ -111,7 +119,7 @@ do_checksum_device (const char *csumtype, const char *device)
{
int fd;
fd = open (device, O_RDONLY);
fd = open (device, O_RDONLY|O_CLOEXEC);
if (fd == -1) {
reply_with_perror ("%s", device);
return NULL;
@@ -131,7 +139,7 @@ do_checksums_out (const char *csumtype, const char *dir)
if (program == NULL)
return -1;
char *sysrootdir = sysroot_path (dir);
CLEANUP_FREE char *sysrootdir = sysroot_path (dir);
if (!sysrootdir) {
reply_with_perror ("malloc");
return -1;
@@ -140,23 +148,19 @@ do_checksums_out (const char *csumtype, const char *dir)
r = stat (sysrootdir, &statbuf);
if (r == -1) {
reply_with_perror ("%s", dir);
free (sysrootdir);
return -1;
}
if (!S_ISDIR (statbuf.st_mode)) {
reply_with_error ("%s: not a directory", dir);
free (sysrootdir);
return -1;
}
char *cmd;
if (asprintf_nowarn (&cmd, "cd %Q && find -type f -print0 | xargs -0 %s",
sysrootdir, program) == -1) {
CLEANUP_FREE char *cmd = NULL;
if (asprintf_nowarn (&cmd, "cd %Q && %s -type f -print0 | %s -0 %s",
sysrootdir, str_find, str_xargs, program) == -1) {
reply_with_perror ("asprintf");
free (sysrootdir);
return -1;
}
free (sysrootdir);
if (verbose)
fprintf (stderr, "%s\n", cmd);
@@ -164,10 +168,8 @@ do_checksums_out (const char *csumtype, const char *dir)
FILE *fp = popen (cmd, "r");
if (fp == NULL) {
reply_with_perror ("%s", cmd);
free (cmd);
return -1;
}
free (cmd);
/* Now we must send the reply message, before the file contents. After
* this there is no opportunity in the protocol to send any error
@@ -185,14 +187,14 @@ do_checksums_out (const char *csumtype, const char *dir)
}
if (ferror (fp)) {
perror (dir);
fprintf (stderr, "fread: %s: %m\n", dir);
send_file_end (1); /* Cancel. */
pclose (fp);
return -1;
}
if (pclose (fp) != 0) {
perror (dir);
fprintf (stderr, "pclose: %s: %m\n", dir);
send_file_end (1); /* Cancel. */
return -1;
}

View File

@@ -27,11 +27,13 @@
#include "daemon.h"
#include "actions.h"
GUESTFSD_EXT_CMD(str_cmp, cmp);
int
do_equal (const char *file1, const char *file2)
{
char *file1buf, *file2buf;
char *err;
CLEANUP_FREE char *file1buf = NULL, *file2buf = NULL;
CLEANUP_FREE char *err = NULL;
int r;
file1buf = sysroot_path (file1);
@@ -43,22 +45,14 @@ do_equal (const char *file1, const char *file2)
file2buf = sysroot_path (file2);
if (file2buf == NULL) {
reply_with_perror ("malloc");
free (file1buf);
return -1;
}
r = commandr (NULL, &err, "cmp", "-s", file1buf, file2buf, NULL);
free (file1buf);
free (file2buf);
r = commandr (NULL, &err, str_cmp, "-s", file1buf, file2buf, NULL);
if (r == -1 || r > 1) {
reply_with_error ("%s", err);
free (err);
return -1;
}
free (err);
return r == 0;
}

View File

@@ -28,19 +28,23 @@
#include "ignore-value.h"
GUESTFSD_EXT_CMD(str_mount, mount);
GUESTFSD_EXT_CMD(str_umount, umount);
static inline void
umount_ignore_fail (const char *path)
{
ignore_value (command (NULL, NULL, "umount", path, NULL));
ignore_value (command (NULL, NULL, str_umount, path, NULL));
}
char *
do_command (char *const *argv)
{
char *out, *err;
char *out;
CLEANUP_FREE char *err;
int r;
char *sysroot_dev, *sysroot_dev_pts, *sysroot_proc,
*sysroot_selinux, *sysroot_sys;
CLEANUP_FREE char *sysroot_dev = NULL, *sysroot_dev_pts = NULL,
*sysroot_proc = NULL, *sysroot_selinux = NULL, *sysroot_sys = NULL;
int dev_ok, dev_pts_ok, proc_ok, selinux_ok, sys_ok;
/* We need a root filesystem mounted to do this. */
@@ -73,23 +77,18 @@ do_command (char *const *argv)
sysroot_proc == NULL || sysroot_selinux == NULL ||
sysroot_sys == NULL) {
reply_with_perror ("malloc");
free (sysroot_dev);
free (sysroot_dev_pts);
free (sysroot_proc);
free (sysroot_selinux);
free (sysroot_sys);
return NULL;
}
r = command (NULL, NULL, "mount", "--bind", "/dev", sysroot_dev, NULL);
r = command (NULL, NULL, str_mount, "--bind", "/dev", sysroot_dev, NULL);
dev_ok = r != -1;
r = command (NULL, NULL, "mount", "--bind", "/dev/pts", sysroot_dev_pts, NULL);
r = command (NULL, NULL, str_mount, "--bind", "/dev/pts", sysroot_dev_pts, NULL);
dev_pts_ok = r != -1;
r = command (NULL, NULL, "mount", "--bind", "/proc", sysroot_proc, NULL);
r = command (NULL, NULL, str_mount, "--bind", "/proc", sysroot_proc, NULL);
proc_ok = r != -1;
r = command (NULL, NULL, "mount", "--bind", "/selinux", sysroot_selinux, NULL);
r = command (NULL, NULL, str_mount, "--bind", "/selinux", sysroot_selinux, NULL);
selinux_ok = r != -1;
r = command (NULL, NULL, "mount", "--bind", "/sys", sysroot_sys, NULL);
r = command (NULL, NULL, str_mount, "--bind", "/sys", sysroot_sys, NULL);
sys_ok = r != -1;
CHROOT_IN;
@@ -102,28 +101,19 @@ do_command (char *const *argv)
if (dev_pts_ok) umount_ignore_fail (sysroot_dev_pts);
if (dev_ok) umount_ignore_fail (sysroot_dev);
free (sysroot_dev);
free (sysroot_dev_pts);
free (sysroot_proc);
free (sysroot_selinux);
free (sysroot_sys);
if (r == -1) {
reply_with_error ("%s", err);
free (out);
free (err);
return NULL;
}
free (err);
return out; /* Caller frees. */
}
char **
do_command_lines (char *const *argv)
{
char *out;
CLEANUP_FREE char *out = NULL;
char **lines;
out = do_command (argv);
@@ -131,7 +121,6 @@ do_command_lines (char *const *argv)
return NULL;
lines = split_lines (out);
free (out);
if (lines == NULL)
return NULL;

View File

@@ -27,13 +27,19 @@
#include "daemon.h"
#include "actions.h"
GUESTFSD_EXT_CMD(str_compress, compress);
GUESTFSD_EXT_CMD(str_gzip, gzip);
GUESTFSD_EXT_CMD(str_bzip2, bzip2);
GUESTFSD_EXT_CMD(str_xz, xz);
GUESTFSD_EXT_CMD(str_lzop, lzop);
/* Has one FileOut parameter. */
static int
do_compressX_out (const char *file, const char *filter, int is_device)
{
int r;
FILE *fp;
char *cmd;
CLEANUP_FREE char *cmd = NULL;
char buf[GUESTFS_MAX_CHUNK_SIZE];
/* The command will look something like:
@@ -65,10 +71,8 @@ do_compressX_out (const char *file, const char *filter, int is_device)
fp = popen (cmd, "r");
if (fp == NULL) {
reply_with_perror ("%s", cmd);
free (cmd);
return -1;
}
free (cmd);
/* Now we must send the reply message, before the file contents. After
* this there is no opportunity in the protocol to send any error
@@ -84,14 +88,14 @@ do_compressX_out (const char *file, const char *filter, int is_device)
}
if (ferror (fp)) {
perror (file);
fprintf (stderr, "fread: %s: %m\n", file);
send_file_end (1); /* Cancel. */
pclose (fp);
return -1;
}
if (pclose (fp) != 0) {
perror (file);
fprintf (stderr, "pclose: %s: %m\n", file);
send_file_end (1); /* Cancel. */
return -1;
}
@@ -103,11 +107,9 @@ do_compressX_out (const char *file, const char *filter, int is_device)
}
#define CHECK_SUPPORTED(prog) \
if (!prog_exists (prog)) { \
if (!prog_exists (prog)) \
/* note: substring "not supported" must appear in this error */ \
reply_with_error ("compression type %s is not supported", prog); \
return -1; \
}
NOT_SUPPORTED (-1, "compression type %s is not supported", prog);
static int
get_filter (const char *ctype, int level, char *ret, size_t n)
@@ -118,15 +120,15 @@ get_filter (const char *ctype, int level, char *ret, size_t n)
reply_with_error ("compress: cannot use optional level parameter with this compression type");
return -1;
}
snprintf (ret, n, "compress -c");
snprintf (ret, n, "%s -c", str_compress);
return 0;
}
else if (STREQ (ctype, "gzip")) {
CHECK_SUPPORTED ("gzip");
if (level == -1)
snprintf (ret, n, "gzip -c");
snprintf (ret, n, "%s -c", str_gzip);
else if (level >= 1 && level <= 9)
snprintf (ret, n, "gzip -c -%d", level);
snprintf (ret, n, "%s -c -%d", str_gzip, level);
else {
reply_with_error ("gzip: incorrect value for level parameter");
return -1;
@@ -136,9 +138,9 @@ get_filter (const char *ctype, int level, char *ret, size_t n)
else if (STREQ (ctype, "bzip2")) {
CHECK_SUPPORTED ("bzip2");
if (level == -1)
snprintf (ret, n, "bzip2 -c");
snprintf (ret, n, "%s -c", str_bzip2);
else if (level >= 1 && level <= 9)
snprintf (ret, n, "bzip2 -c -%d", level);
snprintf (ret, n, "%s -c -%d", str_bzip2, level);
else {
reply_with_error ("bzip2: incorrect value for level parameter");
return -1;
@@ -148,9 +150,9 @@ get_filter (const char *ctype, int level, char *ret, size_t n)
else if (STREQ (ctype, "xz")) {
CHECK_SUPPORTED ("xz");
if (level == -1)
snprintf (ret, n, "xz -c");
snprintf (ret, n, "%s -c", str_xz);
else if (level >= 0 && level <= 9)
snprintf (ret, n, "xz -c -%d", level);
snprintf (ret, n, "%s -c -%d", str_xz, level);
else {
reply_with_error ("xz: incorrect value for level parameter");
return -1;
@@ -160,9 +162,9 @@ get_filter (const char *ctype, int level, char *ret, size_t n)
else if (STREQ (ctype, "lzop")) {
CHECK_SUPPORTED ("lzop");
if (level == -1)
snprintf (ret, n, "lzop -c");
snprintf (ret, n, "%s -c", str_lzop);
else if (level >= 1 && level <= 9)
snprintf (ret, n, "lzop -c -%d", level);
snprintf (ret, n, "%s -c -%d", str_lzop, level);
else {
reply_with_error ("lzop: incorrect value for level parameter");
return -1;

View File

@@ -29,8 +29,8 @@
#include "daemon.h"
#include "actions.h"
#define DEST_FILE_FLAGS O_WRONLY|O_CREAT|O_TRUNC|O_NOCTTY, 0666
#define DEST_DEVICE_FLAGS O_WRONLY, 0
#define DEST_FILE_FLAGS O_WRONLY|O_CREAT|O_TRUNC|O_NOCTTY|O_CLOEXEC, 0666
#define DEST_DEVICE_FLAGS O_WRONLY|O_CLOEXEC, 0
/* NB: We cheat slightly by assuming that optargs_bitmask is
* compatible for all four of the calls. This is true provided they
@@ -78,7 +78,7 @@ copy (const char *src, const char *src_display,
size = -1;
/* Open source and destination. */
src_fd = open (src, O_RDONLY);
src_fd = open (src, O_RDONLY|O_CLOEXEC);
if (src_fd == -1) {
reply_with_perror ("%s", src_display);
return -1;
@@ -177,48 +177,37 @@ int
do_copy_device_to_file (const char *src, const char *dest,
int64_t srcoffset, int64_t destoffset, int64_t size)
{
char *dest_buf;
int r;
CLEANUP_FREE char *dest_buf = sysroot_path (dest);
dest_buf = sysroot_path (dest);
if (!dest_buf) {
reply_with_perror ("malloc");
return -1;
}
r = copy (src, src, dest_buf, dest, DEST_FILE_FLAGS,
srcoffset, destoffset, size);
free (dest_buf);
return r;
return copy (src, src, dest_buf, dest, DEST_FILE_FLAGS,
srcoffset, destoffset, size);
}
int
do_copy_file_to_device (const char *src, const char *dest,
int64_t srcoffset, int64_t destoffset, int64_t size)
{
char *src_buf;
int r;
CLEANUP_FREE char *src_buf = sysroot_path (src);
src_buf = sysroot_path (src);
if (!src_buf) {
reply_with_perror ("malloc");
return -1;
}
r = copy (src_buf, src, dest, dest, DEST_DEVICE_FLAGS,
srcoffset, destoffset, size);
free (src_buf);
return r;
return copy (src_buf, src, dest, dest, DEST_DEVICE_FLAGS,
srcoffset, destoffset, size);
}
int
do_copy_file_to_file (const char *src, const char *dest,
int64_t srcoffset, int64_t destoffset, int64_t size)
{
char *src_buf, *dest_buf;
int r;
CLEANUP_FREE char *src_buf = NULL, *dest_buf = NULL;
src_buf = sysroot_path (src);
if (!src_buf) {
@@ -229,14 +218,9 @@ do_copy_file_to_file (const char *src, const char *dest,
dest_buf = sysroot_path (dest);
if (!dest_buf) {
reply_with_perror ("malloc");
free (src_buf);
return -1;
}
r = copy (src_buf, src, dest_buf, dest, DEST_FILE_FLAGS,
srcoffset, destoffset, size);
free (src_buf);
free (dest_buf);
return r;
return copy (src_buf, src, dest_buf, dest, DEST_FILE_FLAGS,
srcoffset, destoffset, size);
}

View File

@@ -1,5 +1,5 @@
/* libguestfs - the guestfsd daemon
* Copyright (C) 2009-2012 Red Hat Inc.
* Copyright (C) 2009-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
@@ -25,31 +25,34 @@
#include "daemon.h"
#include "actions.h"
GUESTFSD_EXT_CMD(str_cp, cp);
GUESTFSD_EXT_CMD(str_mv, mv);
static int cpmv_cmd (const char *cmd, const char *flags, const char *src, const char *dest);
int
do_cp (const char *src, const char *dest)
{
return cpmv_cmd ("cp", NULL, src, dest);
return cpmv_cmd (str_cp, NULL, src, dest);
}
int
do_cp_a (const char *src, const char *dest)
{
return cpmv_cmd ("cp", "-a", src, dest);
return cpmv_cmd (str_cp, "-a", src, dest);
}
int
do_mv (const char *src, const char *dest)
{
return cpmv_cmd ("mv", NULL, src, dest);
return cpmv_cmd (str_mv, NULL, src, dest);
}
static int
cpmv_cmd (const char *cmd, const char *flags, const char *src, const char *dest)
{
char *srcbuf, *destbuf;
char *err;
CLEANUP_FREE char *srcbuf = NULL, *destbuf = NULL;
CLEANUP_FREE char *err = NULL;
int r;
srcbuf = sysroot_path (src);
@@ -61,7 +64,6 @@ cpmv_cmd (const char *cmd, const char *flags, const char *src, const char *dest)
destbuf = sysroot_path (dest);
if (destbuf == NULL) {
reply_with_perror ("malloc");
free (srcbuf);
return -1;
}
@@ -72,16 +74,11 @@ cpmv_cmd (const char *cmd, const char *flags, const char *src, const char *dest)
else
r = command (NULL, &err, cmd, srcbuf, destbuf, NULL);
free (srcbuf);
free (destbuf);
if (r == -1) {
pulse_mode_cancel ();
reply_with_error ("%s", err);
free (err);
return -1;
}
free (err);
pulse_mode_end ();

View File

@@ -1,5 +1,5 @@
/* libguestfs - the guestfsd daemon
* Copyright (C) 2009-2012 Red Hat Inc.
* Copyright (C) 2009-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
@@ -30,6 +30,22 @@
#include "guestfs_protocol.h"
#include "guestfs-internal-all.h"
/* Mountables */
typedef enum {
MOUNTABLE_DEVICE, /* A bare device */
MOUNTABLE_BTRFSVOL, /* A btrfs subvolume: device + volume */
MOUNTABLE_PATH /* An already mounted path: device = path */
} mountable_type_t;
typedef struct {
mountable_type_t type;
const char *device;
const char *volume;
} mountable_t;
/*-- in guestfsd.c --*/
extern int verbose;
@@ -47,47 +63,92 @@ extern int xwrite (int sock, const void *buf, size_t len)
extern int xread (int sock, void *buf, size_t len)
__attribute__((__warn_unused_result__));
extern int add_string_nodup (char ***argv, int *size, int *alloc, char *str);
extern int add_string (char ***argv, int *size, int *alloc, const char *str);
extern size_t count_strings (char *const *argv);
extern void sort_strings (char **argv, int len);
extern void free_strings (char **argv);
extern void free_stringslen (char **argv, int len);
extern char *mountable_to_string (const mountable_t *mountable);
extern int is_power_of_2 (unsigned long v);
/* Growable strings buffer. */
struct stringsbuf {
char **argv;
size_t size;
size_t alloc;
};
#define DECLARE_STRINGSBUF(v) \
struct stringsbuf (v) = { .argv = NULL, .size = 0, .alloc = 0 }
/* Append a string to the strings buffer.
*
* add_string_nodup: don't copy the string.
* add_string: copy the string.
* end_stringsbuf: NULL-terminate the buffer.
*
* All functions may fail. If these functions return -1, then
* reply_with_* has been called, the strings have been freed and the
* buffer should no longer be used.
*/
extern int add_string_nodup (struct stringsbuf *sb, char *str);
extern int add_string (struct stringsbuf *sb, const char *str);
extern int end_stringsbuf (struct stringsbuf *sb);
extern size_t count_strings (char *const *argv);
extern void sort_strings (char **argv, size_t len);
extern void free_strings (char **argv);
extern void free_stringslen (char **argv, size_t len);
extern void sort_device_names (char **argv, size_t len);
extern int compare_device_names (const char *a, const char *b);
/* Concatenate strings, optionally with a separator string between
* each. On error, these return NULL but do NOT call reply_with_* nor
* free anything.
*/
extern char *concat_strings (char *const *argv);
extern char *join_strings (const char *separator, char *const *argv);
extern char **split_lines (char *str);
#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))
#define commandrv(out,err,argv) commandrvf((out),(err),0,(argv))
#define __external_command __attribute__((__section__(".guestfsd_ext_cmds")))
#define GUESTFSD_EXT_CMD(___ext_cmd_var, ___ext_cmd_str) static const char ___ext_cmd_var[] __external_command = #___ext_cmd_str
#define COMMAND_FLAG_FD_MASK (1024-1)
#define COMMAND_FLAG_FOLD_STDOUT_ON_STDERR 1024
#define COMMAND_FLAG_CHROOT_COPY_FILE_TO_STDIN 2048
extern int commandf (char **stdoutput, char **stderror, int flags,
const char *name, ...);
const char *name, ...) __attribute__((sentinel));
extern int commandrf (char **stdoutput, char **stderror, int flags,
const char *name, ...);
const char *name, ...) __attribute__((sentinel));
extern int commandvf (char **stdoutput, char **stderror, int flags,
char const *const *argv);
extern int commandrvf (char **stdoutput, char **stderror, int flags,
char const* const *argv);
extern char **split_lines (char *str);
extern int is_power_of_2 (unsigned long v);
extern void trim (char *str);
extern int device_name_translation (char *device);
extern int parse_btrfsvol (char *desc, mountable_t *mountable);
extern int prog_exists (const char *prog);
extern void udev_settle (void);
extern int random_name (char *template);
/* This just stops gcc from giving a warning about our custom printf
* formatters %Q and %R. See guestfs(3)/EXTENDING LIBGUESTFS for more
* info about these.
* info about these. In GCC 4.8.0 the warning is even harder to
* 'trick', hence the need for the #pragma directives.
*/
#if defined(__GNUC__) && GUESTFS_GCC_VERSION >= 40800 /* gcc >= 4.8.0 */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsuggest-attribute=format"
#endif
static inline int
asprintf_nowarn (char **strp, const char *fmt, ...)
{
@@ -99,6 +160,14 @@ asprintf_nowarn (char **strp, const char *fmt, ...)
va_end (args);
return r;
}
#if defined(__GNUC__) && GUESTFS_GCC_VERSION >= 40800 /* gcc >= 4.8.0 */
#pragma GCC diagnostic pop
#endif
/* Use by the CLEANUP_* macros. */
extern void cleanup_free (void *ptr);
extern void cleanup_free_string_list (void *ptr);
extern void cleanup_unlink_free (void *ptr);
/*-- in names.c (auto-generated) --*/
extern const char *function_names[];
@@ -111,6 +180,7 @@ extern uint64_t optargs_bitmask;
/*-- in mount.c --*/
extern int is_root_mounted (void);
extern int is_device_mounted (const char *device);
/*-- in stubs.c (auto-generated) --*/
extern void dispatch_incoming_message (XDR *);
@@ -125,12 +195,16 @@ struct optgroup {
};
extern struct optgroup optgroups[];
/*-- in available.c --*/
extern int filesystem_available (const char *filesystem);
/*-- in sync.c --*/
/* Use this as a replacement for sync(2). */
extern int sync_disks (void);
/*-- in ext2.c --*/
extern int e2prog (char *name); /* Massive hack for RHEL 5. */
/* Confirmed this is true up to ext4 from the Linux sources. */
#define EXT2_LABEL_MAX 16
/*-- in lvm.c --*/
extern int lv_canonical (const char *device, char **ret);
@@ -138,6 +212,9 @@ extern int lv_canonical (const char *device, char **ret);
/*-- in lvm-filter.c --*/
extern void copy_lvm (void);
/*-- in zero.c --*/
extern void wipe_device_before_mkfs (const char *device);
/*-- in proto.c --*/
extern void main_loop (int sock) __attribute__((noreturn));
@@ -145,10 +222,11 @@ extern void main_loop (int sock) __attribute__((noreturn));
* NB: you don't need to prefix the string with the current command,
* it is added automatically by the client-side RPC stubs.
*/
extern void reply_with_error (const char *fs, ...)
__attribute__((format (printf,1,2)));
extern void reply_with_error_errno (int err, const char *fs, ...)
__attribute__((format (printf,2,3)));
extern void reply_with_perror_errno (int err, const char *fs, ...)
__attribute__((format (printf,2,3)));
#define reply_with_error(...) reply_with_error_errno(0, __VA_ARGS__)
#define reply_with_perror(...) reply_with_perror_errno(errno, __VA_ARGS__)
/* daemon functions that receive files (FileIn) should call
@@ -166,7 +244,7 @@ extern int cancel_receive (void);
* reply, then send_file_* for each FileOut parameter.
* Note max write size if GUESTFS_MAX_CHUNK_SIZE.
*/
extern int send_file_write (const void *buf, int len);
extern int send_file_write (const void *buf, size_t len);
extern int send_file_end (int cancel);
/* only call this if there is a FileOut parameter */
@@ -195,6 +273,11 @@ extern void pulse_mode_start (void);
extern void pulse_mode_end (void);
extern void pulse_mode_cancel (void);
/* Send a progress message without rate-limiting. This is just
* for debugging - DON'T use it in regular code!
*/
extern void notify_progress_no_ratelimit (uint64_t position, uint64_t total, const struct timeval *now);
/* Return true iff the buffer is all zero bytes.
*
* Note that gcc is smart enough to optimize this properly:
@@ -264,8 +347,11 @@ is_zero (const char *buffer, size_t size)
reply_with_error ("%s: %s: expecting a device name", __func__, (path)); \
fail_stmt; \
} \
if (is_root_device (path)) \
if (is_root_device (path)) { \
cancel_stmt; \
reply_with_error ("%s: %s: device not found", __func__, path); \
fail_stmt; \
} \
if (device_name_translation ((path)) == -1) { \
int err = errno; \
cancel_stmt; \
@@ -275,6 +361,32 @@ is_zero (const char *buffer, size_t size)
} \
} while (0)
/* All functions that take a mountable argument must call this macro.
* It parses the mountable into a mountable_t, ensures any
* underlying device exists, and does device name translation
* (described in the guestfs(3) manpage).
*
* Note that the "string" argument may be modified.
*/
#define RESOLVE_MOUNTABLE(string,mountable,cancel_stmt,fail_stmt) \
do { \
if (STRPREFIX ((string), "btrfsvol:")) { \
if (parse_btrfsvol ((string) + strlen ("btrfsvol:"), &(mountable)) == -1)\
{ \
cancel_stmt; \
reply_with_error ("%s: %s: expecting a btrfs volume", \
__func__, (string)); \
fail_stmt; \
} \
} \
\
else { \
(mountable).type = MOUNTABLE_DEVICE; \
(mountable).device = (string); \
RESOLVE_DEVICE((string), cancel_stmt, fail_stmt); \
} \
} while (0)
/* Helper for functions which need either an absolute path in the
* mounted filesystem, OR a /dev/ device which exists.
*
@@ -295,6 +407,24 @@ is_zero (const char *buffer, size_t size)
} \
} while (0)
/* Helper for functions which need either an absolute path in the
* mounted filesystem, OR a valid mountable description.
*/
#define REQUIRE_ROOT_OR_RESOLVE_MOUNTABLE(string, mountable, \
cancel_stmt, fail_stmt) \
do { \
if (STREQLEN ((string), "/dev/", strlen ("/dev/")) || (string)[0] != '/') {\
RESOLVE_MOUNTABLE (string, mountable, cancel_stmt, fail_stmt); \
} \
\
else { \
NEED_ROOT (cancel_stmt, fail_stmt); \
(mountable).type = MOUNTABLE_PATH; \
(mountable).device = (string); \
} \
} while (0) \
/* NB:
* (1) You must match CHROOT_IN and CHROOT_OUT even along error paths.
* (2) You must not change directory! cwd must always be "/", otherwise
@@ -331,34 +461,23 @@ is_zero (const char *buffer, size_t size)
} \
while (0)
/* Marks functions which are not available.
* NB. Cannot be used for FileIn functions.
*/
#define NOT_AVAILABLE(errcode) \
do { \
reply_with_error ("%s: function not available", __func__); \
return (errcode); \
} \
while (0)
/* Marks functions which are not supported. */
#define NOT_SUPPORTED(errcode,...) \
do { \
reply_with_error_errno (ENOTSUP, __VA_ARGS__); \
return (errcode); \
} \
while (0)
#ifndef __attribute__
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
# define __attribute__(x) /* empty */
# endif
#ifdef HAVE_ATTRIBUTE_CLEANUP
#define CLEANUP_FREE __attribute__((cleanup(cleanup_free)))
#define CLEANUP_FREE_STRING_LIST \
__attribute__((cleanup(cleanup_free_string_list)))
#define CLEANUP_UNLINK_FREE __attribute__((cleanup(cleanup_unlink_free)))
#else
#define CLEANUP_FREE
#define CLEANUP_FREE_STRING_LIST
#define CLEANUP_UNLINK_FREE
#endif
#ifndef ATTRIBUTE_UNUSED
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
#endif
#define STREQ(a,b) (strcmp((a),(b)) == 0)
#define STRCASEEQ(a,b) (strcasecmp((a),(b)) == 0)
#define STRNEQ(a,b) (strcmp((a),(b)) != 0)
#define STRCASENEQ(a,b) (strcasecmp((a),(b)) != 0)
#define STREQLEN(a,b,n) (strncmp((a),(b),(n)) == 0)
#define STRCASEEQLEN(a,b,n) (strncasecmp((a),(b),(n)) == 0)
#define STRNEQLEN(a,b,n) (strncmp((a),(b),(n)) != 0)
#define STRCASENEQLEN(a,b,n) (strncasecmp((a),(b),(n)) != 0)
#define STRPREFIX(a,b) (strncmp((a),(b),strlen((b))) == 0)
#endif /* GUESTFSD_DAEMON_H */

View File

@@ -27,12 +27,14 @@
#include "daemon.h"
#include "actions.h"
GUESTFSD_EXT_CMD(str_dd, dd);
int
do_dd (const char *src, const char *dest)
{
int src_is_dev, dest_is_dev;
char *if_arg, *of_arg;
char *err;
CLEANUP_FREE char *if_arg = NULL, *of_arg = NULL;
CLEANUP_FREE char *err = NULL;
int r;
src_is_dev = STRPREFIX (src, "/dev/");
@@ -54,20 +56,14 @@ do_dd (const char *src, const char *dest)
r = asprintf (&of_arg, "of=%s%s", sysroot, dest);
if (r == -1) {
reply_with_perror ("asprintf");
free (if_arg);
return -1;
}
r = command (NULL, &err, "dd", "bs=1024K", if_arg, of_arg, NULL);
free (if_arg);
free (of_arg);
r = command (NULL, &err, str_dd, "bs=1024K", if_arg, of_arg, NULL);
if (r == -1) {
reply_with_error ("%s: %s: %s", src, dest, err);
free (err);
return -1;
}
free (err);
return 0;
}
@@ -75,19 +71,17 @@ do_dd (const char *src, const char *dest)
int
do_copy_size (const char *src, const char *dest, int64_t ssize)
{
char *buf;
int src_fd, dest_fd;
if (STRPREFIX (src, "/dev/"))
src_fd = open (src, O_RDONLY);
src_fd = open (src, O_RDONLY | O_CLOEXEC);
else {
buf = sysroot_path (src);
CLEANUP_FREE char *buf = sysroot_path (src);
if (!buf) {
reply_with_perror ("malloc");
return -1;
}
src_fd = open (buf, O_RDONLY);
free (buf);
src_fd = open (buf, O_RDONLY | O_CLOEXEC);
}
if (src_fd == -1) {
reply_with_perror ("%s", src);
@@ -95,16 +89,15 @@ do_copy_size (const char *src, const char *dest, int64_t ssize)
}
if (STRPREFIX (dest, "/dev/"))
dest_fd = open (dest, O_WRONLY);
dest_fd = open (dest, O_WRONLY | O_CLOEXEC);
else {
buf = sysroot_path (dest);
CLEANUP_FREE char *buf = sysroot_path (dest);
if (!buf) {
reply_with_perror ("malloc");
close (src_fd);
return -1;
}
dest_fd = open (buf, O_WRONLY|O_CREAT|O_TRUNC|O_NOCTTY, 0666);
free (buf);
dest_fd = open (buf, O_WRONLY|O_CREAT|O_TRUNC|O_NOCTTY|O_CLOEXEC, 0666);
}
if (dest_fd == -1) {
reply_with_perror ("%s", dest);

View File

@@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -32,6 +33,15 @@
#include "daemon.h"
#include "actions.h"
GUESTFSD_EXT_CMD(str_printenv, printenv);
GUESTFSD_EXT_CMD(str_ldd, ldd);
GUESTFSD_EXT_CMD(str_ls, ls);
GUESTFSD_EXT_CMD(str_find, find);
GUESTFSD_EXT_CMD(str_xargs, xargs);
GUESTFSD_EXT_CMD(str_file, file);
GUESTFSD_EXT_CMD(str_grep, grep);
GUESTFSD_EXT_CMD(str_gawk, gawk);
/* This command exposes debugging information, internals and
* status. There is no comprehensive documentation for this
* command. You have to look at the source code in this file
@@ -47,21 +57,22 @@
struct cmd {
const char *cmd;
char * (*f) (const char *subcmd, int argc, char *const *const argv);
char * (*f) (const char *subcmd, size_t argc, char *const *const argv);
};
static char *debug_help (const char *subcmd, int argc, char *const *const argv);
static char *debug_binaries (const char *subcmd, int argc, char *const *const argv);
static char *debug_core_pattern (const char *subcmd, int argc, char *const *const argv);
static char *debug_env (const char *subcmd, int argc, char *const *const argv);
static char *debug_fds (const char *subcmd, int argc, char *const *const argv);
static char *debug_ldd (const char *subcmd, int argc, char *const *const argv);
static char *debug_ls (const char *subcmd, int argc, char *const *const argv);
static char *debug_ll (const char *subcmd, int argc, char *const *const argv);
static char *debug_progress (const char *subcmd, int argc, char *const *const argv);
static char *debug_qtrace (const char *subcmd, int argc, char *const *const argv);
static char *debug_segv (const char *subcmd, int argc, char *const *const argv);
static char *debug_sh (const char *subcmd, int argc, char *const *const argv);
static char *debug_help (const char *subcmd, size_t argc, char *const *const argv);
static char *debug_binaries (const char *subcmd, size_t argc, char *const *const argv);
static char *debug_core_pattern (const char *subcmd, size_t argc, char *const *const argv);
static char *debug_env (const char *subcmd, size_t argc, char *const *const argv);
static char *debug_fds (const char *subcmd, size_t argc, char *const *const argv);
static char *debug_ldd (const char *subcmd, size_t argc, char *const *const argv);
static char *debug_ls (const char *subcmd, size_t argc, char *const *const argv);
static char *debug_ll (const char *subcmd, size_t argc, char *const *const argv);
static char *debug_progress (const char *subcmd, size_t argc, char *const *const argv);
static char *debug_qtrace (const char *subcmd, size_t argc, char *const *const argv);
static char *debug_segv (const char *subcmd, size_t argc, char *const *const argv);
static char *debug_setenv (const char *subcmd, size_t argc, char *const *const argv);
static char *debug_sh (const char *subcmd, size_t argc, char *const *const argv);
static struct cmd cmds[] = {
{ "help", debug_help },
@@ -75,6 +86,7 @@ static struct cmd cmds[] = {
{ "progress", debug_progress },
{ "qtrace", debug_qtrace },
{ "segv", debug_segv },
{ "setenv", debug_setenv },
{ "sh", debug_sh },
{ NULL, NULL }
};
@@ -82,7 +94,7 @@ static struct cmd cmds[] = {
char *
do_debug (const char *subcmd, char *const *argv)
{
int argc, i;
size_t argc, i;
for (i = argc = 0; argv[i] != NULL; ++i)
argc++;
@@ -97,9 +109,9 @@ do_debug (const char *subcmd, char *const *argv)
}
static char *
debug_help (const char *subcmd, int argc, char *const *const argv)
debug_help (const char *subcmd, size_t argc, char *const *const argv)
{
int len, i;
size_t len, i;
char *r, *p;
r = strdup ("Commands supported:");
@@ -128,7 +140,7 @@ debug_help (const char *subcmd, int argc, char *const *const argv)
/* Show open FDs. */
static char *
debug_fds (const char *subcmd, int argc, char *const *const argv)
debug_fds (const char *subcmd, size_t argc, char *const *const argv)
{
int r;
char *out;
@@ -196,7 +208,7 @@ debug_fds (const char *subcmd, int argc, char *const *const argv)
/* Force a segfault in the daemon. */
static char *
debug_segv (const char *subcmd, int argc, char *const *const argv)
debug_segv (const char *subcmd, size_t argc, char *const *const argv)
{
/* http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html
* "Dereferencing a NULL Pointer: contrary to popular belief,
@@ -204,6 +216,7 @@ debug_segv (const char *subcmd, int argc, char *const *const argv)
* to trap [...]"
*/
volatile int *ptr = NULL;
/* coverity[var_deref_op] */
*ptr = 1;
return NULL;
}
@@ -214,16 +227,16 @@ debug_segv (const char *subcmd, int argc, char *const *const argv)
* because it's not using the guest shell, and is not chrooted.
*/
static char *
debug_sh (const char *subcmd, int argc, char *const *const argv)
debug_sh (const char *subcmd, size_t argc, char *const *const argv)
{
CLEANUP_FREE char *cmd = NULL;
size_t len, i, j;
if (argc < 1) {
reply_with_error ("sh: expecting a command to run");
return NULL;
}
char *cmd;
int len, i, j;
/* guestfish splits the parameter(s) into a list of strings,
* and we have to reassemble them here. Not ideal. XXX
*/
@@ -255,8 +268,6 @@ debug_sh (const char *subcmd, int argc, char *const *const argv)
char *err;
int r = commandf (NULL, &err, COMMAND_FLAG_FOLD_STDOUT_ON_STDERR,
"/bin/sh", "-c", cmd, NULL);
free (cmd);
if (r == -1) {
reply_with_error ("%s", err);
free (err);
@@ -268,49 +279,69 @@ debug_sh (const char *subcmd, int argc, char *const *const argv)
/* Print the environment that commands get (by running external printenv). */
static char *
debug_env (const char *subcmd, int argc, char *const *const argv)
debug_env (const char *subcmd, size_t argc, char *const *const argv)
{
int r;
char *out, *err;
char *out;
CLEANUP_FREE char *err = NULL;
r = command (&out, &err, "printenv", NULL);
r = command (&out, &err, str_printenv, NULL);
if (r == -1) {
reply_with_error ("printenv: %s", err);
free (out);
free (err);
return NULL;
}
free (err);
return out;
}
/* Set an environment variable in the daemon and future subprocesses. */
static char *
debug_setenv (const char *subcmd, size_t argc, char *const *const argv)
{
char *ret;
if (argc != 2) {
reply_with_error ("setenv: two arguments expected");
return NULL;
}
setenv (argv[0], argv[1], 1);
ret = strdup ("ok");
if (NULL == ret) {
reply_with_perror ("strdup");
return NULL;
}
return ret;
}
/* Return binaries in the appliance.
* See tests/regressions/rhbz727178.sh
*/
static char *
debug_binaries (const char *subcmd, int argc, char *const *const argv)
debug_binaries (const char *subcmd, size_t argc, char *const *const argv)
{
int r;
char *out, *err;
char *out;
CLEANUP_FREE char *err;
char cmd[256];
const char cmd[] =
"find / -xdev -type f -executable "
"| xargs file -i "
"| grep application/x-executable "
"| gawk -F: '{print $1}'";
snprintf (cmd, sizeof (cmd),
"%s / -xdev -type f -executable "
"| %s %s -i "
"| %s application/x-executable "
"| %s -F: '{print $1}'",
str_find, str_xargs, str_file, str_grep, str_gawk);
r = command (&out, &err, "sh", "-c", cmd, NULL);
if (r == -1) {
reply_with_error ("find: %s", err);
free (out);
free (err);
return NULL;
}
free (err);
return out;
}
@@ -318,10 +349,11 @@ debug_binaries (const char *subcmd, int argc, char *const *const argv)
* See tests/regressions/rhbz727178.sh
*/
static char *
debug_ldd (const char *subcmd, int argc, char *const *const argv)
debug_ldd (const char *subcmd, size_t argc, char *const *const argv)
{
int r;
char *out, *err, *ret;
char *out, *ret;
CLEANUP_FREE char *err = NULL;
if (argc != 1) {
reply_with_error ("ldd: no file argument");
@@ -334,11 +366,10 @@ debug_ldd (const char *subcmd, int argc, char *const *const argv)
* Also 'ldd' randomly sends messages to stderr and errors to stdout
* depending on the phase of the moon.
*/
r = command (&out, &err, "ldd", "-r", argv[0], NULL);
r = command (&out, &err, str_ldd, "-r", argv[0], NULL);
if (r == -1) {
reply_with_error ("ldd: %s: %s", argv[0], err);
free (out);
free (err);
return NULL;
}
@@ -347,99 +378,122 @@ debug_ldd (const char *subcmd, int argc, char *const *const argv)
if (ret == NULL) {
reply_with_perror ("realloc");
free (out);
free (err);
return NULL;
}
strcat (ret, err);
free (err);
return ret;
}
/* List files in the appliance. */
static char *
debug_ls (const char *subcmd, int argc, char *const *const argv)
debug_ls (const char *subcmd, size_t argc, char *const *const argv)
{
int len = count_strings (argv);
size_t len = count_strings (argv);
const char *cargv[len+3];
int i;
size_t i;
int r;
char *out;
CLEANUP_FREE char *err;
cargv[0] = "ls";
cargv[0] = str_ls;
cargv[1] = "-a";
for (i = 0; i < len; ++i)
cargv[2+i] = argv[i];
cargv[2+len] = NULL;
int r;
char *out, *err;
r = commandv (&out, &err, (void *) cargv);
if (r == -1) {
reply_with_error ("ls: %s", err);
free (out);
free (err);
return NULL;
}
free (err);
return out;
}
/* List files in the appliance. */
static char *
debug_ll (const char *subcmd, int argc, char *const *const argv)
debug_ll (const char *subcmd, size_t argc, char *const *const argv)
{
int len = count_strings (argv);
size_t len = count_strings (argv);
const char *cargv[len+3];
int i;
size_t i;
int r;
char *out;
CLEANUP_FREE char *err;
cargv[0] = "ls";
cargv[0] = str_ls;
cargv[1] = "-la";
for (i = 0; i < len; ++i)
cargv[2+i] = argv[i];
cargv[2+len] = NULL;
int r;
char *out, *err;
r = commandv (&out, &err, (void *) cargv);
if (r == -1) {
reply_with_error ("ll: %s", err);
free (out);
free (err);
return NULL;
}
free (err);
return out;
}
/* Generate progress notification messages in order to test progress bars. */
static char *
debug_progress (const char *subcmd, int argc, char *const *const argv)
debug_progress (const char *subcmd, size_t argc, char *const *const argv)
{
uint64_t secs, rate = 0;
char *ret;
if (argc < 1) {
error:
reply_with_error ("progress: expecting arg (time in seconds as string)");
reply_with_error ("progress: expecting one or more args: time in seconds [, rate in microseconds]");
return NULL;
}
char *secs_str = argv[0];
unsigned secs;
if (sscanf (secs_str, "%u", &secs) != 1 || secs == 0)
if (sscanf (argv[0], "%" SCNu64, &secs) != 1)
goto error;
unsigned i;
unsigned tsecs = secs * 10; /* 1/10ths of seconds */
for (i = 1; i <= tsecs; ++i) {
usleep (100000);
notify_progress ((uint64_t) i, (uint64_t) tsecs);
if (secs == 0 || secs > 1000000) { /* RHBZ#816839 */
reply_with_error ("progress: argument is 0, less than 0, or too large");
return NULL;
}
char *ret = strdup ("ok");
if (argc >= 2) {
if (sscanf (argv[1], "%" SCNu64, &rate) != 1)
goto error;
if (rate == 0 || rate > 1000000) {
reply_with_error ("progress: rate is 0 or too large");
return NULL;
}
}
/* Note the inner loops go to '<= limit' because we want to ensure
* that the final 100% completed message is set.
*/
if (rate == 0) { /* Ordinary rate-limited progress messages. */
uint64_t tsecs = secs * 10; /* 1/10ths of seconds */
uint64_t i;
for (i = 1; i <= tsecs; ++i) {
usleep (100000);
notify_progress (i, tsecs);
}
}
else { /* Send messages at a given rate. */
uint64_t usecs = secs * 1000000; /* microseconds */
uint64_t i;
struct timeval now;
for (i = rate; i <= usecs; i += rate) {
usleep (rate);
gettimeofday (&now, NULL);
notify_progress_no_ratelimit (i, usecs, &now);
}
}
ret = strdup ("ok");
if (ret == NULL) {
reply_with_perror ("strdup");
return NULL;
@@ -455,7 +509,7 @@ debug_progress (const char *subcmd, int argc, char *const *const argv)
* crashes doesn't chroot.
*/
static char *
debug_core_pattern (const char *subcmd, int argc, char *const *const argv)
debug_core_pattern (const char *subcmd, size_t argc, char *const *const argv)
{
if (argc < 1) {
reply_with_error ("core_pattern: expecting a core pattern");
@@ -466,13 +520,14 @@ debug_core_pattern (const char *subcmd, int argc, char *const *const argv)
const size_t pattern_len = strlen(pattern);
#define CORE_PATTERN "/proc/sys/kernel/core_pattern"
int fd = open (CORE_PATTERN, O_WRONLY);
int fd = open (CORE_PATTERN, O_WRONLY|O_CLOEXEC);
if (fd == -1) {
reply_with_perror ("open: " CORE_PATTERN);
return NULL;
}
if (write (fd, pattern, pattern_len) < (ssize_t) pattern_len) {
reply_with_perror ("write: " CORE_PATTERN);
close (fd);
return NULL;
}
if (close (fd) == -1) {
@@ -509,7 +564,7 @@ write_cb (void *fd_ptr, const void *buf, size_t len)
* directory in the libguestfs source tree.
*/
static char *
debug_qtrace (const char *subcmd, int argc, char *const *const argv)
debug_qtrace (const char *subcmd, size_t argc, char *const *const argv)
{
int enable;
@@ -531,7 +586,7 @@ debug_qtrace (const char *subcmd, int argc, char *const *const argv)
return NULL;
/* Note this doesn't do device name translation or check this is a device. */
int fd = open (argv[0], O_RDONLY | O_DIRECT);
int fd = open (argv[0], O_RDONLY|O_DIRECT|O_CLOEXEC);
if (fd == -1) {
reply_with_perror ("qtrace: %s: open", argv[0]);
return NULL;
@@ -549,12 +604,13 @@ debug_qtrace (const char *subcmd, int argc, char *const *const argv)
{ 2, 15, 21, 2, -1 }, /* disable trace */
{ 2, 21, 15, 2, -1 } /* enable trace */
};
void *buf;
CLEANUP_FREE void *buf = NULL;
size_t i;
/* For O_DIRECT, buffer must be aligned too (thanks Matt).
* Note posix_memalign has this strange errno behaviour.
*/
/* coverity[resource_leak] */
errno = posix_memalign (&buf, QTRACE_SIZE, QTRACE_SIZE);
if (errno != 0) {
reply_with_perror ("posix_memalign");
@@ -566,20 +622,17 @@ debug_qtrace (const char *subcmd, int argc, char *const *const argv)
if (lseek (fd, patterns[enable][i]*QTRACE_SIZE, SEEK_SET) == -1) {
reply_with_perror ("qtrace: %s: lseek", argv[0]);
close (fd);
free (buf);
return NULL;
}
if (read (fd, buf, QTRACE_SIZE) == -1) {
reply_with_perror ("qtrace: %s: read", argv[0]);
close (fd);
free (buf);
return NULL;
}
}
close (fd);
free (buf);
/* This does a sync and flushes all caches. */
if (do_drop_caches (3) == -1)
@@ -601,7 +654,7 @@ do_debug_upload (const char *filename, int mode)
/* Not chrooted - this command lets you upload a file to anywhere
* in the appliance.
*/
int fd = open (filename, O_WRONLY|O_CREAT|O_TRUNC|O_NOCTTY, mode);
int fd = open (filename, O_WRONLY|O_CREAT|O_TRUNC|O_NOCTTY|O_CLOEXEC, mode);
if (fd == -1) {
int err = errno;

View File

@@ -1,5 +1,5 @@
/* libguestfs - the guestfsd daemon
* Copyright (C) 2009 Red Hat Inc.
* Copyright (C) 2009-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
@@ -24,6 +24,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <dirent.h>
#include <limits.h>
#include <sys/stat.h>
#include "c-ctype.h"
@@ -31,18 +32,18 @@
#include "daemon.h"
#include "actions.h"
typedef int (*block_dev_func_t)(const char *dev,
char ***r, int *size, int *alloc);
typedef int (*block_dev_func_t) (const char *dev, struct stringsbuf *r);
/* Execute a given function for each discovered block device */
static char**
static char **
foreach_block_device (block_dev_func_t func)
{
char **r = NULL;
int size = 0, alloc = 0;
DECLARE_STRINGSBUF (r);
DIR *dir;
int err = 0;
struct dirent *d;
char dev_path[256];
int fd;
dir = opendir ("/sys/block");
if (!dir) {
@@ -50,16 +51,15 @@ foreach_block_device (block_dev_func_t func)
return NULL;
}
while(1) {
for (;;) {
errno = 0;
struct dirent *d = readdir(dir);
if(NULL == d) break;
d = readdir(dir);
if (!d) break;
if (STREQLEN (d->d_name, "sd", 2) ||
STREQLEN (d->d_name, "hd", 2) ||
STREQLEN (d->d_name, "vd", 2) ||
STREQLEN (d->d_name, "sr", 2)) {
char dev_path[256];
snprintf (dev_path, sizeof dev_path, "/dev/%s", d->d_name);
/* Ignore the root device. */
@@ -70,7 +70,7 @@ foreach_block_device (block_dev_func_t func)
* CD-ROM device even though we didn't request it. Try to
* detect this by seeing if the device contains media.
*/
int fd = open (dev_path, O_RDONLY);
fd = open (dev_path, O_RDONLY|O_CLOEXEC);
if (fd == -1) {
perror (dev_path);
continue;
@@ -78,7 +78,7 @@ foreach_block_device (block_dev_func_t func)
close (fd);
/* Call the map function for this device */
if((*func)(d->d_name, &r, &size, &alloc) != 0) {
if ((*func)(d->d_name, &r) != 0) {
err = 1;
break;
}
@@ -86,9 +86,9 @@ foreach_block_device (block_dev_func_t func)
}
/* Check readdir didn't fail */
if(0 != errno) {
if (errno != 0) {
reply_with_perror ("readdir: /sys/block");
free_stringslen(r, size);
free_stringslen (r.argv, r.size);
closedir (dir);
return NULL;
}
@@ -96,37 +96,36 @@ foreach_block_device (block_dev_func_t func)
/* Close the directory handle */
if (closedir (dir) == -1) {
reply_with_perror ("closedir: /sys/block");
free_stringslen(r, size);
free_stringslen (r.argv, r.size);
return NULL;
}
/* Free the result list on error */
if(err) {
free_stringslen(r, size);
if (err) {
free_stringslen (r.argv, r.size);
return NULL;
}
/* Sort the devices. Note that r might be NULL if there are no devices. */
if (r != NULL)
sort_strings (r, size);
/* Sort the devices. */
if (r.size > 0)
sort_device_names (r.argv, r.size);
/* NULL terminate the list */
if (add_string (&r, &size, &alloc, NULL) == -1) {
if (end_stringsbuf (&r) == -1) {
return NULL;
}
return r;
return r.argv;
}
/* Add a device to the list of devices */
static int
add_device(const char *device,
char ***const r, int *const size, int *const alloc)
add_device (const char *device, struct stringsbuf *r)
{
char dev_path[256];
snprintf (dev_path, sizeof dev_path, "/dev/%s", device);
if (add_string (r, size, alloc, dev_path) == -1) {
if (add_string (r, dev_path) == -1) {
return -1;
}
@@ -136,12 +135,11 @@ add_device(const char *device,
char **
do_list_devices (void)
{
return foreach_block_device(add_device);
return foreach_block_device (add_device);
}
static int
add_partitions(const char *device,
char ***const r, int *const size, int *const alloc)
add_partitions (const char *device, struct stringsbuf *r)
{
char devdir[256];
@@ -151,7 +149,7 @@ add_partitions(const char *device,
DIR *dir = opendir (devdir);
if (!dir) {
reply_with_perror ("opendir: %s", devdir);
free_stringslen (*r, *size);
free_stringslen (r->argv, r->size);
return -1;
}
@@ -165,7 +163,7 @@ add_partitions(const char *device,
char part[256];
snprintf (part, sizeof part, "/dev/%s", d->d_name);
if (add_string (r, size, alloc, part) == -1) {
if (add_string (r, part) == -1) {
closedir (dir);
return -1;
}
@@ -173,9 +171,9 @@ add_partitions(const char *device,
}
/* Check if readdir failed */
if(0 != errno) {
if (0 != errno) {
reply_with_perror ("readdir: %s", devdir);
free_stringslen(*r, *size);
free_stringslen (r->argv, r->size);
closedir (dir);
return -1;
}
@@ -183,7 +181,7 @@ add_partitions(const char *device,
/* Close the directory handle */
if (closedir (dir) == -1) {
reply_with_perror ("closedir: /sys/block/%s", device);
free_stringslen (*r, *size);
free_stringslen (r->argv, r->size);
return -1;
}
@@ -193,7 +191,7 @@ add_partitions(const char *device,
char **
do_list_partitions (void)
{
return foreach_block_device(add_partitions);
return foreach_block_device (add_partitions);
}
char *
@@ -245,3 +243,136 @@ do_part_to_partnum (const char *part)
return r;
}
int
do_is_whole_device (const char *device)
{
/* A 'whole' block device will have a symlink to the device in its
* /sys/block directory */
CLEANUP_FREE char *devpath = NULL;
if (asprintf (&devpath, "/sys/block/%s/device",
device + strlen ("/dev/")) == -1)
{
reply_with_perror ("asprintf");
return -1;
}
struct stat statbuf;
if (stat (devpath, &statbuf) == -1) {
if (errno == ENOENT || errno == ENOTDIR) return 0;
reply_with_perror ("stat");
return -1;
}
return 1;
}
int
do_device_index (const char *device)
{
size_t i;
int ret = -1;
CLEANUP_FREE_STRING_LIST char **devices = do_list_devices ();
if (devices == NULL)
return -1;
for (i = 0; devices[i] != NULL; ++i) {
if (STREQ (device, devices[i]))
ret = (int) i;
}
if (ret == -1)
reply_with_error ("device not found");
return ret;
}
int
do_nr_devices (void)
{
size_t i;
CLEANUP_FREE_STRING_LIST char **devices = do_list_devices ();
if (devices == NULL)
return -1;
for (i = 0; devices[i] != NULL; ++i)
;
return (int) i;
}
#define GUESTFSDIR "/dev/disk/guestfs"
char **
do_list_disk_labels (void)
{
DIR *dir = NULL;
struct dirent *d;
char *rawdev = NULL;
DECLARE_STRINGSBUF (ret);
dir = opendir (GUESTFSDIR);
if (!dir) {
reply_with_perror ("opendir: %s", GUESTFSDIR);
return NULL;
}
errno = 0;
while ((d = readdir (dir)) != NULL) {
CLEANUP_FREE char *path = NULL;
if (d->d_name[0] == '.')
continue;
if (asprintf (&path, "%s/%s", GUESTFSDIR, d->d_name) == -1) {
reply_with_perror ("asprintf");
free_stringslen (ret.argv, ret.size);
goto error;
}
rawdev = realpath (path, NULL);
if (rawdev == NULL) {
reply_with_perror ("realpath: %s", path);
free_stringslen (ret.argv, ret.size);
goto error;
}
if (add_string (&ret, d->d_name) == -1)
goto error;
if (add_string_nodup (&ret, rawdev) == -1)
goto error;
rawdev = NULL; /* buffer now owned by the stringsbuf */
}
/* Check readdir didn't fail */
if (errno != 0) {
reply_with_perror ("readdir: %s", GUESTFSDIR);
free_stringslen (ret.argv, ret.size);
goto error;
}
/* Close the directory handle */
if (closedir (dir) == -1) {
reply_with_perror ("closedir: %s", GUESTFSDIR);
free_stringslen (ret.argv, ret.size);
dir = NULL;
goto error;
}
dir = NULL;
if (end_stringsbuf (&ret) == -1)
goto error;
return ret.argv; /* caller frees */
error:
if (dir)
closedir (dir);
free (rawdev);
return NULL;
}

View File

@@ -27,24 +27,24 @@
#include "daemon.h"
#include "actions.h"
GUESTFSD_EXT_CMD(str_df, df);
char *
do_df (void)
{
int r;
char *out, *err;
char *out;
CLEANUP_FREE char *err = NULL;
NEED_ROOT (, return NULL);
r = command (&out, &err, "df", NULL);
r = command (&out, &err, str_df, NULL);
if (r == -1) {
reply_with_error ("%s", err);
free (out);
free (err);
return NULL;
}
free (err);
return out; /* Caller frees. */
}
@@ -52,19 +52,17 @@ char *
do_df_h (void)
{
int r;
char *out, *err;
char *out;
CLEANUP_FREE char *err = NULL;
NEED_ROOT (, return NULL);
r = command (&out, &err, "df", "-h", NULL);
r = command (&out, &err, str_df, "-h", NULL);
if (r == -1) {
reply_with_error ("%s", err);
free (out);
free (err);
return NULL;
}
free (err);
return out; /* Caller frees. */
}

View File

@@ -29,6 +29,8 @@
#include "daemon.h"
#include "actions.h"
GUESTFSD_EXT_CMD(str_rm, rm);
int
do_rmdir (const char *path)
{
@@ -54,7 +56,7 @@ int
do_rm_rf (const char *path)
{
int r;
char *buf, *err;
CLEANUP_FREE char *buf = NULL, *err = NULL;
if (STREQ (path, "/")) {
reply_with_error ("cannot remove root directory");
@@ -67,18 +69,13 @@ do_rm_rf (const char *path)
return -1;
}
r = command (NULL, &err, "rm", "-rf", buf, NULL);
free (buf);
r = command (NULL, &err, str_rm, "-rf", buf, NULL);
/* rm -rf is never supposed to fail. I/O errors perhaps? */
if (r == -1) {
reply_with_error ("%s: %s", path, err);
free (err);
return -1;
}
free (err);
return 0;
}
@@ -131,7 +128,7 @@ recursive_mkdir (const char *path)
{
int loop = 0;
int r;
char *ppath, *p;
char *p;
struct stat buf;
again:
@@ -151,14 +148,13 @@ recursive_mkdir (const char *path)
if (path[0] == '/' && path[1] == '\0') return -1;
/* Try to make the parent directory first. */
ppath = strdup (path);
CLEANUP_FREE char *ppath = strdup (path);
if (ppath == NULL) return -1;
p = strrchr (ppath, '/');
if (p) *p = '\0';
r = recursive_mkdir (ppath);
free (ppath);
if (r != 0) return r;
@@ -189,24 +185,3 @@ do_mkdir_p (const char *path)
return 0;
}
char *
do_mkdtemp (const char *template)
{
char *writable = strdup (template);
if (writable == NULL) {
reply_with_perror ("strdup");
return NULL;
}
CHROOT_IN;
char *r = mkdtemp (writable);
CHROOT_OUT;
if (r == NULL) {
reply_with_perror ("%s", template);
free (writable);
}
return r;
}

View File

@@ -27,20 +27,21 @@
#include "daemon.h"
#include "actions.h"
GUESTFSD_EXT_CMD(str_dmesg, dmesg);
char *
do_dmesg (void)
{
char *out, *err;
char *out;
CLEANUP_FREE char *err = NULL;
int r;
r = command (&out, &err, "dmesg", NULL);
r = command (&out, &err, str_dmesg, NULL);
if (r == -1) {
reply_with_error ("%s", err);
free (out);
free (err);
return NULL;
}
free (err);
return out; /* caller frees */
}

View File

@@ -1,5 +1,5 @@
/* libguestfs - the guestfsd daemon
* Copyright (C) 2009-2012 Red Hat Inc.
* Copyright (C) 2009-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
@@ -28,13 +28,14 @@
#include "daemon.h"
#include "actions.h"
GUESTFSD_EXT_CMD(str_du, du);
int64_t
do_du (const char *path)
{
int r;
int64_t rv;
char *out, *err;
char *buf;
CLEANUP_FREE char *out = NULL, *err = NULL, *buf = NULL;
/* Make the path relative to /sysroot. */
buf = sysroot_path (path);
@@ -45,27 +46,19 @@ do_du (const char *path)
pulse_mode_start ();
r = command (&out, &err, "du", "-s", buf, NULL);
free (buf);
r = command (&out, &err, str_du, "-s", buf, NULL);
if (r == -1) {
pulse_mode_cancel ();
reply_with_error ("%s: %s", path, err);
free (out);
free (err);
return -1;
}
free (err);
if (sscanf (out, "%"SCNi64, &rv) != 1) {
pulse_mode_cancel ();
reply_with_error ("%s: could not read output: %s", path, out);
free (out);
return -1;
}
free (out);
pulse_mode_end ();
return rv;

View File

@@ -50,7 +50,7 @@ do_echo_daemon (char *const *argv)
char *out_new = realloc (out, out_len + 1);
if (NULL == out_new) {
reply_with_perror ("realloc");
free(out);
free (out);
return 0;
}
out = out_new;

File diff suppressed because it is too large Load Diff

View File

@@ -45,7 +45,7 @@ do_fallocate64 (const char *path, int64_t len)
int fd;
CHROOT_IN;
fd = open (path, O_WRONLY | O_CREAT | O_TRUNC | O_NOCTTY, 0666);
fd = open (path, O_WRONLY|O_CREAT|O_TRUNC|O_NOCTTY|O_CLOEXEC, 0666);
CHROOT_OUT;
if (fd == -1) {
reply_with_perror ("open: %s", path);

View File

@@ -1,5 +1,5 @@
/* libguestfs - the guestfsd daemon
* Copyright (C) 2009-2012 Red Hat Inc.
* Copyright (C) 2009-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
@@ -29,6 +29,10 @@
#include "daemon.h"
#include "actions.h"
GUESTFSD_EXT_CMD(str_file, file);
GUESTFSD_EXT_CMD(str_zcat, zcat);
GUESTFSD_EXT_CMD(str_bzcat, bzcat);
int
do_touch (const char *path)
{
@@ -38,6 +42,12 @@ do_touch (const char *path)
/* RHBZ#582484: Restrict touch to regular files. It's also OK
* here if the file does not exist, since we will create it.
*
* XXX Coverity flags this as a time-of-check to time-of-use race
* condition, particularly in the libguestfs live case. Not clear
* how to fix this yet, since unconditionally opening the file can
* cause a hang, so you have to somehow check it first before you
* open it.
*/
CHROOT_IN;
r = lstat (path, &buf);
@@ -56,7 +66,7 @@ do_touch (const char *path)
}
CHROOT_IN;
fd = open (path, O_WRONLY | O_CREAT | O_NOCTTY, 0666);
fd = open (path, O_WRONLY|O_CREAT|O_NOCTTY|O_CLOEXEC, 0666);
CHROOT_OUT;
if (fd == -1) {
@@ -79,123 +89,6 @@ do_touch (const char *path)
return 0;
}
char *
do_cat (const char *path)
{
int fd;
int alloc, size, r, max;
char *buf, *buf2;
CHROOT_IN;
fd = open (path, O_RDONLY);
CHROOT_OUT;
if (fd == -1) {
reply_with_perror ("open: %s", path);
return NULL;
}
/* Read up to GUESTFS_MESSAGE_MAX - <overhead> bytes. If it's
* larger than that, we need to return an error instead (for
* correctness).
*/
max = GUESTFS_MESSAGE_MAX - 1000;
buf = NULL;
size = alloc = 0;
for (;;) {
if (size >= alloc) {
alloc += 8192;
if (alloc > max) {
reply_with_error ("%s: file is too large for message buffer",
path);
free (buf);
close (fd);
return NULL;
}
buf2 = realloc (buf, alloc);
if (buf2 == NULL) {
reply_with_perror ("realloc");
free (buf);
close (fd);
return NULL;
}
buf = buf2;
}
r = read (fd, buf + size, alloc - size);
if (r == -1) {
reply_with_perror ("read: %s", path);
free (buf);
close (fd);
return NULL;
}
if (r == 0) {
buf[size] = '\0';
break;
}
if (r > 0)
size += r;
}
if (close (fd) == -1) {
reply_with_perror ("close: %s", path);
free (buf);
return NULL;
}
return buf; /* caller will free */
}
char **
do_read_lines (const char *path)
{
char **r = NULL;
int size = 0, alloc = 0;
FILE *fp;
char *line = NULL;
size_t len = 0;
ssize_t n;
CHROOT_IN;
fp = fopen (path, "r");
CHROOT_OUT;
if (!fp) {
reply_with_perror ("fopen: %s", path);
return NULL;
}
while ((n = getline (&line, &len, fp)) != -1) {
/* Remove either LF or CRLF. */
if (n >= 2 && line[n-2] == '\r' && line[n-1] == '\n')
line[n-2] = '\0';
else if (n >= 1 && line[n-1] == '\n')
line[n-1] = '\0';
if (add_string (&r, &size, &alloc, line) == -1) {
free (line);
fclose (fp);
return NULL;
}
}
free (line);
if (add_string (&r, &size, &alloc, NULL) == -1) {
fclose (fp);
return NULL;
}
if (fclose (fp) == EOF) {
reply_with_perror ("fclose: %s", path);
free_strings (r);
return NULL;
}
return r;
}
int
do_rm (const char *path)
{
@@ -213,6 +106,24 @@ do_rm (const char *path)
return 0;
}
int
do_rm_f (const char *path)
{
int r;
CHROOT_IN;
r = unlink (path);
CHROOT_OUT;
/* Ignore ENOENT. */
if (r == -1 && errno != ENOENT) {
reply_with_perror ("%s", path);
return -1;
}
return 0;
}
int
do_chmod (int mode, const char *path)
{
@@ -299,7 +210,7 @@ do_write_file (const char *path, const char *content, int size)
}
CHROOT_IN;
fd = open (path, O_WRONLY | O_TRUNC | O_CREAT | O_NOCTTY, 0666);
fd = open (path, O_WRONLY|O_TRUNC|O_CREAT|O_NOCTTY|O_CLOEXEC, 0666);
CHROOT_OUT;
if (fd == -1) {
@@ -322,12 +233,12 @@ do_write_file (const char *path, const char *content, int size)
}
int
do_write (const char *path, const char *content, size_t size)
do_internal_write (const char *path, const char *content, size_t size)
{
int fd;
CHROOT_IN;
fd = open (path, O_WRONLY | O_TRUNC | O_CREAT | O_NOCTTY, 0666);
fd = open (path, O_WRONLY|O_TRUNC|O_CREAT|O_NOCTTY|O_CLOEXEC, 0666);
CHROOT_OUT;
if (fd == -1) {
@@ -350,12 +261,12 @@ do_write (const char *path, const char *content, size_t size)
}
int
do_write_append (const char *path, const char *content, size_t size)
do_internal_write_append (const char *path, const char *content, size_t size)
{
int fd;
CHROOT_IN;
fd = open (path, O_WRONLY | O_APPEND | O_CREAT | O_NOCTTY, 0666);
fd = open (path, O_WRONLY|O_APPEND|O_CREAT|O_NOCTTY|O_CLOEXEC, 0666);
CHROOT_OUT;
if (fd == -1) {
@@ -377,65 +288,6 @@ do_write_append (const char *path, const char *content, size_t size)
return 0;
}
char *
do_read_file (const char *path, size_t *size_r)
{
int fd;
struct stat statbuf;
char *r;
CHROOT_IN;
fd = open (path, O_RDONLY);
CHROOT_OUT;
if (fd == -1) {
reply_with_perror ("open: %s", path);
return NULL;
}
if (fstat (fd, &statbuf) == -1) {
reply_with_perror ("fstat: %s", path);
close (fd);
return NULL;
}
/* The actual limit on messages is smaller than this. This
* check just limits the amount of memory we'll try and allocate
* here. If the message is larger than the real limit, that will
* be caught later when we try to serialize the message.
*/
if (statbuf.st_size >= GUESTFS_MESSAGE_MAX) {
reply_with_error ("%s: file is too large for the protocol, use guestfs_download instead", path);
close (fd);
return NULL;
}
r = malloc (statbuf.st_size);
if (r == NULL) {
reply_with_perror ("malloc");
close (fd);
return NULL;
}
if (xread (fd, r, statbuf.st_size) == -1) {
reply_with_perror ("read: %s", path);
close (fd);
free (r);
return NULL;
}
if (close (fd) == -1) {
reply_with_perror ("close: %s", path);
free (r);
return NULL;
}
/* Mustn't touch *size_r until we are sure that we won't return any
* error (RHBZ#589039).
*/
*size_r = statbuf.st_size;
return r;
}
static char *
pread_fd (int fd, int count, int64_t offset, size_t *size_r,
const char *display_path)
@@ -500,7 +352,7 @@ do_pread (const char *path, int count, int64_t offset, size_t *size_r)
int fd;
CHROOT_IN;
fd = open (path, O_RDONLY);
fd = open (path, O_RDONLY|O_CLOEXEC);
CHROOT_OUT;
if (fd == -1) {
@@ -514,7 +366,7 @@ do_pread (const char *path, int count, int64_t offset, size_t *size_r)
char *
do_pread_device (const char *device, int count, int64_t offset, size_t *size_r)
{
int fd = open (device, O_RDONLY);
int fd = open (device, O_RDONLY|O_CLOEXEC);
if (fd == -1) {
reply_with_perror ("open: %s", device);
return NULL;
@@ -525,7 +377,7 @@ do_pread_device (const char *device, int count, int64_t offset, size_t *size_r)
static int
pwrite_fd (int fd, const char *content, size_t size, int64_t offset,
const char *display_path, int settle)
const char *display_path)
{
ssize_t r;
@@ -541,18 +393,6 @@ pwrite_fd (int fd, const char *content, size_t size, int64_t offset,
return -1;
}
/* When you call close on any block device, udev kicks off a rule
* which runs blkid to reexamine the device. We need to wait for
* this rule to finish running since it holds the device open and
* can cause other operations to fail, notably BLKRRPART. 'settle'
* flag is only set on block devices.
*
* XXX We should be smarter about when we do this or should get rid
* of the udev rules since we don't use blkid in cached mode.
*/
if (settle)
udev_settle ();
return r;
}
@@ -567,7 +407,7 @@ do_pwrite (const char *path, const char *content, size_t size, int64_t offset)
}
CHROOT_IN;
fd = open (path, O_WRONLY);
fd = open (path, O_WRONLY|O_CLOEXEC);
CHROOT_OUT;
if (fd == -1) {
@@ -575,7 +415,7 @@ do_pwrite (const char *path, const char *content, size_t size, int64_t offset)
return -1;
}
return pwrite_fd (fd, content, size, offset, path, 0);
return pwrite_fd (fd, content, size, offset, path);
}
int
@@ -587,20 +427,20 @@ do_pwrite_device (const char *device, const char *content, size_t size,
return -1;
}
int fd = open (device, O_WRONLY);
int fd = open (device, O_WRONLY|O_CLOEXEC);
if (fd == -1) {
reply_with_perror ("open: %s", device);
return -1;
}
return pwrite_fd (fd, content, size, offset, device, 1);
return pwrite_fd (fd, content, size, offset, device);
}
/* This runs the 'file' command. */
char *
do_file (const char *path)
{
char *buf = NULL;
CLEANUP_FREE char *buf = NULL;
const char *display_path = path;
int is_dev = STRPREFIX (path, "/dev/");
@@ -619,15 +459,12 @@ do_file (const char *path)
struct stat statbuf;
if (lstat (path, &statbuf) == -1) {
reply_with_perror ("lstat: %s", display_path);
free (buf);
return NULL;
}
if (! S_ISREG (statbuf.st_mode)) {
char *ret;
free (buf);
if (S_ISDIR (statbuf.st_mode))
ret = strdup ("directory");
else if (S_ISCHR (statbuf.st_mode))
@@ -654,17 +491,15 @@ do_file (const char *path)
*/
const char *flags = is_dev ? "-zbsL" : "-zb";
char *out, *err;
int r = command (&out, &err, "file", flags, path, NULL);
free (buf);
char *out;
CLEANUP_FREE char *err;
int r = command (&out, &err, str_file, flags, path, NULL);
if (r == -1) {
free (out);
reply_with_error ("%s: %s", display_path, err);
free (err);
return NULL;
}
free (err);
/* We need to remove the trailing \n from output of file(1). */
size_t len = strlen (out);
@@ -678,16 +513,16 @@ do_file (const char *path)
char *
do_zfile (const char *method, const char *path)
{
int len;
size_t len;
const char *zcat;
char *cmd;
CLEANUP_FREE char *cmd = NULL;
FILE *fp;
char line[256];
if (STREQ (method, "gzip") || STREQ (method, "compress"))
zcat = "zcat";
zcat = str_zcat;
else if (STREQ (method, "bzip2"))
zcat = "bzcat";
zcat = str_bzcat;
else {
reply_with_error ("unknown method");
return NULL;
@@ -704,12 +539,9 @@ do_zfile (const char *method, const char *path)
fp = popen (cmd, "r");
if (fp == NULL) {
reply_with_perror ("%s", cmd);
free (cmd);
return NULL;
}
free (cmd);
if (fgets (line, sizeof line, fp) == NULL) {
reply_with_perror ("fgets");
fclose (fp);

View File

@@ -123,3 +123,31 @@ do_fill_pattern (const char *pattern, int len, const char *path)
return 0;
}
int
do_fill_dir (const char *dir, int n)
{
size_t len = strlen (dir);
char filename[len+10];
int fd;
int i;
for (i = 0; i < n; ++i) {
snprintf (filename, len+10, "%s/%08d", dir, i);
CHROOT_IN;
fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_CLOEXEC, 0666);
CHROOT_OUT;
if (fd == -1) {
reply_with_perror ("create: %s", filename);
return -1;
}
if (close (fd) == -1) {
reply_with_perror ("close: %s", filename);
return -1;
}
}
return 0;
}

View File

@@ -1,5 +1,5 @@
/* libguestfs - the guestfsd daemon
* Copyright (C) 2009-2012 Red Hat Inc.
* Copyright (C) 2009-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
@@ -30,10 +30,13 @@
#include "daemon.h"
#include "actions.h"
GUESTFSD_EXT_CMD(str_find, find);
static int
input_to_nul (FILE *fp, char *buf, int maxlen)
input_to_nul (FILE *fp, char *buf, size_t maxlen)
{
int i = 0, c;
size_t i = 0;
int c;
while (i < maxlen) {
c = fgetc (fp);
@@ -48,95 +51,6 @@ input_to_nul (FILE *fp, char *buf, int maxlen)
return -1;
}
char **
do_find (const char *dir)
{
struct stat statbuf;
int r, len, sysrootdirlen;
char *cmd;
FILE *fp;
char **res = NULL;
int size = 0, alloc = 0;
char *sysrootdir;
char str[PATH_MAX];
sysrootdir = sysroot_path (dir);
if (!sysrootdir) {
reply_with_perror ("malloc");
return NULL;
}
r = stat (sysrootdir, &statbuf);
if (r == -1) {
reply_with_perror ("%s", dir);
free (sysrootdir);
return NULL;
}
if (!S_ISDIR (statbuf.st_mode)) {
reply_with_error ("%s: not a directory", dir);
free (sysrootdir);
return NULL;
}
sysrootdirlen = strlen (sysrootdir);
/* Assemble the external find command. */
if (asprintf_nowarn (&cmd, "find %Q -print0", sysrootdir) == -1) {
reply_with_perror ("malloc");
free (sysrootdir);
return NULL;
}
free (sysrootdir);
if (verbose)
fprintf (stderr, "%s\n", cmd);
fp = popen (cmd, "r");
if (fp == NULL) {
reply_with_perror ("%s", cmd);
free (cmd);
return NULL;
}
free (cmd);
while ((r = input_to_nul (fp, str, PATH_MAX)) > 0) {
len = strlen (str);
if (len <= sysrootdirlen)
continue;
/* Remove the directory part of the path when adding it. */
if (add_string (&res, &size, &alloc, str + sysrootdirlen) == -1) {
pclose (fp);
return NULL;
}
}
if (pclose (fp) != 0) {
reply_with_perror ("pclose");
free_stringslen (res, size);
return NULL;
}
if (r == -1) {
free_stringslen (res, size);
return NULL;
}
if (add_string (&res, &size, &alloc, NULL) == -1)
return NULL;
sort_strings (res, size-1);
return res; /* caller frees */
}
/* The code below assumes each path returned can fit into a protocol
* chunk. If this turns out not to be true at some point in the
* future then we'll need to modify the code a bit to handle it.
*/
#if PATH_MAX > GUESTFS_MAX_CHUNK_SIZE
#error "PATH_MAX > GUESTFS_MAX_CHUNK_SIZE"
#endif
/* Has one FileOut parameter. */
int
do_find0 (const char *dir)
@@ -144,9 +58,9 @@ do_find0 (const char *dir)
struct stat statbuf;
int r;
FILE *fp;
char *cmd;
char *sysrootdir;
size_t sysrootdirlen, len;
CLEANUP_FREE char *cmd = NULL;
CLEANUP_FREE char *sysrootdir = NULL;
size_t sysrootdirlen;
char str[GUESTFS_MAX_CHUNK_SIZE];
sysrootdir = sysroot_path (dir);
@@ -158,23 +72,19 @@ do_find0 (const char *dir)
r = stat (sysrootdir, &statbuf);
if (r == -1) {
reply_with_perror ("%s", dir);
free (sysrootdir);
return -1;
}
if (!S_ISDIR (statbuf.st_mode)) {
reply_with_error ("%s: not a directory", dir);
free (sysrootdir);
return -1;
}
sysrootdirlen = strlen (sysrootdir);
if (asprintf_nowarn (&cmd, "find %Q -print0", sysrootdir) == -1) {
if (asprintf_nowarn (&cmd, "%s %Q -print0", str_find, sysrootdir) == -1) {
reply_with_perror ("asprintf");
free (sysrootdir);
return -1;
}
free (sysrootdir);
if (verbose)
fprintf (stderr, "%s\n", cmd);
@@ -182,10 +92,8 @@ do_find0 (const char *dir)
fp = popen (cmd, "r");
if (fp == NULL) {
reply_with_perror ("%s", cmd);
free (cmd);
return -1;
}
free (cmd);
/* Now we must send the reply message, before the file contents. After
* this there is no opportunity in the protocol to send any error
@@ -193,8 +101,13 @@ do_find0 (const char *dir)
*/
reply (NULL, NULL);
/* The code below assumes each path returned can fit into a protocol
* chunk (if not you'll get a runtime protocol error). If this
* turns out not to be a problem at some point in the future then
* we'll need to modify the code to handle it. XXX
*/
while ((r = input_to_nul (fp, str, GUESTFS_MAX_CHUNK_SIZE)) > 0) {
len = strlen (str);
size_t len = strlen (str);
if (len <= sysrootdirlen)
continue;
@@ -206,14 +119,14 @@ do_find0 (const char *dir)
}
if (ferror (fp)) {
perror (dir);
fprintf (stderr, "fgetc: %s: %m\n", dir);
send_file_end (1); /* Cancel. */
pclose (fp);
return -1;
}
if (pclose (fp) != 0) {
perror (dir);
fprintf (stderr, "pclose: %s: %m\n", dir);
send_file_end (1); /* Cancel. */
return -1;
}

View File

@@ -26,31 +26,34 @@
#include "daemon.h"
#include "actions.h"
GUESTFSD_EXT_CMD(str_findfs, findfs);
static char *
findfs (const char *tag, const char *label_or_uuid)
{
char *out;
CLEANUP_FREE char *err = NULL;
int r;
/* Kill the cache file, forcing blkid to reread values from the
* original filesystems. In blkid there is a '-p' option which is
* supposed to do this, but (a) it doesn't work and (b) that option
* is not supported in RHEL 5.
*/
unlink ("/etc/blkid/blkid.tab");
unlink ("/run/blkid/blkid.tab");
size_t len = strlen (tag) + strlen (label_or_uuid) + 2;
char arg[len];
snprintf (arg, len, "%s=%s", tag, label_or_uuid);
char *out, *err;
int r = command (&out, &err, "findfs", arg, NULL);
r = command (&out, &err, str_findfs, arg, NULL);
if (r == -1) {
reply_with_error ("%s", err);
free (out);
free (err);
return NULL;
}
free (err);
/* Trim trailing \n if present. */
len = strlen (out);
if (len > 0 && out[len-1] == '\n')

View File

@@ -26,19 +26,19 @@
#include "daemon.h"
#include "actions.h"
GUESTFSD_EXT_CMD(str_fsck, fsck);
int
do_fsck (const char *fstype, const char *device)
{
char *err;
CLEANUP_FREE char *err = NULL;
int r;
r = commandr (NULL, &err, "fsck", "-a", "-t", fstype, device, NULL);
r = commandr (NULL, &err, str_fsck, "-a", "-t", fstype, device, NULL);
if (r == -1) {
reply_with_error ("%s: %s", device, err);
free (err);
return -1;
}
free (err);
return r;
}

97
daemon/fstrim.c Normal file
View File

@@ -0,0 +1,97 @@
/* libguestfs - the guestfsd daemon
* Copyright (C) 2012 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 <string.h>
#include <inttypes.h>
#include "guestfs_protocol.h"
#include "daemon.h"
#include "actions.h"
#include "optgroups.h"
#define MAX_ARGS 64
GUESTFSD_EXT_CMD(str_fstrim, fstrim);
int
optgroup_fstrim_available (void)
{
return prog_exists (str_fstrim);
}
/* Takes optional arguments, consult optargs_bitmask. */
int
do_fstrim (const char *path,
int64_t offset, int64_t length, int64_t minimumfreeextent)
{
const char *argv[MAX_ARGS];
size_t i = 0;
char offset_s[64], length_s[64], mfe_s[64];
CLEANUP_FREE char *err = NULL;
int r;
ADD_ARG (argv, i, str_fstrim);
if ((optargs_bitmask & GUESTFS_FSTRIM_OFFSET_BITMASK)) {
if (offset < 0) {
reply_with_error ("offset < 0");
return -1;
}
snprintf (offset_s, sizeof offset_s, "%" PRIi64, offset);
ADD_ARG (argv, i, "-o");
ADD_ARG (argv, i, offset_s);
}
if ((optargs_bitmask & GUESTFS_FSTRIM_LENGTH_BITMASK)) {
if (length <= 0) {
reply_with_error ("length <= 0");
return -1;
}
snprintf (length_s, sizeof length_s, "%" PRIi64, length);
ADD_ARG (argv, i, "-l");
ADD_ARG (argv, i, length_s);
}
if ((optargs_bitmask & GUESTFS_FSTRIM_MINIMUMFREEEXTENT_BITMASK)) {
if (minimumfreeextent <= 0) {
reply_with_error ("minimumfreeextent <= 0");
return -1;
}
snprintf (mfe_s, sizeof mfe_s, "%" PRIi64, minimumfreeextent);
ADD_ARG (argv, i, "-m");
ADD_ARG (argv, i, mfe_s);
}
ADD_ARG (argv, i, path);
ADD_ARG (argv, i, NULL);
r = commandv (NULL, &err, argv);
if (r == -1) {
reply_with_error ("%s", err);
return -1;
}
return 0;
}

View File

@@ -29,7 +29,7 @@ char **
do_glob_expand (const char *pattern)
{
int r;
glob_t buf;
glob_t buf = { .gl_pathc = 0, .gl_pathv = NULL, .gl_offs = 0 };
/* glob(3) in glibc never calls chdir, so this seems to be safe: */
CHROOT_IN;

View File

@@ -28,15 +28,42 @@
#include "daemon.h"
#include "actions.h"
#define MAX_ARGS 64
static char **
grep (const char *prog, const char *flag, const char *regex, const char *path)
grep (const char *regex, const char *path,
int extended, int fixed, int insensitive, int compressed)
{
char *out, *err;
const char *argv[MAX_ARGS];
size_t i = 0;
CLEANUP_FREE char *out = NULL, *err = NULL;
int fd, flags, r;
char **lines;
if (extended && fixed) {
reply_with_error ("can't use 'extended' and 'fixed' flags at the same time");
return NULL;
}
if (!compressed)
ADD_ARG (argv, i, "grep");
else
ADD_ARG (argv, i, "zgrep");
if (extended)
ADD_ARG (argv, i, "-E");
if (fixed)
ADD_ARG (argv, i, "-F");
if (insensitive)
ADD_ARG (argv, i, "-i");
ADD_ARG (argv, i, regex);
ADD_ARG (argv, i, NULL);
CHROOT_IN;
fd = open (path, O_RDONLY);
fd = open (path, O_RDONLY|O_CLOEXEC);
CHROOT_OUT;
if (fd == -1) {
@@ -48,92 +75,97 @@ grep (const char *prog, const char *flag, const char *regex, const char *path)
* suppress this error and return an empty list.
*/
flags = COMMAND_FLAG_CHROOT_COPY_FILE_TO_STDIN | fd;
r = commandrf (&out, &err, flags, prog, flag, regex, NULL);
r = commandrvf (&out, &err, flags, argv);
if (r == -1 || r > 1) {
reply_with_error ("%s %s %s: %s", prog, flag, regex, err);
free (out);
free (err);
reply_with_error ("%s: %s", regex, err);
return NULL;
}
free (err);
lines = split_lines (out);
free (out);
if (lines == NULL) return NULL;
return lines;
}
/* Takes optional arguments, consult optargs_bitmask. */
char **
do_grep (const char *regex, const char *path)
do_grep (const char *regex, const char *path,
int extended, int fixed, int insensitive, int compressed)
{
/* The "--" is not really needed, but it helps when we don't need a flag. */
return grep ("grep", "--", regex, path);
if (!(optargs_bitmask & GUESTFS_GREP_EXTENDED_BITMASK))
extended = 0;
if (!(optargs_bitmask & GUESTFS_GREP_FIXED_BITMASK))
fixed = 0;
if (!(optargs_bitmask & GUESTFS_GREP_INSENSITIVE_BITMASK))
insensitive = 0;
if (!(optargs_bitmask & GUESTFS_GREP_COMPRESSED_BITMASK))
compressed = 0;
return grep (regex, path, extended, fixed, insensitive, compressed);
}
char **
do_egrep (const char *regex, const char *path)
{
return grep ("egrep", "--", regex, path);
return grep (regex, path, 1, 0, 0, 0);
}
char **
do_fgrep (const char *regex, const char *path)
{
return grep ("fgrep", "--", regex, path);
return grep (regex, path, 0, 1, 0, 0);
}
char **
do_grepi (const char *regex, const char *path)
{
return grep ("grep", "-i", regex, path);
return grep (regex, path, 0, 0, 1, 0);
}
char **
do_egrepi (const char *regex, const char *path)
{
return grep ("egrep", "-i", regex, path);
return grep (regex, path, 1, 0, 1, 0);
}
char **
do_fgrepi (const char *regex, const char *path)
{
return grep ("fgrep", "-i", regex, path);
return grep (regex, path, 0, 1, 1, 0);
}
char **
do_zgrep (const char *regex, const char *path)
{
return grep ("zgrep", "--", regex, path);
return grep (regex, path, 0, 0, 0, 1);
}
char **
do_zegrep (const char *regex, const char *path)
{
return grep ("zegrep", "--", regex, path);
return grep (regex, path, 1, 0, 0, 1);
}
char **
do_zfgrep (const char *regex, const char *path)
{
return grep ("zfgrep", "--", regex, path);
return grep (regex, path, 0, 1, 0, 1);
}
char **
do_zgrepi (const char *regex, const char *path)
{
return grep ("zgrep", "-i", regex, path);
return grep (regex, path, 0, 0, 1, 1);
}
char **
do_zegrepi (const char *regex, const char *path)
{
return grep ("zegrep", "-i", regex, path);
return grep (regex, path, 1, 0, 1, 1);
}
char **
do_zfgrepi (const char *regex, const char *path)
{
return grep ("zfgrep", "-i", regex, path);
return grep (regex, path, 0, 1, 1, 1);
}

View File

@@ -1,5 +1,5 @@
/* libguestfs - the guestfsd daemon
* Copyright (C) 2009-2012 Red Hat Inc.
* Copyright (C) 2009-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
@@ -26,33 +26,31 @@
#include "actions.h"
#include "optgroups.h"
GUESTFSD_EXT_CMD(str_grub_install, grub-install);
int
optgroup_grub_available (void)
{
return prog_exists ("grub-install");
return prog_exists (str_grub_install);
}
int
do_grub_install (const char *root, const char *device)
{
int r;
char *err;
char *buf;
CLEANUP_FREE char *err = NULL, *buf = NULL;
if (asprintf_nowarn (&buf, "--root-directory=%R", root) == -1) {
reply_with_perror ("asprintf");
return -1;
}
r = command (NULL, &err, "grub-install", buf, device, NULL);
free (buf);
r = command (NULL, &err, str_grub_install, buf, device, NULL);
if (r == -1) {
reply_with_error ("%s", err);
free (err);
return -1;
}
free (err);
return 0;
}

View File

@@ -1,5 +1,5 @@
/* libguestfs - the guestfsd daemon
* Copyright (C) 2009-2012 Red Hat Inc.
* Copyright (C) 2009-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
@@ -40,6 +40,7 @@
#include <arpa/inet.h>
#include <netinet/in.h>
#include <errno.h>
#include <assert.h>
#ifdef HAVE_PRINTF_H
# include <printf.h>
@@ -52,6 +53,8 @@
#include "daemon.h"
GUESTFSD_EXT_CMD(str_udevadm, udevadm);
static char *read_cmdline (void);
#ifndef MAX
@@ -63,6 +66,10 @@ static char *read_cmdline (void);
# define O_CLOEXEC 0
#endif
/* For improved readability dealing with pipe arrays */
#define PIPE_READ 0
#define PIPE_WRITE 1
/* If root device is an ext2 filesystem, this is the major and minor.
* This is so we can ignore this device from the point of view of the
* user, eg. in guestfs_list_devices and many other places.
@@ -247,7 +254,7 @@ main (int argc, char *argv[])
copy_lvm ();
/* Connect to virtio-serial channel. */
int sock = open (VIRTIO_SERIAL_CHANNEL, O_RDWR | O_CLOEXEC);
int sock = open (VIRTIO_SERIAL_CHANNEL, O_RDWR|O_CLOEXEC);
if (sock == -1) {
fprintf (stderr,
"\n"
@@ -266,6 +273,17 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
/* Wait for udev devices to be created. If you start libguestfs,
* especially with disks that contain complex (eg. mdadm) data
* already, then it is possible for the 'mdadm' and LVM commands
* that the init script runs to have not completed by the time the
* daemon starts executing library commands. (This is very rare and
* hard to test however, but we have seen it in 'brew'). Run
* udev_settle, but do it as late as possible to minimize the chance
* that we'll have to do any waiting here.
*/
udev_settle ();
/* Send the magic length message which indicates that
* userspace is up inside the guest.
*/
@@ -292,7 +310,7 @@ main (int argc, char *argv[])
static char *
read_cmdline (void)
{
int fd = open ("/proc/cmdline", O_RDONLY);
int fd = open ("/proc/cmdline", O_RDONLY|O_CLOEXEC);
if (fd == -1) {
perror ("/proc/cmdline");
return NULL;
@@ -340,6 +358,13 @@ read_cmdline (void)
/* Return true iff device is the root device (and therefore should be
* ignored from the point of view of user calls).
*/
static int
is_root_device_stat (struct stat *statbuf)
{
if (statbuf->st_rdev == root_device) return 1;
return 0;
}
int
is_root_device (const char *device)
{
@@ -348,9 +373,8 @@ is_root_device (const char *device)
perror (device);
return 0;
}
if (statbuf.st_rdev == root_device)
return 1;
return 0;
return is_root_device_stat (&statbuf);
}
/* Turn "/path" into "/sysroot/path".
@@ -364,7 +388,7 @@ char *
sysroot_path (const char *path)
{
char *r;
int len = strlen (path) + sysroot_len + 1;
size_t len = strlen (path) + sysroot_len + 1;
r = malloc (len);
if (r == NULL)
@@ -417,46 +441,50 @@ xread (int sock, void *v_buf, size_t len)
}
int
add_string_nodup (char ***argv, int *size, int *alloc, char *str)
add_string_nodup (struct stringsbuf *sb, char *str)
{
char **new_argv;
if (*size >= *alloc) {
*alloc += 64;
new_argv = realloc (*argv, *alloc * sizeof (char *));
if (sb->size >= sb->alloc) {
sb->alloc += 64;
new_argv = realloc (sb->argv, sb->alloc * sizeof (char *));
if (new_argv == NULL) {
reply_with_perror ("realloc");
free_strings (*argv);
*argv = NULL;
free_stringslen (sb->argv, sb->size);
sb->argv = NULL;
return -1;
}
*argv = new_argv;
sb->argv = new_argv;
}
(*argv)[*size] = str;
sb->argv[sb->size] = str;
sb->size++;
(*size)++;
return 0;
}
int
add_string (char ***argv, int *size, int *alloc, const char *str)
add_string (struct stringsbuf *sb, const char *str)
{
char *new_str;
char *new_str = NULL;
if (str) {
new_str = strdup (str);
if (new_str == NULL) {
reply_with_perror ("strdup");
free_strings (*argv);
*argv = NULL;
free_stringslen (sb->argv, sb->size);
sb->argv = NULL;
return -1;
}
} else {
new_str = NULL;
}
return add_string_nodup (argv, size, alloc, new_str);
return add_string_nodup (sb, new_str);
}
int
end_stringsbuf (struct stringsbuf *sb)
{
return add_string_nodup (sb, NULL);
}
size_t
@@ -485,7 +513,7 @@ compare (const void *vp1, const void *vp2)
}
void
sort_strings (char **argv, int len)
sort_strings (char **argv, size_t len)
{
qsort (argv, len, sizeof (char *), compare);
}
@@ -493,7 +521,10 @@ sort_strings (char **argv, int len)
void
free_strings (char **argv)
{
int argc;
size_t argc;
if (!argv)
return;
for (argc = 0; argv[argc] != NULL; ++argc)
free (argv[argc]);
@@ -501,15 +532,130 @@ free_strings (char **argv)
}
void
free_stringslen (char **argv, int len)
free_stringslen (char **argv, size_t len)
{
int i;
size_t i;
if (!argv)
return;
for (i = 0; i < len; ++i)
free (argv[i]);
free (argv);
}
/* Compare device names (including partition numbers if present).
* https://rwmj.wordpress.com/2011/01/09/how-are-linux-drives-named-beyond-drive-26-devsdz/
*/
int
compare_device_names (const char *a, const char *b)
{
size_t a_devlen, b_devlen;
int r;
int a_partnum, b_partnum;
/* Skip /dev/ prefix if present. */
if (STRPREFIX (a, "/dev/"))
a += 5;
if (STRPREFIX (b, "/dev/"))
b += 5;
/* Skip sd/hd/vd. */
assert (a[1] == 'd');
a += 2;
assert (b[1] == 'd');
b += 2;
/* Get device name part, that is, just 'a', 'ab' etc. */
a_devlen = strcspn (a, "0123456789");
b_devlen = strcspn (b, "0123456789");
/* If device name part is longer, it is always greater, eg.
* "/dev/sdz" < "/dev/sdaa".
*/
if (a_devlen != b_devlen)
return a_devlen - b_devlen;
/* Device name parts are the same length, so do a regular compare. */
r = strncmp (a, b, a_devlen);
if (r != 0)
return r;
/* Compare partitions numbers. */
a += a_devlen;
b += a_devlen;
/* If no partition numbers, bail -- the devices are the same. This
* can happen in one peculiar case: where you have a mix of devices
* with different interfaces (eg. /dev/sda and /dev/vda).
* (RHBZ#858128).
*/
if (!*a && !*b)
return 0;
r = sscanf (a, "%d", &a_partnum);
assert (r == 1);
r = sscanf (b, "%d", &b_partnum);
assert (r == 1);
return a_partnum - b_partnum;
}
static int
compare_device_names_vp (const void *vp1, const void *vp2)
{
char * const *p1 = (char * const *) vp1;
char * const *p2 = (char * const *) vp2;
return compare_device_names (*p1, *p2);
}
void
sort_device_names (char **argv, size_t len)
{
qsort (argv, len, sizeof (char *), compare_device_names_vp);
}
char *
concat_strings (char *const *argv)
{
return join_strings ("", argv);
}
char *
join_strings (const char *separator, char *const *argv)
{
size_t i, len, seplen, rlen;
char *r;
seplen = strlen (separator);
len = 0;
for (i = 0; argv[i] != NULL; ++i) {
if (i > 0)
len += seplen;
len += strlen (argv[i]);
}
len++; /* for final \0 */
r = malloc (len);
if (r == NULL)
return NULL;
rlen = 0;
for (i = 0; argv[i] != NULL; ++i) {
if (i > 0) {
memcpy (&r[rlen], separator, seplen);
rlen += seplen;
}
len = strlen (argv[i]);
memcpy (&r[rlen], argv[i], len);
rlen += len;
}
r[rlen] = '\0';
return r;
}
/* Easy ways to run external commands. For full documentation, see
* 'commandrvf' below.
*/
@@ -517,9 +663,11 @@ int
commandf (char **stdoutput, char **stderror, int flags, const char *name, ...)
{
va_list args;
const char **argv;
/* NB: Mustn't free the strings which are on the stack. */
CLEANUP_FREE const char **argv;
char *s;
int i, r;
size_t i;
int r;
/* Collect the command line arguments into an array. */
i = 2;
@@ -537,7 +685,6 @@ commandf (char **stdoutput, char **stderror, int flags, const char *name, ...)
const char **p = realloc (argv, sizeof (char *) * (++i));
if (p == NULL) {
perror ("realloc");
free (argv);
va_end (args);
return -1;
}
@@ -550,9 +697,6 @@ commandf (char **stdoutput, char **stderror, int flags, const char *name, ...)
r = commandvf (stdoutput, stderror, flags, (const char * const*) argv);
/* NB: Mustn't free the strings which are on the stack. */
free (argv);
return r;
}
@@ -564,7 +708,7 @@ int
commandrf (char **stdoutput, char **stderror, int flags, const char *name, ...)
{
va_list args;
const char **argv;
CLEANUP_FREE const char **argv;
char *s;
int i, r;
@@ -584,7 +728,6 @@ commandrf (char **stdoutput, char **stderror, int flags, const char *name, ...)
const char **p = realloc (argv, sizeof (char *) * (++i));
if (p == NULL) {
perror ("realloc");
free (argv);
va_end (args);
return -1;
}
@@ -597,9 +740,6 @@ commandrf (char **stdoutput, char **stderror, int flags, const char *name, ...)
r = commandrvf (stdoutput, stderror, flags, argv);
/* NB: Mustn't free the strings which are on the stack. */
free (argv);
return r;
}
@@ -651,11 +791,11 @@ int
commandrvf (char **stdoutput, char **stderror, int flags,
char const* const *argv)
{
int so_size = 0, se_size = 0;
size_t so_size = 0, se_size = 0;
int so_fd[2], se_fd[2];
int flag_copy_stdin = flags & COMMAND_FLAG_CHROOT_COPY_FILE_TO_STDIN;
int stdin_fd[2] = { -1, -1 };
pid_t pid, stdin_pid = -1;
int flag_copy_fd = flags & COMMAND_FLAG_FD_MASK;
pid_t pid;
int r, quit, i;
fd_set rset, rset2;
char buf[256];
@@ -685,13 +825,6 @@ commandrvf (char **stdoutput, char **stderror, int flags,
abort ();
}
if (flag_copy_stdin) {
if (pipe (stdin_fd) == -1) {
error (0, errno, "pipe");
abort ();
}
}
pid = fork ();
if (pid == -1) {
error (0, errno, "fork");
@@ -703,95 +836,42 @@ commandrvf (char **stdoutput, char **stderror, int flags,
signal (SIGPIPE, SIG_DFL);
close (0);
if (flag_copy_stdin) {
dup2 (stdin_fd[0], 0);
close (stdin_fd[0]);
close (stdin_fd[1]);
dup2 (flag_copy_fd, STDIN_FILENO);
} else {
/* Set stdin to /dev/null (ignore failure) */
ignore_value (open ("/dev/null", O_RDONLY));
ignore_value (open ("/dev/null", O_RDONLY|O_CLOEXEC));
}
close (so_fd[0]);
close (se_fd[0]);
close (so_fd[PIPE_READ]);
close (se_fd[PIPE_READ]);
if (!(flags & COMMAND_FLAG_FOLD_STDOUT_ON_STDERR))
dup2 (so_fd[1], 1);
dup2 (so_fd[PIPE_WRITE], STDOUT_FILENO);
else
dup2 (se_fd[1], 1);
dup2 (se_fd[1], 2);
close (so_fd[1]);
close (se_fd[1]);
dup2 (se_fd[PIPE_WRITE], STDOUT_FILENO);
dup2 (se_fd[PIPE_WRITE], STDERR_FILENO);
close (so_fd[PIPE_WRITE]);
close (se_fd[PIPE_WRITE]);
ignore_value (chdir ("/"));
execvp (argv[0], (void *) argv);
perror (argv[0]);
_exit (EXIT_FAILURE);
}
if (flag_copy_stdin) {
int fd = flags & COMMAND_FLAG_FD_MASK;
stdin_pid = fork ();
if (stdin_pid == -1) {
error (0, errno, "fork");
abort ();
}
if (stdin_pid == 0) { /* Child process copying stdin. */
close (so_fd[0]);
close (so_fd[1]);
close (se_fd[0]);
close (se_fd[1]);
close (1);
dup2 (stdin_fd[1], 1);
close (stdin_fd[0]);
close (stdin_fd[1]);
if (chroot (sysroot) == -1) {
perror ("chroot");
_exit (EXIT_FAILURE);
}
ssize_t n;
char buffer[BUFSIZ];
while ((n = read (fd, buffer, sizeof buffer)) > 0) {
if (xwrite (1, buffer, n) == -1)
/* EPIPE error indicates the command process has exited
* early. If the command process fails that will be caught
* by the daemon, and if not, then it's not an error.
*/
_exit (errno == EPIPE ? EXIT_SUCCESS : EXIT_FAILURE);
}
if (n == -1) {
perror ("read");
_exit (EXIT_FAILURE);
}
if (close (fd) == -1) {
perror ("close");
_exit (EXIT_FAILURE);
}
_exit (EXIT_SUCCESS);
}
close (fd);
close (stdin_fd[0]);
close (stdin_fd[1]);
}
/* Parent process. */
close (so_fd[1]);
close (se_fd[1]);
close (so_fd[PIPE_WRITE]);
close (se_fd[PIPE_WRITE]);
FD_ZERO (&rset);
FD_SET (so_fd[0], &rset);
FD_SET (se_fd[0], &rset);
FD_SET (so_fd[PIPE_READ], &rset);
FD_SET (se_fd[PIPE_READ], &rset);
quit = 0;
while (quit < 2) {
again:
rset2 = rset;
r = select (MAX (so_fd[0], se_fd[0]) + 1, &rset2, NULL, NULL, NULL);
r = select (MAX (so_fd[PIPE_READ], se_fd[PIPE_READ]) + 1, &rset2,
NULL, NULL, NULL);
if (r == -1) {
if (errno == EINTR)
goto again;
@@ -812,20 +892,20 @@ commandrvf (char **stdoutput, char **stderror, int flags,
*stderror = strdup ("error running external command, "
"see debug output for details");
}
close (so_fd[0]);
close (se_fd[0]);
close (so_fd[PIPE_READ]);
close (se_fd[PIPE_READ]);
if (flag_copy_stdin) close (flag_copy_fd);
waitpid (pid, NULL, 0);
if (stdin_pid >= 0) waitpid (stdin_pid, NULL, 0);
return -1;
}
if (FD_ISSET (so_fd[0], &rset2)) { /* something on stdout */
r = read (so_fd[0], buf, sizeof buf);
if (FD_ISSET (so_fd[PIPE_READ], &rset2)) { /* something on stdout */
r = read (so_fd[PIPE_READ], buf, sizeof buf);
if (r == -1) {
perror ("read");
goto quit;
}
if (r == 0) { FD_CLR (so_fd[0], &rset); quit++; }
if (r == 0) { FD_CLR (so_fd[PIPE_READ], &rset); quit++; }
if (r > 0 && stdoutput) {
so_size += r;
@@ -839,17 +919,17 @@ commandrvf (char **stdoutput, char **stderror, int flags,
}
}
if (FD_ISSET (se_fd[0], &rset2)) { /* something on stderr */
r = read (se_fd[0], buf, sizeof buf);
if (FD_ISSET (se_fd[PIPE_READ], &rset2)) { /* something on stderr */
r = read (se_fd[PIPE_READ], buf, sizeof buf);
if (r == -1) {
perror ("read");
goto quit;
}
if (r == 0) { FD_CLR (se_fd[0], &rset); quit++; }
if (r == 0) { FD_CLR (se_fd[PIPE_READ], &rset); quit++; }
if (r > 0) {
if (verbose)
ignore_value (write (2, buf, r));
ignore_value (write (STDERR_FILENO, buf, r));
if (stderror) {
se_size += r;
@@ -865,8 +945,8 @@ commandrvf (char **stdoutput, char **stderror, int flags,
}
}
close (so_fd[0]);
close (se_fd[0]);
close (so_fd[PIPE_READ]);
close (se_fd[PIPE_READ]);
/* Make sure the output buffers are \0-terminated. Also remove any
* trailing \n characters from the error buffer (not from stdout).
@@ -890,27 +970,16 @@ commandrvf (char **stdoutput, char **stderror, int flags,
*stderror = q;
if (*stderror) {
(*stderror)[se_size] = '\0';
se_size--;
while (se_size >= 0 && (*stderror)[se_size] == '\n')
(*stderror)[se_size--] = '\0';
while (se_size > 0 && (*stderror)[se_size-1] == '\n') {
se_size--;
(*stderror)[se_size] = '\0';
}
}
}
if (flag_copy_stdin) {
/* Check copy process didn't fail. */
if (waitpid (stdin_pid, &r, 0) != stdin_pid) {
perror ("waitpid");
kill (pid, 9);
waitpid (pid, NULL, 0);
return -1;
}
if (!WIFEXITED (r) || WEXITSTATUS (r) != 0) {
fprintf (stderr, "failed copying from input file, see earlier messages\n");
kill (pid, 9);
waitpid (pid, NULL, 0);
return -1;
}
if (flag_copy_stdin && close (flag_copy_fd) == -1) {
perror ("close");
return -1;
}
/* Get the exit status of the command. */
@@ -946,8 +1015,7 @@ commandrvf (char **stdoutput, char **stderror, int flags,
char **
split_lines (char *str)
{
char **lines = NULL;
int size = 0, alloc = 0;
DECLARE_STRINGSBUF (lines);
char *p, *pend;
if (STREQ (str, ""))
@@ -965,7 +1033,7 @@ split_lines (char *str)
pend++;
}
if (add_string (&lines, &size, &alloc, p) == -1) {
if (add_string (&lines, p) == -1) {
return NULL;
}
@@ -973,10 +1041,10 @@ split_lines (char *str)
}
empty_list:
if (add_string (&lines, &size, &alloc, NULL) == -1)
if (end_stringsbuf (&lines) == -1)
return NULL;
return lines;
return lines.argv;
}
/* Skip leading and trailing whitespace, updating the original string
@@ -1074,7 +1142,7 @@ device_name_translation (char *device)
{
int fd;
fd = open (device, O_RDONLY);
fd = open (device, O_RDONLY|O_CLOEXEC);
if (fd >= 0) {
close_ok:
close (fd);
@@ -1089,12 +1157,12 @@ device_name_translation (char *device)
return -1;
device[5] = 'h'; /* /dev/hd (old IDE driver) */
fd = open (device, O_RDONLY);
fd = open (device, O_RDONLY|O_CLOEXEC);
if (fd >= 0)
goto close_ok;
device[5] = 'v'; /* /dev/vd (for virtio devices) */
fd = open (device, O_RDONLY);
fd = open (device, O_RDONLY|O_CLOEXEC);
if (fd >= 0)
goto close_ok;
@@ -1102,6 +1170,83 @@ device_name_translation (char *device)
return -1;
}
/* Parse the mountable descriptor for a btrfs subvolume. Don't call this
* directly - use the RESOLVE_MOUNTABLE macro.
*
* A btrfs subvolume is given as:
*
* btrfsvol:/dev/sda3/root
*
* where /dev/sda3 is a block device containing a btrfs filesystem, and root is
* the name of a subvolume on it. This function is passed the string following
* 'btrfsvol:'.
*/
int
parse_btrfsvol (char *desc, mountable_t *mountable)
{
mountable->type = MOUNTABLE_BTRFSVOL;
char *device = desc;
if (strncmp (device, "/dev/", strlen("/dev/")) == -1)
return -1;
char *volume = NULL;
char *slash = device + strlen("/dev/") - 1;
while ((slash = strchr (slash + 1, '/'))) {
*slash = '\0';
struct stat statbuf;
if (stat (device, &statbuf) == -1) {
perror (device);
return -1;
}
if (!S_ISDIR (statbuf.st_mode) &&
!is_root_device_stat(&statbuf) &&
device_name_translation (device) == 0)
{
volume = slash + 1;
break;
}
*slash = '/';
}
if (!volume) return -1;
mountable->device = device;
mountable->volume = volume;
return 0;
}
/* Convert a mountable_t back to its string representation
*
* This function can be used in an error path, and must not call
* reply_with_error().
*/
char *
mountable_to_string (const mountable_t *mountable)
{
char *desc;
switch (mountable->type) {
case MOUNTABLE_DEVICE:
case MOUNTABLE_PATH:
return strdup (mountable->device);
case MOUNTABLE_BTRFSVOL:
if (asprintf(&desc, "btrfsvol:%s/%s",
mountable->device, mountable->volume) == -1)
return NULL;
return desc;
default:
return NULL;
}
}
/* Check program exists and is executable on $PATH. Actually, we
* just assume PATH contains the default entries (see main() above).
*/
@@ -1121,6 +1266,52 @@ prog_exists (const char *prog)
return 0;
}
/* Pass a template such as "/sysroot/XXXXXXXX.XXX". This updates the
* template to contain a randomly named file. Any 'X' characters
* after the final '/' are replaced with random characters.
*
* Notes: You should probably use an 8.3 path, so it's compatible with
* all filesystems including basic FAT. Also this only substitutes
* lowercase ASCII letters and numbers, again for compatibility with
* lowest common denominator filesystems.
*
* This doesn't create a file or check whether or not the file exists
* (it would be extremely unlikely to exist as long as the RNG is
* working).
*
* If there is an error, -1 is returned.
*/
int
random_name (char *template)
{
int fd;
unsigned char c;
char *p;
fd = open ("/dev/urandom", O_RDONLY|O_CLOEXEC);
if (fd == -1)
return -1;
p = strrchr (template, '/');
if (p == NULL)
abort (); /* internal error - bad template */
while (*p) {
if (*p == 'X') {
if (read (fd, &c, 1) != 1) {
close (fd);
return -1;
}
*p = "0123456789abcdefghijklmnopqrstuvwxyz"[c % 36];
}
p++;
}
close (fd);
return 0;
}
/* LVM and other commands aren't synchronous, especially when udev is
* involved. eg. You can create or remove some device, but the /dev
* device node won't appear until some time later. This means that
@@ -1128,16 +1319,33 @@ prog_exists (const char *prog)
*
* Use 'udevadm settle' after certain commands, but don't be too
* fussed if it fails.
*
* 'udevsettle' was the old name for this command (RHEL 5). This was
* deprecated in favour of 'udevadm settle'. The old 'udevsettle'
* command was left as a symlink. Then in Fedora 13 the old symlink
* remained but it stopped working (RHBZ#548121), so we have to be
* careful not to assume that we can use 'udevsettle' if it exists.
*/
void
udev_settle (void)
{
(void) command (NULL, NULL, "udevadm", "settle", NULL);
(void) command (NULL, NULL, "udevsettle", NULL);
(void) command (NULL, NULL, str_udevadm, "settle", NULL);
}
/* Use by the CLEANUP_* macros. Do not call these directly. */
void
cleanup_free (void *ptr)
{
free (* (void **) ptr);
}
void
cleanup_free_string_list (void *ptr)
{
free_strings (* (char ***) ptr);
}
void
cleanup_unlink_free (void *ptr)
{
char *filename = * (char **) ptr;
if (filename) {
unlink (filename);
free (filename);
}
}

103
daemon/guestfsd.pod Normal file
View File

@@ -0,0 +1,103 @@
=encoding utf8
=head1 NAME
guestfsd - guestfs daemon
=head1 SYNOPSIS
guestfsd [-r] [-v|--verbose]
=head1 DESCRIPTION
C<guestfsd> is the libguestfs daemon. Normal users never need to run
this program explicitly. This man page discusses what C<guestfsd>
does in both the libguestfs appliance and when using libguestfs live.
=head2 LIBGUESTFS APPLIANCE
For the architecture of the libguestfs appliance, see
L<guestfs(3)/ARCHITECTURE>.
After the appliance boots, the C</init> script in the appliance starts
C<guestfsd> with no arguments. C<guestfsd> opens the virtio-serial
port on a known path (see L</FILES>). It initiates the protocol (see
L<guestfs(3)/COMMUNICATION PROTOCOL>) and processes requests one at a
time from the library until the appliance is destroyed.
Filesystems are mounted under C</sysroot> and all filesystem
operations happen relative to this directory.
=head2 LIBGUESTFS LIVE
In the libguestfs live case, C<guestfsd -r> is started from the
rc-scripts, systemd, etc.
The C<-r> option causes the daemon to operate on the root filesystem
instead of C</sysroot>.
Currently (because of limitations in virtio-serial) only one client
can connect at a time, and C<guestfsd> must be restarted after each
client disconnects. If libguestfs live were changed to use a
different transport such as TCP/IP then this limitation could be
removed.
=head1 OPTIONS
=over 4
=item B<-?>
=item B<--help>
Display brief help.
=item B<-r>
Set the root filesystem to be C</> (instead of the default which is
C</sysroot>). Also do not unmount filesystems when the daemon exits.
This option is used to enable libguestfs live.
=item B<-v>
=item B<--verbose>
Enable verbose messages for debugging.
The verbose flag is also set if the Linux command line contains the
substring C<guestfs_verbose=1>.
=back
=head1 EXIT STATUS
This program returns 0 if successful, or non-zero if there was an
error.
=head1 FILES
=over 4
=item C</dev/virtio-ports/org.libguestfs.channel.0>
The virtio serial port which C<guestfsd> connects to.
=item C</proc/cmdline>
The Linux command line is parsed to discover C<guestfs_*> flags.
=back
=head1 SEE ALSO
L<guestfs(3)>,
L<http://libguestfs.org/>.
=head1 AUTHOR
Richard W.M. Jones L<http://people.redhat.com/~rjones/>
=head1 COPYRIGHT
Copyright (C) 2009-2013 Red Hat Inc.

View File

@@ -31,12 +31,12 @@
static char **
headtail (const char *prog, const char *flag, const char *n, const char *path)
{
char *out, *err;
CLEANUP_FREE char *out = NULL, *err = NULL;
int fd, flags, r;
char **lines;
CHROOT_IN;
fd = open (path, O_RDONLY);
fd = open (path, O_RDONLY|O_CLOEXEC);
CHROOT_OUT;
if (fd == -1) {
@@ -48,13 +48,9 @@ headtail (const char *prog, const char *flag, const char *n, const char *path)
r = commandf (&out, &err, flags, prog, flag, n, NULL);
if (r == -1) {
reply_with_error ("%s %s %s: %s", prog, flag, n, err);
free (out);
free (err);
return NULL;
}
free (err);
#if 0
/* Split it at the first whitespace. */
len = strcspn (out, " \t\n");
@@ -62,7 +58,6 @@ headtail (const char *prog, const char *flag, const char *n, const char *path)
#endif
lines = split_lines (out);
free (out);
if (lines == NULL) return NULL;
return lines;

View File

@@ -31,10 +31,11 @@ char *
do_hexdump (const char *path)
{
int fd, flags, r;
char *out, *err;
char *out;
CLEANUP_FREE char *err = NULL;
CHROOT_IN;
fd = open (path, O_RDONLY);
fd = open (path, O_RDONLY|O_CLOEXEC);
CHROOT_OUT;
if (fd == -1) {
@@ -46,12 +47,9 @@ do_hexdump (const char *path)
r = commandf (&out, &err, flags, "hexdump", "-C", NULL);
if (r == -1) {
reply_with_error ("%s: %s", path, err);
free (err);
free (out);
return NULL;
}
free (err);
return out; /* caller frees */
}

414
daemon/hivex.c Normal file
View File

@@ -0,0 +1,414 @@
/* libguestfs - the guestfsd daemon
* Copyright (C) 2012 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 <string.h>
#include <limits.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include "guestfs_protocol.h"
#include "daemon.h"
#include "actions.h"
#include "optgroups.h"
#ifdef HAVE_HIVEX
#include <hivex.h>
int
optgroup_hivex_available (void)
{
return 1;
}
/* The hivex handle. As with Augeas, there is one per guestfs handle /
* daemon.
*/
static hive_h *h = NULL;
/* Clean up the hivex handle on daemon exit. */
static void hivex_finalize (void) __attribute__((destructor));
static void
hivex_finalize (void)
{
if (h) {
hivex_close (h);
h = NULL;
}
}
#define NEED_HANDLE(errcode) \
do { \
if (!h) { \
reply_with_error ("%s: you must call 'hivex-open' first to initialize the hivex handle", __func__); \
return (errcode); \
} \
} \
while (0)
/* Takes optional arguments, consult optargs_bitmask. */
int
do_hivex_open (const char *filename, int verbose, int debug, int write)
{
CLEANUP_FREE char *buf = NULL;
int flags = 0;
if (h) {
hivex_close (h);
h = NULL;
}
buf = sysroot_path (filename);
if (!buf) {
reply_with_perror ("malloc");
return -1;
}
if (optargs_bitmask & GUESTFS_HIVEX_OPEN_VERBOSE_BITMASK) {
if (verbose)
flags |= HIVEX_OPEN_VERBOSE;
}
if (optargs_bitmask & GUESTFS_HIVEX_OPEN_DEBUG_BITMASK) {
if (debug)
flags |= HIVEX_OPEN_DEBUG;
}
if (optargs_bitmask & GUESTFS_HIVEX_OPEN_WRITE_BITMASK) {
if (write)
flags |= HIVEX_OPEN_WRITE;
}
h = hivex_open (buf, flags);
if (!h) {
reply_with_perror ("hivex failed to open %s", filename);
return -1;
}
return 0;
}
int
do_hivex_close (void)
{
NEED_HANDLE (-1);
hivex_close (h);
h = NULL;
return 0;
}
int64_t
do_hivex_root (void)
{
int64_t r;
NEED_HANDLE (-1);
r = hivex_root (h);
if (r == 0) {
reply_with_perror ("failed");
return -1;
}
return r;
}
char *
do_hivex_node_name (int64_t nodeh)
{
char *r;
NEED_HANDLE (NULL);
r = hivex_node_name (h, nodeh);
if (r == NULL) {
reply_with_perror ("failed");
return NULL;
}
return r;
}
guestfs_int_hivex_node_list *
do_hivex_node_children (int64_t nodeh)
{
guestfs_int_hivex_node_list *ret;
CLEANUP_FREE hive_node_h *r = NULL;
size_t i, len;
NEED_HANDLE (NULL);
r = hivex_node_children (h, nodeh);
if (r == NULL) {
reply_with_perror ("failed");
return NULL;
}
len = 0;
for (i = 0; r[i] != 0; ++i)
len++;
ret = malloc (sizeof *ret);
if (!ret) {
reply_with_perror ("malloc");
return NULL;
}
ret->guestfs_int_hivex_node_list_len = len;
ret->guestfs_int_hivex_node_list_val =
malloc (len * sizeof (guestfs_int_hivex_node));
if (ret->guestfs_int_hivex_node_list_val == NULL) {
reply_with_perror ("malloc");
free (ret);
return NULL;
}
for (i = 0; i < len; ++i)
ret->guestfs_int_hivex_node_list_val[i].hivex_node_h = r[i];
return ret;
}
int64_t
do_hivex_node_get_child (int64_t nodeh, const char *name)
{
int64_t r;
NEED_HANDLE (-1);
errno = 0;
r = hivex_node_get_child (h, nodeh, name);
if (r == 0 && errno != 0) {
reply_with_perror ("failed");
return -1;
}
return r;
}
int64_t
do_hivex_node_parent (int64_t nodeh)
{
int64_t r;
NEED_HANDLE (-1);
r = hivex_node_parent (h, nodeh);
if (r == 0) {
reply_with_perror ("failed");
return -1;
}
return r;
}
guestfs_int_hivex_value_list *
do_hivex_node_values (int64_t nodeh)
{
guestfs_int_hivex_value_list *ret;
CLEANUP_FREE hive_value_h *r = NULL;
size_t i, len;
NEED_HANDLE (NULL);
r = hivex_node_values (h, nodeh);
if (r == NULL) {
reply_with_perror ("failed");
return NULL;
}
len = 0;
for (i = 0; r[i] != 0; ++i)
len++;
ret = malloc (sizeof *ret);
if (!ret) {
reply_with_perror ("malloc");
return NULL;
}
ret->guestfs_int_hivex_value_list_len = len;
ret->guestfs_int_hivex_value_list_val =
malloc (len * sizeof (guestfs_int_hivex_value));
if (ret->guestfs_int_hivex_value_list_val == NULL) {
reply_with_perror ("malloc");
free (ret);
return NULL;
}
for (i = 0; i < len; ++i)
ret->guestfs_int_hivex_value_list_val[i].hivex_value_h = (int64_t) r[i];
return ret;
}
int64_t
do_hivex_node_get_value (int64_t nodeh, const char *key)
{
int64_t r;
NEED_HANDLE (-1);
errno = 0;
r = hivex_node_get_value (h, nodeh, key);
if (r == 0 && errno != 0) {
reply_with_perror ("failed");
return -1;
}
return r;
}
char *
do_hivex_value_key (int64_t valueh)
{
char *r;
NEED_HANDLE (NULL);
r = hivex_value_key (h, valueh);
if (r == NULL) {
reply_with_perror ("failed");
return NULL;
}
return r;
}
int64_t
do_hivex_value_type (int64_t valueh)
{
hive_type r;
NEED_HANDLE (-1);
if (hivex_value_type (h, valueh, &r, NULL) == -1) {
reply_with_perror ("failed");
return -1;
}
return r;
}
char *
do_hivex_value_value (int64_t valueh, size_t *size_r)
{
char *r;
size_t size;
NEED_HANDLE (NULL);
r = hivex_value_value (h, valueh, NULL, &size);
if (r == NULL) {
reply_with_perror ("failed");
return NULL;
}
*size_r = size;
return r;
}
int
do_hivex_commit (const char *filename)
{
CLEANUP_FREE char *buf = NULL;
NEED_HANDLE (-1);
/* The 'filename' parameter is an optional string, and in most
* cases will be NULL.
*/
if (filename) {
buf = sysroot_path (filename);
if (!buf) {
reply_with_perror ("malloc");
return -1;
}
if (hivex_commit (h, buf, 0) == -1) {
reply_with_perror ("%s: commit failed", filename);
return -1;
}
}
else {
if (hivex_commit (h, NULL, 0) == -1) {
reply_with_perror ("commit failed");
return -1;
}
}
return 0;
}
int64_t
do_hivex_node_add_child (int64_t parent, const char *name)
{
int64_t r;
NEED_HANDLE (-1);
r = hivex_node_add_child (h, parent, name);
if (r == 0) {
reply_with_perror ("failed");
return -1;
}
return r;
}
int
do_hivex_node_delete_child (int64_t nodeh)
{
NEED_HANDLE (-1);
if (hivex_node_delete_child (h, nodeh) == -1) {
reply_with_perror ("failed");
return -1;
}
return 0;
}
int
do_hivex_node_set_value (int64_t nodeh,
const char *key, int64_t t,
const char *val, size_t val_size)
{
const hive_set_value v =
{ .key = (char *) key, .t = t, .len = val_size, .value = (char *) val };
NEED_HANDLE (-1);
if (hivex_node_set_value (h, nodeh, &v, 0) == -1) {
reply_with_perror ("failed");
return -1;
}
return 0;
}
#else /* !HAVE_HIVEX */
OPTGROUP_HIVEX_NOT_AVAILABLE
#endif /* !HAVE_HIVEX */

153
daemon/hotplug.c Normal file
View File

@@ -0,0 +1,153 @@
/* libguestfs - the guestfsd daemon
* Copyright (C) 2012 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 <errno.h>
#include <time.h>
#include "guestfs_protocol.h"
#include "daemon.h"
#include "actions.h"
#define HOT_ADD_TIMEOUT 30 /* seconds */
#define HOT_REMOVE_TIMEOUT HOT_ADD_TIMEOUT
static void
hotplug_error (const char *op, const char *path, const char *verb,
int timeout)
{
reply_with_error ("%s drive: '%s' did not %s after %d seconds: "
"this could mean that virtio-scsi (in qemu or kernel) "
"or udev is not working",
op, path, verb, timeout);
}
/* Wait for /dev/disk/guestfs/<label> to appear. Timeout (and error)
* if it doesn't appear after a reasonable length of time.
*/
int
do_internal_hot_add_drive (const char *label)
{
time_t start_t, now_t;
size_t len = strlen (label);
char path[len+64];
int r;
snprintf (path, len+64, "/dev/disk/guestfs/%s", label);
time (&start_t);
while (time (&now_t) - start_t <= HOT_ADD_TIMEOUT) {
udev_settle ();
r = access (path, F_OK);
if (r == -1 && errno != ENOENT) {
reply_with_perror ("%s", path);
return -1;
}
if (r == 0)
return 0;
sleep (1);
}
hotplug_error ("hot-add", path, "appear", HOT_ADD_TIMEOUT);
return -1;
}
GUESTFSD_EXT_CMD(str_fuser, fuser);
/* This function is called before a drive is hot-unplugged. */
int
do_internal_hot_remove_drive_precheck (const char *label)
{
size_t len = strlen (label);
char path[len+64];
int r;
CLEANUP_FREE char *out = NULL, *err = NULL;
/* Ensure there are no requests in flight (thanks Paolo Bonzini). */
udev_settle ();
sync_disks ();
snprintf (path, len+64, "/dev/disk/guestfs/%s", label);
r = commandr (&out, &err, str_fuser, "-v", "-m", path, NULL);
if (r == -1) {
reply_with_error ("fuser: %s: %s", path, err);
return -1;
}
/* "fuser returns a non-zero return code if none of the specified
* files is accessed or in case of a fatal error. If at least one
* access has been found, fuser returns zero."
*/
if (r == 0) {
reply_with_error ("disk with label '%s' is in use "
"(eg. mounted or belongs to a volume group)", label);
/* Useful for debugging when a drive cannot be unplugged. */
if (verbose)
fprintf (stderr, "%s\n", out);
return -1;
}
return 0;
}
/* This function is called after a drive is hot-unplugged. It checks
* that it has really gone and udev has finished processing the
* events, in case the user immediately hotplugs a drive with an
* identical label.
*/
int
do_internal_hot_remove_drive (const char *label)
{
time_t start_t, now_t;
size_t len = strlen (label);
char path[len+64];
int r;
snprintf (path, len+64, "/dev/disk/guestfs/%s", label);
time (&start_t);
while (time (&now_t) - start_t <= HOT_REMOVE_TIMEOUT) {
udev_settle ();
r = access (path, F_OK);
if (r == -1) {
if (errno != ENOENT) {
reply_with_perror ("%s", path);
return -1;
}
/* else udev has removed the file, so we can return */
return 0;
}
sleep (1);
}
hotplug_error ("hot-remove", path, "disappear", HOT_REMOVE_TIMEOUT);
return -1;
}

View File

@@ -30,18 +30,21 @@
#include "daemon.h"
#include "actions.h"
GUESTFSD_EXT_CMD(str_zcat, zcat);
GUESTFSD_EXT_CMD(str_cpio, cpio);
char **
do_initrd_list (const char *path)
{
FILE *fp;
char *cmd;
char filename[PATH_MAX];
char **filenames = NULL;
int size = 0, alloc = 0;
size_t len;
CLEANUP_FREE char *cmd = NULL;
DECLARE_STRINGSBUF (filenames);
CLEANUP_FREE char *filename = NULL;
size_t allocsize;
ssize_t len;
/* "zcat /sysroot/<path> | cpio --quiet -it", but path must be quoted. */
if (asprintf_nowarn (&cmd, "zcat %R | cpio --quiet -it", path) == -1) {
if (asprintf_nowarn (&cmd, "%s %R | %s --quiet -it", str_zcat, path, str_cpio) == -1) {
reply_with_perror ("asprintf");
return NULL;
}
@@ -52,67 +55,67 @@ do_initrd_list (const char *path)
fp = popen (cmd, "r");
if (fp == NULL) {
reply_with_perror ("popen: %s", cmd);
free (cmd);
return NULL;
}
free (cmd);
while (fgets (filename, sizeof filename, fp) != NULL) {
len = strlen (filename);
allocsize = 0;
while ((len = getline (&filename, &allocsize, fp)) != -1) {
if (len > 0 && filename[len-1] == '\n')
filename[len-1] = '\0';
if (add_string (&filenames, &size, &alloc, filename) == -1) {
if (add_string (&filenames, filename) == -1) {
pclose (fp);
return NULL;
}
}
if (add_string (&filenames, &size, &alloc, NULL) == -1) {
if (end_stringsbuf (&filenames) == -1) {
pclose (fp);
return NULL;
}
if (pclose (fp) != 0) {
reply_with_perror ("pclose");
free_strings (filenames);
free_stringslen (filenames.argv, filenames.size);
return NULL;
}
return filenames;
return filenames.argv;
}
char *
do_initrd_cat (const char *path, const char *filename, size_t *size_r)
{
char tmpdir[] = "/tmp/initrd-cat-XXXXXX";
CLEANUP_FREE char *cmd;
struct stat statbuf;
int fd, r;
char *ret = NULL;
CLEANUP_FREE char *fullpath = NULL;
if (mkdtemp (tmpdir) == NULL) {
reply_with_perror ("mkdtemp");
return NULL;
}
/* "zcat /sysroot/<path> | cpio --quiet -id file", but paths must be quoted */
char *cmd;
if (asprintf_nowarn (&cmd, "cd %Q && zcat %R | cpio --quiet -id %Q",
tmpdir, path, filename) == -1) {
reply_with_perror ("asprintf");
rmdir (tmpdir);
return NULL;
}
/* Extract file into temporary directory. This may create subdirs.
* It's also possible that this doesn't create anything at all
* (eg. if the named file does not exist in the cpio archive) --
* cpio is silent in this case.
*/
int r = system (cmd);
if (r == -1) {
reply_with_perror ("command failed: %s", cmd);
free (cmd);
/* "zcat /sysroot/<path> | cpio --quiet -id file", but paths must be quoted */
if (asprintf_nowarn (&cmd, "cd %Q && zcat %R | cpio --quiet -id %Q",
tmpdir, path, filename) == -1) {
reply_with_perror ("asprintf");
rmdir (tmpdir);
return NULL;
}
r = system (cmd);
if (r == -1) {
reply_with_perror ("command failed: %s", cmd);
rmdir (tmpdir);
return NULL;
}
free (cmd);
if (WEXITSTATUS (r) != 0) {
reply_with_perror ("command failed with return code %d",
WEXITSTATUS (r));
@@ -120,14 +123,15 @@ do_initrd_cat (const char *path, const char *filename, size_t *size_r)
return NULL;
}
/* Construct the expected name of the extracted file. */
if (asprintf (&fullpath, "%s/%s", tmpdir, filename) == -1) {
reply_with_perror ("asprintf");
rmdir (tmpdir);
return NULL;
}
/* See if we got a file. */
char fullpath[PATH_MAX];
snprintf (fullpath, sizeof fullpath, "%s/%s", tmpdir, filename);
struct stat statbuf;
int fd;
fd = open (fullpath, O_RDONLY);
fd = open (fullpath, O_RDONLY|O_CLOEXEC);
if (fd == -1) {
reply_with_perror ("open: %s:%s", path, filename);
rmdir (tmpdir);
@@ -137,8 +141,6 @@ do_initrd_cat (const char *path, const char *filename, size_t *size_r)
/* From this point, we know the file exists, so we require full
* cleanup.
*/
char *ret = NULL;
if (fstat (fd, &statbuf) == -1) {
reply_with_perror ("fstat: %s:%s", path, filename);
goto cleanup;
@@ -187,8 +189,7 @@ do_initrd_cat (const char *path, const char *filename, size_t *size_r)
/* Remove the file. */
if (unlink (fullpath) == -1) {
fprintf (stderr, "unlink: ");
perror (fullpath);
fprintf (stderr, "unlink: %s: %m\n", fullpath);
/* non-fatal */
}
@@ -198,8 +199,7 @@ do_initrd_cat (const char *path, const char *filename, size_t *size_r)
if (!p) break;
*p = '\0';
if (rmdir (fullpath) == -1) {
fprintf (stderr, "rmdir: ");
perror (fullpath);
fprintf (stderr, "rmdir: %s: %m\n", fullpath);
/* non-fatal */
}
} while (STRNEQ (fullpath, tmpdir));

View File

@@ -1,5 +1,5 @@
/* libguestfs - the guestfsd daemon
* Copyright (C) 2009-2012 Red Hat Inc.
* Copyright (C) 2009-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
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <unistd.h>
#include <fcntl.h>
@@ -34,12 +35,17 @@
#include "optgroups.h"
#ifdef HAVE_SYS_INOTIFY_H
GUESTFSD_EXT_CMD(str_sort, sort);
/* 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;
/* Because of use of arbitrary offsets within inotify_buf. */
#pragma GCC diagnostic ignored "-Wcast-align"
/* Clean up the inotify handle on daemon exit. */
static void inotify_finalize (void) __attribute__((destructor));
static void
@@ -56,13 +62,6 @@ optgroup_inotify_available (void)
{
return 1;
}
#else /* !HAVE_SYS_INOTIFY_H */
int
optgroup_inotify_available (void)
{
return 0;
}
#endif
/* Because inotify_init does NEED_ROOT, NEED_INOTIFY implies NEED_ROOT. */
#define NEED_INOTIFY(errcode) \
@@ -78,7 +77,6 @@ optgroup_inotify_available (void)
int
do_inotify_init (int max_events)
{
#ifdef HAVE_SYS_INOTIFY_H
FILE *fp;
NEED_ROOT (, return -1);
@@ -129,15 +127,11 @@ do_inotify_init (int max_events)
#endif
return 0;
#else
NOT_AVAILABLE (-1);
#endif
}
int
do_inotify_close (void)
{
#ifdef HAVE_SYS_INOTIFY_H
NEED_INOTIFY (-1);
if (inotify_fd == -1) {
@@ -154,17 +148,13 @@ do_inotify_close (void)
inotify_posn = 0;
return 0;
#else
NOT_AVAILABLE (-1);
#endif
}
int64_t
do_inotify_add_watch (const char *path, int mask)
{
#ifdef HAVE_SYS_INOTIFY_H
int64_t r;
char *buf;
CLEANUP_FREE char *buf = NULL;
NEED_INOTIFY (-1);
@@ -175,22 +165,17 @@ do_inotify_add_watch (const char *path, int mask)
}
r = inotify_add_watch (inotify_fd, buf, mask);
free (buf);
if (r == -1) {
reply_with_perror ("%s", path);
return -1;
}
return r;
#else
NOT_AVAILABLE (-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) {
@@ -199,15 +184,11 @@ do_inotify_rm_watch (int wd)
}
return 0;
#else
NOT_AVAILABLE (-1);
#endif
}
guestfs_int_inotify_event_list *
do_inotify_read (void)
{
#ifdef HAVE_SYS_INOTIFY_H
int space;
guestfs_int_inotify_event_list *ret;
@@ -264,6 +245,12 @@ do_inotify_read (void)
#error "this code needs fixing so it works on non-GCC compilers"
#endif
/* Check event->len is reasonable (note the field is uint32_t). */
if (event->len > PATH_MAX) {
reply_with_error ("event->len = %" PRIu32 " > PATH_MAX", event->len);
goto error;
}
np = realloc (ret->guestfs_int_inotify_event_list_val,
(ret->guestfs_int_inotify_event_list_len + 1) *
sizeof (guestfs_int_inotify_event));
@@ -313,17 +300,12 @@ do_inotify_read (void)
xdr_free ((xdrproc_t) xdr_guestfs_int_inotify_event_list, (char *) ret);
free (ret);
return NULL;
#else
NOT_AVAILABLE (NULL);
#endif
}
char **
do_inotify_files (void)
{
#ifdef HAVE_SYS_INOTIFY_H
char **ret = NULL;
int size = 0, alloc = 0;
DECLARE_STRINGSBUF (ret);
unsigned int i;
FILE *fp = NULL;
guestfs_int_inotify_event_list *events;
@@ -340,7 +322,7 @@ do_inotify_files (void)
return NULL;
}
snprintf (cmd, sizeof cmd, "sort -u > %s", tempfile);
snprintf (cmd, sizeof cmd, "%s -u > %s", str_sort, tempfile);
fp = popen (cmd, "w");
if (fp == NULL) {
@@ -380,23 +362,23 @@ do_inotify_files (void)
}
while (fgets (buf, sizeof buf, fp) != NULL) {
int len = strlen (buf);
size_t len = strlen (buf);
if (len > 0 && buf[len-1] == '\n')
buf[len-1] = '\0';
if (add_string (&ret, &size, &alloc, buf) == -1)
if (add_string (&ret, buf) == -1)
goto error;
}
fclose (fp); /* implicitly closes fd */
fp = NULL;
if (add_string (&ret, &size, &alloc, NULL) == -1)
if (end_stringsbuf (&ret) == -1)
goto error;
unlink (tempfile);
return ret;
return ret.argv;
error:
if (fp != NULL)
@@ -404,7 +386,10 @@ do_inotify_files (void)
unlink (tempfile);
return NULL;
#else
NOT_AVAILABLE (NULL);
#endif
}
#else /* !HAVE_SYS_INOTIFY_H */
OPTGROUP_INOTIFY_NOT_AVAILABLE
#endif

281
daemon/isoinfo.c Normal file
View File

@@ -0,0 +1,281 @@
/* libguestfs - the guestfsd daemon
* Copyright (C) 2012 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 <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include "guestfs_protocol.h"
#include "daemon.h"
#include "actions.h"
GUESTFSD_EXT_CMD(str_isoinfo, isoinfo);
static int
parse_uint32 (uint32_t *ret, const char *str)
{
uint32_t r;
if (sscanf (str, "%" SCNu32, &r) != 1) {
reply_with_error ("cannot parse numeric field from isoinfo: %s", str);
return -1;
}
*ret = r;
return 0;
}
/* This is always in a fixed format:
* "2012 03 16 11:05:46.00"
* or if the field is not present, then:
* "0000 00 00 00:00:00.00"
*/
static int
parse_time_t (int64_t *ret, const char *str)
{
struct tm tm;
time_t r;
if (STREQ (str, "0000 00 00 00:00:00.00") ||
STREQ (str, " : : . ")) {
*ret = -1;
return 0;
}
if (sscanf (str, "%04d %02d %02d %02d:%02d:%02d",
&tm.tm_year, &tm.tm_mon, &tm.tm_mday,
&tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) {
reply_with_error ("cannot parse date from isoinfo: %s", str);
return -1;
}
/* Adjust fields. */
tm.tm_year -= 1900;
tm.tm_mon--;
tm.tm_isdst = -1;
/* Convert to time_t. */
r = timegm (&tm);
if (r == -1) {
reply_with_error ("invalid date or time: %s", str);
return -1;
}
*ret = r;
return 0;
}
static guestfs_int_isoinfo *
parse_isoinfo (char **lines)
{
guestfs_int_isoinfo *ret;
size_t i;
ret = calloc (1, sizeof *ret);
if (ret == NULL) {
reply_with_perror ("calloc");
return NULL;
}
/* Default each int field in the struct to -1. */
ret->iso_volume_space_size = (uint32_t) -1;
ret->iso_volume_set_size = (uint32_t) -1;
ret->iso_volume_sequence_number = (uint32_t) -1;
ret->iso_logical_block_size = (uint32_t) -1;
ret->iso_volume_creation_t = -1;
ret->iso_volume_modification_t = -1;
ret->iso_volume_expiration_t = -1;
ret->iso_volume_effective_t = -1;
for (i = 0; lines[i] != NULL; ++i) {
if (STRPREFIX (lines[i], "System id: ")) {
ret->iso_system_id = strdup (&lines[i][11]);
if (ret->iso_system_id == NULL) goto error;
}
else if (STRPREFIX (lines[i], "Volume id: ")) {
ret->iso_volume_id = strdup (&lines[i][11]);
if (ret->iso_volume_id == NULL) goto error;
}
else if (STRPREFIX (lines[i], "Volume set id: ")) {
ret->iso_volume_set_id = strdup (&lines[i][15]);
if (ret->iso_volume_set_id == NULL) goto error;
}
else if (STRPREFIX (lines[i], "Publisher id: ")) {
ret->iso_publisher_id = strdup (&lines[i][14]);
if (ret->iso_publisher_id == NULL) goto error;
}
else if (STRPREFIX (lines[i], "Data preparer id: ")) {
ret->iso_data_preparer_id = strdup (&lines[i][18]);
if (ret->iso_data_preparer_id == NULL) goto error;
}
else if (STRPREFIX (lines[i], "Application id: ")) {
ret->iso_application_id = strdup (&lines[i][16]);
if (ret->iso_application_id == NULL) goto error;
}
else if (STRPREFIX (lines[i], "Copyright File id: ")) {
ret->iso_copyright_file_id = strdup (&lines[i][19]);
if (ret->iso_copyright_file_id == NULL) goto error;
}
else if (STRPREFIX (lines[i], "Abstract File id: ")) {
ret->iso_abstract_file_id = strdup (&lines[i][18]);
if (ret->iso_abstract_file_id == NULL) goto error;
}
else if (STRPREFIX (lines[i], "Bibliographic File id: ")) {
ret->iso_bibliographic_file_id = strdup (&lines[i][23]);
if (ret->iso_bibliographic_file_id == NULL) goto error;
}
else if (STRPREFIX (lines[i], "Volume size is: ")) {
if (parse_uint32 (&ret->iso_volume_space_size, &lines[i][16]) == -1)
goto error;
}
else if (STRPREFIX (lines[i], "Volume set size is: ")) {
if (parse_uint32 (&ret->iso_volume_set_size, &lines[i][20]) == -1)
goto error;
}
else if (STRPREFIX (lines[i], "Volume set sequence number is: ")) {
if (parse_uint32 (&ret->iso_volume_sequence_number, &lines[i][31]) == -1)
goto error;
}
else if (STRPREFIX (lines[i], "Logical block size is: ")) {
if (parse_uint32 (&ret->iso_logical_block_size, &lines[i][23]) == -1)
goto error;
}
else if (STRPREFIX (lines[i], "Creation Date: ")) {
if (parse_time_t (&ret->iso_volume_creation_t, &lines[i][19]) == -1)
goto error;
}
else if (STRPREFIX (lines[i], "Modification Date: ")) {
if (parse_time_t (&ret->iso_volume_modification_t, &lines[i][19]) == -1)
goto error;
}
else if (STRPREFIX (lines[i], "Expiration Date: ")) {
if (parse_time_t (&ret->iso_volume_expiration_t, &lines[i][19]) == -1)
goto error;
}
else if (STRPREFIX (lines[i], "Effective Date: ")) {
if (parse_time_t (&ret->iso_volume_effective_t, &lines[i][19]) == -1)
goto error;
}
}
/* Any string fields which were not set above will be NULL. However
* we cannot return NULL fields in structs, so we convert these to
* empty strings here.
*/
if (ret->iso_system_id == NULL) {
ret->iso_system_id = strdup ("");
if (ret->iso_system_id == NULL) goto error;
}
if (ret->iso_volume_id == NULL) {
ret->iso_volume_id = strdup ("");
if (ret->iso_volume_id == NULL) goto error;
}
if (ret->iso_volume_set_id == NULL) {
ret->iso_volume_set_id = strdup ("");
if (ret->iso_volume_set_id == NULL) goto error;
}
if (ret->iso_publisher_id == NULL) {
ret->iso_publisher_id = strdup ("");
if (ret->iso_publisher_id == NULL) goto error;
}
if (ret->iso_data_preparer_id == NULL) {
ret->iso_data_preparer_id = strdup ("");
if (ret->iso_data_preparer_id == NULL) goto error;
}
if (ret->iso_application_id == NULL) {
ret->iso_application_id = strdup ("");
if (ret->iso_application_id == NULL) goto error;
}
if (ret->iso_copyright_file_id == NULL) {
ret->iso_copyright_file_id = strdup ("");
if (ret->iso_copyright_file_id == NULL) goto error;
}
if (ret->iso_abstract_file_id == NULL) {
ret->iso_abstract_file_id = strdup ("");
if (ret->iso_abstract_file_id == NULL) goto error;
}
if (ret->iso_bibliographic_file_id == NULL) {
ret->iso_bibliographic_file_id = strdup ("");
if (ret->iso_bibliographic_file_id == NULL) goto error;
}
return ret;
error:
free (ret->iso_system_id);
free (ret->iso_volume_id);
free (ret->iso_volume_set_id);
free (ret->iso_publisher_id);
free (ret->iso_data_preparer_id);
free (ret->iso_application_id);
free (ret->iso_copyright_file_id);
free (ret->iso_abstract_file_id);
free (ret->iso_bibliographic_file_id);
free (ret);
return NULL;
}
static guestfs_int_isoinfo *
isoinfo (const char *path)
{
int r;
CLEANUP_FREE char *out = NULL, *err = NULL;
CLEANUP_FREE_STRING_LIST char **lines = NULL;
/* --debug is necessary to get additional fields, in particular
* the date & time fields.
*/
r = command (&out, &err, str_isoinfo, "--debug", "-d", "-i", path, NULL);
if (r == -1) {
reply_with_error ("%s", err);
return NULL;
}
lines = split_lines (out);
if (lines == NULL)
return NULL;
return parse_isoinfo (lines);
}
guestfs_int_isoinfo *
do_isoinfo_device (const char *device)
{
return isoinfo (device);
}
guestfs_int_isoinfo *
do_isoinfo (const char *path)
{
guestfs_int_isoinfo *ret;
CLEANUP_FREE char *buf = sysroot_path (path);
if (!buf) {
reply_with_perror ("malloc");
return NULL;
}
ret = isoinfo (buf);
return ret;
}

97
daemon/labels.c Normal file
View File

@@ -0,0 +1,97 @@
/* libguestfs - the guestfsd daemon
* Copyright (C) 2012 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 <string.h>
#include <unistd.h>
#include "daemon.h"
#include "actions.h"
#include "optgroups.h"
GUESTFSD_EXT_CMD(str_e2label, e2label);
GUESTFSD_EXT_CMD(str_ntfslabel, ntfslabel);
static int
e2label (const char *device, const char *label)
{
int r;
CLEANUP_FREE char *err = NULL;
if (strlen (label) > EXT2_LABEL_MAX) {
reply_with_error ("%s: ext2 labels are limited to %d bytes",
label, EXT2_LABEL_MAX);
return -1;
}
r = command (NULL, &err, str_e2label, device, label, NULL);
if (r == -1) {
reply_with_error ("%s", err);
return -1;
}
return 0;
}
static int
ntfslabel (const char *device, const char *label)
{
int r;
CLEANUP_FREE char *err = NULL;
/* XXX We should check if the label is longer than 128 unicode
* characters and return an error. This is not so easy since we
* don't have the required libraries.
*/
r = command (NULL, &err, str_ntfslabel, device, label, NULL);
if (r == -1) {
reply_with_error ("%s", err);
return -1;
}
return 0;
}
int
do_set_label (const mountable_t *mountable, const char *label)
{
int r;
/* How we set the label depends on the filesystem type. */
CLEANUP_FREE char *vfs_type = do_vfs_type (mountable);
if (vfs_type == NULL)
return -1;
if (STREQ (vfs_type, "ext2") || STREQ (vfs_type, "ext3")
|| STREQ (vfs_type, "ext4"))
r = e2label (mountable->device, label);
else if (STREQ (vfs_type, "ntfs"))
r = ntfslabel (mountable->device, label);
else {
reply_with_error ("don't know how to set the label for '%s' filesystems",
vfs_type);
r = -1;
}
return r;
}

423
daemon/ldm.c Normal file
View File

@@ -0,0 +1,423 @@
/* libguestfs - the guestfsd daemon
* Copyright (C) 2012 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 <glob.h>
#if HAVE_YAJL
#include <yajl/yajl_tree.h>
#endif
#include "daemon.h"
#include "actions.h"
#include "optgroups.h"
#if HAVE_YAJL
GUESTFSD_EXT_CMD(str_ldmtool, ldmtool);
int
optgroup_ldm_available (void)
{
return prog_exists (str_ldmtool);
}
static int
glob_errfunc (const char *epath, int eerrno)
{
fprintf (stderr, "glob: failure reading %s: %s\n", epath, strerror (eerrno));
return 1;
}
static char **
get_devices (const char *pattern)
{
DECLARE_STRINGSBUF (ret);
glob_t devs;
int err;
size_t i;
err = glob (pattern, GLOB_ERR, glob_errfunc, &devs);
if (err == GLOB_NOSPACE) {
reply_with_error ("glob: returned GLOB_NOSPACE: "
"rerun with LIBGUESTFS_DEBUG=1");
goto error;
} else if (err == GLOB_ABORTED) {
reply_with_error ("glob: returned GLOB_ABORTED: "
"rerun with LIBGUESTFS_DEBUG=1");
goto error;
}
for (i = 0; i < devs.gl_pathc; ++i) {
if (add_string (&ret, devs.gl_pathv[i]) == -1)
goto error;
}
if (end_stringsbuf (&ret) == -1) goto error;
globfree (&devs);
return ret.argv;
error:
globfree (&devs);
if (ret.argv != NULL)
free_stringslen (ret.argv, ret.size);
return NULL;
}
/* All device mapper devices called /dev/mapper/ldm_vol_*. XXX We
* could tighten this up in future if ldmtool had a way to read these
* names back after they have been created.
*/
char **
do_list_ldm_volumes (void)
{
return get_devices ("/dev/mapper/ldm_vol_*");
}
/* Same as above but /dev/mapper/ldm_part_*. See comment above. */
char **
do_list_ldm_partitions (void)
{
return get_devices ("/dev/mapper/ldm_part_*");
}
int
do_ldmtool_create_all (void)
{
int r;
CLEANUP_FREE char *err = NULL;
r = command (NULL, &err, "ldmtool", "create", "all", NULL);
if (r == -1) {
reply_with_error ("%s", err);
return -1;
}
return 0;
}
int
do_ldmtool_remove_all (void)
{
int r;
CLEANUP_FREE char *err = NULL;
r = command (NULL, &err, "ldmtool", "remove", "all", NULL);
if (r == -1) {
reply_with_error ("%s", err);
return -1;
}
return 0;
}
static yajl_val
parse_json (const char *json, const char *func)
{
yajl_val tree;
char parse_error[1024];
if (verbose)
fprintf (stderr, "%s: parsing json: %s\n", func, json);
tree = yajl_tree_parse (json, parse_error, sizeof parse_error);
if (tree == NULL) {
reply_with_error ("parse error: %s",
strlen (parse_error) ? parse_error : "unknown error");
return NULL;
}
/* Caller should free this by doing 'yajl_tree_free (tree);'. */
return tree;
}
#define TYPE_ERROR ((char **) -1)
static char **
json_value_to_string_list (yajl_val node)
{
DECLARE_STRINGSBUF (strs);
yajl_val n;
size_t i, len;
if (! YAJL_IS_ARRAY (node))
return TYPE_ERROR;
len = YAJL_GET_ARRAY(node)->len;
for (i = 0; i < len; ++i) {
n = YAJL_GET_ARRAY(node)->values[i];
if (! YAJL_IS_STRING (n))
return TYPE_ERROR;
if (add_string (&strs, YAJL_GET_STRING (n)) == -1)
return NULL;
}
if (end_stringsbuf (&strs) == -1)
return NULL;
return strs.argv;
}
static char **
parse_json_get_string_list (const char *json,
const char *func, const char *cmd)
{
char **ret;
yajl_val tree = NULL;
tree = parse_json (json, func);
if (tree == NULL)
return NULL;
ret = json_value_to_string_list (tree);
yajl_tree_free (tree);
if (ret == TYPE_ERROR) {
reply_with_error ("output of '%s' was not a JSON array of strings", cmd);
return NULL;
}
return ret;
}
#define GET_STRING_NULL_TO_EMPTY 1
static char *
parse_json_get_object_string (const char *json, const char *key, int flags,
const char *func, const char *cmd)
{
char *str, *ret;
yajl_val tree = NULL, node;
size_t i, len;
tree = parse_json (json, func);
if (tree == NULL)
return NULL;
if (! YAJL_IS_OBJECT (tree))
goto bad_type;
len = YAJL_GET_OBJECT(tree)->len;
for (i = 0; i < len; ++i) {
if (STREQ (YAJL_GET_OBJECT(tree)->keys[i], key)) {
node = YAJL_GET_OBJECT(tree)->values[i];
if ((flags & GET_STRING_NULL_TO_EMPTY) && YAJL_IS_NULL (node))
ret = strdup ("");
else {
str = YAJL_GET_STRING (node);
if (str == NULL)
goto bad_type;
ret = strdup (str);
}
if (ret == NULL)
reply_with_perror ("strdup");
yajl_tree_free (tree);
return ret;
}
}
bad_type:
reply_with_error ("output of '%s' was not a JSON object "
"containing a key '%s' of type string", cmd, key);
yajl_tree_free (tree);
return NULL;
}
static char **
parse_json_get_object_string_list (const char *json, const char *key,
const char *func, const char *cmd)
{
char **ret;
yajl_val tree, node;
size_t i, len;
tree = parse_json (json, func);
if (tree == NULL)
return NULL;
if (! YAJL_IS_OBJECT (tree))
goto bad_type;
len = YAJL_GET_OBJECT(tree)->len;
for (i = 0; i < len; ++i) {
if (STREQ (YAJL_GET_OBJECT(tree)->keys[i], key)) {
node = YAJL_GET_OBJECT(tree)->values[i];
ret = json_value_to_string_list (node);
if (ret == TYPE_ERROR)
goto bad_type;
yajl_tree_free (tree);
return ret;
}
}
bad_type:
reply_with_error ("output of '%s' was not a JSON object "
"containing a key '%s' of type array of strings",
cmd, key);
yajl_tree_free (tree);
return NULL;
}
char **
do_ldmtool_scan (void)
{
const char *empty_list[] = { NULL };
return do_ldmtool_scan_devices ((char * const *) empty_list);
}
char **
do_ldmtool_scan_devices (char * const * devices)
{
char **ret;
size_t i, nr_devices;
CLEANUP_FREE_STRING_LIST const char **argv = NULL;
int r;
CLEANUP_FREE char *out = NULL, *err = NULL;
nr_devices = count_strings (devices);
argv = malloc ((3 + nr_devices) * sizeof (char *));
if (argv == NULL) {
reply_with_perror ("malloc");
return NULL;
}
argv[0] = str_ldmtool;
argv[1] = "scan";
for (i = 0; i < nr_devices; ++i)
argv[2+i] = devices[i];
argv[2+i] = NULL;
r = commandv (&out, &err, argv);
if (r == -1) {
reply_with_error ("%s", err);
return NULL;
}
ret = parse_json_get_string_list (out, __func__, "ldmtool scan");
return ret;
}
char *
do_ldmtool_diskgroup_name (const char *diskgroup)
{
int r;
CLEANUP_FREE char *out = NULL, *err = NULL;
r = command (&out, &err, str_ldmtool, "show", "diskgroup", diskgroup, NULL);
if (r == -1) {
reply_with_error ("%s", err);
return NULL;
}
return parse_json_get_object_string (out, "name", 0,
__func__, "ldmtool show diskgroup");
}
char **
do_ldmtool_diskgroup_volumes (const char *diskgroup)
{
int r;
CLEANUP_FREE char *out = NULL, *err = NULL;
r = command (&out, &err, str_ldmtool, "show", "diskgroup", diskgroup, NULL);
if (r == -1) {
reply_with_error ("%s", err);
return NULL;
}
free (err);
return parse_json_get_object_string_list (out, "volumes",
__func__, "ldmtool show diskgroup");
}
char **
do_ldmtool_diskgroup_disks (const char *diskgroup)
{
int r;
CLEANUP_FREE char *out = NULL, *err = NULL;
r = command (&out, &err, str_ldmtool, "show", "diskgroup", diskgroup, NULL);
if (r == -1) {
reply_with_error ("%s", err);
return NULL;
}
return parse_json_get_object_string_list (out, "disks",
__func__, "ldmtool show diskgroup");
}
char *
do_ldmtool_volume_type (const char *diskgroup, const char *volume)
{
int r;
CLEANUP_FREE char *out = NULL, *err = NULL;
r = command (&out, &err,
str_ldmtool, "show", "volume", diskgroup, volume, NULL);
if (r == -1) {
reply_with_error ("%s", err);
return NULL;
}
return parse_json_get_object_string (out, "type", 0,
__func__, "ldmtool show volume");
}
char *
do_ldmtool_volume_hint (const char *diskgroup, const char *volume)
{
int r;
CLEANUP_FREE char *out = NULL, *err = NULL;
r = command (&out, &err,
str_ldmtool, "show", "volume", diskgroup, volume, NULL);
if (r == -1) {
reply_with_error ("%s", err);
return NULL;
}
return parse_json_get_object_string (out, "hint", GET_STRING_NULL_TO_EMPTY,
__func__, "ldmtool show volume");
}
char **
do_ldmtool_volume_partitions (const char *diskgroup, const char *volume)
{
int r;
CLEANUP_FREE char *out = NULL, *err = NULL;
r = command (&out, &err,
str_ldmtool, "show", "volume", diskgroup, volume, NULL);
if (r == -1) {
reply_with_error ("%s", err);
return NULL;
}
return parse_json_get_object_string_list (out, "partitions",
__func__, "ldmtool show volume");
}
#else /* !HAVE_YAJL */
OPTGROUP_LDM_NOT_AVAILABLE
#endif

Some files were not shown because too many files have changed in this diff Show More