|
|
0602f3 |
From 9e52e90cf8d570516d4098584c263c9d8b76c447 Mon Sep 17 00:00:00 2001
|
|
|
0602f3 |
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
|
0602f3 |
Date: Tue, 25 May 2021 10:27:53 +0100
|
|
|
0602f3 |
Subject: [PATCH] v2v: -i ova: Fix parsing if OVA directory name has a trailing
|
|
|
0602f3 |
"/"
|
|
|
0602f3 |
|
|
|
0602f3 |
If you use an OVA directory with a trailing "/" in the name, virt-v2v
|
|
|
0602f3 |
would fail with:
|
|
|
0602f3 |
|
|
|
0602f3 |
virt-v2v: error: internal error: assertion failed at parse_ova.ml, line 273, char 15
|
|
|
0602f3 |
|
|
|
0602f3 |
The fix for this is to knock off the trailing "/" if present.
|
|
|
0602f3 |
|
|
|
0602f3 |
Reported-by: Xiaodai Wang
|
|
|
0602f3 |
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1964324
|
|
|
0602f3 |
(cherry picked from commit f8428f5eaaff6dedc54a40138f760298a7a3a965)
|
|
|
0602f3 |
---
|
|
|
0602f3 |
v2v/parse_ova.ml | 18 +++++++++++++++++-
|
|
|
0602f3 |
1 file changed, 17 insertions(+), 1 deletion(-)
|
|
|
0602f3 |
|
|
|
0602f3 |
diff --git a/v2v/parse_ova.ml b/v2v/parse_ova.ml
|
|
|
0602f3 |
index 568ac5fa..fc413d2a 100644
|
|
|
0602f3 |
--- a/v2v/parse_ova.ml
|
|
|
0602f3 |
+++ b/v2v/parse_ova.ml
|
|
|
0602f3 |
@@ -57,6 +57,13 @@ and ova_type =
|
|
|
0602f3 |
*)
|
|
|
0602f3 |
| TarOptimized of string (* tarball *)
|
|
|
0602f3 |
|
|
|
0602f3 |
+let string_of_t { orig_ova; top_dir; ova_type } =
|
|
|
0602f3 |
+ sprintf "orig_ova = %s, top_dir = %s, ova_type = %s"
|
|
|
0602f3 |
+ orig_ova top_dir
|
|
|
0602f3 |
+ (match ova_type with
|
|
|
0602f3 |
+ | Directory -> "Directory"
|
|
|
0602f3 |
+ | TarOptimized tarball -> "TarOptimized " ^ tarball)
|
|
|
0602f3 |
+
|
|
|
0602f3 |
type file_ref =
|
|
|
0602f3 |
| LocalFile of string
|
|
|
0602f3 |
| TarFile of string * string
|
|
|
0602f3 |
@@ -122,6 +129,13 @@ let rec parse_ova ova =
|
|
|
0602f3 |
(* Exploded path must be absolute (RHBZ#1155121). *)
|
|
|
0602f3 |
let top_dir = absolute_path top_dir in
|
|
|
0602f3 |
|
|
|
0602f3 |
+ (* top_dir must not end with / except if it == "/" (which is
|
|
|
0602f3 |
+ * likely not what you want). (RHBZ#1964324)
|
|
|
0602f3 |
+ *)
|
|
|
0602f3 |
+ let top_dir =
|
|
|
0602f3 |
+ if top_dir = "/" || not (String.is_suffix top_dir "/") then top_dir
|
|
|
0602f3 |
+ else String.sub top_dir 0 (String.length top_dir - 1) in
|
|
|
0602f3 |
+
|
|
|
0602f3 |
(* If virt-v2v is running as root, and the backend is libvirt, then
|
|
|
0602f3 |
* we have to chmod the directory to 0755 and files to 0644
|
|
|
0602f3 |
* so it is readable by qemu.qemu. This is libvirt bug RHBZ#890291.
|
|
|
0602f3 |
@@ -136,7 +150,9 @@ let rec parse_ova ova =
|
|
|
0602f3 |
ignore (run_command cmd)
|
|
|
0602f3 |
);
|
|
|
0602f3 |
|
|
|
0602f3 |
- { orig_ova = ova; top_dir; ova_type }
|
|
|
0602f3 |
+ let ova = { orig_ova = ova; top_dir; ova_type } in
|
|
|
0602f3 |
+ debug "ova: %s" (string_of_t ova);
|
|
|
0602f3 |
+ ova
|
|
|
0602f3 |
|
|
|
0602f3 |
(* Return true if [libvirt] supports ["json:"] pseudo-URLs and accepts the
|
|
|
0602f3 |
* ["raw"] driver. Function also returns true if [libvirt] backend is not
|
|
|
0602f3 |
--
|
|
|
0602f3 |
2.31.1
|
|
|
0602f3 |
|