iotests: nbd: Stop qemu-nbd before remaking image
197 is one example where _make_test_img is used twice without stopping the NBD server in between. An error will occur like this: @@ -26,9 +26,13 @@ === Partial final cluster === +qemu-img: TEST_DIR/t.IMGFMT: Failed to get "resize" lock +Is another process using the image? Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1024 +Failed to find an available port: Address already in use read 1024/1024 bytes at offset 0 Patch _make_test_img to stop the old qemu-nbd before starting a new one, which fixes this problem, and similarly 215. Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
0e1a582750
commit
2f9d4083f7
|
@ -195,6 +195,16 @@ _use_sample_img()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_stop_nbd_server()
|
||||||
|
{
|
||||||
|
if [ -f "${QEMU_TEST_DIR}/qemu-nbd.pid" ]; then
|
||||||
|
local QEMU_NBD_PID
|
||||||
|
read QEMU_NBD_PID < "${QEMU_TEST_DIR}/qemu-nbd.pid"
|
||||||
|
kill ${QEMU_NBD_PID}
|
||||||
|
rm -f "${QEMU_TEST_DIR}/qemu-nbd.pid"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
_make_test_img()
|
_make_test_img()
|
||||||
{
|
{
|
||||||
# extra qemu-img options can be added by tests
|
# extra qemu-img options can be added by tests
|
||||||
|
@ -234,6 +244,10 @@ _make_test_img()
|
||||||
extra_img_options="-o $optstr $extra_img_options"
|
extra_img_options="-o $optstr $extra_img_options"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ $IMGPROTO = "nbd" ]; then
|
||||||
|
_stop_nbd_server
|
||||||
|
fi
|
||||||
|
|
||||||
# XXX(hch): have global image options?
|
# XXX(hch): have global image options?
|
||||||
(
|
(
|
||||||
if [ $use_backing = 1 ]; then
|
if [ $use_backing = 1 ]; then
|
||||||
|
@ -274,12 +288,7 @@ _cleanup_test_img()
|
||||||
case "$IMGPROTO" in
|
case "$IMGPROTO" in
|
||||||
|
|
||||||
nbd)
|
nbd)
|
||||||
if [ -f "${QEMU_TEST_DIR}/qemu-nbd.pid" ]; then
|
_stop_nbd_server
|
||||||
local QEMU_NBD_PID
|
|
||||||
read QEMU_NBD_PID < "${QEMU_TEST_DIR}/qemu-nbd.pid"
|
|
||||||
kill ${QEMU_NBD_PID}
|
|
||||||
rm -f "${QEMU_TEST_DIR}/qemu-nbd.pid"
|
|
||||||
fi
|
|
||||||
rm -f "$TEST_IMG_FILE"
|
rm -f "$TEST_IMG_FILE"
|
||||||
;;
|
;;
|
||||||
vxhs)
|
vxhs)
|
||||||
|
|
Loading…
Reference in a new issue