Richard W.M. Jones
2018-Jun-21 14:24 UTC
[Libguestfs] p2v: Allow virt-v2v input and output drivers containing '-' (RHBZ#1590220).
v1 was here: https://www.redhat.com/archives/libguestfs/2018-June/msg00047.html v1 -> v2: - Add a regular expression in the virt-v2v modules code too. - - - I was planning a much more ambitious second version of this patch (half written too) which had: virt-v2v --describe-modules that listed a big chunk of XML which virt-p2v would parse. These would include the names of the available modules and the long descriptions (currently hard-coded into virt-p2v p2v/gui.c). However it was a bunch of tricky code and it would be difficult to maintain interop with both old and new versions of virt-v2v. Also there's a problem with translating strings. So in the end I wasn't happy with it. Rich.
Richard W.M. Jones
2018-Jun-21 14:24 UTC
[Libguestfs] [PATCH v2] p2v: Allow virt-v2v input and output drivers containing '-' (RHBZ#1590220).
The new ‘-o rhv-upload’ output mode contains a '-' character in the name, but the regular expression which matched the output of the virt-v2v command did not recognize '-' as a valid character. It ended up mapping this to just "rhv" meaning two "rhv" entries would appear in the list of output drivers. Thanks: Ming Xie. --- p2v/ssh.c | 7 +++++-- v2v/modules_list.ml | 11 +++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/p2v/ssh.c b/p2v/ssh.c index d2699fffd..15f53b692 100644 --- a/p2v/ssh.c +++ b/p2v/ssh.c @@ -181,8 +181,11 @@ compile_regexps (void) 0); COMPILE (feature_libguestfs_rewrite_re, "libguestfs-rewrite", 0); COMPILE (feature_colours_option_re, "colours-option", 0); - COMPILE (feature_input_re, "input:((?:\\w)*)", 0); - COMPILE (feature_output_re, "output:((?:\\w)*)", 0); + /* The input and output regexps must match the same pattern in + * v2v/modules_list.ml. + */ + COMPILE (feature_input_re, "input:((?:[-\\w])+)", 0); + COMPILE (feature_output_re, "output:((?:[-\\w])+)", 0); COMPILE (portfwd_re, "Allocated port ((?:\\d)+) for remote forward", 0); } diff --git a/v2v/modules_list.ml b/v2v/modules_list.ml index 91b029b07..b7accc4f9 100644 --- a/v2v/modules_list.ml +++ b/v2v/modules_list.ml @@ -21,8 +21,15 @@ open Std_utils let input_modules = ref [] and output_modules = ref [] -let register_input_module name = List.push_front name input_modules -and register_output_module name = List.push_front name output_modules +(* Must match the regular expressions in p2v/ssh.c *) +let module_name_re = PCRE.compile ~anchored:true "[-\\w]+" + +let register_input_module name + assert (PCRE.matches module_name_re name); + List.push_front name input_modules +and register_output_module name + assert (PCRE.matches module_name_re name); + List.push_front name output_modules let input_modules () = List.sort compare !input_modules and output_modules () = List.sort compare !output_modules -- 2.16.2
Pino Toscano
2018-Jun-21 16:32 UTC
Re: [Libguestfs] [PATCH v2] p2v: Allow virt-v2v input and output drivers containing '-' (RHBZ#1590220).
On Thursday, 21 June 2018 16:24:22 CEST Richard W.M. Jones wrote:> The new ‘-o rhv-upload’ output mode contains a '-' character in the > name, but the regular expression which matched the output of the > virt-v2v command did not recognize '-' as a valid character. It ended > up mapping this to just "rhv" meaning two "rhv" entries would appear > in the list of output drivers. > > Thanks: Ming Xie. > ---LGTM. Thanks, -- Pino Toscano
Seemingly Similar Threads
- [PATCH v2] p2v: Allow virt-v2v input and output drivers containing '-' (RHBZ#1590220).
- [PATCH] p2v: Allow virt-v2v input and output drivers containing '-' (RHBZ#1590220).
- [PATCH 1/2] v2v: register also aliases of input/output modules
- Re: [PATCH] p2v: Allow virt-v2v input and output drivers containing '-' (RHBZ#1590220).
- [PATCH v2 1/2] v2v: register also aliases of input/output modules