Commit Graph

124 Commits

Author SHA1 Message Date
Richard W.M. Jones
75abec1f70 include: Move lib/guestfs.h to include/guestfs.h
This brings libguestfs into line with other projects which have a
separate include/ directory for the public header.

It's also the case that <guestfs.h> has never particularly belonged in
the lib/ subdirectory.  Some tools add -Ilib/ but they only need
<guestfs.h> and not any other headers from that directory, and
separating out the public header allows us to clean those up.  This is
certainly the case for examples, and some language bindings and some
tests.

In future I'm hopeful we can use this as the basis to tease out other
dependencies, as a prelude to separating them out from the repo.
2020-09-21 18:38:28 +01:00
Richard W.M. Jones
0e17236d7d Update copyright dates to 2020. 2020-03-06 19:32:32 +00:00
Pino Toscano
78a18b20e1 tests: fix srcdir references
Make sure to properly reference to files in the source directory.
2019-12-17 15:33:21 +01:00
Pino Toscano
d8d8c856a1 lib: introduce GUESTFS_NO_DEPRECATED
Add a simple way to do not even provide prototypes of deprecated
functions in the C library: this way, users (like our tools) can build
against the library making sure to not use any deprecated function, not
even when compiler deprecation warnings are disabled.

Add it to the majority of our tools/internal libraries, and make sure
that it is not defined when building the API bridges of our bindings.
2019-04-23 18:08:19 +02:00
Pino Toscano
9d1fc91cca build: stop using GUESTFS_WARN_DEPRECATED
This is no more used now, as compiler deprecation warnings are triggered
by default.
2019-04-23 18:08:19 +02:00
Richard W.M. Jones
05d4fcb64d Update copyright dates for 2019.
This command run over the source:

perl -pi.bak -e 's/(20[01][0-9])-2018/$1-2019/g' `git ls-files`
2019-01-08 11:58:30 +00:00
Pino Toscano
53de4aeec5 test-tool: add a documentation test
Add the podcheck.pl test, to make sure the documentation is in sync with
the available options.

Also fix the formats of options in the current POD, so it matches what
used already in other documentations, and what podcheck.pl expects.
2018-06-28 10:10:10 +02:00
Pino Toscano
5565cf767a test-tool: implement --short-options & --long-options
While not useful per-se, it will help checking the available options.
2018-06-28 10:10:10 +02:00
Richard W.M. Jones
212762c593 Update copyright dates for 2018.
Run the following command over the source:

  perl -pi.bak -e 's/(20[01][0-9])-2017/$1-2018/g' `git ls-files`
2018-01-04 15:30:10 +00:00
Richard W.M. Jones
e6c89f9631 utils: Rename ‘guestfs-internal-frontend.h’ to ‘guestfs-utils.h’.
The reason it's not just ‘utils.h’ is because Pino is worried that we
might pick up /usr/include/utils.h from a rogue library.
2017-07-10 17:01:59 +01:00
Richard W.M. Jones
ee206d7ba8 Use Unicode single quotes ‘’ in place of short single quoted strings throughout.
Only in end-user messages and documentation.  This change was done
mostly mechanically using the Perl script attached below.

I also changed don't -> don’t etc and made some other simple fixes.

See also: https://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html

----------
 #!/usr/bin/perl -w

use strict;
use Locale::PO;

my $re = qr{'([-\w%.,=?*/]+)'};

my %files = ();

foreach my $filename ("po/libguestfs.pot", "po-docs/libguestfs-docs.pot") {
    my $poref = Locale::PO->load_file_asarray($filename);

    foreach my $po (@$poref) {
        if ($po->msgid =~ $re) {
            my @refs = split /\s+/, $po->reference;
            foreach my $ref (@refs) {
                my ($file, $lineno) = split /:/, $ref, 2;
                $file =~ s{^\.\./}{};
                if (exists $files{$file}) {
                    push @{$files{$file}}, $lineno;
                } else {
                    $files{$file} = [$lineno];
                }
            }
        }
    }
}

