Commit Graph

1264 Commits

Author SHA1 Message Date
Richard W.M. Jones
bfe98ffe13 Update release notes for 1.42.
Also update generator/authors.ml so that ‘make maintainer-check-authors’
passes.
2020-03-09 13:35:40 +00:00
Richard W.M. Jones
0e17236d7d Update copyright dates to 2020. 2020-03-06 19:32:32 +00:00
Richard W.M. Jones
3cea2cfe04 lib: Move guestfs_device_index impl from daemon to library.
This function doesn't work reliably with the proposed change to device
name translation.  The reason is that strings returned by
Devsparts.list_devices contained translated names, so their indexes
did not correspond to the untranslated names used outside the
appliance..

We can avoid this and make the function much simpler and faster by
implementing it on the library side instead.
2020-03-05 13:18:27 +00:00
Martin Kletzander
c7d7b25524 mlcustomize: Trim whitespaces from commands read from file (RHBZ#1351000)
The first split does not care about the whole string, it is just trying to get
the command name in front, so triml is just right.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2020-02-24 13:14:46 +01:00
Csaba Henk
95244fd2ca golang: make API idiomatic so that functions return (<val>, error)
Go API functions returned (<val>, *GuestfsError) that made
code like this fail to build:

    n, err := os.Stdin.Read(buf)
    if err != nil {
        log.Fatal(err)
    }
    n, err = g.Pwrite_device(dev, buf[:n], off)
    ...

As err should be of error (interface) type as of the stdlib call,
and should be of *GuestfsError type as of the libguestfs call.

The concrete error value that libguestfs functions return can be
a *GuestfsError, but the function signature should have (<val>, error)
as return value.
2020-02-19 18:12:15 +00:00
Nikolay Ivanets
94843f155a lib: add support for disks with 4096 bytes sector size
Nowadays there are hard drives and operating systems which support
"4K native" sector size.  In this mode physical and logical block size
exposed to the operating system is equal to 4096 bytes.

GPT partition table (as a known example) being created in this mode will
place GPT header at LBA1 which is 4096 bytes.  libguetfs is unable to
recognize partition table on such physical block devices or disk images.
The reason is that libguestfs appliance will look for a GPT header at
LBA1 which is seen at 512 byte offset.

In order to fix the issue we need a way to provide correct logical block
size for attached disks.  Fortunately QEMU and libvirt already provides
a way to specify physical/logical block size per disk basis.

After discussion in a mailing list we agreed that physical block size is
rarely used and is not so important.  Thus both physical and logical
block size will be set to the same value.

In this patch one more optional parameter 'blocksize' is added
to add_drive_opts API method.  Valid values are 512 and 4096.

add_drive_scratch has the same optional parameter for a consistency and
testing purpose.

add-domain and add_libvirt_dom will pass logical_block_size value from
libvirt XML to add_drive_opts method.
2020-02-11 15:20:09 +00:00
Richard W.M. Jones
9f3148c791 ocaml: Use caml_alloc_initialized_string instead of memcpy.
See this commit in libguestfs-common:
398dc56a6c
2020-02-06 10:32:08 +00:00
Pino Toscano
df3e693b1b python: PEP 8: adapt empty lines
Add or remove empty lines to match the needed ones around
blocks/functions/etc.

Adapt the generation of guestfs.py to emit the separating empty line
before adding a new function/alias, rather than after it.

This is just formatting, no behaviour changes.
2020-01-14 16:21:22 +01:00
Pino Toscano
40251e4b3c python: replace guestfs_int_py_fromstringsize in Py2 branches
In Python 2 code branches use PyString_FromStringAndSize directly
instead of the guestfs_int_py_fromstringsize wrapper (which calls
PyString_FromStringAndSize anyway on Python < 3).
2020-01-09 17:49:16 +01:00
Pino Toscano
c3728416fb python: assume support for Capsules
They were introduced in Python 2.7 and 3.1, so we can assume they exist
(as Python 2.7 is the minimum version required, and 3.0 is long gone).
2020-01-09 17:29:15 +01:00
Pino Toscano
444750bfd1 python: drop code for Python < 2.5
Python >= 2.7 is required.
2020-01-09 17:22:16 +01:00
Pino Toscano
cb0edd4354 build: use split stringlist functions from common/utils
The OCaml and Python bindings directly use the utils.c source in
common/utils, mostly for guestfs_int_free_string_list.  That source
contained also functions using gnulib functions, however without
linking to gnulib.  When building with default build flags (e.g. without
as-needed mode), the gnulib symbols cannot be resolved, leading to
unusable OCaml and Python libraries.

As solution, update the common submodule to get the split of the split
of the stringlist functions in common/utils, and adapt the OCaml and
Python bindings:
- both now use stringlists-utils.c instead of utils.c
- fix the Python distutils setup to include only the sources really
  needed
2020-01-09 14:57:38 +01:00
Pino Toscano
d8540adffb inspect: document OpenMandriva Lx as detected distro
Also extend the virt-inspector RNG schema to allow it.

Followup of commit a4ef6716b4.
2019-12-18 13:14:59 +01:00
Pino Toscano
7ced2b9354 generator: do not generate mlv2v files when not needed
mlv2v is not shipped with libguestfs, so do not try to generate the
files for it in case generator is invoked on a release tarball.
2019-12-12 18:01:32 +01:00
Pino Toscano
4aa4edf972 ocaml: add handling for errno ENOSPC 2019-11-29 13:16:32 +01:00
Pino Toscano
206ce8bbf1 New API: luks_uuid
Return the UUID of a LUKS device.
2019-11-29 12:04:55 +01:00
Richard W.M. Jones
20c2dfbe00 generator, customize, v2v: Only place generated files in libguestfs or common.
After the proposed split of the libguestfs repo, we will end up with
the following layout:

  libguestfs.git
      common -> git submodule libguestfs-common.git
      generator

  virt-v2v.git
      common -> git submodule libguestfs-common.git

  guestfs-tools.git
      common -> git submodule libguestfs-common.git

The generator will only be able to write to libguestfs directories and
the common directory/submodule.  This is mostly the case already with
only 6 exceptions:

  customize/customize-options.pod
  customize/customize-synopsis.pod
  customize/customize_cmdline.ml
  customize/customize_cmdline.mli
  v2v/uefi.ml
  v2v/uefi.mli

This commit moves these files around so they appear under common/ml*

It is somewhat unsatisfactory because it involves copying files
around, but there are some mitigating factors:

(1) Any changes now give us more freedom to develop faster and thus
clean things up in future.

(2) The v2v/uefi files ought to go away in future anyway.

This is simple code motion and should have no effect on the built
programs or tests.
2019-10-14 18:37:29 +01:00
Pino Toscano
dea9636c59 Remove remaining virt-p2v bits
Remove (almost) all the remaining bits related to virt-p2v.
2019-09-10 17:52:16 +02:00
Pino Toscano
2c02adb8ba Remove virt-p2v
This removes only the tool itself, and all the bits strictly needed to
not break the build.

This is now available as separate tool in its own repository:
https://github.com/libguestfs/virt-p2v
2019-09-10 17:52:16 +02:00
Richard W.M. Jones
74ce7332db ocaml: Change calls to caml_named_value() to cope with const value* return.
In OCaml >= 4.09 the return value pointer of caml_named_value is
declared const.

Based on Pino Toscano's original patch to ocaml-augeas.
2019-09-05 09:00:14 +01:00
Richard W.M. Jones
15d1611889 python: Ignore -Wcast-align warnings in Python 3.8 header files.
Disable this warning/error in the Python 3.8 header files:

In file included from /usr/include/python3.8/abstract.h:837,
                 from /usr/include/python3.8/Python.h:147,
                 from actions.h:31,
                 from actions-6.c:34:
/usr/include/python3.8/cpython/abstract.h: In function '_PyVectorcall_Function':
/usr/include/python3.8/cpython/abstract.h:91:11: error: cast increases required alignment of target type [-Werror=cast-align]
   91 |     ptr = (vectorcallfunc*)(((char *)callable) + offset);
      |           ^
2019-09-02 09:00:18 +01:00
Richard W.M. Jones
451e6a7b97 python: Include <Python.h> in one place.
Previously to work around some problems in Python 2 header files we
had to include <Python.h> before any other config file.

For Python 3 which is all we really care about now this is no longer
needed.  We can move the include from three files into the local
"actions.h" file, bringing all the Python definitions and workarounds
into a single place.
2019-09-02 09:00:18 +01:00
Pino Toscano
5d94be2583 generator: improve pod2text invocation
- feed the content directly to stdin, avoid the need of read (and write)
  a temporary file
- read all the output at once, without a tail-recursive function
- apply trimming and first line discarding after closing the process
2019-08-13 16:01:25 +02:00
Pino Toscano
81a01f20c3 generator: adjust variable names
Rename some pod2text-related variables to better-fitting names.

This is just a small refactoring.
2019-08-13 13:45:13 +02:00
Pino Toscano
da0137e828 generator: isolate memoized cache in own module
Isolate the logic for the memoized disk cache in a small module, so it
can be reused for other tools.

Other than refactoring, there should be no behaviour changes.
2019-08-13 13:19:17 +02:00
Pino Toscano
0c261637f9 Fix small issues in documentations of APIs
- fix names of arguments & optional arguments in C<..> markers
- use https for URLs where possible
- fix links to other guestfs APIs
- use more C<..> markers for special tests, shell commands, values of
  arguments, and names of fields
- link to command man pages where an explicit command is mentioned
- fix few incorrect documentation bits
2019-08-13 07:43:42 +02:00
Hiroyuki Katsura
bb0cb3e730 Rust bindings: Add Event structs, Clarify Handle lifetime
Without clarifying handle's lifetime, it is unable
to see how long the callbacks which the handle
owns will live. Then, Rust compiler will infer
that the callbacks have 'static lifetime. It is
not convenient for users.
2019-08-06 14:54:04 +01: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
Pino Toscano
fe96e24001 p2v: generate C about data authors from AUTHORS file
Create a small Perl script to generate about-authors.c from the p2v
AUTHORS file at build time, instead of generating in the generator
at dist time.
2019-07-03 12:41:02 +02:00
Pino Toscano
1fe60aabdf p2v: remove non-author credits
Soon only the virt-p2v authors will be available, so remove all the
other roles.  This leaves only in the virt-p2v about dialog, which is a
mild regression compared to the current situation, although it is just
for user information.
2019-07-03 12:40:52 +02:00
Pino Toscano
7ad6afc222 p2v: generate an AUTHORS file
Create a simple AUTHORS file for virt-p2v, so it is easier to
extract or use it later on.
2019-07-02 15:40:39 +02:00
Pino Toscano
35916b6030 generator: remove p2v_config
No more used now, as this configuration is generated within p2v itself
at build time.
2019-07-01 14:26:44 +02:00
Pino Toscano
180290ff74 p2v: move kernel config POD docs to perl script
Copy from generator/p2v_config.ml also the bits for POD documentation,
adding them to generate-p2v-config.pl; this way,
virt-p2v-kernel-config.pod can be generated at build time directly,
instead of statically shipped as generator output.
2019-07-01 14:14:56 +02:00
Pino Toscano
796ce74f31 p2v: move kernel config to perl script
Instead of generating the p2v kernel config using the OCaml generator,
create a Perl script to do this job, mostly at build time.  This is done
to rely less on the generator for p2v, and because the generation of
these sources is quick enough that it can be done at build time (instead
of shipping the generated sources in dist tarballs).

The generate-p2v-config.pl mimics what generator/p2v_config.ml --
namings, and general structure are kept close to that for comparison.

The two C sources are created at build time by the script; however, the
p2v-config.h header is generated at configure time: this is done because
p2v-config.h is included by p2v.h (another header), which in turn is
included by all the p2v C sources -- automake is not able to properly
resolve the dependency, and thus it would not be generated properly.
2019-07-01 13:58:13 +02:00
Pino Toscano
ca8f8afcc5 Revert "daemon: implement OptString for OCaml APIs"
This causes the build to fail, as Val_optstring is still not used by any
generated C glue function.

This reverts commit 8e51e9078f.
2019-05-30 09:45:40 +02:00
Pino Toscano
8e51e9078f daemon: implement OptString for OCaml APIs
It is already considered as string option, so create an option string
value in the C glue for OptString parameters.
2019-05-30 09:12:32 +02:00
Pino Toscano
96aed2fc9e perl: show warnings for deprecated functions
Emit a deprecation warning when a deprecated function is used, so users
have a way to know that they are using one.
2019-04-23 18:08:19 +02:00
Pino Toscano
a7666c1f1c ruby: show warnings for deprecated functions
Emit a warning when a deprecated function is used, so users have a way
to know that they are using one.
2019-04-23 18:08:19 +02:00
Pino Toscano
cf865444a8 python: show warnings for deprecated functions
Emit a DeprecationWarning warning when a deprecated function is used, so
users have a way to know that they are using one.
2019-04-23 18:08:19 +02: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
84d0f5aa9f lib: enable deprecation warnings by default
Right now, deprecated functions of the library do not trigger any
compiler deprecation warning by default; they do that only if
GUESTFS_WARN_DEPRECATED=1 is defined.  However, this is not something
that seems to be done often -- at least none of the projects using the
libguestfs C API does that.

Hence, do a small behaviour change to change this on the other way
round: now deprecated functions trigger compiler deprecation warnings by
default, using GUESTFS_NO_WARN_DEPRECATED to disable this (and revert
to the previous behaviour).  Even though deprecated functions will not
be removed, we really want users to migrate away from them, as they were
deprecated for good reasons.

Define GUESTFS_NO_WARN_DEPRECATED where needed:
- in all the bindings, as they bind all the functions including the
  deprecated ones
- in the guestfish actions, as it exposes almost all the APIs
- in the C API test, as it runs the automated tests of all the APIs that
  have them
- for two tests that explicitly test deprecated functions
2019-04-23 18:08:19 +02:00
Pino Toscano
0ee02e0117 python: change types for RBufferOut/FBuffer with Python 3 (RHBZ#1661871)
So far RBufferOut return values, and FBuffer struct fields are 'str' on
all the versions of Python.  Python 3 distinguishes between 'str'
(unicode strings), and 'bytes', with 'str' no more able to hold
arbitrary data.

For this reason, switch the return value of RBufferOut functions, and
FBuffer struct fields to bytes on Python 3: while this is a potentially
incompatibile change, this is the only way to handle safely sequences
of arbitrary bytes.
2019-01-22 14:29:13 +01:00
Yuri Chornoivan
7f97433a3c Fix miscellaneous typos in comments. 2019-01-11 17:14:45 +00: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
34c23403c5 tools: Ensure CFLAGS and LDFLAGS are passed to all OCaml binaries (RHBZ#1624130).
After this commit, all annocheck errors are fixed except for:

  Hardened: virt-get-kernel: MAYB: Gaps were detected in the annobin coverage.  Run with -v to list.

After discussion with the annocheck maintainers this gap in coverage
(which corresponds to the OCaml runtime) seems to be caused either by
the runtime not being linked with the right flags, or might be a bug
in annocheck itself.  In any case it's not something that can be
resolved within the scope of libguestfs.
2018-09-21 10:16:34 +01:00
Richard W.M. Jones
598e879ad1 Version 1.39.9. 2018-08-28 22:17:02 +01:00
Bernhard M. Wiedemann
4d39faaa30 generator: Do not claim copyright for future years
This change helps to make libguestfs package build reproducible.
See https://reproducible-builds.org/ for why this is good.

Without this patch, building today's libguestfs in 2033, claims
 Copyright (C) 2009-2033 Red Hat Inc.
which cannot be correct.

This affected files like
/usr/include/guestfs-gobject.h
/usr/lib/perl5/vendor_perl/5.26.2/x86_64-linux-thread-multi/Sys/Guestfs.pm
/usr/lib64/python2.7/site-packages/guestfs.py
/usr/lib64/ocaml/guestfs/guestfs.mli

Commits like 212762c593
will take care of updating the year.
2018-08-22 11:29:29 +01:00
Pino Toscano
c486f0cf4a Change wording from "twice" to "more than once" in error messages
When erroring out about duplicated parameters, say "more than once"
instead of "twice", since there can be more than two repeated
parameters.

Thanks to: Xiaodai Wang
2018-08-10 15:01:02 +02:00