summaryrefslogtreecommitdiffstats
path: root/src/guestfs.c
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* Run qemu with -nographic option.Richard Jones2010-03-221-2/+3
| | | | | On Mac OS X this prevents a short "flash" as qemu opens a toplevel window.
* add_drive_ro adds readonly=on option if available.Richard Jones2010-03-161-4/+18
| | | | | | | | | | | | | | Change the add_drive_ro call so it adds the readonly=on option if qemu supports that. This just means that qemu will not try to open the drive with O_RDWR, and should not otherwise change the behaviour of qemu or libguestfs. (In particular, writes to the read-only drive are still permitted, and are just discarded when the handle is closed). However it should alleviate RHBZ#571714 where udev was deciding to incorrectly relabel a device because we had opened the device for writing (even though we didn't actually write to it).
* Allow qemu_supports to run earlier.Richard Jones2010-03-161-9/+18
| | | | | | | Reimplement qemu_supports() internal function. Allow it to run before launch so we can test qemu features. Document that you should run guestfs_set_qemu as early as possible to make sure these tests are reliable.
* Rewrite libguestfs-supermin-helper in C.Richard Jones2010-03-121-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | libguestfs-supermin-helper was previously a shell script. Although we had steadily optimized it, there were a number of intractable hot spots: (1) cpio still reads input files in 512 byte chunks; this is *very* pessimal behaviour, particularly when SELinux is enabled. (2) the hostfiles globbing was done very inefficiently by the shell, with the shell rereading the same directory over and over again. This is a rewrite of this shell script in C. It is approximately 3 times faster without SELinux, and has an even greater speed difference with SELinux. The main features are: (a) It never frees memory, making it simpler. The program is designed to run and exit in sub-second times, so this is acceptable. (b) It caches directory reads, making the globbing of host files much faster (measured this as ~ 4 x speed up). (c) It doesn't use external cpio, but instead contains code to write newc format cpio files, which is all that the kernel can read. Unlike cpio, this code uses large buffers for reads and writes. (d) Ignores missing or unreadable hostfiles, whereas cpio gave a warning. (e) Checks all return values from system calls. (f) With --verbose flag, it will print messages timing itself. This passes all tests. Updated with feedback from Jim Meyering.
* Remove some unused variables.Richard Jones2010-02-151-2/+1
| | | | | | Since we have to compile with -Wno-unused-variables, we don't spot unused variables in code. I found these by compiling the code in Ubuntu.
* New APIs: add-drive{,-ro}-with-if allows you to set QEMU block emulation.Richard Jones2010-02-121-5/+19
| | | | | | | | | | | The default if=... comes from configure time (currently it defaults to if=virtio). This change allows you to set the QEMU block emulation. We don't think this will be used very often, but virt-v2v requires it in order to work around a subtle problem with running 'mkinitrd' in an appliance attached to a guest.
* Add -enable-kvm option to qemu command line.Richard Jones2010-02-091-0/+31
| | | | | | | | If the version of qemu being used supports -enable-kvm option, then check if /dev/kvm is openable and add this option. I have found this option makes no difference, although it is *supposed* to enable KVM (hardware virtualization) support.
* supermin: Prevent multilib corruption (RHBZ#558593).Richard Jones2010-01-271-2/+4
| | | | | | | | | | | | | | | | | | | On some combination of installing, upgrading and removing the base libguestfs package on x86_64, multilib can corrupt libguestfs by leaving a copy of /usr/bin/libguestfs-supermin-helper around which references the wrong architecture (usually, contains links to the i386-based appliance, when the x86_64 appliance should be constructed). This commit changes libguestfs-supermin-helper so that the script is the same on all architectures. Instead, the library passes the differences to the script (eg. $host_cpu). Because the i386 and x86_64 libraries should be at different locations (/usr/lib vs /usr/lib64) this should prevent multilib from screwing things up. Related links: https://bugzilla.redhat.com/show_bug.cgi?id=558593 http://rwmj.wordpress.com/2009/11/16/please-someone-shoot-multilib/#content https://bugzilla.redhat.com/show_bug.cgi?id=235752
* qemu: Upstream regression of -stdio serial option.Richard Jones2010-01-071-4/+17
| | | | | | | | | | | | | Best explained by the comment in the code: /* Newer versions of qemu (from around 2009/12) changed the * behaviour of monitors so that an implicit '-monitor stdio' is * assumed if we are in -nographic mode and there is no other * -monitor option. Only a single stdio device is allowed, so * this broke the '-serial stdio' option. There is a new flag * called -nodefaults which gets rid of all this default crud, so * let's use that to avoid this and any future surprises. */
* lib: Add thread-safety to global list of handles.Richard Jones2009-12-071-9/+10
| | | | | | | | | | | | | | | | This commit uses the Gnulib 'lock' module to implement a mutex on the global list of handles which is stored by the library. Note that Gnulib nicely avoids explicitly linking with -lpthread unless the application program itself links to -lpthread. Locks are only enabled in multithreaded applications. $ ldd src/.libs/libguestfs.so.0.217.0 linux-vdso.so.1 => (0x00007fffcb7ff000) libc.so.6 => /lib64/libc.so.6 (0x00007f96a4e6c000) /lib64/ld-linux-x86-64.so.2 (0x00007f96a544d000) Please enter the commit message for your changes. Lines starting
* Don't export STREQ and friends in <guestfs.h>Richard Jones2009-11-101-0/+1
| | | | | Move these to private header file(s) and other places as required since these aren't part of the public API.
* Fix problems found by 'make syntax check'Richard Jones2009-11-101-1/+1
|
* Print timestamped messages during appliance launch.Richard Jones2009-11-101-0/+54
| | | | | In verbose mode, print timestamped messages during guestfs_launch so we can see how long each step takes.