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