242 Commits

Author SHA1 Message Date
Richard W.M. Jones
c8faa5d0b0 fish: Add -w|--rw option to --help output. 2011-03-22 11:50:03 +00:00
Richard W.M. Jones
4e0cf4dbf8 New event API (RHBZ#664558).
This API allows more than one callback to be registered for each
event, makes it possible to call the API from other languages, and
allows [nearly all] log, debug and trace messages to be rerouted from
stderr.

An older version of this API was discussed on the mailing list here:
https://www.redhat.com/archives/libguestfs/2010-December/msg00081.html
https://www.redhat.com/archives/libguestfs/2011-January/msg00012.html

This also updates guestfish to use the new API for its progress bars.
2011-03-15 12:16:50 +00:00
Richard W.M. Jones
a20e5c00c3 fish: Add guestfish --live, guestmount --live options.
The other programs have the variable, but the flag is not enabled
either because it doesn't make sense or because the implications are
not well understood.
2011-02-03 18:50:45 +00:00
Richard W.M. Jones
cfd9513a54 Add guestfs_add_domain 'live' flag.
This optional flag controls whether this API call will try to connect
to a running virtual machine 'guestfsd' process.

If the flag is given and the virtual machine is running, then the
libvirt XML is parsed looking for a suitable <channel> element, and
'guestfs_set_attach_method' is called with the corresponding
virtio-serial socket path.
2011-02-03 18:50:45 +00:00
Richard W.M. Jones
316ad8311a fish: Initialize pcmd structure.
On Debian we get this warning which I'm pretty sure is bogus:

fish.c:690: error: 'pcmd.cmd' may be used uninitialized in this
function [-Wuninitialized]
2011-01-18 22:38:05 +00:00
Richard W.M. Jones
c3887285ab fish: <! cmd executes a shell command and inlines the resulting commands.
The new guestfish construct "<! cmd" executes the shell command
"cmd", and then anything printed to stdout by "cmd" is parsed
and executed as a guestfish command.

This allows some very hairy shell scripting with guestfish.
2011-01-18 13:16:28 +00:00
Richard W.M. Jones
61a4db138e fish: Factor out command line parsing.
Factor out the code which splits a string into a command line.
2011-01-18 11:24:38 +00:00
Richard W.M. Jones
4bcb267a24 fish: Make exit_on_error into a completely local variable.
Note that 'time' and 'glob' (which both run subcommands) do not
correctly pass the exit_on_error flag in the remote case.  This is not
a regression: the current code doesn't work either.
2011-01-18 10:33:01 +00:00
Richard W.M. Jones
f6a21c1e0d fish: exit_on_error is a local variable. 2011-01-18 10:21:49 +00:00
Richard W.M. Jones
5376e13806 fish: Remove some unused local variables. 2010-12-09 11:55:23 +00:00
Richard W.M. Jones
272b754093 fish: Don't use external pod2text program.
This removes the dependency from guestfish to the external
pod2text program (and hence the final dependency on perl for
guestfish).  This is done by storing the formatted pod2text
output in guestfish as the help text.
2010-11-26 21:51:11 +00:00
Richard W.M. Jones
70faafe8d4 fish: Keep device names in options drives list.
In the 'struct drv *drvs' structure, keep a list of the
device name(s) for each added drive or guest.  The device name
is the canonical name as that drive would be known inside
libguestfs, eg. "/dev/sda"
2010-11-25 15:40:56 +00:00
Richard W.M. Jones
2c4a7ef92a fish: Add --rw option (does nothing yet).
This adds the guestfish --rw option, intended in future
to be required for writing to disk images.

At the moment this does not change the default and so does
nothing.  This patch is intended for backporting to the
stable branches so that we can start to introduce scripts
which use 'guestfish --rw'.
2010-11-08 10:21:48 +00:00
Richard W.M. Jones
371e83c090 fish: Add --listen --csh to for csh, tcsh compatibility.
(Thanks Eric Blake).
2010-11-05 15:39:27 +00:00
Richard W.M. Jones
a232e62dcf fish: '-i' option automatically handles whole-disk encryption.
This feature is also available in guestmount because of the
shared option parsing code.

You don't need to do anything to enable it, just using -i
will attempt decryption of encrypted partitions.

Only works for simple Fedora whole-disk encryption.  It's a
work-in-progress to make it work for other types of encryption.
2010-11-05 11:39:24 +00:00
Richard W.M. Jones
74f7c9e4b7 fish: Make the 'help' command more helpful. 2010-11-04 17:04:03 +00:00
Richard W.M. Jones
c66d6f215e Unify guestfish and guestmount options processing (RHBZ#642932).
In guestfish, factor out the processing of the options -a, -c,
-d, -i, -m, -n, -r, -v, -V, -x into a separate set of files:
options.c, options.h, inspect.c, virt.c.

Change guestmount so that it uses these same files (from the
../fish directory) to process the same options.

This unifies the handling of these options between the two programs.
It also adds the useful inspection feature to guestmount, so you
can now do:

  guestmount -d Guest -i --ro mnt/
2010-10-27 12:04:16 +01:00
Richard W.M. Jones
f48cd1f262 Enable autosync by default. 2010-10-27 10:59:45 +01:00
Richard W.M. Jones
0c1d3c02a8 fish: Specify format of disks (RHBZ#642934,CVE-2010-3851).
For libvirt guests, the disk format is copied from libvirt (if
libvirt knows it).

For command line disk images, you can use --format to override
format auto-detection.
2010-10-22 17:45:06 +01:00
Richard W.M. Jones
c9c0ac7d36 Allow $TMPDIR to override most temporary directory uses.
Be more consistent in allowing the user to override use of the
temporary directory by specifying $TMPDIR.  Also prefer P_tmpdir
macro (defined in <stdio.h>) if that is defined, rather than
hard-coding "/tmp" for the fallback location.
2010-09-24 19:25:06 +01:00
Richard W.M. Jones
734b2d2483 fish: Fix segfault in free_drives() function.
This updates commit 8ea62c8d7f
so it doesn't try to free the optarg (stack-allocated) strings.
2010-09-22 11:59:58 +01:00
Richard W.M. Jones
8c5a4d949e leak: Clear history before exiting guestfish.
Clear the in-memory history before exiting.  This removes
some but not all memory leaks associated with using the GNU
History library.  As far as I can tell it is not possible to
free up everything used by GNU History.

(Found by valgrind).
2010-09-21 19:51:22 +01:00
Richard W.M. Jones
8ea62c8d7f leak: Free list of drives and mountpoints in guestfish.
Previously the list of -a, -d, -m, -N parameters were leaked.  This
change frees them explicitly.

This is not such an important fix since guestfish is a one-shot
program, but it aids in finding other leaks in future.

(Found by valgrind).
2010-09-21 19:51:22 +01:00
Richard W.M. Jones
ff4ae8633e fish: Add --echo-keys option to allow passphrases/keys to be echoed.
See also:
http://catless.ncl.ac.uk/Risks/26.17.html#subj13.3
2010-09-21 10:56:47 +01:00
Richard W.M. Jones
0003ea2c3d generator: Generate guestfish-only commands.
The guestfish-only commands such as 'alloc' and 'edit' are
now generated from one place in the generator instead of being
spread around ad-hoc in the C code.
2010-09-18 09:38:05 +01:00
Richard W.M. Jones
3eb76554ef fish: Correction for online help for 'edit' and 'more' commands.
This corrects commit b5c287bcd4
and commit 639ca1828b.
2010-09-17 14:35:48 +01:00
Richard Jones
dd093a7660 fish: If -m option fails, suggest a mountpoint. 2010-09-15 21:47:37 +01:00
Richard Jones
c98f073361 fish: In usage message use new-style -i option syntax. 2010-09-14 22:29:08 +01:00
Richard Jones
42b62b8240 fish: Update copyright dates in usage message. 2010-09-14 22:28:10 +01:00
Richard Jones
31a2c006cd fish: Remove extraneous space from usage message. 2010-09-14 22:27:06 +01:00
Richard Jones
513363290e syntax: Remove unused assert.h header. 2010-09-10 22:57:52 +01:00
Richard Jones
2635a9c70e fish: Implement copy-in and copy-out commands. 2010-09-09 23:12:19 +01:00
Richard Jones
fa918b166a fish: Allow guestfish -N help for listing prepared disk image help. 2010-09-08 09:59:32 +01:00
Richard Jones
54837f6d7b fish: Implement progress bars in guestfish.
The progress bar is updated 3 times per second, and is not displayed
at all for operations which take less than two seconds.

You can disable progress bars by using the flag --no-progress-bars,
and you can enable progress bars in non-interactive sessions with
the flag --progress-bars.

A good way to test this is to use the following command:

guestfish --progress-bars \
          -N disk:10G \
          zero-device /dev/sda

(adjust "10G" to get different lengths of time).
2010-09-01 14:20:02 +01:00
Richard Jones
3003df6bbc fish: Detect UTF-8 output and open termcap/terminfo database.
Provide a generic mechanism within guestfish to detect if
output if UTF-8 and to open the termcap (or terminfo) database
for the current terminal type.
2010-09-01 12:03:35 +01:00
Richard Jones
4932fdca3c build: Don't add version extra string to the version number.
If this string was non-empty, then it broke a lot of things because
autoconf and other parts of the build system were expecting this
string to contain a simple MAJOR.MINOR.RELEASE version number.

This requires changes to guestfish and guestmount so they use the
guestfs_version API to fetch the version from the library.  (The
Perl tools were already doing it this way).  In a way this is more
accurate, because it's no longer hard-coded in the binary, but
fetched from the dynamically linked libguestfs.so.
2010-08-27 13:38:49 +01:00
Richard Jones
4440e22f4f fish: Reimplement -i option using new C-based inspection.
Don't shell out to virt-inspector.  Instead, use the new C-based
inspection APIs.

This is much faster.

The new syntax is slightly different:

  guestfish -a disk.img -i
  guestfish -d guest -i

However, the old syntax still works.
2010-08-17 14:09:25 +01:00
Richard Jones
1a9aa565b3 fish: Add -c/--connect and -d/--domain options.
The -d option lets you specify libvirt domains.  The disks from
these domains are found and added, as if you'd named them with -a.

The -c option lets you specify a libvirt URI, which is needed
when we consult libvirt to implement the above.
2010-08-17 14:09:25 +01:00
Richard Jones
581a7965fa generator: Add 'Key' parameter type.
Add a 'Key' parameter type, used for passing sensitive key material
into libguestfs.

Eventually the plan is to mlock() key material into memory.  However
this is very difficult to achieve because the encoded XDR strings
end up in many places.  Therefore users should note that key material
passed to libguestfs might end up in swap.

The only difference between 'Key' and 'String' currently is that
guestfish requests the key from /dev/tty with echoing turned off.
2010-07-21 19:49:22 +01:00
Richard Jones
8161ea9bb0 fish: Don't fail if -m and --listen flags are both given (RHBZ#612178).
Testing this against a Fedora disk image:

$ ./fish/guestfish --ro -a F13.img -m /dev/sda1 --listen
export GUESTFISH_PID=6033
$ ./fish/guestfish --remote=6033 -- ping-daemon
$ ./fish/guestfish --remote=6033 -- ping-daemon
$ ./fish/guestfish --remote=6033 -- exit

Without this fix the first remote command would fail because
qemu would have already been killed.
2010-07-07 15:03:51 +01:00
Richard Jones
f2b7a8e15c fish: help command return error for non-existent commands (RHBZ#597145).
With this change, the exit status indicates error for non-existent
commands.

$ guestfish -h foo
foo: command not known, use -h to list all commands
$ echo $?
1
$ guestfish help foo
foo: command not known, use -h to list all commands
$ echo $?
1
2010-06-02 13:38:00 +01:00
Richard Jones
21bd2db7cf fish: Don't eat words when completing case-insensitive paths (RHBZ#582993). 2010-05-25 13:59:44 +01:00
Richard Jones
c9f1a45334 fish: New command: 'supported'
This checks all available optional groups and prints out which
ones are supported by the daemon.  Note you must launch the appliance
first.

Example:

><fs> supported
      augeas yes
     inotify yes
 linuxfsuuid yes
linuxmodules yes
 linuxxattrs yes
        lvm2 yes
       mknod yes
      ntfs3g yes
   ntfsprogs yes
    realpath yes
       scrub yes
     selinux yes
          xz yes
    zerofree yes
2010-05-25 11:31:11 +01:00
Richard Jones
5e1aff7856 fish: Allow suffixes on number parameters (eg. 1M)
This small change uses the gnulib xstrtoll functionality to
enable suffixes on integer parameters in guestfish.  For example:

 truncate-size /file 1G

(previously you would have had to given the full number).

This also applies to the 'alloc' and 'sparse' commands (and
indirectly to the -N option).  The specification for these commands
has changed slightly, in that 'alloc foo 1MB' would now use SI
units, allocating 1000000 bytes instead of a true megabyte.  All
existing uses would use 'alloc foo 1M' which still allocates true
megabytes.
2010-05-21 14:51:53 +01:00
Richard Jones
3920ad95f6 New API: write for creating files with fixed content (RHBZ#501889).
The guestfs_write call can be used to create small files with
arbitrary 8 bit content, including \0 bytes.

This replaces and deprecates write-file, which cannot be modified
to use BufferIn because of an unfortunate choice in the ABI: the
size parameter to write-file, if zero, means that the daemon tries
to calculate the length of the buffer using strlen.  However this
fails if we pass a zero-length buffer using BufferIn because then
the daemon tries to do strlen on a (really) zero length buffer, not
even containing a terminating \0 character, thus segfaulting.
2010-05-20 10:30:12 +01:00
Richard Jones
5af010c96d fish: Fix build error if built without readline.
fish.c:1447: error: 'add_history_line' defined but not used [-Wunused-function]

(Reported by Matt Booth)
2010-05-20 10:30:12 +01:00
Richard Jones
11a2ad8c9a guestfish: Fix build error in 'print_shell_quote' function.
Amend commit 1c6ed48bd3 so the prototype of
'print_shell_quote' function is correct.
2010-05-13 17:07:45 +01:00
Richard Jones
1c6ed48bd3 guestfish -i and virt-inspector work on filenames containing spaces (RHBZ#507810).
This commit fixes a long-standing bug which prevented guestfish -i
and virt-inspector from working on disk images which had a space
in the filename (or other unsafe characters).  It works by ensuring
that the strings passed between guestfish -i and virt-inspector are
quoted correctly in both directions.

Note that this commit adds a dependency from virt-inspector to
the perl module String::ShellQuote.  We have previously used this
module in virt-make-fs.
2010-05-13 16:22:05 +01:00
Richard Jones
87eecb507e fish: With both '-x' and '-i', pass through '-x' to inferior process. 2010-05-12 16:13:07 +01:00
Richard Jones
214a803ac5 Revert "fish: Add 'please wait' message when launching (and interactive)."
This reverts commit 01fedcde05.
2010-05-08 09:45:19 +01:00