summaryrefslogtreecommitdiffstats
path: root/daemon/daemon.h
Commit message (Collapse)AuthorAgeFilesLines
* daemon: Return error properly when user tries to mount appliance root ↵Richard W.M. Jones2012-02-131-1/+4
| | | | | | | | | | | | (RHBZ#789960). In the case where the caller attempts to mount the "hidden" appliance root device (eg. /dev/vdb if /dev/vda is the only normal block device added), we were calling reply_with_error but not actually returning immediately, resulting in protocol desynchronization. This commit fixes this obvious mistake.
* Clarify the error message when unavailable functions are called (RHBZ#679737).Richard W.M. Jones2012-02-011-10/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Callers are supposed to use the availability API to check for functions that may not be available in particular builds of libguestfs. If they don't do this, currently they tend to get obscure error messages, eg: libguestfs: error: zerofree: /dev/vda1: zerofree: No such file or directory This commit changes the error message to explain what callers ought to be doing instead: libguestfs: error: zerofree: feature 'zerofree' is not available in this build of libguestfs. Read 'AVAILABILITY' in the guestfs(3) man page for how to check for the availability of features. This patch makes the stubs check for availability. The stub code changes to: static void zerofree_stub (XDR *xdr_in) { [...] /* The caller should have checked before calling this. */ if (! optgroup_zerofree_available ()) { reply_with_error ("feature '%s' is not available in this\n" "build of libguestfs. Read 'AVAILABILITY' in the guestfs(3) man page for\n" "how to check for the availability of features.", "zerofree"); goto done; } [...]
* Tempus fugit.Richard W.M. Jones2012-01-181-1/+1
| | | | Update all copyright dates to 2012.
* New API: list-md-devices.Matthew Booth2011-11-111-0/+1
| | | | | | | Return a list of Linux MD devices detected in the guest. This API complements list_devices, list_partitions, list_lvs and list_dm_devices.
* daemon: Define safe ADD_ARG macro for constructing arg lists on the stack.Richard W.M. Jones2011-11-111-0/+12
|
* daemon: Use a private copy of /etc/lvm so we don't modify the real config.Richard W.M. Jones2011-11-041-0/+3
| | | | | | | | | In the libguestfs live case we need to be careful not to modify the real /etc/lvm/lvm.conf file (when setting the filter rule). When the daemon starts, make a complete copy of /etc/lvm in a temporary directory, and adjust LVM_SYSTEM_DIR to point to the copy. All changes are made in the temporary copy.
* daemon: Move useful is_zero function to header file.Richard W.M. Jones2011-09-281-0/+18
| | | | Code motion.
* daemon: Make sysroot_len be size_t instead of int.Richard W.M. Jones2011-05-191-1/+1
|
* daemon: Introduce "pulse mode" progress events.Richard W.M. Jones2011-04-011-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* RHEL 5: Use mke4fs on RHEL 5 as replacement for mke2fs.Richard W.M. Jones2011-03-251-1/+4
| | | | | Notes: Labels: cleanup, forcestable Depends: 227bea6c7ef89b707fe2c01c4d0d0fb9081e8c04
* proto: Fix FileIn ops that abort during the chunk upload stage.Richard W.M. Jones2011-03-181-13/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Allow -r option to run daemon standalone.Richard W.M. Jones2011-02-031-8/+14
| | | | | | | | 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: Replace root_mounted global with intelligence.Richard W.M. Jones2011-01-271-2/+2
| | | | | | | | | | | | | | | | | 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.
* docs: Obsolete HACKING file, move content into guestfs(3) man page.Richard W.M. Jones2010-12-191-2/+2
| | | | | | Add a new section called "EXTENDING LIBGUESTFS" to the guestfs manual page which contains all the information previously in "HACKING".
* protocol: Upload progress messages and optional arguments.Richard W.M. Jones2010-12-011-0/+2
| | | | | | | | Two unrelated changes to the protocol to support progress messages during uploads, and optional arguments. Note that this makes an incompatible change to the protocol, and this is reflected in the protocol version field (3 -> 4).
* daemon: Don't use ../src path to include generator_protocol.hRichard W.M. Jones2010-11-031-1/+1
| | | | | This file is already hard-linked into the current directory, so the relative path is not required.
* daemon: Fix /dev/mapper paths from mounts and mountpoints (RHBZ#646432).Richard W.M. Jones2010-10-281-0/+3
| | | | Make the LV paths returned by these two commands canonical.
* Implement progress messages in the daemon and library.Richard Jones2010-08-311-0/+7
| | | | | | | | | | | | This implements progress notification messages in the daemon, and adds a callback in the library to handle them. No calls are changed so far, so in fact no progress messages can be generated by this commit. For more details, see: https://www.redhat.com/archives/libguestfs/2010-July/msg00003.html https://www.redhat.com/archives/libguestfs/2010-July/msg00024.html
* Change to using ext2-based, cached supermin appliance.Richard Jones2010-08-231-0/+4
| | | | | | | | | | | | This changes the method used to build the supermin appliance to use the new ext2-based appliance supported by latest febootstrap. The appliance can also be cached, so we avoid rebuilding it each time it is used. Mailing list discussion goes into the rationale and details: https://www.redhat.com/archives/libguestfs/2010-August/msg00028.html Requires febootstrap >= 2.8.
* mkfs-b: Check that blocksize parameter is > 0 and a power of 2.Richard Jones2010-06-031-0/+2
|
* daemon: count_strings function returns size_tRichard Jones2010-06-021-1/+1
|
* Fix FileIn cmds losing synch if both ends send cancel messages (RHBZ#576879).Richard Jones2010-05-131-11/+15
| | | | | | | | | | | | | | | | | | | | | | | During a FileIn command (eg. upload, tar-in) if both sides experience errors, then both sides could send cancel messages, the result being lost synchronization. The reason for the lost synch was because the daemon was ignoring this case and sending an error message back which the library side (which had cancelled) was not expecting. Fix this by checking in the daemon for the case where the library also cancels during daemon cancellation, and not sending an error messages. This also includes an enhanced regression test which checks for this case. This extends the original fix in commit 5922d7084d6b43f0a1a15b664c7082dfeaf584d0. More details can be found here: https://bugzilla.redhat.com/show_bug.cgi?id=576879#c5
* daemon: Fix for commands working on absolute symbolic links (RHBZ#579608).Richard Jones2010-05-071-1/+3
| | | | | | | | | | | | | | | | The original idea (suggested by Al Viro) was to fork and chroot into the sysroot and read the file from there. Because of the separate process being chrooted, absolute links would be resolved correctly. The slightly modified idea is to open the file in the daemon process (but temporarily chrooted, so symlinks resolve correctly), fork, and have the subprocess just be responsible for copying the file. (Strictly speaking we don't need to fork, but this implementation is simpler). This commit just includes the changes needed to the command*() functions in daemon/guestfsd.c and adds an absolute symlink to the test ISO for testing it. Later commits will fix the broken daemon commands themselves.
* Fix upload losing synchronization if root not mounted (RHBZ#576879).Richard Jones2010-04-171-9/+17
| | | | | | | | | | | | Modify the generator so that it can correctly handle early cancellation for Pathname|Device|.. parameters. This fixes the upload command, but consequently we need to fix the parameters for tar_in and t?z_in commands. This should also mean that 'win:' can now be used as the second argument of tar_in and t?z_in commands in guestfish, whereas previously this wouldn't have worked. Adds a regression test for the original problem.
* Code cleanups related to RHBZ#580246.Richard Jones2010-04-081-1/+1
| | | | | | | | | | | | | | 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.
* appliance: Set $PATH instead of hard-coding paths to binaries everywhere.Richard Jones2010-03-261-0/+2
| | | | | | Change the appliance so PATH includes common directories. Thus we don't need to hard-code paths to binaries (eg. "/sbin/fdisk") everywhere.
* daemon: Add a trim utility function.Richard Jones2010-03-181-0/+2
| | | | | This function trims the whitespace from around a string. It does this in-place, so it can be called for malloc'd strings.
* daemon: Don't need to prefix error messages with the command name.Richard Jones2010-02-121-1/+4
| | | | | | | | | | | | | | | | | | | | 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:..)
* daemon error handling: Define a new function reply_with_perror_errno.Richard Jones2009-12-071-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | 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; }
* Whitespace change.Richard Jones2009-11-271-1/+1
|
* daemon: Move prototypes around to keep functions grouped logically.Richard Jones2009-11-261-3/+3
|
* sync: Windows implementation of sync() call.Richard Jones2009-11-251-0/+4
| | | | | Replace calls to sync() with calls to sync_disks() which supports Win32 via FlushFileBuffers.
* availability: Add optional groups and implement guestfs_available call.Richard Jones2009-11-201-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current groups are defined very conservatively using the following criteria: (a) Would be impossible to implement on Windows because of sheer architectural differences (eg: mknod). (b) Already optional (augeas, inotify). (c) Not currently optional but not implemented on older RHEL and Debian releases (ntfs-3g.probe, scrub, zerofree). The optional groups I've defined according to these criteria are: . augeas . inotify . linuxfsuuid . linuxmodules . linuxxattrs . lvm2 . mknod . ntfs3g . scrub . selinux . zerofree (Note that these choices don't prevent us from adding more optional groups in future. On the other hand to avoid breaking ABIs we would not wish to change the above groups). The rest of this large commit is really just implementation: Each optional function is classified using Optional "group" flag in the generator. The daemon has to implement a function int optgroup_<name>_available (void); for each optional group. Some of these functions are fixed at compile time, and some do simple run-time tests. The do_available implementation in the daemon looks up the correct function in a table and runs it. We document the optional groups in the guestfs(3) man page. Also: I added a NOT_AVAILABLE macro in order to unify all the existing places where we had a message equivalent to "function __func__ is not available".
* daemon/Win32: Use gnulib modules for first porting to Win32.Richard Jones2009-11-201-0/+1
|
* change strncmp() == 0 to STREQLEN()Jim Meyering2009-11-091-1/+1
| | | | | git grep -l 'strncmp *([^=]*== *0'|xargs \ perl -pi -e 's/\bstrncmp( *\(.*?\)) *== *0\b/STREQLEN$1/g'
* change strncmp(...) != 0 to STRNEQLEN(...)Jim Meyering2009-11-091-1/+1
| | | | | git grep -l 'strncmp *([^=]*!= *0'|xargs \ perl -pi -e 's/\bstrncmp( *\(.*?\)) *!= *0/STRNEQLEN$1/g'
* define STREQ, STRNEQ, STREQLEN, STRCASEQ, etc.Jim Meyering2009-11-091-0/+10
| | | | | | * src/guestfs.h: Define STREQ and company. * daemon/daemon.h: Likewise. * hivex/hivex.h: Likewise.
* indent with spaces, not TABsJim Meyering2009-11-091-3/+3
| | | | | | | | | | | * HACKING: Expand indentation TABs. * configure.ac: Likewise. * daemon/daemon.h: Likewise. * daemon/guestfsd.c: Likewise. * fuse/guestmount.c: Likewise. * hivex/LICENSE: Likewise. * src/generator.ml: Likewise. * tools/virt-win-reg: Likewise.
* Fix prototype of commandv to match prototype of commandrv.Richard Jones2009-11-091-1/+1
|
* daemon: Add flags argument to command*() functions.Richard W.M. Jones2009-11-091-6/+15
| | | | | | | | | | | | | | | | This adds new variations of the command*() functions which take a 'flags' argument. Currently the only flag available is defined as follows: COMMAND_FLAG_FOLD_STDOUT_ON_STDERR: For broken external commands that send error messages to stdout (hello, parted) but that don't have any useful stdout information, use this flag to capture the error messages in the *stderror buffer. If using this flag, you should pass stdoutput as NULL because nothing could ever be captured in that buffer. This patch also adds some documentation for command*() function.
* Daemon: fix handling of errors from xread and xwrite.Richard Jones2009-09-171-2/+4
| | | | | | If xread or xwrite returns -1, that indicates an error and we should exit. Note that xread/xwrite has already printed the error message.
* daemon: diagnose socket write failureJim Meyering2009-08-201-1/+1
| | | | | | | | | * daemon/proto.c (send_chunk): Don't ignore socket-write error. * daemon/proto.c (send_file_end): Return "int", not void, so we can propagate send_chunk failure to caller. * daemon/daemon.h (send_file_end): Update prototype. * daemon/tar.c (do_tar_out, do_tgz_out): Update uses of send_file_end. * daemon/upload.c (do_download): Likewise.
* daemon.h: avoid warning about possible noreturn functionJim Meyering2009-08-171-1/+1
| | | | * daemon/daemon.h (main_loop): Use "noreturn" attribute.
* adjust const "**" pointers to avoid warningsJim Meyering2009-08-171-3/+3
| | | | | | Also, ... * src/generator.ml: Add DeviceList type, and propagate that change out to all calling/interface code.
* fix daemon.h's use of NEED_ROOT-in-#defineJim Meyering2009-08-131-1/+1
|
* update all NEED_ROOT usesJim Meyering2009-08-131-1/+1
| | | | | | run this command: git grep -l -w NEED_ROOT|xargs perl -pi -e \ 's/(NEED_ROOT) \((.*?)\)/$1 (return $2)/'
* s/NEED_ROOT_OR_IS_DEVICE/REQUIRE_ROOT_OR_RESOLVE_DEVICE/Jim Meyering2009-08-131-1/+1
|
* propagate semantic changes to NEED_ROOT, NEED_ROOT_OR_IS_DEVICEJim Meyering2009-08-131-8/+8
| | | | | | changing IS_DEVICE semantics leads to changing semantics of NEED_ROOT_OR_IS_DEVICE and NEED_ROOT, too. * daemon/daemon.h: Update definitions.
* convert the last few, manuallyJim Meyering2009-08-131-1/+1
|
* * daemon/daemon.h (RESOLVE_DEVICE): Rename from IS_DEVICE.Jim Meyering2009-08-131-3/+3
| | | | | Change parameter from "errcode" (which would be returned) to "fail_stmt" so that a caller can specify e.g., "goto done" upon failure.