mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 18:23:57 -06:00
Block layer core and image format patches
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAABAgAGBQJVevYFAAoJEH8JsnLIjy/W3jEP/0hiQ3rCRZ/he8s5maTdT+TR YSeHkB5rKpz0Uopn1DMn1QrIbUVzX7dyb+uf9zQ0/xRQIzf6k8uxqU/NWrdoF3NK qx91dGWedwnG+TEBIMbcR7nMrw4dP6kH7uPz/VWMXDHVLz0HIcD95qhKgs0mSY6J dWqex6ACjXM68zJU5IioagU9evV80WZE1S8z7zfixxtTBx5hCaTVbwalkaCxcrXw PbZle55rjI8B10+OzgBw0fq10nias+NTndU9CwNBboxmEtAjq8/mQ663vcWlmiFo 9a/hkda27Z5ut/0Tqk1v4uLHauylp++rrAabPBAuCFMKes6cdkddP15Q/r52aJ29 5meodQtbet1rGrM+Aq4vuSuWId71PGypEI/3URDdNfYFNISoeLLsk4lcQUu7VrDD sRX3Jt8SI3nkIgOnhPyi7NDPmafxFt8yRt5vM8MyR5ynF8NS/2hiAc3wqnbXGjUj a5GqDCefb1yM0R5HvksuFFt3OnXlKJQ3J+ksXNUJf9DSAZPauqWD696pcTeg8wyy 3PIGkczgUuKTVfFWd3THZxJLAo7ZuqvXBHHV8o1SeMBDxwh4FhTd8Kjvm3rUNFfl VDox4qwZ1AcxLrxgqazKU7sD9iWBDHURRcpOoUsBys7oxQZnhcmMp1fRlEkTOyrD HNiSNByqBrtkfeVzHlSe =QgYk -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging Block layer core and image format patches # gpg: Signature made Fri Jun 12 16:08:53 2015 BST using RSA key ID C88F2FD6 # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" * remotes/kevin/tags/for-upstream: (25 commits) block: Fix reopen flag inheritance block: Add BlockDriverState.inherits_from block: Add list of children to BlockDriverState queue.h: Add QLIST_FIX_HEAD_PTR() block: Drain requests before swapping nodes in bdrv_swap() block: Move flag inheritance to bdrv_open_inherit() block: Use QemuOpts in bdrv_open_common() block: Use macro for cache option names vmdk: Use bdrv_open_image() quorum: Use bdrv_open_image() check-qdict: Test cases for new functions qdict: Add qdict_{set,copy}_default() qdict: Add qdict_array_entries() iotests: Add tests for overriding BDRV_O_PROTOCOL block: driver should override flags in bdrv_open() block: Change bitmap truncate conditional to assertion block: record new size in bdrv_dirty_bitmap_truncate raw-posix: Fix .bdrv_co_get_block_status() for unaligned image size vmdk: Use vmdk_find_index_in_cluster everywhere vmdk: Fix index_in_cluster calculation in vmdk_co_get_block_status ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
f3e3b083d4
25 changed files with 658 additions and 159 deletions
|
@ -152,6 +152,28 @@ static void qdict_get_try_str_test(void)
|
|||
QDECREF(tests_dict);
|
||||
}
|
||||
|
||||
static void qdict_defaults_test(void)
|
||||
{
|
||||
QDict *dict, *copy;
|
||||
|
||||
dict = qdict_new();
|
||||
copy = qdict_new();
|
||||
|
||||
qdict_set_default_str(dict, "foo", "abc");
|
||||
qdict_set_default_str(dict, "foo", "def");
|
||||
g_assert_cmpstr(qdict_get_str(dict, "foo"), ==, "abc");
|
||||
qdict_set_default_str(dict, "bar", "ghi");
|
||||
|
||||
qdict_copy_default(copy, dict, "foo");
|
||||
g_assert_cmpstr(qdict_get_str(copy, "foo"), ==, "abc");
|
||||
qdict_set_default_str(copy, "bar", "xyz");
|
||||
qdict_copy_default(copy, dict, "bar");
|
||||
g_assert_cmpstr(qdict_get_str(copy, "bar"), ==, "xyz");
|
||||
|
||||
QDECREF(copy);
|
||||
QDECREF(dict);
|
||||
}
|
||||
|
||||
static void qdict_haskey_not_test(void)
|
||||
{
|
||||
QDict *tests_dict = qdict_new();
|
||||
|
@ -444,6 +466,49 @@ static void qdict_array_split_test(void)
|
|||
QDECREF(test_dict);
|
||||
}
|
||||
|
||||
static void qdict_array_entries_test(void)
|
||||
{
|
||||
QDict *dict = qdict_new();
|
||||
|
||||
g_assert_cmpint(qdict_array_entries(dict, "foo."), ==, 0);
|
||||
|
||||
qdict_put(dict, "bar", qint_from_int(0));
|
||||
qdict_put(dict, "baz.0", qint_from_int(0));
|
||||
g_assert_cmpint(qdict_array_entries(dict, "foo."), ==, 0);
|
||||
|
||||
qdict_put(dict, "foo.1", qint_from_int(0));
|
||||
g_assert_cmpint(qdict_array_entries(dict, "foo."), ==, -EINVAL);
|
||||
qdict_put(dict, "foo.0", qint_from_int(0));
|
||||
g_assert_cmpint(qdict_array_entries(dict, "foo."), ==, 2);
|
||||
qdict_put(dict, "foo.bar", qint_from_int(0));
|
||||
g_assert_cmpint(qdict_array_entries(dict, "foo."), ==, -EINVAL);
|
||||
qdict_del(dict, "foo.bar");
|
||||
|
||||
qdict_put(dict, "foo.2.a", qint_from_int(0));
|
||||
qdict_put(dict, "foo.2.b", qint_from_int(0));
|
||||
qdict_put(dict, "foo.2.c", qint_from_int(0));
|
||||
g_assert_cmpint(qdict_array_entries(dict, "foo."), ==, 3);
|
||||
g_assert_cmpint(qdict_array_entries(dict, ""), ==, -EINVAL);
|
||||
|
||||
QDECREF(dict);
|
||||
|
||||
dict = qdict_new();
|
||||
qdict_put(dict, "1", qint_from_int(0));
|
||||
g_assert_cmpint(qdict_array_entries(dict, ""), ==, -EINVAL);
|
||||
qdict_put(dict, "0", qint_from_int(0));
|
||||
g_assert_cmpint(qdict_array_entries(dict, ""), ==, 2);
|
||||
qdict_put(dict, "bar", qint_from_int(0));
|
||||
g_assert_cmpint(qdict_array_entries(dict, ""), ==, -EINVAL);
|
||||
qdict_del(dict, "bar");
|
||||
|
||||
qdict_put(dict, "2.a", qint_from_int(0));
|
||||
qdict_put(dict, "2.b", qint_from_int(0));
|
||||
qdict_put(dict, "2.c", qint_from_int(0));
|
||||
g_assert_cmpint(qdict_array_entries(dict, ""), ==, 3);
|
||||
|
||||
QDECREF(dict);
|
||||
}
|
||||
|
||||
static void qdict_join_test(void)
|
||||
{
|
||||
QDict *dict1, *dict2;
|
||||
|
@ -663,6 +728,7 @@ int main(int argc, char **argv)
|
|||
g_test_add_func("/public/get_try_int", qdict_get_try_int_test);
|
||||
g_test_add_func("/public/get_str", qdict_get_str_test);
|
||||
g_test_add_func("/public/get_try_str", qdict_get_try_str_test);
|
||||
g_test_add_func("/public/defaults", qdict_defaults_test);
|
||||
g_test_add_func("/public/haskey_not", qdict_haskey_not_test);
|
||||
g_test_add_func("/public/haskey", qdict_haskey_test);
|
||||
g_test_add_func("/public/del", qdict_del_test);
|
||||
|
@ -670,6 +736,7 @@ int main(int argc, char **argv)
|
|||
g_test_add_func("/public/iterapi", qdict_iterapi_test);
|
||||
g_test_add_func("/public/flatten", qdict_flatten_test);
|
||||
g_test_add_func("/public/array_split", qdict_array_split_test);
|
||||
g_test_add_func("/public/array_entries", qdict_array_entries_test);
|
||||
g_test_add_func("/public/join", qdict_join_test);
|
||||
|
||||
g_test_add_func("/errors/put_exists", qdict_put_exists_test);
|
||||
|
|
|
@ -194,7 +194,6 @@ echo === Specifying the protocol layer ===
|
|||
echo
|
||||
|
||||
run_qemu -drive file="$TEST_IMG",file.driver=file
|
||||
run_qemu -drive file="$TEST_IMG",file.driver=qcow2
|
||||
|
||||
echo
|
||||
echo === Leaving out required options ===
|
||||
|
|
|
@ -253,9 +253,6 @@ Testing: -drive file=TEST_DIR/t.qcow2,file.driver=file
|
|||
QEMU X.Y.Z monitor - type 'help' for more information
|
||||
(qemu) q[K[Dqu[K[D[Dqui[K[D[D[Dquit[K
|
||||
|
||||
Testing: -drive file=TEST_DIR/t.qcow2,file.driver=qcow2
|
||||
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,file.driver=qcow2: Block format 'qcow2' used by device '' doesn't support the option 'filename'
|
||||
|
||||
|
||||
=== Leaving out required options ===
|
||||
|
||||
|
|
|
@ -93,6 +93,16 @@ $QEMU_IO -c "open -o l2-cache-size=1M,refcount-cache-size=0.25M $TEST_IMG" \
|
|||
-c 'read -P 42 0 64k' \
|
||||
| _filter_qemu_io
|
||||
|
||||
echo
|
||||
echo '=== Testing minimal L2 cache and COW ==='
|
||||
echo
|
||||
|
||||
$QEMU_IMG snapshot -c foo "$TEST_IMG"
|
||||
# This requires a COW operation, which accesses two L2 tables simultaneously
|
||||
# (COW source and destination), so there must be enough space in the cache to
|
||||
# place both tables there (and qemu should not crash)
|
||||
$QEMU_IO -c "open -o cache-size=0 $TEST_IMG" -c 'write 0 64k' | _filter_qemu_io
|
||||
|
||||
# success, all done
|
||||
echo '*** done'
|
||||
rm -f $seq.full
|
||||
|
|
|
@ -26,4 +26,9 @@ read 65536/65536 bytes at offset 0
|
|||
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
||||
read 65536/65536 bytes at offset 0
|
||||
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
||||
|
||||
=== Testing minimal L2 cache and COW ===
|
||||
|
||||
wrote 65536/65536 bytes at offset 0
|
||||
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
||||
*** done
|
||||
|
|
60
tests/qemu-iotests/119
Executable file
60
tests/qemu-iotests/119
Executable file
|
@ -0,0 +1,60 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# NBD test case for overriding BDRV_O_PROTOCOL by explicitly specifying
|
||||
# a driver
|
||||
#
|
||||
# Copyright (C) 2015 Red Hat, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
# creator
|
||||
owner=mreitz@redhat.com
|
||||
|
||||
seq="$(basename $0)"
|
||||
echo "QA output created by $seq"
|
||||
|
||||
here="$PWD"
|
||||
tmp=/tmp/$$
|
||||
status=1 # failure is the default!
|
||||
|
||||
_cleanup()
|
||||
{
|
||||
_cleanup_test_img
|
||||
}
|
||||
trap "_cleanup; exit \$status" 0 1 2 3 15
|
||||
|
||||
# get standard environment, filters and checks
|
||||
. ./common.rc
|
||||
. ./common.filter
|
||||
|
||||
_supported_fmt raw
|
||||
_supported_proto nbd
|
||||
_supported_os Linux
|
||||
|
||||
_make_test_img 64M
|
||||
# This should not crash
|
||||
echo "{'execute': 'qmp_capabilities'}
|
||||
{'execute': 'human-monitor-command',
|
||||
'arguments': {'command-line': 'qemu-io drv \"read -P 0 0 64k\"'}}
|
||||
{'execute': 'quit'}" \
|
||||
| $QEMU -drive id=drv,if=none,file="$TEST_IMG",driver=nbd \
|
||||
-qmp stdio -nodefaults \
|
||||
| _filter_qmp | _filter_qemu_io
|
||||
|
||||
# success, all done
|
||||
echo
|
||||
echo '*** done'
|
||||
rm -f $seq.full
|
||||
status=0
|
11
tests/qemu-iotests/119.out
Normal file
11
tests/qemu-iotests/119.out
Normal file
|
@ -0,0 +1,11 @@
|
|||
QA output created by 119
|
||||
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
|
||||
QMP_VERSION
|
||||
{"return": {}}
|
||||
read 65536/65536 bytes at offset 0
|
||||
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
||||
{"return": ""}
|
||||
{"return": {}}
|
||||
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN"}
|
||||
|
||||
*** done
|
65
tests/qemu-iotests/120
Executable file
65
tests/qemu-iotests/120
Executable file
|
@ -0,0 +1,65 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Non-NBD test cases for overriding BDRV_O_PROTOCOL by explicitly
|
||||
# specifying a driver
|
||||
#
|
||||
# Copyright (C) 2015 Red Hat, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
# creator
|
||||
owner=mreitz@redhat.com
|
||||
|
||||
seq="$(basename $0)"
|
||||
echo "QA output created by $seq"
|
||||
|
||||
here="$PWD"
|
||||
tmp=/tmp/$$
|
||||
status=1 # failure is the default!
|
||||
|
||||
_cleanup()
|
||||
{
|
||||
_cleanup_test_img
|
||||
}
|
||||
trap "_cleanup; exit \$status" 0 1 2 3 15
|
||||
|
||||
# get standard environment, filters and checks
|
||||
. ./common.rc
|
||||
. ./common.filter
|
||||
|
||||
_supported_fmt generic
|
||||
_supported_proto file
|
||||
_supported_os Linux
|
||||
|
||||
_make_test_img 64M
|
||||
|
||||
echo "{'execute': 'qmp_capabilities'}
|
||||
{'execute': 'human-monitor-command',
|
||||
'arguments': {'command-line': 'qemu-io drv \"write -P 42 0 64k\"'}}
|
||||
{'execute': 'quit'}" \
|
||||
| $QEMU -qmp stdio -nodefaults \
|
||||
-drive id=drv,if=none,file="$TEST_IMG",driver=raw,file.driver=$IMGFMT \
|
||||
| _filter_qmp | _filter_qemu_io
|
||||
$QEMU_IO -c 'read -P 42 0 64k' "$TEST_IMG" | _filter_qemu_io
|
||||
|
||||
$QEMU_IO_PROG -c 'read -P 42 0 64k' \
|
||||
"json:{'driver': 'raw', 'file': {'driver': '$IMGFMT', 'file': {'filename': '$TEST_IMG'}}}" \
|
||||
| _filter_qemu_io
|
||||
|
||||
# success, all done
|
||||
echo
|
||||
echo '*** done'
|
||||
rm -f $seq.full
|
||||
status=0
|
15
tests/qemu-iotests/120.out
Normal file
15
tests/qemu-iotests/120.out
Normal file
|
@ -0,0 +1,15 @@
|
|||
QA output created by 120
|
||||
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
|
||||
QMP_VERSION
|
||||
{"return": {}}
|
||||
wrote 65536/65536 bytes at offset 0
|
||||
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
||||
{"return": ""}
|
||||
{"return": {}}
|
||||
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN"}
|
||||
read 65536/65536 bytes at offset 0
|
||||
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
||||
read 65536/65536 bytes at offset 0
|
||||
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
||||
|
||||
*** done
|
|
@ -125,7 +125,7 @@ class TestIncrementalBackup(iotests.QMPTestCase):
|
|||
|
||||
event = self.vm.event_wait(name="BLOCK_JOB_COMPLETED",
|
||||
match={'data': {'device': kwargs['device']}})
|
||||
self.assertIsNotNone(event)
|
||||
self.assertNotEqual(event, None)
|
||||
|
||||
try:
|
||||
failure = self.dictpath(event, 'data/error')
|
||||
|
|
|
@ -29,6 +29,7 @@ tmp=/tmp/$$
|
|||
status=1 # failure is the default!
|
||||
|
||||
devname="eiodev$$"
|
||||
sudo=""
|
||||
|
||||
_setup_eiodev()
|
||||
{
|
||||
|
@ -37,6 +38,7 @@ _setup_eiodev()
|
|||
echo "0 $((1024 * 1024 * 1024 / 512)) error" | \
|
||||
$cmd dmsetup create "$devname" 2>/dev/null
|
||||
if [ "$?" -eq 0 ]; then
|
||||
sudo="$cmd"
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
@ -74,7 +76,7 @@ TEST_IMG="/dev/mapper/$devname"
|
|||
echo
|
||||
echo "== reading from error device =="
|
||||
# Opening image should succeed but the read operation should fail
|
||||
$QEMU_IO --format "$IMGFMT" --nocache -c "read 0 65536" "$TEST_IMG" | _filter_qemu_io
|
||||
$sudo $QEMU_IO --format "$IMGFMT" --nocache -c "read 0 65536" "$TEST_IMG" | _filter_qemu_io
|
||||
|
||||
# success, all done
|
||||
echo "*** done"
|
||||
|
|
|
@ -121,6 +121,8 @@
|
|||
114 rw auto quick
|
||||
115 rw auto
|
||||
116 rw auto quick
|
||||
119 rw auto quick
|
||||
120 rw auto quick
|
||||
121 rw auto
|
||||
122 rw auto
|
||||
123 rw auto quick
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue