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