This function is needed for other drivers, move the code in order to
help sharing it later.
---
v2v/windows_virtio.ml | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/v2v/windows_virtio.ml b/v2v/windows_virtio.ml
index b0d9d08..14ffc51 100644
--- a/v2v/windows_virtio.ml
+++ b/v2v/windows_virtio.ml
@@ -226,18 +226,7 @@ and add_viostor_to_driver_database g root arch current_cs driverdir
=
*)
let controller_path =
[ current_cs; "Control"; "Class"; scsi_adapter_guid ] in
- let controller_offset =
- match Windows.get_node g root controller_path with
- | None ->
- error (f_"cannot find HKLM\\SYSTEM\\%s in the guest registry")
- (String.concat "\\" controller_path)
- | Some node ->
- let rec loop node i =
- let controller_offset = sprintf "%04d" i in
- let child = g#hivex_node_get_child node controller_offset in
- if child = 0_L then controller_offset else loop node (i+1)
- in
- loop node 0 in
+ let controller_offset = get_controller_offset g root controller_path in
let regedits = [
controller_path @ [ controller_offset ],
@@ -400,6 +389,19 @@ and set_free_oem_inf g root guid driver_inf driverdir =
g#cp (driverdir // driver_inf) ("/Windows/Inf/" ^ oem_inf);
oem_inf
+and get_controller_offset g root controller_path =
+ match Windows.get_node g root controller_path with
+ | None ->
+ error (f_"cannot find HKLM\\SYSTEM\\%s in the guest registry")
+ (String.concat "\\" controller_path)
+ | Some node ->
+ let rec loop node i =
+ let controller_offset = sprintf "%04d" i in
+ let child = g#hivex_node_get_child node controller_offset in
+ if child = 0_L then controller_offset else loop node (i+1)
+ in
+ loop node 0
+
(* Copy the matching drivers to the driverdir; return true if any have
* been copied.
*)
--
2.6.2