Tomáš Golembiovský
2018-Dec-04 21:46 UTC
[Libguestfs] [PATCH] v2v: don't fail when virtio-win does not have qemu-ga packages
It should not be error to use virtio-win ISO that does not have Linux packages of QEMU Guest Agent. Only oVirt/RHV guest tools ISO has such packages now. Regular virtio-win ISO does not have them and maybe never will. Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com> --- v2v/windows_virtio.ml | 88 +++++++++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 33 deletions(-) diff --git a/v2v/windows_virtio.ml b/v2v/windows_virtio.ml index 0b9bdfff3..9972e8c88 100644 --- a/v2v/windows_virtio.ml +++ b/v2v/windows_virtio.ml @@ -205,7 +205,7 @@ and install_linux_tools g inspect 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 + (fun _ _ -> true) true in debug "done copying %d files" (List.length packages); let packages = List.map ((//) dst_path) packages in try @@ -286,36 +286,49 @@ and ddb_regedits inspect drv_name drv_pciid * been copied. *) and copy_drivers g inspect driverdir - [] <> copy_from_virtio_win g inspect "/" driverdir virtio_iso_path_matches_guest_os + [] <> copy_from_virtio_win g inspect "/" driverdir + virtio_iso_path_matches_guest_os false (* 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. * + * If [ok_if_missing] is true only warn when [srcdir] is missing, fail with an + * error if false. + * * Returns list of copied files. *) -and copy_from_virtio_win g inspect srcdir destdir filter +and copy_from_virtio_win g inspect srcdir destdir filter ok_if_missing let ret = ref [] in if is_directory virtio_win then ( 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 dir) in - let paths = external_command cmd in - List.iter ( - fun path -> - 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); - List.push_front target_name ret - ) - ) paths + if not (is_directory srcdir) then ( + let msg = f_"cannot locate directory '%s' in virtio-win directory" in + if ok_if_missing then ( + warning msg srcdir; + ) + else + error msg srcdir + ) else ( + let cmd = sprintf "cd %s && find -L -type f" (quote dir) in + let paths = external_command cmd in + List.iter ( + fun path -> + 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); + List.push_front target_name ret + ) + ) paths + ) ) else if is_regular_file virtio_win then ( debug "windows: copy_from_virtio_win: guest tools source ISO %s" virtio_win; @@ -327,21 +340,30 @@ and copy_from_virtio_win g inspect srcdir destdir filter let vio_root = "/" in g2#mount_ro "/dev/sda" vio_root; let srcdir = vio_root ^ "/" ^ srcdir in - let paths = g2#find srcdir in - Array.iter ( - fun path -> - let source = srcdir ^ "/" ^ path in - if g2#is_file source ~followsymlinks:false && - 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); - List.push_front target_name ret - ) - ) paths; + if not (g2#is_dir srcdir) then ( + let msg = f_"cannot locate directory '%s' in virtio-win ISO" in + if ok_if_missing then + warning msg srcdir + else + error msg srcdir + ) + else ( + let paths = g2#find srcdir in + Array.iter ( + fun path -> + let source = srcdir ^ "/" ^ path in + if g2#is_file source ~followsymlinks:false && + 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); + List.push_front target_name ret + ) + ) paths; + ); g2#close() with Guestfs.Error msg -> error (f_"%s: cannot open virtio-win ISO file: %s") virtio_win msg -- 2.19.1
Nikolay Ivanets
2018-Dec-04 21:50 UTC
Re: [Libguestfs] [PATCH] v2v: don't fail when virtio-win does not have qemu-ga packages
вт, 4 груд. 2018, 23:46 Tomáš Golembiovský користувач tgolembi@redhat.com пише:> Regular virtio-win ISO does not have them and maybe never will. >May I ask why?>
Tomáš Golembiovský
2018-Dec-04 22:03 UTC
Re: [Libguestfs] [PATCH] v2v: don't fail when virtio-win does not have qemu-ga packages
On Tue, 4 Dec 2018 23:50:42 +0200 Nikolay Ivanets <stenavin@gmail.com> wrote:> вт, 4 груд. 2018, 23:46 Tomáš Golembiovský користувач tgolembi@redhat.com > пише: > > > Regular virtio-win ISO does not have them and maybe never will. > > > > May I ask why?Well there's this philosophical question whether the ISO is for Windows guests only or not. Or whether it should contain only drivers. But most importantly, nobody asked for this yet. Opening a BZ against virtio-win by somebody who needs it would be a good start. Tomas -- Tomáš Golembiovský <tgolembi@redhat.com>
Possibly Parallel Threads
- [PATCH] v2v: don't fail when virtio-win does not have qemu-ga packages
- Re: Guestfish command - "copy-out" not working for symbolic links
- Re: Guestfish command - "copy-out" not working for symbolic links
- Re: Guestfish command - "copy-out" not working for symbolic links
- Re: Guestfish command - "copy-out" not working for symbolic links