76 Commits

Author SHA1 Message Date
Richard W.M. Jones
fd1148f795 v2v: Implement --parallel=N for parallel disk copies
When set, run up to N copies of nbdcopy in parallel.  This only
applies for guests with multiple disks.

The default, as for all older versions of virt-v2v, is to copy disks
one at a time.
2024-12-02 17:18:27 +00:00
Richard W.M. Jones
5c866e7bb2 build: Use nbdcopy and nbdinfo from ./configure
Use the configured binaries, so that (eg) ./configure NBDCOPY=...
will do the right thing.
2024-12-02 13:43:39 +00:00
Richard W.M. Jones
9e25b211a4 build: Remove --with-virt-v2v-nbdkit-python-plugin=...
In theory, ./configure --with-virt-v2v-nbdkit-python-plugin=<name>
allowed you to override the default nbdkit-python-plugin name (usually
"python").  However:

 (a) nbdkit no longer provides a Python version 2 plugin and hasn't
 since nbdkit 1.16 (2019),

 (b) we no longer support older RHEL where there were parallel Python
 2 & 3 plugins and this was an issue, and

 (c) the result wasn't actually used in the code (it used to be, but I
 think I replaced it with "python" and forgot about this ./configure
 parameter).
2024-12-02 13:30:11 +00:00
Richard W.M. Jones
d46ceba1bd lib, input: Model UEFI secureboot property in metadata
This models a UEFI NVRAM variable which controls whether or not EFI
binary signatures are verified, which is an initial step in the long
chain of operations commonly known as "secure boot".  I added plenty
of documentation explaining what this really means as it is
non-obvious.

Thanks: Daniel Berrange, Andrea Bolognani
2024-11-15 14:50:25 +00:00
Richard W.M. Jones
69b4e83935 -o qemu: Replace hard-coded UEFI paths
Update the qemu shell script to simply find the UEFI paths as
required.

Remove lib/uefi.ml:find_uefi_firmware as this function is no longer
needed.

Remove common/mlv2v/ everywhere.  This contained a list of UEFI code
and NVRAM files which is no longer used.

Update common submodule.  This pulls in:

  Richard W.M. Jones (5):
      mlcustomize/customize_run.ml: Move 'in' to new line
      mlstdutils/guestfs_config: Define host_os
      mlcustomize, mltools: Check guest OS is compatible before allowing --run
      Remove mlv2v/ subdirectory
      qemuopts: Add ability to add raw, unquoted output to qemu scripts
      qemuopts: Fix missing break statement
2024-11-15 14:15:57 +00:00
Richard W.M. Jones
8dd5577174 lib: OVF: Add preliminary support for Windows Server 2025
Unfortunately support has not yet been added to oVirt.  However I have
inferred the correct ostype value based on existing entries.

Also pull in the following commit from the common submodule:

  Richard W.M. Jones (1):
      mlcustomize: Add heuristic support for Windows Server 2025

Related: https://issues.redhat.com/browse/RHEL-65009
Related: https://issues.redhat.com/browse/RHEL-65010
Reported-by: Ming Xie
2024-10-30 10:18:02 +00:00
Richard W.M. Jones
6b57c16140 lib: YAML: Fix empty dictionaries and lists
Another weird corner case in YAML is that empty dictionaries have a
special representation.  Empty lists also have a special
representation, that we got wrong.

Link: https://stackoverflow.com/a/33510095
2024-09-10 10:25:18 +01:00
Richard W.M. Jones
d33fa8822b convert: Collect drive mappings in 'inspect' object
Currently we only print it in debugging output, but we might use it in
future.  It costs nothing to get it as it is already collected for
Windows guests (and is empty for other guests).
2024-07-30 16:33:20 +01:00
Richard W.M. Jones
652766b412 convert: Dump more information about the guest during conversion
As with the previous commit, this will match searches for ^info:
2024-07-30 16:07:34 +01:00
Richard W.M. Jones
0950ae3d75 convert: Tag some important information in debug output with ^info:
When we get large virt-v2v logs back from customers it is often
difficult to find relevant information about the guest.  Try to fix
this by tagging some important information so that it will match this
regular expression in searches:

  ^info:

Note I'm not including information about input and output drivers
here.  If we suspect a problem there, then more detailed review of the
log is always needed, plus that information is usually much easier to
find (eg. finding the kubevirt yaml or libvirt XML is obvious even in
large log files).

