Commit Graph

11130 Commits

Author SHA1 Message Date
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
Pino Toscano
0704d8eb0b v2v: update documentation on nbdkit (RHBZ#1605242)
nbdkit >= 1.6 ships a VDDK plugin always built, so recommend that
version instead of recommending to build nbdkit from sources.
2019-04-12 16:19:43 +02:00
Pino Toscano
fb7983f999 v2v: start reading the new libvirt firmware autoselect
Starting with 5.2.0, libvirt has a way to select automatically the
firmware for a guest using an attribute of the <os> tag.  Hence, use
this information (when available, of course) to flag the firmware used
by the guest.
2019-04-08 18:23:27 +02:00
Pino Toscano
3720900438 inspect: get icon of OpenMandriva guests
Followup of commit a4ef6716b4.
2019-04-08 13:34:11 +02:00
Pino Toscano
c4205809bc inspect: correct osinfo ID for ALT Linux >= 8
ALT Linux 8.x has different IDs in osinfo-db, so return the proper IDs
for the newest stable series.
2019-04-04 10:25:03 +02:00
Pino Toscano
764ee8c74e inspect: return osinfo short IDs for rolling distros
Return the right osinfo short IDs for some rolling Linux distributions,
such as Arch Linux, Gentoo, and Void Linux.  Their IDs were recently
added to osinfo-db.
2019-04-04 10:25:03 +02:00
Pino Toscano
aee4a96ce2 inspect: fully detect Arch Linux from os-release
Consider Arch Linux as rolling distribution, so it is recognized using
/etc/os-release.

The end result does not change, although this makes Arch Linux inspected
using os-release only, instead of getting inspection details mixed from
both os-release and lsb-release.
2019-04-04 10:25:03 +02:00
Pino Toscano
c0155f5823 inspect: detect Gentoo from os-release
Add "gentoo" as recognized ID in /etc/os-release, and consider it as
rolling distribution (so without VERSION_ID in os-release).

This avoids using a not-useful version read from /etc/gentoo-release,
e.g. "Gentoo Base System release 2.6".
2019-04-04 10:25:03 +02:00
Pino Toscano
a6db759a72 inspect: factorize list of rolling distros
Use a static list of rolling distros, so it is easier to handle them
differently; use this list for handling the lack of VERSION_ID in
os-release files.

This is just refactoring, no behaviour changes.
2019-04-04 10:25:03 +02:00
Hiroyuki Katsura
7772cfc771 Add missing python bindings tests
Signed-off-by: Hiroyuki Katsura <hiroyuki.katsura.0513@gmail.com>
2019-04-03 17:28:58 +01:00
Bernhard Rosenkränzer
a4ef6716b4 Add OpenMandriva support as guest and host (RHBZ#1694268). 2019-04-03 13:08:08 +01:00
Pino Toscano
f190e08d85 v2v: add -o json output mode
Add a new output mode to virt-v2v: similar to -o local, the written
metadata is a JSON file with the majority of the data that virt-v2v
knowns about (or collects) during the conversion.

This is meant to be used only when no existing output mode is usable,
and a guest needs to be converted to run on KVM anyway.  The user of
this mode is supposed to use all the data in the JSON, as they contain
important details on how even run the guest (e.g. w.r.t. firmware,
drivers of disks/NICs, etc).
2019-04-01 18:44:00 +02:00
Pino Toscano
a27748d700 v2v: add Var_expander
This helper module provides a facility to replace %{FOO}-like variables
in text strings with user-provided content.
2019-04-01 18:44:00 +02:00
Pino Toscano
0ed2e5c14a common/mlpcre: add offset flag for PCRE.matches
This way it is possible to change where the matching start, instead of
always assuming it is the beginning.
2019-04-01 18:44:00 +02:00
Pino Toscano
1086599ad8 OCaml tools: fix 3999 -> 3339 typo
RFC 3339 is the actual RFC for date/time strings.
Typo found by Martin 'eagle eyes' Kletzander.

Fixes commit f79129b8dc.
2019-04-01 18:44:00 +02:00
Richard W.M. Jones
e047cc4da8 lib: qemu: rbd: Properly escape IPv6 addresses.
Each ':' character in the address must be escaped from qemu.

Thanks: Jonathan Wright
2019-04-01 17:31:25 +01:00
Pino Toscano
f79129b8dc OCaml tools: output messages into JSON for machine readable
When the machine readable mode is enabled, print all the messages
(progress, info, warning, and errors) also as JSON in the machine
readable stream: this way, users can easily parse the status of the
OCaml tool, and report that back.

The formatting of the current date time into the RFC 3999 format is done
in C, because of the lack of OCaml APIs for this.
2019-03-29 13:57:47 +01:00
Pino Toscano
70514dfaf1 common/mltools: allow fd for machine readable output
Allow to specify a file descriptor for the machine readable output.

Use the same assumption as done in v2v, i.e. that Unix.file_descr is
simply the int file descriptor.
2019-03-29 13:57:47 +01:00
Pino Toscano
abf1607f46 common/mltools: make sure machine readable output is flushed
Enhance the helper printf function for machine readable output to always
flush after each string: this way, readers of the machine readable
stream can get the output as soon as it is outputted.
2019-03-29 13:57:46 +01:00
Pino Toscano
8b06ea0ebc common/mltools: move the code for machine readable up
Move the code for handling machine readable up in the file, so it can be
used by other functions.

Only code motion, no behaviour changes.
2019-03-29 13:57:46 +01:00
Tomáš Golembiovský
200bec7cfd v2v: windows: save log file from rhev-apt installer
Store log from MSI installer. Log file will be located in firstboot
scripts-done directory with name rhev-apt.log. The path has to be
double-quoted to handle spaces in path name properly.

Hopefully this can help resolve RHBZ#1584678 someday.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2019-03-27 16:34:44 +01:00
Tomáš Golembiovský
f4bda5571a v2v: fix path to source when copying files from guest tools directory
The debug message was slightly changed too to better match the similar
message for ISO case. It refers to the root directory instead of the
specific subdirectory inside guest tools.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
2019-03-27 16:34:44 +01:00
Pino Toscano
cbf887ed90 v2v: change the reporting of RHV Tools messages/warnings/error
The RHV Tools ISO is provided as Red Hat only product, and thus not
available for all the virt-v2v users.  Hence, change the way we report
the status of the installation of the qemu guest agent from the RHV
Tools ISO:
- do not warn if virt-v2v does not know how to install the package for
  the current guest
- do not warn if the ISO does not contain packages for the current guest
- on successful installations, show an info message

Related: RHBZ#1691659
2019-03-27 14:46:34 +01:00
Pino Toscano
78f08a15fa v2v: try to pick the right arch for qemu-ga pkgs
Right now the code copies, and then tries to install, all the files
found for the directory of a distro.  This does not take into account
differences in the architectures of the packages available, so a x86_64
package must be installed only on x86_64 guests.

As solution, filter the packages using the typical suffix used by
packages (so architecture + file extension), to pick only packages
compatible with the current guest.
2019-03-27 14:46:34 +01:00
Pino Toscano
13ef175a7b v2v: linux: add helper functions for pkg arch and extension
Add helper functions to get the typical extension of binary packages
for a package manager, and the string for an architecture.
2019-03-27 14:46:34 +01:00