Handle kernel without device-mapper support
Signed-off-by: heyitao <heyitao@uniontech.com>
This commit is contained in:
parent
6768e48a78
commit
8f54669cbd
76
0001-Don-t-cache-device-mapper-major.patch
Normal file
76
0001-Don-t-cache-device-mapper-major.patch
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
From 1c5804926a289882ff4a84f1c6ca6df1dd117215 Mon Sep 17 00:00:00 2001
|
||||||
|
From: rpm-build <rpm-build>
|
||||||
|
Date: Tue, 31 Aug 2021 08:22:41 -0400
|
||||||
|
Subject: [PATCH] Don't cache device-mapper major
|
||||||
|
|
||||||
|
---
|
||||||
|
src/util/virdevmapper.c | 19 +++++--------------
|
||||||
|
1 file changed, 5 insertions(+), 14 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/util/virdevmapper.c b/src/util/virdevmapper.c
|
||||||
|
index a471504..2b9e689 100644
|
||||||
|
--- a/src/util/virdevmapper.c
|
||||||
|
+++ b/src/util/virdevmapper.c
|
||||||
|
@@ -46,11 +46,8 @@
|
||||||
|
|
||||||
|
G_STATIC_ASSERT(BUF_SIZE > sizeof(struct dm_ioctl));
|
||||||
|
|
||||||
|
-static unsigned int virDMMajor;
|
||||||
|
-
|
||||||
|
-
|
||||||
|
static int
|
||||||
|
-virDevMapperOnceInit(void)
|
||||||
|
+virDevMapperGetMajor(unsigned int *major)
|
||||||
|
{
|
||||||
|
g_autofree char *buf = NULL;
|
||||||
|
VIR_AUTOSTRINGLIST lines = NULL;
|
||||||
|
@@ -69,7 +66,7 @@ virDevMapperOnceInit(void)
|
||||||
|
|
||||||
|
if (sscanf(lines[i], "%u %ms\n", &maj, &dev) == 2 &&
|
||||||
|
STREQ(dev, DM_NAME)) {
|
||||||
|
- virDMMajor = maj;
|
||||||
|
+ *major = maj;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -84,10 +81,6 @@ virDevMapperOnceInit(void)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
-
|
||||||
|
-VIR_ONCE_GLOBAL_INIT(virDevMapper);
|
||||||
|
-
|
||||||
|
-
|
||||||
|
static void *
|
||||||
|
virDMIoctl(int controlFD, int cmd, struct dm_ioctl *dm, char **buf)
|
||||||
|
{
|
||||||
|
@@ -305,9 +298,6 @@ virDevMapperGetTargets(const char *path,
|
||||||
|
* consist of devices or yet another targets. If that's the
|
||||||
|
* case, we have to stop recursion somewhere. */
|
||||||
|
|
||||||
|
- if (virDevMapperInitialize() < 0)
|
||||||
|
- return -1;
|
||||||
|
-
|
||||||
|
if ((controlFD = virDMOpen()) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
@@ -319,13 +309,14 @@ bool
|
||||||
|
virIsDevMapperDevice(const char *dev_name)
|
||||||
|
{
|
||||||
|
struct stat buf;
|
||||||
|
+ unsigned int major;
|
||||||
|
|
||||||
|
- if (virDevMapperInitialize() < 0)
|
||||||
|
+ if (virDevMapperGetMajor(&major) < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!stat(dev_name, &buf) &&
|
||||||
|
S_ISBLK(buf.st_mode) &&
|
||||||
|
- major(buf.st_rdev) == virDMMajor)
|
||||||
|
+ major(buf.st_rdev) == major)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
--
|
||||||
|
2.18.2
|
||||||
|
|
||||||
58
0001-Handle-kernel-without-device-mapper-support.patch
Normal file
58
0001-Handle-kernel-without-device-mapper-support.patch
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
From 3c12ed40d06ffe2f2c871667f31925f8727162a4 Mon Sep 17 00:00:00 2001
|
||||||
|
From: rpm-build <rpm-build>
|
||||||
|
Date: Tue, 31 Aug 2021 08:31:06 -0400
|
||||||
|
Subject: [PATCH] Handle kernel without device-mapper support
|
||||||
|
|
||||||
|
---
|
||||||
|
src/util/virdevmapper.c | 19 ++++++++++++++++++-
|
||||||
|
1 file changed, 18 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/src/util/virdevmapper.c b/src/util/virdevmapper.c
|
||||||
|
index 2b9e689..158c9d4 100644
|
||||||
|
--- a/src/util/virdevmapper.c
|
||||||
|
+++ b/src/util/virdevmapper.c
|
||||||
|
@@ -53,6 +53,9 @@ virDevMapperGetMajor(unsigned int *major)
|
||||||
|
VIR_AUTOSTRINGLIST lines = NULL;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
+ if (!virFileExists(CONTROL_PATH))
|
||||||
|
+ return -2;
|
||||||
|
+
|
||||||
|
if (virFileReadAll(PROC_DEVICES, BUF_SIZE, &buf) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
@@ -124,8 +127,13 @@ virDMOpen(void)
|
||||||
|
|
||||||
|
memset(&dm, 0, sizeof(dm));
|
||||||
|
|
||||||
|
- if ((controlFD = open(CONTROL_PATH, O_RDWR)) < 0)
|
||||||
|
+ if ((controlFD = open(CONTROL_PATH, O_RDWR)) < 0) {
|
||||||
|
+ if (errno == ENOENT)
|
||||||
|
+ return -2;
|
||||||
|
+
|
||||||
|
+ virReportSystemError(errno, _("Unable to open %s"), CONTROL_PATH);
|
||||||
|
return -1;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
if (!virDMIoctl(controlFD, DM_VERSION, &dm, &tmp)) {
|
||||||
|
virReportSystemError(errno, "%s",
|
||||||
|
@@ -299,7 +307,16 @@ virDevMapperGetTargets(const char *path,
|
||||||
|
* case, we have to stop recursion somewhere. */
|
||||||
|
|
||||||
|
if ((controlFD = virDMOpen()) < 0)
|
||||||
|
+ if ((controlFD = virDMOpen()) < 0) {
|
||||||
|
+ if (controlFD == -2) {
|
||||||
|
+ /* The CONTROL_PATH doesn't exist. Probably the
|
||||||
|
+ * module isn't loaded, yet. Don't error out, just
|
||||||
|
+ * exit. */
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
return -1;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
return virDevMapperGetTargetsImpl(controlFD, path, devPaths, ttl);
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.18.2
|
||||||
|
|
||||||
@ -105,7 +105,7 @@
|
|||||||
Summary: Library providing a simple virtualization API
|
Summary: Library providing a simple virtualization API
|
||||||
Name: libvirt
|
Name: libvirt
|
||||||
Version: 6.2.0
|
Version: 6.2.0
|
||||||
Release: 21
|
Release: 22
|
||||||
License: LGPLv2+
|
License: LGPLv2+
|
||||||
URL: https://libvirt.org/
|
URL: https://libvirt.org/
|
||||||
|
|
||||||
@ -184,6 +184,8 @@ Patch0067: tests-fix-stat-mocking-with-Fedora-rawhide.patch
|
|||||||
Patch0068: cpu_map-Add-Cooperlake-x86-CPU-model.patch
|
Patch0068: cpu_map-Add-Cooperlake-x86-CPU-model.patch
|
||||||
Patch0069: cpu_map-Add-pschange-mc-no-bit-in-IA32_ARCH_CAPABILI.patch
|
Patch0069: cpu_map-Add-pschange-mc-no-bit-in-IA32_ARCH_CAPABILI.patch
|
||||||
Patch0070: cpu_map-Distribute-x86_Cooperlake.xml.patch
|
Patch0070: cpu_map-Distribute-x86_Cooperlake.xml.patch
|
||||||
|
Patch0071: 0001-Don-t-cache-device-mapper-major.patch
|
||||||
|
Patch0072: 0001-Handle-kernel-without-device-mapper-support.patch
|
||||||
|
|
||||||
Requires: libvirt-daemon = %{version}-%{release}
|
Requires: libvirt-daemon = %{version}-%{release}
|
||||||
Requires: libvirt-daemon-config-network = %{version}-%{release}
|
Requires: libvirt-daemon-config-network = %{version}-%{release}
|
||||||
@ -1917,6 +1919,10 @@ exit 0
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Sep 2 2021 heyitao <heyitao@uniontech.com> - 6.2.0-22
|
||||||
|
- Don't cache device-mapper major
|
||||||
|
- Handle kernel without device-mapper support
|
||||||
|
|
||||||
* Fri Jul 30 2021 chenyanpanHW <chenyanpan@huawei.com> - 6.2.0-21
|
* Fri Jul 30 2021 chenyanpanHW <chenyanpan@huawei.com> - 6.2.0-21
|
||||||
- DESC: delete -S git_am from %autosetup, and delete BuildRequires git
|
- DESC: delete -S git_am from %autosetup, and delete BuildRequires git
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user