The main complexity here was to ensure that all of the nbdinfo
information appears together.  We need to run the command and collect
the output, otherwise it gets mixed in with debugging from nbdkit
which resulted from running nbdinfo.

Also update the common submodule to include:

  Richard W.M. Jones (1):
      mldrivers/linux_kernels.ml: Prefix general information with ^info:
2024-07-30 16:07:34 +01:00
Richard W.M. Jones
7a82e130c2 lib: Only get nbdkit config and version once
The configuration (--dump-config) and version of nbdkit won't change
while we are running, so we only need to get it once.  We also don't
need the config parameter to Nbdkit.version so drop that.
2024-07-30 15:57:57 +01:00
Richard W.M. Jones
43ca22168b -o qemu: Remove final use of error_unless_uefi_firmware
This function was used by -o libvirt / -o local to check that we have
UEFI firmware for the target architecture.  All it does is called
find_uefi_firmware early so that we fail early.

The same check was copied into -o qemu, probably wrongly as we call
find_uefi_firmware just below, so the early fail is not necessary.

This allows us to remove error_unless_uefi_firmware completely since
it is no longer used anywhere.
2024-03-11 12:05:46 +00:00
Richard W.M. Jones
69d73c251a types: Add gcaps_rtc_utc to record if the RTC is set to UTC or localtime
Almost every Linux guest expects the motherboard Real Time Clock (RTC)
to be set to UTC and they adjust the time displayed based on their
timezone (which may be different for each user).

Most Windows guests expect the RTC to be set to the local time.
Windows can be configured to use a UTC clock.  We can detect this by
looking at the Windows registry.

To cope with this difference we need to add a guestcaps flag based on
what we think the guest is expecting.  (We might also use the source
hypervisor RTC setting, but it is not thought to be as reliable as
inspecting the guest.)

This change simply adds the flag to guestcaps, and sets it to always
true, so there is no change to the output.

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2023-09-25 17:21:00 +01:00
Laszlo Ersek
8bcf383510 lib/utils: make "chown_for_libvirt_rhbz_1045069" fail hard
Currently "chown_for_libvirt_rhbz_1045069" is best effort; if it fails, we
suppress the exception (we log it in verbose mode only, even).

That's not proved helpful: it almost certainly leads to later errors, but
those errors are less clear than the original (suppressed) exception.
Namely, the user sees something like

> Failed to connect to '/tmp/v2v.sKlulY/in0': Permission denied

rather than

> Failed to connect socket to '/var/run/libvirt/virtqemud-sock-ro':
> Connection refused

So just allow the exception to propagate outwards.

