Commit Graph

11154 Commits

Author SHA1 Message Date
Pino Toscano
f30840e01b p2v: stop including guestfs.h
It is no more needed, guestfs-utils.h is enough these days.
2019-07-03 12:41:02 +02:00
Pino Toscano
498f940419 contrib: move p2v files within p2v 2019-07-03 12:41:02 +02: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
e7a550c2d8 p2v: ship generate-p2v-config.pl
Fixes commit 796ce74f31.
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
f02c0cb552 p2v: tests: use a local blank-part disk image
Instead of using the "global" blank-part test image, use a local version
of it created with guestfish.
2019-07-01 18:47:18 +02:00
Pino Toscano
ea4d9bd157 p2v: tests: switch windows image with local fedora one
Instead of using the "global" Windows test image, use a local Fedora
image created with virt-builder.
2019-07-01 18:44:30 +02:00
Pino Toscano
9fe175cd76 p2v: split gitignore
Move (or copy the general ones) all the p2v entries in the top-level
.gitignore file to a new file specific for p2v.  This will make it
easier to keep them when splitting p2v.
2019-07-01 18:38:09 +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
Richard W.M. Jones
c4638739d6 python: PYTHON_LIBS is not set in Python 3.8 (RHBZ#1705482).
Python 3.8 no longer links C extensions to -lpython, instead relying
on the fact that the python binary itself already contains those
symbols.  This means $PYTHON_LIBS is empty and so the Python bindings
are not built.

Use a different test to see if the python module is available.
2019-05-31 13:07:25 +01: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
8eb696f827 appliance: remove custom Shadow augeas lens
Now that augeas 1.2.0 is required, assume the Shadow lens is available
there, and thus drop the local copy.
2019-05-30 09:12:32 +02:00
Pino Toscano
31d72dc463 build: raise augeas requirement to 1.2.0
It is widely available also on older distributions.
2019-05-30 09:12:32 +02:00
Richard W.M. Jones
2bb6be333e appliance: Remove /etc/dhcp/dhclient-enter-hooks.d/resolved.
Workaround for Ubuntu which uses this script to try to start a systemd
service.  That won't work because systemd is not used inside the
appliance.  See:

https://bugs.launchpad.net/ubuntu/+source/supermin/+bug/1824236

Thanks: Ioanna Alifieraki
2019-05-29 17:54:52 +01:00
Pino Toscano
0cafcc0e88 build: build C sources using OCaml API with CAML_NAME_SPACE
This way no non-namespaced OCaml C symbols are used, reducing the risk
of clashes with other code.

The only exception is ocaml-augeas, which does not build with
CAML_NAME_SPACE; it will be fixed upstream, and it affects only
ocaml-augeas itself.
2019-05-28 11:39:20 +02:00
Martin Kletzander
c2918b8b74 Use proper label for nbdkit sockets
While svirt_t can be used for sockets it does not always guarantee that it will
be accessible from a virtual machine.  The VM might be running under svirt_tcg_t
context which will need a svirt_tcg_t label on the socket in order to access it.

There is, however, another label, svirt_socket_t, which is accessible from
virt_domain:

  # sesearch -A -s svirt_t -c unix_stream_socket -p connectto
  ...
  allow virt_domain svirt_socket_t:unix_stream_socket { ... connectto ... };
  ...

And virt_domain is a type attribute of both svirt_t and svirt_tcg_t:

  # seinfo -x -a virt_domain
  Type Attributes: 1
     attribute virt_domain;
          svirt_t
          svirt_tcg_t

Resolves: https://bugzilla.redhat.com/1698437

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2019-05-28 10:14:37 +01:00
Pino Toscano
2ad84a080d tests: import importlib.util directly
It seems that on older Python 3 versions importlib.util is not imported
automatically when importlib is imported; as solution, import
importlib.util directly (as it is what is used, anyway).

Fixes commit f79129b8dc.
2019-05-24 14:49:05 +02:00
Pino Toscano
c9543de73d launch: libvirt: fix custom hypervisor check
Previously, is_custom_hv() used to compare the QEMU executable found
during configure to the hypervisor set to check whether it is a custom
one; however, the QEMU found at configure time can be different than
what libvirt was configured with.

This fixes the libvirt backend when libguestfs is configured with a
different QEMU, that now will be specified as emulator overriding the
libvirt one.
2019-05-24 14:49:05 +02:00
Pino Toscano
797925cc3c launch: libvirt: get default QEMU from domcapabilities
Parse the libvirt domain capabilities for the default emulator
capabilities, and get the path to the default QEMU executable.
2019-05-24 14:49:05 +02:00
Pino Toscano
8d453fe9cc build: stop looking for ocaml-libvirt
We ship our own copy of it, so we do not need the external version.
(Also, the latest upstream version of ocaml-libvirt was already not
usable to build the test harness of v2v.)
2019-05-20 13:40:19 +02:00
Pino Toscano
5c4bd181b6 v2v: test-harness: stop using the external ocaml-libvirt
Use the embedded copy.
2019-05-20 13:40:19 +02:00
Pino Toscano
3e89a1d44f v2v: -o libvirt: switch away from virsh
Now that we have a proper libvirt connection object, use it directly to
refresh the storage pool, and define the final guest.  This avoids
spawning a new virsh process twice, with no possibility to even share a
possible authentication required.
2019-05-20 13:40:19 +02:00
Pino Toscano
e8f9ea2f67 v2v: -o libvirt: use a Lazy for the connection
Store the Libvirt.Connect.t object as instance variable, so it can be
used also outside of prepare_targets.  Use a private method to access
it, so there is no need to directly use the Lazy object.
2019-05-20 13:40:19 +02:00
Pino Toscano
a871f6c251 v2v: switch to ocaml-libvirt
Currently virt-v2v has few custom C-based functions for libvirt
operations, which are limited in what they do, and there is a lot of
duplicated code.

Instead, switch to ocaml-libvirt for all the libvirt interaction
currently done by the Libvirt_utils module.  This has few advantages:
- each input & output module now opens a libvirt connection only once,
  only when needed
- no need to pass URIs and passwords around, if not needed
- a wider range of libvirt APIs can now be used, with no need to create
  bindings manually

The hierarchy of input_libvirt* classes is changed to take a Lazy object
with the libvirt connection, accessing it through a "proctected" method:
this way, the connection is opened only at the first access.
Also, the Libvirt_utils module now is just helpers around the Libvirt
module, to centralize error handling, and few common operations.
2019-05-20 13:40:19 +02:00
Pino Toscano
99493eeddd common: Bundle the libvirt-ocaml library for use by virt-v2v
Add a copy of the libvirt-ocaml library, currently available at:
  https://libvirt.org/git/?p=libvirt-ocaml.git;a=summary
This is a snapshot at commit d3ed8dcf1b0a6a8a855ceecbe0bb97f21e6665e3,
which has all the features we need (and that builds fine).
It is expected to stay synchronized with upstream, until there is a new
upstream release, and it will be widespread enough.
2019-05-20 13:32:59 +02:00
Pino Toscano
c0d95dcde8 v2v: require libvirt
While there are input modes that do not use libvirt, making libvirt
mandatory for virt-v2v slightly simplifies the code now, and allow for
further improvements/integration with libvirt later on.
2019-05-20 13:30:23 +02:00
Pino Toscano
71b021c99d v2v: -o json: add a simple test for it
Followup of commit f190e08d85.
2019-05-20 10:22:29 +02:00
Richard W.M. Jones
052d2be483 builder: templates: Add RHEL 8.0 (x86-64 only for now). 2019-05-10 16:24:53 +01:00
Richard W.M. Jones
652e8de397 builder: templates: Remove RHEL 8 Alpha temporary hacks. 2019-05-10 16:24:53 +01:00
Richard W.M. Jones
05decc6976 builder: Fedora 30 templates. 2019-05-04 21:07:05 +01:00
Pino Toscano
8bbf8e8900 test-data: switch away from deprecated APIs
Adapt make-fedora-img.pl to not use deprecated APIs anymore:
- set_e2uuid -> set_uuid
- txz_in -> tar_in + compress:xz

This causes no changes in the generated test images.
2019-05-02 18:34:18 +02:00
Pino Toscano
9f39e9be24 python: silence usage of add_cdrom in test
One test explicitly tests add_cdrom, so silence the deprecation warning
only for that function.
2019-04-24 12:49:48 +02:00
Pino Toscano
19ce506ccb perl: silence usage of add_cdrom in test
One test explicitly tests add_cdrom, so silence the deprecation warning
only for that function.
2019-04-24 12:49:28 +02:00
Pino Toscano
b6a7157751 python: modernize inspect_vm example
Since we already assume Python >= 2.7, modernize this example to make it
work also on Python 3:
- use print() as function
- sort the mount points using a key for sorted(), instead of a
  comparison function
- remove extra newline escape
- reident two lines according to the PEP 8 style
2019-04-24 11:59:36 +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
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
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
7a54596aaf tests: switch last-errno away from deprecated APIs
This test only calls stat to check the failure on missing file, so
switch to statns to get the same behaviour with a non-deprecated API.
2019-04-23 18:06:31 +02:00
Pino Toscano
05e559549d v2v: -o rhv-upload: check whether the cluster exists
In the precheck script, check that the target cluster actually exists.
This will avoid errors when creating the VM after the data copying.
2019-04-16 12:17:18 +02:00
Denis Plotnikov
4cfc071a84 daemon: drop error message check in do_part_expand_gpt
part-expand-gpt takes extreme cautions and doesn't proceed to writing
to the disk if the preliminary dry run of sgdisk has generated any
warnings on stdout.

This blocks the use of part-expand-gpt on disk shrink (with disk
resize being the main usecase for part-expand-gpt), because sgdisk dry
run produces a warning in that case.

So remove the excessive safety check, and leave it up to the caller.

Signed-off-by: Denis Plotnikov <dplotnikov@virtuozzo.com>
Reviewed-by: Roman Kagan <rkagan@virtuozzo.com>
2019-04-16 09:32:02 +01:00
Richard W.M. Jones
3b2d83d470 v2v: Move have_selinux to utils.
This is not quite a neutral refactoring, because it means we now run
the getenforce command every time virt-v2v starts up.  However it's a
trivial command that reads a single /sys file and it can't fail even
if the command is missing or on platforms that know nothing about
SELinux.
2019-04-15 11:41:29 +01:00
Richard W.M. Jones
5067968297 common/mlstdutils: Add String.unix2dos function.
Simple string line ending replacement convenience function.
2019-04-15 11:41:29 +01:00
Pino Toscano
1629ec6a56 v2v: warn when the guest has direct network interfaces (RHBZ#1518539)
virt-v2v obviously cannot convert this kind of devices, since they are
specific to the host of the hypervisor.  Thus, emit a warning about the
presence of direct network interfaces, so at least this can be noticed
when converting a guest.
2019-04-12 17:28:12 +02:00