[Libguestfs] [PATCH 2/2] v2v: windows: uninstall VMware Tools

Pino Toscano ptoscano at redhat.com
Fri Nov 16 12:57:20 UTC 2018


It looks like VMware Tools support their unattended uninstallation even
after the guest is not running anymore on VMware.
---
 v2v/convert_windows.ml | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/v2v/convert_windows.ml b/v2v/convert_windows.ml
index 8740afd1c..2d2b6adfe 100644
--- a/v2v/convert_windows.ml
+++ b/v2v/convert_windows.ml
@@ -192,6 +192,13 @@ let convert (g : G.guestfs) inspect source output rcaps =
       Some "PREVENT_REBOOT=Yes LAUNCHED_BY_SETUP_EXE=Yes" in
     unistallation_commands "Parallels Tools" matchfn extra_uninstall_string in
 
+  (* Locate and retrieve all uninstallation commands for VMware Tools. *)
+  let vmwaretools_uninst =
+    let matchfn s =
+      String.find s "VMware Tools" != -1
+    in
+    unistallation_commands "VMware Tools" matchfn None in
+
   (*----------------------------------------------------------------------*)
   (* Perform the conversion of the Windows guest. *)
 
@@ -277,7 +284,8 @@ let convert (g : G.guestfs) inspect source output rcaps =
       configure_vmdp tool_path;
 
     unconfigure_xenpv ();
-    unconfigure_prltools ()
+    unconfigure_prltools ();
+    unconfigure_vmwaretools ()
 
   (* [set_reg_val_dword_1 path name] creates a registry key
    * called [name = dword:1] in the registry [path].
@@ -430,6 +438,23 @@ if errorlevel 3010 exit /b 0
           "uninstall Parallels tools" fb_script
     ) prltools_uninsts
 
+  and unconfigure_vmwaretools () =
+    List.iter (
+      fun uninst ->
+        let fb_script = "\
+ at echo off
+
+echo uninstalling VMware Tools
+" ^ uninst ^
+(* ERROR_SUCCESS_REBOOT_REQUIRED == 3010 is OK too *)
+"
+if errorlevel 3010 exit /b 0
+" in
+
+        Firstboot.add_firstboot_script g inspect.i_root
+          "uninstall VMware Tools" fb_script
+    ) vmwaretools_uninst
+
   and update_system_hive reg =
     (* Update the SYSTEM hive.  When this function is called the hive has
      * already been opened as a hivex handle inside guestfs.
-- 
2.17.2




More information about the Libguestfs mailing list