[Libguestfs] [v2v PATCH v2 1/7] convert/windows_virtio: fix copy_from_libosinfo <-> VIRTIO_WIN priority

Laszlo Ersek lersek at redhat.com
Tue Feb 1 12:32:13 UTC 2022


Commit 258e4b718d5d introduced the "copy_from_libosinfo" branch in
"copy_drivers" with higher priority than the existent
"copy_from_virtio_win".

This introduced a conflict with the documentation ("docs/virt-v2v.pod").
The documentation stated (and still states) that the VIRTIO_WIN env var,
when set, dictates where virt-v2v look for the virtio-win drivers. The
conflict is that, even in case we set VIRTIO_WIN, virt-v2v still consults
libosinfo first.

Skip the "copy_from_libosinfo" branch in case VIRTIO_WIN is set, plus
explain in the documentation that VIRTIO_WIN, when set, overrides
libosinfo.

NOTE: the necessity of this fix is made apparent by the next patch in the
series. Namely, "copy_from_libosinfo" has a bug in the architecture
filter. Once we fix that bug in the next patch, *and* install (e.g.)
"virtio-win-1.9.24-4.el8.noarch" on the conversion host, the "i-ova" test
case will suddenly prefer the virtio drivers exposed via libosinfo, in
spite of the "tests/test-v2v-i-ova.sh" script explicitly setting
VIRTIO_WIN to "test-data/fake-virtio-win". The symptom is that the pvpanic
device will be enabled in the domain XML, due to it being supported by the
actual (not fake) virtio-win drivers.

Fixes: 258e4b718d5d80c79634fe864c8c52b12e41777c
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2043333
Signed-off-by: Laszlo Ersek <lersek at redhat.com>
---

Notes:
    v2:
    - no change

 convert/windows_virtio.ml | 12 ++++++------
 docs/virt-v2v.pod         | 24 +++++++++++++++++-------
 2 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/convert/windows_virtio.ml b/convert/windows_virtio.ml
index 1c5c148e65fd..d21ee6814458 100644
--- a/convert/windows_virtio.ml
+++ b/convert/windows_virtio.ml
@@ -26,20 +26,20 @@ open Regedit
 
 open Types
 open Utils
 
 module G = Guestfs
 
-let virtio_win =
-  try Sys.getenv "VIRTIO_WIN"
+let virtio_win, virtio_win_from_env =
+  try Sys.getenv "VIRTIO_WIN", true
   with Not_found ->
-    try Sys.getenv "VIRTIO_WIN_DIR" (* old name for VIRTIO_WIN *)
+    try Sys.getenv "VIRTIO_WIN_DIR" (* old name for VIRTIO_WIN *), true
     with Not_found ->
       let iso = Config.datadir // "virtio-win" // "virtio-win.iso" in
-      if Sys.file_exists iso then iso
-      else Config.datadir // "virtio-win"
+      (if Sys.file_exists iso then iso
+       else Config.datadir // "virtio-win"), false
 
 let scsi_class_guid = "{4D36E97B-E325-11CE-BFC1-08002BE10318}"
 let viostor_legacy_pciid = "VEN_1AF4&DEV_1001&SUBSYS_00021AF4&REV_00"
 let viostor_modern_pciid = "VEN_1AF4&DEV_1042&SUBSYS_11001AF4&REV_01"
 let vioscsi_legacy_pciid = "VEN_1AF4&DEV_1004&SUBSYS_00081AF4&REV_00"
 let vioscsi_modern_pciid = "VEN_1AF4&DEV_1048&SUBSYS_11001AF4&REV_01"
@@ -225,13 +225,13 @@ and ddb_regedits inspect drv_name drv_pciid =
   ]
 
 (* Copy the matching drivers to the driverdir; return true if any have
  * been copied.
  *)
 and copy_drivers g inspect driverdir =
-  [] <> copy_from_libosinfo g inspect driverdir ||
+  (not virtio_win_from_env && [] <> copy_from_libosinfo g inspect driverdir) ||
     [] <> copy_from_virtio_win g inspect "/" driverdir
       virtio_iso_path_matches_guest_os
       (fun () ->
         error (f_"root directory ‘/’ is missing from the virtio-win directory or ISO.\n\nThis should not happen and may indicate that virtio-win or virt-v2v is broken in some way.  Please report this as a bug with a full debug log."))
 
 and copy_qemu_ga g inspect =
diff --git a/docs/virt-v2v.pod b/docs/virt-v2v.pod
index 3d0e00a354ae..89c47cd3823c 100644
--- a/docs/virt-v2v.pod
+++ b/docs/virt-v2v.pod
@@ -916,13 +916,18 @@ below.
 
  Debian 6+      All versions support virtio
 
  Ubuntu 10.04+  All versions support virtio
 
  Windows        Drivers are installed from the ISO or directory pointed
-                to by "VIRTIO_WIN" environment variable if present
+                to by the "VIRTIO_WIN" environment variable if present.
+                If the "VIRTIO_WIN" environment variable is absent
+                (which is the recommended setting), then libosinfo is
+                consulted first, for driver files that are locally
+                available on the conversion host.
+
 
 =head2 RHEL 4: SELinux relabel appears to hang forever
 
 In RHEL E<le> 4.7 there was a bug which causes SELinux relabelling
 to appear to hang forever at:
 
@@ -1592,29 +1597,34 @@ script in Windows guests.  It is required if you intend to use the
 I<--firstboot> or I<--firstboot-command> options with Windows guests.
 
 =back
 
 =item C<VIRTIO_WIN>
 
-This is where virtio drivers for Windows are searched for.  It can be
-a directory I<or> point to F<virtio-win.iso> (CD ROM image containing
-drivers).
+This is an override for where virtio drivers for Windows are searched
+for.  It can be a directory I<or> point to F<virtio-win.iso> (CD ROM
+image containing drivers).
 
-If unset, then we look for drivers in whichever of these paths
-is found first:
+If unset, then we look for drivers via whichever of these methods
+succeeds first:
 
 =over 4
 
+=item C<osinfo-db>
+
+Load osinfo data from the default paths, and attempt to find drivers via
+libosinfo lookup.  This is the preferred method.
+
 =item F</usr/share/virtio-win/virtio-win.iso>
 
 The ISO containing virtio drivers for Windows.
 
 =item F</usr/share/virtio-win>
 
 The exploded tree of virtio drivers for Windows.  This is
-usually incomplete, hence the ISO is preferred.
+usually incomplete, hence the least preferred method.
 
 =back
 
 See L</Enabling virtio>.
 
 =back
-- 
2.19.1.3.g30247aa5d201






More information about the Libguestfs mailing list