|
|
0d20ef |
From b69454033c11c983b9546f9d2aa031c1594f0b79 Mon Sep 17 00:00:00 2001
|
|
|
0d20ef |
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
|
0d20ef |
Date: Tue, 18 Nov 2014 14:17:35 +0000
|
|
|
0d20ef |
Subject: [PATCH] v2v: linux: Refactor device replacement code.
|
|
|
0d20ef |
|
|
|
0d20ef |
No functional change. This should be equivalent to previously.
|
|
|
0d20ef |
|
|
|
0d20ef |
(cherry picked from commit 467bbf72f74527ca00678cfea80b1785868cd842)
|
|
|
0d20ef |
---
|
|
|
0d20ef |
v2v/convert_linux.ml | 55 ++++++++++++++++++++++++++--------------------------
|
|
|
0d20ef |
1 file changed, 27 insertions(+), 28 deletions(-)
|
|
|
0d20ef |
|
|
|
0d20ef |
diff --git a/v2v/convert_linux.ml b/v2v/convert_linux.ml
|
|
|
0d20ef |
index d094969..6c483c2 100644
|
|
|
0d20ef |
--- a/v2v/convert_linux.ml
|
|
|
0d20ef |
+++ b/v2v/convert_linux.ml
|
|
|
0d20ef |
@@ -1305,55 +1305,54 @@ let rec convert ~verbose ~keep_serial_console (g : G.guestfs) inspect source =
|
|
|
0d20ef |
Str.regexp "^/dev/\\([a-z]+\\)$" in
|
|
|
0d20ef |
|
|
|
0d20ef |
let rec replace_if_device path value =
|
|
|
0d20ef |
- if Str.string_match rex_device_cciss_p value 0 then (
|
|
|
0d20ef |
+ let replace device =
|
|
|
0d20ef |
+ try List.assoc device map
|
|
|
0d20ef |
+ with Not_found ->
|
|
|
0d20ef |
+ if string_find device "md" = -1 && string_find device "fd" = -1 &&
|
|
|
0d20ef |
+ device <> "cdrom" then
|
|
|
0d20ef |
+ warning ~prog (f_"%s references unknown device \"%s\". You may have to fix this entry manually after conversion.")
|
|
|
0d20ef |
+ path device;
|
|
|
0d20ef |
+ device
|
|
|
0d20ef |
+ in
|
|
|
0d20ef |
+
|
|
|
0d20ef |
+ if string_find path "GRUB_CMDLINE" >= 0 then (
|
|
|
0d20ef |
+ (* Handle grub2 resume=<dev> specially. *)
|
|
|
0d20ef |
+ if Str.string_match rex_resume value 0 then (
|
|
|
0d20ef |
+ let start = Str.matched_group 1 value
|
|
|
0d20ef |
+ and device = Str.matched_group 2 value
|
|
|
0d20ef |
+ and end_ = Str.matched_group 3 value in
|
|
|
0d20ef |
+ let device = replace_if_device path device in
|
|
|
0d20ef |
+ start ^ device ^ end_
|
|
|
0d20ef |
+ )
|
|
|
0d20ef |
+ else value
|
|
|
0d20ef |
+ )
|
|
|
0d20ef |
+ else if Str.string_match rex_device_cciss_p value 0 then (
|
|
|
0d20ef |
let device = Str.matched_group 1 value
|
|
|
0d20ef |
and part = Str.matched_group 2 value in
|
|
|
0d20ef |
- "/dev/" ^ replace path device ^ part
|
|
|
0d20ef |
+ "/dev/" ^ replace device ^ part
|
|
|
0d20ef |
)
|
|
|
0d20ef |
else if Str.string_match rex_device_cciss value 0 then (
|
|
|
0d20ef |
let device = Str.matched_group 1 value in
|
|
|
0d20ef |
- "/dev/" ^ replace path device
|
|
|
0d20ef |
+ "/dev/" ^ replace device
|
|
|
0d20ef |
)
|
|
|
0d20ef |
else if Str.string_match rex_device_p value 0 then (
|
|
|
0d20ef |
let device = Str.matched_group 1 value
|
|
|
0d20ef |
and part = Str.matched_group 2 value in
|
|
|
0d20ef |
- "/dev/" ^ replace path device ^ part
|
|
|
0d20ef |
+ "/dev/" ^ replace device ^ part
|
|
|
0d20ef |
)
|
|
|
0d20ef |
else if Str.string_match rex_device value 0 then (
|
|
|
0d20ef |
let device = Str.matched_group 1 value in
|
|
|
0d20ef |
- "/dev/" ^ replace path device
|
|
|
0d20ef |
+ "/dev/" ^ replace device
|
|
|
0d20ef |
)
|
|
|
0d20ef |
else (* doesn't look like a known device name *)
|
|
|
0d20ef |
value
|
|
|
0d20ef |
-
|
|
|
0d20ef |
- and replace path device =
|
|
|
0d20ef |
- try List.assoc device map
|
|
|
0d20ef |
- with Not_found ->
|
|
|
0d20ef |
- if string_find device "md" = -1 && string_find device "fd" = -1 &&
|
|
|
0d20ef |
- device <> "cdrom" then
|
|
|
0d20ef |
- warning ~prog (f_"%s references unknown device \"%s\". You may have to fix this entry manually after conversion.")
|
|
|
0d20ef |
- path device;
|
|
|
0d20ef |
- device
|
|
|
0d20ef |
in
|
|
|
0d20ef |
|
|
|
0d20ef |
let changed = ref false in
|
|
|
0d20ef |
List.iter (
|
|
|
0d20ef |
fun path ->
|
|
|
0d20ef |
let value = g#aug_get path in
|
|
|
0d20ef |
-
|
|
|
0d20ef |
- let new_value =
|
|
|
0d20ef |
- (* Handle grub2 resume=<dev> specially. *)
|
|
|
0d20ef |
- if string_find path "GRUB_CMDLINE" >= 0 then (
|
|
|
0d20ef |
- if Str.string_match rex_resume value 0 then (
|
|
|
0d20ef |
- let start = Str.matched_group 1 value
|
|
|
0d20ef |
- and device = Str.matched_group 2 value
|
|
|
0d20ef |
- and end_ = Str.matched_group 3 value in
|
|
|
0d20ef |
- let device = replace_if_device path device in
|
|
|
0d20ef |
- start ^ device ^ end_
|
|
|
0d20ef |
- )
|
|
|
0d20ef |
- else value
|
|
|
0d20ef |
- )
|
|
|
0d20ef |
- else replace_if_device path value in
|
|
|
0d20ef |
+ let new_value = replace_if_device path value in
|
|
|
0d20ef |
|
|
|
0d20ef |
if value <> new_value then (
|
|
|
0d20ef |
g#aug_set path new_value;
|
|
|
0d20ef |
--
|
|
|
0d20ef |
1.8.3.1
|
|
|
0d20ef |
|