Commit Graph

1273 Commits

Author SHA1 Message Date
Richard W.M. Jones
79f3d451a8 daemon: Reimplement list_dm_devices API in OCaml.
Simple refactoring.  The only annoying point is requiring an extra
module because of OCaml module dependency restrictions.
2020-10-12 10:44:29 +01:00
Richard W.M. Jones
c456ea0332 New APIs: cryptsetup-open and cryptsetup-close.
This commit deprecates luks-open/luks-open-ro/luks-close for the more
generic sounding names cryptsetup-open/cryptsetup-close, which also
correspond directly to the cryptsetup commands.

The optional cryptsetup-open readonly flag is used to replace the
functionality of luks-open-ro.

The optional cryptsetup-open crypttype parameter can be used to select
the type (corresponding to cryptsetup open --type), which allows us to
open BitLocker-encrypted disks with no extra effort.  As a convenience
the crypttype parameter may be omitted, and libguestfs will use a
heuristic (based on vfs-type output) to try to determine the correct
type to use.

The deprecated functions and the new functions are all (re-)written in
OCaml.

There is no new test here, unfortunately.  It would be nice to test
Windows BitLocker support in this new API, however the Linux tools do
not support creating BitLocker disks, and while it is possible to
create one under Windows, the smallest compressed disk I could create
is 37M because of a mixture of the minimum support size for BitLocker
disks and the fact that encrypted parts of NTFS cannot be compressed.

Also synchronise with common module.
2020-10-12 10:44:08 +01:00
Richard W.M. Jones
b89f377540 Version 1.43.2. 2020-09-21 18:56:18 +01:00
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
3743cc89f6 golang: Capitalize fields in structs so they are publicly accessible.
See: https://github.com/libguestfs/libguestfs/issues/53
2020-09-21 10:56:29 +01:00
Sam Eiderman
66a5913462 python: Add type hints
Since support for python2 is dropped we can use the new python3 syntax
for type hints.

Signed-off-by: Sam Eiderman <sameid@google.com>
2020-07-06 20:35:58 +01:00
Richard W.M. Jones
75def0ef18 python: Remove deprecated use of PyEval_ThreadsInitialized.
The correct/modern way to do this is:

https://docs.python.org/3/c-api/init.html#releasing-the-gil-from-extension-code

PyEval_ThreadsInitialized was deprecated in 3.9 and will be removed
completely in 3.11, so we shouldn't use that function.
2020-07-06 12:40:33 +01:00
Richard W.M. Jones
403d17a876 python: Drop support for Python 2.
Python 2 reached end of life on 2020-01-01:
https://python3statement.org/
https://pythonclock.org/

The minimum version required is now Python 3.4 (since that is the
version in Debian oldoldstable), but 3.6 is the minimum version that
I actually test.
2020-07-06 12:40:33 +01:00
Sergei Golovan
987734fcca erlang: Port to libei for Erlang 23
Replace the use of liberl_interface, which is removed in Erlang 23,
by libei. The implementation uses the ei_decode_iodata() function
which has been introduces only for Erlang 23, so it doesnt work with
earlier Erlang versions.
2020-06-04 13:49:35 +01:00
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