Pino Toscano
2018-May-18 15:42 UTC
[Libguestfs] [PATCH] RFC: v2v: use RHV Setup Tools ISO if available
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 + 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
Tomáš Golembiovský
2018-May-23 13:42 UTC
Re: [Libguestfs] [PATCH] RFC: v2v: use RHV Setup Tools ISO if available
On Fri, 18 May 2018 17:42:15 +0200 Pino Toscano <ptoscano@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" inUsing 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@redhat.com > https://www.redhat.com/mailman/listinfo/libguestfs-- Tomáš Golembiovský <tgolembi@redhat.com>
Pino Toscano
2018-May-23 15:19 UTC
Re: [Libguestfs] [PATCH] RFC: v2v: use RHV Setup Tools ISO if available
On Wednesday, 23 May 2018 15:42:42 CEST Tomáš Golembiovský wrote:> On Fri, 18 May 2018 17:42:15 +0200 > Pino Toscano <ptoscano@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`.virt_tools_data_dir () will be /usr/share when --prefix=/usr, although I can hardcode it to /usr/share, since it's where the rhv-guest-tools-iso RPM will install it anyway.> 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?From what I remember, VIRTIO_WIN is usually pointed to the virtio-win.iso, not to the RHV Tools ISO. Am I missing anything? -- Pino Toscano
Apparently Analagous Threads
- Re: [PATCH] RFC: v2v: use RHV Setup Tools ISO if available
- Re: [PATCH] RFC: v2v: use RHV Setup Tools ISO if available
- [PATCH 0/4] v2v: windows: Only try to install rhev-apt if the target is RHV (RHBZ#1161019).
- [PATCH v2 0/2] v2v:windows: prevent conflicts with PnP on firstboot
- [PATCH v3 0/3] SUSE VMDP support