foreach my $file (sort keys %files) {
    unless (-w $file) {
        warn "warning: $file is probably generated\n"; # have to edit generator
        next;
    }
    my @lines = sort { $a <=> $b } @{$files{$file}};

    #print "editing $file at lines ", join (", ", @lines), " ...\n";
    open FILE, "<$file" or die "$file: $!";
    my @all = ();
    push @all, $_ while <FILE>;
    close FILE;

    my $ext = $file;
    $ext =~ s/^.*\.//;

    foreach (@lines) {
        # Don't mess with verbatim sections in POD files.
        next if $ext eq "pod" && $all[$_-1] =~ m/^ /;

        unless ($all[$_-1] =~ $re) {
            # this can happen for multi-line strings, have to edit it
            # by hand
            warn "warning: $file:$_ does not contain expected content\n";
            next;
        }
        $all[$_-1] =~ s/$re/‘$1’/g;
    }

    rename "$file", "$file.bak";
    open FILE, ">$file" or die "$file: $!";
    print FILE $_ for @all;
    close FILE;
    my $mode = (stat ("$file.bak"))[2];
    chmod ($mode & 0777, "$file");
}
2017-04-04 18:47:37 +01:00
Richard W.M. Jones
8c58b62f9d Replace possessive ASCII apostrophe ('s) with Unicode apostrophe (’s).
Only replaced in end-user messages and documentation, not in code,
comments, or anything else that's not end-user visible.

See: https://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html
2017-03-31 10:38:04 +01:00
Richard W.M. Jones
26948d5cb1 generator: Deprecate direct mode (guestfs_set_direct, guestfs_get_direct). 2017-03-07 12:47:51 +00:00
Richard W.M. Jones
f161c9ea57 Rename src/ to lib/ 2017-01-26 15:05:46 +00:00
Richard W.M. Jones
b53cec584d lib: Move utilities to new directory common/utils.
Just code motion.

This commit makes it clearer what is a utility and what is part of the
library.  It also makes it clear that we should rename:

  guestfs-internal-frontend.h -> utils.h
  guestfs-internal-frontend-cleanups.h -> cleanups.h (?)

but this commit does not make that change.
2017-01-26 15:05:46 +00:00
Pino Toscano
55bf7de97c Update copyright dates for 2017
Run the following command over the source:

  perl -pi.bak -e 's/(20[01][0-9])-2016/$1-2017/g' `git ls-files`

(Thanks Rich for the perl snippet, as used in past years.)
2017-01-03 16:48:21 +01:00
Richard W.M. Jones
76c0a67d30 build: Add common CLEANFILES and DISTCLEANFILES to common-rules.mk.
By adding common CLEANFILES and DISTCLEANFILES variables to
common-rules.mk, we can remove these from most other Makefiles, and
also clean files more consistently.

Note that bin_PROGRAMS are already cleaned by 'make clean', so I
removed cases where these were unnecessarily added to CLEANFILES.
2016-08-25 16:54:34 +01:00
Pino Toscano
8e57268dd4 static const char *str -> static const char str[]
Make all the static constant strings as char arrays, so they can be
fully stored in read-only memory.
2016-07-22 13:16:02 +02:00
Richard W.M. Jones
35bac3a650 lib: Deprecate old SELinux APIs, rewrite SELinux documentation (RHBZ#1152825).
Also turns the --selinux option of guestfish, guestmount and
virt-rescue into a no-op -- it didn't work before so this is
effectively no change.
2016-07-14 15:28:10 +01:00
Richard W.M. Jones
fdfedcb4ef Use 'error' function for fprintf followed by exit.
Like with the previous commit, this replaces instances of:

  if (something_bad) {
    fprintf (stderr, "%s: error message\n", guestfs_int_program_name);
    exit (EXIT_FAILURE);
  }

with:

  if (something_bad)
    error (EXIT_FAILURE, 0, "error message");

(except in a few cases were errno was incorrectly being ignored, in
which case I have fixed that).

It's slightly more complex than the previous commit because we must be
careful to:

 - Remove the program name (since error(3) prints it).

 - Remove any trailing \n character from the message.

Candidates for replacement were found using:

  pcregrep --buffer-size 10M -M '\bfprintf\b.*\n.*\bexit\b' `git ls-files`
2016-04-04 17:57:38 +01:00
Richard W.M. Jones
129e4938ba Use 'error' function consistently throughout.
Wherever we had code which did:

  if (something_bad) {
    perror (...);
    exit (EXIT_FAILURE);
  }

replace this with use of the error(3) function:

  if (something_bad)
    error (EXIT_FAILURE, errno, ...);

The error(3) function is supplied by glibc, or by gnulib on platforms
which don't have it, and is much more flexible than perror(3).  Since
we already use error(3), there seems to be no downside to mandating it
everywhere.

Note there is one nasty catch with error(3): error (EXIT_SUCCESS, ...)
does *not* exit!  This is also the reason why error(3) cannot be
marked as __attribute__((noreturn)).

Because the examples can't use gnulib, I did not change them.

To search for multiline patterns of the above form, pcregrep -M turns
out to be very useful:

  pcregrep --buffer-size 10M -M '\bperror\b.*\n.*\bexit\b' `git ls-files`
2016-04-04 13:14:26 +01:00
Pino Toscano
55202a4d49 New API: get-sockdir
Introduce a new read-only API to get a path where to store temporary
sockets: this is different from tmpdir, as we need short paths for
sockets (due to sockaddr_un::sun_path), and it is either
XDG_RUNTIME_DIR if set, or /tmp; adapt guestfs_int_create_socketname
to create sockets in that location.

Furthermore, print sockdir and XDG_RUNTIME_DIR in test-tool for
debugging.
2016-02-03 13:15:29 +01:00
Richard W.M. Jones
446f7794e0 podwrapper: Add --warning flag for manual pages of CLI tools (RHBZ#1293527).
This doesn't add --warning flags to the translated pages,
which is a bug to be fixed at some point.
2016-01-11 13:42:49 +00:00
Richard W.M. Jones
307c83177c Update copyright dates for 2016.
Run the following command over the source:

  perl -pi.bak -e 's/(20[01][0-9])-2015/$1-2016/g' `git ls-files`
2016-01-02 21:19:51 +00:00
Richard W.M. Jones
47b095b928 website: Put website into a separate directory.
Move the random set of HTML files we build from html/ into
the website/ directory.

Also in the website/ directory, put the index.html file from
http://libguestfs.org, which was previously not under version control.
It is generated from index.html.in so we can automatically add the
current version and release date.

Also in the website/ directory, put various CSS file, images, etc.
which are required by the website and were also previously not under
version control.

Change the 'make website' rule to 'make maintainer-upload-website'.
As the name suggests, it is only useful for the maintainer, and will
fail with an error for anyone else.
2015-10-31 17:09:29 +00:00
Richard W.M. Jones
677c721e85 Fix whitespace.
Because of previous automated commits, such as changing 'guestfs___'
-> 'guestfs_int_', several function calls no longer lined up with
their parameters, and some lines were too long.

The bulk of this commit was done using emacs batch mode and the
technique described here:

  http://www.cslab.pepperdine.edu/warford/BatchIndentationEmacs.html

The changes suggested by emacs were then reviewed by hand.
2015-10-05 14:28:33 +01:00
Richard W.M. Jones
ccdbbc7fe4 Fix various -Wformat problems.
Updating gnulib has caused -Wformat-signedness to be enabled.  This
has revealed many problems in C format strings.  The fixes here fall
into the following main categories:

 - Using %d with an unsigned parameter.

 - %x and %o expect an unsigned argument.

 - uid_t and gid_t are unsigned on Linux.  The safe way to print these
   is to cast them to uintmax_t and then print them using the %ju
   modifier (see http://stackoverflow.com/a/1401581).

 - Using %d to print an enum.  Since enums may be either char or int,
   I fixed this by casting the enum to int.

 - strtol_error & lzma_ret are both unsigned types.
2015-07-02 16:08:44 +01:00
Richard W.M. Jones
5a445c2e40 docs: You normally need to set SUPERMIN_KERNEL_VERSION as well. 2015-03-23 12:14:59 +00:00
Richard W.M. Jones
762c0bdab9 docs: Remove some rogue references to 'febootstrap'. 2015-03-23 12:12:23 +00:00
Richard W.M. Jones
52528729f6 gcc5: test-tool: Initialize local variable.
gcc 5 cannot prove that the variable is always initialized
and therefore prints a warning.
2015-01-19 16:06:16 +00:00
Richard W.M. Jones
c5800dc97d Update copyright dates for 2015. 2015-01-17 09:08:15 +00:00
Richard W.M. Jones
de0b7c4e66 build: Map host CPU 'powerpc64le' to qemu-system-ppc64.
Make the corresponding change in libguestfs-test-tool as well.

Thanks: Dan Horák
2014-12-02 09:51:41 +00:00
Richard W.M. Jones
bd589a1d53 test-tool: Map powerpc64 -> ppc64 when searching for qemu.
Consequence of the previous commit.

This also adjusts the whitespace to make the generated script
a bit nicer.
2014-11-06 15:15:39 +00:00
Pino Toscano
a5426cce5f build: check for libintl, and use it
Look for libint/gettext and link to it; this properly detects whether
libint is part of libc.
2014-11-05 13:45:17 +01:00
Richard W.M. Jones
4ff6ba3550 test-tool: Handle mapping other architectures to qemu-system-* binaries. 2014-10-24 16:55:36 +01:00
Menanteau Guy
5018e00129 ppc64le: test-tool: Use correct qemu-system-ppc64 binary when creating qemu wrapper. 2014-10-24 16:51:02 +01:00
Pino Toscano
ca9930ef16 test-tool: stop printing the FEBOOTSTRAP_* envvars
Stop printing the FEBOOTSTRAP_* environment variables, since they are
not used anymore.
2014-09-01 10:28:00 +02:00
Richard W.M. Jones
ffffe71c16 build: Remove code coverage and code profiling options.
This reverts commit 5a2e320ec9.
2014-04-09 14:51:59 +01:00
Richard W.M. Jones
c4dc70f8c4 podwrapper: Remove =encoding from input files and add it back in podwrapper.
This changes podwrapper so that the input (POD) files should not
contain an =encoding directive.  However they must be UTF-8.
Podwrapper then adds the '=encoding utf8' directive back during final
generation.

This in particular avoids problems with nested =encoding directives in
fragments.  These break POD, and are undesirable anyway.
2014-03-20 13:47:19 +00:00
Richard W.M. Jones
b13c22668d appliance: Use supermin >= 5.
This requires the new version of supermin (5.1.0).
2014-02-26 15:21:08 +00:00
Richard W.M. Jones
10b20b7938 test-tool: Rearrange output into alphabetical order. 2014-01-21 11:07:03 +00:00
Richard W.M. Jones
1e4663858b New API: set-backend-settings, get-backend-settings.
Allow settings (an arbitrary list of strings) to be passed to the
current backend.  This will allow us to tweak how the backend works,
eg. by forcing TCG.
2014-01-18 16:32:03 +00:00
Richard W.M. Jones
20514fec25 test-tool: Use size_t instead of int for array index. 2014-01-18 16:32:03 +00:00
Richard W.M. Jones
6c971faecf Update copyright dates for 2014. 2014-01-02 16:53:34 +00:00
Richard W.M. Jones
e7fa7f4d16 launch: Print program and version as part of standard debug output when launching the handle.
There are a lot of cases where people post debugging output, but we're
not sure precisely which version they are using.
2013-11-25 23:25:44 +00:00
Richard W.M. Jones
fb41ce252f Change supermin man pages section 8 to section 1.
Corresponding change in upstream supermin:
cb3f9e8bba
2013-11-12 08:49:45 +00:00
Richard W.M. Jones
78dbd08dd2 Rename 'qemu' as 'hv', 'LIBGUESTFS_QEMU' as 'LIBGUESTFS_HV'. 2013-08-14 17:25:34 +01:00
Richard W.M. Jones
14fabcd88e tests: Use new guestfs_add_drive_scratch API where possible in tests.
Replaces code such as:

  fd = open "test1.img"
  ftruncate fd, size
  close fd
  g.add_drive "test1.img"

with the shorter and simpler:

  g.add_drive_scratch size
2013-07-20 16:31:42 +01:00
Richard W.M. Jones
f2b90b374f New APIs: set-program, get-program.
These set or get the program name in the handle.  Most programs
will never need to call this, since we set this, if possible,
using the glibc 'program_invocation_short_name(3)' feature.
2013-04-11 12:52:54 +01:00
Richard W.M. Jones
68990840b6 "attach method" is from now on known as "backend".
This large, but mainly mechanical commit, renames "attach method"
everywhere to "backend".

Backwards compatibility of the API (guestfs_{set,get}_attach_method)
and environment (LIBGUESTFS_ATTACH_METHOD) is maintained, but in new
code use guestfs_{set,get}_backend and LIBGUESTFS_BACKEND instead.

The default backend (launching qemu directly) is now called 'direct'
instead of 'appliance', although you can still use 'appliance' as a
synonym.
2013-04-01 11:16:18 +01:00