** NOTE: INCOMPLETE! ** We would have to do the same changes to
the firstboot code etc.
---
v2v/convert_windows.ml | 89 +++++++++++++++++++++++++++++---------------------
1 file changed, 51 insertions(+), 38 deletions(-)
diff --git a/v2v/convert_windows.ml b/v2v/convert_windows.ml
index e37c6b8..5a2cf1b 100644
--- a/v2v/convert_windows.ml
+++ b/v2v/convert_windows.ml
@@ -41,6 +41,8 @@ module G = Guestfs
type ('a, 'b) maybe = Either of 'a | Or of 'b
+let re_controlset = Str.regexp "ControlSet[0-9][0-9][0-9]"
+
let convert ~verbose ~keep_serial_console (g : G.guestfs) inspect source =
(* Get the data directory. *)
let virt_tools_data_dir =
@@ -181,38 +183,46 @@ echo uninstalling Xen PV driver
(* Update the SYSTEM hive. When this function is called the hive has
* already been opened as a hivex handle inside guestfs.
*)
- (* Find the 'Current' ControlSet. *)
- let current_cs =
- let select = g#hivex_node_get_child root "Select" in
- let valueh = g#hivex_node_get_value select "Current" in
- let value = int_of_le32 (g#hivex_value_value valueh) in
- sprintf "ControlSet%03Ld" value in
- if verbose then printf "current ControlSet is %s\n%!" current_cs;
+ (* Find all the ControlSetNNNs. Old virt-v2v would only update
+ * the CurrentControlSet, but this version does all of them.
+ *)
+ let control_sets =
+ let nodes = g#hivex_node_children root in
+ let nodes = Array.to_list nodes in
+ List.filter (
+ fun { G.hivex_node_h = nodeh } ->
+ let name = g#hivex_node_name nodeh in
+ Str.string_match re_controlset name 0
+ ) nodes in
- disable_services root current_cs;
- install_virtio_drivers root current_cs
+ disable_services root control_sets;
+ install_virtio_drivers root control_sets
- and disable_services root current_cs =
+ and disable_services root control_sets =
(* Disable miscellaneous services. *)
- let services = get_node root [current_cs; "Services"] in
-
- (* Disable the Processor and Intelppm services
- *
http://blogs.msdn.com/b/virtual_pc_guy/archive/2005/10/24/484461.aspx
- *
- * Disable the rhelscsi service (RHBZ#809273).
- *)
- let disable = [ "Processor"; "Intelppm"; "rhelscsi" ]
in
List.iter (
- fun name ->
- let node = g#hivex_node_get_child services name in
- if node <> 0L then (
- (* Delete the node instead of trying to disable it. RHBZ#737600. *)
- g#hivex_node_delete_child node
+ fun { G.hivex_node_h = control_set_node } ->
+ let services = g#hivex_node_get_child control_set_node "Services" in
+ if services <> 0L then (
+ (* Disable the Processor and Intelppm services
+ *
http://blogs.msdn.com/b/virtual_pc_guy/archive/2005/10/24/484461.aspx
+ *
+ * Disable the rhelscsi service (RHBZ#809273).
+ *)
+ let disable = [ "Processor"; "Intelppm";
"rhelscsi" ] in
+ List.iter (
+ fun name ->
+ let node = g#hivex_node_get_child services name in
+ if node <> 0L then (
+ (* Delete the node instead of trying to disable it. RHBZ#737600. *)
+ g#hivex_node_delete_child node
+ )
+ ) disable
)
- ) disable
+ ) control_sets
- and install_virtio_drivers root current_cs =
+ and install_virtio_drivers root control_sets =
(* Copy the virtio drivers to the guest. *)
let driverdir = sprintf "%s/Drivers/VirtIO" systemroot in
g#mkdir_p driverdir;
@@ -283,7 +293,7 @@ echo uninstalling Xen PV driver
let target = sprintf "%s/system32/drivers/viostor.sys" systemroot in
let target = g#case_sensitive_path target in
g#upload block_path target;
- add_viostor_to_critical_device_database root current_cs;
+ add_viostor_to_critical_device_database root control_sets;
Virtio_blk
) in
@@ -313,29 +323,29 @@ echo uninstalling Xen PV driver
(block, net)
- and add_viostor_to_critical_device_database root current_cs =
+ and add_viostor_to_critical_device_database root control_sets =
(* See
http://rwmj.wordpress.com/2010/04/30/tip-install-a-device-driver-in-a-win...
* NB: All these edits are in the HKLM\SYSTEM hive. No other
* hive may be modified here.
*)
let regedits = [
- [ current_cs; "Control"; "CriticalDeviceDatabase";
"pci#ven_1af4&dev_1001&subsys_00000000" ],
+ [ "Control"; "CriticalDeviceDatabase";
"pci#ven_1af4&dev_1001&subsys_00000000" ],
[ "Service", REG_SZ "viostor";
"ClassGUID", REG_SZ "{4D36E97B-E325-11CE-BFC1-08002BE10318}"
];
- [ current_cs; "Control"; "CriticalDeviceDatabase";
"pci#ven_1af4&dev_1001&subsys_00020000" ],
+ [ "Control"; "CriticalDeviceDatabase";
"pci#ven_1af4&dev_1001&subsys_00020000" ],
[ "Service", REG_SZ "viostor";
"ClassGUID", REG_SZ "{4D36E97B-E325-11CE-BFC1-08002BE10318}"
];
- [ current_cs; "Control"; "CriticalDeviceDatabase";
"pci#ven_1af4&dev_1001&subsys_00021af4" ],
+ [ "Control"; "CriticalDeviceDatabase";
"pci#ven_1af4&dev_1001&subsys_00021af4" ],
[ "Service", REG_SZ "viostor";
"ClassGUID", REG_SZ "{4D36E97B-E325-11CE-BFC1-08002BE10318}"
];
- [ current_cs; "Control"; "CriticalDeviceDatabase";
"pci#ven_1af4&dev_1001&subsys_00021af4&rev_00" ],
+ [ "Control"; "CriticalDeviceDatabase";
"pci#ven_1af4&dev_1001&subsys_00021af4&rev_00" ],
[ "Service", REG_SZ "viostor";
"ClassGUID", REG_SZ "{4D36E97B-E325-11CE-BFC1-08002BE10318}"
];
- [ current_cs; "Services"; "viostor" ],
+ [ "Services"; "viostor" ],
[ "Type", REG_DWORD 0x1_l;
"Start", REG_DWORD 0x0_l;
"Group", REG_SZ "SCSI miniport";
@@ -343,29 +353,32 @@ echo uninstalling Xen PV driver
"ImagePath", REG_EXPAND_SZ "system32\\drivers\\viostor.sys";
"Tag", REG_DWORD 0x21_l ];
- [ current_cs; "Services"; "viostor"; "Parameters" ],
+ [ "Services"; "viostor"; "Parameters" ],
[ "BusType", REG_DWORD 0x1_l ];
- [ current_cs; "Services"; "viostor"; "Parameters";
"MaxTransferSize" ],
+ [ "Services"; "viostor"; "Parameters";
"MaxTransferSize" ],
[ "ParamDesc", REG_SZ "Maximum Transfer Size";
"type", REG_SZ "enum";
"default", REG_SZ "0" ];
- [ current_cs; "Services"; "viostor"; "Parameters";
"MaxTransferSize"; "enum" ],
+ [ "Services"; "viostor"; "Parameters";
"MaxTransferSize"; "enum" ],
[ "0", REG_SZ "64 KB";
"1", REG_SZ "128 KB";
"2", REG_SZ "256 KB" ];
- [ current_cs; "Services"; "viostor"; "Parameters";
"PnpInterface" ],
+ [ "Services"; "viostor"; "Parameters";
"PnpInterface" ],
[ "5", REG_DWORD 0x1_l ];
- [ current_cs; "Services"; "viostor"; "Enum" ],
+ [ "Services"; "viostor"; "Enum" ],
[ "0", REG_SZ
"PCI\\VEN_1AF4&DEV_1001&SUBSYS_00021AF4&REV_00\\3&13c0b0c5&0&20";
"Count", REG_DWORD 0x1_l;
"NextInstance", REG_DWORD 0x1_l ];
] in
- reg_import g root regedits
+ List.iter (
+ fun { G.hivex_node_h = control_set_node } ->
+ reg_import g control_set_node regedits
+ ) control_sets
and update_software_hive root =
(* Update the SOFTWARE hive. When this function is called the
--
2.1.0