It seems that checking for oem%d.inf in the DeviceIds registry entry
doesn't always list all oemXX.inf files. For example we may have
oem1.inf free in the registry key, but used in another one.
Also extract this into a separate function for later use to setup
another driver.
---
v2v/windows_virtio.ml | 52 ++++++++++++++++++++++++++-------------------------
1 file changed, 27 insertions(+), 25 deletions(-)
diff --git a/v2v/windows_virtio.ml b/v2v/windows_virtio.ml
index f538b36..b0d9d08 100644
--- a/v2v/windows_virtio.ml
+++ b/v2v/windows_virtio.ml
@@ -82,7 +82,7 @@ let rec install_drivers g inspect systemroot root current_cs rcaps =
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_registry g inspect root current_cs;
+ add_viostor_to_registry g inspect root current_cs driverdir;
Virtio_blk
| Some IDE, _ ->
@@ -133,11 +133,11 @@ let rec install_drivers g inspect systemroot root current_cs rcaps
=
(block, net, video)
)
-and add_viostor_to_registry g inspect root current_cs =
+and add_viostor_to_registry g inspect root current_cs driverdir =
let { i_major_version = major; i_minor_version = minor;
i_arch = arch } = inspect in
if (major == 6 && minor >= 2) || major >= 7 then (* Windows >= 8 *)
- add_viostor_to_driver_database g root arch current_cs
+ add_viostor_to_driver_database g root arch current_cs driverdir
else (* Windows <= 7 *)
add_viostor_to_critical_device_database g root current_cs
@@ -195,7 +195,7 @@ and add_viostor_to_critical_device_database g root current_cs =
reg_import g root regedits
-and add_viostor_to_driver_database g root arch current_cs =
+and add_viostor_to_driver_database g root arch current_cs driverdir =
(* Windows >= 8 doesn't use the CriticalDeviceDatabase. Instead
* one must add keys into the DriverDatabase.
*)
@@ -213,27 +213,7 @@ and add_viostor_to_driver_database g root arch current_cs =
sprintf "viostor.inf_%s_%s" arch "c86329aaeb0a7904" in
let scsi_adapter_guid = "{4d36e97b-e325-11ce-bfc1-08002be10318}" in
- (* There should be a key
- * HKLM\SYSTEM\DriverDatabase\DeviceIds\<scsi_adapter_guid>
- * We want to add:
- * "oem1.inf"=hex(0):
- * but if we find "oem1.inf" we'll add "oem2.inf" (etc).
- *)
- let oem_inf =
- let path = [ "DriverDatabase"; "DeviceIds"; scsi_adapter_guid ]
in
- match Windows.get_node g root path with
- | None ->
- error (f_"cannot find HKLM\\SYSTEM\\DriverDatabase\\DeviceIds\\%s in the
guest registry") scsi_adapter_guid
- | Some node ->
- let rec loop node i =
- let oem_inf = sprintf "oem%d.inf" i in
- let value = g#hivex_node_get_value node oem_inf in
- if value = 0_L then oem_inf else loop node (i+1)
- in
- let oem_inf = loop node 1 in
- (* Create the key. *)
- g#hivex_node_set_value node oem_inf (* REG_NONE *) 0_L "";
- oem_inf in
+ let oem_inf = set_free_oem_inf g root scsi_adapter_guid "viostor.inf"
driverdir in
(* There should be a key
* HKLM\SYSTEM\ControlSet001\Control\Class\<scsi_adapter_guid>
@@ -398,6 +378,28 @@ and add_viostor_to_driver_database g root arch current_cs =
@=hex(ffff0012):6f,00,65,00,6d,00,31,00,2e,00,69,00,6e,00,66,00,00,00
*)
+(* There should be a key
+ * HKLM\SYSTEM\DriverDatabase\DeviceIds\<guid>
+ * We want to add:
+ * "oem1.inf"=hex(0):
+ * but if we find "oem1.inf" we'll add "oem2.inf" (etc).
+ *)
+and set_free_oem_inf g root guid driver_inf driverdir =
+ let path = [ "DriverDatabase"; "DeviceIds"; guid ] in
+ match Windows.get_node g root path with
+ | None ->
+ error (f_"cannot find HKLM\\SYSTEM\\DriverDatabase\\DeviceIds\\%s in the guest
registry") guid
+ | Some node ->
+ let rec loop i =
+ let oem_inf = sprintf "oem%d.inf" i in
+ if not (g#exists ("/Windows/Inf/" ^ oem_inf)) then oem_inf else loop
(i+1)
+ in
+ let oem_inf = loop 1 in
+ (* Create the key. *)
+ g#hivex_node_set_value node oem_inf (* REG_NONE *) 0_L "";
+ g#cp (driverdir // driver_inf) ("/Windows/Inf/" ^ oem_inf);
+ oem_inf
+
(* Copy the matching drivers to the driverdir; return true if any have
* been copied.
*)
--
2.6.2