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.
To fix this problem 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 3e7652716..f78d18d39 100644
--- a/v2v/convert_linux.ml
+++ b/v2v/convert_linux.ml
@@ -115,10 +115,10 @@ let rec 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
--
2.13.2