Commit Graph

163 Commits

Author SHA1 Message Date
Richard W.M. Jones
5ff81f7d6e perl: Add %guestfs_introspection hash with introspection information.
Because this is a useful introspection API, it is a candidate for
being backported into older stable branches.
(cherry picked from commit 365885dab2)
2011-10-31 09:57:22 +00:00
Richard W.M. Jones
7d809dfd42 Add an optional group ("grub") for the guestfs_grub_install API.
This also improves the documentation for this call, pointing out
several pitfalls in using it.

This unfortunately breaks existing callers that might use
guestfs_grub_install without checking for this new group.
(cherry picked from commit 99624d2922)
2011-09-16 16:15:37 +01:00
Richard W.M. Jones
8e9e6725b4 ruby: Check Ruby callback exists before we call it (RHBZ#733297).
(cherry picked from commit 1a4f1df77e)
2011-09-16 16:15:36 +01:00
Richard W.M. Jones
88f9599e1f ruby: Use a regular C array to pass the arguments through rb_rescue.
(cherry picked from commit 675f336319)
2011-09-16 16:15:36 +01:00
Richard W.M. Jones
32a8b0f54c ruby: Append newline character after printing exception in callback.
(cherry picked from commit 0cd5b9ac15)
2011-09-16 16:15:36 +01:00
Richard W.M. Jones
8ce64bd62f Coverity: in daemon, free struct in RStruct, RStructList functions.
(cherry picked from commit b2edcbe1b9)
2011-09-16 16:15:35 +01:00
Richard W.M. Jones
68fcbb6f5f pclose: Fix other places where we only tested pclose == -1.
pclose can return > 0 when the status of the command was non-zero.
(cherry picked from commit 631faad971)
2011-09-16 16:15:35 +01:00
Richard W.M. Jones
403af82609 Coverity: Check return value from sscanf in bindtests calls.
(cherry picked from commit 4c76aaa391)
2011-09-16 15:48:29 +01:00
Richard W.M. Jones
b2aa2ef621 Note that additional memory may be required to typecheck Augeas lenses (RHBZ#729887).
(cherry picked from commit 7739d7f471)
2011-08-17 13:05:23 +01:00
Richard W.M. Jones
2fb83cc8ed fish: Declare run_* functions in a generated header file.
Calls to these functions are generated, so there is no need to declare
the functions by hand.

Cherry picked from commit 3064277680
and backported to stable-1.10 branch.
2011-08-17 12:31:38 +01:00
Richard W.M. Jones
340a13f991 docs: Fix function names in deprecation notices.
(cherry picked from commit 60adf092a8)
2011-08-07 22:00:50 +01:00
Richard W.M. Jones
b1e84c723d guestfs.h: Add missing extern keyword before event functions.
(cherry picked from commit 4b53a3737b)
2011-07-27 15:02:06 +01:00
Richard W.M. Jones
696d8b681d Document that ntfsresize cannot be used multiple times (RHBZ#685009).
(cherry picked from commit 2ba2ddf211)
2011-07-13 17:16:23 +01:00
Richard W.M. Jones
b3c030caca protocol: Force optargs_bitmask to be passed as 0 for non-opt actions.
If the action doesn't take optional arguments, nevertheless force the
optargs_bitmask field in the header to be passed as 0, and give an
error if not.
(cherry picked from commit 0344248af5)
2011-07-13 17:16:06 +01:00
Richard W.M. Jones
b04c998b11 capitests: Allow tests to properly test optional arguments.
For optional arguments, you can now specify empty string to mean no
argument, except for String optional arguments where you must use
"NOARG" (empty string meaning a supplied empty string argument).
(cherry picked from commit f7a11c6043)
2011-07-13 17:15:47 +01:00
Richard W.M. Jones
a3f4c85bd1 generator: Fix functions with both RBufferOut and optional args.
No current function returns RBufferOut and has optional args.  Such
functions would be generated incorrectly.

RBufferOut implies a silent "size_t *size_r" argument is added after
the regular arguments and before the optional arguments.  Various
changes to the code generator need to be made to take this into
account.
(cherry picked from commit adb5db58d8)
2011-07-13 16:51:18 +01:00
Richard W.M. Jones
16e022871c trace: Print empty list correctly.
Empty lists returned by RStringList and RHashtable functions
were incorrectly printed as [""].

Fix this so they are printed as [] instead.
(cherry picked from commit 56b94f5f6a)
2011-07-13 16:49:57 +01:00
Richard W.M. Jones
dc6b633ea5 generator: Rewrite UUIDs that begin with zero byte.
In util-linux <= 2.19, mkswap -U cannot handle the first byte of the
UUID being zero, so we artificially rewrite such UUIDs.

See: http://article.gmane.org/gmane.linux.utilities.util-linux-ng/4273
(cherry picked from commit 4ee190628b)
2011-06-13 19:00:17 +01:00
Richard W.M. Jones
5cb480857f Document that guestfs_file output depends on file(1) command.
And therefore practically it cannot be part of the ABI since
the output of file(1) itself changes from time to time.
(cherry picked from commit ef6f877b9d)
2011-06-13 14:19:15 +01:00
Richard W.M. Jones
87a2ee5096 generator: Mark sfdisk functions as deprecated.
Point to the part-* API calls as replacements.
(cherry picked from commit 12414ddc02)
2011-06-13 14:19:03 +01:00
Richard W.M. Jones
58cfbe23a5 generator: Mark mount as deprecated.
Callers should use 'mount_options' or 'mount_vfs' instead.

See also:
http://libguestfs.org/guestfs.3.html#libguestfs_gotchas
(cherry picked from commit 4ec8fd189d)
2011-06-13 14:18:59 +01:00
Richard W.M. Jones
980b7525e6 generator: Mark wait_ready as deprecated.
The function has been a no op for a very long time.  By marking
it as deprecated we make it clear that you shouldn't call it
in new code.
(cherry picked from commit 31de91f6d2)
2011-06-13 14:18:55 +01:00
Richard W.M. Jones
ff2b337389 generator: Check the flags fields.
(cherry picked from commit b43482964a)
2011-06-13 14:18:44 +01:00
Richard W.M. Jones
2cee1bbfd0 lib: Add GCC version macro to the header file.
This will be used to internally enable various GCC enhancements.
(cherry picked from commit 33adb59b60)
2011-06-13 14:17:40 +01:00
Richard W.M. Jones
7dd9c522bb lib: Add vertical space between each function in <guestfs.h>.
(cherry picked from commit 36b236fc97)
2011-06-13 14:17:31 +01:00
Richard W.M. Jones
65acc7ce62 doc: Use I<-...> for cross-references to command line options.
This is now used consistently across all the documentation.
(cherry picked from commit c49fc3831d)
2011-05-18 11:40:31 +01:00
Richard W.M. Jones
bcb11e7a28 zero: Disable file test because of bug in file command.
See: https://bugzilla.redhat.com/show_bug.cgi?id=705499
(cherry picked from commit f55b32b2db)
2011-05-18 11:40:30 +01:00
Richard W.M. Jones
27a8596c22 python: Rearrange C files for bindings.
Move the hand-written functions into two new files:
guestfs-py.h and guestfs-py-byhand.c

This is just code motion.
(cherry picked from commit 16da7589e9)
2011-04-24 09:22:41 +01:00
Richard W.M. Jones
38f8ca3674 perl: Decrement refcount in $g->delete_event_callback.
This updates commit bc468c87d0.
(cherry picked from commit 3acf732c2f)
2011-04-24 09:22:33 +01:00
Richard W.M. Jones
ef9f82e16c inspect: "centos" and "scientificlinux" are now separate distros.
Previously we returned "rhel" for these, which was not accurate.
(cherry picked from commit 2b0ca7e7b8)
2011-04-24 09:22:17 +01:00
Richard W.M. Jones
7881c85d3a python: Release Python GIL while running libguestfs calls.
Release the Python global interpreter lock while running libguestfs
calls.

We don't release it around guestfs_create() because that is a short
call that just allocates memory.  We do release it around
guestfs_close() since that is a potentially long-running (it can call
wait(2) amongst other things).  We also release it around all the
other generated Python calls.

We don't yet support callbacks into Python code (ie. the new event
API).  But when we do in future, we will need to also handle the GIL
around those callbacks.

This code is adapted from libvirt's python/typewrappers.h.  Thanks to
Dan Berrange for showing us how to do this properly.
(cherry picked from commit 08dc4a87b9)
2011-04-18 22:12:59 +01:00
Richard W.M. Jones
b8be128caa fish: Enhance guestfish win:... parsing to understand drive letters. 2011-04-05 20:01:59 +01:00
Richard W.M. Jones
13d8963d8c New API: inspect-get-drive-mappings
This returns the drive mappings from the Windows Registry.

virt-inspector displays the drive mappings, giving output
similar to this:

  <drive_mappings>
    <drive_mapping name="C">/dev/sda2</drive_mapping>
    <drive_mapping name="E">/dev/sdb1</drive_mapping>
  </drive_mappings>
2011-04-05 20:01:57 +01:00
Richard W.M. Jones
9e7c6a5483 New API: inspect-get-windows-current-control-set
This returns the actual registry key corresponding to
CurrentControlSet (eg. it might be "ControlSet001").

Previously the inspection code was hard-coding ControlSet001.  Now we
use the correct control set, and also make it available to callers
through the API.

This commit also updates the virt-dhcp-address example so it uses this
new API.

virt-inspector displays the current control set when available.
2011-04-05 20:01:15 +01:00
Richard W.M. Jones
afa1780959 python: Convert any iterable argument to a list (RHBZ#693324).
Thanks to Erez Shinan.
2011-04-04 12:48:02 +01:00
Richard W.M. Jones
9b60f3a9f3 du: Add pulse mode progress messages. 2011-04-01 18:37:49 +01:00
Richard W.M. Jones
40f7323134 daemon: Introduce "pulse mode" progress events.
This introduces a new form of progress event, where we don't know how
much of the operation has taken place, but we nevertheless want to
send back some indication of activity.  Some progress bar indicators
directly support this, eg. GtkProgressBar where it is known as "pulse
mode".

A pulse mode progress message is a special backwards-compatible form
of the ordinary progress message.  No change is required in callers,
unless they want to add support for pulse mode.

The daemon sends:

 - zero or more progress messages with position = 0, total = 1
 - a single final progress message with position = total = 1

Note that the final progress message may not be sent if the call fails
and returns an error.  This is consistent with the behaviour of
ordinary progress messages.

The daemon allows two types of implementation.  Either you can just
call notify_progress (0, 1); ...; notify_progress (1, 1) as usual.

Or you can call the functions pulse_mode_start, pulse_mode_end and/or
pulse_mode_cancel (see documentation in daemon/daemon.h).  For this
second form of call, the guarantee is very weak: it *just* says the
daemon is still capable of doing something, and it doesn't imply that
if there is a subprocess that it is doing anything.  However this does
make it very easy to add pulse mode progress messages to all sorts of
existing calls that depend on long-running external commands.

To do: add a third variant that monitors a subprocess and only sends
back progress messages if it's doing something, where "doing
something" might indicate it's using CPU time or it's printing output.
2011-04-01 16:05:45 +01:00
Richard W.M. Jones
371eabfae3 Generate progress messages during launch.
This commit generates approximate progress messages during the
guestfs_launch call.  Currently this code generates:

   0 / 12: launch clock starts
   3 / 12: appliance created
   6 / 12: detected that guest kernel started
   9 / 12: detected that /init script is running
  12 / 12: launch completed successfully

(Note this is not an ABI and may be changed or removed in a future
version).

Progress messages are only generated at all if 5 seconds have elapsed
since the launch, and they are only generated for the ordinary
appliance (not if using attach-method to attach to an existing virtio
serial port).
2011-04-01 16:05:30 +01:00
Richard W.M. Jones
94945d84c7 docs: Fix link to progress messages in guestfs(3).
This updates commit 4e0cf4dbf8.
2011-04-01 16:05:30 +01:00
Richard W.M. Jones
e751293e10 ruby: Don't segfault if callbacks throw exceptions (RHBZ#664558).
(Thanks Chris Lalancette).

See:
https://bugzilla.redhat.com/show_bug.cgi?id=664558#c6
2011-03-28 10:03:16 +01:00
Richard W.M. Jones
23b7c92b0d inspector: Add detection of Slackware. 2011-03-25 11:22:38 +00:00
Richard W.M. Jones
3f1e3223c4 New API: guestfs_inspect_get_product_variant
This returns a product variant for inspected operating systems.  In
practice this is a useful way to distinguish between consumer and
enterprise/server versions of Windows that otherwise have the same
version number.
2011-03-23 16:00:48 +00:00
Richard W.M. Jones
f4d996fd26 proto: Fix both-ends-cancel case.
In the case where both ends cancel at the same time (eg. both ends
realize there are errors before or during the transfer), previously we
skipped sending back an error from the daemon, on the spurious basis
that the library would not need it (the library is cancelling because
of its own error).

However this is wrong: we should always send back an error message
from the daemon in order to preserve synchronization of the protocol.

A simple test case is:

  $ guestfish -N fs -m /dev/sda1 upload nosuchfile /
  libguestfs: error: open: nosuchfile: No such file or directory
  libguestfs: error: unexpected procedure number (66/282)

(Notice two things: there are errors at both ends, and the
loss of synchronization).

After applying this commit, the loss of synchronization does not occur
and we just see the library error:

  $ guestfish -N fs -m /dev/sda1 upload nosuchfile /
  libguestfs: error: open: nosuchfile: No such file or directory

The choice of displaying the library or the daemon error is fairly
arbitrary in this case -- it would be valid to display either or even
to combine them into one error.  Displaying the library error only
makes the code considerably simpler.

This commit also (re-)enables a test for this case.
2011-03-18 18:27:24 +00:00
Richard W.M. Jones
33b638109e proto: Fix FileIn ops that abort during the chunk upload stage.
As a previous, incorrect attempt to fix RHBZ#576879 we tried to
prevent the daemon from sending an error reply if the daemon had
cancelled the transfer.  This is wrong: the daemon should send an
error reply in these cases.

A simple test case is this:

  guestfish -N fs -m /dev/sda1 upload big-file /

(This fails because the target "/" is a directory, not a file.)
Prior to this commit, libguestfs would hang instead of printing an
error.  With this commit, libguestfs prints an error.

What is happening is:

  (1) Library is uploading
  a file                          (2) In the middle of the long
                                  upload, daemon detects an error.
                                  Daemon cancels.
  (3) Library detects cancel,
  sends cancel chunk, then waits
  for the error reply from the
  daemon.                         (4) Daemon is supposed to send
                                  an error reply message.

Because step (4) wasn't happening, uploads that failed like this would
hang in the library (waiting for the error message, while the daemon
was waiting for the next request).

This also adds a regression test.

This temporarily breaks the "both ends cancel" case (RHBZ#576879c5).
Therefore the test for that is disabled, and this is fixed in the next
patch in the series.

This partially reverts commit dc706a639e.
2011-03-18 17:56:45 +00:00
Richard W.M. Jones
502a98948c haskell: Small fixes for ghc 7. 2011-03-18 11:19:31 +00:00
Richard W.M. Jones
883390fb2e perl: Binding and test for guestfs_last_errno (RHBZ#672491). 2011-03-15 16:49:12 +00:00
Richard W.M. Jones
cf26ef818e ruby: Use ALLOC_N to avoid potential memory leak (RHBZ#667610). 2011-03-15 15:00:58 +00:00
Richard W.M. Jones
c50ed37b71 ruby: Remove unnecessary checking around StringValueCStr (RHBZ#667610). 2011-03-15 14:53:16 +00:00
Richard W.M. Jones
e9f25e693e ruby: Add rdoc documentation (RHBZ#667610). 2011-03-15 14:53:08 +00:00
Richard W.M. Jones
6a64114929 New event API - Ruby bindings (RHBZ#664558). 2011-03-15 12:16:51 +00:00