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 <berrange@redhat.com>
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)