From: Tomáš Golembiovský <tgolembi(a)redhat.com>
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(a)redhat.com>
---
v2v/windows_virtio.ml | 77 ++++++++++++++++++++++++++-----------------
1 file changed, 47 insertions(+), 30 deletions(-)
diff --git a/v2v/windows_virtio.ml b/v2v/windows_virtio.ml
index 0b9bdfff3..59d83c42d 100644
--- a/v2v/windows_virtio.ml
+++ b/v2v/windows_virtio.ml
@@ -204,8 +204,12 @@ and install_linux_tools g inspect =
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
+ let packages =
+ copy_from_virtio_win g inspect src_path dst_path
+ (fun _ _ -> true)
+ (fun () ->
+ warning "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
debug "done copying %d files" (List.length packages);
let packages = List.map ((//) dst_path) packages in
try
@@ -286,36 +290,46 @@ 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
+ (fun () ->
+ error "driver directory ‘%s’ is missing from the virtio-win directory or
ISO.\n\nThis should not happen and may indicate that virtio-win or virt-v2v is broken in
some way. Please report this as a bug with a full debug log."
+ driverdir)
(* 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 [srcdir] is missing from the ISO then [missing ()] is called
+ * which might give a warning or error.
+ *
* 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 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;
+ if not (is_directory srcdir) then missing ()
+ 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
- )
+ 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 +341,24 @@ 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;
+ if not (g2#is_dir srcdir) then missing ()
+ 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
- )
+ 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.0.rc0