973 Commits

Author SHA1 Message Date
Richard W.M. Jones
f223dfa29a New APIs: copy-{file,device}-to-{file,device}.
The four new APIs:
guestfs_copy_device_to_device,
guestfs_copy_device_to_file,
guestfs_copy_file_to_device, and
guestfs_copy_file_to_file
let you copy from a source to a destination, between files and
devices, optionally allowing source and destination offsets and size
to be specified.
2011-10-26 10:07:21 +01:00
Richard W.M. Jones
47412f137f New API: part-to-partnum
This converts a partition device name (eg. /dev/sda1) to a partition
number (eg. 1).  This is useful in conjunction with the parted APIs
that mostly take a disk device + partnum.
2011-10-25 12:46:05 +01:00
Richard W.M. Jones
3814680423 Add test for qemu broken -machine option (RHBZ#748266).
Also add this option, if necessary, when testing for virtio-serial
support.

When the workaround is enabled, we specify machine type 'pc'.
2011-10-24 15:47:57 +01:00
Richard W.M. Jones
31bf0cf313 add-drive-opts: Correctly handle unreadable and unwritable files (RHBZ#747287). 2011-10-21 16:31:19 +01:00
Richard W.M. Jones
527079aa0d lib: Common code for formatting the qemu -drive parameter.
This is just code refactoring.
2011-10-21 12:49:18 +01:00
Richard W.M. Jones
f5172902bc Allow compilation without hivex (RHBZ#723474). 2011-10-21 12:29:12 +01:00
Richard W.M. Jones
c46bedf925 inspection: Return root devices sorted. 2011-10-19 16:27:38 +01:00
Matthew Booth
6aa3ece129 inspect: Handle cciss devices in /etc/fstab 2011-10-19 16:27:38 +01:00
Matthew Booth
f5c9f0e9ee inspect: Don't assume number of captures in match functions
It is possible for the pcre library to return a variable number of captures for
a single regular expression. e.g.:

  ^/dev/(cciss/c\d+d\d+)(?:p(\d+))?$

This will return either 1 or 2 captures depending on whether the device has a
partition suffix. The current match wrappers don't allow for this, and require
that a predictable number of matches are returned.

This change updates match, match1, match2, and match3 to ignore the specific
number of matches returned. Instead, any returned captures are assigned to the
given arguments, and any remaining arguments are set to NULL.
2011-10-19 16:27:38 +01:00
Matthew Booth
a1df33eac2 inspect: Add drive naming hints
We currently use a heuristic to guess how drive names we find
referenced in the guest map to drive names in the appliance. If this
heuristic fails it can cause inspection to fail.

This change adds a new 'name' option to add_drive_opts, which allows
the user to explicitly pass the name of a drive to libguestfs if it is
known. This change also updates the fstab-parsing inspection code to
use this information if it is available.
2011-10-19 16:27:38 +01:00
Matthew Booth
1f615fddaf NFC: Remove unnecessary goto 2011-10-19 16:27:38 +01:00
Matthew Booth
f1041e912b launch: Store drive information in guestfs_h
This is a NFC on its own, but provides a place-holder for drive metadata which
can be used after launch.

Fixes by RWMJ:

 - Fix the tests: this requires a new internal function 'debug-drives'
   that dumps out the g->drives information so it can be checked in
   two of the tests.  Previously these tests used 'debug-cmdline'.

 - Test file existence / use_cache_off in the add_drive_opts function,
   not when launching qemu in the child process.

 - Call free along error paths.

 - Add comments.
2011-10-19 16:26:42 +01:00
Matthew Booth
472f02d08b inspect: Fix fstab device mapping for >26 disks
The regular expression matching disk name assumed that there was only a single
letter suffix. This change handles a naming scheme for any number of disks.
2011-10-19 16:26:42 +01:00
Richard W.M. Jones
138e118d62 launch: Ensure g->cmdline is allocated before assigning g->cmdline[0]. 2011-10-19 16:26:39 +01:00
Michael Scherer
f25d2300ce Add basic support for netbsd detection. 2011-10-14 10:35:17 +01:00
Michael Scherer
8f6eed00da Add support for pkgsrc, default NetBSD package manager.
For now, only detect the tool, but support from reading
installed package could be added later ( may require either
a package of pkgsrc, or a smaller tool to read the db ).
2011-10-14 10:27:48 +01:00
Michael Scherer
05a8359c7c Add support for mounting ufs from NetBSD, and fix FreeBSD detection on Fedora 16
While testing on Fedora 16, I noticed that Linux will mount the disk
without trouble by using automatically ufstype=old, and yet do not
let us read the directories. So we should start directly with usftype=ufs2,
and if it fail, try 44bsd, as used for netbsd and openbsd ( as seen on
http://wiki-static.aydogan.net/How_to_mount_FFS_partition_under_Linux ).
2011-10-14 10:26:16 +01:00
Michael Scherer
15d79b5ea9 Add the Opensuse logo ( thanks to Vincent Untz )
Like Ubuntu one, it may not be always present.
2011-10-14 10:01:49 +01:00
Michael Scherer
5332515db3 Add Opensuse and zypper detection support
This would also erronously detect SLES as Opensuse.
2011-10-14 10:01:44 +01:00
Michael Scherer
1d0683964f Add support for Ubuntu logo
Ths logo is present on Lucid Lynx, but may not always be installed, like
in case of a minimal installation ( or server ). While Edubuntu and Kubuntu
have different logo, I didn't check where it would be placed.
2011-10-14 10:01:43 +01:00
Michael Scherer
7d4a99db87 Detect Mageia distribution 2011-10-14 10:01:40 +01:00
Richard W.M. Jones
c155330f04 Add systemtap/DTrace probes.
Mainly this is a documentation change.  However a sample of
DTrace-compatible userspace probes are also added.
2011-10-10 13:26:15 +01:00
Richard W.M. Jones
1e35941f62 New tool: virt-sysprep: system preparation for guests. 2011-10-08 13:38:30 +01:00
Richard W.M. Jones
b4bb49ffd1 New tool: virt-alignment-scan to check alignment of partitions. 2011-10-05 18:13:29 +01:00
Richard W.M. Jones
f3341222b3 docs: Add directory sections for resize/ and sparsify/ 2011-10-05 14:38:07 +01:00
Richard W.M. Jones
fac15924f5 New tool: virt-sparsify to make disk images sparse. 2011-10-04 17:37:48 +01:00
Richard W.M. Jones
293772bf75 docs: Add virt-resize to list of links in guestfs(3). 2011-10-04 10:58:25 +01:00
Richard W.M. Jones
b39b3c5c74 docs: virt-win-reg is written in Perl, not virt-resize. 2011-10-04 10:58:02 +01:00
Richard W.M. Jones
b57fcc5064 Update API support documentation. 2011-10-04 10:57:05 +01:00
Richard W.M. Jones
5c2f1a2d94 mount: No longer implicitly add -o sync,noatime options. 2011-10-01 08:20:50 +01:00
Richard W.M. Jones
04fbcc63eb New API: set-smp, get-smp
These calls allow you to change the number of virtual CPUs assigned to
the appliance.

This also adds a --smp option to virt-rescue.
2011-09-28 14:52:56 +01:00
Richard W.M. Jones
8403f5a9d8 New APIs: compress-out, compress-device-out.
These APIs let you copy compressed files or devices out from the disk
image.

Compression is useful for large images which are mostly zeroes.  We
cannot currently do sparseness detection, and compression gives us a
form of zero detection for free.

Example usage:

$ guestfish --ro -a /dev/vg_pin/F16x64 -i \
    compress-out gzip /etc/passwd /tmp/passwd.gz
$ file -z /tmp/passwd.gz
/tmp/passwd.gz: ASCII text (gzip compressed data, was "passwd", from
Unix, last modified: Sun Aug 28 14:40:46 2011)
2011-09-28 14:52:56 +01:00
Richard W.M. Jones
322106521f Add no_timer_check to disable faulty test during boot (RHBZ#502058).
See:

https://bugzilla.redhat.com/show_bug.cgi?id=502058#c15
https://bugzilla.redhat.com/show_bug.cgi?id=698842#c8

This updates commit 79e66f89e2.
2011-09-26 13:35:24 +01:00
Richard W.M. Jones
3c7b3634b2 docs: Show how to use a qemu wrapper to edit the qemu command line. 2011-09-26 09:58:46 +01:00
Richard W.M. Jones
79e66f89e2 Enable APIC.
Originally this was disabled to work around RHBZ#502058.  That bug was
never officially fixed, but it may have fixed itself.

In the meantime, KVM has broken ordinary PIC support (RHBZ#723822).
Since APIC is the most common way that regular Linux and Windows
guests run it makes sense to remove this hack.
2011-09-21 19:31:10 +01:00
Richard W.M. Jones
84763d7fca Add Erlang bindings. 2011-09-21 15:21:58 +01:00
Richard W.M. Jones
917f947590 inspection: Handle /dev/root in /etc/fstab.
This means "the device that holds /etc/fstab", so map it correctly.

This fixes support for ttylinux and also some other guests that use
/dev/root instead of a real device name.
2011-09-16 15:26:20 +01:00
Richard W.M. Jones
b648b1813f inspection: Add support for ttylinux (a minimal Linux). 2011-09-16 15:21:26 +01:00
Richard W.M. Jones
b3f1457fdd docs: Add a section explaining the appliance boot process. 2011-09-07 15:21:37 +01:00
Richard W.M. Jones
9420eaf44e Add GUESTFS_EVENT_ENTER event.
This event is generated whenever a libguestfs function is called.
2011-08-26 21:55:03 +01:00
Richard W.M. Jones
ce18be33cd Coverity: fix memory leak along error path. 2011-08-23 19:50:11 +01:00
Richard W.M. Jones
631faad971 pclose: Fix other places where we only tested pclose == -1.
pclose can return > 0 when the status of the command was non-zero.
2011-08-23 18:56:12 +01:00
Richard W.M. Jones
f159619113 test_qemu: Improve the error message.
Note that errno is probably not set to a useful value here, so there
is not much point recording it.
2011-08-23 18:53:48 +01:00
Richard W.M. Jones
a24652c7b2 test_qemu: pclose may return any != 0 on error.
In particular pclose returns a status > 0 if the command fails.
2011-08-23 18:53:00 +01:00
Richard W.M. Jones
2ace9be4cd qemu detection: Free up previous qemu help/version strings if they exist. 2011-08-23 18:43:24 +01:00
Richard W.M. Jones
08e77ad8cb Coverity: test_qemu: Ensure FILE * is not leaked along error paths.
This refactors the code in test_qemu slightly to ensure that
FILE *fp is not leaked on error paths.
2011-08-23 18:03:23 +01:00
Richard W.M. Jones
06019bc82e Escape special/non-printing characters in debug output (RHBZ#731744).
The default event handler in libguestfs was simply writing all debug
output directly to stderr.  However if the output contains
non-printable characters such as terminal control codes then these
would also be sent directly.

With newer SeaBIOS there is a lame attempt to implement a splash
screen using terminal control codes, thus when libguestfs tries to
display debugging output it would cause the screen to clear and debug
output to be lost.

This commit causes all non-printing characters to be escaped.
(\n and \r characters from the appliance are treated somewhat
specially).

Furthermore, instead of using write(2), use buffered stderr calls.
2011-08-18 18:03:41 +01:00
Richard W.M. Jones
635af5be04 Remove guestfs___print_timestamped_argv.
This function was used to print the qemu and
febootstrap-supermin-helper command lines.

Unfortunately in the qemu case it was used incorrectly: it called the
internal debug function (ie. event API callback) from the forked qemu
subprocess, which meant that higher level event callbacks might have
been invoked from the child process.

To fix this, convert the qemu case into a new function called
print_qemu_command line which just prints the command line directly to
stderr.  This is called after stderr has been redirected into the pipe
to the main process.  Thus the qemu command line will be marshalled
into the event API along with other qemu and appliance output.

After fixing this, only one use of guestfs___print_timestamped_argv
remained, for printing the febootstrap-supermin-helper command line.
This is converted to a local function print_febootstrap_command_line.

Also print_febootstrap_command_line is now called before we fork
febootstrap-supermin-helper, so that messages no longer overlap.
2011-08-18 18:02:56 +01:00
Hilko Bengen
0241c75393 out-of-tree build: fix building library 2011-08-15 14:50:33 +01:00
Hilko Bengen
ff101adf7e out-of-tree build: fix documentation generation 2011-08-15 14:50:33 +01:00