Fix loop_wait (#1462150)
The previous code used losetup --list -O to return the backing store associated with the loop device. This can fail due to losetup truncating the output filename if sysfs isn't setup. Instead of printing the full path it will truncate it to 64 characters with a * at the end. See util-linux lib/loopdev.c for the code that does this. This commit changes it to use the existing get_loop_name function, which uses losetup -j to lookup the loop device associated with the backing store which avoids the truncation problem. Resolves: rhbz#1462150
This commit is contained in:
parent
79917e7e88
commit
a883412ccc
@ -24,6 +24,7 @@ import os, tempfile
|
|||||||
from os.path import join, dirname
|
from os.path import join, dirname
|
||||||
from subprocess import Popen, PIPE, CalledProcessError
|
from subprocess import Popen, PIPE, CalledProcessError
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
from time import sleep
|
from time import sleep
|
||||||
@ -136,12 +137,16 @@ def loop_waitfor(loop_dev, outfile):
|
|||||||
"""
|
"""
|
||||||
for x in xrange(0,5):
|
for x in xrange(0,5):
|
||||||
runcmd(["udevadm", "settle", "--timeout", "300"])
|
runcmd(["udevadm", "settle", "--timeout", "300"])
|
||||||
buf = runcmd_output(["losetup", "--list", "-O", "BACK-FILE", loop_dev])
|
## XXX Note that losetup --list output can be truncated to 64 bytes in some
|
||||||
lines = buf.splitlines()
|
## situations. Don't use it to lookup backing file, go the other way
|
||||||
if len(lines) < 2:
|
## and lookup the loop for the backing file. See util-linux lib/loopdev.c
|
||||||
continue
|
## loopcxt_get_backing_file()
|
||||||
if lines[1].strip() == outfile:
|
if get_loop_name(outfile) == os.path.basename(loop_dev):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# If this really is a race, give it some time to settle down
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
raise RuntimeError("Unable to setup %s on %s" % (loop_dev, outfile))
|
raise RuntimeError("Unable to setup %s on %s" % (loop_dev, outfile))
|
||||||
|
|
||||||
def loop_attach(outfile):
|
def loop_attach(outfile):
|
||||||
|
Loading…
Reference in New Issue
Block a user