Commit Graph

387 Commits

Author SHA1 Message Date
Richard W.M. Jones
1784e08830 daemon: Use stdint UINT64_C instead of <const>ULL.
(cherry picked from commit cd29c50ca8)
2010-10-23 13:15:31 +01:00
Richard Jones
1f6985069f daemon: Move 'exists', 'is-file' and 'is-dir' to separate file.
This commit is just code movement.
(cherry picked from commit 3a99114360)
2010-10-23 12:12:21 +01:00
Richard Jones
a9cff0636f daemon: Don't warn about 'long long' usage.
This removes a fatal warning (-Werror) which stops compilation
on 32 bit machines.
(cherry picked from commit aa96881a51)
2010-09-08 14:17:56 +01:00
Richard Jones
61340088b3 parted: Check partition number >= 1 in several calls.
(cherry picked from commit cbb0260368)
2010-06-02 19:50:59 +01:00
Richard Jones
235aabfacf daemon: Parse output of old parted which didn't support -m option (RHBZ#598309).
This fixes the following commands when run with RHEL 5-era parted:

  get-bootable
  get-parttype
  part-list
(cherry picked from commit 3ab2d089f3)
2010-06-02 19:50:22 +01:00
Richard Jones
45e3f231be daemon: count_strings function returns size_t
(cherry picked from commit aee7d55fcf)
2010-06-02 19:49:59 +01:00
Richard Jones
fb0ba47674 daemon: write-file: Check range of size parameter (RHBZ#597135).
This also adds a regression test.

For stable-1.2 branch:
 - cherry picked from commit 9733d47469
 - modify the regression test to apply against the generator
2010-06-02 19:41:33 +01:00
Richard Jones
8e620995b5 daemon: Limit label lengths (RHBZ#597118).
(cherry picked from commit 52f9cd4882)
2010-06-02 19:39:50 +01:00
Richard Jones
858661ca96 daemon: Kill blkid cache to improve reliability of blkid commands.
By killing the cache file, we make blkid work in situations such
as a just-created filesystem.
(cherry picked from commit 21c42e9fab)
2010-06-02 19:39:37 +01:00
Richard Jones
261622b56e daemon: Generalize the implementation of vfs-type.
Note that there is no change to the semantics of the code.
(cherry picked from commit 85c71f8fff)
2010-06-02 19:39:25 +01:00
Richard Jones
3101ea517d Fix error message in strings-e command (RHBZ#588651).
(cherry picked from commit 287f8957fe
and modified to apply to the stable branch.  Note that the original
commit message contains a typo 'string-e' instead of 'strings-e')
2010-05-14 17:23:44 +01:00
Richard Jones
ee57a338ba Run udev_settle() after swapon/swapoff (RHBZ#516096).
(cherry picked from commit 9d158c3ab1)
2010-05-14 17:23:44 +01:00
Richard Jones
3f3d881dc3 daemon: gnulib module 'error' is used directly by the daemon.
(cherry picked from commit b52ef0b021)
2010-05-14 17:11:28 +01:00
Richard Jones
988a707f37 daemon: Fix read-file so it fails gracefully for large files (RHBZ#589039).
Pengzhen Cao noticed that read-file would fail for files
larger than the protocol size; this is *not* the bug.  However
it would also lose protocol synchronization after this.

The reason was that functions which return RBufferOut in the
generator must not 'touch' the *size_r parameter along error
return paths.

I fixed read-file and initrd-cat, and I checked that pread was
doing the right thing.

This also adds regression tests for read-file with various categories
of large file.
(cherry picked from commit 42f59b28f1)
2010-05-14 17:06:06 +01:00
Richard Jones
47bd233069 Change network configuration to use macros.
Change the network configuration so everything is set using
some macros at the top of src/guestfs.c.

Also, rename the macros used in the daemon so they are not the
same.  It was a very long time since these sets of macros had to
match the ones defined in src/guestfs.c, despite what the comment
said.

Note that this commit should not change the semantics of the
program at all.
(cherry picked from commit 8a9f2ca655)
2010-05-14 16:59:45 +01:00
Richard Jones
7c434ceb4b lvresize: Use --force so it can make LVs smaller (RHBZ#587484).
This also adds a regression test for this bug.
(cherry picked from commit c24de46d06)
2010-04-30 17:38:11 +01:00
Richard Jones
ad7afde90f daemon: Split out checksum type to program name mapping into function.
This shouldn't change the semantics of the program.

For stable-1.2 this was cherry picked from commit af29c84 and
rebased against the older code in daemon/checksum.c.
2010-04-23 17:10:07 +01:00
Richard Jones
e240b51188 Improved checking, documentation of modes (RHBZ#582901, RHBZ#582929).
chmod: Disallow negative mode, document mode affected by umask.

mkdir-mode: Disallow negative mode, document that filesystems
may interpret the mode in different ways.

mknod: Disallow negative mode, document mode affected by umask.

umask: Check the range of umask mask value carefully.
(cherry picked from commit 61ab83d190)
2010-04-20 08:43:42 +01:00
Richard Jones
e84ab94975 New partition APIs: part_del, part_get_bootable, part_get/set_mbr_id
These APIs flesh out further the partitioning API.

Note for stable-1.2 branch:
Cherry picked from b68c030adf and modified
to apply against stable-1.2.  We need these new APIs
in order to support bugfixes in virt-resize.
2010-04-12 19:07:12 +01:00
Richard Jones
7095bab611 daemon: More reliable parsing of the output from 'parted print'.
Previously we used strtok.  However this has the problem that
strtok considers multiple delimiter characters to be like a single
delimiter, eg. "1:::2" would be parsed the same as "1:2".  In
other words, the previous code would skip over or fail if there
are empty fields.
(cherry picked from commit cb9350019c)
2010-04-12 19:04:13 +01:00
Richard Jones
b15faa4319 daemon: Make the RUN_PARTED macro take an error statement.
This allows us to make the RUN_PARTED macro do something else
along the error path, other than just returning -1.
(cherry picked from commit 440ad646cd)
2010-04-12 19:04:01 +01:00
Richard Jones
837b66e30e Allow aug-ls to take Augeas variable as argument (RHBZ#580016).
(cherry picked from commit d1dd00606d)
2010-04-12 19:03:41 +01:00
Richard Jones
86fb1e3440 Code cleanups related to RHBZ#580246.
This includes various code cleanups:

 (a) A regression test for RHBZ#580246.

 (b) Use write instead of fwrite to write out the tar file.  This is
     just because the error handling of write seems to be better
     specified and easier to use.

 (c) Use size_t instead of int for length.

 (d) Clearer debug messages when in verbose mode.
(cherry picked from commit de7ef2a0fd)
2010-04-08 22:22:58 +01:00
Richard Jones
dfd7f552bb Fix tar-in command hangs when running out of disk space (RHBZ#580246).
The problem was this sequence of events:

 (1) File transfer goes through OK.

 (2) pclose returns failure (because 'tar' subprocess failed)

 (3) We try to cancel the transfer by calling cancel_receive.

Step (3) fails because the transfer (as far as the library is
concerned) has succeeded, so causing a hang.

The more fundamental reason why we see steps (1) and (2) is that
'tar' does NOT fail immediately if there is a write error.  Instead
it continues reading and discarding the input until the end of the
input before giving "Error exit delayed from previous errors".
IMHO this is a bug with tar, since an ENOSPC write error should
be fatal for tar.
(cherry picked from commit 07f4b20ae9)
2010-04-08 22:22:48 +01:00
Richard Jones
d5f98968a4 Check error returns from posix_fallocate (RHBZ#579664).
posix_fallocate has a non-standard way to return error indications.
Thus all our calls to posix_fallocate were effectively unchecked.  For
example:

  $ guestfish alloc test.img 1P
  $ echo $?
  0
  $ ll test.img
  -rw-rw-r--. 1 rjones rjones 0 2010-04-06 11:02 test.img
  $ rm test.img

With this change, errors are detected and reported properly:

  $ ./fish/guestfish alloc test.img 1P
  fallocate: File too large

This is a fix for:
https://bugzilla.redhat.com/show_bug.cgi?id=579664
(cherry picked from commit 2ade61d1f8)
2010-04-08 22:21:20 +01:00
Richard Jones
641e8275b3 daemon: Set TERM=dumb inside the daemon.
Since commit 977edb3185 we have been passing TERM from the
library into the appliance (for the benefit of virt-rescue).
However this changes the output of parted, which I would argue
is a bug in parted:

 TERM=xterm /sbin/parted -m -- /dev/sda unit b print 2>&1 | hexdump -C
 00000000  1b 5b 3f 31 30 33 34 68  42 59 54 3b 0a 2f 64 65  |.[?1034hBYT;./de|

Notice the escape-sequence junk before the official "BYT;"
header.

By setting TERM=dumb we avoid this.
2010-03-30 13:36:06 +01:00
Richard Jones
f826ce4876 Fix the error message when reply body is too large (RHBZ#509597). 2010-03-27 11:11:30 +00:00
Jim Meyering
b6a0c8565c Const-correctness fix. 2010-03-26 20:01:45 +00:00
Richard Jones
9e0b31a2af appliance: Set $PATH instead of hard-coding paths to binaries everywhere.
Change the appliance so PATH includes common directories.  Thus
we don't need to hard-code paths to binaries (eg. "/sbin/fdisk")
everywhere.
2010-03-26 13:36:30 +00:00
Richard Jones
00a9ae7365 Fix lvresize test on RHEL 5, by fixing guestfs_e2fsck_l.
The problem is that mkfs was making an ext2 filesystem,
which later we were checking with e4fsck.  e4fsck corrects
an "error" on the filesystem:
  /dev/VG/LV: Adding dirhash hint to filesystem.
e4fsck returns 1 (errors corrected) which we were interpreting
as an error return.
2010-03-24 23:28:14 +00:00
Richard Jones
c4e8aa245a Use ext4 dev tools on RHEL 5 (RHBZ#576688). 2010-03-24 22:02:34 +00:00
Richard Jones
b6483061c2 New API: guestfs_copy_size to copy a fixed number of bytes.
This is similar to 'guestfs_dd', but it copies just a fixed
number of bytes from the source to the destination.  It's an
error if the source is too short or if the destination is too
small.
2010-03-23 21:56:14 +00:00
Richard Jones
50d2af4f85 New APIs: Query the relationship between LVM objects.
These calls allow you to query the relationship between
LVM objects, for example, which PVs contain a VG, or which
LVs are contained in a VG.

See the example / test program 'regressions/test-lvm-mapping.pl'
for an example of how to do this from Perl.
2010-03-18 15:21:08 +00:00
Richard Jones
27e73269d3 daemon: Add a trim utility function.
This function trims the whitespace from around a string.  It
does this in-place, so it can be called for malloc'd strings.
2010-03-18 15:21:04 +00:00
Richard Jones
369872b91e Tab to space (whitespace fixes only). 2010-03-12 16:23:46 +00:00
Richard Jones
30a0b5cf16 Distribute .gitignore files.
These are useful for Debian since they keep the tarball unpacked
in git.
2010-02-15 15:35:07 +00:00
Richard Jones
e9c3711310 daemon: Don't need to prefix error messages with the command name.
The RPC stubs already prefix the command name to error messages.
The daemon doesn't have to do this.  As a (small) benefit this also
makes the daemon slightly smaller.

Code in the daemon such as:

  if (argv[0] == NULL) {
    reply_with_error ("passed an empty list");
    return NULL;
  }

now results in error messages like this:

  ><fs> command ""
  libguestfs: error: command: passed an empty list

(whereas previously you would have seen ..command: command:..)
2010-02-12 16:49:00 +00:00
Richard Jones
e4fbe3e2cd New API call: initrd-cat to list a file from an initrd. 2010-02-09 12:26:22 +00:00
Richard Jones
74fe427460 Implement 'vgrename' and 'lvrename' APIs. 2010-01-28 22:06:27 +00:00
Richard Jones
306077ac96 Add 'filesize' call.
Returns the size of a file.  You can already do this with 'stat',
but this call is good for scripting.
2010-01-25 11:37:12 +00:00
Richard Jones
008cbfcc15 Update to latest Gnulib. 2010-01-13 11:27:50 +00:00
Richard Jones
5c6147ecc7 daemon: Work around udevsettle issue (RHBZ#548121). 2009-12-18 19:20:37 +00:00
Richard Jones
983e7a2345 daemon error handling: Define a new function reply_with_perror_errno.
This allows you to save the errno from a previous call and
pass it to reply_with_perror.

For example, original code:

  r = some_system_call ();
  err = errno;
  do_cleanup ();
  errno = err;
  if (r == -1) {
    reply_with_perror ("failed");
    return -1;
  }

can in future be changed to:

  r = some_system_call ();
  err = errno;
  do_cleanup ();
  if (r == -1) {
    reply_with_perror_errno (err, "failed");
    return -1;
  }
2009-12-07 11:13:12 +00:00
Richard Jones
4b4e0d0d07 daemon error handling: recursive_mkdir shouldn't need to set errno. 2009-12-07 11:13:11 +00:00
Richard Jones
50c239c045 daemon error handling: Clear errno before calling stub functions.
This just ensures that we accurately report errors, even if our
error path code doesn't set errno.  We won't end up with a bogus
errno left over from a previous call.
2009-12-04 15:06:23 +00:00
Richard Jones
f02acc3d30 Whitespace change. 2009-11-27 14:32:47 +00:00
Richard Jones
940ef864d0 daemon: Move prototypes around to keep functions grouped logically. 2009-11-26 17:16:17 +00:00
Richard Jones
bba019781a Fix error handling in 'zero' function. 2009-11-26 17:16:17 +00:00
Richard Jones
a86eb0e0d2 Make realpath call optional, disable it for Windows. 2009-11-26 14:13:55 +00:00
Richard Jones
6699491803 build: update gnulib submodule to latest 2009-11-26 14:11:46 +00:00