|
|
ffd6ed |
From c0af637714a8dfde5739e335810e3e2290be5084 Mon Sep 17 00:00:00 2001
|
|
|
ffd6ed |
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
|
ffd6ed |
Date: Mon, 7 Sep 2015 17:16:24 +0100
|
|
|
ffd6ed |
Subject: [PATCH] v2v: windows: Refactor Xen uninstaller detection code.
|
|
|
ffd6ed |
|
|
|
ffd6ed |
No change, just refactoring.
|
|
|
ffd6ed |
|
|
|
ffd6ed |
(cherry picked from commit 8f889f0c3e65908299d68376b79fbda4fceb2fbe)
|
|
|
ffd6ed |
---
|
|
|
ffd6ed |
v2v/convert_windows.ml | 70 ++++++++++++++++++++++++++------------------------
|
|
|
ffd6ed |
1 file changed, 36 insertions(+), 34 deletions(-)
|
|
|
ffd6ed |
|
|
|
ffd6ed |
diff --git a/v2v/convert_windows.ml b/v2v/convert_windows.ml
|
|
|
ffd6ed |
index a89c908..e3d3a39 100644
|
|
|
ffd6ed |
--- a/v2v/convert_windows.ml
|
|
|
ffd6ed |
+++ b/v2v/convert_windows.ml
|
|
|
ffd6ed |
@@ -103,43 +103,45 @@ let convert ~verbose ~keep_serial_console (g : G.guestfs) inspect source =
|
|
|
ffd6ed |
(*----------------------------------------------------------------------*)
|
|
|
ffd6ed |
(* Inspect the Windows guest. *)
|
|
|
ffd6ed |
|
|
|
ffd6ed |
- let find_xenpv_uninst root =
|
|
|
ffd6ed |
- try
|
|
|
ffd6ed |
- let xenpvreg = "Red Hat Paravirtualized Xen Drivers for Windows(R)" in
|
|
|
ffd6ed |
- let node =
|
|
|
ffd6ed |
- get_node root
|
|
|
ffd6ed |
- ["Microsoft"; "Windows"; "CurrentVersion"; "Uninstall"; xenpvreg] in
|
|
|
ffd6ed |
- let uninstkey = "UninstallString" in
|
|
|
ffd6ed |
- let valueh = g#hivex_node_get_value node uninstkey in
|
|
|
ffd6ed |
- if valueh = 0L then (
|
|
|
ffd6ed |
- warning ~prog (f_"cannot uninstall Xen PV drivers: registry key 'HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s' does not contain an '%s' key")
|
|
|
ffd6ed |
- xenpvreg uninstkey;
|
|
|
ffd6ed |
- raise Not_found
|
|
|
ffd6ed |
- );
|
|
|
ffd6ed |
- let data = g#hivex_value_value valueh in
|
|
|
ffd6ed |
- let data = decode_utf16le ~prog data in
|
|
|
ffd6ed |
-
|
|
|
ffd6ed |
- (* The uninstall program will be uninst.exe. This is a wrapper
|
|
|
ffd6ed |
- * around _uninst.exe which prompts the user. As we don't want
|
|
|
ffd6ed |
- * the user to be prompted, we run _uninst.exe explicitly.
|
|
|
ffd6ed |
- *)
|
|
|
ffd6ed |
- let len = String.length data in
|
|
|
ffd6ed |
- let data =
|
|
|
ffd6ed |
- if len >= 8 &&
|
|
|
ffd6ed |
- String.lowercase (String.sub data (len-8) 8) = "uninst.exe" then
|
|
|
ffd6ed |
- (String.sub data 0 (len-8)) ^ "_uninst.exe"
|
|
|
ffd6ed |
- else
|
|
|
ffd6ed |
- data in
|
|
|
ffd6ed |
-
|
|
|
ffd6ed |
- Some data
|
|
|
ffd6ed |
- with
|
|
|
ffd6ed |
- Not_found -> None
|
|
|
ffd6ed |
- in
|
|
|
ffd6ed |
-
|
|
|
ffd6ed |
(* Open the software hive (readonly) and find the Xen PV uninstaller,
|
|
|
ffd6ed |
* if it exists.
|
|
|
ffd6ed |
*)
|
|
|
ffd6ed |
- let xenpv_uninst = with_hive "software" ~write:false find_xenpv_uninst in
|
|
|
ffd6ed |
+ let xenpv_uninst =
|
|
|
ffd6ed |
+ let xenpvreg = "Red Hat Paravirtualized Xen Drivers for Windows(R)" in
|
|
|
ffd6ed |
+
|
|
|
ffd6ed |
+ let find_xenpv_uninst root =
|
|
|
ffd6ed |
+ try
|
|
|
ffd6ed |
+ let node =
|
|
|
ffd6ed |
+ get_node root
|
|
|
ffd6ed |
+ ["Microsoft"; "Windows"; "CurrentVersion"; "Uninstall";
|
|
|
ffd6ed |
+ xenpvreg] in
|
|
|
ffd6ed |
+ let uninstkey = "UninstallString" in
|
|
|
ffd6ed |
+ let valueh = g#hivex_node_get_value node uninstkey in
|
|
|
ffd6ed |
+ if valueh = 0L then (
|
|
|
ffd6ed |
+ warning ~prog (f_"cannot uninstall Xen PV drivers: registry key 'HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s' does not contain an '%s' key")
|
|
|
ffd6ed |
+ xenpvreg uninstkey;
|
|
|
ffd6ed |
+ raise Not_found
|
|
|
ffd6ed |
+ );
|
|
|
ffd6ed |
+ let data = g#hivex_value_value valueh in
|
|
|
ffd6ed |
+ let data = decode_utf16le ~prog data in
|
|
|
ffd6ed |
+
|
|
|
ffd6ed |
+ (* The uninstall program will be uninst.exe. This is a wrapper
|
|
|
ffd6ed |
+ * around _uninst.exe which prompts the user. As we don't want
|
|
|
ffd6ed |
+ * the user to be prompted, we run _uninst.exe explicitly.
|
|
|
ffd6ed |
+ *)
|
|
|
ffd6ed |
+ let len = String.length data in
|
|
|
ffd6ed |
+ let data =
|
|
|
ffd6ed |
+ if len >= 8 &&
|
|
|
ffd6ed |
+ String.lowercase (String.sub data (len-8) 8) = "uninst.exe" then
|
|
|
ffd6ed |
+ (String.sub data 0 (len-8)) ^ "_uninst.exe"
|
|
|
ffd6ed |
+ else
|
|
|
ffd6ed |
+ data in
|
|
|
ffd6ed |
+
|
|
|
ffd6ed |
+ Some data
|
|
|
ffd6ed |
+ with
|
|
|
ffd6ed |
+ Not_found -> None
|
|
|
ffd6ed |
+ in
|
|
|
ffd6ed |
+ with_hive "software" ~write:false find_xenpv_uninst in
|
|
|
ffd6ed |
|
|
|
ffd6ed |
(*----------------------------------------------------------------------*)
|
|
|
ffd6ed |
(* Perform the conversion of the Windows guest. *)
|
|
|
ffd6ed |
--
|
|
|
ffd6ed |
1.8.3.1
|
|
|
ffd6ed |
|