On Mon, Aug 10, 2015 at 06:55:30PM +0300, Roman Kagan wrote:
Copy the appropriate driver files from the virtio-win storage into
%SYSTEMROOT%\Drivers\VirtIO once they are discovered, and stick to using
those copies later on.
This way the knowledge of where the drivers come from originally is
consolidated in one place, so the lifetime of the associated entities
becomes easier to control (to be implemented in followup patches).
Signed-off-by: Roman Kagan <rkagan(a)virtuozzo.com>
---
v2v/convert_windows.ml | 128 ++++++++++++++++++++++---------------------------
1 file changed, 56 insertions(+), 72 deletions(-)
diff --git a/v2v/convert_windows.ml b/v2v/convert_windows.ml
index 9e83df8..26609f2 100644
--- a/v2v/convert_windows.ml
+++ b/v2v/convert_windows.ml
@@ -231,12 +231,9 @@ echo uninstalling Xen PV driver
with
Not_found -> ()
- and install_virtio_drivers root current_cs =
- (* Copy the virtio drivers to the guest. *)
- let driverdir = sprintf "%s/Drivers/VirtIO" systemroot in
- g#mkdir_p driverdir;
+ and copy_virtio_drivers driverdir =
+ (* Copy the matching drivers to the driverdir. *)
- (* Load the list of drivers available. *)
let drivers = find_virtio_win_drivers virtio_win in
(* Filter out only drivers matching the current guest. *)
@@ -260,73 +257,60 @@ echo uninstalling Xen PV driver
flush stdout
);
- match drivers with
- | [] ->
- warning (f_"there are no virtio drivers available for this version of
Windows (%d.%d %s %s). virt-v2v looks for drivers in %s\n\nThe guest will be configured
to use slower emulated devices.")
- inspect.i_major_version inspect.i_minor_version
- inspect.i_arch inspect.i_product_variant
- virtio_win;
- ( IDE, RTL8139, Cirrus )
-
- | drivers ->
- (* Can we install the block driver? *)
- let block : guestcaps_block_type =
- try
- let viostor_sys_file =
- List.find
- (fun { vwd_filename = filename } -> filename =
"viostor.sys")
- drivers in
- (* Get the actual file contents of the .sys file. *)
- let content = viostor_sys_file.vwd_get_contents () in
- let target = sprintf "%s/system32/drivers/viostor.sys" systemroot
in
- let target = g#case_sensitive_path target in
- g#write target content;
- add_viostor_to_critical_device_database root current_cs;
- Virtio_blk
- with Not_found ->
- warning (f_"there is no viostor (virtio block device) driver for this
version of Windows (%d.%d %s). virt-v2v looks for this driver in %s\n\nThe guest will be
configured to use a slower emulated device.")
- inspect.i_major_version inspect.i_minor_version
- inspect.i_arch virtio_win;
- IDE in
-
- (* Can we install the virtio-net driver? *)
- let net : guestcaps_net_type =
- if not (List.exists
- (fun { vwd_filename = filename } -> filename =
"netkvm.inf")
- drivers) then (
- warning (f_"there is no virtio network driver for this version of
Windows (%d.%d %s). virt-v2v looks for this driver in %s\n\nThe guest will be configured
to use a slower emulated device.")
- inspect.i_major_version inspect.i_minor_version
- inspect.i_arch virtio_win;
- RTL8139
- )
- else
- (* It will be installed at firstboot. *)
- Virtio_net in
-
- (* Can we install the QXL driver? *)
- let video : guestcaps_video_type =
- if not (List.exists
- (fun { vwd_filename = filename } -> filename =
"qxl.inf")
- drivers) then (
- warning (f_"there is no QXL driver for this version of Windows (%d.%d
%s). virt-v2v looks for this driver in %s\n\nThe guest will be configured to use standard
VGA.")
- inspect.i_major_version inspect.i_minor_version
- inspect.i_arch virtio_win;
- Cirrus
- )
- else
- (* It will be installed at firstboot. *)
- QXL in
-
- (* Copy all the drivers to the driverdir. They will be
- * installed at firstboot.
- *)
- List.iter (
- fun driver ->
- let content = driver.vwd_get_contents () in
- g#write (driverdir // driver.vwd_filename) content
- ) drivers;
-
- (block, net, video)
+ List.iter (
+ fun driver ->
+ let content = driver.vwd_get_contents () in
+ g#write (driverdir // driver.vwd_filename) content
+ ) drivers
+
+ and install_virtio_drivers root current_cs =
+ (* Copy the virtio drivers to the guest. *)
+ let driverdir = sprintf "%s/Drivers/VirtIO" systemroot in
+ g#mkdir_p driverdir;
+
+ copy_virtio_drivers driverdir;
+
+ (* Can we install the block driver? *)
+ let block : guestcaps_block_type =
+ let source = driverdir // "viostor.sys" in
+ if (g#exists source) then (
+ let target = sprintf "%s/system32/drivers/viostor.sys" systemroot in
+ let target = g#case_sensitive_path target in
+ g#cp source target;
+ add_viostor_to_critical_device_database root current_cs;
+ Virtio_blk
+ ) else (
+ warning (f_"there is no viostor (virtio block device) driver for this
version of Windows (%d.%d %s). virt-v2v looks for this driver in %s\n\nThe guest will be
configured to use a slower emulated device.")
+ inspect.i_major_version inspect.i_minor_version
+ inspect.i_arch virtio_win;
+ IDE
+ ) in
+
+ (* Can we install the virtio-net driver? *)
+ let net : guestcaps_net_type =
+ if not (g#exists (driverdir // "netkvm.inf")) then (
+ warning (f_"there is no virtio network driver for this version of Windows
(%d.%d %s). virt-v2v looks for this driver in %s\n\nThe guest will be configured to use a
slower emulated device.")
+ inspect.i_major_version inspect.i_minor_version
+ inspect.i_arch virtio_win;
+ RTL8139
+ )
+ else
+ (* It will be installed at firstboot. *)
+ Virtio_net in
+
+ (* Can we install the QXL driver? *)
+ let video : guestcaps_video_type =
+ if not (g#exists (driverdir // "qxl.inf")) then (
+ warning (f_"there is no QXL driver for this version of Windows (%d.%d %s).
virt-v2v looks for this driver in %s\n\nThe guest will be configured to use standard
VGA.")
+ inspect.i_major_version inspect.i_minor_version
+ inspect.i_arch virtio_win;
+ Cirrus
+ )
+ else
+ (* It will be installed at firstboot. *)
+ QXL in
+
+ (block, net, video)
and add_viostor_to_critical_device_database root current_cs =
let { i_major_version = major; i_minor_version = minor;
--
2.4.3
This looks good to me (once I used the 'git diff -w' option to show
the true changes).
So likely ACK.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/