<div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr">Il giorno sab 26 gen 2019, 13:20 Tomáš Golembiovský <<a href="mailto:tgolembi@redhat.com">tgolembi@redhat.com</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Allow multiple alternative directory names for distributions (or<br>
distribution familiy) when installing Linux guest tools packages.<br>
Original naming required that there is a separate directory for every<br>
version of a distribution (e.g. fc28, fc29, ...). This is inconvenient<br>
when users want to keep just a single version of the package for the<br>
distribution.<br>
<br>
For each distribution one can have either a common directory (e.g.<br>
fedora) or a versioned directory (fedora28). This can also be combined.<br>
I.e. one can have both `fedora` and `fedora28` in which case `fedora28`<br>
will be used when converting Fedora 28 guest wheres `fedora` will be<br>
used when converting guests with any other Fedora version.<br>
<br>
To have better names for unversioned directories the original names<br>
were changed this way:<br>
<br>
    fc -> fedora<br>
    el -> rhel<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto">this will cut centos off</div><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
    lp -> suse<br>
<br>
The original directory names are kept for backward compatibility and are<br>
aliased to new names as described below. When both new and old name are<br>
present on file system the new name takes precedence.<br>
<br>
    fc28 -> fedora<br>
    el6 -> rhel6<br>
    el7 -> rhel7<br>
    lp151 -> suse<br>
<br>
Signed-off-by: Tomáš Golembiovský <<a href="mailto:tgolembi@redhat.com" target="_blank" rel="noreferrer">tgolembi@redhat.com</a>><br>
---<br>
 v2v/<a href="http://windows_virtio.ml" rel="noreferrer noreferrer" target="_blank">windows_virtio.ml</a> | 65 +++++++++++++++++++++++++------------------<br>
 1 file changed, 38 insertions(+), 27 deletions(-)<br>
<br>
diff --git a/v2v/<a href="http://windows_virtio.ml" rel="noreferrer noreferrer" target="_blank">windows_virtio.ml</a> b/v2v/<a href="http://windows_virtio.ml" rel="noreferrer noreferrer" target="_blank">windows_virtio.ml</a><br>
index 94c4774b7..cc33d9502 100644<br>
--- a/v2v/<a href="http://windows_virtio.ml" rel="noreferrer noreferrer" target="_blank">windows_virtio.ml</a><br>
+++ b/v2v/<a href="http://windows_virtio.ml" rel="noreferrer noreferrer" target="_blank">windows_virtio.ml</a><br>
@@ -186,14 +186,18 @@ let rec install_drivers ((g, _) as reg) inspect rcaps =<br>
 and install_linux_tools g inspect =<br>
   let os =<br>
     match inspect.i_distro with<br>
-    | "fedora" -> Some "fc28"<br>
+    | "fedora" -> Some [<br>
+      (sprintf "fedora%d" inspect.i_major_version); "fedora"; "fc28"]<br>
     | "rhel" | "centos" | "scientificlinux" | "redhat-based"<br>
-    | "oraclelinux" -><br>
-      (match inspect.i_major_version with<br>
-       | 6 -> Some "el6"<br>
-       | 7 -> Some "el7"<br>
-       | _ -> None)<br>
-    | "sles" | "suse-based" | "opensuse" -> Some "lp151"<br>
+    | "oraclelinux" -> Some (<br>
+      [(sprintf "rhel%d" inspect.i_major_version)]<br>
+      @ (match inspect.i_major_version with<br>
+       | 6 -> ["el6"]<br>
+       | 7 -> ["el7"]<br>
+       | _ -> [])<br>
+      @ ["rhel"])<br>
+    | "sles" | "suse-based" | "opensuse" -> Some [<br>
+      (sprintf "fedora%d" inspect.i_major_version); "suse"; "lp151"]<br>
     | _ -> None in<br>
<br>
   match os with<br>
@@ -201,15 +205,15 @@ and install_linux_tools g inspect =<br>
       warning (f_"don't know how to install guest tools on %s-%d")<br>
         inspect.i_distro inspect.i_major_version<br>
   | Some os -><br>
