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

Richard W.M. Jones rjones at redhat.com
Fri Nov 16 16:31:29 UTC 2018


On Fri, Nov 16, 2018 at 01:57:20PM +0100, Pino Toscano wrote:
> 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.

ACK

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top




More information about the Libguestfs mailing list