Commit Graph

10826 Commits

Author SHA1 Message Date
Pino Toscano
5565cf767a test-tool: implement --short-options & --long-options
While not useful per-se, it will help checking the available options.
2018-06-28 10:10:10 +02:00
Pino Toscano
b61c98b9e1 v2v: -o local: print libvirt XML
In verbose mode, print the generated libvirt XML to stderr for
debugging, just like -o libvirt does.
2018-06-28 10:10:10 +02:00
Richard W.M. Jones
b7a2e6270d 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.
2018-06-28 08:37:11 +01:00
Richard W.M. Jones
a1e1f6ec88 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.
2018-06-26 08:49:37 +01:00
Nir Soffer
32ab53cecd v2v: rhv-upload-plugin: Remove unused variables
Remove some instances of "transfer" and "transfer_service" that are not
used in current code.
2018-06-26 08:42:06 +01:00
Nir Soffer
0ae61ce99c 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.
2018-06-25 19:09:34 +01:00
Nir Soffer
f4e0a8342d 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
2018-06-25 19:09:22 +01:00
Richard W.M. Jones
264f7ae9dd docs: building: autotools and gettext must be installed separately.
Thanks: Nir Soffer
2018-06-25 08:48:21 +01:00
Yuri Chornoivan
adbf1bc320 Fix minor typos 2018-06-25 08:35:43 +01:00
Richard W.M. Jones
3886a113f2 p2v: Allow virt-v2v input and output drivers containing '-' (RHBZ#1590220).
The new ‘-o rhv-upload’ output mode contains a '-' character in the
name, but the regular expression which matched the output of the
virt-v2v command did not recognize '-' as a valid character.  It ended
up mapping this to just "rhv" meaning two "rhv" entries would appear
in the list of output drivers.

Thanks: Ming Xie.
2018-06-22 12:51:10 +01:00
Richard W.M. Jones
75e8b13867 v2v: <File ovf:size> changed to the actual size (if known).
Note that this attribute is optional.

Thanks: Arik Hadas
2018-06-21 15:16:53 +01:00
Richard W.M. Jones
7c2afc88fd v2v: Add <Disk ovf:capacity> attribute containing disk virtual size (RHBZ#1592468).
Virt-v2v transfers to newer versions of ovirt-engine can fail with:

  ovirtsdk4.Error: Fault reason is "Operation Failed". Fault detail is "failed to parse a given ovf configuration ovf error: [empty name]: cannot read '//*/disksection' with value: null". HTTP response code is 400.

This was caused by a change made to oVirt:

  https://gerrit.ovirt.org/#/c/91902/

so that it now requires the <Disk ovf:capacity> attribute.

Thanks: Arik Hadas
2018-06-21 15:16:53 +01:00
Richard W.M. Jones
8c3375d47c v2v: docs: Removed vsyscall support in Debian kernels requiring workaround (RHBZ#1592061).
Thanks: Haigang Li
2018-06-21 15:14:20 +01:00
Richard W.M. Jones
e2910eeaf8 v2v: -o libvirt: Don't write only <vendor> without <model> (RHBZ#1591789).
Avoids the libvirt error:

  error: XML error: CPU vendor specified without CPU model
2018-06-21 15:09:05 +01:00
Richard W.M. Jones
70bc83f893 lib: libvirt: Convert all socket parameters to an absolute path (RHBZ#1588451). 2018-06-21 13:19:04 +01:00
Nir Soffer
77a412c0a1 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.
2018-06-18 11:56:00 +01:00
Pino Toscano
4f927e58a9 fuse: fix build when not available
The 'localmountpoint' variable in the handle is available only when
building with FUSE support, so guard it in a proper #ifdef block.

Fixes commit 296370fb86.

Thanks to: Corentin Labbe (both reporting, and testing)
2018-06-15 18:36:39 +02:00
Richard W.M. Jones
afd1c70601 gitignore: Don't ignore patch files. 2018-06-14 11:10:48 +01:00
Richard W.M. Jones
a804a6f205 v2v: tests: Stable-sort CPU features in --print-source option.
The test failed with:

  -   CPU features: pae,apic,acpi
  +   CPU features: acpi,apic,pae

Fixes commit 67145499ec.
2018-06-12 17:36:28 +01:00
Richard W.M. Jones
67145499ec v2v: parse_libvirt_xml: Simplify code by using xpath_get_nodes utility fn.
No functional change.
2018-06-12 10:29:17 +01:00
Richard W.M. Jones
24404a5dec v2v: Refactor order of parameters to input objects.
Simple refactoring of the order of parameters to input objects
so they are always in the order:

  input_foo          ; class name
    input_conn       ; command line -iX parameters, alphabetically
    input_password   ;
    ...              ;
    vddk_options     ; extra class parameters
    ...              ;
    guestname        ; remaining command line parameters
2018-06-12 10:29:17 +01:00
Richard W.M. Jones
f49c5d14dd v2v: Use -ip to pass input password (instead of --password-file).
Consistent with the option -op added in
commit a4e181137a, use -ip to pass
passwords for the input side.

This replaces --password-file, and like that option you have to pass a
filename.

This also changes the code so we pass around the filename instead of
the password between functions.  For ‘-it vddk’ this simplifies
things: we can pass the filename through to nbdkit and we never need
to read it in virt-v2v.  For other input methods we eventually need to
read the password from the file at some lower level place in the code.
2018-06-12 10:29:16 +01:00
Richard W.M. Jones
0b3c95cc7a v2v: copy-to-local: Use Getopt ‘M’ for -ic parameter. 2018-06-12 10:29:16 +01:00
Richard W.M. Jones
f25404c65f 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.
2018-06-07 19:17:18 +01:00
Richard W.M. Jones
831a75cd11 v2v: -o rhv-upload: Log full imageio response on failure.
Thanks: Nir Soffer
2018-06-07 19:17:18 +01:00
Richard W.M. Jones
a4d5548a45 docs: security: Document CVE-2018-11806.
Qemu: slirp: heap buffer overflow while reassembling fragmented
datagrams.
2018-06-06 11:02:19 +01:00
Richard W.M. Jones
553e201119 fish: rc: Minor whitespace fixes. 2018-06-04 05:41:58 -04:00
Richard W.M. Jones
2add3c6995 utils: Factor out hexdump code used by --enable-packet-dump.
Factor out the common code used to hexdump the protocol when
./configure --enable-packet-dump is used.

It's not quite a straight refactor because I had to fix some
signedness bugs in the code which were not revealed before because
this code is usually disabled.
2018-06-04 05:36:56 -04:00
Mykola Ivanets
b699111e04 daemon: list-filesystems: Filter out MBR extended partitions.
Extended MBR partitions cannot hold filesystems - filter them out.

RWMJ:

* Simplify is_mbr_extended function.

* Fix regression test rhbz1285847:

  The test assumed that list-filesystems would return an extended MBR
  partition (as "unknown").  However such partitions only contain
  logical partitions inside them, not filesystems.

* Some minor whitespace changes.
2018-06-01 15:09:34 +01:00
Mykola Ivanets
0a2f276be0 daemon: list-filesystems: Filter out Microsoft Reserved and Windows Snapshot partitions.
Filter out Microsoft Reserved Partition and Windows Snapshot Partition.
2018-06-01 15:09:34 +01:00
Mykola Ivanets
16192ad953 daemon: list-filesystems: Change the way we filter out LDM partitions.
1. Now we use GPT partition type to filter out LDM partitions.
2. We also check for filesystems on LDM volumes because LDM partitions
doesn't contain filesystems (list_ldm_partitions is not called anymore).
3. Obvious repetitive comments are moved to a function description.
2018-06-01 15:09:34 +01:00
Mykola Ivanets
af63e6e491 tests: list-filesystems command ignores partitioned MD devices.
Test guestfish list-filesystems command finds file system on partitioned md device and doesn't take into account md device itself (similar to as physical devices are filtered out if they are partitioned).
2018-06-01 15:09:34 +01:00
Mykola Ivanets
b316a33264 daemon: list-filesystems: Ignore partitioned MD devices.
Ignore partitioned MD devices the same way we ignore regular partitioned
devices because they cannot contain filesystems as well.
2018-06-01 15:09:34 +01:00
Mykola Ivanets
55abc820cd daemon: Changing the way that we detect if a device contains partitions.
Instead of using part_to_dev to find such devices we open the device's
directory under /sys/block/<dev_name> and look for entries starting with
<dev_name>, eg. /sys/block/sda/sda1.
2018-06-01 15:09:34 +01:00
Mykola Ivanets
7b4d13626f daemon: inspect: better handling windows drive mapping.
I saw several Windows disk images which contains strange registry entry
for mapped drives:

"\\DosDevices\\Y:"=hex(3):00,00,00,00,00,00,00,00,00,00,00,00

Which is decoded something like diskID = 0x0, partition starts at 0
bytes offset from the start of the disk.  In addition to a Windows disk
image, I have attached dummy disk and made xfs file system on a whole
device without partitioning it.  I mount xfs file system to a "/" and
then mkdir and mount other found file systems inside (/fs1, /fs2 etc.).

When we decode drive mappings we are looking for a disk with ID 0x0 (it
is 4 bytes somewhere LBA0).  It is appeared that dummy non-partitioned
disk with xfs file system has zeros by offset where diskID is expected
to be).  So the disk is considered as a candidate to search for
partition at offset 0. part-list command (and "parted" which is used
under the hood) reports there is 1 partition on "dummy" disk which
starts exactly at offset 0.  And thus dummy device name and partition
number are simply concatenated together and corresponding drive mapping
is returned: Y => /dev/sdX1.  But /dev/sdX1 is not existing block
device.

No matter either it is a bug in "parted" (or it works this way
by-design), let's protect ourself from this situation: in addition we
look for msdos partition table on a disk before making any further
assumptions.
2018-06-01 15:09:34 +01:00
Richard W.M. Jones
dd162d2cd5 daemon: Move lvmetad to early in the appliance boot process.
When the daemon starts up it creates a fresh (empty) LVM configuration
and starts up lvmetad (which depends on the LVM configuration).

However this appears to cause problems: Some types of PV seem to
require lvmetad and don't work without it
(https://bugzilla.redhat.com/show_bug.cgi?id=1581810).  If we don't
start lvmetad earlier, the device nodes are not created.

Therefore move the whole initialization step into appliance/init.

Two further changes had to be made:

Now we are using lvmetad all the time, using vgchange is incorrect.
With lvmetad activated early we must use ‘pvscan --cache --activate ay’
to scan all disks for PVs and activate any VGs on them (although the
documentation is complex, confusing and contradictory so I'm not
completely sure about this).

The ‘lvm_system_dir’ local variable in ‘daemon/lvm-filter.c’
previously contained the path of the directory above $LVM_SYSTEM_DIR
(eg. $LVM_SYSTEM_DIR = "/etc/lvm", lvm_system_dir = "/etc").  As this
was highly confusing, I have changed it so the local variable and the
environment variable have identical contents.  This involved removing
the ‘lvm/’ component from a couple of paths since it is now included
in the local variable.
2018-05-29 20:38:40 +01:00
Pino Toscano
c0da02f90d 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.
2018-05-29 07:04:50 +02:00
Pino Toscano
c021ac5e64 v2v: fix "rhevexp" typo in documentation
Spotted by Ming Xie.
2018-05-29 06:49:23 +02:00
Pino Toscano
a4e3b7c059 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.
2018-05-22 21:20:13 +02:00
Pino Toscano
500acb15f8 v2v: linux: fix kernel detection when split in different packages
The current detection code for Linux kernels assumes that a kernel
package contains everything in it, i.e. the kernel itself, its modules,
and its configuration.  However, since recent Ubuntu versions (e.g.
starting from 18.04) modules & config (with few more files) are split in
an own package, thus not detecting the modpath from installed vmlinuz
files.

To overcome this situation, rework this detection a bit:
1) find the vmlinuz file as before, but then immediately make sure it
   exists by stat'ing it
2) find the modules path from the package as before:
2a) if found, extract the version in the same step
2b) if not found, get the kernel version from the vmlinuz filename,
    and use it to detect the modules path
