提交 d44122ec 编写于 作者: P Peter Maydell

Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging

Block layer patches for 2.6

# gpg: Signature made Tue 12 Apr 2016 17:10:29 BST using RSA key ID C88F2FD6
# gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>"

* remotes/kevin/tags/for-upstream:
  qemu-iotests: iotests.py: get rid of __all__
  qemu-iotests: 068: don't require KVM
  qemu-iotests: 148: properly skip test if quorum support is missing
  qemu-iotests: iotests.VM: remove qtest socket on error
  qemu-iotests: fix 051 on non-PC architectures
  qemu-iotests: check: don't place files with predictable names in /tmp
  MAINTAINERS: Block layer core, qcow2 and blkdebug
  qcow2: Prevent backing file names longer than 1023
  vpc: fix return value check for blk_pwrite
  iotests: Make 150 use qemu-img map instead of du
  block: initialize qcrypto API at startup
  qemu-img: fix formatting of error message
  iotests: fix the broken 026.nocache output
Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
......@@ -985,6 +985,7 @@ F: tests/intel-hda-test.c
Block layer core
M: Kevin Wolf <kwolf@redhat.com>
M: Max Reitz <mreitz@redhat.com>
L: qemu-block@nongnu.org
S: Supported
F: block*
......@@ -1569,6 +1570,7 @@ F: block/win32-aio.c
qcow2
M: Kevin Wolf <kwolf@redhat.com>
M: Max Reitz <mreitz@redhat.com>
L: qemu-block@nongnu.org
S: Supported
F: block/qcow2*
......@@ -1581,6 +1583,7 @@ F: block/qcow.c
blkdebug
M: Kevin Wolf <kwolf@redhat.com>
M: Max Reitz <mreitz@redhat.com>
L: qemu-block@nongnu.org
S: Supported
F: block/blkdebug.c
......
......@@ -1986,6 +1986,10 @@ static int qcow2_change_backing_file(BlockDriverState *bs,
{
BDRVQcow2State *s = bs->opaque;
if (backing_file && strlen(backing_file) > 1023) {
return -EINVAL;
}
pstrcpy(bs->backing_file, sizeof(bs->backing_file), backing_file ?: "");
pstrcpy(bs->backing_format, sizeof(bs->backing_format), backing_fmt ?: "");
......
......@@ -775,7 +775,7 @@ static int create_dynamic_disk(BlockBackend *blk, uint8_t *buf,
num_bat_entries = (total_sectors + block_size / 512) / (block_size / 512);
ret = blk_pwrite(blk, offset, buf, HEADER_SIZE);
if (ret) {
if (ret < 0) {
goto fail;
}
......
......@@ -37,6 +37,7 @@
#include "block/block_int.h"
#include "block/blockjob.h"
#include "block/qapi.h"
#include "crypto/init.h"
#include <getopt.h>
#define QEMU_IMG_VERSION "qemu-img version " QEMU_VERSION QEMU_PKGVERSION \
......@@ -256,7 +257,7 @@ static BlockBackend *img_open_opts(const char *optstr,
options = qemu_opts_to_qdict(opts, NULL);
blk = blk_new_open(NULL, NULL, options, flags, &local_err);
if (!blk) {
error_reportf_err(local_err, "Could not open '%s'", optstr);
error_reportf_err(local_err, "Could not open '%s': ", optstr);
return NULL;
}
blk_set_enable_write_cache(blk, !writethrough);
......@@ -3486,6 +3487,11 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
}
if (qcrypto_init(&local_error) < 0) {
error_reportf_err(local_error, "cannot initialize crypto: ");
exit(1);
}
module_call_init(MODULE_INIT_QOM);
bdrv_init();
if (argc < 2) {
......
......@@ -23,6 +23,7 @@
#include "sysemu/block-backend.h"
#include "block/block_int.h"
#include "trace/control.h"
#include "crypto/init.h"
#define CMD_NOFILE_OK 0x01
......@@ -443,6 +444,11 @@ int main(int argc, char **argv)
progname = basename(argv[0]);
qemu_init_exec_dir(argv[0]);
if (qcrypto_init(&local_error) < 0) {
error_reportf_err(local_error, "cannot initialize crypto: ");
exit(1);
}
module_call_init(MODULE_INIT_QOM);
qemu_add_opts(&qemu_object_opts);
bdrv_init();
......
......@@ -31,6 +31,7 @@
#include "qapi/qmp/qstring.h"
#include "qom/object_interfaces.h"
#include "io/channel-socket.h"
#include "crypto/init.h"
#include <getopt.h>
#include <libgen.h>
......@@ -519,6 +520,12 @@ int main(int argc, char **argv)
memset(&sa_sigterm, 0, sizeof(sa_sigterm));
sa_sigterm.sa_handler = termsig_handler;
sigaction(SIGTERM, &sa_sigterm, NULL);
if (qcrypto_init(&local_err) < 0) {
error_reportf_err(local_err, "cannot initialize crypto: ");
exit(1);
}
module_call_init(MODULE_INIT_QOM);
qemu_add_opts(&qemu_object_opts);
qemu_init_exec_dir(argv[0]);
......
此差异已折叠。
......@@ -145,7 +145,7 @@ QEMU X.Y.Z monitor - type 'help' for more information
Testing: -drive driver=null-co,cache=invalid_value
QEMU_PROG: -drive driver=null-co,cache=invalid_value: invalid cache option
Testing: -drive file=TEST_DIR/t.qcow2,cache=writeback,backing.file.filename=TEST_DIR/t.qcow2.base,backing.cache.no-flush=on,backing.cache.writeback=on,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,if=none,id=drive0 -nodefaults
Testing: -drive file=TEST_DIR/t.qcow2,cache=writeback,backing.file.filename=TEST_DIR/t.qcow2.base,backing.cache.no-flush=on,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,if=none,id=drive0 -nodefaults
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) iininfinfoinfo info binfo blinfo bloinfo blocinfo block
drive0 (NODE_NAME): TEST_DIR/t.qcow2 (qcow2)
......@@ -165,7 +165,7 @@ backing-file: TEST_DIR/t.qcow2.base (file, read-only)
Cache mode: writeback, ignore flushes
(qemu) qququiquit
Testing: -drive file=TEST_DIR/t.qcow2,cache=writethrough,backing.file.filename=TEST_DIR/t.qcow2.base,backing.cache.no-flush=on,backing.cache.writeback=on,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,if=none,id=drive0 -nodefaults
Testing: -drive file=TEST_DIR/t.qcow2,cache=writethrough,backing.file.filename=TEST_DIR/t.qcow2.base,backing.cache.no-flush=on,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,if=none,id=drive0 -nodefaults
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) iininfinfoinfo info binfo blinfo bloinfo blocinfo block
drive0 (NODE_NAME): TEST_DIR/t.qcow2 (qcow2)
......@@ -185,7 +185,7 @@ backing-file: TEST_DIR/t.qcow2.base (file, read-only)
Cache mode: writeback, ignore flushes
(qemu) qququiquit
Testing: -drive file=TEST_DIR/t.qcow2,cache=unsafe,backing.file.filename=TEST_DIR/t.qcow2.base,backing.cache.no-flush=on,backing.cache.writeback=on,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,if=none,id=drive0 -nodefaults
Testing: -drive file=TEST_DIR/t.qcow2,cache=unsafe,backing.file.filename=TEST_DIR/t.qcow2.base,backing.cache.no-flush=on,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,if=none,id=drive0 -nodefaults
QEMU X.Y.Z monitor - type 'help' for more information
(qemu) iininfinfoinfo info binfo blinfo bloinfo blocinfo block
drive0 (NODE_NAME): TEST_DIR/t.qcow2 (qcow2)
......@@ -205,8 +205,8 @@ backing-file: TEST_DIR/t.qcow2.base (file, read-only)
Cache mode: writeback, ignore flushes
(qemu) qququiquit
Testing: -drive file=TEST_DIR/t.qcow2,cache=invalid_value,backing.file.filename=TEST_DIR/t.qcow2.base,backing.cache.no-flush=on,backing.cache.writeback=on,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,if=none,id=drive0 -nodefaults
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,cache=invalid_value,backing.file.filename=TEST_DIR/t.qcow2.base,backing.cache.no-flush=on,backing.cache.writeback=on,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,if=none,id=drive0: invalid cache option
Testing: -drive file=TEST_DIR/t.qcow2,cache=invalid_value,backing.file.filename=TEST_DIR/t.qcow2.base,backing.cache.no-flush=on,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,if=none,id=drive0 -nodefaults
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,cache=invalid_value,backing.file.filename=TEST_DIR/t.qcow2.base,backing.cache.no-flush=on,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,if=none,id=drive0: invalid cache option
=== Specifying the protocol layer ===
......
......@@ -53,7 +53,7 @@ _make_test_img $IMG_SIZE
case "$QEMU_DEFAULT_MACHINE" in
s390-ccw-virtio)
platform_parm="-no-shutdown -machine accel=kvm"
platform_parm="-no-shutdown"
;;
*)
platform_parm=""
......
......@@ -79,9 +79,6 @@ sector = "%d"
self.assert_qmp(event, 'data/sector-num', sector)
def testQuorum(self):
if not 'quorum' in iotests.qemu_img_pipe('--help'):
return
# Generate an error and get an event
self.vm.hmp_qemu_io("drive0", "aio_read %d %d" %
(offset * sector_size, sector_size))
......@@ -139,4 +136,5 @@ class TestFifoQuorumEvents(TestQuorumEvents):
read_pattern = 'fifo'
if __name__ == '__main__':
iotests.verify_quorum()
iotests.main(supported_fmts=["raw"])
......@@ -38,65 +38,34 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
. ./common.rc
. ./common.filter
_supported_fmt generic
_supported_fmt raw qcow2
_supported_proto file
_supported_os Linux
on_disk_size()
{
du "$@" | sed -e 's/\t\+.*//'
}
img_size=1048576
echo
echo '=== Comparing empty image against sparse conversion ==='
echo '=== Mapping sparse conversion ==='
echo
_make_test_img $img_size
empty_size=$(on_disk_size "$TEST_IMG")
$QEMU_IMG_PROG convert -O "$IMGFMT" -S 512 \
"json:{ 'driver': 'null-co', 'size': $img_size, 'read-zeroes': true }" \
"$TEST_IMG"
sparse_convert_size=$(on_disk_size "$TEST_IMG")
if [ "$empty_size" -eq "$sparse_convert_size" ]; then
echo 'Equal image size'
else
echo 'Different image size'
fi
$QEMU_IMG map "$TEST_IMG" | _filter_qemu_img_map
echo
echo '=== Comparing full image against non-sparse conversion ==='
echo '=== Mapping non-sparse conversion ==='
echo
_make_test_img $img_size
$QEMU_IO -c "write 0 $img_size" "$TEST_IMG" | _filter_qemu_io
full_size=$(on_disk_size "$TEST_IMG")
$QEMU_IMG convert -O "$IMGFMT" -S 0 \
"json:{ 'driver': 'null-co', 'size': $img_size, 'read-zeroes': true }" \
"$TEST_IMG"
non_sparse_convert_size=$(on_disk_size "$TEST_IMG")
if [ "$full_size" -eq "$non_sparse_convert_size" ]; then
echo 'Equal image size'
else
echo 'Different image size'
fi
$QEMU_IMG map "$TEST_IMG" | _filter_qemu_img_map
# success, all done
......
QA output created by 150
=== Comparing empty image against sparse conversion ===
=== Mapping sparse conversion ===
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
Equal image size
Offset Length File
=== Comparing full image against non-sparse conversion ===
=== Mapping non-sparse conversion ===
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
wrote 1048576/1048576 bytes at offset 0
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
Equal image size
Offset Length File
0 0x100000 TEST_DIR/t.IMGFMT
*** done
......@@ -19,7 +19,6 @@
# Control script for QA
#
tmp=/tmp/$$
status=0
needwrap=true
try=0
......@@ -130,6 +129,8 @@ fi
# exit 1
#fi
tmp="${TEST_DIR}"/$$
_wallclock()
{
date "+%H %M %S" | $AWK_PROG '{ print $1*3600 + $2*60 + $3 }'
......@@ -146,8 +147,8 @@ _wrapup()
# for hangcheck ...
# remove files that were used by hangcheck
#
[ -f /tmp/check.pid ] && rm -rf /tmp/check.pid
[ -f /tmp/check.sts ] && rm -rf /tmp/check.sts
[ -f "${TEST_DIR}"/check.pid ] && rm -rf "${TEST_DIR}"/check.pid
[ -f "${TEST_DIR}"/check.sts ] && rm -rf "${TEST_DIR}"/check.sts
if $showme
then
......@@ -197,8 +198,8 @@ END { if (NR > 0) {
needwrap=false
fi
rm -f /tmp/*.out /tmp/*.err /tmp/*.time
rm -f /tmp/check.pid /tmp/check.sts
rm -f "${TEST_DIR}"/*.out "${TEST_DIR}"/*.err "${TEST_DIR}"/*.time
rm -f "${TEST_DIR}"/check.pid "${TEST_DIR}"/check.sts
rm -f $tmp.*
}
......@@ -208,16 +209,16 @@ trap "_wrapup; exit \$status" 0 1 2 3 15
# Save pid of check in a well known place, so that hangcheck can be sure it
# has the right pid (getting the pid from ps output is not reliable enough).
#
rm -rf /tmp/check.pid
echo $$ >/tmp/check.pid
rm -rf "${TEST_DIR}"/check.pid
echo $$ > "${TEST_DIR}"/check.pid
# for hangcheck ...
# Save the status of check in a well known place, so that hangcheck can be
# sure to know where check is up to (getting test number from ps output is
# not reliable enough since the trace stuff has been introduced).
#
rm -rf /tmp/check.sts
echo "preamble" >/tmp/check.sts
rm -rf "${TEST_DIR}"/check.sts
echo "preamble" > "${TEST_DIR}"/check.sts
# don't leave old full output behind on a clean run
rm -f check.full
......@@ -285,7 +286,7 @@ do
rm -f core $seq.notrun
# for hangcheck ...
echo "$seq" >/tmp/check.sts
echo "$seq" > "${TEST_DIR}"/check.sts
start=`_wallclock`
$timestamp && echo -n " ["`date "+%T"`"]"
......
......@@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import errno
import os
import re
import subprocess
......@@ -28,10 +29,6 @@ import qmp
import qtest
import struct
__all__ = ['imgfmt', 'imgproto', 'test_dir' 'qemu_img', 'qemu_io',
'VM', 'QMPTestCase', 'notrun', 'main', 'verify_image_format',
'verify_platform', 'filter_test_dir', 'filter_win32',
'filter_qemu_io', 'filter_chown', 'log']
# This will not work if arguments contain spaces but is necessary if we
# want to support the override options that ./check supports.
......@@ -247,7 +244,8 @@ class VM(object):
self._qmp.accept()
self._qtest.accept()
except:
os.remove(self._monitor_path)
_remove_if_exists(self._monitor_path)
_remove_if_exists(self._qtest_path)
raise
def shutdown(self):
......@@ -409,6 +407,15 @@ class QMPTestCase(unittest.TestCase):
event = self.wait_until_completed(drive=drive)
self.assert_qmp(event, 'data/type', 'mirror')
def _remove_if_exists(path):
'''Remove file object at path if it exists'''
try:
os.remove(path)
except OSError as exception:
if exception.errno == errno.ENOENT:
return
raise
def notrun(reason):
'''Skip this test suite'''
# Each test in qemu-iotests has a number ("seq")
......@@ -426,6 +433,11 @@ def verify_platform(supported_oses=['linux']):
if True not in [sys.platform.startswith(x) for x in supported_oses]:
notrun('not suitable for this OS: %s' % sys.platform)
def verify_quorum():
'''Skip test suite if quorum support is not available'''
if 'quorum' not in qemu_img_pipe('--help'):
notrun('quorum support missing')
def main(supported_fmts=[], supported_oses=['linux']):
'''Run tests'''
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册