mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 08:13:54 -06:00
Block layer patches
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAABAgAGBQJW+7EyAAoJEH8JsnLIjy/WzXEP/0grmb7+Pu36dT835sLQonzB eIK5WIIlVDQsvW/pRXefsRZiZxlXPPMBfk5VmegtcjKycIDxZ8thDa4wOQMzMuD2 nOGyG0lo7tLcx+/t2P6sICGYLpHgvfbObtnEQuSpi6wk2fg6Mg3K9Nhxqs8kyn0B ADs8Bx+FrzSK4rOVfgZP9AvLJUgz1/Keq4i8pdIIBuXP/ZQOQlaDQwF4IgxCXBJL ETS0q3JySiy6F1nt5HNzj8AcJFUEYVqUc+Og2/lry1/ZR3r/iaX63sRKqlb/kV/J g/Hh+075D0RQlp1I4Nl/0MvBBAYZ53JmURLc8nFFnFF8+vwiLxZR5LkwNkMfdyrI masbxmhEpHHuAqdOabSp4lSNIGYarKSc3n/HrC5lMGBNnxPuWfeM4t88JlYUSxKu Km9ofhdaTqDXDm5P2l4nrJcCMwOzVZaddaZYpj6vAxuRpCe91rbZZVvhtjHe6WE7 jspMLzcr5yUlOBa8+hPvWiIq29U+qnEdTAqq+3sYzvN2cvTNsveRgQMG7J+c1Bsn 2EWZz+m+ni2Uz+mDKX4oC6dqwcAjg+RB/b1I5Zsf6kEpoyq+mULdruevE6lFVHhX bMKKXOxJErxc40IrvXfAAYLJzbZyMBD3V5cbulOqIJiPAio94F8WEuye1gacEi7g rwpsqg/wi7jwc9pWsBcr =+NOQ -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging Block layer patches # gpg: Signature made Wed 30 Mar 2016 11:57:54 BST using RSA key ID C88F2FD6 # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" * remotes/kevin/tags/for-upstream: (48 commits) iotests: Test qemu-img convert -S 0 behavior block/null-{co,aio}: Implement get_block_status() block/null-{co,aio}: Allow reading zeroes qemu-img: Fix preallocation with -S 0 for convert block: Remove bdrv_(set_)enable_write_cache() block: Remove BDRV_O_CACHE_WB block: Remove bdrv_parse_cache_flags() qemu-io: Use bdrv_parse_cache_mode() in reopen_f() block: Use bdrv_parse_cache_mode() in drive_init() raw: Support BDRV_REQ_FUA nbd: Support BDRV_REQ_FUA iscsi: Support BDRV_REQ_FUA block: Introduce bdrv_co_writev_flags() block/qapi: Use blk_enable_write_cache() block: Move enable_write_cache to BB level block: Handle flush error in bdrv_pwrite_sync() block: Always set writeback mode in blk_new_open() block: blockdev_init(): Call blk_set_enable_write_cache() explicitly xen_disk: Call blk_set_enable_write_cache() explicitly qemu-img: Call blk_set_enable_write_cache() explicitly ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
b9c27e7ae6
58 changed files with 4014 additions and 544 deletions
|
@ -187,12 +187,6 @@ qemu-img create -f qcow2 -o encryption=off TEST_DIR/t.qcow2 64M
|
|||
Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16
|
||||
|
||||
qemu-img create -f qcow2 -o encryption=on TEST_DIR/t.qcow2 64M
|
||||
qemu-img: Encrypted images are deprecated
|
||||
Support for them will be removed in a future release.
|
||||
You can use 'qemu-img convert' to convert your image to an unencrypted one.
|
||||
qemu-img: Encrypted images are deprecated
|
||||
Support for them will be removed in a future release.
|
||||
You can use 'qemu-img convert' to convert your image to an unencrypted one.
|
||||
Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 size=67108864 encryption=on cluster_size=65536 lazy_refcounts=off refcount_bits=16
|
||||
|
||||
== Check lazy_refcounts option (only with v3) ==
|
||||
|
|
|
@ -218,7 +218,7 @@ run_qemu -drive driver=null-co,cache=invalid_value
|
|||
|
||||
for cache in writeback writethrough unsafe invalid_value; do
|
||||
echo -e "info block\ninfo block file\ninfo block backing\ninfo block backing-file" | \
|
||||
run_qemu -drive file="$TEST_IMG",cache=$cache,backing.file.filename="$TEST_IMG.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=$device_id -nodefaults
|
||||
run_qemu -drive file="$TEST_IMG",cache=$cache,backing.file.filename="$TEST_IMG.base",backing.cache.no-flush=on,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,if=none,id=$device_id -nodefaults
|
||||
done
|
||||
|
||||
echo
|
||||
|
|
|
@ -239,7 +239,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) i[K[Din[K[D[Dinf[K[D[D[Dinfo[K[D[D[D[Dinfo [K[D[D[D[D[Dinfo b[K[D[D[D[D[D[Dinfo bl[K[D[D[D[D[D[D[Dinfo blo[K[D[D[D[D[D[D[D[Dinfo bloc[K[D[D[D[D[D[D[D[D[Dinfo block[K
|
||||
drive0 (NODE_NAME): TEST_DIR/t.qcow2 (qcow2)
|
||||
|
@ -259,7 +259,7 @@ backing-file: TEST_DIR/t.qcow2.base (file, read-only)
|
|||
Cache mode: writeback, ignore flushes
|
||||
(qemu) q[K[Dqu[K[D[Dqui[K[D[D[Dquit[K
|
||||
|
||||
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) i[K[Din[K[D[Dinf[K[D[D[Dinfo[K[D[D[D[Dinfo [K[D[D[D[D[Dinfo b[K[D[D[D[D[D[Dinfo bl[K[D[D[D[D[D[D[Dinfo blo[K[D[D[D[D[D[D[D[Dinfo bloc[K[D[D[D[D[D[D[D[D[Dinfo block[K
|
||||
drive0 (NODE_NAME): TEST_DIR/t.qcow2 (qcow2)
|
||||
|
@ -279,7 +279,7 @@ backing-file: TEST_DIR/t.qcow2.base (file, read-only)
|
|||
Cache mode: writeback, ignore flushes
|
||||
(qemu) q[K[Dqu[K[D[Dqui[K[D[D[Dquit[K
|
||||
|
||||
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) i[K[Din[K[D[Dinf[K[D[D[Dinfo[K[D[D[D[Dinfo [K[D[D[D[D[Dinfo b[K[D[D[D[D[D[Dinfo bl[K[D[D[D[D[D[D[Dinfo blo[K[D[D[D[D[D[D[D[Dinfo bloc[K[D[D[D[D[D[D[D[D[Dinfo block[K
|
||||
drive0 (NODE_NAME): TEST_DIR/t.qcow2 (qcow2)
|
||||
|
@ -299,8 +299,8 @@ backing-file: TEST_DIR/t.qcow2.base (file, read-only)
|
|||
Cache mode: writeback, ignore flushes
|
||||
(qemu) q[K[Dqu[K[D[Dqui[K[D[D[Dquit[K
|
||||
|
||||
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 ===
|
||||
|
|
|
@ -45,7 +45,8 @@ function do_run_qemu()
|
|||
|
||||
function run_qemu()
|
||||
{
|
||||
do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp | _filter_qemu \
|
||||
do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp \
|
||||
| _filter_qemu | _filter_imgfmt \
|
||||
| sed -e 's/\("actual-size":\s*\)[0-9]\+/\1SIZE/g'
|
||||
}
|
||||
|
||||
|
|
|
@ -38,19 +38,14 @@ QMP_VERSION
|
|||
|
||||
=== Encrypted image ===
|
||||
|
||||
qemu-img: Encrypted images are deprecated
|
||||
Support for them will be removed in a future release.
|
||||
You can use 'qemu-img convert' to convert your image to an unencrypted one.
|
||||
qemu-img: Encrypted images are deprecated
|
||||
Support for them will be removed in a future release.
|
||||
You can use 'qemu-img convert' to convert your image to an unencrypted one.
|
||||
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 encryption=on
|
||||
Testing: -S
|
||||
QMP_VERSION
|
||||
{"return": {}}
|
||||
Encrypted images are deprecated
|
||||
Support for them will be removed in a future release.
|
||||
You can use 'qemu-img convert' to convert your image to an unencrypted one.
|
||||
IMGFMT built-in AES encryption is deprecated
|
||||
Support for it will be removed in a future release.
|
||||
You can use 'qemu-img convert' to switch to an
|
||||
unencrypted IMGFMT image, or a LUKS raw image.
|
||||
{"error": {"class": "GenericError", "desc": "blockdev-add doesn't support encrypted devices"}}
|
||||
{"return": {}}
|
||||
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN"}
|
||||
|
@ -58,9 +53,10 @@ You can use 'qemu-img convert' to convert your image to an unencrypted one.
|
|||
Testing:
|
||||
QMP_VERSION
|
||||
{"return": {}}
|
||||
Encrypted images are deprecated
|
||||
Support for them will be removed in a future release.
|
||||
You can use 'qemu-img convert' to convert your image to an unencrypted one.
|
||||
IMGFMT built-in AES encryption is deprecated
|
||||
Support for it will be removed in a future release.
|
||||
You can use 'qemu-img convert' to switch to an
|
||||
unencrypted IMGFMT image, or a LUKS raw image.
|
||||
{"error": {"class": "GenericError", "desc": "Guest must be stopped for opening of encrypted image"}}
|
||||
{"return": {}}
|
||||
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN"}
|
||||
|
@ -68,12 +64,6 @@ You can use 'qemu-img convert' to convert your image to an unencrypted one.
|
|||
|
||||
=== Missing driver ===
|
||||
|
||||
qemu-img: Encrypted images are deprecated
|
||||
Support for them will be removed in a future release.
|
||||
You can use 'qemu-img convert' to convert your image to an unencrypted one.
|
||||
qemu-img: Encrypted images are deprecated
|
||||
Support for them will be removed in a future release.
|
||||
You can use 'qemu-img convert' to convert your image to an unencrypted one.
|
||||
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 encryption=on
|
||||
Testing: -S
|
||||
QMP_VERSION
|
||||
|
|
|
@ -112,16 +112,14 @@ read 3145728/3145728 bytes at offset 0
|
|||
3 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
||||
read 63963136/63963136 bytes at offset 3145728
|
||||
61 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
||||
[{ "start": 0, "length": 6291456, "depth": 0, "zero": false, "data": true, "offset": 327680},
|
||||
{ "start": 6291456, "length": 60817408, "depth": 0, "zero": true, "data": false}]
|
||||
[{ "start": 0, "length": 67108864, "depth": 0, "zero": false, "data": true, "offset": 327680}]
|
||||
|
||||
convert -c -S 0:
|
||||
read 3145728/3145728 bytes at offset 0
|
||||
3 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
||||
read 63963136/63963136 bytes at offset 3145728
|
||||
61 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
||||
[{ "start": 0, "length": 6291456, "depth": 0, "zero": false, "data": true},
|
||||
{ "start": 6291456, "length": 60817408, "depth": 0, "zero": true, "data": false}]
|
||||
[{ "start": 0, "length": 67108864, "depth": 0, "zero": false, "data": true}]
|
||||
Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=67108864
|
||||
wrote 33554432/33554432 bytes at offset 0
|
||||
32 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
||||
|
|
|
@ -1,43 +1,25 @@
|
|||
QA output created by 134
|
||||
qemu-img: Encrypted images are deprecated
|
||||
Support for them will be removed in a future release.
|
||||
You can use 'qemu-img convert' to convert your image to an unencrypted one.
|
||||
qemu-img: Encrypted images are deprecated
|
||||
Support for them will be removed in a future release.
|
||||
You can use 'qemu-img convert' to convert your image to an unencrypted one.
|
||||
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 encryption=on
|
||||
|
||||
== reading whole image ==
|
||||
Encrypted images are deprecated
|
||||
Support for them will be removed in a future release.
|
||||
You can use 'qemu-img convert' to convert your image to an unencrypted one.
|
||||
Disk image 'TEST_DIR/t.qcow2' is encrypted.
|
||||
password:
|
||||
read 134217728/134217728 bytes at offset 0
|
||||
128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
||||
|
||||
== rewriting whole image ==
|
||||
Encrypted images are deprecated
|
||||
Support for them will be removed in a future release.
|
||||
You can use 'qemu-img convert' to convert your image to an unencrypted one.
|
||||
Disk image 'TEST_DIR/t.qcow2' is encrypted.
|
||||
password:
|
||||
wrote 134217728/134217728 bytes at offset 0
|
||||
128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
||||
|
||||
== verify pattern ==
|
||||
Encrypted images are deprecated
|
||||
Support for them will be removed in a future release.
|
||||
You can use 'qemu-img convert' to convert your image to an unencrypted one.
|
||||
Disk image 'TEST_DIR/t.qcow2' is encrypted.
|
||||
password:
|
||||
read 134217728/134217728 bytes at offset 0
|
||||
128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
||||
|
||||
== verify pattern failure with wrong password ==
|
||||
Encrypted images are deprecated
|
||||
Support for them will be removed in a future release.
|
||||
You can use 'qemu-img convert' to convert your image to an unencrypted one.
|
||||
Disk image 'TEST_DIR/t.qcow2' is encrypted.
|
||||
password:
|
||||
Pattern verification failed at offset 0, 134217728 bytes
|
||||
|
|
|
@ -96,36 +96,36 @@ function check_cache_all()
|
|||
# bs->backing
|
||||
|
||||
echo -e "cache.direct=on on none0"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$files","$ids",cache.direct=on | grep "Cache"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$files","$ids",cache.direct=on | grep -e "Cache" -e "[Cc]annot|[Cc]ould not|[Cc]an't"
|
||||
echo -e "\ncache.direct=on on file"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$files","$ids",file.cache.direct=on | grep "Cache"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$files","$ids",file.cache.direct=on | grep -e "Cache" -e "[Cc]annot|[Cc]ould not|[Cc]an't"
|
||||
echo -e "\ncache.direct=on on backing"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$files","$ids",backing.cache.direct=on | grep "Cache"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$files","$ids",backing.cache.direct=on | grep -e "Cache" -e "[Cc]annot|[Cc]ould not|[Cc]an't"
|
||||
echo -e "\ncache.direct=on on backing-file"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$files","$ids",backing.file.cache.direct=on | grep "Cache"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$files","$ids",backing.file.cache.direct=on | grep -e "Cache" -e "[Cc]annot|[Cc]ould not|[Cc]an't"
|
||||
|
||||
# cache.writeback is supposed to be inherited by bs->backing; bs->file
|
||||
# always gets cache.writeback=on
|
||||
|
||||
echo -e "\n\ncache.writeback=off on none0"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$files","$ids",cache.writeback=off | grep "Cache"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$files","$ids",cache.writeback=off | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
|
||||
echo -e "\ncache.writeback=off on file"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$files","$ids",file.cache.writeback=off | grep "Cache"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$files","$ids",file.cache.writeback=off | grep -e "doesn't" -e "does not"
|
||||
echo -e "\ncache.writeback=off on backing"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$files","$ids",backing.cache.writeback=off | grep "Cache"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$files","$ids",backing.cache.writeback=off | grep -e "doesn't" -e "does not"
|
||||
echo -e "\ncache.writeback=off on backing-file"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$files","$ids",backing.file.cache.writeback=off | grep "Cache"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$files","$ids",backing.file.cache.writeback=off | grep -e "doesn't" -e "does not"
|
||||
|
||||
# cache.no-flush is supposed to be inherited by both bs->file and bs->backing
|
||||
|
||||
echo -e "\n\ncache.no-flush=on on none0"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$files","$ids",cache.no-flush=on | grep "Cache"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$files","$ids",cache.no-flush=on | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
|
||||
echo -e "\ncache.no-flush=on on file"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$files","$ids",file.cache.no-flush=on | grep "Cache"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$files","$ids",file.cache.no-flush=on | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
|
||||
echo -e "\ncache.no-flush=on on backing"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$files","$ids",backing.cache.no-flush=on | grep "Cache"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$files","$ids",backing.cache.no-flush=on | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
|
||||
echo -e "\ncache.no-flush=on on backing-file"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$files","$ids",backing.file.cache.no-flush=on | grep "Cache"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$files","$ids",backing.file.cache.no-flush=on | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
|
||||
}
|
||||
|
||||
echo
|
||||
|
@ -134,7 +134,8 @@ echo
|
|||
|
||||
# First check the inherited cache mode after opening the image.
|
||||
|
||||
hmp_cmds="info block image
|
||||
hmp_cmds="info block none0
|
||||
info block image
|
||||
info block file
|
||||
info block backing
|
||||
info block backing-file"
|
||||
|
@ -164,6 +165,7 @@ echo
|
|||
# new cache mode is specified in the flags, not as an option.
|
||||
|
||||
hmp_cmds='qemu-io none0 "reopen -c none"
|
||||
info block none0
|
||||
info block image
|
||||
info block file
|
||||
info block backing
|
||||
|
@ -179,6 +181,7 @@ echo
|
|||
# new cache mode is specified as an option, not in the flags.
|
||||
|
||||
hmp_cmds='qemu-io none0 "reopen -o cache.direct=on"
|
||||
info block none0
|
||||
info block image
|
||||
info block file
|
||||
info block backing
|
||||
|
@ -213,12 +216,13 @@ echo
|
|||
# BDS initialised with the json: pseudo-protocol, but still have it inherit
|
||||
# options from its parent node.
|
||||
|
||||
hmp_cmds="qemu-io none0 \"reopen -o cache.writeback=off,cache.direct=on,cache.no-flush=on\"
|
||||
hmp_cmds="qemu-io none0 \"reopen -o cache.direct=on,cache.no-flush=on\"
|
||||
info block none0
|
||||
info block image
|
||||
info block blkdebug
|
||||
info block file"
|
||||
|
||||
echo "$hmp_cmds" | run_qemu -drive if=none,file="blkdebug::json:{\"filename\":\"$TEST_IMG\",,\"cache\":{\"writeback\":false,,\"direct\":false}}",node-name=image,file.node-name=blkdebug,file.image.node-name=file | grep "Cache"
|
||||
echo "$hmp_cmds" | run_qemu -drive if=none,file="blkdebug::json:{\"filename\":\"$TEST_IMG\",,\"cache\":{\"direct\":false}}",node-name=image,file.node-name=blkdebug,file.image.node-name=file | grep "Cache"
|
||||
|
||||
echo
|
||||
echo "=== Check that referenced BDSes don't inherit ==="
|
||||
|
@ -234,35 +238,35 @@ function check_cache_all_separate()
|
|||
# Check cache.direct
|
||||
|
||||
echo -e "cache.direct=on on blk"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk" -drive "$drv_file" -drive "$drv_img",cache.direct=on | grep "Cache"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk" -drive "$drv_file" -drive "$drv_img",cache.direct=on | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
|
||||
echo -e "\ncache.direct=on on file"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk" -drive "$drv_file",cache.direct=on -drive "$drv_img" | grep "Cache"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk" -drive "$drv_file",cache.direct=on -drive "$drv_img" | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
|
||||
echo -e "\ncache.direct=on on backing"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk",cache.direct=on -drive "$drv_file" -drive "$drv_img" | grep "Cache"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk",cache.direct=on -drive "$drv_file" -drive "$drv_img" | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
|
||||
echo -e "\ncache.direct=on on backing-file"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile",cache.direct=on -drive "$drv_bk" -drive "$drv_file" -drive "$drv_img" | grep "Cache"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile",cache.direct=on -drive "$drv_bk" -drive "$drv_file" -drive "$drv_img" | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
|
||||
|
||||
# Check cache.writeback
|
||||
|
||||
echo -e "\n\ncache.writeback=off on blk"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk" -drive "$drv_file" -drive "$drv_img",cache.writeback=off | grep "Cache"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk" -drive "$drv_file" -drive "$drv_img",cache.writeback=off | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
|
||||
echo -e "\ncache.writeback=off on file"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk" -drive "$drv_file",cache.writeback=off -drive "$drv_img" | grep "Cache"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk" -drive "$drv_file",cache.writeback=off -drive "$drv_img" | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
|
||||
echo -e "\ncache.writeback=off on backing"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk",cache.writeback=off -drive "$drv_file" -drive "$drv_img" | grep "Cache"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk",cache.writeback=off -drive "$drv_file" -drive "$drv_img" | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
|
||||
echo -e "\ncache.writeback=off on backing-file"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile",cache.writeback=off -drive "$drv_bk" -drive "$drv_file" -drive "$drv_img" | grep "Cache"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile",cache.writeback=off -drive "$drv_bk" -drive "$drv_file" -drive "$drv_img" | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
|
||||
|
||||
# Check cache.no-flush
|
||||
|
||||
echo -e "\n\ncache.no-flush=on on blk"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk" -drive "$drv_file" -drive "$drv_img",cache.no-flush=on | grep "Cache"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk" -drive "$drv_file" -drive "$drv_img",cache.no-flush=on | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
|
||||
echo -e "\ncache.no-flush=on on file"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk" -drive "$drv_file",cache.no-flush=on -drive "$drv_img" | grep "Cache"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk" -drive "$drv_file",cache.no-flush=on -drive "$drv_img" | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
|
||||
echo -e "\ncache.no-flush=on on backing"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk",cache.no-flush=on -drive "$drv_file" -drive "$drv_img" | grep "Cache"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile" -drive "$drv_bk",cache.no-flush=on -drive "$drv_file" -drive "$drv_img" | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
|
||||
echo -e "\ncache.no-flush=on on backing-file"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile",cache.no-flush=on -drive "$drv_bk" -drive "$drv_file" -drive "$drv_img" | grep "Cache"
|
||||
echo "$hmp_cmds" | run_qemu -drive "$drv_bkfile",cache.no-flush=on -drive "$drv_bk" -drive "$drv_file" -drive "$drv_img" | grep -e "Cache" -e "[Cc]annot\|[Cc]ould not\|[Cc]an't"
|
||||
}
|
||||
|
||||
echo
|
||||
|
@ -321,6 +325,7 @@ echo "--- Basic reopen ---"
|
|||
echo
|
||||
|
||||
hmp_cmds='qemu-io none0 "reopen -o backing.cache.direct=on"
|
||||
info block none0
|
||||
info block image
|
||||
info block file
|
||||
info block backing
|
||||
|
@ -338,8 +343,8 @@ echo
|
|||
# TODO Implement node-name support for 'qemu-io' HMP command for -c
|
||||
# Can use only -o to access child node options for now
|
||||
|
||||
hmp_cmds="qemu-io none0 \"reopen -o file.cache.writeback=off,file.cache.direct=off,file.cache.no-flush=off\"
|
||||
qemu-io none0 \"reopen -o backing.file.cache.writeback=on,backing.file.cache.direct=off,backing.file.cache.no-flush=on\"
|
||||
hmp_cmds="qemu-io none0 \"reopen -o file.cache.direct=off,file.cache.no-flush=off\"
|
||||
qemu-io none0 \"reopen -o backing.file.cache.direct=off,backing.file.cache.no-flush=on\"
|
||||
qemu-io none0 \"reopen -c none\"
|
||||
info block image
|
||||
info block file
|
||||
|
|
|
@ -39,14 +39,17 @@ cache.direct=on on none0
|
|||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
|
||||
cache.direct=on on file
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
|
||||
cache.direct=on on backing
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback, direct
|
||||
|
@ -56,32 +59,25 @@ cache.direct=on on backing-file
|
|||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback, direct
|
||||
|
||||
|
||||
cache.writeback=off on none0
|
||||
Cache mode: writethrough
|
||||
Cache mode: writeback
|
||||
Cache mode: writethrough
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
|
||||
cache.writeback=off on file
|
||||
Cache mode: writeback
|
||||
Cache mode: writethrough
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,file.cache.writeback=off: Block protocol 'file' doesn't support the option 'cache.writeback'
|
||||
|
||||
cache.writeback=off on backing
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writethrough
|
||||
Cache mode: writeback
|
||||
QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.cache.writeback=off: Could not open backing file: Block format 'qcow2' does not support the option 'cache.writeback'
|
||||
|
||||
cache.writeback=off on backing-file
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writethrough
|
||||
QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.file.cache.writeback=off: Could not open backing file: Block protocol 'file' doesn't support the option 'cache.writeback'
|
||||
|
||||
|
||||
cache.no-flush=on on none0
|
||||
|
@ -89,14 +85,17 @@ cache.no-flush=on on none0
|
|||
Cache mode: writeback, ignore flushes
|
||||
Cache mode: writeback, ignore flushes
|
||||
Cache mode: writeback, ignore flushes
|
||||
Cache mode: writeback, ignore flushes
|
||||
|
||||
cache.no-flush=on on file
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback, ignore flushes
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
|
||||
cache.no-flush=on on backing
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback, ignore flushes
|
||||
|
@ -106,6 +105,7 @@ cache.no-flush=on on backing-file
|
|||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback, ignore flushes
|
||||
|
||||
--- Cache modes after reopen (live snapshot) ---
|
||||
|
@ -140,32 +140,20 @@ cache.direct=on on backing-file
|
|||
|
||||
|
||||
cache.writeback=off on none0
|
||||
Cache mode: writethrough
|
||||
Cache mode: writethrough
|
||||
Cache mode: writeback
|
||||
Cache mode: writethrough
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
|
||||
cache.writeback=off on file
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writethrough
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,file.cache.writeback=off: Block protocol 'file' doesn't support the option 'cache.writeback'
|
||||
|
||||
cache.writeback=off on backing
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writethrough
|
||||
Cache mode: writeback
|
||||
QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.cache.writeback=off: Could not open backing file: Block format 'qcow2' does not support the option 'cache.writeback'
|
||||
|
||||
cache.writeback=off on backing-file
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writethrough
|
||||
QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.file.cache.writeback=off: Could not open backing file: Block protocol 'file' doesn't support the option 'cache.writeback'
|
||||
|
||||
|
||||
cache.no-flush=on on none0
|
||||
|
@ -203,24 +191,28 @@ cache.direct=on on none0
|
|||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
|
||||
cache.direct=on on file
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
|
||||
cache.direct=on on backing
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
|
||||
cache.direct=on on backing-file
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
|
||||
|
||||
cache.writeback=off on none0
|
||||
|
@ -228,24 +220,16 @@ cache.writeback=off on none0
|
|||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
|
||||
cache.writeback=off on file
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writethrough, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,file.cache.writeback=off: Block protocol 'file' doesn't support the option 'cache.writeback'
|
||||
|
||||
cache.writeback=off on backing
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writethrough, direct
|
||||
Cache mode: writeback, direct
|
||||
QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.cache.writeback=off: Could not open backing file: Block format 'qcow2' does not support the option 'cache.writeback'
|
||||
|
||||
cache.writeback=off on backing-file
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writethrough, direct
|
||||
QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.file.cache.writeback=off: Could not open backing file: Block protocol 'file' doesn't support the option 'cache.writeback'
|
||||
|
||||
|
||||
cache.no-flush=on on none0
|
||||
|
@ -253,14 +237,17 @@ cache.no-flush=on on none0
|
|||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
|
||||
cache.no-flush=on on file
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct, ignore flushes
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
|
||||
cache.no-flush=on on backing
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct, ignore flushes
|
||||
|
@ -270,6 +257,7 @@ cache.no-flush=on on backing-file
|
|||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct, ignore flushes
|
||||
|
||||
--- Change cache modes with reopen (qemu-io command, options) ---
|
||||
|
@ -279,49 +267,45 @@ cache.direct=on on none0
|
|||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
|
||||
cache.direct=on on file
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
|
||||
cache.direct=on on backing
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
|
||||
cache.direct=on on backing-file
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
|
||||
|
||||
cache.writeback=off on none0
|
||||
Cache mode: writethrough, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writethrough, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
|
||||
cache.writeback=off on file
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writethrough, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,file.cache.writeback=off: Block protocol 'file' doesn't support the option 'cache.writeback'
|
||||
|
||||
cache.writeback=off on backing
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writethrough, direct
|
||||
Cache mode: writeback, direct
|
||||
QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.cache.writeback=off: Could not open backing file: Block format 'qcow2' does not support the option 'cache.writeback'
|
||||
|
||||
cache.writeback=off on backing-file
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writethrough, direct
|
||||
QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.file.cache.writeback=off: Could not open backing file: Block protocol 'file' doesn't support the option 'cache.writeback'
|
||||
|
||||
|
||||
cache.no-flush=on on none0
|
||||
|
@ -329,14 +313,17 @@ cache.no-flush=on on none0
|
|||
Cache mode: writeback, direct, ignore flushes
|
||||
Cache mode: writeback, direct, ignore flushes
|
||||
Cache mode: writeback, direct, ignore flushes
|
||||
Cache mode: writeback, direct, ignore flushes
|
||||
|
||||
cache.no-flush=on on file
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct, ignore flushes
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
|
||||
cache.no-flush=on on backing
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct, ignore flushes
|
||||
|
@ -346,6 +333,7 @@ cache.no-flush=on on backing-file
|
|||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct, ignore flushes
|
||||
|
||||
--- Change cache modes after snapshot ---
|
||||
|
@ -381,31 +369,19 @@ cache.direct=on on backing-file
|
|||
|
||||
cache.writeback=off on none0
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writethrough
|
||||
Cache mode: writeback
|
||||
Cache mode: writethrough
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
|
||||
cache.writeback=off on file
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback
|
||||
Cache mode: writethrough
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,file.cache.writeback=off: Block protocol 'file' doesn't support the option 'cache.writeback'
|
||||
|
||||
cache.writeback=off on backing
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writethrough
|
||||
Cache mode: writeback
|
||||
QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.cache.writeback=off: Could not open backing file: Block format 'qcow2' does not support the option 'cache.writeback'
|
||||
|
||||
cache.writeback=off on backing-file
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writethrough
|
||||
QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.file.cache.writeback=off: Could not open backing file: Block protocol 'file' doesn't support the option 'cache.writeback'
|
||||
|
||||
|
||||
cache.no-flush=on on none0
|
||||
|
@ -438,9 +414,10 @@ cache.no-flush=on on backing-file
|
|||
|
||||
--- Change cache mode in parent, child has explicit option in JSON ---
|
||||
|
||||
Cache mode: writethrough, direct, ignore flushes
|
||||
Cache mode: writeback, direct, ignore flushes
|
||||
Cache mode: writethrough, ignore flushes
|
||||
Cache mode: writeback, direct, ignore flushes
|
||||
Cache mode: writeback, direct, ignore flushes
|
||||
Cache mode: writeback, ignore flushes
|
||||
|
||||
=== Check that referenced BDSes don't inherit ===
|
||||
|
||||
|
@ -473,28 +450,28 @@ cache.direct=on on backing-file
|
|||
|
||||
|
||||
cache.writeback=off on blk
|
||||
Cache mode: writethrough
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
|
||||
cache.writeback=off on file
|
||||
Cache mode: writeback
|
||||
Cache mode: writethrough
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
|
||||
cache.writeback=off on backing
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writethrough
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
|
||||
cache.writeback=off on backing-file
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writethrough
|
||||
Cache mode: writeback
|
||||
|
||||
|
||||
cache.no-flush=on on blk
|
||||
|
@ -554,7 +531,7 @@ cache.direct=on on backing-file
|
|||
|
||||
cache.writeback=off on blk
|
||||
Cache mode: writethrough
|
||||
Cache mode: writethrough
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
|
@ -562,7 +539,7 @@ cache.writeback=off on blk
|
|||
cache.writeback=off on file
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writethrough
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
|
||||
|
@ -570,7 +547,7 @@ cache.writeback=off on backing
|
|||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writethrough
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
|
||||
cache.writeback=off on backing-file
|
||||
|
@ -578,7 +555,7 @@ cache.writeback=off on backing-file
|
|||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writethrough
|
||||
Cache mode: writeback
|
||||
|
||||
|
||||
cache.no-flush=on on blk
|
||||
|
@ -644,21 +621,21 @@ cache.writeback=off on blk
|
|||
|
||||
cache.writeback=off on file
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writethrough
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
|
||||
cache.writeback=off on backing
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback
|
||||
Cache mode: writethrough
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
|
||||
cache.writeback=off on backing-file
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writethrough
|
||||
Cache mode: writeback
|
||||
|
||||
|
||||
cache.no-flush=on on blk
|
||||
|
@ -695,20 +672,24 @@ cache.direct=on on none0
|
|||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
|
||||
cache.direct=on on file
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
|
||||
cache.direct=on on backing
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
|
||||
cache.direct=on on backing-file
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback, direct
|
||||
|
@ -718,47 +699,43 @@ cache.direct=on on backing-file
|
|||
cache.writeback=off on none0
|
||||
Cache mode: writethrough
|
||||
Cache mode: writeback
|
||||
Cache mode: writethrough, direct
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
|
||||
cache.writeback=off on file
|
||||
Cache mode: writeback
|
||||
Cache mode: writethrough
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,file.cache.writeback=off: Block protocol 'file' doesn't support the option 'cache.writeback'
|
||||
|
||||
cache.writeback=off on backing
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writethrough, direct
|
||||
Cache mode: writeback, direct
|
||||
QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.cache.writeback=off: Could not open backing file: Block format 'qcow2' does not support the option 'cache.writeback'
|
||||
|
||||
cache.writeback=off on backing-file
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writethrough, direct
|
||||
QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,backing.file.filename=TEST_DIR/t.qcow2.base,node-name=image,backing.node-name=backing,backing.file.node-name=backing-file,file.node-name=file,backing.file.cache.writeback=off: Could not open backing file: Block protocol 'file' doesn't support the option 'cache.writeback'
|
||||
|
||||
|
||||
cache.no-flush=on on none0
|
||||
Cache mode: writeback, ignore flushes
|
||||
Cache mode: writeback, ignore flushes
|
||||
Cache mode: writeback, ignore flushes
|
||||
Cache mode: writeback, direct, ignore flushes
|
||||
Cache mode: writeback, direct, ignore flushes
|
||||
|
||||
cache.no-flush=on on file
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback, ignore flushes
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, direct
|
||||
|
||||
cache.no-flush=on on backing
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback, direct, ignore flushes
|
||||
Cache mode: writeback, direct, ignore flushes
|
||||
|
||||
cache.no-flush=on on backing-file
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback, direct
|
||||
|
@ -767,7 +744,7 @@ cache.no-flush=on on backing-file
|
|||
--- Change cache mode after reopening child ---
|
||||
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writethrough
|
||||
Cache mode: writeback
|
||||
Cache mode: writeback, direct
|
||||
Cache mode: writeback, ignore flushes
|
||||
*** done
|
||||
|
|
519
tests/qemu-iotests/149
Executable file
519
tests/qemu-iotests/149
Executable file
|
@ -0,0 +1,519 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (C) 2016 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: Daniel P. Berrange <berrange@redhat.com>
|
||||
#
|
||||
# Exercise the QEMU 'luks' block driver to validate interoperability
|
||||
# with the Linux dm-crypt + cryptsetup implementation
|
||||
|
||||
import subprocess
|
||||
import os
|
||||
import os.path
|
||||
|
||||
import base64
|
||||
|
||||
import iotests
|
||||
|
||||
|
||||
class LUKSConfig(object):
|
||||
"""Represent configuration parameters for a single LUKS
|
||||
setup to be tested"""
|
||||
|
||||
def __init__(self, name, cipher, keylen, mode, ivgen,
|
||||
ivgen_hash, hash, password=None, passwords=None):
|
||||
|
||||
self.name = name
|
||||
self.cipher = cipher
|
||||
self.keylen = keylen
|
||||
self.mode = mode
|
||||
self.ivgen = ivgen
|
||||
self.ivgen_hash = ivgen_hash
|
||||
self.hash = hash
|
||||
|
||||
if passwords is not None:
|
||||
self.passwords = passwords
|
||||
else:
|
||||
self.passwords = {}
|
||||
|
||||
if password is None:
|
||||
self.passwords["0"] = "123456"
|
||||
else:
|
||||
self.passwords["0"] = password
|
||||
|
||||
def __repr__(self):
|
||||
return self.name
|
||||
|
||||
def image_name(self):
|
||||
return "luks-%s.img" % self.name
|
||||
|
||||
def image_path(self):
|
||||
return os.path.join(iotests.test_dir, self.image_name())
|
||||
|
||||
def device_name(self):
|
||||
return "qiotest-145-%s" % self.name
|
||||
|
||||
def device_path(self):
|
||||
return "/dev/mapper/" + self.device_name()
|
||||
|
||||
def first_password(self):
|
||||
for i in range(8):
|
||||
slot = str(i)
|
||||
if slot in self.passwords:
|
||||
return (self.passwords[slot], slot)
|
||||
raise Exception("No password found")
|
||||
|
||||
def first_password_base64(self):
|
||||
(pw, slot) = self.first_password()
|
||||
return base64.b64encode(pw)
|
||||
|
||||
def active_slots(self):
|
||||
slots = []
|
||||
for i in range(8):
|
||||
slot = str(i)
|
||||
if slot in self.passwords:
|
||||
slots.append(slot)
|
||||
return slots
|
||||
|
||||
def verify_passwordless_sudo():
|
||||
"""Check whether sudo is configured to allow
|
||||
password-less access to commands"""
|
||||
|
||||
args = ["sudo", "-n", "/bin/true"]
|
||||
|
||||
proc = subprocess.Popen(args,
|
||||
stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT)
|
||||
|
||||
msg = proc.communicate()[0]
|
||||
|
||||
if proc.returncode != 0:
|
||||
iotests.notrun('requires password-less sudo access: %s' % msg)
|
||||
|
||||
|
||||
def cryptsetup(args, password=None):
|
||||
"""Run the cryptsetup command in batch mode"""
|
||||
|
||||
fullargs = ["sudo", "cryptsetup", "-q", "-v"]
|
||||
fullargs.extend(args)
|
||||
|
||||
iotests.log(" ".join(fullargs), filters=[iotests.filter_test_dir])
|
||||
proc = subprocess.Popen(fullargs,
|
||||
stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT)
|
||||
|
||||
msg = proc.communicate(password)[0]
|
||||
|
||||
if proc.returncode != 0:
|
||||
raise Exception(msg)
|
||||
|
||||
|
||||
def cryptsetup_add_password(config, slot):
|
||||
"""Add another password to a LUKS key slot"""
|
||||
|
||||
(password, mainslot) = config.first_password()
|
||||
|
||||
pwfile = os.path.join(iotests.test_dir, "passwd.txt")
|
||||
with open(pwfile, "w") as fh:
|
||||
fh.write(config.passwords[slot])
|
||||
|
||||
try:
|
||||
args = ["luksAddKey", config.image_path(),
|
||||
"--key-slot", slot,
|
||||
"--key-file", "-",
|
||||
pwfile]
|
||||
|
||||
cryptsetup(args, password)
|
||||
finally:
|
||||
os.unlink(pwfile)
|
||||
|
||||
|
||||
def cryptsetup_format(config):
|
||||
"""Format a new LUKS volume with cryptsetup, adding the
|
||||
first key slot only"""
|
||||
|
||||
(password, slot) = config.first_password()
|
||||
|
||||
args = ["luksFormat"]
|
||||
cipher = config.cipher + "-" + config.mode + "-" + config.ivgen
|
||||
if config.ivgen_hash is not None:
|
||||
cipher = cipher + ":" + config.ivgen_hash
|
||||
args.extend(["--cipher", cipher])
|
||||
if config.mode == "xts":
|
||||
args.extend(["--key-size", str(config.keylen * 2)])
|
||||
else:
|
||||
args.extend(["--key-size", str(config.keylen)])
|
||||
if config.hash is not None:
|
||||
args.extend(["--hash", config.hash])
|
||||
args.extend(["--key-slot", slot])
|
||||
args.extend(["--key-file", "-"])
|
||||
args.append(config.image_path())
|
||||
|
||||
cryptsetup(args, password)
|
||||
|
||||
|
||||
def chown(config):
|
||||
"""Set the ownership of a open LUKS device to this user"""
|
||||
|
||||
path = config.device_path()
|
||||
|
||||
args = ["sudo", "chown", "%d:%d" % (os.getuid(), os.getgid()), path]
|
||||
iotests.log(" ".join(args), filters=[iotests.filter_chown])
|
||||
proc = subprocess.Popen(args,
|
||||
stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT)
|
||||
|
||||
msg = proc.communicate()[0]
|
||||
|
||||
if proc.returncode != 0:
|
||||
raise Exception("Cannot change owner on %s" % path)
|
||||
|
||||
|
||||
def cryptsetup_open(config):
|
||||
"""Open an image as a LUKS device"""
|
||||
|
||||
(password, slot) = config.first_password()
|
||||
|
||||
args = ["luksOpen", config.image_path(), config.device_name()]
|
||||
|
||||
cryptsetup(args, password)
|
||||
|
||||
|
||||
def cryptsetup_close(config):
|
||||
"""Close an active LUKS device """
|
||||
|
||||
args = ["luksClose", config.device_name()]
|
||||
cryptsetup(args)
|
||||
|
||||
|
||||
def delete_image(config):
|
||||
"""Delete a disk image"""
|
||||
|
||||
try:
|
||||
os.unlink(config.image_path())
|
||||
iotests.log("unlink %s" % config.image_path(),
|
||||
filters=[iotests.filter_test_dir])
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
|
||||
def create_image(config, size_mb):
|
||||
"""Create a bare disk image with requested size"""
|
||||
|
||||
delete_image(config)
|
||||
iotests.log("truncate %s --size %dMB" % (config.image_path(), size_mb),
|
||||
filters=[iotests.filter_test_dir])
|
||||
with open(config.image_path(), "w") as fn:
|
||||
fn.truncate(size_mb * 1024 * 1024)
|
||||
|
||||
|
||||
def qemu_img_create(config, size_mb):
|
||||
"""Create and format a disk image with LUKS using qemu-img"""
|
||||
|
||||
opts = [
|
||||
"key-secret=sec0",
|
||||
"cipher-alg=%s-%d" % (config.cipher, config.keylen),
|
||||
"cipher-mode=%s" % config.mode,
|
||||
"ivgen-alg=%s" % config.ivgen,
|
||||
"hash-alg=%s" % config.hash,
|
||||
]
|
||||
if config.ivgen_hash is not None:
|
||||
opts.append("ivgen-hash-alg=%s" % config.ivgen_hash)
|
||||
|
||||
args = ["create", "-f", "luks",
|
||||
"--object",
|
||||
("secret,id=sec0,data=%s,format=base64" %
|
||||
config.first_password_base64()),
|
||||
"-o", ",".join(opts),
|
||||
config.image_path(),
|
||||
"%dM" % size_mb]
|
||||
|
||||
iotests.log("qemu-img " + " ".join(args), filters=[iotests.filter_test_dir])
|
||||
iotests.log(iotests.qemu_img_pipe(*args), filters=[iotests.filter_test_dir])
|
||||
|
||||
def qemu_io_image_args(config, dev=False):
|
||||
"""Get the args for access an image or device with qemu-io"""
|
||||
|
||||
if dev:
|
||||
return [
|
||||
"--image-opts",
|
||||
"driver=file,filename=%s" % config.device_path()]
|
||||
else:
|
||||
return [
|
||||
"--object",
|
||||
("secret,id=sec0,data=%s,format=base64" %
|
||||
config.first_password_base64()),
|
||||
"--image-opts",
|
||||
("driver=luks,key-secret=sec0,file.filename=%s" %
|
||||
config.image_path())]
|
||||
|
||||
def qemu_io_write_pattern(config, pattern, offset_mb, size_mb, dev=False):
|
||||
"""Write a pattern of data to a LUKS image or device"""
|
||||
|
||||
args = ["-c", "write -P 0x%x %dM %dM" % (pattern, offset_mb, size_mb)]
|
||||
args.extend(qemu_io_image_args(config, dev))
|
||||
iotests.log("qemu-io " + " ".join(args), filters=[iotests.filter_test_dir])
|
||||
iotests.log(iotests.qemu_io(*args), filters=[iotests.filter_test_dir,
|
||||
iotests.filter_qemu_io])
|
||||
|
||||
|
||||
def qemu_io_read_pattern(config, pattern, offset_mb, size_mb, dev=False):
|
||||
"""Read a pattern of data to a LUKS image or device"""
|
||||
|
||||
args = ["-c", "read -P 0x%x %dM %dM" % (pattern, offset_mb, size_mb)]
|
||||
args.extend(qemu_io_image_args(config, dev))
|
||||
iotests.log("qemu-io " + " ".join(args), filters=[iotests.filter_test_dir])
|
||||
iotests.log(iotests.qemu_io(*args), filters=[iotests.filter_test_dir,
|
||||
iotests.filter_qemu_io])
|
||||
|
||||
|
||||
def test_once(config, qemu_img=False):
|
||||
"""Run the test with a desired LUKS configuration. Can either
|
||||
use qemu-img for creating the initial volume, or cryptsetup,
|
||||
in order to test interoperability in both directions"""
|
||||
|
||||
iotests.log("# ================= %s %s =================" % (
|
||||
"qemu-img" if qemu_img else "dm-crypt", config))
|
||||
|
||||
oneKB = 1024
|
||||
oneMB = oneKB * 1024
|
||||
oneGB = oneMB * 1024
|
||||
oneTB = oneGB * 1024
|
||||
|
||||
# 4 TB, so that we pass the 32-bit sector number boundary.
|
||||
# Important for testing correctness of some IV generators
|
||||
# The files are sparse, so not actually using this much space
|
||||
image_size = 4 * oneTB
|
||||
if qemu_img:
|
||||
iotests.log("# Create image")
|
||||
qemu_img_create(config, image_size / oneMB)
|
||||
else:
|
||||
iotests.log("# Create image")
|
||||
create_image(config, image_size / oneMB)
|
||||
|
||||
lowOffsetMB = 100
|
||||
highOffsetMB = 3 * oneTB / oneMB
|
||||
|
||||
try:
|
||||
if not qemu_img:
|
||||
iotests.log("# Format image")
|
||||
cryptsetup_format(config)
|
||||
|
||||
for slot in config.active_slots()[1:]:
|
||||
iotests.log("# Add password slot %s" % slot)
|
||||
cryptsetup_add_password(config, slot)
|
||||
|
||||
# First we'll open the image using cryptsetup and write a
|
||||
# known pattern of data that we'll then verify with QEMU
|
||||
|
||||
iotests.log("# Open dev")
|
||||
cryptsetup_open(config)
|
||||
|
||||
try:
|
||||
iotests.log("# Set dev owner")
|
||||
chown(config)
|
||||
|
||||
iotests.log("# Write test pattern 0xa7")
|
||||
qemu_io_write_pattern(config, 0xa7, lowOffsetMB, 10, dev=True)
|
||||
iotests.log("# Write test pattern 0x13")
|
||||
qemu_io_write_pattern(config, 0x13, highOffsetMB, 10, dev=True)
|
||||
finally:
|
||||
iotests.log("# Close dev")
|
||||
cryptsetup_close(config)
|
||||
|
||||
# Ok, now we're using QEMU to verify the pattern just
|
||||
# written via dm-crypt
|
||||
|
||||
iotests.log("# Read test pattern 0xa7")
|
||||
qemu_io_read_pattern(config, 0xa7, lowOffsetMB, 10, dev=False)
|
||||
iotests.log("# Read test pattern 0x13")
|
||||
qemu_io_read_pattern(config, 0x13, highOffsetMB, 10, dev=False)
|
||||
|
||||
|
||||
# Write a new pattern to the image, which we'll later
|
||||
# verify with dm-crypt
|
||||
iotests.log("# Write test pattern 0x91")
|
||||
qemu_io_write_pattern(config, 0x91, lowOffsetMB, 10, dev=False)
|
||||
iotests.log("# Write test pattern 0x5e")
|
||||
qemu_io_write_pattern(config, 0x5e, highOffsetMB, 10, dev=False)
|
||||
|
||||
|
||||
# Now we're opening the image with dm-crypt once more
|
||||
# and verifying what QEMU wrote, completing the circle
|
||||
iotests.log("# Open dev")
|
||||
cryptsetup_open(config)
|
||||
|
||||
try:
|
||||
iotests.log("# Set dev owner")
|
||||
chown(config)
|
||||
|
||||
iotests.log("# Read test pattern 0x91")
|
||||
qemu_io_read_pattern(config, 0x91, lowOffsetMB, 10, dev=True)
|
||||
iotests.log("# Read test pattern 0x5e")
|
||||
qemu_io_read_pattern(config, 0x5e, highOffsetMB, 10, dev=True)
|
||||
finally:
|
||||
iotests.log("# Close dev")
|
||||
cryptsetup_close(config)
|
||||
finally:
|
||||
iotests.log("# Delete image")
|
||||
delete_image(config)
|
||||
print
|
||||
|
||||
|
||||
# Obviously we only work with the luks image format
|
||||
iotests.verify_image_format(supported_fmts=['luks'])
|
||||
iotests.verify_platform()
|
||||
|
||||
# We need sudo in order to run cryptsetup to create
|
||||
# dm-crypt devices. This is safe to use on any
|
||||
# machine, since all dm-crypt devices are backed
|
||||
# by newly created plain files, and have a dm-crypt
|
||||
# name prefix of 'qiotest' to avoid clashing with
|
||||
# user LUKS volumes
|
||||
verify_passwordless_sudo()
|
||||
|
||||
|
||||
# If we look at all permutations of cipher, key size,
|
||||
# mode, ivgen, hash, there are ~1000 possible configs.
|
||||
#
|
||||
# We certainly don't want/need to test every permutation
|
||||
# to get good validation of interoperability between QEMU
|
||||
# and dm-crypt/cryptsetup.
|
||||
#
|
||||
# The configs below are a representative set that aim to
|
||||
# exercise each axis of configurability.
|
||||
#
|
||||
configs = [
|
||||
# A common LUKS default
|
||||
LUKSConfig("aes-256-xts-plain64-sha1",
|
||||
"aes", 256, "xts", "plain64", None, "sha1"),
|
||||
|
||||
|
||||
# LUKS default but diff ciphers
|
||||
LUKSConfig("twofish-256-xts-plain64-sha1",
|
||||
"twofish", 256, "xts", "plain64", None, "sha1"),
|
||||
LUKSConfig("serpent-256-xts-plain64-sha1",
|
||||
"serpent", 256, "xts", "plain64", None, "sha1"),
|
||||
# Should really be xts, but kernel doesn't support xts+cast5
|
||||
# nor does it do essiv+cast5
|
||||
LUKSConfig("cast5-128-cbc-plain64-sha1",
|
||||
"cast5", 128, "cbc", "plain64", None, "sha1"),
|
||||
LUKSConfig("cast6-256-xts-plain64-sha1",
|
||||
"cast6", 256, "xts", "plain64", None, "sha1"),
|
||||
|
||||
|
||||
# LUKS default but diff modes / ivgens
|
||||
LUKSConfig("aes-256-cbc-plain-sha1",
|
||||
"aes", 256, "cbc", "plain", None, "sha1"),
|
||||
LUKSConfig("aes-256-cbc-plain64-sha1",
|
||||
"aes", 256, "cbc", "plain64", None, "sha1"),
|
||||
LUKSConfig("aes-256-cbc-essiv-sha256-sha1",
|
||||
"aes", 256, "cbc", "essiv", "sha256", "sha1"),
|
||||
LUKSConfig("aes-256-xts-essiv-sha256-sha1",
|
||||
"aes", 256, "xts", "essiv", "sha256", "sha1"),
|
||||
|
||||
|
||||
# LUKS default but smaller key sizes
|
||||
LUKSConfig("aes-128-xts-plain64-sha256-sha1",
|
||||
"aes", 128, "xts", "plain64", None, "sha1"),
|
||||
LUKSConfig("aes-192-xts-plain64-sha256-sha1",
|
||||
"aes", 192, "xts", "plain64", None, "sha1"),
|
||||
|
||||
LUKSConfig("twofish-128-xts-plain64-sha1",
|
||||
"twofish", 128, "xts", "plain64", None, "sha1"),
|
||||
LUKSConfig("twofish-192-xts-plain64-sha1",
|
||||
"twofish", 192, "xts", "plain64", None, "sha1"),
|
||||
|
||||
LUKSConfig("serpent-128-xts-plain64-sha1",
|
||||
"serpent", 128, "xts", "plain64", None, "sha1"),
|
||||
LUKSConfig("serpent-192-xts-plain64-sha1",
|
||||
"serpent", 192, "xts", "plain64", None, "sha1"),
|
||||
|
||||
LUKSConfig("cast6-128-xts-plain64-sha1",
|
||||
"cast6", 128, "xts", "plain", None, "sha1"),
|
||||
LUKSConfig("cast6-192-xts-plain64-sha1",
|
||||
"cast6", 192, "xts", "plain64", None, "sha1"),
|
||||
|
||||
|
||||
# LUKS default but diff hash
|
||||
LUKSConfig("aes-256-xts-plain64-sha256",
|
||||
"aes", 256, "xts", "plain64", None, "sha256"),
|
||||
LUKSConfig("aes-256-xts-plain64-sha512",
|
||||
"aes", 256, "xts", "plain64", None, "sha512"),
|
||||
LUKSConfig("aes-256-xts-plain64-ripemd160",
|
||||
"aes", 256, "xts", "plain64", None, "ripemd160"),
|
||||
|
||||
# Password in slot 3
|
||||
LUKSConfig("aes-256-xts-plain-sha1-pwslot3",
|
||||
"aes", 256, "xts", "plain", None, "sha1",
|
||||
passwords={
|
||||
"3": "slot3",
|
||||
}),
|
||||
|
||||
# Passwords in every slot
|
||||
LUKSConfig("aes-256-xts-plain-sha1-pwallslots",
|
||||
"aes", 256, "xts", "plain", None, "sha1",
|
||||
passwords={
|
||||
"0": "slot1",
|
||||
"1": "slot1",
|
||||
"2": "slot2",
|
||||
"3": "slot3",
|
||||
"4": "slot4",
|
||||
"5": "slot5",
|
||||
"6": "slot6",
|
||||
"7": "slot7",
|
||||
}),
|
||||
]
|
||||
|
||||
blacklist = [
|
||||
# We don't have a cast-6 cipher impl for QEMU yet
|
||||
"cast6-256-xts-plain64-sha1",
|
||||
"cast6-128-xts-plain64-sha1",
|
||||
"cast6-192-xts-plain64-sha1",
|
||||
|
||||
# GCrypt doesn't support Twofish with 192 bit key
|
||||
"twofish-192-xts-plain64-sha1",
|
||||
|
||||
# We don't have sha512 hash wired up yet
|
||||
"aes-256-xts-plain64-sha512",
|
||||
|
||||
# We don't have ripemd160 hash wired up yet
|
||||
"aes-256-xts-plain64-ripemd160",
|
||||
]
|
||||
|
||||
whitelist = []
|
||||
if "LUKS_CONFIG" in os.environ:
|
||||
whitelist = os.environ["LUKS_CONFIG"].split(",")
|
||||
|
||||
for config in configs:
|
||||
if config.name in blacklist:
|
||||
iotests.log("Skipping %s in blacklist" % config.name)
|
||||
continue
|
||||
|
||||
if len(whitelist) > 0 and config.name not in whitelist:
|
||||
iotests.log("Skipping %s not in whitelist" % config.name)
|
||||
continue
|
||||
|
||||
test_once(config, qemu_img=False)
|
||||
|
||||
# XXX we should support setting passwords in a non-0
|
||||
# key slot with 'qemu-img create' in future
|
||||
(pw, slot) = config.first_password()
|
||||
if slot == "0":
|
||||
test_once(config, qemu_img=True)
|
1880
tests/qemu-iotests/149.out
Normal file
1880
tests/qemu-iotests/149.out
Normal file
File diff suppressed because it is too large
Load diff
105
tests/qemu-iotests/150
Executable file
105
tests/qemu-iotests/150
Executable file
|
@ -0,0 +1,105 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Test that qemu-img convert -S 0 fully allocates the target image
|
||||
#
|
||||
# Copyright (C) 2016 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
|
||||
|
||||
|
||||
on_disk_size()
|
||||
{
|
||||
du "$@" | sed -e 's/\t\+.*//'
|
||||
}
|
||||
|
||||
|
||||
img_size=1048576
|
||||
|
||||
|
||||
echo
|
||||
echo '=== Comparing empty image against 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
|
||||
|
||||
|
||||
echo
|
||||
echo '=== Comparing full image against 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
|
||||
|
||||
|
||||
# success, all done
|
||||
echo "*** done"
|
||||
rm -f $seq.full
|
||||
status=0
|
14
tests/qemu-iotests/150.out
Normal file
14
tests/qemu-iotests/150.out
Normal file
|
@ -0,0 +1,14 @@
|
|||
QA output created by 150
|
||||
|
||||
=== Comparing empty image against sparse conversion ===
|
||||
|
||||
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
|
||||
Equal image size
|
||||
|
||||
=== Comparing full image against 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
|
||||
*** done
|
|
@ -155,6 +155,7 @@ check options
|
|||
-ssh test ssh
|
||||
-nfs test nfs
|
||||
-archipelago test archipelago
|
||||
-luks test luks
|
||||
-xdiff graphical mode diff
|
||||
-nocache use O_DIRECT on backing file
|
||||
-misalign misalign memory allocations
|
||||
|
|
|
@ -150,3 +150,5 @@
|
|||
145 auto quick
|
||||
146 auto quick
|
||||
148 rw auto quick
|
||||
149 rw auto sudo
|
||||
150 rw auto quick
|
||||
|
|
|
@ -29,7 +29,9 @@ import qtest
|
|||
import struct
|
||||
|
||||
__all__ = ['imgfmt', 'imgproto', 'test_dir' 'qemu_img', 'qemu_io',
|
||||
'VM', 'QMPTestCase', 'notrun', 'main']
|
||||
'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.
|
||||
|
@ -71,7 +73,9 @@ def qemu_img_verbose(*args):
|
|||
|
||||
def qemu_img_pipe(*args):
|
||||
'''Run qemu-img and return its output'''
|
||||
subp = subprocess.Popen(qemu_img_args + list(args), stdout=subprocess.PIPE)
|
||||
subp = subprocess.Popen(qemu_img_args + list(args),
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT)
|
||||
exitcode = subp.wait()
|
||||
if exitcode < 0:
|
||||
sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' '.join(qemu_img_args + list(args))))
|
||||
|
@ -80,7 +84,8 @@ def qemu_img_pipe(*args):
|
|||
def qemu_io(*args):
|
||||
'''Run qemu-io and return the stdout data'''
|
||||
args = qemu_io_args + list(args)
|
||||
subp = subprocess.Popen(args, stdout=subprocess.PIPE)
|
||||
subp = subprocess.Popen(args, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT)
|
||||
exitcode = subp.wait()
|
||||
if exitcode < 0:
|
||||
sys.stderr.write('qemu-io received signal %i: %s\n' % (-exitcode, ' '.join(args)))
|
||||
|
@ -101,6 +106,28 @@ def create_image(name, size):
|
|||
i = i + 512
|
||||
file.close()
|
||||
|
||||
test_dir_re = re.compile(r"%s" % test_dir)
|
||||
def filter_test_dir(msg):
|
||||
return test_dir_re.sub("TEST_DIR", msg)
|
||||
|
||||
win32_re = re.compile(r"\r")
|
||||
def filter_win32(msg):
|
||||
return win32_re.sub("", msg)
|
||||
|
||||
qemu_io_re = re.compile(r"[0-9]* ops; [0-9\/:. sec]* \([0-9\/.inf]* [EPTGMKiBbytes]*\/sec and [0-9\/.inf]* ops\/sec\)")
|
||||
def filter_qemu_io(msg):
|
||||
msg = filter_win32(msg)
|
||||
return qemu_io_re.sub("X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)", msg)
|
||||
|
||||
chown_re = re.compile(r"chown [0-9]+:[0-9]+")
|
||||
def filter_chown(msg):
|
||||
return chown_re.sub("chown UID:GID", msg)
|
||||
|
||||
def log(msg, filters=[]):
|
||||
for flt in filters:
|
||||
msg = flt(msg)
|
||||
print msg
|
||||
|
||||
# Test if 'match' is a recursive subset of 'event'
|
||||
def event_match(event, match=None):
|
||||
if match is None:
|
||||
|
@ -391,16 +418,21 @@ def notrun(reason):
|
|||
print '%s not run: %s' % (seq, reason)
|
||||
sys.exit(0)
|
||||
|
||||
def verify_image_format(supported_fmts=[]):
|
||||
if supported_fmts and (imgfmt not in supported_fmts):
|
||||
notrun('not suitable for this image format: %s' % imgfmt)
|
||||
|
||||
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 main(supported_fmts=[], supported_oses=['linux']):
|
||||
'''Run tests'''
|
||||
|
||||
debug = '-d' in sys.argv
|
||||
verbosity = 1
|
||||
if supported_fmts and (imgfmt not in supported_fmts):
|
||||
notrun('not suitable for this image format: %s' % imgfmt)
|
||||
|
||||
if True not in [sys.platform.startswith(x) for x in supported_oses]:
|
||||
notrun('not suitable for this OS: %s' % sys.platform)
|
||||
verify_image_format(supported_fmts)
|
||||
verify_platform(supported_oses)
|
||||
|
||||
# We need to filter out the time taken from the output so that qemu-iotest
|
||||
# can reliably diff the results against master output.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue