mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

Blame SOURCES/0057-p2v-Allow-virt-v2v-input-and-output-drivers-containi.patch

e9bfca
From ea9feae9d8793e417c393d6c61b558bb8764698d Mon Sep 17 00:00:00 2001
e9bfca
From: "Richard W.M. Jones" <rjones@redhat.com>
e9bfca
Date: Tue, 12 Jun 2018 10:22:02 +0100
e9bfca
Subject: [PATCH] p2v: Allow virt-v2v input and output drivers containing '-'
e9bfca
 (RHBZ#1590220).
e9bfca
MIME-Version: 1.0
e9bfca
Content-Type: text/plain; charset=UTF-8
e9bfca
Content-Transfer-Encoding: 8bit
e9bfca
e9bfca
The new ‘-o rhv-upload’ output mode contains a '-' character in the
e9bfca
name, but the regular expression which matched the output of the
e9bfca
virt-v2v command did not recognize '-' as a valid character.  It ended
e9bfca
up mapping this to just "rhv" meaning two "rhv" entries would appear
e9bfca
in the list of output drivers.
e9bfca
e9bfca
Thanks: Ming Xie.
e9bfca
(cherry picked from commit 3886a113f231f7b38a89333491888c4d9a0c19da)
e9bfca
---
e9bfca
 p2v/ssh.c           |  7 +++++--
e9bfca
 v2v/modules_list.ml | 11 +++++++++--
e9bfca
 2 files changed, 14 insertions(+), 4 deletions(-)
e9bfca
e9bfca
diff --git a/p2v/ssh.c b/p2v/ssh.c
e9bfca
index d2699fffd..15f53b692 100644
e9bfca
--- a/p2v/ssh.c
e9bfca
+++ b/p2v/ssh.c
e9bfca
@@ -181,8 +181,11 @@ compile_regexps (void)
e9bfca
 	   0);
e9bfca
   COMPILE (feature_libguestfs_rewrite_re, "libguestfs-rewrite", 0);
e9bfca
   COMPILE (feature_colours_option_re, "colours-option", 0);
e9bfca
-  COMPILE (feature_input_re, "input:((?:\\w)*)", 0);
e9bfca
-  COMPILE (feature_output_re, "output:((?:\\w)*)", 0);
e9bfca
+  /* The input and output regexps must match the same pattern in
e9bfca
+   * v2v/modules_list.ml.
e9bfca
+   */
e9bfca
+  COMPILE (feature_input_re, "input:((?:[-\\w])+)", 0);
e9bfca
+  COMPILE (feature_output_re, "output:((?:[-\\w])+)", 0);
e9bfca
   COMPILE (portfwd_re, "Allocated port ((?:\\d)+) for remote forward", 0);
e9bfca
 }
e9bfca
 
e9bfca
diff --git a/v2v/modules_list.ml b/v2v/modules_list.ml
e9bfca
index 91b029b07..b7accc4f9 100644
e9bfca
--- a/v2v/modules_list.ml
e9bfca
+++ b/v2v/modules_list.ml
e9bfca
@@ -21,8 +21,15 @@ open Std_utils
e9bfca
 let input_modules = ref []
e9bfca
 and output_modules = ref []
e9bfca
 
e9bfca
-let register_input_module name = List.push_front name input_modules
e9bfca
-and register_output_module name = List.push_front name output_modules
e9bfca
+(* Must match the regular expressions in p2v/ssh.c *)
e9bfca
+let module_name_re = PCRE.compile ~anchored:true "[-\\w]+"
e9bfca
+
e9bfca
+let register_input_module name =
e9bfca
+  assert (PCRE.matches module_name_re name);
e9bfca
+  List.push_front name input_modules
e9bfca
+and register_output_module name =
e9bfca
+  assert (PCRE.matches module_name_re name);
e9bfca
+  List.push_front name output_modules
e9bfca
 
e9bfca
 let input_modules () = List.sort compare !input_modules
e9bfca
 and output_modules () = List.sort compare !output_modules
e9bfca
-- 
8ff76f
2.20.1
e9bfca