From 95b0da8f37c83aced070759cb126613d522bd0a6 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 21 Sep 2017 11:55:53 +0100 Subject: [PATCH] v2v: linux: Fix uninstallation of kmod-xenpv from /etc/rc.local script. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the original conversion of virt-v2v from Perl (commit 0131d6f666d93dd353c4e4092fd945861646d319), the Perl regular expression was incorrectly transscribed. ‘\b’ was not converted to ‘\\b’ so the new regexp was looking for an ASCII BEL character, not a word boundary. Also ‘|’ was used, but Str requires ‘\|’ (ie. "\\|" in the final source). To fix these problems I converted the code to use PCRE, and went back to the original virt-v2v code (virt-v2v.git: lib/Sys/VirtConvert/Converter/Linux.pm) to find out what the Perl regular expression should have been. Note I have also removed ‘.*’ at the beginning and end of the regexp because PCRE regexps are not anchored. --- v2v/convert_linux.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml index b432fdd47..f1a710d60 100644 --- a/v2v/convert_linux.ml +++ b/v2v/convert_linux.ml @@ -173,10 +173,10 @@ let convert (g : G.guestfs) inspect source output rcaps = (try let lines = g#read_lines "/etc/rc.local" in let lines = Array.to_list lines in - let rex = Str.regexp ".*\\b\\(insmod|modprobe\\)\b.*\\bxen-vbd.*" in + let rex = PCRE.compile "\\b(insmod|modprobe)\\b.*\\bxen-vbd" in let lines = List.map ( fun s -> - if Str.string_match rex s 0 then + if PCRE.matches rex s then "#" ^ s else s