summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
...
* availability: Skip tests when functions are not available.Richard Jones2009-11-201-3/+23
|
* availability: Add optional groups and implement guestfs_available call.Richard Jones2009-11-201-62/+138
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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".
* availability: Add guestfs_available.Richard Jones2009-11-202-2/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Start a new API allowing groups of functions to be tested for availability. There are two reasons for this: (1) If libguestfs is built with missing dependencies (eg. no Augeas lib) then the corresponding functions are disabled in the appliance. Up till now there has been no way to test for this except to speculatively issue commands and check for errors. (2) When we port the daemon to Win32 it is likely that major pieces of functionality won't be available (eg. LVM support). This API gives a way to test for that. There is no change for existing clients: you still have to check for errors from individual API calls. For new clients, you will be able to test for availability of particular APIs. Usage scenario (A): An LVM editing tool which requires both the LVM API and inotify in order to function at all: char *apis[] = { "inotify", "lvm2", NULL }; r = guestfs_available (g, apis); if (r == -1) { /* print an error and exit */ } Usage scenario (B): A general purpose tool which optionally provides configuration file editing, but this can be disabled, the result merely being reduced functionality: char *apis[] = { "augeas", NULL }; r = guestfs_available (g, apis); enable_config_edit_menus = r == 0;
* build: Add missing dependency libguestfs.la->guestfs_protocol.hMatthew Booth2009-11-201-0/+1
|
* maint: use EXIT_SUCCESS and EXIT_FAILURE, not 0 and 1 to exitJim Meyering2009-11-201-20/+20
| | | | | | | | | | | | | | | Convert all uses automatically, via these two commands: git grep -l '\<exit *(1)' \ | grep -vEf .x-sc_prohibit_magic_number_exit \ | xargs --no-run-if-empty \ perl -pi -e 's/\b(exit ?)\(1\)/$1(EXIT_FAILURE)/' git grep -l '\<exit *(0)' \ | grep -vEf .x-sc_prohibit_magic_number_exit \ | xargs --no-run-if-empty \ perl -pi -e 's/\b(exit ?)\(0\)/$1(EXIT_SUCCESS)/' * .x-sc_prohibit_magic_number_exit: New file. Edit (RWMJ): Don't change Java code.
* generator: open Unix module by default.Richard Jones2009-11-191-22/+23
| | | | | | | | | | | | | | Add: open Unix at the top of the generator, which means that we don't need to prefix any 'Unix.foo' symbols (we can just use 'foo' instead). Unfortunately the Unix module shadows one symbol in Pervasives (the Pervasives module is opened by default in OCaml code). That symbol is 'stdout'. So we replace this with 'Pervasives.stdout' in two places. Still a net reduction in code size.
* syntax-check: Fix tab-vs-space issue in the generator.Richard Jones2009-11-191-4/+4
|
* build: Fix inter-directory dependenciesMatthew Booth2009-11-191-16/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | This change adds an explicit dependency on generator.ml for every file it generates, except java files. Java is left for another time because it's considerably trickier. It also adds a build rule for src/libguestfs.la so it can be rebuilt as required from other directories. It does this by creating a top level make file, subdir-rules.mk, which can be included from sub-directories. sub-directories need to define 'generator_built' to include local files which are built by generator.ml, and they will be updated automatically. This fixes parallel make, and will automatically re-create generated files when make is run from any directory. It also fixes the problem which efad4f53 was targetting. Specifically, src/guestfs_protocol.(c|h) had an erroneous dependency on stamp-generator, and therefore generator.ml, despite not being directly created by it. This caused them to be recreated every time generator.ml ran rather than only when src/guestfs_protocol.x was updated, which cascaded into a daemon and therefore appliance update. This patch also changes the contents of the distribution tarball by including files created by rpcgen.
* generator: Acquire lock to prevent two parallel runs of the generator.Richard Jones2009-11-191-6/+27
| | | | | | | | | | | | | This commit acquires a lock on a file to prevent two parallel runs of the generator from stomping on each other. The second run will wait for the first to complete before starting. The lock is acquired on the "HACKING" file because it's convenient -- we are already checking this file exists to make sure that we don't start off in the wrong directory. Tested by adding some artificial sleeps in the code to observe locking behaviour between two parallel runs.
* syntax-check: expand TABs in generator.mlJim Meyering2009-11-191-23/+23
| | | | | | | | | | | | | | | | | | | | | | Jim Meyering wrote: >>From 6f128e90afb055f9899011c4a592eb289e678936 Mon Sep 17 00:00:00 2001 > From: Jim Meyering <meyering@redhat.com> > Date: Thu, 19 Nov 2009 11:39:10 +0100 > Subject: [PATCH libguestfs] syntax-check: expand TABs in generator.ml > > * src/generator.ml: Expand leading TABs to spaces. That was incomplete. Please use the following instead. With it, now, "make syntax-check" now passes once again. >From 716a30d0b692972aac8fbea1fb7ad3318ab3a0d8 Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyering@redhat.com> Date: Thu, 19 Nov 2009 11:39:10 +0100 Subject: [PATCH libguestfs] syntax-check: expand leading TABs * src/generator.ml: Expand leading TABs to spaces. * fuse/test-fuse.sh: Likewise.
* BUILT_SOURCES now depends on running the generator.Richard Jones2009-11-181-1/+1
| | | | This completely reverts commit efad4f53923dcca94613e193d6383bd032e70498.
* generator: Fix API of functions that return RBufferOutRichard Jones2009-11-181-9/+37
| | | | | | | | | | | | | | | | | | | | | (NB: The API / ABI doesn't actually change here - it's just made much simpler to use). The API for RBufferOut functions was unexpectedly hard to use in the case where a zero-length buffer might be returned. For discussion on this see: https://www.redhat.com/archives/libguestfs/2009-November/thread.html#00115 This commit ensures that in the zero-length buffer case, the return value is never NULL. Thus code is now able to just check if the return value == NULL to indicate an error, which is simpler for all concerned. The implementation of this is, however, more complex because we have to be careful about this case inside both the daemon and the library code, which is what this commit does. This has passed a full round of tests.
* fish: Improve output of guestfish -h cmdRichard Jones2009-11-171-3/+5
| | | | | | Display this output like a short manual page. Don't put <..> around the parameters to the command.
* New API call: fill - fill a file with octetsRichard Jones2009-11-172-1/+14
|
* Generate guestfs_protocol.x when stamp-generator updatesMatthew Booth2009-11-111-0/+2
| | | | | This partially reverts efad4f53923dcca94613e193d6383bd032e70498. guestfs_protocol.x wasn't being generated when building from a clean checkout.
* Don't export STREQ and friends in <guestfs.h>Richard Jones2009-11-105-10/+37
| | | | | 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.
* Record time of guest launch.Richard Jones2009-11-101-6/+7
| | | | | | | | | | The guest handle field start_t was previously used (when we had the wait_ready call), but had fallen into disuse. Note that it could never be accessed through the API. Rename this field as launch_t, convert it to a timeval, and use it to measure the time since guestfs_launch was called so that we can start profiling guest launch.
* appliance: Prefix kernel messages with timestamp.Richard Jones2009-11-101-0/+1
|
* Generic partition creation interface.Richard Jones2009-11-102-29/+231
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit introduces a generic partition creation interface which should be future-proof and extensible, and partially replaces the old sfdisk-based interface. The implementation is based on parted but is hopefully not too dependent on the particulars of parted. The following new calls are introduced: guestfs_part_init: Initialize a disk with a partition table. Unlike the sfdisk- based interface, we also support GPT and other partition types, which is essential to scale to devices larger than 2TB. guestfs_part_add: Add a partition to an existing disk. guestfs_part_disk: Convenience function which combines part_init & part_add, creating a single partition that covers the whole disk. guestfs_part_set_bootable: guestfs_part_set_name: Set various aspects of existing partitions. guestfs_part_list: List partitions on a device. This returns a programming-friendly list of partition structs (in contrast to sfdisk-l which cannot be parsed). guestfs_part_get_parttype: Return the partition table type, eg. "msdos" or "gpt". The following calls are planned, but not added currently: guestfs_part_get_bootable guestfs_part_get_name guestfs_part_set_type guestfs_part_get_type
* change strncasecmp() == 0 to STRCASEEQLEN()Jim Meyering2009-11-091-1/+1
| | | | | git grep -l 'strncasecmp *([^=]*== *0'|xargs \ perl -pi -e 's/\bstrncasecmp( *\(.*?\)) *== *0\b/STRCASEEQLEN$1/g'
* use STREQ, not strcmp: part 2Jim Meyering2009-11-091-8/+8
| | | | | git grep -l 'strcmp *([^=]*!= *0'|xargs \ perl -pi -e 's/\bstrcmp( *\(.*?\)) *!= *0\b/STRNEQ$1/g'
* use STREQ, not strcmp: part 1Jim Meyering2009-11-092-12/+12
| | | | | git grep -l 'strcmp *([^=]*== *0'|xargs \ perl -pi -e 's/\bstrcmp( *\(.*?\)) *== *0/STREQ$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'
* convert uses of strcasecmp to STRCASEEQJim Meyering2009-11-091-6/+6
| | | | | git grep -l 'strcasecmp *([^=]*== *0'| xargs \ perl -pi -e 's/\bstrcasecmp( *\(.*?\)) *== *0/STRCASEEQ$1/'
* 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-9/+9
| | | | | | | | | | | * 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.
* haskell: Disambiguate truncate symbol.Richard Jones2009-11-091-0/+6
| | | | | | | This is a hack, but GHC doesn't like it if we have a symbol with the same name as one in the Haskell Prelude. Therefore we much hide the corresponding symbol in the Prelude when building this module.
* ocaml: General improvements to generated code.Richard W.M. Jones2009-11-061-8/+29
|
* Don't update appliance after running generator.Richard Jones2009-11-051-4/+0
| | | | | | I'm not sure why these dependencies exist, but they cause the appliance to be updated every time the generator runs, which appears to be unnecessary.
* Allow callers to disable the recovery process.Richard Jones2009-11-032-26/+71
|
* New API call: preadRichard Jones2009-11-022-1/+12
| | | | | guestfs_pread lets you do partial file reads from arbitrary places within a file. It works like the pread(2) system call.
* New API calls: lstatlist, lxattrlist, readlinklist.Richard Jones2009-11-022-1/+74
| | | | | | | | These three functions are very specifically designed for FUSE support, so we can list directories efficiently. Instead of making lots of lstat, lgetxattr and readlink calls, we can make just three calls per directory to grab all the attributes (which we then cache briefly).
* New API calls: truncate, truncate_size, mkdir_mode, utimens, lchown.Richard Jones2009-11-022-26/+149
| | | | | | | | | | | | | | | truncate, truncate_size: Used to truncate files to a particular size, or to zero bytes. mkdir_mode: Like mkdir but allows you to also specify the initial permissions for the new directory. utimens: Set timestamp on a file with nanosecond accuracy. lchown: Corresponding to lchown(2) syscall (we already have chown). The implementation is complicated by the fact that we had to add an Int64 parameter type to the generator.
* guestfish: Fix a third indentation problem.Richard Jones2009-11-021-1/+1
|
* guestfish: Another indentation fix.Richard Jones2009-11-021-1/+1
|
* guestfish: Fix printing of buffers in structs.Richard Jones2009-11-021-2/+2
| | | | | | | | | | Somehow an 'indent' string crept in there, so it was printing: <char><indent><char><indent><char>... instead of: <char><char><char>...
* Fix rstructs_used handling in guestfish generated code.Richard Jones2009-11-021-17/+7
| | | | | | | | | | | | rstructs_used wasn't correctly generating code for guestfish because guestfish doesn't make all functions visible. Since the calculation of rstructs_used was over all functions (including ones not available in guestfish) it could have generated unnecessary functions. In fact this error didn't affect us before - but I discovered it when I added some extra struct-returning functions (future commit).
* New API: vfs_type - get the Linux VFS driver for a mounted device.Richard Jones2009-10-262-1/+13
|
* guestfish: Add win: prefix to use Windows paths.Richard Jones2009-10-261-4/+12
| | | | | | | Add a win: prefix for path arguments in guestfish: ><fs> file win:c:\windows\system32\config\system.log MS Windows registry file, NT/2000 or above
* New API: case-sensitive-path to return case sensitive path on NTFS 3g fsRichard Jones2009-10-262-1/+59
| | | | | | | | | | | | | | | | | | | | This function handles an annoyance/peculiarity of the Linux NTFS 3g driver, which is that it exports NTFS filesystems with names case sensitive, even though under Windows they would be case insensitive. This causes problems because the location of (eg.) c:\windows might appear as /windows or /WINDOWS (etc) depending on the inconsequential details of how it was originally created. Example of this problem on a real Windows guest: ><fs> file /windows/system32/config/system.log libguestfs: error: file: access: /windows/system32/config/system.log: No such file or directory ><fs> case-sensitive-path /windows/system32/config/system.log /WINDOWS/system32/config/system.LOG ><fs> file /WINDOWS/system32/config/system.LOG MS Windows registry file, NT/2000 or above
* Set LC_ALL=C before running qemu.Richard Jones2009-10-211-2/+4
|
* New API: find0 (unlimited version of find)Richard Jones2009-10-202-2/+37
| | | | | | | | | | | | | This adds a new API call guestfs_find0, which is like guestfs_find but mainly doesn't suffer from the protocol limit of the earlier command. The earlier command is not deprecated because it is still very useful. guestfs_find0 uses a FileOut parameter and writes the results to an external file. The filenames in the output are separated by ASCII NUL characters (so a bit like "find -print0"). There is also the addition of a regression test for this command.
* guestfs_find: Document protocol limits for this API call.Richard Jones2009-10-201-1/+1
| | | | | | | | | | guestfs_find has to send the complete list of files in a single protocol message (hence, limited to 2-4 MB). Unfortunately on a typical Linux guest, guestfs_find ("/") will exceed this limit resulting in an error. Therefore we should add an unlimited version of this call in a future commit. This commit just documents the current limit.
* avoid use of all ctype macrosJim Meyering2009-09-242-7/+7
| | | | | | | | | | | | | | | | | | | | * cfg.mk (disable_temporarily): Don't disable sc_avoid_ctype_macros. * fish/tilde.c: Remove unnecessary inclusion of ctype.h. * bootstrap: Add gnulib's c-ctype module to the list. * daemon/m4/gnulib-cache.m4: Likewise. * daemon/ext2.c: Include "c-ctype.h", not <ctype.h>. Use c_isspace, etc, rather than isspace. * daemon/guestfsd.c: Likewise. * daemon/lvm.c: Likewise. * daemon/proto.c: Likewise. * fish/fish.c: Likewise. * fish/tilde.c: Likewise. * src/generator.ml: Likewise. * src/guestfs.c: Likewise. * examples/to-xml.c: Likewise. * examples/Makefile.am (to_xml_CPPFLAGS): Add -I$(top_srcdir)/gnulib/lib so inclusion of "c-ctype.h" works. (to_xml_CPPFLAGS): Rename from to_xml_CFLAGS.
* maint: use spaces, not TABs for indentationJim Meyering2009-09-241-24/+24
| | | | | | | | "make syntax-check" was failing. This fixes it. * HACKING: Indent with spaces, not TABs. * configure.ac: Likewise. * rescue/virt-rescue: Likewise. * src/generator.ml: Likewise.
* Add direct appliance mode flag and implementation.Richard Jones2009-09-232-33/+94
| | | | | | | | When the g->direct flag is set, the appliance stdin/stdout are not connected to the library. Instead they inherit the stdin/stdout of the caller. This is used to implement virt-rescue.
* Change handling of spaces on Linux kernel command line.Richard Jones2009-09-221-8/+8
|
* Implement "null vmchannel" - no vmchannel needed!Richard Jones2009-09-221-64/+297
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit removes the requirement for vmchannel, although retaining support for it. In this configuration, known as "null vmchannel", the library listens on a random loopback port. It passes the number of this port to the appliance (guestfs_vmchannel=tcp:10.0.2.2:12345), and the daemon then connects back. The library, instead of connecting, listens and accepts the connection during guestfs_launch. QEMU SLIRP (user mode networking) is still required to make this work: SLIRP forwards the TCP connection transparently (instead of explicitly as with guestfwd) to 127.0.0.1:<port> There is a window in which any other local process on the machine could see the port number in the qemu command line and try to connect to it. This would be a devastating security hole, because any local process could pretend to be the daemon and feed back malicious replies to our remote procedure calls. To prevent this, we check the UID of the other side of the TCP connection. If the UID is different from the library's EUID, then we reject the connection. To do this we have to parse /proc/net/tcp. (On Solaris we could use getsockopt (SO_PEERCRED), but this doesn't work on Linux TCP sockets). Other vmchannel(s) are still supported. This is important, because we can't in general be sure the qemu will always support SLIRP. In particular, in recent versions of qemu it is possible to compile out SLIRP.