And then, now that "chown_for_libvirt_rhbz_1045069" will be able to fail,
hoist the call to "On_exit.rm_rf" before the call to
"chown_for_libvirt_rhbz_1045069", after creating the v2v temporary
directory. In the current order, if "chown_for_libvirt_rhbz_1045069" threw
an exception, then we'd leak the temp dir in the filesystem.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2182024
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20230629123443.188350-3-lersek@redhat.com>
[lersek@redhat.com: reinstate parens under "then" [Rich]]
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2023-06-30 10:49:52 +02:00
Laszlo Ersek
dab9629c01 lib/utils: fix typo
Fix a small comment typo from commit 4e7f20684373 ("lib: Improve security
of in/out sockets when running virt-v2v as root", 2022-03-23).

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2182024
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20230629123443.188350-2-lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2023-06-30 10:49:44 +02:00
Andrey Drobyshev
ebb0b7b239 Revert "Remove guestcaps_block_type Virtio_SCSI"
This code is needed to check whether virtio-scsi driver was installed.

This reverts commit f0afc439524853508938b2bfc758896f053462e3.
Message-Id: <20230310175433.781335-2-andrey.drobyshev@virtuozzo.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
2023-03-14 13:02:04 +01:00
Richard W.M. Jones
8ad152afc4 Rework Std_utils.Option so it works like the OCaml stdlib module
OCaml 4.08 introduces a stdlib Option module which looks a bit like
ours but has a number of differences.  In particular our functions
Option.may and Option.default have no corresponding functions in
stdlib, although there are close enough equivalents.

This change was automated using this command:

$ perl -pi.bak \
  -e 's/Option.may/Option.iter/g; s/Option.default /Option.value ~default:/g' \
  `git ls-files`

Update common module to include:

  commit cffa077323fafcdfcf78e230c022afa891a6b3ff
  Author: Richard W.M. Jones <rjones@redhat.com>
  Date:   Mon Feb 20 12:11:51 2023 +0000

    mlstdutils: Rework the Option module to be compatible with stdlib

  commit 007d0506c538db0a43fec7e9986a95ecdcd48b56
  Author: Richard W.M. Jones <rjones@redhat.com>
  Date:   Mon Feb 20 12:18:29 2023 +0000

    mltools: Replace Option.may with Option.iter
2023-02-20 12:21:47 +00:00
Richard W.M. Jones
e4a7f08c40 -o qemu: Always use -cpu host unless overridden by source hypervisor
As with the prior commit, prefer -cpu host for all guests (except when
we have more information from the source hypervisor).  Although there
is the disadvantage that -cpu host is non-migratable, in practice it
would be very difficult to live migrate a host launched using direct
qemu commands.

Note that after this change, gcaps_arch_min_version is basically an
informational field.  No output uses it, but it will appear in debug
output and there's the possibility we might use it for a future output
mode.

Thanks: Laszlo Ersek
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2023-02-20 11:11:20 +00:00
Richard W.M. Jones
2cf337c26e v2v: Rename gcaps_default_cpu to gcaps_arch_min_version
Some guests require not just a specific architecture, but cannot run
on qemu's default CPU model, eg. requiring x86_64-v2.  Since we
anticipate future guests requiring higher versions, let's encode the
minimum architecture version instead of a simple boolean.

This patch essentially just remaps:

  gcaps_default_cpu = true  => gcaps_arch_min_version = 0
  gcaps_default_cpu = false => gcaps_arch_min_version = 2

I removed a long comment about how this capability is used because we
intend to completely remove use of the capability in a coming commit.

Updates: commit a50b975024ac5e46e107882e27fea498bf425685
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2023-02-20 11:08:39 +00:00
Richard W.M. Jones
d2b01e487f Split long lines in messages
This commit splits up any long lines found in errors, warnings or
other messages.  OCaml ignores whitespace following "\<CR>" within a
string, eg:

  "long string \
   more stuff"

is parsed as:

  "long string more stuff"

Thanks: Laszlo Ersek, for working out the OCaml syntax for this
2023-01-20 10:29:24 +00:00
Richard W.M. Jones
15a3fa4768 lib: Move DOM code from virt-v2v to mltools
Update common submodule, picking up:

    mltools: Move DOM code from virt-v2v to mltools

    This is a simple library for generating XML output.  We would like to
    use this in the new guestfs-tools program 'virt-drivers', so move it
    to common/mltools.

    This is a straightforward code move, the library has no significant
    dependencies.
2023-01-19 15:55:52 +00:00
Richard W.M. Jones
4ab3126aa1 convert: Move firmware inspection to a new Firmware module
The existing function Inspect_source.get_firmware_bootable_device
detected if the guest could boot using UEFI through inspection (rather
than whatever the hypervisor told us).

Move this function to a new module, renaming it as
Firmware.detect_firmware.

Since we intend to move this into common/ (so it can be used in
guestfs-tools), remove the i_firmware field from the inspect struct
and pass it around as a separate argument.
2023-01-19 10:13:52 +00:00
Richard W.M. Jones
1ea99fb2a7 Remove support for RHEL 3
This was the only guest type which did not support ACPI.  It also only
supported direct to libvirt output.  It hasn't been tested for a long
time, and hasn't been supported by Red Hat for very much longer.
Removing this means we no longer have to think about non-ACPI guests.
2023-01-17 14:23:08 +00:00
Laszlo Ersek
fcd787573b rhv: Use osinfo to distinguish Windows >= 10 variants in "ovirt:id" too
Reflect commit 38b35f3b7e5c ("rhv: Use osinfo to distinguish Windows >= 10
variants", 2022-12-02) to the "ovirt:id" field in the OVF as well. Take
the values from "packaging/conf/osinfo-defaults.properties" in the
ovirt-engine tree, as the comment on "get_ovirt_osid" explains.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2152465
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20230101140926.260265-1-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2023-01-05 16:57:10 +01:00
Richard W.M. Jones
438eec2bbc lib: Add a simple YAML generator
This is only enough to be able to generate Kubevirt machine
descriptions so it does not have to deal with all the general
complexity of YAML.  Only associative arrays, lists, simple types like
strings, and blocks of lines are supported.

Unfortunately even generating simple YAML safely is not easy.  There
are many quirks to the format and many traps, including the dependency
between lists and associative arrays, and the lack of type safety.
2022-12-09 22:01:04 +00:00
Laszlo Ersek
b13813b527 convert_linux.get_uefi_arch_suffix: move to Utils
So that Windows conversion can use the same function.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2149629
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20221202124409.11741-2-lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2022-12-02 14:29:54 +01:00
Richard W.M. Jones
38b35f3b7e rhv: Use osinfo to distinguish Windows >= 10 variants
Windows versions >= 10 no longer use the NT major.minor numbering
scheme (it is fixed at 10.0).  Libguestfs >= 1.49.8 can distinguish
these versions and it sets <osinfo> correctly, so use that instead.

After this change the OVF will contain:

  <Info>Windows 10 Pro</Info>
  <Description>windows_11</Description>

which is strange, but apparently what Microsoft intended.  As far as
RHV is concerned it only needs <Description> to choose the correct
devices etc.

Reported-by: Tingting Zheng
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2149863
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2022-12-02 10:20:31 +00:00
Richard W.M. Jones
2eb6441264 common: Adapt to renamed function On_exit.rmdir -> On_exit.rm_rf
This function was renamed to make it clearer what it does (and that
it's potentially dangerous).  The functionality is unchanged.

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2022-07-15 08:57:52 +01:00
Richard W.M. Jones
71c4301909 qemu-nbd: Implement output compression for qcow2 files
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2022-07-05 10:46:30 +01:00
Richard W.M. Jones
3c4505c12a build: Remove bundled OCaml bindings for libvirt
The ocaml-libvirt project (https://gitlab.com/libvirt/libvirt-ocaml)
provides bindings for libvirt.  For historical reasons we bundled this
as it was throught ocaml-libvirt wasn't widespread on distros.  In
fact Fedora and Debian derivatives all have this.  Arch does not
(yet), but we can fix that.

It said in the README file in that directory, "before virt-v2v 1.42 is
released we hope to have unbundled this".  That didn't happen, but
let's remove it now.
2022-04-28 15:42:26 +01:00
Laszlo Ersek
a50b975024 types: introduce the "gcaps_default_cpu" field
Conversion will set "gcaps_default_cpu" to true iff the guest OS is
capable of running on QEMU's default VCPU model.

This capability will only matter for the QEMU and libvirt output modules,
where, in case the capability is false *and* the source hypervisor does
not specify a VCPU model, we'll have to manually present the guest OS with
a VCPU that looks as close as possible to a physical CPU.  (In that case,
we'll specify host-passthrough.)

The management applications targeted by the RHV and OpenStack output
modules have their own explicit VCPU defaults, overriding the QEMU default
model even in case the source hypervisor does not specify a VCPU model;
those modules will ignore this capability therefore.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2076013
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220420162333.24069-2-lersek@redhat.com>
[lersek@redhat.com: mention "-cpu qemu64" near the new field def (Rich)]
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2022-04-22 09:12:20 +02:00
Richard W.M. Jones
75872bf282 input: -i vmx: Add support for NVMe devices
We model NVMe devices in the source hypervisor.

We currently assume that no one is using the namespaces feature of
NVMe, ie. that each source device will appear in a Linux guest as
/dev/nvme0n1, /dev/nvme1n1, etc.  We could fix this if it is a
problem, but it requires adjusting the current assumption for
removable devices that slots are simple integers.

The devices are mapped to virtio-blk, so in the target the device name
has to change from /dev/nvme0 to /dev/vda (etc.)

Reported-by: Ming Xie
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2070530
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2022-04-08 16:24:38 +01:00
Laszlo Ersek
9788b06765 nbdkit, qemuNBD: run_unix: formally require externally provided socket
At this point, virt-v2v never relies on the Unix domain sockets created
inside the "run_unix" implementations. Simplify the code by removing this
option.

Consequently, the internally created temporary directory only holds the
NBD server's PID file, and never its UNIX domain socket. Therefore:

(1) we no longer need the libguestfs socket dir to be our temp dir,

(2) we need not change the file mode bits on the temp dir,

(3) we can rename "tmpdir" to the more specific "piddir".

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2066773
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220323104330.9667-1-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2022-03-23 13:39:12 +01:00
Richard W.M. Jones
4e7f206843 lib: Improve security of in/out sockets when running virt-v2v as root
When using the libvirt backend and running as root, libvirt will run
qemu as a non-root user (eg. qemu:qemu).  The v2v directory stores NBD
endpoints that qemu must be able to open and so we set the directory
to mode 0711.  Unfortunately this permits any non-root user to open
the sockets (since, by design, they have predictable names within the
directory).

Additionally we were setting the sockets themselves to 0777 mode.

Instead of using directory permissions, change the owner of the
directory and sockets to precisely give access to the qemu user and no
one else.

Reported-by: Xiaodai Wang
Thanks: Dr David Gilbert, Daniel Berrangé, Laszlo Ersek
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2066773
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2022-03-23 10:38:35 +00:00
Richard W.M. Jones
f44c8d2e81 lib/nbdkit.ml: Correct copy/paste error in comment 2022-03-23 10:37:24 +00:00
Richard W.M. Jones
5a60e9a4f6 lib, v2v: Move common code for creating v2v directory to Utils
I have also renamed the directory in the code from "tmpdir" to
"v2vdir" since tmpdir was a bit generic and didn't accurately describe
what this directory is for.

This is simple refactoring.
2022-03-22 14:33:30 +00:00
Richard W.M. Jones
c208bc97d8 lib: Remove Utils.metaversion
This was used before we turned the helpers into OCaml modules but is
now dead code, remove it.

Fixes: commit 4de22686fe74e1711efd9bfed3f663b67e7ad69e
Fixes: commit 724ecb5e887e5b71db836143ec0c0d8a20b05903
Fixes: commit 5609c73c615a8f12c5c6d50908bb4761bdc16173
2022-03-22 14:33:30 +00:00
Richard W.M. Jones
2b27652013 Add in-place support back to virt-v2v
Add a new front end called virt-v2v-in-place which implements simple
in-place conversion support for local disks.

Commit 255722cbf3 ("v2v: Modular virt-v2v") temporarily dropped this
feature.  This commit adds it back.
2022-03-10 15:11:53 +00:00
Richard W.M. Jones
8f326d8b10 Refactor calculation of output name
When we decide which output name to use, we start with the source name
(source.s_name), and override it with the output name specified on the
command line (-on option).

This calculation is done in quite a few places.

One place is in the conversion function.  This is completely
unnecessary and the commit removes it.

Also all the output functions do it, but they don't do it during other
option parsing code (ie. parse_options).  I have rationalized this
slightly by moving the calculation in all output modules to the
parse_options function and passing the computed value around in the
same structure as all the other parsed options.  (This change will
make more sense in the context of the following commit which further
rationalizes option parsing across all output modules.)

The change is quite large but is only refactoring and should make no
semantic change.
2022-02-11 16:24:28 +00:00
Richard W.M. Jones
0d880dc288 lib/qemuNBD.ml: Use qemu-nbd --discard=unmap
The default for qemu-nbd is to ignore discard requests.  This meant
that for input files in qcow2 format the "Mapping ..."  (ie. fstrim)
step did nothing, all the work was ignored and we copied deleted data
over to the destination.

This was detected by the test-v2v-trim.sh test.

Fixes: commit 255722cbf39afc0b012e2ac00d16fa6ba2f8c21f
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2022-01-20 12:43:34 +00:00
Richard W.M. Jones
a6aa06d499 lib/qemuNBD.ml: Use qemu-nbd --shared=0 flag to allow multiple connections
qemu-nbd --shared (-e) flag controls how many clients can connect
concurrently.  0 means unlimited.

We want to allow the sockets to be queried by other processes while
virt-v2v is running and it should be safe to do this.  The default
configuration of qemu-nbd doesn't allow this so add --shared=0.

Note this does not (in current qemu) enable multi-conn because we
aren't using the -r (read-only) flag.

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2022-01-20 12:43:34 +00:00
Laszlo Ersek
a2afed32d8 lib/utils: get_disk_allocated: adopt the int64 element type for "entries"
Adapt our "Utils.get_disk_allocated" function to the changed signature of
"NBD.block_status", coming from libnbd patch

  ocaml: map C's uint32_t to OCaml's int64

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2027598
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220114135048.25243-3-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2022-01-17 15:29:10 +01:00
Laszlo Ersek
a2cbc3fc86 lib/utils: get_disk_allocated: assert that NBD block length is positive
It makes no sense for the NBD server to return a zero-length block, plus
it used to be a bug in the libnbd OCaml bindings to wrap 32-bit block
lengths with the MSB set around to negative (signed) 32-bit integers
(which would then be widened to negative (signed) 64-bit integers).

Any non-positive "len" value breaks the progression of "fetch_offset",
potentially leading to an infinite loop.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2027598
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220114135048.25243-2-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
Acked-by: Eric Blake <eblake@redhat.com>
2022-01-17 15:28:20 +01:00
Richard W.M. Jones
4578887821 lib/utils.ml: Pass virt-v2v -v flag to libnbd
If using virt-v2v in verbose mode, pass the debug flag when using
libnbd.  This provides additional debugging.

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2022-01-12 12:41:55 +00:00
Richard W.M. Jones
fec32560c8 lib/utils.ml: Make with_nbd_connect_unix meta_contexts erasable
Make the meta_contexts parameter of Utils.with_nbd_connect_unix
optional and erasable.  This involves three connected changes, we
first make it optional (ie. '?meta_contexts'), providing the obvious
default of empty list.  We then need to move it to the first parameter
so OCaml can erase it even if we partially apply this function.
Finally remove the label from the function parameter 'f'.

Explanation for why the final change was necessary here:
https://listman.redhat.com/archives/libguestfs/2022-January/msg00082.html

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2022-01-12 12:41:55 +00:00
Laszlo Ersek
789017805a lib/types: introduce the "gcaps_virtio_1_0" guest capability
Add a new field to the "guestcaps" record to track whether the guest
supports the virtio devices that it does at the virtio-1.0 protocol level.

Virt-v2v's current assumption is that virtio-1.0 is supported by any
guest, namely for those virtio devices specifically that the guest
supports -- which in fact may be the empty set. Make this assumption
explicit by setting the new field to "true" in "convert/convert_linux.ml"
and "convert/convert_windows.ml".

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1942325
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220106140910.13695-4-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2022-01-07 12:20:41 +01:00
Laszlo Ersek
0878688630 lib/types: update "string_of_guestcaps"
The "string_of_guestcaps" function is out of date; the following commits
did not update it, when they introduced new fields to the "guestcaps"
record type:

- d295d6e510a4 ("v2v: Extend guestcaps to record drivers for virtio-rng,
  balloon and pvpanic.", 2017-04-06)

- 05f780c16f01 ("v2v: support configuration of viosock driver",
  2021-02-26)

Print those fields now.

Fixes: d295d6e510a4fb251d545c52c0a9d6dccabe6f78
Fixes: 05f780c16f0135c657615520c2245b42de1efc3e
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1942325
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220106140910.13695-3-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2022-01-07 12:20:38 +01:00
Laszlo Ersek
dc69bb6033 lib/types: reformat "string_of_guestcaps"
The printf format string in "string_of_guestcaps" is hard to read, because
it is not indented properly wrt. the rest of the source code. Indent it
properly without changing its behavior.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1942325
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220106140910.13695-2-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2022-01-07 12:20:14 +01:00
Laszlo Ersek
07b12fe99f output_rhv: restrict block status collection to the old RHV output
Nir reports that, despite the comment we removed in commit a2a4f7a09996,
we generally cannot access the output NBD servers in the finalization
stage. In particular, in the "rhv_upload_finalize" function
[output/output_rhv_upload.ml], the output disks are disconnected before
"create_ovf" is called.

Consequently, the "get_disk_allocated" call in the "create_ovf" ->
"add_disks" -> "get_disk_allocated" chain fails.

Rich suggests that we explicitly restrict the "get_disk_allocated" call
with a new optional boolean parameter to the one output plugin that really
needs it, namely the old RHV one.

Accordingly, revert the VDSM test case to its state at (a2a4f7a09996^).

Cc: Nir Soffer <nsoffer@redhat.com>
Fixes: a2a4f7a09996a5e66d027d0d9692e083eb0a8128
Reported-by: Nir Soffer <nsoffer@redhat.com>
Suggested-by: Richard W.M. Jones <rjones@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2034240
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20211220135640.12436-1-lersek@redhat.com>
Tested-by: Nir Soffer <nsoffer@redhat.com>
[lersek@redhat.com: drop parens around condition in "if"; thanks: Rich]
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2021-12-22 10:25:39 +01:00
Richard W.M. Jones
ff84a00fff lib: Make QemuNBD mini-library handle mutable
Similar change to the previous commit.
2021-12-11 17:22:07 +00:00