-      let src_path = "linux" // os in<br>
+      let src_paths = List.map ((//) "linux") os in<br>
       let dst_path = "/var/tmp" in<br>
-      debug "locating packages in %s" src_path;<br>
+      debug "locating packages in: %s" (String.concat ", " src_paths);<br>
       let packages =<br>
-        copy_from_virtio_win g inspect src_path dst_path<br>
+        copy_from_virtio_win g inspect src_paths dst_path<br>
                              (fun _ _ -> true)<br>
                              (fun () -><br>
-                               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.")<br>
-                                       src_path) in<br>
+                               warning (f_"none of the guest tools directories ‘[%s]’ was found on the virtio-win directory or ISO.\n\nGuest tools are only provided in the oVirt/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.")<br>
+                                  (String.concat ", " src_paths)) in<br>
       debug "done copying %d files" (List.length packages);<br>
       let packages = List.map ((//) dst_path) packages in<br>
       try<br>
@@ -290,29 +294,34 @@ and ddb_regedits inspect drv_name drv_pciid =<br>
  * been copied.<br>
  *)<br>
 and copy_drivers g inspect driverdir =<br>
-  [] <> copy_from_virtio_win g inspect "/" driverdir<br>
+  [] <> copy_from_virtio_win g inspect ["/"] driverdir<br>
     virtio_iso_path_matches_guest_os<br>
     (fun () -><br>
       error (f_"root directory ‘/’ 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."))<br>
<br>
-(* Copy all files from virtio_win directory/ISO located in [srcdir]<br>
- * subdirectory and all its subdirectories to the [destdir]. The directory<br>
- * hierarchy is not preserved, meaning all files will be directly in [destdir].<br>
- * The file list is filtered based on [filter] function.<br>
+(* Find first existing direcotry from [scrdirs] list located in virtio_win<br>
+ * directory/ISO and copy all files from that directory and all its<br>
+ * subdirectories to the [destdir]. The directory hierarchy is not preserved,<br>
+ * meaning all files will be directly in [destdir]. The file list is filtered<br>
+ * based on [filter] function.<br>
  *<br>
- * If [srcdir] is missing from the ISO then [missing ()] is called<br>
+ * If none of the directories in [srcdirs] exists [missing ()] is called<br>
  * which might give a warning or error.<br>
  *<br>
+ * Note that the call may succeed whithout copying any file at all. This may<br>
+ * happen when the source subdirectory exists but is empty or when [filter]<br>
+ * function is too strict to allow any of the files.<br>
+ *<br>
  * Returns list of copied files.<br>
  *)<br>
-and copy_from_virtio_win g inspect srcdir destdir filter missing =<br>
+and copy_from_virtio_win g inspect srcdirs destdir filter missing =<br>
   let ret = ref [] in<br>
   if is_directory virtio_win then (<br>
     debug "windows: copy_from_virtio_win: guest tools source directory %s" virtio_win;<br>
<br>
-    let dir = virtio_win // srcdir in<br>
-    if not (is_directory dir) then missing ()<br>
-    else (<br>
+    try<br>
+      let srcdirs = List.map ((//) virtio_win) srcdirs in<br>
+      let dir = List.find is_directory srcdirs in<br>
       let cmd = sprintf "cd %s && find -L -type f" (quote dir) in<br>
       let paths = external_command cmd in<br>
       List.iter (<br>
@@ -328,7 +337,8 @@ and copy_from_virtio_win g inspect srcdir destdir filter missing =<br>
             List.push_front target_name ret<br>
           )<br>
       ) paths<br>
-    )<br>
+    with Not_found -><br>
+      missing()<br>
   )<br>
   else if is_regular_file virtio_win then (<br>
     debug "windows: copy_from_virtio_win: guest tools source ISO %s" virtio_win;<br>
@@ -339,9 +349,9 @@ and copy_from_virtio_win g inspect srcdir destdir filter missing =<br>
       g2#launch ();<br>
       let vio_root = "/" in<br>
       g2#mount_ro "/dev/sda" vio_root;<br>
-      let srcdir = vio_root ^ "/" ^ srcdir in<br>
-      if not (g2#is_dir srcdir) then missing ()<br>
-      else (<br>
+      let srcdirs = List.map ((//) vio_root) srcdirs in<br>
+      try<br>
+        let srcdir = List.find g2#is_dir srcdirs in<br>
         let paths = g2#find srcdir in<br>
         Array.iter (<br>
           fun path -><br>
@@ -357,7 +367,8 @@ and copy_from_virtio_win g inspect srcdir destdir filter missing =<br>
               List.push_front target_name ret<br>
             )<br>
         ) paths;<br>
-      );<br>
+      with Not_found -><br>
+        missing();<br>
       g2#close()<br>
     with Guestfs.Error msg -><br>
       error (f_"%s: cannot open virtio-win ISO file: %s") virtio_win msg<br>
-- <br>
2.20.1<br>
<br>
</blockquote></div></div></div>