[Libguestfs] [PATCH] RFC: v2v: use RHV Setup Tools ISO if available

Tomáš Golembiovský tgolembi at redhat.com
Wed May 23 13:42:42 UTC 2018


On Fri, 18 May 2018 17:42:15 +0200
Pino Toscano <ptoscano at redhat.com> wrote:

> If the RHV Setup Tools ISO is installed, open it, and copy RHEV APT from
> there, instead of using (if available) the executable located in the
> virt-tools data directory.
> 
> This way, RHV conversion hosts with the RHV Setup Tools ISO installed
> will always install the latest version when convering Windows guests,
> no matter which version is (eventually) shipped as virt-tools.
> ---
>  v2v/convert_windows.ml | 57 ++++++++++++++++++++++++++++++++++++------
>  v2v/virt-v2v.pod       | 18 +++++++++++++
>  2 files changed, 67 insertions(+), 8 deletions(-)
> 
> diff --git a/v2v/convert_windows.ml b/v2v/convert_windows.ml
> index 163319545..21dafe4f4 100644
> --- a/v2v/convert_windows.ml
> +++ b/v2v/convert_windows.ml
> @@ -27,6 +27,10 @@ open Types
>  
>  module G = Guestfs
>  
> +type tool_location =
> +  | Local_path of string (* path of file *)
> +  | ISO of string * string (* path of ISO, path to look for inside the ISO *)
> +
>  (* Convert Windows guests.
>   *
>   * This only does a "pre-conversion", the steps needed to get the
> @@ -239,12 +243,15 @@ let convert (g : G.guestfs) inspect source output rcaps =
>  
>      (* Install RHEV-APT only if appropriate for the output hypervisor. *)
>      if output#install_rhev_apt then (
> -      let tool_path = virt_tools_data_dir () // "rhev-apt.exe" in
> -      if Sys.file_exists tool_path then
> -        configure_rhev_apt tool_path
> -      else
> -        warning (f_"%s is missing, but the output hypervisor is oVirt or RHV.  Installing RHEV-APT in the guest would mean the guest is automatically updated with new drivers etc.  You may wish to install RHEV-APT manually after conversion.")
> -                tool_path
> +      let rhev_apt =
> +        let iso = virt_tools_data_dir () // "rhv-guest-tools-iso" // "rhv-tools-setup.iso" in

Using virt_tools_data_dir seems wrong, if you meant to use the ISO
(actually a symlink) at `/usr/share/rhv-guest-tools-iso/rhv-tools-setup.iso`.

Still, the ISO is rarely used this way in RHV. Most of the time the ISO
is stored somewhere else in storage domain and we pass it's location in
VIRTIO_WIN environment variable.

Could you first check the VIRTIO_WIN variable, and fallback to the ISO
in /usr?

Other than that LGTM.

    Tomas


> +        if is_regular_file iso then
> +          ISO (iso, "/RHEV-Application Provisioning Tool.exe")
> +        else
> +          Local_path (virt_tools_data_dir () // "rhev-apt.exe") in
> +
> +      if copy_rhev_apt rhev_apt then
> +        configure_rhev_apt ()
>      );
>  
>      (* Install VMDP unconditionally, if available, but don't
> @@ -330,12 +337,46 @@ echo Wait for PnP to complete
>      (* add_firstboot_script has created the path already. *)
>      g#upload tool_path (g#case_sensitive_path pnp_wait_path)
>  
> -  and configure_rhev_apt tool_path =
> +  and copy_rhev_apt tool_location =
>      (* Configure RHEV-APT (the RHV guest agent).  However if it doesn't
>       * exist just warn about it and continue.
>       *)
> -    g#upload tool_path "/rhev-apt.exe"; (* XXX *)
> +    let ret = ref false in
> +    let target = "/rhev-apt.exe" (* XXX *) in
> +    (match tool_location with
> +    | Local_path path ->
> +       debug "windows: copy_rhev_apt: source file %s" path;
> +       if Sys.file_exists path then (
> +         g#upload path target;
> +         ret := true
> +       )
> +       else
> +         warning (f_"%s is missing, but the output hypervisor is oVirt or RHV.  Installing RHEV-APT in the guest would mean the guest is automatically updated with new drivers etc.  You may wish to install RHEV-APT manually after conversion.")
> +                 path
> +    | ISO (iso, path) ->
> +       debug "windows: copy_rhev_apt: source ISO %s, path %s" iso path;
> +       try
> +         let g2 = open_guestfs ~identifier:"rhev_apt" () in
> +         g2#add_drive_opts iso ~readonly:true;
> +         g2#launch ();
> +         g2#mount_ro "/dev/sda" "/";
> +         if g2#is_file path ~followsymlinks:true then (
> +           debug "copying rhev-apt: '%s:%s' -> '%s'"
> +                 iso path target;
>  
> +           g#write target (g2#read_file path);
> +           ret := true
> +         )
> +         else
> +           warning (f_"%s is missing in %s, but the output hypervisor is oVirt or RHV.  Installing RHEV-APT in the guest would mean the guest is automatically updated with new drivers etc.  You may wish to install RHEV-APT manually after conversion.")
> +                   path iso;
> +         g2#close()
> +       with Guestfs.Error msg ->
> +         error (f_"%s: cannot open RHEV Tools ISO file: %s") iso msg
> +    );
> +    !ret
> +
> +  and configure_rhev_apt () =
>      let fb_script = "\
>  @echo off
>  
> diff --git a/v2v/virt-v2v.pod b/v2v/virt-v2v.pod
> index 859d68fc5..3d153f1b3 100644
> --- a/v2v/virt-v2v.pod
> +++ b/v2v/virt-v2v.pod
> @@ -2464,6 +2464,20 @@ option at all.  The option was added when virt-v2v was rewritten in 2014.
>  
>  =over 4
>  
> +=item F</usr/share/rhv-guest-tools-iso/rhv-tools-setup.iso>
> +
> +(Optional)
> +
> +If this file is present, then virt-v2v assumes that it is a RHV Tools
> +ISO, containing F</RHEV-Application Provisioning Tool.exe> as the
> +RHV Application Provisioning Tool (RHEV APT).  The RHEV APT will be
> +installed in the Windows guest during conversion.  This tool is a
> +guest agent which ensures that the virtio drivers remain up to date
> +when the guest is running on Red Hat Virtualization (RHV).
> +
> +This ISO comes from Red Hat Virtualization (RHV), and is not
> +distributed with virt-v2v.
> +
>  =item F</usr/share/virtio-win>
>  
>  (Optional)
> @@ -2522,6 +2536,10 @@ conversion.  This tool is a guest agent which ensures that the virtio
>  drivers remain up to date when the guest is running on Red Hat
>  Virtualization (RHV).
>  
> +Note this file is not used if
> +F</usr/share/rhv-guest-tools-iso/rhv-tools-setup.iso> is already
> +present.
> +
>  This file comes from Red Hat Virtualization (RHV), and is not
>  distributed with virt-v2v.
>  
> -- 
> 2.17.0
> 
> _______________________________________________
> Libguestfs mailing list
> Libguestfs at redhat.com
> https://www.redhat.com/mailman/listinfo/libguestfs


-- 
Tomáš Golembiovský <tgolembi at redhat.com>




More information about the Libguestfs mailing list