summaryrefslogtreecommitdiffstats
path: root/daemon
Commit message (Collapse)AuthorAgeFilesLines
* Add an optional group ("grub") for the guestfs_grub_install API.Richard W.M. Jones2011-09-161-1/+8
| | | | | | | | | 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 99624d29226ece1abbbdd921183b360f5f80de91)
* daemon: Factor out name of virtio serial channel.Richard W.M. Jones2011-09-161-3/+5
| | | | | This is just code motion. (cherry picked from commit 73be6db9bf1c0ae96262a5f4fa9328bb4e648637)
* protocol: Fix case where download can fail for small files.Richard W.M. Jones2011-09-161-0/+6
| | | | | | | | | | | | | | There is another case where downloads of small files could fail if the library side (writer) fails. In this case the library would send back a cancellation, but it would be received after the daemon had finished sending the whole file (because the file is small enough). The daemon would reenter the main loop and immediately get an unexpected cancel message, causing the daemon to die. This commit also makes test-cancellation-download-librarycancels.sh more robust. We use Monte-Carlo testing with a range of file sizes. Small file sizes should trigger the error case. (cherry picked from commit e4cba8f2b1a68e7361ce342ff659cccb0490446e)
* blkid: Use -c /dev/null option to kill the cache.Richard W.M. Jones2011-07-271-9/+4
| | | | | | | On recent Debian, /etc/blkid.tab is now a symlink to /dev/.blkid.tab. Rather than chasing the cache file around (it may move to /run in future) use the -c /dev/null option to stop blkid from reading the cache. (cherry picked from commit 1d0f398d8e3c74ce6a70cbbb8d9b8ae07c6d7ef6)
* blkid: Detect when value not found and return empty string.Richard W.M. Jones2011-07-271-4/+15
| | | | | | | | | | | | | | | If the blkid command returns 2, that means the value was not found. Note that this changes the output of the vfs-type API when the filesystem has no type (eg when it is empty). Previously this would return an error. Now it returns empty string "". We did not document this either way. Making it return empty string is consistent with vfs-label and vfs-uuid. This change broke list-filesystems, since that code was assuming that vfs-type could only return a filesystem type or an error. (cherry picked from commit 168fd4ad5d1e5da93e11388095d41aaa8f804ceb)
* mkfs: Don't die if mke2fs is not available.Richard W.M. Jones2011-07-271-4/+4
| | | | | Allow other types of filesystems to be created. (cherry picked from commit c6340f45007b0ab7e1c5391cf78afc10a816553f)
* part-get-bootable: Fix when partitions are missing or unordered (RHBZ#602997).Richard W.M. Jones2011-07-131-4/+30
| | | | (cherry picked from commit 511c82df46f5c6f4a7f984fdb81d4691038ed6da)
* daemon: Keep Coverity happy by ignoring some return values.Richard W.M. Jones2011-06-133-7/+17
| | | | (cherry picked from commit f5096dd546ac43c7288b3ab7aec1562f070f78f6)
* Coverity: Don't return freed pointers from command* along error path.Richard W.M. Jones2011-06-131-2/+14
| | | | | | | | | | | If the external command failed to run, we could free up the allocated *stdoutput and *stderror pointers, but then return those freed pointers to the caller. The caller usually tries to print and free *stderror, so this is a serious error. Instead, return *stdoutput as NULL, and *stderror pointing to a generic error message. (cherry picked from commit 29453a58d818df24c238d0a08a68886ebe4029dd)
* Coverity: Missing return on error path.Richard W.M. Jones2011-06-131-0/+1
| | | | (cherry picked from commit 7a091a11d7aeddc170e4d1b833fd9d7d18c00841)
* Coverity: Ensure fp is closed along all error paths.Richard W.M. Jones2011-06-131-4/+6
| | | | (cherry picked from commit 346c5b0ebf58c81f657540eeb72abaa41bfc4e3f)
* Coverity: Close directory handle along error paths.Richard W.M. Jones2011-06-131-0/+2
| | | | (cherry picked from commit 7c020a14802255c966b2b402b983551b86a08bba)
* Coverity: Don't leak argv arrays.Richard W.M. Jones2011-06-131-0/+4
| | | | (cherry picked from commit 869c11b30c72c57e48dd63c4641087a06abe80d5)
* Coverity: Don't leak error strings.Richard W.M. Jones2011-06-135-3/+14
| | | | (cherry picked from commit 3135b8c378f9f98ae66e37fd79d305764334980d)
* Coverity: Check return value of sysroot_path.Richard W.M. Jones2011-06-131-1/+1
| | | | | For some reason we were checking the parameter! (cherry picked from commit 7fae594df719d1d81a043c4d0280b359f750facb)
* Coverity: Check return value of malloc.Richard W.M. Jones2011-06-131-0/+4
| | | | (cherry picked from commit 3a5bd5aba23583e64bfaabc906ca95b0f9d37578)
* Coverity: Don't close fd_cwd if fd_cwd == -1.Richard W.M. Jones2011-06-131-2/+5
| | | | (cherry picked from commit 76dfb74324fa0daa343d7edf89bd05e1fe7b4db0)
* Coverity: Avoid calling sort_strings (NULL, 0) on empty list.Richard W.M. Jones2011-06-131-2/+3
| | | | (cherry picked from commit 3ed8d5122026f37dd96cc7e8503c4f3ecf0afbb7)
* Coverity: Don't call free_strings (NULL).Richard W.M. Jones2011-06-131-1/+0
| | | | (cherry picked from commit 48ebf50f3136ac27f4252662e351230ffa2b15e5)
* Coverity: Remove unreachable code.Richard W.M. Jones2011-06-134-12/+0
| | | | (cherry picked from commit 9160eec4fbf12643d8d5fa13465066822b2fed92)
* daemon: Fix error message.Nikita A Menkovich2011-06-131-1/+1
| | | | (cherry picked from commit 08bc8e40cea750bd35493ecab514e8e37c883a0a)
* daemon: Make sysroot_len be size_t instead of int.Richard W.M. Jones2011-06-132-2/+2
| | | | (cherry picked from commit 4b91462bad010a0b214e808f94a916002be65b91)
* daemon: Remove some less useful debugging messages.Richard W.M. Jones2011-05-187-61/+7
| | | | | | | | | Remove some debug messages which were basically left over from when the code was being developed. However we leave debug messages where it is printing an external command that is about to be executed, since those are useful. (cherry picked from commit 5ce759bfdc70c97121ef34ab4d5c918d568f2474)
* Compile rpcgen-generated files with -fno-strict-aliasingMatthew Booth2011-04-071-6/+5
| | | | | rpcgen generates source which can't be safely compiled with strict-aliasing enabled.
* daemon: Reimplement 'mounts' and 'mountpoints' commands.Richard W.M. Jones2011-04-051-48/+29
| | | | | | | | Reimplement these so they read /proc/mounts instead of trying to parse the output of the 'mount' external command. One consequence of this is that these commands now work again for ntfs-3g filesystems.
* du: Add pulse mode progress messages.Richard W.M. Jones2011-04-011-1/+7
|
* cpmv: Add pulse mode progress messages.Richard W.M. Jones2011-04-011-1/+6
|
* checksum: Add pulse mode progress messages.Richard W.M. Jones2011-04-011-1/+6
|
* daemon: Introduce "pulse mode" progress events.Richard W.M. Jones2011-04-014-1/+136
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* daemon: When running commands, restart select if we receive a signal.Richard W.M. Jones2011-04-011-0/+4
|
* daemon: Reset SIGPIPE to default before running subprocesses.Richard W.M. Jones2011-04-011-0/+1
|
* RHEL 5: Use mke4fs on RHEL 5 as replacement for mke2fs.Richard W.M. Jones2011-03-253-3/+10
| | | | | Notes: Labels: cleanup, forcestable Depends: 227bea6c7ef89b707fe2c01c4d0d0fb9081e8c04
* mkfs: Force mke2fs to create a filesystem even on raw IDE device (RHBZ#690819).Richard W.M. Jones2011-03-251-2/+18
| | | | Notes: Labels: bugfix, RHBZ#690819
* umount-all: Use /proc/mounts instead of output of 'mount' command.Richard W.M. Jones2011-03-221-34/+24
| | | | | | | | | | The particular issue is that ntfs-3g (or FUSE?) no longer appears to update /etc/mtab, which meant that umount-all was not unmounting these partitions. But parsing /proc/mounts is simpler and more robust in any case. Notes: Labels: bugfix
* proto: Fix both-ends-cancel case.Richard W.M. Jones2011-03-184-4/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* proto: Fix FileIn ops that abort during the chunk upload stage.Richard W.M. Jones2011-03-187-39/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 dc706a639eec16084c0618baf7bfde00c6565f63.
* daemon: Improve protocol debug messages.Richard Jones2011-03-181-18/+26
| | | | | | | | This adds 'guestfsd: ...' prefix before each message, and also puts a message at the top of the main loop just after a new message has been received. The intent is to make it simpler to follow the protocol.
* daemon: Print error for invalid chunk.cancel field.Richard W.M. Jones2011-03-181-0/+7
| | | | | | | The chunk.cancel field should always be [0|1]. If it is not then something has gone badly wrong -- probably loss of synchronization. If this occurs print a debug message and return error from receive_file function.
* proto: Improve debug messages.Richard W.M. Jones2011-03-181-1/+2
|
* daemon: Ignore return value from chdir.Richard W.M. Jones2011-02-031-1/+1
| | | | This updates commit 7eb012f3710bb554d5fc2c4229036901b0b5ad90.
* daemon: Remove -f (don't fork) option.Richard W.M. Jones2011-02-031-30/+3
| | | | This option was not being used.
* daemon: Allow -r option to run daemon standalone.Richard W.M. Jones2011-02-033-12/+31
| | | | | | | | This changes several aspects of the daemon. Currently: * sysroot will be "" (ie. operate directly on /) * CHROOT_IN/CHROOT_OUT are disabled * autosync doesn't try to unmount everything
* daemon: change to root directoryRichard W.M. Jones2011-02-031-0/+2
| | | | Ensure the daemon always starts with current directory == root.
* daemon: Parse /proc/mounts instead of /etc/mtabRichard W.M. Jones2011-02-031-2/+5
| | | | | | | | | | | | | | | | | | | | | | | Since Fedora util-linux 2.19, the %post script does: rm -f /etc/mtab ln -s /proc/mounts /etc/mtab We are no longer running %post scripts, so this means that /etc/mtab is a plain file in the appliance. Usual 'mount' still updates it, but for some reason mount.ntfs does *not* update it in Fedora 15, meaning that you couldn't mount and then operate on NTFS partitions. It seems better to always parse /proc/mounts (ie. what the kernel thinks is mounted) unconditionally, rather than relying on the capriciousness of the external mount command. Therefore, parse /proc/mounts instead of /etc/mtab, but add a note saying that in future we should really be parsing /proc/self/mountinfo, but that needs a custom parser, and the format is rather tricky: http://lxr.linux.no/#linux+v2.6.37/Documentation/filesystems/proc.txt#L1462
* Add a new internal-autosync API to perform autosync.Richard W.M. Jones2011-01-281-0/+17
| | | | | | | | | Instead of explicitly calling umount-all; sync, we add a daemon function called internal-autosync which does the same. Apart from slightly simplifying the process of closing the handle, the main advantage is we can modify the daemon for the standalone case so that internal-autosync does not do the umount-all operation.
* daemon: Replace root_mounted global with intelligence.Richard W.M. Jones2011-01-272-27/+51
| | | | | | | | | | | | | | | | | We used to maintain a global flag 'root_mounted' which tells us if the user has mounted something on root (ie. on the sysroot directory). This flag caused a lot of trouble (eg. RHBZ#599503) because it's hard to keep the flag updated correctly when the user can do arbitrary mounts and also use mkmountpoint. Remove this flag and replace it with a test to see if something is mounted on *or under* the sysroot. (It has to be *or under* because of mkmountpoint and friends). This also replaces a rather convoluted "have we mounted root yet" check in the mount* APIs with a simpler check to see if the mountpoint exists and is an ordinary directory.
* daemon: Add perror to two exit paths to make errors clearer.Richard W.M. Jones2011-01-271-1/+4
|
* mkfs-opts: Add optional "features" parameter.Nikita A Menkovich2011-01-261-3/+8
| | | | | This allows the -O parameter to be added to the mkfs command line. This is used to select filesystem features.
* New API: resize2fs-M to resize ext2/3/4 to minimum size.Nikita A Menkovich2011-01-141-0/+21
|
* docs: Obsolete HACKING file, move content into guestfs(3) man page.Richard W.M. Jones2010-12-192-3/+4
| | | | | | Add a new section called "EXTENDING LIBGUESTFS" to the guestfs manual page which contains all the information previously in "HACKING".