3) check that the modules path exists

The detection done in (2b) is based on the current packaging scheme
found in the most important Linux distributions (Fedora, RHEL, CentOS,
Debian, Ubuntu, openSUSE, AltLinux, and possibly more).  The notable
exception is Arch Linux.

As additional change, do not assume the config file is in the same
package as vmlinuz, but directly look into the filesystem using the
version we already have.
2018-05-22 10:46:21 +02:00
Pino Toscano
1b6a2b221d v2v: -o null: support older qemu-img (RHBZ#1580309)
Commit 4699c7b6e1 converted the null
output to use the null-co qemu driver with a JSON URL syntax --
especially the latter is only available in newer versions of qemu.

Even if this output mode is mostly for testing, check at runtime whether
the null-co + JSON way is possible, falling back to the creation of
thrown-away temporary files as before.
2018-05-22 10:25:30 +02:00
Richard W.M. Jones
0c934144eb v2v: Use Std_utils.qemu_input_filename instead of prefixing "file:" to filename (RHBZ#1580292).
This also allows us to use virt-v2v with the old version of qemu in
RHEL 7.

Fixes commit e29296cfa2.

Thanks: Pino Toscano for suggesting the fix.
2018-05-22 09:07:33 +01:00
Richard W.M. Jones
f366da30e6 Version 1.39.5. v1.39.5 2018-05-21 13:09:53 +01:00
Richard W.M. Jones
4683f4c99f builder: templates: Rebuild index.
Fixes commit 1f983a050f.
2018-05-21 10:01:35 +01:00
Richard W.M. Jones
1f983a050f builder: templates: Rebuild Ubuntu 18.04 image without proxy (RHBZ#1579047). 2018-05-21 09:58:23 +01:00
Richard W.M. Jones
3632c77bfd builder: templates: Remove bogus proxy from Ubuntu apt configuration (RHBZ#1579047).
Thanks: Lars Seipel.

See also commit 4b2e9c9264 which did the
same for Debian back in 2013.
2018-05-21 09:58:23 +01:00
Richard W.M. Jones
140a25b511 authors: Add Nikolay Ivanets (alternate form). 2018-05-15 14:05:03 +01:00
Richard W.M. Jones
5982f7aec8 authors: Add Adam Robinson. 2018-05-15 14:05:03 +01:00
Richard W.M. Jones
eb4d283a09 macOS: unix-utils: Include <sys/mount.h>.
If <sys/mount.h> is available on the platform, always include
it in this file.
2018-05-15 11:15:54 +01:00
Adam Robinson
431d8c8c1e macOS: Include <rpc/types.h> before <rpc/xdr.h>.
The ordering of includes is required on this platform.
2018-05-15 11:15:54 +01:00