Commit Graph

113 Commits

Author SHA1 Message Date
Hilko Bengen
b30e2cf122 Fix out-of-tree build: Do not accidentally build mllib components in srcdir 2014-03-04 00:06:09 +01:00
Hilko Bengen
f75142c577 Fix building on architectures where ocamlopt is not available 2014-02-28 14:01:25 +00:00
Pino Toscano
59eb9bff87 resize: preserve GPT partition names (RHBZ#1060404).
Save the partition names/labels of the source partitions, and restore
them after the partition copy.
2014-02-04 15:54:44 +01:00
Richard W.M. Jones
170b64337d resize: Try to remove a few more _ -> .. cases.
This allows the compiler to catch missing cases more effectively,
especially if we update the types with more cases in future.
2014-02-04 13:27:34 +00:00
Pino Toscano
ef7ac043a6 resize: properly restore GPT partition types
If there is a GPT partition layout, then what should be read and
restored for each partition is the GPT type and not the MBR ID.

Related to RHBZ#1060404.
2014-02-04 13:32:28 +01:00
Richard W.M. Jones
f02fddc26b tests: Update miscellaneous tests to use disk-create API.
Instead of calling out to qemu-img / truncate.
2014-01-28 21:02:11 +00:00
Richard W.M. Jones
3331db84bc resize: Don't truncate libguestfs error messages.
If we rely on OCaml's internal exception printing, then it will
truncate error messages like this:

  Fatal error: exception Guestfs.Error("could not create appliance
  through libvirt.

  Try running qemu directly without libvirt using this environment
  variable: export LIBGUESTFS_BACKEND=direct

  Original error from libvirt: unable to set security context
  'unconfined_u:object_r:svi
note the truncation here ^^^^^^^

Instead of using the internal exception printing, wrap the whole
program in a 'main ()' function and add an exception handler.

This large change is non-functional apart from the addition of the
exception handlers at the end.
2014-01-23 15:08:52 +00:00
Richard W.M. Jones
6c971faecf Update copyright dates for 2014. 2014-01-02 16:53:34 +00:00
Richard W.M. Jones
d98fbf2071 resize: Move roundup64 function into common utilities.
This is just code motion.
2013-12-14 13:21:25 +00:00
Richard W.M. Jones
5b89dd4aa1 mllib: Create config.ml from configure and use it for --version options.
Also don't internationalize the output of the --version option, as
that isn't useful.
2013-10-22 13:48:41 +01:00
Richard W.M. Jones
1e24b88270 resize, builder: Improve speed by using cache=unsafe on newly created files.
However because qemu might open these files immediately afterwards
using cache=none, we have to sync the file before exiting.
2013-10-18 13:59:01 +01:00
Richard W.M. Jones
9a4bfb386e resize: Rearrange objects.
This is just build refactoring.
2013-10-18 13:33:32 +01:00
Richard W.M. Jones
13b79aacca Use qemu-img -o preallocation=metadata where possible.
When format is qcow2 and we're *not* using a backing disk, we can use
preallocation=metadata for better performance.
2013-10-17 15:03:37 +01:00
Richard W.M. Jones
fb4dd1b55a resize: Add --no-sparse flag to let you turn off sparse copying.
Useful when the target is a block device containing old data.
2013-10-14 13:26:37 +01:00
Richard W.M. Jones
ff9bc90e63 resize: Don't add mllib/* sources to 'SOURCES'.
This was a mistake in commit 2a6ce79320.
2013-10-03 21:42:05 +01:00
Richard W.M. Jones
748ab33969 mllib: Rename parse_size to parse_resize.
This is just code motion, but it reduces a source of confusion.
2013-10-03 21:42:04 +01:00
Richard W.M. Jones
98d56bb102 mllib: error function has ~prog parameter, instead of assuming virt-resize.
$ virt-sparsify a a
  virt-resize: error: you cannot use the same disk image for input and
  output
  If reporting bugs, run virt-resize with the '-d' option and include the
  complete output.

Note (a) it assumes the program is called "virt-resize" which it
isn't, and (b) it assumes the program has a debug option -d which it
doesn't.

This commit changes the error message and adds a -v option to
virt-resize.
2013-10-03 21:42:04 +01:00
Richard W.M. Jones
e1d7fb406b resize, sparsify: Small argument parser refactoring.
Factor out a common string.
2013-10-03 21:42:04 +01:00
Richard W.M. Jones
09a4f42861 uri: Fix two compiler warnings.
We have to include the right header so that guestfs___free_string_list
is declared.  Unfortunately that means ensuring -I src is passed to
the compiler in every tool subdirectory.

Also fix (bogus) compiler warning about incorrect type of the
parameter to caml_copy_string_array.
2013-09-24 13:41:35 +01:00
Richard W.M. Jones
2a6ce79320 tools: Move shared OCaml code to mllib/ directory.
Previously a lot of shared code lived in the resize/ directory for no
particular reason.

This is just code motion.
2013-09-24 13:41:35 +01:00
Richard W.M. Jones
dbbdaebe22 resize: Allow the input file to be a URI.
This lets you use nbd as a source for resizing, eg:

  virt-resize nbd://example.com outfile
2013-09-23 15:22:24 +01:00
Richard W.M. Jones
13f3b4a83d sparsify: Fix signal handling.
If you don't have a ^C (SIGINT) signal handler at all, then at_exit
handlers are not called so you end up leaving the large temporary
overlay file lying around.  That was fixed, incorrectly, by
commit 7283a5a276.

However the code now would delete the overlay file in the SIGINT
handler but otherwise continue running until basically it tries to
read the overlay file (now deleted) and fails.  So it kind of worked,
by accident.

Fix this so that the signal handler calls exit, thus ensuring both
that the exit handler is called (to delete the file) and that the
program actually exits as soon as possible.

This also refactors the unlink_on_exit function into a utility.
2013-08-31 21:29:16 +01:00
Nikita Menkovich
f33343a5c1 sysprep: added --mount-options option to mount selected partitions with options. 2013-08-19 08:31:55 +01:00
Richard W.M. Jones
2d758d548b uml: resize: Skip test since it needs qcow2. 2013-08-13 15:46:55 +01:00
Richard W.M. Jones
67fd809ca3 resize: Mark progress bar functions as "noalloc".
Avoids GC overhead and turns these into simple C calls.  See:
http://camltastic.blogspot.co.uk/2008/08/tip-calling-c-functions-directly-with.html
2013-08-03 10:04:29 +01:00
Richard W.M. Jones
3d39549ded resize: Mark isatty function as "noalloc".
This turns it into an ordinary C call without the unnecessary [in this
case] GC frame overhead.  See:
http://camltastic.blogspot.co.uk/2008/08/tip-calling-c-functions-directly-with.html
2013-08-03 10:01:34 +01:00
Richard W.M. Jones
406522d1d2 resize: Add bindings for the guestfish -a URI parsing mini-library.
This allows -a options to be parsed from OCaml programs, reusing
the same code that is being used by C.
2013-07-30 15:37:16 +01:00
Richard W.M. Jones
b56990ddf8 resize: Move isatty_stdout function to separate module (TTY.isatty_stdout).
It was jammed into the Progress module just for convenience.
2013-07-30 11:46:22 +01:00
Richard W.M. Jones
fb282e677c resize: Link to information about dracut-modules-growroot. 2013-07-29 13:52:16 +01:00
Richard W.M. Jones
4180abcc1f tests: Use unique or temporary names for temporary files.
Review every test(!) to ensure that it:

 - Doesn't use a generic name (eg. "test1.img", "test.out") for any
   temporary file it needs.

 - Does instead use a unique name or a temporary name (eg. a name like
   "name-of-the-test.img", or a scratch disk).

 - Does not use 'rm -f' to clean up its temporary files (so we can
   detect errors if the wrong temporary file is created or removed).

This allows tests to be run in parallel, so they don't stomp on each
other's temporary files.
2013-07-23 10:16:00 +01:00
Richard W.M. Jones
8965368eb8 sysprep: Add new fs-uuids operation.
This creates new random UUIDs for all filesystems in a guest.
2013-07-22 13:52:23 +01:00
Richard W.M. Jones
a7aa47f4de virt-resize: Add notes about Windows and disk consistency (RHBZ#975753).
Also group the Windows-related notes together.
2013-06-20 09:13:41 +01:00
Richard W.M. Jones
b730bc0c46 virt-resize: Take into account large start offset of the first partition when calculating overhead (RHBZ#974904).
Since we don't usually move the first partition, if the first
partition has an unusually large offset from the start of the disk,
then the unpartitioned space in front of that partition counts as
partitioning overhead.  However the previous surplus calculation was
not taking that into account.

This was a problem for certain Ubuntu images which are partitioned
with an 8 MB gap before the first partition.

Thanks: David Hart.
2013-06-19 19:03:21 +01:00
Richard W.M. Jones
07f3e5ae5c virt-resize: Add some more debugging messages.
These are only printed when using the --debug flag and are
helpful for diagnosing problems.
2013-06-19 19:02:48 +01:00
Richard W.M. Jones
7949fd3949 virt-resize: Fix minor typo in error message. 2013-06-19 19:02:15 +01:00
Richard W.M. Jones
49bdaabc7d build: Add common-rules.mk, common rules for all Makefiles.
This file is mainly a central place to:

 - include localenv if it exists, and

 - define the RHEL 5 backwards compatibility macros, instead of
   spreading them over every other file.
2013-06-04 12:41:11 +01:00
Richard W.M. Jones
333337b6a9 debian: Add OCaml .depend files to DISTCLEANFILES.
Otherwise debuild complains that these files have been created after
it does a 'make distclean'.
2013-05-02 13:18:12 +01:00
Richard W.M. Jones
33c087ea9c Add 'sparse' option to copy-{device,file}-to-{device,file} calls.
Setting the 'sparse' optional boolean causes writes to be omitted if
the block to be written contains all zero bytes.

This should help with sparse backing files (eg. raw, qcow2, dm-thin, etc).

Also, modify virt-resize to use this option by default when copying
devices.  The savings in virt-resize can be quite startling, eg
'du -sh' (ie. true size) of a resized disk image:

8.1G      /tmp/f15x32-resized.img    # before this change
3.2G      /tmp/f15x32-resized.img    # after this change
2013-04-04 14:58:32 +01:00
Richard W.M. Jones
1cb38ab924 New API: feature-available.
This API is an easier to use version of the existing guestfs_available,
because the new API returns true/false instead of throwing an error
when a feature from the list is not available.

In truth we've had this implementation internally in the library
and several tools and in Sys::Guestfs::Lib for a long time.  This
change just turns it into a publicly consumable API.
2013-04-02 12:38:50 +01:00
Richard W.M. Jones
6185aa4e38 ocaml tools: Enable parallel builds.
In particular, building virt-sysprep is slow because there are so many
modules.  Enable parallel builds.  If it breaks, we should fix it, not
work around it.
2013-03-28 20:15:51 +00:00
Richard W.M. Jones
6c9a7fe561 Add --long-options option to most tools.
For example:

$ guestfish --long-options
--add
--cmd-help
--connect
--csh
--domain
--echo-keys
[etc.]

The idea of this is to make it easier to write a bash completion
script that accurately expands --<TAB> options for each command.
2013-03-28 14:46:20 +00:00
Richard W.M. Jones
05ba393724 OCaml tools: Use Common_gettext and Common_utils modules.
Share these modules across all three tools virt-resize, virt-sparsify
and virt-sysprep.

This is mostly code motion.
2013-03-28 14:00:42 +00:00
Richard W.M. Jones
d16bb6b70c RHEL 5: Replacement for 'Unix.isatty stdout' for old OCaml versions.
Unix.isatty missing on RHEL 5-era OCaml 3.09.3.
2013-03-09 22:32:30 +00:00
Richard W.M. Jones
5a2e320ec9 configure: Add --enable-code-profiling and --enable-code-coverage flags.
These configure flags enable code profiling (with gprof) and code
coverage (with gcov) respectively.

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

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

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

Also neither flag will help in capturing data from the appliance.
2012-12-04 14:11:14 +00:00
Richard W.M. Jones
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
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
a0722c7ad8 resize, sparsify: Suppress progress bar when output is not a tty. 2012-10-15 15:51:55 +01: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
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