Pino Toscano
2019-Mar-26 17:02 UTC
[Libguestfs] [PATCH 0/3] v2v: improve RHV guest tools installation
This series slightly improves the way qemu-ga is installed from the RHV Tools ISO, simplifying the feedback to the user. Patch #3 sort of conflicts with patch #2 of a related series by Tomáš Golembiovský: https://www.redhat.com/archives/libguestfs/2019-February/msg00016.html Pino Toscano (3): v2v: linux: add helper functions for pkg arch and extension v2v: try to pick the right arch for qemu-ga pkgs v2v: change the reporting of RHV Tools messages/warnings/error v2v/linux.ml | 21 +++++++++++++++++++++ v2v/linux.mli | 8 ++++++++ v2v/windows_virtio.ml | 21 ++++++++++++++------- 3 files changed, 43 insertions(+), 7 deletions(-) -- 2.20.1
Pino Toscano
2019-Mar-26 17:02 UTC
[Libguestfs] [PATCH 1/3] v2v: linux: add helper functions for pkg arch and extension
Add helper functions to get the typical extension of binary packages for a package manager, and the string for an architecture. --- v2v/linux.ml | 21 +++++++++++++++++++++ v2v/linux.mli | 8 ++++++++ 2 files changed, 29 insertions(+) diff --git a/v2v/linux.ml b/v2v/linux.ml index 99b0e0e7b..4949c8e16 100644 --- a/v2v/linux.ml +++ b/v2v/linux.ml @@ -179,3 +179,24 @@ let is_package_manager_save_file filename (* Recognized suffixes of package managers. *) let suffixes = [ ".dpkg-old"; ".dpkg-new"; ".rpmsave"; ".rpmnew"; ] in List.exists (Filename.check_suffix filename) suffixes + +let binary_package_extension { i_package_format = package_format } + match package_format with + | "deb" -> "deb" + | "rpm" -> "rpm" + | format -> + error (f_"don’t know what is the extension of binary packages using %s") + format + +let architecture_string { i_package_format = package_format; i_arch = arch; + i_distro = distro } + match package_format, distro, arch with + | "deb", _, "x86_64" -> "amd64" + | "deb", _, a -> a + | "rpm", ("sles"|"suse-based"|"opensuse"), "i386" -> "i586" + | "rpm", ("sles"|"suse-based"|"opensuse"), a -> a + | "rpm", _, "i386" -> "i686" + | "rpm", _, a -> a + | format, distro, arch -> + error (f_"don’t know what is the architecture string of %s using %s on %s") + arch format distro diff --git a/v2v/linux.mli b/v2v/linux.mli index 0a5991d12..30099745c 100644 --- a/v2v/linux.mli +++ b/v2v/linux.mli @@ -38,3 +38,11 @@ val is_file_owned : Guestfs.guestfs -> Types.inspect -> string -> bool val is_package_manager_save_file : string -> bool (** Return true if the filename is something like [*.rpmsave], ie. a package manager save-file. *) + +val binary_package_extension : Types.inspect -> string +(** Return the extension typically used for binary packages in the + specified package format. *) + +val architecture_string : Types.inspect -> string +(** Return the architecture string typically used for binary packages + in the specified package format, and for the specified distro. *) -- 2.20.1
Pino Toscano
2019-Mar-26 17:02 UTC
[Libguestfs] [PATCH 2/3] v2v: try to pick the right arch for qemu-ga pkgs
Right now the code copies, and then tries to install, all the files found for the directory of a distro. This does not take into account differences in the architectures of the packages available, so a x86_64 package must be installed only on x86_64 guests. As solution, filter the packages using the typical suffix used by packages (so architecture + file extension), to pick only packages compatible with the current guest. --- v2v/windows_virtio.ml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/v2v/windows_virtio.ml b/v2v/windows_virtio.ml index 3a3559cb2..d29033a01 100644 --- a/v2v/windows_virtio.ml +++ b/v2v/windows_virtio.ml @@ -203,10 +203,19 @@ and install_linux_tools g inspect | Some os -> let src_path = "linux" // os in let dst_path = "/var/tmp" in + let pkg_arch = Linux.architecture_string inspect in + let pkg_ext = Linux.binary_package_extension inspect in + let package_suffixes = [ + sprintf ".%s.%s" pkg_arch pkg_ext; + sprintf "_%s.%s" pkg_arch pkg_ext; + ] in + let package_filter path _ + List.exists (String.is_suffix path) package_suffixes + in debug "locating packages in %s" src_path; let packages copy_from_virtio_win g inspect src_path dst_path - (fun _ _ -> true) + package_filter (fun () -> warning (f_"guest tools directory ‘%s’ is missing from the virtio-win directory or ISO.\n\nGuest tools are only provided in the RHV Guest Tools ISO, so this can happen if you are using the version of virtio-win which contains just the virtio drivers. In this case only virtio drivers can be installed in the guest, and installation of Guest Tools will be skipped.") src_path) in -- 2.20.1
Pino Toscano
2019-Mar-26 17:02 UTC
[Libguestfs] [PATCH 3/3] v2v: change the reporting of RHV Tools messages/warnings/error
The RHV Tools ISO is provided as Red Hat only product, and thus not available for all the virt-v2v users. Hence, change the way we report the status of the installation of the qemu guest agent from the RHV Tools ISO: - do not warn if virt-v2v does not know how to install the package for the current guest - do not warn if the ISO does not contain packages for the current guest - on successful installations, show an info message Related: RHBZ#1691659 --- v2v/windows_virtio.ml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/v2v/windows_virtio.ml b/v2v/windows_virtio.ml index d29033a01..996216bd7 100644 --- a/v2v/windows_virtio.ml +++ b/v2v/windows_virtio.ml @@ -197,9 +197,7 @@ and install_linux_tools g inspect | _ -> None in match os with - | None -> - warning (f_"don't know how to install guest tools on %s-%d") - inspect.i_distro inspect.i_major_version + | None -> () | Some os -> let src_path = "linux" // os in let dst_path = "/var/tmp" in @@ -216,13 +214,13 @@ and install_linux_tools g inspect let packages copy_from_virtio_win g inspect src_path dst_path package_filter - (fun () -> - warning (f_"guest tools directory ‘%s’ is missing from the virtio-win directory or ISO.\n\nGuest tools are only provided in the RHV Guest Tools ISO, so this can happen if you are using the version of virtio-win which contains just the virtio drivers. In this case only virtio drivers can be installed in the guest, and installation of Guest Tools will be skipped.") - src_path) in + (fun () -> ()) in debug "done copying %d files" (List.length packages); let packages = List.map ((//) dst_path) packages in try Linux.install_local g inspect packages; + if packages <> [] then + info (f_"QEMU Guest Agent installed for this guest."); with G.Error msg -> warning (f_"failed to install QEMU Guest Agent: %s") msg -- 2.20.1
Richard W.M. Jones
2019-Mar-27 10:40 UTC
Re: [Libguestfs] [PATCH 1/3] v2v: linux: add helper functions for pkg arch and extension
On Tue, Mar 26, 2019 at 06:02:40PM +0100, Pino Toscano wrote:> Add helper functions to get the typical extension of binary packages > for a package manager, and the string for an architecture. > --- > v2v/linux.ml | 21 +++++++++++++++++++++ > v2v/linux.mli | 8 ++++++++ > 2 files changed, 29 insertions(+) > > diff --git a/v2v/linux.ml b/v2v/linux.ml > index 99b0e0e7b..4949c8e16 100644 > --- a/v2v/linux.ml > +++ b/v2v/linux.ml > @@ -179,3 +179,24 @@ let is_package_manager_save_file filename > (* Recognized suffixes of package managers. *) > let suffixes = [ ".dpkg-old"; ".dpkg-new"; ".rpmsave"; ".rpmnew"; ] in > List.exists (Filename.check_suffix filename) suffixes > + > +let binary_package_extension { i_package_format = package_format } > + match package_format with > + | "deb" -> "deb" > + | "rpm" -> "rpm" > + | format -> > + error (f_"don’t know what is the extension of binary packages using %s") > + format > + > +let architecture_string { i_package_format = package_format; i_arch = arch; > + i_distro = distro } > + match package_format, distro, arch with > + | "deb", _, "x86_64" -> "amd64" > + | "deb", _, a -> a > + | "rpm", ("sles"|"suse-based"|"opensuse"), "i386" -> "i586" > + | "rpm", ("sles"|"suse-based"|"opensuse"), a -> a > + | "rpm", _, "i386" -> "i686" > + | "rpm", _, a -> a > + | format, distro, arch -> > + error (f_"don’t know what is the architecture string of %s using %s on %s") > + arch format distro > diff --git a/v2v/linux.mli b/v2v/linux.mli > index 0a5991d12..30099745c 100644 > --- a/v2v/linux.mli > +++ b/v2v/linux.mli > @@ -38,3 +38,11 @@ val is_file_owned : Guestfs.guestfs -> Types.inspect -> string -> bool > val is_package_manager_save_file : string -> bool > (** Return true if the filename is something like [*.rpmsave], ie. > a package manager save-file. *) > + > +val binary_package_extension : Types.inspect -> string > +(** Return the extension typically used for binary packages in the > + specified package format. *) > + > +val architecture_string : Types.inspect -> string > +(** Return the architecture string typically used for binary packages > + in the specified package format, and for the specified distro. *) > -- > 2.20.1ACK. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/
Richard W.M. Jones
2019-Mar-27 10:41 UTC
Re: [Libguestfs] [PATCH 2/3] v2v: try to pick the right arch for qemu-ga pkgs
On Tue, Mar 26, 2019 at 06:02:41PM +0100, Pino Toscano wrote:> Right now the code copies, and then tries to install, all the files > found for the directory of a distro. This does not take into account > differences in the architectures of the packages available, so a x86_64 > package must be installed only on x86_64 guests. > > As solution, filter the packages using the typical suffix used by > packages (so architecture + file extension), to pick only packages > compatible with the current guest. > --- > v2v/windows_virtio.ml | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/v2v/windows_virtio.ml b/v2v/windows_virtio.ml > index 3a3559cb2..d29033a01 100644 > --- a/v2v/windows_virtio.ml > +++ b/v2v/windows_virtio.ml > @@ -203,10 +203,19 @@ and install_linux_tools g inspect > | Some os -> > let src_path = "linux" // os in > let dst_path = "/var/tmp" in > + let pkg_arch = Linux.architecture_string inspect in > + let pkg_ext = Linux.binary_package_extension inspect in > + let package_suffixes = [ > + sprintf ".%s.%s" pkg_arch pkg_ext; > + sprintf "_%s.%s" pkg_arch pkg_ext; > + ] in > + let package_filter path _ > + List.exists (String.is_suffix path) package_suffixes > + in > debug "locating packages in %s" src_path; > let packages > copy_from_virtio_win g inspect src_path dst_path > - (fun _ _ -> true) > + package_filter > (fun () -> > warning (f_"guest tools directory ‘%s’ is missing from the virtio-win directory or ISO.\n\nGuest tools are only provided in the RHV Guest Tools ISO, so this can happen if you are using the version of virtio-win which contains just the virtio drivers. In this case only virtio drivers can be installed in the guest, and installation of Guest Tools will be skipped.") > src_path) inMakes sense, ACK. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-builder quickly builds VMs from scratch http://libguestfs.org/virt-builder.1.html
Richard W.M. Jones
2019-Mar-27 10:43 UTC
Re: [Libguestfs] [PATCH 3/3] v2v: change the reporting of RHV Tools messages/warnings/error
On Tue, Mar 26, 2019 at 06:02:42PM +0100, Pino Toscano wrote:> The RHV Tools ISO is provided as Red Hat only product, and thus not > available for all the virt-v2v users. Hence, change the way we report > the status of the installation of the qemu guest agent from the RHV > Tools ISO: > - do not warn if virt-v2v does not know how to install the package for > the current guest > - do not warn if the ISO does not contain packages for the current guest > - on successful installations, show an info message > > Related: RHBZ#1691659 > --- > v2v/windows_virtio.ml | 10 ++++------ > 1 file changed, 4 insertions(+), 6 deletions(-) > > diff --git a/v2v/windows_virtio.ml b/v2v/windows_virtio.ml > index d29033a01..996216bd7 100644 > --- a/v2v/windows_virtio.ml > +++ b/v2v/windows_virtio.ml > @@ -197,9 +197,7 @@ and install_linux_tools g inspect > | _ -> None in > > match os with > - | None -> > - warning (f_"don't know how to install guest tools on %s-%d") > - inspect.i_distro inspect.i_major_version > + | None -> () > | Some os -> > let src_path = "linux" // os in > let dst_path = "/var/tmp" in > @@ -216,13 +214,13 @@ and install_linux_tools g inspect > let packages > copy_from_virtio_win g inspect src_path dst_path > package_filter > - (fun () -> > - warning (f_"guest tools directory ‘%s’ is missing from the virtio-win directory or ISO.\n\nGuest tools are only provided in the RHV Guest Tools ISO, so this can happen if you are using the version of virtio-win which contains just the virtio drivers. In this case only virtio drivers can be installed in the guest, and installation of Guest Tools will be skipped.") > - src_path) in > + (fun () -> ()) in > debug "done copying %d files" (List.length packages); > let packages = List.map ((//) dst_path) packages in > try > Linux.install_local g inspect packages; > + if packages <> [] then > + info (f_"QEMU Guest Agent installed for this guest."); > with G.Error msg -> > warning (f_"failed to install QEMU Guest Agent: %s") msgACK Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v
Tomáš Golembiovský
2019-Mar-27 13:41 UTC
Re: [Libguestfs] [PATCH 0/3] v2v: improve RHV guest tools installation
On Tue, 26 Mar 2019 18:02:39 +0100 Pino Toscano <ptoscano@redhat.com> wrote:> This series slightly improves the way qemu-ga is installed from the > RHV Tools ISO, simplifying the feedback to the user. > > Patch #3 sort of conflicts with patch #2 of a related series by > Tomáš Golembiovský: > https://www.redhat.com/archives/libguestfs/2019-February/msg00016.html > > Pino Toscano (3): > v2v: linux: add helper functions for pkg arch and extension > v2v: try to pick the right arch for qemu-ga pkgs > v2v: change the reporting of RHV Tools messages/warnings/errorAck series -- Tomáš Golembiovský <tgolembi@redhat.com>
Seemingly Similar Threads
- [PATCH 2/3] v2v: try to pick the right arch for qemu-ga pkgs
- [PATCH 2/2] v2v: allow alternative directories for distributions
- [PATCH v4 3/3] v2v: linux: install QEMU-GA (RHBZ#1619665)
- Re: [PATCH 2/2] v2v: allow alternative directories for distributions
- [PATCH 0/3] v2v: improve RHV guest tools installation