|
|
b971b8 |
From e0f87dd97d0061eb2ea22b025c8bbf3310c78290 Mon Sep 17 00:00:00 2001
|
|
|
b971b8 |
Message-Id: <e0f87dd97d0061eb2ea22b025c8bbf3310c78290@dist-git>
|
|
|
b971b8 |
From: Michal Privoznik <mprivozn@redhat.com>
|
|
|
b971b8 |
Date: Fri, 19 Jun 2020 17:44:09 +0200
|
|
|
b971b8 |
Subject: [PATCH] virDevMapperGetTargetsImpl: Check for dm major properly
|
|
|
b971b8 |
MIME-Version: 1.0
|
|
|
b971b8 |
Content-Type: text/plain; charset=UTF-8
|
|
|
b971b8 |
Content-Transfer-Encoding: 8bit
|
|
|
b971b8 |
|
|
|
b971b8 |
In v6.4.0-rc1~143 I've introduced a check that is supposed to
|
|
|
b971b8 |
return from the function early, if given path is not a dm target.
|
|
|
b971b8 |
While the idea is still valid, the implementation had a flaw.
|
|
|
b971b8 |
It calls stat() over given path and the uses major(sb.st_dev) to
|
|
|
b971b8 |
learn the major of the device. This is then passed to
|
|
|
b971b8 |
dm_is_dm_major() which returns true or false depending whether
|
|
|
b971b8 |
the device is under devmapper's control or not.
|
|
|
b971b8 |
|
|
|
b971b8 |
The problem with this approach is in how the major of the device
|
|
|
b971b8 |
is obtained - paths managed by devmapper are special files and
|
|
|
b971b8 |
thus we want to be using st_rdev instead of st_dev to obtain the
|
|
|
b971b8 |
major number. Well, that's what virIsDevMapperDevice() does
|
|
|
b971b8 |
already so might as well us that.
|
|
|
b971b8 |
|
|
|
b971b8 |
Fixes: 01626c668ecfbe465d18799ac4628e6127ea1d47
|
|
|
b971b8 |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1839992
|
|
|
b971b8 |
|
|
|
b971b8 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
b971b8 |
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
b971b8 |
(cherry picked from commit d53ab9f54ea8d6cc1e5c3b04c4eb743cae9518ce)
|
|
|
b971b8 |
|
|
|
b971b8 |
https://bugzilla.redhat.com/show_bug.cgi?id=1849095
|
|
|
b971b8 |
|
|
|
b971b8 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
b971b8 |
Message-Id: <c3222a07d4259142dae4cf4f7f38730a101042b1.1592581422.git.mprivozn@redhat.com>
|
|
|
b971b8 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
b971b8 |
---
|
|
|
b971b8 |
src/util/virdevmapper.c | 9 +--------
|
|
|
b971b8 |
1 file changed, 1 insertion(+), 8 deletions(-)
|
|
|
b971b8 |
|
|
|
b971b8 |
diff --git a/src/util/virdevmapper.c b/src/util/virdevmapper.c
|
|
|
b971b8 |
index 23b2a16057..c346432d86 100644
|
|
|
b971b8 |
--- a/src/util/virdevmapper.c
|
|
|
b971b8 |
+++ b/src/util/virdevmapper.c
|
|
|
b971b8 |
@@ -66,7 +66,6 @@ virDevMapperGetTargetsImpl(const char *path,
|
|
|
b971b8 |
char ***devPaths_ret,
|
|
|
b971b8 |
unsigned int ttl)
|
|
|
b971b8 |
{
|
|
|
b971b8 |
- struct stat sb;
|
|
|
b971b8 |
struct dm_task *dmt = NULL;
|
|
|
b971b8 |
struct dm_deps *deps;
|
|
|
b971b8 |
struct dm_info info;
|
|
|
b971b8 |
@@ -85,13 +84,7 @@ virDevMapperGetTargetsImpl(const char *path,
|
|
|
b971b8 |
return ret;
|
|
|
b971b8 |
}
|
|
|
b971b8 |
|
|
|
b971b8 |
- if (stat(path, &sb) < 0) {
|
|
|
b971b8 |
- if (errno == ENOENT)
|
|
|
b971b8 |
- return 0;
|
|
|
b971b8 |
- return -1;
|
|
|
b971b8 |
- }
|
|
|
b971b8 |
-
|
|
|
b971b8 |
- if (!dm_is_dm_major(major(sb.st_dev)))
|
|
|
b971b8 |
+ if (!virIsDevMapperDevice(path))
|
|
|
b971b8 |
return 0;
|
|
|
b971b8 |
|
|
|
b971b8 |
if (!(dmt = dm_task_create(DM_DEVICE_DEPS))) {
|
|
|
b971b8 |
--
|
|
|
b971b8 |
2.27.0
|
|
|
b971b8 |
|