summaryrefslogtreecommitdiffstats
path: root/src/guestfs.c
Commit message (Collapse)AuthorAgeFilesLines
* Add user cancellation to the C API.Richard W.M. Jones2011-07-151-0/+6
| | | | | | | | | This allows long transfers (FileIn and FileOut operations) to be cancelled by calling the signal and thread safe guestfs_user_cancel function. Most of this commit consists of a multithreaded program that tests user cancellation of uploads and downloads.
* New APIs: set-pgroup, get-pgroupRichard W.M. Jones2011-07-151-0/+13
| | | | | | | | | | | If the pgroup flag is set in the handle, then the qemu and recovery subprocesses are placed in separate process groups. The default is false. The purpose for setting up a process group is that ^C will not be passed from the main process down to these processes (killing them). This allows ^C and other keyboard events to be caught and handled in the main process.
* Add a trace message to guestfs_close.Richard W.M. Jones2011-04-301-0/+7
| | | | | | | | | | Only the "first half" (ie. the call) is traced, because by the time the function returns the handle has gone and there's no way to generate events. You should see: libguestfs: trace: close
* internal: Use size_t instead of int for command line size.Richard W.M. Jones2011-04-301-1/+1
|
* guestfs_close: Move local variables close to code that uses them.Richard W.M. Jones2011-04-301-3/+4
| | | | This is just code motion.
* guestfs_close: Remove unused local variable.Richard W.M. Jones2011-04-301-2/+1
|
* Remove temporary directory containing arbitrary files.Richard W.M. Jones2011-04-131-9/+40
| | | | | | | | In preparation for caching inspection information in the temporary directory (g->tmpdir), allow the temporary directory to contain arbitrary files, and remove all of them when the handle is closed. This just generalizes the previous method of cleaning up the tmpdir.
* Rename $tmpdir/sock to $tmpdir/guestfsd.sock.Richard W.M. Jones2011-03-251-1/+1
| | | | | | | | No functional change; this simply makes the purpose of the socket clearer. Notes: Labels: cleanup
* New event API (RHBZ#664558).Richard W.M. Jones2011-03-151-57/+90
| | | | | | | | | | | | | 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.
* New APIs: guestfs_first_private, guestfs_next_private to walk overRichard W.M. Jones2011-03-151-0/+41
| | | | | | | | the private data area. This commit adds new APIs for walking over the keys and pointers in the private data area associated with each handle (note this is only applicable to the C API).
* check the pid is > 0 before calling waitpid()Angus Salkeld2011-03-151-1/+1
| | | | Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
* New APIs: set-attach-method, get-attach-method.Richard W.M. Jones2011-02-031-0/+45
| | | | | | | | | | These allow you to get and set the attach method. The format is one of: * appliance * unix:<path> It's stored broken out into an enum and a string in the handle.
* Add a new internal-autosync API to perform autosync.Richard W.M. Jones2011-01-281-4/+2
| | | | | | | | | 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.
* generator: trace mode prints return values.Richard W.M. Jones2010-11-171-0/+6
|
* lib: Add safe_asprintf function.Richard W.M. Jones2010-11-131-0/+16
|
* lib: Make pcre, libmagic and hivex libraries optional.Richard Jones2010-11-101-0/+9
| | | | | | | | | | | | | | | This change makes these libraries optional. If they are not available at compile time then certain core API features will be disabled (see below). This also changes PCRE detection to use pkg-config instead of the ad hoc autoconf checks. The large inspect.c file has been split out into separate function-specific files. file-architecture: requires pcre & libmagic inspection: requires pcre & hivex
* lib: Expose errno through new API guestfs_last_errno.Richard W.M. Jones2010-11-031-4/+17
| | | | | | | If either the daemon sends back an errno, or a system call fails in the library, save the errno in the handle and then make it available to callers through the guestfs_last_errno function.
* Enable autosync by default.Richard W.M. Jones2010-10-271-0/+1
|
* Don't include control characters in BufferIn trace output (RHBZ#646822).Matthew Booth2010-10-261-0/+29
| | | | | | | | | | | | The example below shows what the output looks like for a large random buffer. $ guestfish -N fs -m /dev/sda1 -x -- \ touch /test : \ pwrite /test "$(dd if=/dev/urandom bs=128k count=1)" 0 [...] pwrite "/test" "\x7f\xa0/\xb3\x80\xd3\xbc\xc3\xc3.\xb1\xe0\x1b\xafC\x06\xd5;\x0ajJ[o\xc1\xdd\xae\x1f\xce\xb2\x8d\xb3\xd0\x11\xcc$%\xe6<\xc7\xc7\xe7BU*\xc4l%\xaa\xea\xe9\x1an\xda]\xc6I\x0eC\xf9;\xec\x12a\x1f\xeaRH\xb2P\xd6+\xc4\xe6\xa5bW\x99\\x9d\xc8\x9bJ\xef\x99-\x16:h5\xe2\x0f\xa2\xa08\x9bU\x0b$\x138\xcf\xd4j\x9b\x83{%\xac0\xdaa1Xx\xbd`\x8e\xdd\x82\x87\x07\x98\xd2\x9ed\x8bq\xd0\x1f5\x8f\xab\xad4z1\xda\xc4b\xc1\xbc\x0f\xaa\xea\xc1\x15(\xfd1\xc2\x0bF\xe6\x9e\xb0+/g\\xab\xb0b\xde_\xca\xf9\xad\xe1?%\x17\xad\x98\xa4e\xc1\xe0f'\x89\xe9>\xff\xadhYi\xe7\x8c]%\xef\xe0\xa1R\xe5\xd5\x03K\xefI\xdf\xad\xd3\x82\xdb\x0f\xdd\xc3\x8f"\xf1G\xea\xf9r\xdd\xff\x88\x81\xb7\xf2\x0e\x0f\x1d;:\xf2F1\xdb\xb5D\xa1^\x928\xf5\x8e)\xab\xc4\xc3H(\xd0ol\xc6\xe4\xd6\xa3L\x1c\x06\xf4"<truncated, original size 130567 bytes> 0 [...]
* syntax: Remove unused ignore-value.h header.Richard Jones2010-09-101-1/+0
|
* syntax: Remove unused signal.h header.Richard Jones2010-09-101-1/+0
|
* syntax: Remove unused c-ctype.h header.Richard Jones2010-09-101-1/+0
|
* Implement private data area.Richard Jones2010-09-011-0/+81
| | | | | | | | | The private data area is a hash table which is associated with libguestfs handles, that C callers may use to store arbitrary data for the lifetime of the handle. Later the OCaml bindings will use this in order to implement callbacks.
* Implement progress messages in the daemon and library.Richard Jones2010-08-311-0/+8
| | | | | | | | | | | | 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
* New APIs: set-network and get-network to enable network support.Richard Jones2010-08-241-0/+13
| | | | guestfs_set_network (g, true) enables network support in the appliance.
* Change to using ext2-based, cached supermin appliance.Richard Jones2010-08-231-6/+0
| | | | | | | | | | | | 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.
* New APIs for guest inspection.Richard Jones2010-08-171-0/+2
| | | | | | | | | | | | | | | | | | | | | This commit converts (some of) the Perl inspection code to C and makes it available through core APIs. The new APIs are: inspect-os - Does the inspection, returns list of OSes inspect-get-* - Get results of the inspection where '*' is one of: type - 'windows' or 'linux' distro - Linux distro arch - architecture product-name - long product name string major-version minor-version - major.minor version of OS mountpoints - get a list of the mountpoints filesystems - get all filesystems associated with the OS This works for all existing supported Linux and Windows OSes.
* Add safe_strndup call.Richard Jones2010-08-171-0/+8
|
* Rearrange library code into separate files.Richard Jones2010-07-271-2210/+0
| | | | | | | | | | | | We split the library code into these separate files: - guestfs.c: creating handles, closing handles, handle-related variables - actions.c: generated library-side stubs for each action - bindtests.c: generated code to test bindings - launch.c: launching the appliance - proto.c: the library side of the daemon communications protocol This is just code movement.
* Rename guestfs-{actions,bindtests}.c to {actions,bindtests}.cRichard Jones2010-07-271-1/+1
| | | | | Rename these two generated files, in preparation for splitting up the main src/guestfs.c file.
* Move variable initialization close to variable use.Richard Jones2010-07-221-3/+3
|
* Revert "add_drive_ro adds readonly=on option if available." (RHBZ#617200).Richard Jones2010-07-221-18/+4
| | | | | | | | | | | | | | | | | | Adding the readonly=on option is not so clever. This causes qemu to present the disk as read-only to the guest. (The expected behaviour of snapshots=on,readonly=on was that it would open the disk O_RDONLY but present a writable disk to the guest). Since the guest sees a read-only disk, we are unable to do any recovery if a filesystem on the disk is inconsistent. This basically prevents most accesses to live disk images. What we really want is a qemu option which presents a writable disk to the guest, but only opens the disk on the host side with O_RDONLY, to alleviate the udev bug RHBZ#571714. This reverts commit 676462684e05dd8341dd695762dd99a87d8ec022.
* Make tmp directory world readable (RHBZ#610880).Richard Jones2010-07-071-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | If you have a restrictive umask (0077 for example) then files in the tmp directory would be created with 0600 permissions. Example: drwx------. 2 rjones rjones 4096 Jul 2 17:52 . drwxrwxrwt. 57 root root 102400 Jul 2 17:52 .. -rw-------. 1 rjones rjones 86328832 Jul 2 17:52 initrd lrwxrwxrwx. 1 rjones rjones 46 Jul 2 17:52 kernel -> /boot/vmlinuz-2.6.33-0.40.rc7.git0.fc13.x86_64 This in itself is not a problem. However in virt-v2v we also change UID:GID and the result is that qemu is unable to read the initrd file: qemu: could not load initial ram disk '/tmp/libguestfs2ssynP/initrd' With this patch we make the tmp directory and the files world readable. After the patch: $ ls -la /tmp/libguestfsJFVzPg/ total 116192 drwxr-xr-x. 2 rjones rjones 4096 Jul 2 18:03 . drwxrwxrwt. 56 root root 102400 Jul 2 18:03 .. -rw-r--r--. 1 rjones rjones 118869504 Jul 2 18:03 initrd lrwxrwxrwx. 1 rjones rjones 46 Jul 2 18:03 kernel -> /boot/vmlinuz-2.6.33-0.40.rc7.git0.fc13.x86_64
* Add error callback (RHBZ#602599).Richard Jones2010-06-101-0/+14
| | | | Read the note in the man page before using this feature.
* Unify supermin appliance building using febootstrap 2.7Richard Jones2010-05-131-12/+10
|
* launch: Rearrange the code so config check is first.Richard Jones2010-05-081-12/+12
| | | | | | | Move the config state check first in the guestfs_launch function, so that we don't reset g->launch_t or calculate the temporary directory in the case where the launch function will immediately return with an error.
* If qemu dies during launch, set an error message (RHBZ#588851).Richard Jones2010-05-071-4/+11
|
* Use link-local addresses between appliance and host (RHBZ#588763).Richard Jones2010-05-041-3/+3
|
* Change network configuration to use macros.Richard Jones2010-05-041-5/+25
| | | | | | | | | | | | | 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.
* If qemu dies during launch in "null vmchannel" mode, don't hang (RHBZ#579155).Richard Jones2010-04-081-1/+9
| | | | | | Detect if qemu dies during launch by wait(2)-ing for it, and then getting EOF on the qemu pipe. This was broken in null vmchannel mode, causing a hang.
* Don't kill self accidentally.Richard Jones2010-04-081-3/+3
| | | | | | Always check that pid > 0 before calling kill (pid, 9). The issue was that sometimes pid == 0, and this ends up killing ourselves.
* Fix for "warning: unexpected connection from UID ..."Richard Jones2010-04-081-0/+1
| | | | | | | | This warning is currently a fatal error. The code attempts to retry the accept call, but because we don't reset sock = -1 the retry doesn't happen and it dies anyway. Set sock = -1 so the retry attempt can happen.
* rescue: Pass $TERM from library into the virt-rescue appliance.Richard Jones2010-03-261-0/+2
| | | | | We set it on the kernel command line, then get it out from there when the rescue appliance boots.
* Change some _exit(0|1) to _exit(EXIT_SUCCESS|EXIT_FAILURE).Richard W.M. Jones2010-03-231-4/+4
|
* Mac OS X: Disable null vmchannel implementation.Richard Jones2010-03-221-1/+14
| | | | | | | | | As far as I can tell, Darwin has no way to check the peer euid of a _loopback_ TCP socket. This is required for the "null vmchannel" implementation to work securely. Therefore disable this - Darwin will use one of the other supported vmchannel implementations instead.
* Mac OS X: 'xdr_uint32_t' is 'xdr_u_int32_t'Richard Jones2010-03-221-0/+4
|
* Mac OS X: Fix HAVE_GNU_CALLOC so it works when __GLIBC__ is not defined.Richard Jones2010-03-221-0/+4
|
* Mac OS X: strerror_r on Macs is not like GNU strerror_r.Richard Jones2010-03-221-1/+1
| | | | | Really this should be turned into a configure-time test. Perhaps one exists already?
* Mac OS X: define MAX macro if not already defined.Richard Jones2010-03-221-0/+4
|
* Mac OS X: kill(2) requires <signal.h>Richard Jones2010-03-221-0/+1
|