Commit Graph

40 Commits

Author SHA1 Message Date
Richard W.M. Jones
e2c7bddf10 Update copyright dates for 2023
Run this command across the source:

  perl -pi.bak -e 's/(20[012][0-9])-20[12][012]/$1-2023/g' `git ls-files`

and remove changes to po{,-docs}/*.po{,t} (these will be regenerated
later when we run 'make dist').
2023-02-07 10:50:48 +00:00
Richard W.M. Jones
d01ce08218 rust: Fix deprecated use of panic!(format!(...))
warning: panic message is not a string literal
 --> src/bin/event_leak.rs:9:30
  |
9 |             Err(e) => panic!(format!(" could not create handle {:?}", e)),
  |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(non_fmt_panic)]` on by default
  = note: this is no longer accepted in Rust 2021
  = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
2021-05-05 12:57:51 +01:00
Richard W.M. Jones
5244d11bd7 generator/bindtests.ml: Remove use of gnulib intprops.h 2021-04-06 13:27:02 +01:00
Richard W.M. Jones
0e17236d7d Update copyright dates to 2020. 2020-03-06 19:32:32 +00:00
Richard W.M. Jones
45e66a567d generator: Use ~copyrights shorthand for ~copyrights:copyrights 2019-07-29 12:15:32 +01:00
Richard W.M. Jones
e6f5ec35cc generator: copywrites -> copyrights 2019-07-29 12:14:23 +01:00
Hiroyuki_Katsura
3bbd00c83e Rust bindings: Add Rust bindings
This patch includes Actions and their tests. Missing:

- Events
- Examples

Rust bindings: Add create / close functions

Rust bindings: Add 4 bindings tests

Rust bindings: Add generator of structs

Rust bindings: Add generator of structs for optional arguments

Rust bindings: Add generator of function signatures

Rust bindings: Complete actions

Rust bindings: Fix memory management

Rust bindings: Add bindtests

Rust bindings: Add additional 4 bindings tests

Rust bindings: Format test files

Rust bindings: Incorporate bindings to build system
2019-07-29 10:28:31 +01: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
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
2d1e2d12af common/mlstdutils: Add with_open_in and with_open_out functions.
These safe wrappers around Pervasives.open_in and Pervasives.open_out
ensure that exceptions escaping cannot leave unclosed files.
2017-11-16 12:32:58 +00:00
Richard W.M. Jones
c7651744da ocaml: Replace pattern matching { field = field } with { field }.
If you have a struct containing ‘field’, eg:

  type t = { field : int }

then previously to pattern-match on this type, eg. in function
parameters, you had to write:

  let f { field = field } =
    (* ... use field ... *)

In OCaml >= 3.12 it is possible to abbreviate cases where the field
being matched and the variable being bound have the same name, so now
you can just write:

  let f { field } =
    (* ... use field ... *)

(Similarly for a field prefixed by a Module name you can use
‘{ Module.field }’ instead of ‘{ Module.field = field }’).

This style is widely used inside the OCaml compiler sources, and is
briefer than the long form, so it makes sense to use it.  Furthermore
there was one place in virt-dib where we are already using this new
style, so the old code did not compile on OCaml < 3.12.

See also:
https://forge.ocamlcore.org/docman/view.php/77/112/leroy-cug2010.pdf
2017-10-05 11:32:54 +01:00
Richard W.M. Jones
61d4891ef4 mllib: Split ‘Common_utils’ into ‘Std_utils’ + ‘Common_utils’.
The new module ‘Std_utils’ contains only functions which are pure
OCaml and depend only on the OCaml stdlib.  Therefore these functions
may be used by the generator.

The new module is moved to ‘common/mlstdutils’.

This also removes the "<stdlib>" hack, and the code which copied the
library around.

Also ‘Guestfs_config’, ‘Libdir’ and ‘StringMap’ modules are moved
since these are essentially the same.

The bulk of this change is just updating files which use
‘open Common_utils’ to add ‘open Std_utils’ where necessary.
2017-07-10 17:01:59 +01:00
Richard W.M. Jones
30411ef623 generator: Simplify the handling of string parameters.
Previously we had lots of types like String, Device, StringList,
DeviceList, etc. where Device was just a String with magical
properties (but only inside the daemon), and DeviceList was just a
list of Device strings.

Replace these with some simple top-level types:

  String
  StringList

and move the magic into a subtype.

The change is mechanical, for example:

    old                     --->    new
  FileIn "filename"               String (FileIn, "filename")
  DeviceList "devices"            StringList (Device, "devices")

Handling BufferIn is sufficiently different from a plain String
throughout all the bindings that it still uses a top-level type.
(Compare with FileIn/FileOut where the only difference is in the
protocol, but the bindings can uniformly treat it as a plain String.)

There is no semantic change, and the generated files are identical
except for a minor change in the (deprecated) Perl
%guestfs_introspection table.
2017-05-03 19:26:18 +01:00
Richard W.M. Jones
a75076f271 GCC 7: Allocate sufficient space for sprintf output.
GCC 7.0.1 can determine if there is likely to be sufficient space in
the output buffer when using sprintf/snprintf, based on the format
string.

The errors were all either of this form:

bindtests.c:717:29: error: '%zu' directive output may be truncated writing between 1 and 19 bytes into a region of size 16 [-Werror=format-truncation=]
     snprintf (strs[i], 16, "%zu", i);
                             ^~~
bindtests.c:717:28: note: directive argument in the range [0, 2305843009213693951]
     snprintf (strs[i], 16, "%zu", i);
                             ^~~~~

or this form:

sync.c: In function 'fsync_devices':
sync.c:108:50: error: '%s' directive output may be truncated writing up to 255 bytes into a region of size 251 [-Werror=format-truncation=]
       snprintf (dev_path, sizeof dev_path, "/dev/%s", d->d_name);
                                                  ^~

Fixed by converting these into dynamic allocation, or making the
output buffer larger, whichever was easier.

There is a gnulib macro we can use to make this simpler for integers.
It requires a new gnulib module (intprops), but it turns out that we
were already pulling that in through dependencies, so the change to
bootstrap is a no-op.  (thanks: Dan Berrange)
2017-02-14 17:53:28 +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
2cc348448a generator: Share Common_utils code.
For a very long time we have maintained two sets of utility functions,
in mllib/common_utils.ml and generator/utils.ml.  This changes things
so that the same set of utility functions can be shared with both
directories.

It's not possible to use common_utils.ml directly in the generator
because it provides several functions that use modules outside the
OCaml stdlib.  Therefore we add some lightweight post-processing which
extracts the functions using only the stdlib:

  (*<stdlib>*)
  ...
  (*</stdlib>*)

and creates generator/common_utils.ml and generator/common_utils.mli
from that.  The effect is we only need to write utility functions
once.

As with other tools, we still have generator-specific utility
functions in generator/utils.ml.

Also in this change:

 - Use String.uppercase_ascii and String.lowercase_ascii in place
   of deprecated String.uppercase/String.lowercase.

 - Implement String.capitalize_ascii to replace deprecated
   String.capitalize.

 - Move isspace, isdigit, isxdigit functions to Char module.
2016-12-09 09:31:25 +00:00
Pino Toscano
6e34396661 python: PEP 8: avoid too long lines
Reindent Python scripts to make sure lines are not longer than 80
columns.

Regarding autogenerated code (guestfs.py and bindtests.py): add an
helper function to make sure comma-separated lists are wrapped at the
wanted length.

This produces only differences in the indentation of long Python lines,
with no behaviour changes.
2016-05-04 18:56:01 +02:00
Pino Toscano
6105ee0c71 python: PEP 8: adapt whitespaces in lines
Add (after comma) or remove (before opening round bracket, and around
'=' in arguments) whitespaces according to the PEP 8 specification.

This is just code reformatting, with no behaviour changes; no content
changed beside whitespaces, so "git diff -w" gives an empty diff.
2016-05-04 18:56:01 +02:00
Richard W.M. Jones
ae3c051567 generator: Declare which input file(s) generate each output file. 2016-02-23 10:40:06 +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
Pino Toscano
7c10cda266 generator: add a FilenameList parameter type
Mostly like StringList (so it can used in current StringList
parameters), but checking client- and daemon-side that the elements are
file names.
2015-10-21 13:00:18 +02:00
Pino Toscano
d98c9c0e0b Fix shebang in perl scripts
Instead of hardcoding the location of perl (assuming it is installed in
/usr), use /usr/bin/env to run it, and thus picking it from $PATH.
This makes it possible to run these scripts also on installations with
perl in a different prefix than /usr.

Also, given that we want enable warnings on scripts, turn the -w
previously in shebang to explicit "use warnings;" in scripts which
didn't have it before.
2015-10-05 15:43:35 +02: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
1efd8aa8f1 Change guestfs__* to guestfs_impl_*
libguestfs has used double and triple underscores in identifiers.
These aren't valid for global names in C++.

The second step is to replace all guestfs__* (2 underscores) with
guestfs_impl_*.

These functions are used where a libguestfs API call is implemented on
the library side.  The generator creates a wrapper function which
calls guestfs_impl_* to do the work.  (Libguestfs APIs which are
passed directly by the daemon work differently and don't require a
guestfs_impl_* function).

This is an entirely mechanical change done using:
  git ls-files | xargs perl -pi.bak -e 's/guestfs___/guestfs_impl_/g'

Reference: http://stackoverflow.com/a/228797
2015-02-14 18:46:04 +00:00
Pino Toscano
f71168497d php: skip bindtests on 32bit platforms
bindtests checks also 64bit int values, which won't work when the
underlying platform has sizeof(long) < 8 (like on 32bit architectures).
2015-02-13 14:37:46 +01:00
Pino Toscano
3b8d56d491 php: add a simple bindtests test
Generate a simple bindtests test for the PHP binding, so it is possible
to easily test all the argument types.

Unlike the bindtests for other languages, optional arguments are not
tested, due to the limitations of optional arguments in PHP (or maybe
they way we implement them).
2015-02-11 15:02:57 +01:00
Richard W.M. Jones
c5800dc97d Update copyright dates for 2015. 2015-01-17 09:08:15 +00:00
Richard W.M. Jones
ebf8a3654a bindtests: Fill in all fields in dummy lvm_pv struct.
Used for testing RStruct/RStructList return values, but only
in GObject and Java bindings.
2014-03-07 15:53:59 +00:00
Pino Toscano
b10dd601fb generator: add a GUID parameter type
At the moment it is basically the change as String, and it is mapped as
if it was such.
2014-02-06 17:43:04 +01:00
Richard W.M. Jones
6c971faecf Update copyright dates for 2014. 2014-01-02 16:53:34 +00:00
Richard W.M. Jones
ee4ce2a029 ruby: Fix .new method (RHBZ#1046509).
The .new method was unintentionally broken in
commit 9466060201.

This fixes the .new method and allows it to be called with multiple
parameters, so you can use:

  Guestfs::Guestfs.new
  Guestfs::Guestfs.new()
  Guestfs::Guestfs.new(:close_on_exit => false)
  etc.

For backwards compatibility, Guestfs::create may still be used.

This commit also adds regression tests:

 - Use .new method in regular tests.  (Because this was not done
   before, we didn't catch the breakage.)

 - Test that ::create still works.

 - Test that args can be passed to .new method.
2013-12-27 13:22:20 +00:00
Richard W.M. Jones
bb09c4a448 golang: tests: Call or defer g.Close(). 2013-07-04 14:52:44 +01:00
Richard W.M. Jones
58b51f5921 golang: Add bindtests. 2013-07-04 14:01:27 +01:00
Matthew Booth
ef2276654e generator: Create Mountable_or_Path, initially identical to Dev_or_Path 2013-02-11 15:43:53 +00:00
Matthew Booth
8fb2306be4 generator: Add new Mountable argument type
This type is initially identical to Device.
2013-02-08 14:59:00 +00:00
Richard W.M. Jones
0d18a8b407 Update copyright dates for 2013. 2013-02-02 13:56:19 +00:00
Richard W.M. Jones
ca488a6d7b lua: Various fixes to the bindings (thanks Jerome Vuarand).
See http://article.gmane.org/gmane.comp.lang.lua.general/95065

Note that this is incompatible with existing code.  You
have to do:

  local G = require "guestfs"
  local g = G.create ()

ie. give the module your own name ("G" in that example).
2012-11-20 16:34:23 +00:00
Richard W.M. Jones
7f1f7dd44f lua: Add bindtests. 2012-11-20 14:11:47 +00:00
Richard W.M. Jones
3820a2578c generator: Test zero args, one optarg; and 63 optargs.
This just generates the code; it's not called.
2012-09-03 09:36:04 +01:00
Richard W.M. Jones
d331fd70e2 generator: Rename 'generator_*' as '*'.
This is a simple renaming of the files/modules.

Note that in OCaml, module names are derived from filenames by
capitalizing the first letter.  Thus the old module names had the form
"Generator_api_versions".  The new modules names have the form
"Api_versions".
2012-09-02 19:47:33 +01:00