Commit Graph

10832 Commits

Author SHA1 Message Date
Pino Toscano
751afe91e0 inspect: fix inspection of partition-less devices (RHBZ#1661038)
When parsing "xdev"-kind devices, do not assume that the partition
number can be converted to integer: re_xdev accepts an empty part of the
partition number, so just handle as it is, as string.

This fixes a regression due to the conversion of the inspection code to
OCaml, as the old C version did not have this issue.

(cherry picked from commit cf6b527824)
2019-04-11 16:39:57 +02:00
Pino Toscano
31af609ecc inspect: fix icon of RHEL
Use a better icon for RHEL guests, still provided by redhat-logos (or
equivalent in downstream distributions), and which fits a better
definition of logo for the distribution.

Thanks to Ray Strode for the hints.

(cherry picked from commit c648052690)
2019-04-11 16:23:02 +02:00
Richard W.M. Jones
66a40516a2 Revert "launch: libvirt: Use qemu-bridge-helper to implement a full network (RHBZ#1148012)."
We've been carrying this exact patch in RHEL 7 for several years.  It
reverts the change made in 2014 where we switched to using the virbr0
bridge for libguestfs networking instead of SLIRP.  We thought SLIRP
was going to become unsupported in qemu, but recently there have been
more encouraging signs since it looks like SLIRP will be spun off as a
separate project, running as a modular process and properly secured
and supported.

This reverts commit 224de20b9a.

(cherry picked from commit 492a945791)
2019-01-23 17:11:30 +01:00
Pino Toscano
f4c25f88b1 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.

(cherry picked from commit 0ee02e0117)
2019-01-23 17:11:25 +01:00
Pino Toscano
da45c7c305 python: fix call of Python handlers of events
Make sure to reference the arguments, to make sure they are kept alive
during the function call; this is visible when setting an event handler
for the CLOSE event, and testing it with Python 3.

This does not seem to create a memory leak e.g. with Python 2.

Also, switch away from the quasi-internal PyEval_CallObject to the
public PyObject_CallObject, which takes care of doing safety checks.

(cherry picked from commit 85235aec83)
2019-01-23 17:11:16 +01:00
Pino Toscano
c5460f73b8 v2v: further doc update for VMware roles
Remove "Allow virtual machine download", added with
commit 37955f14aa, because it does not
seem to be actually needed.

Related: RHBZ#1530967
(cherry picked from commit 5e5896752e)
2019-01-10 14:23:47 +01:00
Pino Toscano
6e71dcc1c9 v2v: -o rhv-upload: decouple name of nbdkit python plugin
Do not assume that the Python plugin of nbdkit has the same name of the
Python interpreter.

Use the default upstream name of nbdkit to identify it; downstream
distributions must adjust this variable, in case they rename the Python
plugin of nbdkit.

(cherry picked from commit 6b80c5fb51)
2018-12-16 16:29:29 +01:00
Pino Toscano
10bff3240c v2v: update docs for VMware roles (RHBZ#1530967)
Update the list of permissions needed for VMware vCenter 6.5.

(cherry picked from commit 37955f14aa)
2018-12-16 16:23:06 +01:00
Pino Toscano
c9b55904a0 inspect: handle os-release "opensuse-tumbleweed" as opensuse
Followup of commit 70407cd622 for openSUSE
Thumbleweed.

(cherry picked from commit 28bd06227b)
2018-12-12 11:39:12 +01:00
Richard W.M. Jones
1e72a13be2 inspection: Parse os-release "opensuse-leap" as opensuse (RHBZ#1634248).
(cherry picked from commit 70407cd622)
2018-12-12 11:39:01 +01:00
Pino Toscano
e003f5b8e7 v2v: linux: improve regex for resume= entries (RHBZ#1651987)
Add few more characters for the devices of resume= entries in the
command line of grub: this way it is possible to match also /dev/mapper
devices.

This should require no further processing, since the names of the
/dev/mapper devices do not change after the conversion.

(cherry picked from commit 50b08fd84b)
2018-12-12 11:38:33 +01:00
Richard W.M. Jones
e4ba4ed8bb v2v: docs: Remove sentence about supporting qemu-kvm-rhev in RHEL (RHBZ#1651977).
The previous support documentation said that for UEFI guests, when
using RHEL ≥ 7.3 host, you must use qemu-kvm-rhev.  For RHEL 8 this is
inaccurate since qemu-kvm-rhev no longer exists.

To fix this I've dropped the whole sentence.  It only applies to the
downstream product (RHEL) and so RHEL can add the right documentation
if it needs to.

Thanks: Ming Xie, Pino Toscano.
(cherry picked from commit 0e6bbcee7e)
2018-12-04 12:12:55 +01:00
Richard W.M. Jones
4d78c436b1 v2v: docs: Describe support for SHA-2 certs for Windows 7 / 2008 R2 (RHBZ#1624878).
Thanks: Yan Vugenfirer.
(cherry picked from commit 741ef228cd)
2018-12-04 12:08:52 +01:00
Richard W.M. Jones
8a4072c4b1 v2v: windows: Fix rhev-apt command line (RHBZ#1624902).
See:
https://bugzilla.redhat.com/show_bug.cgi?id=1584678#c15

Fixes commit bcdbe6405c.  However this
bug was copied directly from old virt-v2v which did the same thing
(from lib/Sys/VirtConvert/Converter/Windows.pm):

  echo installing rhev-apt >>log.txt
  "rhev-apt.exe" /S /v /qn >>log.txt

Thanks: Lev Veyde
(cherry picked from commit e12c56176a)
2018-12-04 12:06:37 +01:00
Richard W.M. Jones
81f35e441d v2v: Model machine type explicitly.
QEMU for x86 supports two machine types, "pc" (emulating the ancient
Intel i440FX chipset originally used by the Pentium Pro), and "q35"
(https://wiki.qemu.org/Features/Q35).

Currently virt-v2v does not set any machine type, so libvirt or the
target hypervisor will choose some default, probably i440fx.  The
latest advice from the QEMU and libvirt communities is not to rely on
the default machine type but to specify what we need explicitly, but
it may also be that the libvirt configuration file has been changed to
set the default machine type to Q35 (either by the distro or the end
user).

None of this matters for reasonably new guests since they can boot
with either chipset.  However there are some very old guests (notably
Windows XP) which cannot handle Q35.

This commit changes virt-v2v so it always tries to specify the machine
type explicitly (assuming the target supports that, and not all of
them do).  For x86_64 guests this patch always selects i440fx (pc).
In future we hope to get the correct machine type for the guest from
libosinfo but this is not available yet.

For non-x86 architectures we select the "virt" model which will
probably only work for AArch64.  More work is needed for POWER.

For secure boot we still have to force the machine type to Q35.  In a
future version this forcing can be removed since any guest which is
using secure boot will be new enough that it'll be using Q35 anyway
(on x86).

(cherry picked from commit 55879b2f2c)
2018-10-05 10:59:35 +02:00
Pino Toscano
57ed1fc428 ocaml: make sure to pass LDFLAGS to ocamlmklibs linker (RHBZ#1624130)
Pass the LDFLAGS properly as arguments for the C linker when using
ocamlmklibs via the -ldopt option.

Followup of commit 34c23403c5.

(cherry picked from commit 4ff573c352)
2018-09-27 16:09:58 +02:00
Richard W.M. Jones
7423e43ec2 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.

(cherry picked from commit 34c23403c5)
2018-09-27 10:06:56 +02:00
Richard W.M. Jones
81a9e4f428 tools: Link OCaml programs with -runtime-variant _pic if available.
OCaml has a small runtime which is statically linked into the virt
tools (providing things like GC and primitives).  Since OCaml 4.03 it
has been possible to select variants of this runtime, one of which is
compiled with -fPIC, using ‘ocamlopt -runtime-variant _pic’.

This has performance implications on i686, but is relatively free on
other architectures.  Since it (in theory) adds to the security of the
final binary this commit enables it whenever it is available.

(cherry picked from commit 09abb9c990)
2018-09-27 10:06:43 +02:00
Richard W.M. Jones
8be6817e95 ppc64le: Don't use -cpu parameter under any circumstances (RHBZ#1605071).
(cherry picked from commit 56318f0b5f)
2018-09-05 13:57:29 +02:00
Richard W.M. Jones
739ac1bc0f v2v: -o rhv-upload: Properly replace SD_UUID in OVF (RHBZ#1612653).
The @SD_UUID@ pattern was not being replaced correctly.

Thanks: Daniel Erez.
(cherry picked from commit 389e165519)
2018-08-22 12:10:06 +02:00
Richard W.M. Jones
6f116349a2 v2v: -o rhv-upload: Fix error message disk numbering (RHBZ#1615885).
The output method used the s_disk_id field assuming it was a unique,
monotonically increasing number counting from 0.  However this is not
the case, the input method simply has to set s_disk_id to be unique
for each disk.

Fixes commit cc04573927.

Thanks: Xiaodai Wang
(cherry picked from commit 90c9c12258)
2018-08-22 12:09:40 +02:00
Pino Toscano
bb804081e9 v2v: parse_libvirt_xml: handle srN CDROM devices (RHBZ#1612785)
This device naming is mostly written by virt-p2v, so get the slot from
it directly without using the drive_index "decoding" function.

(cherry picked from commit c9abaa3e96)
2018-08-22 12:09:20 +02:00
Pino Toscano
21cf4aaafb uefi: remove last references to kraxel's old edk2 builds
Commit 889386f8c6 removed most of them
already, so remove the last ones, and the supporting code.
2018-08-09 16:27:48 +02:00
Daniel Erez
bc2ba2f47b v2v: rhv plugin - case-sensitive search queries
Changed both search queries to case-sensitive (to ensure an exact match).
2018-08-09 16:26:58 +02:00
Daniel Erez
c0f9ab6665 v2v: rhv plugin - fix DC search string
Search for DC by 'storage.name=' to make it explicit.
I.e. "storage=" uses regex, so similar names can be
found in the search query. For example, searching for
a domain named FCSD, will find FCSD1 as well.
2018-08-09 16:26:58 +02:00
Pino Toscano
bb6b81861e v2v: -o rhv-upload: check for ovirtsdk4 (RHBZ#1601943)
Check earlier whether the ovirtsdk4 Python can be imported correctly,
to avoid errors later on during the migration.
2018-08-09 16:26:58 +02:00
Pino Toscano
77604b91ec v2v: change QXL ResourceType in OVirt flavour (RHBZ#1598715)
Due to a conflict with the IDs of the OVF standard, and the existing
implementation in ovirt-engine, the ID of QXL devices changed to a
different value.

As a consequence, change the ResourceType of QXL devices, but only in
OVirt flavour to avoid breaking vdsm mode.

See: https://bugzilla.redhat.com/show_bug.cgi?id=1598715#c5
(cherry picked from commit aa9e18f6d1)
2018-08-09 16:26:58 +02:00
Daniel Erez
e1401de974 v2v: rhv plugin - find suitable host (RHBZ#1596810) (RHBZ#1596851)
For direct upload, a suitable host must be in status 'Up'
and belong to the same datacenter as the created disk.
Added these criteria to the host search query.

(cherry picked from commit 4ed1bc5a79)
2018-08-09 16:26:58 +02:00
Nir Soffer
7b5ec5a647 v2v: rhv-upload-plugin: Optimize only direct upload
The optimization to start the transfer on the local host makes sense
only when using the rhv-direct=true option. When using a proxy, let the
engine choose a host.

(cherry picked from commit 891b5a0ec0)
2018-08-09 16:26:58 +02:00
Nir Soffer
8aaf7d89ef v2v: rhv-upload-plugin: Improve error handling
When optimizing the connection using unix socket, we handle these cases:

- The local host is not an oVirt host (no /etc/vdsm/vdsm.id).
- The local host is an oVirt host, but is not registered with engine.
- Creating UnixHTTPConnection() fails. Unlikely and probably a bug in
  the plugin, but we can recover by using the https connection.

The current code handle these cases silently, making it harder to
understand why the unix socket optimization did no happen. Add debug
message to make this clear.

Also comment in the error handler why we take this path instead of
failing the operation.

(cherry picked from commit f5442d2f04)
2018-08-09 16:26:58 +02:00
Nir Soffer
a3e99c84e1 v2v: rhv-upload-plugin: Remove unneeded auth
Old imageio proxy was using Authorization header for GET and PUT
requests. Remove unneeded authorization when sending OPTIONS request.

Remove unneeded duplicated comments about authorization for old
imageio, and replace them with a comment when we set needs_auth.

(cherry picked from commit d5f36bacf9)
2018-08-09 16:26:58 +02:00
Pino Toscano
da504873e1 v2v: improve -os documentation for rhv-upload
Thanks to: Ming Xie

(cherry picked from commit 8d33ff8ba4)
2018-08-09 16:26:58 +02:00
Richard W.M. Jones
db7e06935b v2v: -o rhv-upload: Use Unix domain socket to access imageio (RHBZ#1588088).
In the case where virt-v2v runs on the same server as the imageio
daemon that we are talking to, it may be possible to optimize access
using a Unix domain socket.

This is only an optimization.  If it fails or if we're not running on
the same server it will fall back to the usual HTTPS over TCP
connection.

Thanks: Nir Soffer, Daniel Erez.
(cherry picked from commit b7a2e6270d)
2018-08-09 16:26:58 +02:00
Richard W.M. Jones
1d2058c08b v2v: -o rhv-upload: Always fetch server options when opening the connection.
Previously we lazily requested the server options in the can_*
callbacks.  The can_* callbacks are always called by nbdkit straight
after open, so this just adds complexity for no benefit.  This change
simply makes the code always fetch the server options during the open
callback.

This is — functionally at least — mostly just refactoring.  However I
also added a useful debug message so we can see what features the
imageio server is offering.

(cherry picked from commit a1e1f6ec88)
2018-08-09 16:26:58 +02:00
Nir Soffer
6e683fa651 v2v: rhv-upload-plugin: Remove unused variables
Remove some instances of "transfer" and "transfer_service" that are not
used in current code.

(cherry picked from commit 32ab53cecd)
2018-08-09 16:26:58 +02:00
Nir Soffer
47fd85a883 v2v: rhv-upload-plugin: Fix name error
"http" and "transfer" variables were missing in emulate_zero, so the
code would fail with NameError.  This can happen only when communicating
with old imageio versions not supporting the "zero" feature.

Testing with qemu-img 2.12 show that we never send emulated zero request
because of the highestwrite mechanism, but it can break with older
qemu-img-rhev used on RHEL.

(cherry picked from commit 0ae61ce99c)
2018-08-09 16:26:58 +02:00
Nir Soffer
6cd873ff9a v2v: rvh-upload-plugin: Always read the response
Python manual warns[1]:

    Note that you must have read the whole response before you can send
    a new request to the server.

The reason for this warning is exposed only when the server is using
keep alive connections. When the response is not read, sending a new
request will fail with:

    httplib.ResponseNotReady

Even if Content-Length was 0 or the request has no content. The failure
looks like this when using --verbose:

nbdkit: python[1]: debug: zero count=33554432 offset=0 may_trim=1 fua=0
nbdkit: python[1]: debug: zero count=33554432 offset=33554432 may_trim=1 fua=0
nbdkit: python[1]: error: /home/nsoffer/src/libguestfs/tmp/rhvupload.Au2B5I/rhv-upload-plugin.py: zero: error: Request-sent
nbdkit: python[1]: debug: sending error reply: Input/output error
qemu-img: error writing zeroes at offset 0: Input/output error

Change all requests to read the whole response.

Tested with imageio patch supporting keep alive connections:
https://gerrit.ovirt.org/#/c/92296/

[1] https://docs.python.org/3.8/library/http.client.html#http.client.HTTPConnection.getresponse

(cherry picked from commit f4e0a8342d)
2018-08-09 16:26:58 +02:00
Richard W.M. Jones
c2ed35e2bc v2v: -o rhv-upload: Log full imageio response on failure.
Thanks: Nir Soffer
(cherry picked from commit 831a75cd11)
2018-08-09 16:26:58 +02:00
Nir Soffer
5917bdc15f v2v: -o rhv-upload: Optimize http request sending
When sending request with small or no payload, it is simpler and
possibly more efficient to use the high level HTTPSConnection.request(),
instead of the lower level APIs.

The only reason to use the lower level APIs is to avoid copying the
payload, or on python 2, to use a bigger buffer size when streaming a
file-like object.

(cherry picked from commit 77a412c0a1)
2018-08-09 16:26:58 +02:00
Pino Toscano
ee00f39eea inspector: show the per-OS osinfo guess (RHBZ#1544842)
Output also the osinfo guess for each OS in the generated XML output;
adapt the RNG schema, and the test data to it.

(cherry picked from commit 2f8ec91fc1)
2018-08-09 16:26:58 +02:00
Pino Toscano
24aef5baa9 New API: inspect_get_osinfo
Try to guess the possible osinfo-db short ID for the specified OS.

Related to: https://bugzilla.redhat.com/show_bug.cgi?id=1544842

(cherry picked from commit 286b88891c)
2018-08-09 16:26:58 +02:00
Richard W.M. Jones
e61cbd740b v2v: -o rhv-upload: Set inactivity timeout (RHBZ#1586198).
This increases the inactivity timeout for transfers from the default
(60 seconds in oVirt < 4.2.3, 600 seconds in >= 4.2.3), up to 1 hour,
so that we should never hit it for ordinary transfers.

Note this requires oVirt >= 4.2.3.  The corresponding oVirt fix was
https://bugzilla.redhat.com/1563278

I also replaced the deprecated ‘image’ parameter with ‘disk’.

Thanks: Nir Soffer, Daniel Erez.
(cherry picked from commit f25404c65f)
2018-08-09 16:26:58 +02:00
Pino Toscano
973810a232 v2v: add and use Create_ovf.ovf_flavour_to_string
Add an helper to convert an OVF flavour to string, and use it in
-o vdsm to print the actual value of the vdsm-ovf-flavour option.

Thanks to Ming Xie.

(cherry picked from commit c0da02f90d)
2018-08-09 16:26:58 +02:00
Pino Toscano
bd2afb6e11 v2v: fix "rhevexp" typo in documentation
Spotted by Ming Xie.

(cherry picked from commit c021ac5e64)
2018-08-09 16:26:58 +02:00
Pino Toscano
b31fcaf987 v2v: fix build rules for output_rhv_upload_*_source.ml files
Use the $(srcdir) variable where needed, to make sure it builds also
with srcdir != builddir.

Furthermore, make sure that the OCaml dependencies calculation depend on
the generated output_rhv_upload_*_source.ml files, otherwise there will
be incomplete OCaml rules for them in the generated .depend.

Fixes commit cc04573927.

(cherry picked from commit a4e3b7c059)
2018-08-09 16:26:58 +02:00
Richard W.M. Jones
c2570c81e8 v2v: Map Windows Server 2012 R2 x86-64 to ovirt ID 25.
Thanks: Michal Skrivanek

Fixes commit 593a19cc86.

(cherry picked from commit c6e8929929)
2018-08-09 16:26:58 +02:00
Tomáš Golembiovský
1ddbe89dbc v2v: -o rhv-upload: install RHV tools (RHBZ#1561828).
Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
(cherry picked from commit f3f00d3f9c)
2018-08-09 16:26:58 +02:00
Richard W.M. Jones
2e9cc6b230 v2v: -o rhv-upload: Don't require ‘-of raw’ parameter.
Because we checked the limitation of raw+sparse during command line
processing, it had the effect of forcing you to use ‘-of raw’ even if
the input was already in raw format.  Move the checking to the output
mode to avoid this.

Fixes commit cc04573927.

(cherry picked from commit b3769afaec)
2018-08-09 16:26:58 +02:00
Pino Toscano
2648e807fa v2v: refer to the right embed script in EXTRA_DIST
Fixes commit cc04573927.

(cherry picked from commit cf49fe1003)
2018-08-09 16:26:58 +02:00
Richard W.M. Jones
79aa92b800 v2v: Add -o rhv-upload output mode (RHBZ#1557273).
This adds a new output mode to virt-v2v.  virt-v2v -o rhv-upload
streams images directly to an oVirt or RHV >= 4 Data Domain using the
oVirt SDK v4.  It is more efficient than -o rhv because it does not
need to go via the Export Storage Domain, and is possible for humans
to use unlike -o vdsm.

The implementation uses the Python SDK (‘ovirtsdk4’ module).  An
nbdkit Python 3 plugin translates NBD calls from qemu into HTTPS
requests to oVirt via the SDK.

(cherry picked from commit cc04573927)
2018-08-09 16:26:58 +02:00