render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
43fe83
From f012f3f9db0db87efd7f6b8ee7d871932eaa918b Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <f012f3f9db0db87efd7f6b8ee7d871932eaa918b.1377873638.git.jdenemar@redhat.com>
43fe83
From: "Daniel P. Berrange" <berrange@redhat.com>
43fe83
Date: Tue, 13 Aug 2013 11:36:51 +0100
43fe83
Subject: [PATCH] Make check for /dev/loop device names stricter to avoid
43fe83
 /dev/loop-control
43fe83
43fe83
For https://bugzilla.redhat.com/show_bug.cgi?id=924815
43fe83
43fe83
Recentish (2011) kernels introduced a new device called /dev/loop-control,
43fe83
which causes libvirt's detection of loop devices to get confused
43fe83
since it only checks for a prefix of 'loop'. Also check that the
43fe83
next character is a digit
43fe83
43fe83
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
43fe83
(cherry picked from commit 68a9637b2c0655c23713965f6444f66af95fbff3)
43fe83
---
43fe83
 src/util/virfile.c | 6 +++++-
43fe83
 1 file changed, 5 insertions(+), 1 deletion(-)
43fe83
43fe83
diff --git a/src/util/virfile.c b/src/util/virfile.c
43fe83
index 8f0eec3..2b07ac9 100644
43fe83
--- a/src/util/virfile.c
43fe83
+++ b/src/util/virfile.c
43fe83
@@ -546,7 +546,11 @@ static int virFileLoopDeviceOpen(char **dev_name)
43fe83
 
43fe83
     errno = 0;
43fe83
     while ((de = readdir(dh)) != NULL) {
43fe83
-        if (!STRPREFIX(de->d_name, "loop"))
43fe83
+        /* Checking 'loop' prefix is insufficient, since
43fe83
+         * new kernels have a dev named 'loop-control'
43fe83
+         */
43fe83
+        if (!STRPREFIX(de->d_name, "loop") ||
43fe83
+            !c_isdigit(de->d_name[4]))
43fe83
             continue;
43fe83
 
43fe83
         if (virAsprintf(&looppath, "/dev/%s", de->d_name) < 0)
43fe83
-- 
43fe83
1.8.3.2
43fe83