153 lines
6.4 KiB
Diff
153 lines
6.4 KiB
Diff
From 728dab8031b59bb3fd5f8e53786b05df51d35311 Mon Sep 17 00:00:00 2001
|
|
From: Laszlo Ersek <lersek@redhat.com>
|
|
Date: Tue, 1 Feb 2022 13:32:19 +0100
|
|
Subject: [PATCH] convert/convert_windows: consult "best driver"'s dev list for
|
|
virtio-1.0
|
|
|
|
Life would be too simple if we could just call osinfo_os_get_all_devices()
|
|
for determining virtio-1.0 support for Windows guests. Now that we've
|
|
extracted the libosinfo logic that identifies the "best" virtio driver
|
|
(for copying its files into the guest), fetch the list of devices
|
|
supported by the same "best driver" as well. Use that list, in addition to
|
|
the one from osinfo_os_get_all_devices(), for determining (Q35 and)
|
|
virtio-1.0 support.
|
|
|
|
Thankfully this mess is not needed when converting Linux guests.
|
|
|
|
With this, we need to revert the data for three Windows-based test cases
|
|
to their pre-f0cea012d018 status (modulo intermediary commits 4f6b143c1cb3
|
|
("output: -o libvirt, qemu: Use correct device name for vsock",
|
|
2022-01-20) and 4c3d0b8b3b4b ("output: -o libvirt: Fix <graphics/> element
|
|
port/autoport", 2022-01-20)). The reason is that those tests all set the
|
|
VIRTIO_WIN environment variable, in which case we simply assume
|
|
"virtio_1_0 = true" on the fallback ("Not_found" exception) branch.
|
|
|
|
Fixes: f0cea012d0183edf6f7b769c28d5038593f3fe6a
|
|
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2043333
|
|
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
Message-Id: <20220201123219.9317-8-lersek@redhat.com>
|
|
Acked-by: Richard W.M. Jones <rjones@redhat.com>
|
|
(cherry picked from commit cacedec64072609c5203437a378aea2ab9a0e659)
|
|
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
---
|
|
convert/convert_windows.ml | 26 +++++++++++++++++++++++---
|
|
convert/windows_virtio.mli | 6 +++++-
|
|
tests/test-v2v-cdrom.expected | 2 +-
|
|
tests/test-v2v-floppy.expected | 2 +-
|
|
tests/test-v2v-i-ova.xml | 8 ++++----
|
|
5 files changed, 34 insertions(+), 10 deletions(-)
|
|
|
|
diff --git a/convert/convert_windows.ml b/convert/convert_windows.ml
|
|
index 1c2d17f2..7bdcaf52 100644
|
|
--- a/convert/convert_windows.ml
|
|
+++ b/convert/convert_windows.ml
|
|
@@ -242,12 +242,32 @@ let convert (g : G.guestfs) _ inspect _ static_ips =
|
|
match inspect.i_arch with
|
|
| ("i386"|"x86_64") ->
|
|
(try
|
|
+ (* Fall back to the decision that's based on the year that the OS
|
|
+ * was released in under three circumstances:
|
|
+ * - the user specified the location of the Windows virtio drivers
|
|
+ * through an environment variable, or
|
|
+ * - "Libosinfo_utils.get_os_by_short_id" fails to look up the OS,
|
|
+ * or
|
|
+ * - "Libosinfo_utils.best_driver" cannot find any matching driver.
|
|
+ * In each of these cases, a "Not_found" exception is raised. This
|
|
+ * behavior exactly mirrors that of "Windows_virtio.copy_drivers".
|
|
+ *)
|
|
+ if Windows_virtio.virtio_win_from_env then
|
|
+ raise Not_found;
|
|
let os = Libosinfo_utils.get_os_by_short_id inspect.i_osinfo in
|
|
- let devices = os#get_devices () in
|
|
- debug "libosinfo devices for OS \"%s\":\n%s" inspect.i_osinfo
|
|
+ let devices = os#get_devices ()
|
|
+ and drivers = os#get_device_drivers () in
|
|
+ let best_drv_devs =
|
|
+ (Libosinfo_utils.best_driver drivers inspect.i_arch).devices in
|
|
+ debug "libosinfo internal devices for OS \"%s\":\n%s"
|
|
+ inspect.i_osinfo
|
|
(Libosinfo_utils.string_of_osinfo_device_list devices);
|
|
+ debug "libosinfo \"best driver\" devices for OS \"%s\":\n%s"
|
|
+ inspect.i_osinfo
|
|
+ (Libosinfo_utils.string_of_osinfo_device_list best_drv_devs);
|
|
let { Libosinfo_utils.q35; vio10 } =
|
|
- Libosinfo_utils.os_support_of_osinfo_device_list devices in
|
|
+ Libosinfo_utils.os_support_of_osinfo_device_list
|
|
+ (devices @ best_drv_devs) in
|
|
(if q35 then Q35 else I440FX), vio10
|
|
with
|
|
| Not_found ->
|
|
diff --git a/convert/windows_virtio.mli b/convert/windows_virtio.mli
|
|
index 53603d24..a92cc01d 100644
|
|
--- a/convert/windows_virtio.mli
|
|
+++ b/convert/windows_virtio.mli
|
|
@@ -16,7 +16,11 @@
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
*)
|
|
|
|
-(** Functions for installing Windows virtio drivers. *)
|
|
+(** Values and functions for installing Windows virtio drivers. *)
|
|
+
|
|
+val virtio_win_from_env : bool
|
|
+(** [virtio_win_from_env] is true iff at least one of the VIRTIO_WIN and
|
|
+ VIRTIO_WIN_DIR variables is present in the environment. *)
|
|
|
|
val install_drivers
|
|
: Registry.t -> Types.inspect ->
|
|
diff --git a/tests/test-v2v-cdrom.expected b/tests/test-v2v-cdrom.expected
|
|
index b9504929..17bd152d 100644
|
|
--- a/tests/test-v2v-cdrom.expected
|
|
+++ b/tests/test-v2v-cdrom.expected
|
|
@@ -1,4 +1,4 @@
|
|
- <disk type='file' device='disk' model='virtio-transitional'>
|
|
+ <disk type='file' device='disk'>
|
|
<driver name='qemu' type='raw'/>
|
|
<target dev='vda' bus='virtio'/>
|
|
</disk>
|
|
diff --git a/tests/test-v2v-floppy.expected b/tests/test-v2v-floppy.expected
|
|
index f4b67954..a718c21f 100644
|
|
--- a/tests/test-v2v-floppy.expected
|
|
+++ b/tests/test-v2v-floppy.expected
|
|
@@ -1,4 +1,4 @@
|
|
- <disk type='file' device='disk' model='virtio-transitional'>
|
|
+ <disk type='file' device='disk'>
|
|
<driver name='qemu' type='raw'/>
|
|
<target dev='vda' bus='virtio'/>
|
|
</disk>
|
|
diff --git a/tests/test-v2v-i-ova.xml b/tests/test-v2v-i-ova.xml
|
|
index 1915dd40..6b8cda62 100644
|
|
--- a/tests/test-v2v-i-ova.xml
|
|
+++ b/tests/test-v2v-i-ova.xml
|
|
@@ -21,7 +21,7 @@
|
|
<on_reboot>restart</on_reboot>
|
|
<on_crash>restart</on_crash>
|
|
<devices>
|
|
- <disk type='file' device='disk' model='virtio-transitional'>
|
|
+ <disk type='file' device='disk'>
|
|
<driver name='qemu' type='raw'/>
|
|
<source file='TestOva-sda'/>
|
|
<target dev='vda' bus='virtio'/>
|
|
@@ -36,16 +36,16 @@
|
|
</disk>
|
|
<interface type='bridge'>
|
|
<source bridge='VM Network'/>
|
|
- <model type='virtio-transitional'/>
|
|
+ <model type='virtio'/>
|
|
</interface>
|
|
<video>
|
|
<model type='vga' vram='16384' heads='1'/>
|
|
</video>
|
|
<graphics type='vnc' autoport='yes'/>
|
|
- <rng model='virtio-transitional'>
|
|
+ <rng model='virtio'>
|
|
<backend model='random'>/dev/urandom</backend>
|
|
</rng>
|
|
- <memballoon model='virtio-transitional'/>
|
|
+ <memballoon model='virtio'/>
|
|
<input type='tablet' bus='usb'/>
|
|
<input type='mouse' bus='ps2'/>
|
|
<console type='pty'/>
|
|
--
|
|
2.19.1.3.g30247aa5d201
|
|
|