|
|
696189 |
From ba2963bc57c8c8a3d6f7cc2fd274c9ebd4ddb7d8 Mon Sep 17 00:00:00 2001
|
|
|
696189 |
From: Laszlo Ersek <lersek@redhat.com>
|
|
|
696189 |
Date: Wed, 6 Jul 2022 12:32:15 +0200
|
|
|
696189 |
Subject: [PATCH] convert/convert_linux: complete the remapping of NVMe devices
|
|
|
696189 |
|
|
|
696189 |
In commit 75872bf282d7 ("input: -i vmx: Add support for NVMe devices",
|
|
|
696189 |
2022-04-08), we missed that pathnames such as
|
|
|
696189 |
|
|
|
696189 |
/dev/nvme0n1[p1]
|
|
|
696189 |
|
|
|
696189 |
would not match our "rex_device_cciss" and "rex_device" regular
|
|
|
696189 |
expressions.
|
|
|
696189 |
|
|
|
696189 |
As a consequence, we don't remap such pathnames now in the boot config
|
|
|
696189 |
files with Augeas.
|
|
|
696189 |
|
|
|
696189 |
Add a new regex and associated mapping logic for this kind of pathname.
|
|
|
696189 |
|
|
|
696189 |
Notes:
|
|
|
696189 |
|
|
|
696189 |
(1) "rex_device_cciss" could be extended internally with an alternative
|
|
|
696189 |
pattern:
|
|
|
696189 |
|
|
|
696189 |
^/dev/(cciss/c\\d+d\\d+|nvme\\d+n1)(?:p(\\d+))?$
|
|
|
696189 |
^^^^^^^^^^^
|
|
|
696189 |
|
|
|
696189 |
but Rich suggested we should add a separate, complete regexp for
|
|
|
696189 |
maintainability.
|
|
|
696189 |
|
|
|
696189 |
(2) Even with a separate regexp, we could reuse the existent CCISS pattern
|
|
|
696189 |
handler:
|
|
|
696189 |
|
|
|
696189 |
if PCRE.matches rex_device_cciss value ||
|
|
|
696189 |
PCRE.matches rex_device_nvme value then (
|
|
|
696189 |
let device = PCRE.sub 1
|
|
|
696189 |
and part = try PCRE.sub 2 with Not_found -> "" in
|
|
|
696189 |
"/dev/" ^ replace device ^ part
|
|
|
696189 |
)
|
|
|
696189 |
|
|
|
696189 |
Namely, although "PCRE.matches" creates/updates global state, and
|
|
|
696189 |
"PCRE.sub" reads that state, the "||" operator in OCaml has short-circuit
|
|
|
696189 |
behavior, and both regexps have the same structure.
|
|
|
696189 |
|
|
|
696189 |
But, using the same maintainability argument, let's keep the handler logic
|
|
|
696189 |
for NVMe detached.
|
|
|
696189 |
|
|
|
696189 |
Fixes: 75872bf282d7f2322110caca70963717b43806b1
|
|
|
696189 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2101665
|
|
|
696189 |
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
696189 |
Message-Id: <20220706103215.5607-1-lersek@redhat.com>
|
|
|
696189 |
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
|
|
|
696189 |
(cherry picked from commit 4368b94ee1724c16aa35c0ee42ce4c51ce037b5a)
|
|
|
696189 |
---
|
|
|
696189 |
convert/convert_linux.ml | 6 ++++++
|
|
|
696189 |
1 file changed, 6 insertions(+)
|
|
|
696189 |
|
|
|
696189 |
diff --git a/convert/convert_linux.ml b/convert/convert_linux.ml
|
|
|
696189 |
index 59d143bd..a66ff1e4 100644
|
|
|
696189 |
--- a/convert/convert_linux.ml
|
|
|
696189 |
+++ b/convert/convert_linux.ml
|
|
|
696189 |
@@ -1199,6 +1199,7 @@ let convert (g : G.guestfs) source inspect keep_serial_console _ =
|
|
|
696189 |
(* Map device names for each entry. *)
|
|
|
696189 |
let rex_resume = PCRE.compile "^resume=(/dev/[-a-z\\d/_]+)(.*)$"
|
|
|
696189 |
and rex_device_cciss = PCRE.compile "^/dev/(cciss/c\\d+d\\d+)(?:p(\\d+))?$"
|
|
|
696189 |
+ and rex_device_nvme = PCRE.compile "^/dev/(nvme\\d+n1)(?:p(\\d+))?$"
|
|
|
696189 |
and rex_device = PCRE.compile "^/dev/([a-z]+)(\\d*)?$" in
|
|
|
696189 |
|
|
|
696189 |
let rec replace_if_device path value =
|
|
|
696189 |
@@ -1221,6 +1222,11 @@ let convert (g : G.guestfs) source inspect keep_serial_console _ =
|
|
|
696189 |
and part = try PCRE.sub 2 with Not_found -> "" in
|
|
|
696189 |
"/dev/" ^ replace device ^ part
|
|
|
696189 |
)
|
|
|
696189 |
+ else if PCRE.matches rex_device_nvme value then (
|
|
|
696189 |
+ let device = PCRE.sub 1
|
|
|
696189 |
+ and part = try PCRE.sub 2 with Not_found -> "" in
|
|
|
696189 |
+ "/dev/" ^ replace device ^ part
|
|
|
696189 |
+ )
|
|
|
696189 |
else if PCRE.matches rex_device value then (
|
|
|
696189 |
let device = PCRE.sub 1
|
|
|
696189 |
and part = try PCRE.sub 2 with Not_found -> "" in
|