Tomáš Golembiovský
2018-Nov-07 11:53 UTC
[Libguestfs] [PATCH v3 0/3] Install QEMU-GA from oVirt guest tools ISO on Linux
changes in v3: - fix call to install_local changes in v2: - moved copy_drivers above copy_files - renamed copy_files to copy_from_virtio_win - renamed install to install_local - use rpm instead of yum This installs packages with QEMU Guest Agent when converting Linux machine. The packages should be available on guest tools ISO. The patches work "as-is" but probably deserve some more attention: - it is "abusing" Winows_virtio code but renaming/refactoring everything to remove "windows" from the name and use "guest tools" seems like a lot of unnecesary work - support for Debian is missing I don't know how to install the package only when all it's dependencies are already installed. dpkg cannot be used to check that (simulate the install). And attempting to install the package will leave it half-installed (dpkg cannot roll-back). Tomáš Golembiovský (3): v2v: refactor copy_drivers() in Windows_virtio v2v: linux: install packages v2v: linux: install QEMU-GA (RHBZ#1619665) v2v/convert_linux.ml | 2 ++ v2v/linux.ml | 14 ++++++++ v2v/linux.mli | 3 ++ v2v/windows_virtio.ml | 78 +++++++++++++++++++++++++++++++++--------- v2v/windows_virtio.mli | 4 +++ 5 files changed, 84 insertions(+), 17 deletions(-) -- 2.19.0
Tomáš Golembiovský
2018-Nov-07 11:53 UTC
[Libguestfs] [PATCH v3 1/3] v2v: refactor copy_drivers() in Windows_virtio
Changed the function to be more generic and renamed. The only change in behavior is in produced debug messages. Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com> --- v2v/windows_virtio.ml | 48 ++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/v2v/windows_virtio.ml b/v2v/windows_virtio.ml index 9b45c76f5..da02b6c4e 100644 --- a/v2v/windows_virtio.ml +++ b/v2v/windows_virtio.ml @@ -254,28 +254,41 @@ and ddb_regedits inspect drv_name drv_pciid * been copied. *) and copy_drivers g inspect driverdir - let ret = ref false in + List.length ( + copy_from_virtio_win g inspect "/" driverdir virtio_iso_path_matches_guest_os + ) > 0 + +(* Copy all files from virtio_win directory/ISO located in [srcdir] + * subdirectory and all its subdirectories to the [destdir]. The directory + * hierarchy is not preserved, meaning all files will be directly in [destdir]. + * The file list is filtered based on [filter] function. + * + * Returns list of copied files. + *) +and copy_from_virtio_win g inspect srcdir destdir filter + let ret = ref [] in if is_directory virtio_win then ( - debug "windows: copy_drivers: source directory virtio_win %s" virtio_win; + let dir = virtio_win // srcdir in + debug "windows: copy_from_virtio_win: guest tools source directory %s" dir; - let cmd = sprintf "cd %s && find -L -type f" (quote virtio_win) in + let cmd = sprintf "cd %s && find -L -type f" (quote dir) in let paths = external_command cmd in List.iter ( fun path -> - if virtio_iso_path_matches_guest_os path inspect then ( - let source = virtio_win // path in - let target = driverdir // - String.lowercase_ascii (Filename.basename path) in - debug "copying virtio driver bits: 'host:%s' -> '%s'" + if filter path inspect then ( + let source = dir // path in + let target_name = String.lowercase_ascii (Filename.basename path) in + let target = destdir // target_name in + debug "windows: copying guest tools bits: 'host:%s' -> '%s'" source target; g#write target (read_whole_file source); - ret := true + List.push_front target_name ret ) ) paths ) else if is_regular_file virtio_win then ( - debug "windows: copy_drivers: source ISO virtio_win %s" virtio_win; + debug "windows: copy_from_virtio_win: guest tools source ISO %s" virtio_win; try let g2 = open_guestfs ~identifier:"virtio_win" () in @@ -283,19 +296,20 @@ and copy_drivers g inspect driverdir g2#launch (); let vio_root = "/" in g2#mount_ro "/dev/sda" vio_root; - let paths = g2#find vio_root in + let srcdir = vio_root // srcdir in + let paths = g2#find srcdir in Array.iter ( fun path -> - let source = vio_root // path in + let source = srcdir // path in if g2#is_file source ~followsymlinks:false && - virtio_iso_path_matches_guest_os path inspect then ( - let target = driverdir // - String.lowercase_ascii (Filename.basename path) in - debug "copying virtio driver bits: '%s:%s' -> '%s'" + filter path inspect then ( + let target_name = String.lowercase_ascii (Filename.basename path) in + let target = destdir // target_name in + debug "windows: copying guest tools bits: '%s:%s' -> '%s'" virtio_win path target; g#write target (g2#read_file source); - ret := true + List.push_front target_name ret ) ) paths; g2#close() -- 2.19.0
Tomáš Golembiovský
2018-Nov-07 11:53 UTC
[Libguestfs] [PATCH v3 2/3] v2v: linux: install packages
Install packages from local files without touching network. Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com> --- v2v/linux.ml | 14 ++++++++++++++ v2v/linux.mli | 3 +++ 2 files changed, 17 insertions(+) diff --git a/v2v/linux.ml b/v2v/linux.ml index 177724e39..966170cdd 100644 --- a/v2v/linux.ml +++ b/v2v/linux.ml @@ -31,6 +31,20 @@ let augeas_reload g g#aug_load (); debug_augeas_errors g +let rec install_local g { i_package_format = package_format } packages + if packages <> [] then ( + match package_format with + | "rpm" -> + let cmd = [ "rpm"; "--upgrade"; "-v" ] @ packages in + let cmd = Array.of_list cmd in + ignore (g#command cmd) + | format -> + error (f_"don’t know how to install packages using %s: packages: %s") + format (String.concat " " packages) + (* Reload Augeas in case anything changed. *) + augeas_reload g + ) + let rec remove g inspect packages if packages <> [] then ( do_remove g inspect packages; diff --git a/v2v/linux.mli b/v2v/linux.mli index 1c604665e..80593cebc 100644 --- a/v2v/linux.mli +++ b/v2v/linux.mli @@ -23,6 +23,9 @@ val augeas_reload : Guestfs.guestfs -> unit additional debugging information about parsing problems that augeas found. *) +val install_local: Guestfs.guestfs -> Types.inspect -> string list -> unit +(** Install pacakge(s). *) + val remove : Guestfs.guestfs -> Types.inspect -> string list -> unit (** Uninstall package(s). *) -- 2.19.0
Tomáš Golembiovský
2018-Nov-07 11:53 UTC
[Libguestfs] [PATCH v3 3/3] v2v: linux: install QEMU-GA (RHBZ#1619665)
Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com> --- v2v/convert_linux.ml | 2 ++ v2v/windows_virtio.ml | 30 ++++++++++++++++++++++++++++++ v2v/windows_virtio.mli | 4 ++++ 3 files changed, 36 insertions(+) diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml index e8c64ac1b..a1bafe91a 100644 --- a/v2v/convert_linux.ml +++ b/v2v/convert_linux.ml @@ -81,6 +81,8 @@ let convert (g : G.guestfs) inspect source output rcaps let rec do_convert () augeas_grub_configuration (); + Windows_virtio.install_linux_tools g inspect; + unconfigure_xen (); unconfigure_vbox (); unconfigure_vmware (); diff --git a/v2v/windows_virtio.ml b/v2v/windows_virtio.ml index da02b6c4e..223e7661b 100644 --- a/v2v/windows_virtio.ml +++ b/v2v/windows_virtio.ml @@ -27,6 +27,8 @@ open Regedit open Types open Utils +module G = Guestfs + let virtio_win try Sys.getenv "VIRTIO_WIN" with Not_found -> @@ -181,6 +183,34 @@ let rec install_drivers ((g, _) as reg) inspect rcaps virtio_rng_supported, virtio_ballon_supported, isa_pvpanic_supported) ) +and install_linux_tools g inspect + let os = match inspect.i_distro with + | "fedora" -> Some "fc28" + | "rhel" | "centos" | "scientificlinux" | "redhat-based" + | "oraclelinux" -> (match inspect.i_major_version with + | 6 -> Some "el6" + | 7 -> Some "el7" + | _ -> None) + | "sles" | "suse-based" | "opensuse" -> Some "lp151" + | _ -> 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 + | Some os -> + let src_path = "linux" // os in + let dst_path = "/var/tmp" in + debug "locating packages in %s" src_path; + let packages = copy_from_virtio_win g inspect src_path dst_path + (fun _ _ -> true) in + debug "done copying %d files" (List.length packages); + let packages = List.map ((//) dst_path) packages in + try + Linux.install g inspect packages; + with G.Error msg -> + warning (f_"failed to install QEMU Guest Agent: %s") msg + and add_guestor_to_registry ((g, root) as reg) inspect drv_name drv_pciid let ddb_node = g#hivex_node_get_child root "DriverDatabase" in diff --git a/v2v/windows_virtio.mli b/v2v/windows_virtio.mli index 91b3ced45..fa9997829 100644 --- a/v2v/windows_virtio.mli +++ b/v2v/windows_virtio.mli @@ -40,6 +40,10 @@ val install_drivers virtio devices if we managed to install those, or legacy devices if we didn't. *) +val install_linux_tools : Guestfs.guestfs -> Types.inspect -> unit +(** installs QEMU Guest Agent on Linux guest OS from the driver directory or + driver ISO. It is not fatal if we fail to install the agent. *) + (**/**) (* The following function is only exported for unit tests. *) -- 2.19.0
Pino Toscano
2018-Nov-07 12:32 UTC
Re: [Libguestfs] [PATCH v3 0/3] Install QEMU-GA from oVirt guest tools ISO on Linux
On Wednesday, 7 November 2018 12:53:17 CET Tomáš Golembiovský wrote:> - support for Debian is missing > I don't know how to install the package only when all it's dependencies are > already installed.dpkg -i foo.deb> dpkg cannot be used to check that (simulate the install).dpkg --dry-run (the man page lists also --no-act, and --simulate)> And attempting to install the package will leave it half-installed (dpkg > cannot roll-back).`dpkg -i` performs a complete installation, doing all the steps needed, and leaving the package properly configured if the process is succesfull. -- Pino Toscano
Tomáš Golembiovský
2018-Nov-07 14:01 UTC
Re: [Libguestfs] [PATCH v3 0/3] Install QEMU-GA from oVirt guest tools ISO on Linux
On Wed, 07 Nov 2018 13:32:45 +0100 Pino Toscano <ptoscano@redhat.com> wrote:> On Wednesday, 7 November 2018 12:53:17 CET Tomáš Golembiovský wrote: > > - support for Debian is missing > > I don't know how to install the package only when all it's dependencies are > > already installed. > > dpkg -i foo.debIf it were as easy as this. :)> > > dpkg cannot be used to check that (simulate the install). > > dpkg --dry-run (the man page lists also --no-act, and --simulate)The --dry-run does not seem to do much. It does not verify dependencies. See below.> > > And attempting to install the package will leave it half-installed (dpkg > > cannot roll-back). > > `dpkg -i` performs a complete installation, doing all the steps needed, > and leaving the package properly configured if the process is succesfull.That is assuming everything is OK and the package can be installed. If there are missing dependencies it leaves the package unpacked in the system but in un-configured state. This would have to be fixed after next boot of the guest. See this:> root@8e59267e1b89:/# dpkg -l qemu-guest-agent > dpkg-query: no packages found matching qemu-guest-agent > root@8e59267e1b89:/# dpkg --simulate --refuse-downgrade --skip-same-version --install /var/tmp/qemu-guest-agent_1%3a2.8+dfsg-6+deb9u4_amd64.deb > Selecting previously unselected package qemu-guest-agent. > (Reading database ... 6498 files and directories currently installed.) > Preparing to unpack .../qemu-guest-agent_1%3a2.8+dfsg-6+deb9u4_amd64.deb ... > root@8e59267e1b89:/# echo $? > 0 > root@8e59267e1b89:/# dpkg --refuse-downgrade --skip-same-version --install /var/tmp/qemu-guest-agent_1%3a2.8+dfsg-6+deb9u4_amd64.deb > Selecting previously unselected package qemu-guest-agent. > (Reading database ... 6498 files and directories currently installed.) > Preparing to unpack .../qemu-guest-agent_1%3a2.8+dfsg-6+deb9u4_amd64.deb ... > Unpacking qemu-guest-agent (1:2.8+dfsg-6+deb9u4) ... > dpkg: dependency problems prevent configuration of qemu-guest-agent: > qemu-guest-agent depends on libglib2.0-0 (>= 2.37.1); however: > Package libglib2.0-0 is not installed. > > dpkg: error processing package qemu-guest-agent (--install): > dependency problems - leaving unconfigured > Errors were encountered while processing: > qemu-guest-agent > root@8e59267e1b89:/# dpkg -l qemu-guest-agent > Desired=Unknown/Install/Remove/Purge/Hold > | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend > |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) > ||/ Name Version Architecture Description > +++-===============-============-============-===================================> iU qemu-guest-agen 1:2.8+dfsg-6 amd64 Guest-side qemu-system agent > root@8e59267e1b89:/#Sadly, dpkg cannot even roll-back in case of errors. So far I haven't found any way to check dependencies in advance. Tomas> > -- > Pino Toscano-- Tomáš Golembiovský <tgolembi@redhat.com>
Richard W.M. Jones
2018-Nov-07 15:31 UTC
Re: [Libguestfs] [PATCH v3 0/3] Install QEMU-GA from oVirt guest tools ISO on Linux
On Wed, Nov 07, 2018 at 12:53:17PM +0100, Tomáš Golembiovský wrote:> changes in v3: > - fix call to install_local > > changes in v2: > - moved copy_drivers above copy_files > - renamed copy_files to copy_from_virtio_win > - renamed install to install_local > - use rpm instead of yum > > This installs packages with QEMU Guest Agent when converting Linux machine. The > packages should be available on guest tools ISO. The patches work "as-is" but > probably deserve some more attention: > > - it is "abusing" Winows_virtio code but renaming/refactoring everything to > remove "windows" from the name and use "guest tools" seems like a lot of > unnecesary workI didn't mean the comment to mean it was abusing Windows_virtio. It was just a surprise since at the moment Convert_windows is the only consumer of the Windows_virtio code. However the change is still correct so this doesn't matter, and maybe we can rename the module in future.> - support for Debian is missing > I don't know how to install the package only when all it's dependencies are > already installed. dpkg cannot be used to check that (simulate the install). > And attempting to install the package will leave it half-installed (dpkg > cannot roll-back).Will we actually have Debian packages on the ISO? BTW do we actually have an example of the new ISO or virtio-win.rpm I can test against? Rich.> Tomáš Golembiovský (3): > v2v: refactor copy_drivers() in Windows_virtio > v2v: linux: install packages > v2v: linux: install QEMU-GA (RHBZ#1619665) > > v2v/convert_linux.ml | 2 ++ > v2v/linux.ml | 14 ++++++++ > v2v/linux.mli | 3 ++ > v2v/windows_virtio.ml | 78 +++++++++++++++++++++++++++++++++--------- > v2v/windows_virtio.mli | 4 +++ > 5 files changed, 84 insertions(+), 17 deletions(-) > > -- > 2.19.0 > > _______________________________________________ > Libguestfs mailing list > Libguestfs@redhat.com > https://www.redhat.com/mailman/listinfo/libguestfs-- 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
Richard W.M. Jones
2018-Nov-07 15:43 UTC
Re: [Libguestfs] [PATCH v3 1/3] v2v: refactor copy_drivers() in Windows_virtio
On Wed, Nov 07, 2018 at 12:53:18PM +0100, Tomáš Golembiovský wrote:> Changed the function to be more generic and renamed. > The only change in behavior is in produced debug messages. > > Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com> > --- > v2v/windows_virtio.ml | 48 ++++++++++++++++++++++++++++--------------- > 1 file changed, 31 insertions(+), 17 deletions(-) > > diff --git a/v2v/windows_virtio.ml b/v2v/windows_virtio.ml > index 9b45c76f5..da02b6c4e 100644 > --- a/v2v/windows_virtio.ml > +++ b/v2v/windows_virtio.ml > @@ -254,28 +254,41 @@ and ddb_regedits inspect drv_name drv_pciid > * been copied. > *) > and copy_drivers g inspect driverdir > - let ret = ref false in > + List.length ( > + copy_from_virtio_win g inspect "/" driverdir virtio_iso_path_matches_guest_os > + ) > 0You can write this as: [] <> copy_from_virtio_win g [etc...] which is also more efficient because the compiler will optimize it to a single test that the function doesn't return a cons.> +(* Copy all files from virtio_win directory/ISO located in [srcdir] > + * subdirectory and all its subdirectories to the [destdir]. The directory > + * hierarchy is not preserved, meaning all files will be directly in [destdir]. > + * The file list is filtered based on [filter] function. > + * > + * Returns list of copied files. > + *) > +and copy_from_virtio_win g inspect srcdir destdir filter > + let ret = ref [] in > if is_directory virtio_win then ( > - debug "windows: copy_drivers: source directory virtio_win %s" virtio_win; > + let dir = virtio_win // srcdir in > + debug "windows: copy_from_virtio_win: guest tools source directory %s" dir; > > - let cmd = sprintf "cd %s && find -L -type f" (quote virtio_win) in > + let cmd = sprintf "cd %s && find -L -type f" (quote dir) in > let paths = external_command cmd in > List.iter ( > fun path -> > - if virtio_iso_path_matches_guest_os path inspect then ( > - let source = virtio_win // path in > - let target = driverdir // > - String.lowercase_ascii (Filename.basename path) in > - debug "copying virtio driver bits: 'host:%s' -> '%s'" > + if filter path inspect then ( > + let source = dir // path in > + let target_name = String.lowercase_ascii (Filename.basename path) in > + let target = destdir // target_name in > + debug "windows: copying guest tools bits: 'host:%s' -> '%s'" > source target; > > g#write target (read_whole_file source); > - ret := true > + List.push_front target_name retThis will return the list of files backwards (if that matters), but is also more efficient than using push_back.> ) > ) paths > ) > else if is_regular_file virtio_win then ( > - debug "windows: copy_drivers: source ISO virtio_win %s" virtio_win; > + debug "windows: copy_from_virtio_win: guest tools source ISO %s" virtio_win; > > try > let g2 = open_guestfs ~identifier:"virtio_win" () in > @@ -283,19 +296,20 @@ and copy_drivers g inspect driverdir > g2#launch (); > let vio_root = "/" in > g2#mount_ro "/dev/sda" vio_root; > - let paths = g2#find vio_root in > + let srcdir = vio_root // srcdir inIt doesn't really matter since virt-v2v only ever runs on Linux, but strictly speaking this is wrong. It should be: let srcdir = vio_root ^ "/" ^ srcdir in (But using // in the previous part of the code *was* correct). The reason is that this path is evaluated in the libguestfs appliance name space, whereas operation // uses host path concatenation (would be \ on Windows host for example).> + let paths = g2#find srcdir in > Array.iter ( > fun path -> > - let source = vio_root // path in > + let source = srcdir // path inSame here, except the old code was wrong too :-)> if g2#is_file source ~followsymlinks:false && > - virtio_iso_path_matches_guest_os path inspect then ( > - let target = driverdir // > - String.lowercase_ascii (Filename.basename path) in > - debug "copying virtio driver bits: '%s:%s' -> '%s'" > + filter path inspect then ( > + let target_name = String.lowercase_ascii (Filename.basename path) in > + let target = destdir // target_name inAnd this is wrong too (and in the old code).> + debug "windows: copying guest tools bits: '%s:%s' -> '%s'" > virtio_win path target; > > g#write target (g2#read_file source); > - ret := true > + List.push_front target_name ret > ) > ) paths; > g2#close() > --Generally looks fine. 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
2018-Nov-07 15:43 UTC
Re: [Libguestfs] [PATCH v3 2/3] v2v: linux: install packages
On Wed, Nov 07, 2018 at 12:53:19PM +0100, Tomáš Golembiovský wrote:> Install packages from local files without touching network. > > Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com> > --- > v2v/linux.ml | 14 ++++++++++++++ > v2v/linux.mli | 3 +++ > 2 files changed, 17 insertions(+) > > diff --git a/v2v/linux.ml b/v2v/linux.ml > index 177724e39..966170cdd 100644 > --- a/v2v/linux.ml > +++ b/v2v/linux.ml > @@ -31,6 +31,20 @@ let augeas_reload g > g#aug_load (); > debug_augeas_errors g > > +let rec install_local g { i_package_format = package_format } packages > + if packages <> [] then ( > + match package_format with > + | "rpm" -> > + let cmd = [ "rpm"; "--upgrade"; "-v" ] @ packages in > + let cmd = Array.of_list cmd in > + ignore (g#command cmd) > + | format -> > + error (f_"don’t know how to install packages using %s: packages: %s") > + format (String.concat " " packages) > + (* Reload Augeas in case anything changed. *) > + augeas_reload g > + ) > + > let rec remove g inspect packages > if packages <> [] then ( > do_remove g inspect packages; > diff --git a/v2v/linux.mli b/v2v/linux.mli > index 1c604665e..80593cebc 100644 > --- a/v2v/linux.mli > +++ b/v2v/linux.mli > @@ -23,6 +23,9 @@ val augeas_reload : Guestfs.guestfs -> unit > additional debugging information about parsing problems > that augeas found. *) > > +val install_local: Guestfs.guestfs -> Types.inspect -> string list -> unit > +(** Install pacakge(s). *) > + > val remove : Guestfs.guestfs -> Types.inspect -> string list -> unit > (** Uninstall package(s). *)This is fine now, assuming we don't want to add dpkg support. 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
Richard W.M. Jones
2018-Nov-07 15:46 UTC
Re: [Libguestfs] [PATCH v3 3/3] v2v: linux: install QEMU-GA (RHBZ#1619665)
On Wed, Nov 07, 2018 at 12:53:20PM +0100, Tomáš Golembiovský wrote:> Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com> > --- > v2v/convert_linux.ml | 2 ++ > v2v/windows_virtio.ml | 30 ++++++++++++++++++++++++++++++ > v2v/windows_virtio.mli | 4 ++++ > 3 files changed, 36 insertions(+) > > diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml > index e8c64ac1b..a1bafe91a 100644 > --- a/v2v/convert_linux.ml > +++ b/v2v/convert_linux.ml > @@ -81,6 +81,8 @@ let convert (g : G.guestfs) inspect source output rcaps > let rec do_convert () > augeas_grub_configuration (); > > + Windows_virtio.install_linux_tools g inspect; > + > unconfigure_xen (); > unconfigure_vbox (); > unconfigure_vmware (); > diff --git a/v2v/windows_virtio.ml b/v2v/windows_virtio.ml > index da02b6c4e..223e7661b 100644 > --- a/v2v/windows_virtio.ml > +++ b/v2v/windows_virtio.ml > @@ -27,6 +27,8 @@ open Regedit > open Types > open Utils > > +module G = Guestfs > + > let virtio_win > try Sys.getenv "VIRTIO_WIN" > with Not_found -> > @@ -181,6 +183,34 @@ let rec install_drivers ((g, _) as reg) inspect rcaps > virtio_rng_supported, virtio_ballon_supported, isa_pvpanic_supported) > ) > > +and install_linux_tools g inspect > + let os = match inspect.i_distro with > + | "fedora" -> Some "fc28" > + | "rhel" | "centos" | "scientificlinux" | "redhat-based" > + | "oraclelinux" -> (match inspect.i_major_version with > + | 6 -> Some "el6" > + | 7 -> Some "el7" > + | _ -> None) > + | "sles" | "suse-based" | "opensuse" -> Some "lp151" > + | _ -> 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 > + | Some os -> > + let src_path = "linux" // os in > + let dst_path = "/var/tmp" in > + debug "locating packages in %s" src_path; > + let packages = copy_from_virtio_win g inspect src_path dst_path > + (fun _ _ -> true) in > + debug "done copying %d files" (List.length packages); > + let packages = List.map ((//) dst_path) packages in > + try > + Linux.install g inspect packages; > + with G.Error msg -> > + warning (f_"failed to install QEMU Guest Agent: %s") msgSo this was going to be my question about this. Here we've decided to effectively ignore failure to install qemu-ga. Should it be an error? What's the chance that for a supported guest it might fail? Do the packages have complex dependencies? The patch in general looks OK. Rich.> and add_guestor_to_registry ((g, root) as reg) inspect drv_name drv_pciid > let ddb_node = g#hivex_node_get_child root "DriverDatabase" in > > diff --git a/v2v/windows_virtio.mli b/v2v/windows_virtio.mli > index 91b3ced45..fa9997829 100644 > --- a/v2v/windows_virtio.mli > +++ b/v2v/windows_virtio.mli > @@ -40,6 +40,10 @@ val install_drivers > virtio devices if we managed to install those, or legacy devices > if we didn't. *) > > +val install_linux_tools : Guestfs.guestfs -> Types.inspect -> unit > +(** installs QEMU Guest Agent on Linux guest OS from the driver directory or > + driver ISO. It is not fatal if we fail to install the agent. *) > + > (**/**) > > (* The following function is only exported for unit tests. *) > -- > 2.19.0 > > _______________________________________________ > Libguestfs mailing list > Libguestfs@redhat.com > https://www.redhat.com/mailman/listinfo/libguestfs-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW
Tomáš Golembiovský
2018-Nov-07 16:32 UTC
Re: [Libguestfs] [PATCH v3 0/3] Install QEMU-GA from oVirt guest tools ISO on Linux
On Wed, 7 Nov 2018 15:31:56 +0000 "Richard W.M. Jones" <rjones@redhat.com> wrote:> On Wed, Nov 07, 2018 at 12:53:17PM +0100, Tomáš Golembiovský wrote: > > changes in v3: > > - fix call to install_local > > > > changes in v2: > > - moved copy_drivers above copy_files > > - renamed copy_files to copy_from_virtio_win > > - renamed install to install_local > > - use rpm instead of yum > > > > This installs packages with QEMU Guest Agent when converting Linux machine. The > > packages should be available on guest tools ISO. The patches work "as-is" but > > probably deserve some more attention: > > > > - it is "abusing" Winows_virtio code but renaming/refactoring everything to > > remove "windows" from the name and use "guest tools" seems like a lot of > > unnecesary work > > I didn't mean the comment to mean it was abusing Windows_virtio. It > was just a surprise since at the moment Convert_windows is the only > consumer of the Windows_virtio code. However the change is still > correct so this doesn't matter, and maybe we can rename the module in > future.This was in cover letter before your comment. :)> > > - support for Debian is missing > > I don't know how to install the package only when all it's dependencies are > > already installed. dpkg cannot be used to check that (simulate the install). > > And attempting to install the package will leave it half-installed (dpkg > > cannot roll-back). > > Will we actually have Debian packages on the ISO?Yes.> > BTW do we actually have an example of the new ISO or virtio-win.rpm I > can test against?I am not sure if we have ISO for oVirt already. Let me check. Tomas> > Rich. > > > Tomáš Golembiovský (3): > > v2v: refactor copy_drivers() in Windows_virtio > > v2v: linux: install packages > > v2v: linux: install QEMU-GA (RHBZ#1619665) > > > > v2v/convert_linux.ml | 2 ++ > > v2v/linux.ml | 14 ++++++++ > > v2v/linux.mli | 3 ++ > > v2v/windows_virtio.ml | 78 +++++++++++++++++++++++++++++++++--------- > > v2v/windows_virtio.mli | 4 +++ > > 5 files changed, 84 insertions(+), 17 deletions(-) > > > > -- > > 2.19.0 > > > > _______________________________________________ > > Libguestfs mailing list > > Libguestfs@redhat.com > > https://www.redhat.com/mailman/listinfo/libguestfs > > -- > 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-- Tomáš Golembiovský <tgolembi@redhat.com>
Apparently Analagous Threads
- [PATCH v3 1/3] v2v: refactor copy_drivers() in Windows_virtio
- [PATCH v4 1/3] v2v: refactor copy_drivers() in Windows_virtio
- [PATCH v5 0/3] Install QEMU-GA from oVirt guest tools ISO on Linux
- [PATCH v3] v2v: don't fail when virtio-win does not have qemu-ga
- [PATCH v2 0/3] Install QEMU-GA from oVirt guest tools ISO on Linux