1 | The following changes since commit 96662996eda78c48aadddd4e76d8615c7eb72d80: | 1 | The following changes since commit 474f3938d79ab36b9231c9ad3b5a9314c2aeacde: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20210513a' into staging (2021-05-14 12:03:47 +0100) | 3 | Merge remote-tracking branch 'remotes/amarkovic/tags/mips-queue-jun-21-2019' into staging (2019-06-21 15:40:50 +0100) |
4 | 4 | ||
5 | are available in the Git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | https://github.com/XanClic/qemu.git tags/pull-block-2021-05-14 | 7 | https://github.com/XanClic/qemu.git tags/pull-block-2019-06-24 |
8 | 8 | ||
9 | for you to fetch changes up to c61ebf362d0abf288ce266845519d5a550a1d89f: | 9 | for you to fetch changes up to ab5d4a30f7f3803ca5106b370969c1b7b54136f8: |
10 | 10 | ||
11 | write-threshold: deal with includes (2021-05-14 16:14:10 +0200) | 11 | iotests: Fix 205 for concurrent runs (2019-06-24 16:01:40 +0200) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Block patches: | 14 | Block patches: |
15 | - drop block/io write notifiers | 15 | - The SSH block driver now uses libssh instead of libssh2 |
16 | - qemu-iotests enhancements to make debugging easier | 16 | - The VMDK block driver gets read-only support for the seSparse |
17 | - rbd parsing fix | 17 | subformat |
18 | - HMP qemu-io fix (for iothreads) | 18 | - Various fixes |
19 | - mirror job cancel relaxation (do not cancel in-flight requests when a | 19 | |
20 | READY mirror job is canceled with force=false) | 20 | --- |
21 | - document qcow2's data_file and data_file_raw features | 21 | |
22 | - fix iotest 297 for pylint 2.8 | 22 | v2: |
23 | - block/copy-on-read refactoring | 23 | - Squashed Pino's fix for pre-0.8 libssh into the libssh patch |
24 | 24 | ||
25 | ---------------------------------------------------------------- | 25 | ---------------------------------------------------------------- |
26 | Connor Kuehl (3): | 26 | Anton Nefedov (1): |
27 | iotests/231: Update expected deprecation message | 27 | iotest 134: test cluster-misaligned encrypted write |
28 | block/rbd: Add an escape-aware strchr helper | ||
29 | Document qemu-img options data_file and data_file_raw | ||
30 | 28 | ||
31 | Emanuele Giuseppe Esposito (1): | 29 | Klaus Birkelund Jensen (1): |
32 | qemu-iotests: fix pylint 2.8 consider-using-with error | 30 | nvme: do not advertise support for unsupported arbitration mechanism |
33 | 31 | ||
34 | Paolo Bonzini (5): | 32 | Max Reitz (1): |
35 | qemu-iotests: do not buffer the test output | 33 | iotests: Fix 205 for concurrent runs |
36 | qemu-iotests: allow passing unittest.main arguments to the test | ||
37 | scripts | ||
38 | qemu-iotests: move command line and environment handling from | ||
39 | TestRunner to TestEnv | ||
40 | qemu-iotests: let "check" spawn an arbitrary test command | ||
41 | qemu-iotests: fix case of SOCK_DIR already in the environment | ||
42 | 34 | ||
43 | Vladimir Sementsov-Ogievskiy (10): | 35 | Pino Toscano (1): |
44 | monitor: hmp_qemu_io: acquire aio contex, fix crash | 36 | ssh: switch from libssh2 to libssh |
45 | mirror: stop cancelling in-flight requests on non-force cancel in | ||
46 | READY | ||
47 | block/copy-on-read: use bdrv_drop_filter() and drop s->active | ||
48 | block/write-threshold: don't use write notifiers | ||
49 | block: drop write notifiers | ||
50 | test-write-threshold: rewrite test_threshold_(not_)trigger tests | ||
51 | block/write-threshold: drop extra APIs | ||
52 | test-write-threshold: drop extra tests | ||
53 | test-write-threshold: drop extra TestStruct structure | ||
54 | write-threshold: deal with includes | ||
55 | 37 | ||
56 | docs/tools/qemu-img.rst | 31 +++++++ | 38 | Sam Eiderman (3): |
57 | include/block/block_int.h | 15 +--- | 39 | vmdk: Fix comment regarding max l1_size coverage |
58 | include/block/write-threshold.h | 27 ++---- | 40 | vmdk: Reduce the max bound for L1 table size |
59 | include/qemu/job.h | 2 +- | 41 | vmdk: Add read-only support for seSparse snapshots |
60 | block.c | 1 - | 42 | |
61 | block/backup.c | 2 +- | 43 | Vladimir Sementsov-Ogievskiy (1): |
62 | block/copy-on-read.c | 33 +------ | 44 | blockdev: enable non-root nodes for transaction drive-backup source |
63 | block/io.c | 11 +-- | 45 | |
64 | block/mirror.c | 6 +- | 46 | configure | 65 +- |
65 | block/monitor/block-hmp-cmds.c | 31 ++++--- | 47 | block/Makefile.objs | 6 +- |
66 | block/rbd.c | 32 ++++--- | 48 | block/ssh.c | 652 ++++++++++-------- |
67 | block/write-threshold.c | 91 ++++--------------- | 49 | block/vmdk.c | 372 +++++++++- |
68 | job.c | 2 +- | 50 | blockdev.c | 2 +- |
69 | qemu-io-cmds.c | 8 +- | 51 | hw/block/nvme.c | 1 - |
70 | qemu-io.c | 17 +++- | 52 | .travis.yml | 4 +- |
71 | tests/unit/test-write-threshold.c | 90 ++----------------- | 53 | block/trace-events | 14 +- |
72 | tests/qemu-iotests/231 | 4 + | 54 | docs/qemu-block-drivers.texi | 2 +- |
73 | tests/qemu-iotests/231.out | 7 +- | 55 | .../dockerfiles/debian-win32-cross.docker | 1 - |
74 | tests/qemu-iotests/240.out | 8 +- | 56 | .../dockerfiles/debian-win64-cross.docker | 1 - |
75 | tests/qemu-iotests/245.out | 8 +- | 57 | tests/docker/dockerfiles/fedora.docker | 4 +- |
76 | tests/qemu-iotests/264 | 2 +- | 58 | tests/docker/dockerfiles/ubuntu.docker | 2 +- |
77 | tests/qemu-iotests/295.out | 6 +- | 59 | tests/docker/dockerfiles/ubuntu1804.docker | 2 +- |
78 | tests/qemu-iotests/296.out | 8 +- | 60 | tests/qemu-iotests/059.out | 2 +- |
79 | tests/qemu-iotests/check | 19 +++- | 61 | tests/qemu-iotests/134 | 9 + |
80 | tests/qemu-iotests/iotests.py | 145 +++++++++++++++++------------- | 62 | tests/qemu-iotests/134.out | 10 + |
81 | tests/qemu-iotests/pylintrc | 3 + | 63 | tests/qemu-iotests/205 | 2 +- |
82 | tests/qemu-iotests/testenv.py | 22 ++++- | 64 | tests/qemu-iotests/207 | 54 +- |
83 | tests/qemu-iotests/testrunner.py | 37 +++----- | 65 | tests/qemu-iotests/207.out | 2 +- |
84 | 28 files changed, 289 insertions(+), 379 deletions(-) | 66 | 20 files changed, 823 insertions(+), 384 deletions(-) |
85 | 67 | ||
86 | -- | 68 | -- |
87 | 2.31.1 | 69 | 2.21.0 |
88 | 70 | ||
89 | 71 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Connor Kuehl <ckuehl@redhat.com> | ||
2 | 1 | ||
3 | The deprecation message in the expected output has technically been | ||
4 | wrong since the wrong version of a patch was applied to it. Because of | ||
5 | this, the test fails. Correct the expected output so that it passes. | ||
6 | |||
7 | Signed-off-by: Connor Kuehl <ckuehl@redhat.com> | ||
8 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
9 | Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> | ||
10 | Message-Id: <20210421212343.85524-2-ckuehl@redhat.com> | ||
11 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
12 | --- | ||
13 | tests/qemu-iotests/231.out | 4 +--- | ||
14 | 1 file changed, 1 insertion(+), 3 deletions(-) | ||
15 | |||
16 | diff --git a/tests/qemu-iotests/231.out b/tests/qemu-iotests/231.out | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/tests/qemu-iotests/231.out | ||
19 | +++ b/tests/qemu-iotests/231.out | ||
20 | @@ -XXX,XX +XXX,XX @@ | ||
21 | QA output created by 231 | ||
22 | -qemu-img: RBD options encoded in the filename as keyvalue pairs is deprecated. Future versions may cease to parse these options in the future. | ||
23 | +qemu-img: warning: RBD options encoded in the filename as keyvalue pairs is deprecated | ||
24 | unable to get monitor info from DNS SRV with service name: ceph-mon | ||
25 | -no monitors specified to connect to. | ||
26 | qemu-img: Could not open 'json:{'file.driver':'rbd','file.filename':'rbd:rbd/bogus:conf=BOGUS_CONF'}': error connecting: No such file or directory | ||
27 | unable to get monitor info from DNS SRV with service name: ceph-mon | ||
28 | -no monitors specified to connect to. | ||
29 | qemu-img: Could not open 'json:{'file.driver':'rbd','file.pool':'rbd','file.image':'bogus','file.conf':'BOGUS_CONF'}': error connecting: No such file or directory | ||
30 | *** done | ||
31 | -- | ||
32 | 2.31.1 | ||
33 | |||
34 | diff view generated by jsdifflib |
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 1 | From: Klaus Birkelund Jensen <klaus@birkelund.eu> |
---|---|---|---|
2 | 2 | ||
3 | "qemu/typedefs.h" is enough for include/block/write-threshold.h header | 3 | The device mistakenly reports that the Weighted Round Robin with Urgent |
4 | with forward declaration of BlockDriverState. Also drop extra includes | 4 | Priority Class arbitration mechanism is supported. |
5 | from block/write-threshold.c and tests/unit/test-write-threshold.c | ||
6 | 5 | ||
7 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 6 | It is not. |
8 | Message-Id: <20210506090621.11848-9-vsementsov@virtuozzo.com> | 7 | |
9 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | 8 | Signed-off-by: Klaus Birkelund Jensen <klaus.jensen@cnexlabs.com> |
9 | Message-id: 20190606092530.14206-1-klaus@birkelund.eu | ||
10 | Acked-by: Maxim Levitsky <mlevitsk@redhat.com> | ||
10 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 11 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
11 | --- | 12 | --- |
12 | include/block/write-threshold.h | 2 +- | 13 | hw/block/nvme.c | 1 - |
13 | block/write-threshold.c | 2 -- | 14 | 1 file changed, 1 deletion(-) |
14 | tests/unit/test-write-threshold.c | 1 - | ||
15 | 3 files changed, 1 insertion(+), 4 deletions(-) | ||
16 | 15 | ||
17 | diff --git a/include/block/write-threshold.h b/include/block/write-threshold.h | 16 | diff --git a/hw/block/nvme.c b/hw/block/nvme.c |
18 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/block/write-threshold.h | 18 | --- a/hw/block/nvme.c |
20 | +++ b/include/block/write-threshold.h | 19 | +++ b/hw/block/nvme.c |
21 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp) |
22 | #ifndef BLOCK_WRITE_THRESHOLD_H | 21 | n->bar.cap = 0; |
23 | #define BLOCK_WRITE_THRESHOLD_H | 22 | NVME_CAP_SET_MQES(n->bar.cap, 0x7ff); |
24 | 23 | NVME_CAP_SET_CQR(n->bar.cap, 1); | |
25 | -#include "block/block_int.h" | 24 | - NVME_CAP_SET_AMS(n->bar.cap, 1); |
26 | +#include "qemu/typedefs.h" | 25 | NVME_CAP_SET_TO(n->bar.cap, 0xf); |
27 | 26 | NVME_CAP_SET_CSS(n->bar.cap, 1); | |
28 | /* | 27 | NVME_CAP_SET_MPSMAX(n->bar.cap, 4); |
29 | * bdrv_write_threshold_set: | ||
30 | diff --git a/block/write-threshold.c b/block/write-threshold.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/block/write-threshold.c | ||
33 | +++ b/block/write-threshold.c | ||
34 | @@ -XXX,XX +XXX,XX @@ | ||
35 | |||
36 | #include "qemu/osdep.h" | ||
37 | #include "block/block_int.h" | ||
38 | -#include "qemu/coroutine.h" | ||
39 | #include "block/write-threshold.h" | ||
40 | -#include "qemu/notify.h" | ||
41 | #include "qapi/error.h" | ||
42 | #include "qapi/qapi-commands-block-core.h" | ||
43 | #include "qapi/qapi-events-block-core.h" | ||
44 | diff --git a/tests/unit/test-write-threshold.c b/tests/unit/test-write-threshold.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/tests/unit/test-write-threshold.c | ||
47 | +++ b/tests/unit/test-write-threshold.c | ||
48 | @@ -XXX,XX +XXX,XX @@ | ||
49 | */ | ||
50 | |||
51 | #include "qemu/osdep.h" | ||
52 | -#include "qapi/error.h" | ||
53 | #include "block/block_int.h" | ||
54 | #include "block/write-threshold.h" | ||
55 | |||
56 | -- | 28 | -- |
57 | 2.31.1 | 29 | 2.21.0 |
58 | 30 | ||
59 | 31 | diff view generated by jsdifflib |
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | We don't need this extra logic: it doesn't make code simpler. | 3 | We forget to enable it for transaction .prepare, while it is already |
4 | enabled in do_drive_backup since commit a2d665c1bc362 | ||
5 | "blockdev: loosen restrictions on drive-backup source node" | ||
4 | 6 | ||
5 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 7 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
6 | Reviewed-by: Max Reitz <mreitz@redhat.com> | 8 | Message-id: 20190618140804.59214-1-vsementsov@virtuozzo.com |
7 | Message-Id: <20210506090621.11848-8-vsementsov@virtuozzo.com> | 9 | Reviewed-by: John Snow <jsnow@redhat.com> |
8 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
9 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 10 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
10 | --- | 11 | --- |
11 | tests/unit/test-write-threshold.c | 20 +++----------------- | 12 | blockdev.c | 2 +- |
12 | 1 file changed, 3 insertions(+), 17 deletions(-) | 13 | 1 file changed, 1 insertion(+), 1 deletion(-) |
13 | 14 | ||
14 | diff --git a/tests/unit/test-write-threshold.c b/tests/unit/test-write-threshold.c | 15 | diff --git a/blockdev.c b/blockdev.c |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/tests/unit/test-write-threshold.c | 17 | --- a/blockdev.c |
17 | +++ b/tests/unit/test-write-threshold.c | 18 | +++ b/blockdev.c |
18 | @@ -XXX,XX +XXX,XX @@ static void test_threshold_trigger(void) | 19 | @@ -XXX,XX +XXX,XX @@ static void drive_backup_prepare(BlkActionState *common, Error **errp) |
19 | g_assert_cmpuint(bdrv_write_threshold_get(&bs), ==, 0); | 20 | assert(common->action->type == TRANSACTION_ACTION_KIND_DRIVE_BACKUP); |
20 | } | 21 | backup = common->action->u.drive_backup.data; |
21 | 22 | ||
22 | -typedef struct TestStruct { | 23 | - bs = qmp_get_root_bs(backup->device, errp); |
23 | - const char *name; | 24 | + bs = bdrv_lookup_bs(backup->device, backup->device, errp); |
24 | - void (*func)(void); | 25 | if (!bs) { |
25 | -} TestStruct; | 26 | return; |
26 | - | 27 | } |
27 | |||
28 | int main(int argc, char **argv) | ||
29 | { | ||
30 | - size_t i; | ||
31 | - TestStruct tests[] = { | ||
32 | - { "/write-threshold/not-trigger", | ||
33 | - test_threshold_not_trigger }, | ||
34 | - { "/write-threshold/trigger", | ||
35 | - test_threshold_trigger }, | ||
36 | - { NULL, NULL } | ||
37 | - }; | ||
38 | - | ||
39 | g_test_init(&argc, &argv, NULL); | ||
40 | - for (i = 0; tests[i].name != NULL; i++) { | ||
41 | - g_test_add_func(tests[i].name, tests[i].func); | ||
42 | - } | ||
43 | + g_test_add_func("/write-threshold/not-trigger", test_threshold_not_trigger); | ||
44 | + g_test_add_func("/write-threshold/trigger", test_threshold_trigger); | ||
45 | + | ||
46 | return g_test_run(); | ||
47 | } | ||
48 | -- | 28 | -- |
49 | 2.31.1 | 29 | 2.21.0 |
50 | 30 | ||
51 | 31 | diff view generated by jsdifflib |
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 1 | From: Anton Nefedov <anton.nefedov@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | Testing set/get of one 64bit variable doesn't seem necessary. We have a | 3 | COW (even empty/zero) areas require encryption too |
4 | lot of such variables. Also remaining tests do test set/get anyway. | ||
5 | 4 | ||
6 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 5 | Signed-off-by: Anton Nefedov <anton.nefedov@virtuozzo.com> |
6 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
7 | Reviewed-by: Max Reitz <mreitz@redhat.com> | 7 | Reviewed-by: Max Reitz <mreitz@redhat.com> |
8 | Message-Id: <20210506090621.11848-7-vsementsov@virtuozzo.com> | 8 | Reviewed-by: Alberto Garcia <berto@igalia.com> |
9 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | 9 | Message-id: 20190516143028.81155-1-anton.nefedov@virtuozzo.com |
10 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 10 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
11 | --- | 11 | --- |
12 | tests/unit/test-write-threshold.c | 43 ------------------------------- | 12 | tests/qemu-iotests/134 | 9 +++++++++ |
13 | 1 file changed, 43 deletions(-) | 13 | tests/qemu-iotests/134.out | 10 ++++++++++ |
14 | 2 files changed, 19 insertions(+) | ||
14 | 15 | ||
15 | diff --git a/tests/unit/test-write-threshold.c b/tests/unit/test-write-threshold.c | 16 | diff --git a/tests/qemu-iotests/134 b/tests/qemu-iotests/134 |
17 | index XXXXXXX..XXXXXXX 100755 | ||
18 | --- a/tests/qemu-iotests/134 | ||
19 | +++ b/tests/qemu-iotests/134 | ||
20 | @@ -XXX,XX +XXX,XX @@ echo | ||
21 | echo "== reading whole image ==" | ||
22 | $QEMU_IO --object $SECRET -c "read 0 $size" --image-opts $IMGSPEC | _filter_qemu_io | _filter_testdir | ||
23 | |||
24 | +echo | ||
25 | +echo "== rewriting cluster part ==" | ||
26 | +$QEMU_IO --object $SECRET -c "write -P 0xb 512 512" --image-opts $IMGSPEC | _filter_qemu_io | _filter_testdir | ||
27 | + | ||
28 | +echo | ||
29 | +echo "== verify pattern ==" | ||
30 | +$QEMU_IO --object $SECRET -c "read -P 0 0 512" --image-opts $IMGSPEC | _filter_qemu_io | _filter_testdir | ||
31 | +$QEMU_IO --object $SECRET -c "read -P 0xb 512 512" --image-opts $IMGSPEC | _filter_qemu_io | _filter_testdir | ||
32 | + | ||
33 | echo | ||
34 | echo "== rewriting whole image ==" | ||
35 | $QEMU_IO --object $SECRET -c "write -P 0xa 0 $size" --image-opts $IMGSPEC | _filter_qemu_io | _filter_testdir | ||
36 | diff --git a/tests/qemu-iotests/134.out b/tests/qemu-iotests/134.out | ||
16 | index XXXXXXX..XXXXXXX 100644 | 37 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/tests/unit/test-write-threshold.c | 38 | --- a/tests/qemu-iotests/134.out |
18 | +++ b/tests/unit/test-write-threshold.c | 39 | +++ b/tests/qemu-iotests/134.out |
19 | @@ -XXX,XX +XXX,XX @@ | 40 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 encryption=on encrypt. |
20 | #include "block/write-threshold.h" | 41 | read 134217728/134217728 bytes at offset 0 |
21 | 42 | 128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | |
22 | 43 | ||
23 | -static void test_threshold_not_set_on_init(void) | 44 | +== rewriting cluster part == |
24 | -{ | 45 | +wrote 512/512 bytes at offset 512 |
25 | - uint64_t res; | 46 | +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) |
26 | - BlockDriverState bs; | 47 | + |
27 | - memset(&bs, 0, sizeof(bs)); | 48 | +== verify pattern == |
28 | - | 49 | +read 512/512 bytes at offset 0 |
29 | - res = bdrv_write_threshold_get(&bs); | 50 | +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) |
30 | - g_assert_cmpint(res, ==, 0); | 51 | +read 512/512 bytes at offset 512 |
31 | -} | 52 | +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) |
32 | - | 53 | + |
33 | -static void test_threshold_set_get(void) | 54 | == rewriting whole image == |
34 | -{ | 55 | wrote 134217728/134217728 bytes at offset 0 |
35 | - uint64_t threshold = 4 * 1024 * 1024; | 56 | 128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) |
36 | - uint64_t res; | ||
37 | - BlockDriverState bs; | ||
38 | - memset(&bs, 0, sizeof(bs)); | ||
39 | - | ||
40 | - bdrv_write_threshold_set(&bs, threshold); | ||
41 | - | ||
42 | - res = bdrv_write_threshold_get(&bs); | ||
43 | - g_assert_cmpint(res, ==, threshold); | ||
44 | -} | ||
45 | - | ||
46 | -static void test_threshold_multi_set_get(void) | ||
47 | -{ | ||
48 | - uint64_t threshold1 = 4 * 1024 * 1024; | ||
49 | - uint64_t threshold2 = 15 * 1024 * 1024; | ||
50 | - uint64_t res; | ||
51 | - BlockDriverState bs; | ||
52 | - memset(&bs, 0, sizeof(bs)); | ||
53 | - | ||
54 | - bdrv_write_threshold_set(&bs, threshold1); | ||
55 | - bdrv_write_threshold_set(&bs, threshold2); | ||
56 | - res = bdrv_write_threshold_get(&bs); | ||
57 | - g_assert_cmpint(res, ==, threshold2); | ||
58 | -} | ||
59 | - | ||
60 | static void test_threshold_not_trigger(void) | ||
61 | { | ||
62 | uint64_t threshold = 4 * 1024 * 1024; | ||
63 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv) | ||
64 | { | ||
65 | size_t i; | ||
66 | TestStruct tests[] = { | ||
67 | - { "/write-threshold/not-set-on-init", | ||
68 | - test_threshold_not_set_on_init }, | ||
69 | - { "/write-threshold/set-get", | ||
70 | - test_threshold_set_get }, | ||
71 | - { "/write-threshold/multi-set-get", | ||
72 | - test_threshold_multi_set_get }, | ||
73 | { "/write-threshold/not-trigger", | ||
74 | test_threshold_not_trigger }, | ||
75 | { "/write-threshold/trigger", | ||
76 | -- | 57 | -- |
77 | 2.31.1 | 58 | 2.21.0 |
78 | 59 | ||
79 | 60 | diff view generated by jsdifflib |
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 1 | From: Sam Eiderman <shmuel.eiderman@oracle.com> |
---|---|---|---|
2 | 2 | ||
3 | bdrv_write_threshold_exceeded() is unused. | 3 | Commit b0651b8c246d ("vmdk: Move l1_size check into vmdk_add_extent") |
4 | extended the l1_size check from VMDK4 to VMDK3 but did not update the | ||
5 | default coverage in the moved comment. | ||
4 | 6 | ||
5 | bdrv_write_threshold_is_set() is used only to double check the value of | 7 | The previous vmdk4 calculation: |
6 | bs->write_threshold_offset in tests. No real sense in it (both tests do | ||
7 | check real value with help of bdrv_write_threshold_get()) | ||
8 | 8 | ||
9 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 9 | (512 * 1024 * 1024) * 512(l2 entries) * 65536(grain) = 16PB |
10 | |||
11 | The added vmdk3 calculation: | ||
12 | |||
13 | (512 * 1024 * 1024) * 4096(l2 entries) * 512(grain) = 1PB | ||
14 | |||
15 | Adding the calculation of vmdk3 to the comment. | ||
16 | |||
17 | In any case, VMware does not offer virtual disks more than 2TB for | ||
18 | vmdk4/vmdk3 or 64TB for the new undocumented seSparse format which is | ||
19 | not implemented yet in qemu. | ||
20 | |||
21 | Reviewed-by: Karl Heubaum <karl.heubaum@oracle.com> | ||
22 | Reviewed-by: Eyal Moscovici <eyal.moscovici@oracle.com> | ||
23 | Reviewed-by: Liran Alon <liran.alon@oracle.com> | ||
24 | Reviewed-by: Arbel Moshe <arbel.moshe@oracle.com> | ||
25 | Signed-off-by: Sam Eiderman <shmuel.eiderman@oracle.com> | ||
26 | Message-id: 20190620091057.47441-2-shmuel.eiderman@oracle.com | ||
27 | Reviewed-by: yuchenlin <yuchenlin@synology.com> | ||
10 | Reviewed-by: Max Reitz <mreitz@redhat.com> | 28 | Reviewed-by: Max Reitz <mreitz@redhat.com> |
11 | Message-Id: <20210506090621.11848-5-vsementsov@virtuozzo.com> | ||
12 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
13 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
14 | [mreitz: Adjusted commit message as per Eric's suggestion] | ||
15 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 29 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
16 | --- | 30 | --- |
17 | include/block/write-threshold.h | 24 ------------------------ | 31 | block/vmdk.c | 11 ++++++++--- |
18 | block/write-threshold.c | 19 ------------------- | 32 | 1 file changed, 8 insertions(+), 3 deletions(-) |
19 | tests/unit/test-write-threshold.c | 4 ---- | ||
20 | 3 files changed, 47 deletions(-) | ||
21 | 33 | ||
22 | diff --git a/include/block/write-threshold.h b/include/block/write-threshold.h | 34 | diff --git a/block/vmdk.c b/block/vmdk.c |
23 | index XXXXXXX..XXXXXXX 100644 | 35 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/include/block/write-threshold.h | 36 | --- a/block/vmdk.c |
25 | +++ b/include/block/write-threshold.h | 37 | +++ b/block/vmdk.c |
26 | @@ -XXX,XX +XXX,XX @@ void bdrv_write_threshold_set(BlockDriverState *bs, uint64_t threshold_bytes); | 38 | @@ -XXX,XX +XXX,XX @@ static int vmdk_add_extent(BlockDriverState *bs, |
27 | */ | 39 | return -EFBIG; |
28 | uint64_t bdrv_write_threshold_get(const BlockDriverState *bs); | 40 | } |
29 | 41 | if (l1_size > 512 * 1024 * 1024) { | |
30 | -/* | 42 | - /* Although with big capacity and small l1_entry_sectors, we can get a |
31 | - * bdrv_write_threshold_is_set | 43 | + /* |
32 | - * | 44 | + * Although with big capacity and small l1_entry_sectors, we can get a |
33 | - * Tell if a write threshold is set for a given BDS. | 45 | * big l1_size, we don't want unbounded value to allocate the table. |
34 | - */ | 46 | - * Limit it to 512M, which is 16PB for default cluster and L2 table |
35 | -bool bdrv_write_threshold_is_set(const BlockDriverState *bs); | 47 | - * size */ |
36 | - | 48 | + * Limit it to 512M, which is: |
37 | -/* | 49 | + * 16PB - for default "Hosted Sparse Extent" (VMDK4) |
38 | - * bdrv_write_threshold_exceeded | 50 | + * cluster size: 64KB, L2 table size: 512 entries |
39 | - * | 51 | + * 1PB - for default "ESXi Host Sparse Extent" (VMDK3/vmfsSparse) |
40 | - * Return the extent of a write request that exceeded the threshold, | 52 | + * cluster size: 512B, L2 table size: 4096 entries |
41 | - * or zero if the request is below the threshold. | 53 | + */ |
42 | - * Return zero also if the threshold was not set. | 54 | error_setg(errp, "L1 size too big"); |
43 | - * | 55 | return -EFBIG; |
44 | - * NOTE: here we assume the following holds for each request this code | 56 | } |
45 | - * deals with: | ||
46 | - * | ||
47 | - * assert((req->offset + req->bytes) <= UINT64_MAX) | ||
48 | - * | ||
49 | - * Please not there is *not* an actual C assert(). | ||
50 | - */ | ||
51 | -uint64_t bdrv_write_threshold_exceeded(const BlockDriverState *bs, | ||
52 | - const BdrvTrackedRequest *req); | ||
53 | - | ||
54 | /* | ||
55 | * bdrv_write_threshold_check_write | ||
56 | * | ||
57 | diff --git a/block/write-threshold.c b/block/write-threshold.c | ||
58 | index XXXXXXX..XXXXXXX 100644 | ||
59 | --- a/block/write-threshold.c | ||
60 | +++ b/block/write-threshold.c | ||
61 | @@ -XXX,XX +XXX,XX @@ uint64_t bdrv_write_threshold_get(const BlockDriverState *bs) | ||
62 | return bs->write_threshold_offset; | ||
63 | } | ||
64 | |||
65 | -bool bdrv_write_threshold_is_set(const BlockDriverState *bs) | ||
66 | -{ | ||
67 | - return bs->write_threshold_offset > 0; | ||
68 | -} | ||
69 | - | ||
70 | -uint64_t bdrv_write_threshold_exceeded(const BlockDriverState *bs, | ||
71 | - const BdrvTrackedRequest *req) | ||
72 | -{ | ||
73 | - if (bdrv_write_threshold_is_set(bs)) { | ||
74 | - if (req->offset > bs->write_threshold_offset) { | ||
75 | - return (req->offset - bs->write_threshold_offset) + req->bytes; | ||
76 | - } | ||
77 | - if ((req->offset + req->bytes) > bs->write_threshold_offset) { | ||
78 | - return (req->offset + req->bytes) - bs->write_threshold_offset; | ||
79 | - } | ||
80 | - } | ||
81 | - return 0; | ||
82 | -} | ||
83 | - | ||
84 | void bdrv_write_threshold_set(BlockDriverState *bs, uint64_t threshold_bytes) | ||
85 | { | ||
86 | bs->write_threshold_offset = threshold_bytes; | ||
87 | diff --git a/tests/unit/test-write-threshold.c b/tests/unit/test-write-threshold.c | ||
88 | index XXXXXXX..XXXXXXX 100644 | ||
89 | --- a/tests/unit/test-write-threshold.c | ||
90 | +++ b/tests/unit/test-write-threshold.c | ||
91 | @@ -XXX,XX +XXX,XX @@ static void test_threshold_not_set_on_init(void) | ||
92 | BlockDriverState bs; | ||
93 | memset(&bs, 0, sizeof(bs)); | ||
94 | |||
95 | - g_assert(!bdrv_write_threshold_is_set(&bs)); | ||
96 | - | ||
97 | res = bdrv_write_threshold_get(&bs); | ||
98 | g_assert_cmpint(res, ==, 0); | ||
99 | } | ||
100 | @@ -XXX,XX +XXX,XX @@ static void test_threshold_set_get(void) | ||
101 | |||
102 | bdrv_write_threshold_set(&bs, threshold); | ||
103 | |||
104 | - g_assert(bdrv_write_threshold_is_set(&bs)); | ||
105 | - | ||
106 | res = bdrv_write_threshold_get(&bs); | ||
107 | g_assert_cmpint(res, ==, threshold); | ||
108 | } | ||
109 | -- | 57 | -- |
110 | 2.31.1 | 58 | 2.21.0 |
111 | 59 | ||
112 | 60 | diff view generated by jsdifflib |
1 | From: Connor Kuehl <ckuehl@redhat.com> | 1 | From: Sam Eiderman <shmuel.eiderman@oracle.com> |
---|---|---|---|
2 | 2 | ||
3 | Sometimes the parser needs to further split a token it has collected | 3 | 512M of L1 entries is a very loose bound, only 32M are required to store |
4 | from the token input stream. Right now, it does a cursory check to see | 4 | the maximal supported VMDK file size of 2TB. |
5 | if the relevant characters appear in the token to determine if it should | ||
6 | break it down further. | ||
7 | 5 | ||
8 | However, qemu_rbd_next_tok() will escape characters as it removes tokens | 6 | Fixed qemu-iotest 59# - now failure occures before on impossible L1 |
9 | from the token stream and plain strchr() won't. This can make the | 7 | table size. |
10 | initial strchr() check slightly misleading since it implies | ||
11 | qemu_rbd_next_tok() will find the token and split on it, except the | ||
12 | reality is that qemu_rbd_next_tok() will pass over it if it is escaped. | ||
13 | 8 | ||
14 | Use a custom strchr to avoid mixing escaped and unescaped string | 9 | Reviewed-by: Karl Heubaum <karl.heubaum@oracle.com> |
15 | operations. Furthermore, this code is identical to how | 10 | Reviewed-by: Eyal Moscovici <eyal.moscovici@oracle.com> |
16 | qemu_rbd_next_tok() seeks its next token, so incorporate this custom | 11 | Reviewed-by: Liran Alon <liran.alon@oracle.com> |
17 | strchr into the body of that function to reduce duplication. | 12 | Reviewed-by: Arbel Moshe <arbel.moshe@oracle.com> |
18 | 13 | Signed-off-by: Sam Eiderman <shmuel.eiderman@oracle.com> | |
19 | Reported-by: Han Han <hhan@redhat.com> | 14 | Message-id: 20190620091057.47441-3-shmuel.eiderman@oracle.com |
20 | Fixes: https://bugzilla.redhat.com/1873913 | 15 | Reviewed-by: Max Reitz <mreitz@redhat.com> |
21 | Signed-off-by: Connor Kuehl <ckuehl@redhat.com> | ||
22 | Message-Id: <20210421212343.85524-3-ckuehl@redhat.com> | ||
23 | Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> | ||
24 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 16 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
25 | --- | 17 | --- |
26 | block/rbd.c | 32 +++++++++++++++++++++----------- | 18 | block/vmdk.c | 13 +++++++------ |
27 | tests/qemu-iotests/231 | 4 ++++ | 19 | tests/qemu-iotests/059.out | 2 +- |
28 | tests/qemu-iotests/231.out | 3 +++ | 20 | 2 files changed, 8 insertions(+), 7 deletions(-) |
29 | 3 files changed, 28 insertions(+), 11 deletions(-) | ||
30 | 21 | ||
31 | diff --git a/block/rbd.c b/block/rbd.c | 22 | diff --git a/block/vmdk.c b/block/vmdk.c |
32 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/block/rbd.c | 24 | --- a/block/vmdk.c |
34 | +++ b/block/rbd.c | 25 | +++ b/block/vmdk.c |
35 | @@ -XXX,XX +XXX,XX @@ static int qemu_rbd_connect(rados_t *cluster, rados_ioctx_t *io_ctx, | 26 | @@ -XXX,XX +XXX,XX @@ static int vmdk_add_extent(BlockDriverState *bs, |
36 | const char *keypairs, const char *secretid, | 27 | error_setg(errp, "Invalid granularity, image may be corrupt"); |
37 | Error **errp); | 28 | return -EFBIG; |
38 | |||
39 | +static char *qemu_rbd_strchr(char *src, char delim) | ||
40 | +{ | ||
41 | + char *p; | ||
42 | + | ||
43 | + for (p = src; *p; ++p) { | ||
44 | + if (*p == delim) { | ||
45 | + return p; | ||
46 | + } | ||
47 | + if (*p == '\\' && p[1] != '\0') { | ||
48 | + ++p; | ||
49 | + } | ||
50 | + } | ||
51 | + | ||
52 | + return NULL; | ||
53 | +} | ||
54 | + | ||
55 | + | ||
56 | static char *qemu_rbd_next_tok(char *src, char delim, char **p) | ||
57 | { | ||
58 | char *end; | ||
59 | |||
60 | *p = NULL; | ||
61 | |||
62 | - for (end = src; *end; ++end) { | ||
63 | - if (*end == delim) { | ||
64 | - break; | ||
65 | - } | ||
66 | - if (*end == '\\' && end[1] != '\0') { | ||
67 | - end++; | ||
68 | - } | ||
69 | - } | ||
70 | - if (*end == delim) { | ||
71 | + end = qemu_rbd_strchr(src, delim); | ||
72 | + if (end) { | ||
73 | *p = end + 1; | ||
74 | *end = '\0'; | ||
75 | } | 29 | } |
76 | @@ -XXX,XX +XXX,XX @@ static void qemu_rbd_parse_filename(const char *filename, QDict *options, | 30 | - if (l1_size > 512 * 1024 * 1024) { |
77 | qemu_rbd_unescape(found_str); | 31 | + if (l1_size > 32 * 1024 * 1024) { |
78 | qdict_put_str(options, "pool", found_str); | 32 | /* |
79 | 33 | * Although with big capacity and small l1_entry_sectors, we can get a | |
80 | - if (strchr(p, '@')) { | 34 | * big l1_size, we don't want unbounded value to allocate the table. |
81 | + if (qemu_rbd_strchr(p, '@')) { | 35 | - * Limit it to 512M, which is: |
82 | image_name = qemu_rbd_next_tok(p, '@', &p); | 36 | - * 16PB - for default "Hosted Sparse Extent" (VMDK4) |
83 | 37 | - * cluster size: 64KB, L2 table size: 512 entries | |
84 | found_str = qemu_rbd_next_tok(p, ':', &p); | 38 | - * 1PB - for default "ESXi Host Sparse Extent" (VMDK3/vmfsSparse) |
85 | @@ -XXX,XX +XXX,XX @@ static void qemu_rbd_parse_filename(const char *filename, QDict *options, | 39 | - * cluster size: 512B, L2 table size: 4096 entries |
86 | image_name = qemu_rbd_next_tok(p, ':', &p); | 40 | + * Limit it to 32M, which is enough to store: |
87 | } | 41 | + * 8TB - for both VMDK3 & VMDK4 with |
88 | /* Check for namespace in the image_name */ | 42 | + * minimal cluster size: 512B |
89 | - if (strchr(image_name, '/')) { | 43 | + * minimal L2 table size: 512 entries |
90 | + if (qemu_rbd_strchr(image_name, '/')) { | 44 | + * 8 TB is still more than the maximal value supported for |
91 | found_str = qemu_rbd_next_tok(image_name, '/', &image_name); | 45 | + * VMDK3 & VMDK4 which is 2TB. |
92 | qemu_rbd_unescape(found_str); | 46 | */ |
93 | qdict_put_str(options, "namespace", found_str); | 47 | error_setg(errp, "L1 size too big"); |
94 | diff --git a/tests/qemu-iotests/231 b/tests/qemu-iotests/231 | 48 | return -EFBIG; |
95 | index XXXXXXX..XXXXXXX 100755 | 49 | diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out |
96 | --- a/tests/qemu-iotests/231 | ||
97 | +++ b/tests/qemu-iotests/231 | ||
98 | @@ -XXX,XX +XXX,XX @@ _filter_conf() | ||
99 | $QEMU_IMG info "json:{'file.driver':'rbd','file.filename':'rbd:rbd/bogus:conf=${BOGUS_CONF}'}" 2>&1 | _filter_conf | ||
100 | $QEMU_IMG info "json:{'file.driver':'rbd','file.pool':'rbd','file.image':'bogus','file.conf':'${BOGUS_CONF}'}" 2>&1 | _filter_conf | ||
101 | |||
102 | +# Regression test: the qemu-img invocation is expected to fail, but it should | ||
103 | +# not seg fault the parser. | ||
104 | +$QEMU_IMG create "rbd:rbd/aa\/bb:conf=${BOGUS_CONF}" 1M 2>&1 | _filter_conf | ||
105 | + | ||
106 | # success, all done | ||
107 | echo "*** done" | ||
108 | rm -f $seq.full | ||
109 | diff --git a/tests/qemu-iotests/231.out b/tests/qemu-iotests/231.out | ||
110 | index XXXXXXX..XXXXXXX 100644 | 50 | index XXXXXXX..XXXXXXX 100644 |
111 | --- a/tests/qemu-iotests/231.out | 51 | --- a/tests/qemu-iotests/059.out |
112 | +++ b/tests/qemu-iotests/231.out | 52 | +++ b/tests/qemu-iotests/059.out |
113 | @@ -XXX,XX +XXX,XX @@ unable to get monitor info from DNS SRV with service name: ceph-mon | 53 | @@ -XXX,XX +XXX,XX @@ Offset Length Mapped to File |
114 | qemu-img: Could not open 'json:{'file.driver':'rbd','file.filename':'rbd:rbd/bogus:conf=BOGUS_CONF'}': error connecting: No such file or directory | 54 | 0x140000000 0x10000 0x50000 TEST_DIR/t-s003.vmdk |
115 | unable to get monitor info from DNS SRV with service name: ceph-mon | 55 | |
116 | qemu-img: Could not open 'json:{'file.driver':'rbd','file.pool':'rbd','file.image':'bogus','file.conf':'BOGUS_CONF'}': error connecting: No such file or directory | 56 | === Testing afl image with a very large capacity === |
117 | +Formatting 'rbd:rbd/aa\/bb:conf=BOGUS_CONF', fmt=raw size=1048576 | 57 | -qemu-img: Can't get image size 'TEST_DIR/afl9.IMGFMT': File too large |
118 | +unable to get monitor info from DNS SRV with service name: ceph-mon | 58 | +qemu-img: Could not open 'TEST_DIR/afl9.IMGFMT': L1 size too big |
119 | +qemu-img: rbd:rbd/aa\/bb:conf=BOGUS_CONF: error connecting: No such file or directory | ||
120 | *** done | 59 | *** done |
121 | -- | 60 | -- |
122 | 2.31.1 | 61 | 2.21.0 |
123 | 62 | ||
124 | 63 | diff view generated by jsdifflib |
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 1 | From: Sam Eiderman <shmuel.eiderman@oracle.com> |
---|---|---|---|
2 | 2 | ||
3 | Max reported the following bug: | 3 | Until ESXi 6.5 VMware used the vmfsSparse format for snapshots (VMDK3 in |
4 | 4 | QEMU). | |
5 | $ ./qemu-img create -f raw src.img 1G | 5 | |
6 | $ ./qemu-img create -f raw dst.img 1G | 6 | This format was lacking in the following: |
7 | 7 | ||
8 | $ (echo ' | 8 | * Grain directory (L1) and grain table (L2) entries were 32-bit, |
9 | {"execute":"qmp_capabilities"} | 9 | allowing access to only 2TB (slightly less) of data. |
10 | {"execute":"blockdev-mirror", | 10 | * The grain size (default) was 512 bytes - leading to data |
11 | "arguments":{"job-id":"mirror", | 11 | fragmentation and many grain tables. |
12 | "device":"source", | 12 | * For space reclamation purposes, it was necessary to find all the |
13 | "target":"target", | 13 | grains which are not pointed to by any grain table - so a reverse |
14 | "sync":"full", | 14 | mapping of "offset of grain in vmdk" to "grain table" must be |
15 | "filter-node-name":"mirror-top"}} | 15 | constructed - which takes large amounts of CPU/RAM. |
16 | '; sleep 3; echo ' | 16 | |
17 | {"execute":"human-monitor-command", | 17 | The format specification can be found in VMware's documentation: |
18 | "arguments":{"command-line": | 18 | https://www.vmware.com/support/developer/vddk/vmdk_50_technote.pdf |
19 | "qemu-io mirror-top \"write 0 1G\""}}') \ | 19 | |
20 | | x86_64-softmmu/qemu-system-x86_64 \ | 20 | In ESXi 6.5, to support snapshot files larger than 2TB, a new format was |
21 | -qmp stdio \ | 21 | introduced: SESparse (Space Efficient). |
22 | -blockdev file,node-name=source,filename=src.img \ | 22 | |
23 | -blockdev file,node-name=target,filename=dst.img \ | 23 | This format fixes the above issues: |
24 | -object iothread,id=iothr0 \ | 24 | |
25 | -device virtio-blk,drive=source,iothread=iothr0 | 25 | * All entries are now 64-bit. |
26 | 26 | * The grain size (default) is 4KB. | |
27 | crashes: | 27 | * Grain directory and grain tables are now located at the beginning |
28 | 28 | of the file. | |
29 | 0 raise () at /usr/lib/libc.so.6 | 29 | + seSparse format reserves space for all grain tables. |
30 | 1 abort () at /usr/lib/libc.so.6 | 30 | + Grain tables can be addressed using an index. |
31 | 2 error_exit | 31 | + Grains are located in the end of the file and can also be |
32 | (err=<optimized out>, | 32 | addressed with an index. |
33 | msg=msg@entry=0x55fbb1634790 <__func__.27> "qemu_mutex_unlock_impl") | 33 | - seSparse vmdks of large disks (64TB) have huge preallocated |
34 | at ../util/qemu-thread-posix.c:37 | 34 | headers - mainly due to L2 tables, even for empty snapshots. |
35 | 3 qemu_mutex_unlock_impl | 35 | * The header contains a reverse mapping ("backmap") of "offset of |
36 | (mutex=mutex@entry=0x55fbb25ab6e0, | 36 | grain in vmdk" to "grain table" and a bitmap ("free bitmap") which |
37 | file=file@entry=0x55fbb1636957 "../util/async.c", | 37 | specifies for each grain - whether it is allocated or not. |
38 | line=line@entry=650) | 38 | Using these data structures we can implement space reclamation |
39 | at ../util/qemu-thread-posix.c:109 | 39 | efficiently. |
40 | 4 aio_context_release (ctx=ctx@entry=0x55fbb25ab680) at ../util/async.c:650 | 40 | * Due to the fact that the header now maintains two mappings: |
41 | 5 bdrv_do_drained_begin | 41 | * The regular one (grain directory & grain tables) |
42 | (bs=bs@entry=0x55fbb3a87000, recursive=recursive@entry=false, | 42 | * A reverse one (backmap and free bitmap) |
43 | parent=parent@entry=0x0, | 43 | These data structures can lose consistency upon crash and result |
44 | ignore_bds_parents=ignore_bds_parents@entry=false, | 44 | in a corrupted VMDK. |
45 | poll=poll@entry=true) at ../block/io.c:441 | 45 | Therefore, a journal is also added to the VMDK and is replayed |
46 | 6 bdrv_do_drained_begin | 46 | when the VMware reopens the file after a crash. |
47 | (poll=true, ignore_bds_parents=false, parent=0x0, recursive=false, | 47 | |
48 | bs=0x55fbb3a87000) at ../block/io.c:448 | 48 | Since ESXi 6.7 - SESparse is the only snapshot format available. |
49 | 7 blk_drain (blk=0x55fbb26c5a00) at ../block/block-backend.c:1718 | 49 | |
50 | 8 blk_unref (blk=0x55fbb26c5a00) at ../block/block-backend.c:498 | 50 | Unfortunately, VMware does not provide documentation regarding the new |
51 | 9 blk_unref (blk=0x55fbb26c5a00) at ../block/block-backend.c:491 | 51 | seSparse format. |
52 | 10 hmp_qemu_io (mon=0x7fffaf3fc7d0, qdict=<optimized out>) | 52 | |
53 | at ../block/monitor/block-hmp-cmds.c:628 | 53 | This commit is based on black-box research of the seSparse format. |
54 | 54 | Various in-guest block operations and their effect on the snapshot file | |
55 | man pthread_mutex_unlock | 55 | were tested. |
56 | ... | 56 | |
57 | EPERM The mutex type is PTHREAD_MUTEX_ERRORCHECK or | 57 | The only VMware provided source of information (regarding the underlying |
58 | PTHREAD_MUTEX_RECURSIVE, or the mutex is a robust mutex, and the | 58 | implementation) was a log file on the ESXi: |
59 | current thread does not own the mutex. | 59 | |
60 | 60 | /var/log/hostd.log | |
61 | So, thread doesn't own the mutex. And we have iothread here. | 61 | |
62 | 62 | Whenever an seSparse snapshot is created - the log is being populated | |
63 | Next, note that AIO_WAIT_WHILE() documents that ctx must be acquired | 63 | with seSparse records. |
64 | exactly once by caller. But where is it acquired in the call stack? | 64 | |
65 | Seems nowhere. | 65 | Relevant log records are of the form: |
66 | 66 | ||
67 | qemuio_command do acquire aio context.. But we need context acquired | 67 | [...] Const Header: |
68 | around blk_unref() as well and actually around blk_insert_bs() too. | 68 | [...] constMagic = 0xcafebabe |
69 | 69 | [...] version = 2.1 | |
70 | Let's refactor qemuio_command so that it doesn't acquire aio context | 70 | [...] capacity = 204800 |
71 | but callers do that instead. This way we can cleanly acquire aio | 71 | [...] grainSize = 8 |
72 | context in hmp_qemu_io() around all three calls. | 72 | [...] grainTableSize = 64 |
73 | 73 | [...] flags = 0 | |
74 | Reported-by: Max Reitz <mreitz@redhat.com> | 74 | [...] Extents: |
75 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 75 | [...] Header : <1 : 1> |
76 | Message-Id: <20210423134233.51495-1-vsementsov@virtuozzo.com> | 76 | [...] JournalHdr : <2 : 2> |
77 | [mreitz: Fixed comment] | 77 | [...] Journal : <2048 : 2048> |
78 | [...] GrainDirectory : <4096 : 2048> | ||
79 | [...] GrainTables : <6144 : 2048> | ||
80 | [...] FreeBitmap : <8192 : 2048> | ||
81 | [...] BackMap : <10240 : 2048> | ||
82 | [...] Grain : <12288 : 204800> | ||
83 | [...] Volatile Header: | ||
84 | [...] volatileMagic = 0xcafecafe | ||
85 | [...] FreeGTNumber = 0 | ||
86 | [...] nextTxnSeqNumber = 0 | ||
87 | [...] replayJournal = 0 | ||
88 | |||
89 | The sizes that are seen in the log file are in sectors. | ||
90 | Extents are of the following format: <offset : size> | ||
91 | |||
92 | This commit is a strict implementation which enforces: | ||
93 | * magics | ||
94 | * version number 2.1 | ||
95 | * grain size of 8 sectors (4KB) | ||
96 | * grain table size of 64 sectors | ||
97 | * zero flags | ||
98 | * extent locations | ||
99 | |||
100 | Additionally, this commit proivdes only a subset of the functionality | ||
101 | offered by seSparse's format: | ||
102 | * Read-only | ||
103 | * No journal replay | ||
104 | * No space reclamation | ||
105 | * No unmap support | ||
106 | |||
107 | Hence, journal header, journal, free bitmap and backmap extents are | ||
108 | unused, only the "classic" (L1 -> L2 -> data) grain access is | ||
109 | implemented. | ||
110 | |||
111 | However there are several differences in the grain access itself. | ||
112 | Grain directory (L1): | ||
113 | * Grain directory entries are indexes (not offsets) to grain | ||
114 | tables. | ||
115 | * Valid grain directory entries have their highest nibble set to | ||
116 | 0x1. | ||
117 | * Since grain tables are always located in the beginning of the | ||
118 | file - the index can fit into 32 bits - so we can use its low | ||
119 | part if it's valid. | ||
120 | Grain table (L2): | ||
121 | * Grain table entries are indexes (not offsets) to grains. | ||
122 | * If the highest nibble of the entry is: | ||
123 | 0x0: | ||
124 | The grain in not allocated. | ||
125 | The rest of the bytes are 0. | ||
126 | 0x1: | ||
127 | The grain is unmapped - guest sees a zero grain. | ||
128 | The rest of the bits point to the previously mapped grain, | ||
129 | see 0x3 case. | ||
130 | 0x2: | ||
131 | The grain is zero. | ||
132 | 0x3: | ||
133 | The grain is allocated - to get the index calculate: | ||
134 | ((entry & 0x0fff000000000000) >> 48) | | ||
135 | ((entry & 0x0000ffffffffffff) << 12) | ||
136 | * The difference between 0x1 and 0x2 is that 0x1 is an unallocated | ||
137 | grain which results from the guest using sg_unmap to unmap the | ||
138 | grain - but the grain itself still exists in the grain extent - a | ||
139 | space reclamation procedure should delete it. | ||
140 | Unmapping a zero grain has no effect (0x2 will not change to 0x1) | ||
141 | but unmapping an unallocated grain will (0x0 to 0x1) - naturally. | ||
142 | |||
143 | In order to implement seSparse some fields had to be changed to support | ||
144 | both 32-bit and 64-bit entry sizes. | ||
145 | |||
146 | Reviewed-by: Karl Heubaum <karl.heubaum@oracle.com> | ||
147 | Reviewed-by: Eyal Moscovici <eyal.moscovici@oracle.com> | ||
148 | Reviewed-by: Arbel Moshe <arbel.moshe@oracle.com> | ||
149 | Signed-off-by: Sam Eiderman <shmuel.eiderman@oracle.com> | ||
150 | Message-id: 20190620091057.47441-4-shmuel.eiderman@oracle.com | ||
78 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 151 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
79 | --- | 152 | --- |
80 | block/monitor/block-hmp-cmds.c | 31 +++++++++++++++++++++---------- | 153 | block/vmdk.c | 358 ++++++++++++++++++++++++++++++++++++++++++++++++--- |
81 | qemu-io-cmds.c | 8 ++++---- | 154 | 1 file changed, 342 insertions(+), 16 deletions(-) |
82 | qemu-io.c | 17 +++++++++++++++-- | 155 | |
83 | 3 files changed, 40 insertions(+), 16 deletions(-) | 156 | diff --git a/block/vmdk.c b/block/vmdk.c |
84 | |||
85 | diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c | ||
86 | index XXXXXXX..XXXXXXX 100644 | 157 | index XXXXXXX..XXXXXXX 100644 |
87 | --- a/block/monitor/block-hmp-cmds.c | 158 | --- a/block/vmdk.c |
88 | +++ b/block/monitor/block-hmp-cmds.c | 159 | +++ b/block/vmdk.c |
89 | @@ -XXX,XX +XXX,XX @@ void hmp_eject(Monitor *mon, const QDict *qdict) | 160 | @@ -XXX,XX +XXX,XX @@ typedef struct { |
90 | 161 | uint16_t compressAlgorithm; | |
91 | void hmp_qemu_io(Monitor *mon, const QDict *qdict) | 162 | } QEMU_PACKED VMDK4Header; |
92 | { | 163 | |
93 | - BlockBackend *blk; | 164 | +typedef struct VMDKSESparseConstHeader { |
94 | + BlockBackend *blk = NULL; | 165 | + uint64_t magic; |
95 | + BlockDriverState *bs = NULL; | 166 | + uint64_t version; |
96 | BlockBackend *local_blk = NULL; | 167 | + uint64_t capacity; |
97 | + AioContext *ctx = NULL; | 168 | + uint64_t grain_size; |
98 | bool qdev = qdict_get_try_bool(qdict, "qdev", false); | 169 | + uint64_t grain_table_size; |
99 | const char *device = qdict_get_str(qdict, "device"); | 170 | + uint64_t flags; |
100 | const char *command = qdict_get_str(qdict, "command"); | 171 | + uint64_t reserved1; |
101 | @@ -XXX,XX +XXX,XX @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict) | 172 | + uint64_t reserved2; |
102 | } else { | 173 | + uint64_t reserved3; |
103 | blk = blk_by_name(device); | 174 | + uint64_t reserved4; |
104 | if (!blk) { | 175 | + uint64_t volatile_header_offset; |
105 | - BlockDriverState *bs = bdrv_lookup_bs(NULL, device, &err); | 176 | + uint64_t volatile_header_size; |
106 | - if (bs) { | 177 | + uint64_t journal_header_offset; |
107 | - blk = local_blk = blk_new(bdrv_get_aio_context(bs), | 178 | + uint64_t journal_header_size; |
108 | - 0, BLK_PERM_ALL); | 179 | + uint64_t journal_offset; |
109 | - ret = blk_insert_bs(blk, bs, &err); | 180 | + uint64_t journal_size; |
110 | - if (ret < 0) { | 181 | + uint64_t grain_dir_offset; |
111 | - goto fail; | 182 | + uint64_t grain_dir_size; |
112 | - } | 183 | + uint64_t grain_tables_offset; |
113 | - } else { | 184 | + uint64_t grain_tables_size; |
114 | + bs = bdrv_lookup_bs(NULL, device, &err); | 185 | + uint64_t free_bitmap_offset; |
115 | + if (!bs) { | 186 | + uint64_t free_bitmap_size; |
116 | goto fail; | 187 | + uint64_t backmap_offset; |
117 | } | 188 | + uint64_t backmap_size; |
118 | } | 189 | + uint64_t grains_offset; |
119 | } | 190 | + uint64_t grains_size; |
120 | 191 | + uint8_t pad[304]; | |
121 | + ctx = blk ? blk_get_aio_context(blk) : bdrv_get_aio_context(bs); | 192 | +} QEMU_PACKED VMDKSESparseConstHeader; |
122 | + aio_context_acquire(ctx); | 193 | + |
123 | + | 194 | +typedef struct VMDKSESparseVolatileHeader { |
124 | + if (bs) { | 195 | + uint64_t magic; |
125 | + blk = local_blk = blk_new(bdrv_get_aio_context(bs), 0, BLK_PERM_ALL); | 196 | + uint64_t free_gt_number; |
126 | + ret = blk_insert_bs(blk, bs, &err); | 197 | + uint64_t next_txn_seq_number; |
127 | + if (ret < 0) { | 198 | + uint64_t replay_journal; |
128 | + goto fail; | 199 | + uint8_t pad[480]; |
200 | +} QEMU_PACKED VMDKSESparseVolatileHeader; | ||
201 | + | ||
202 | #define L2_CACHE_SIZE 16 | ||
203 | |||
204 | typedef struct VmdkExtent { | ||
205 | @@ -XXX,XX +XXX,XX @@ typedef struct VmdkExtent { | ||
206 | bool compressed; | ||
207 | bool has_marker; | ||
208 | bool has_zero_grain; | ||
209 | + bool sesparse; | ||
210 | + uint64_t sesparse_l2_tables_offset; | ||
211 | + uint64_t sesparse_clusters_offset; | ||
212 | + int32_t entry_size; | ||
213 | int version; | ||
214 | int64_t sectors; | ||
215 | int64_t end_sector; | ||
216 | int64_t flat_start_offset; | ||
217 | int64_t l1_table_offset; | ||
218 | int64_t l1_backup_table_offset; | ||
219 | - uint32_t *l1_table; | ||
220 | + void *l1_table; | ||
221 | uint32_t *l1_backup_table; | ||
222 | unsigned int l1_size; | ||
223 | uint32_t l1_entry_sectors; | ||
224 | |||
225 | unsigned int l2_size; | ||
226 | - uint32_t *l2_cache; | ||
227 | + void *l2_cache; | ||
228 | uint32_t l2_cache_offsets[L2_CACHE_SIZE]; | ||
229 | uint32_t l2_cache_counts[L2_CACHE_SIZE]; | ||
230 | |||
231 | @@ -XXX,XX +XXX,XX @@ static int vmdk_add_extent(BlockDriverState *bs, | ||
232 | * minimal L2 table size: 512 entries | ||
233 | * 8 TB is still more than the maximal value supported for | ||
234 | * VMDK3 & VMDK4 which is 2TB. | ||
235 | + * 64TB - for "ESXi seSparse Extent" | ||
236 | + * minimal cluster size: 512B (default is 4KB) | ||
237 | + * L2 table size: 4096 entries (const). | ||
238 | + * 64TB is more than the maximal value supported for | ||
239 | + * seSparse VMDKs (which is slightly less than 64TB) | ||
240 | */ | ||
241 | error_setg(errp, "L1 size too big"); | ||
242 | return -EFBIG; | ||
243 | @@ -XXX,XX +XXX,XX @@ static int vmdk_add_extent(BlockDriverState *bs, | ||
244 | extent->l2_size = l2_size; | ||
245 | extent->cluster_sectors = flat ? sectors : cluster_sectors; | ||
246 | extent->next_cluster_sector = ROUND_UP(nb_sectors, cluster_sectors); | ||
247 | + extent->entry_size = sizeof(uint32_t); | ||
248 | |||
249 | if (s->num_extents > 1) { | ||
250 | extent->end_sector = (*(extent - 1)).end_sector + extent->sectors; | ||
251 | @@ -XXX,XX +XXX,XX @@ static int vmdk_init_tables(BlockDriverState *bs, VmdkExtent *extent, | ||
252 | int i; | ||
253 | |||
254 | /* read the L1 table */ | ||
255 | - l1_size = extent->l1_size * sizeof(uint32_t); | ||
256 | + l1_size = extent->l1_size * extent->entry_size; | ||
257 | extent->l1_table = g_try_malloc(l1_size); | ||
258 | if (l1_size && extent->l1_table == NULL) { | ||
259 | return -ENOMEM; | ||
260 | @@ -XXX,XX +XXX,XX @@ static int vmdk_init_tables(BlockDriverState *bs, VmdkExtent *extent, | ||
261 | goto fail_l1; | ||
262 | } | ||
263 | for (i = 0; i < extent->l1_size; i++) { | ||
264 | - le32_to_cpus(&extent->l1_table[i]); | ||
265 | + if (extent->entry_size == sizeof(uint64_t)) { | ||
266 | + le64_to_cpus((uint64_t *)extent->l1_table + i); | ||
267 | + } else { | ||
268 | + assert(extent->entry_size == sizeof(uint32_t)); | ||
269 | + le32_to_cpus((uint32_t *)extent->l1_table + i); | ||
129 | + } | 270 | + } |
130 | + } | 271 | } |
131 | + | 272 | |
132 | /* | 273 | if (extent->l1_backup_table_offset) { |
133 | * Notably absent: Proper permission management. This is sad, but it seems | 274 | + assert(!extent->sesparse); |
134 | * almost impossible to achieve without changing the semantics and thereby | 275 | extent->l1_backup_table = g_try_malloc(l1_size); |
135 | @@ -XXX,XX +XXX,XX @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict) | 276 | if (l1_size && extent->l1_backup_table == NULL) { |
136 | 277 | ret = -ENOMEM; | |
137 | fail: | 278 | @@ -XXX,XX +XXX,XX @@ static int vmdk_init_tables(BlockDriverState *bs, VmdkExtent *extent, |
138 | blk_unref(local_blk); | 279 | } |
139 | + | 280 | |
140 | + if (ctx) { | 281 | extent->l2_cache = |
141 | + aio_context_release(ctx); | 282 | - g_new(uint32_t, extent->l2_size * L2_CACHE_SIZE); |
142 | + } | 283 | + g_malloc(extent->entry_size * extent->l2_size * L2_CACHE_SIZE); |
143 | + | 284 | return 0; |
144 | hmp_handle_error(mon, err); | 285 | fail_l1b: |
286 | g_free(extent->l1_backup_table); | ||
287 | @@ -XXX,XX +XXX,XX @@ static int vmdk_open_vmfs_sparse(BlockDriverState *bs, | ||
288 | return ret; | ||
145 | } | 289 | } |
146 | 290 | ||
147 | diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c | 291 | +#define SESPARSE_CONST_HEADER_MAGIC UINT64_C(0x00000000cafebabe) |
148 | index XXXXXXX..XXXXXXX 100644 | 292 | +#define SESPARSE_VOLATILE_HEADER_MAGIC UINT64_C(0x00000000cafecafe) |
149 | --- a/qemu-io-cmds.c | 293 | + |
150 | +++ b/qemu-io-cmds.c | 294 | +/* Strict checks - format not officially documented */ |
151 | @@ -XXX,XX +XXX,XX @@ static const cmdinfo_t help_cmd = { | 295 | +static int check_se_sparse_const_header(VMDKSESparseConstHeader *header, |
152 | .oneline = "help for one or all commands", | 296 | + Error **errp) |
153 | }; | 297 | +{ |
154 | 298 | + header->magic = le64_to_cpu(header->magic); | |
155 | +/* | 299 | + header->version = le64_to_cpu(header->version); |
156 | + * Called with aio context of blk acquired. Or with qemu_get_aio_context() | 300 | + header->grain_size = le64_to_cpu(header->grain_size); |
157 | + * context acquired if blk is NULL. | 301 | + header->grain_table_size = le64_to_cpu(header->grain_table_size); |
158 | + */ | 302 | + header->flags = le64_to_cpu(header->flags); |
159 | int qemuio_command(BlockBackend *blk, const char *cmd) | 303 | + header->reserved1 = le64_to_cpu(header->reserved1); |
160 | { | 304 | + header->reserved2 = le64_to_cpu(header->reserved2); |
161 | - AioContext *ctx; | 305 | + header->reserved3 = le64_to_cpu(header->reserved3); |
162 | char *input; | 306 | + header->reserved4 = le64_to_cpu(header->reserved4); |
163 | const cmdinfo_t *ct; | 307 | + |
164 | char **v; | 308 | + header->volatile_header_offset = |
165 | @@ -XXX,XX +XXX,XX @@ int qemuio_command(BlockBackend *blk, const char *cmd) | 309 | + le64_to_cpu(header->volatile_header_offset); |
166 | if (c) { | 310 | + header->volatile_header_size = le64_to_cpu(header->volatile_header_size); |
167 | ct = find_command(v[0]); | 311 | + |
168 | if (ct) { | 312 | + header->journal_header_offset = le64_to_cpu(header->journal_header_offset); |
169 | - ctx = blk ? blk_get_aio_context(blk) : qemu_get_aio_context(); | 313 | + header->journal_header_size = le64_to_cpu(header->journal_header_size); |
170 | - aio_context_acquire(ctx); | 314 | + |
171 | ret = command(blk, ct, c, v); | 315 | + header->journal_offset = le64_to_cpu(header->journal_offset); |
172 | - aio_context_release(ctx); | 316 | + header->journal_size = le64_to_cpu(header->journal_size); |
173 | } else { | 317 | + |
174 | fprintf(stderr, "command \"%s\" not found\n", v[0]); | 318 | + header->grain_dir_offset = le64_to_cpu(header->grain_dir_offset); |
175 | ret = -EINVAL; | 319 | + header->grain_dir_size = le64_to_cpu(header->grain_dir_size); |
176 | diff --git a/qemu-io.c b/qemu-io.c | 320 | + |
177 | index XXXXXXX..XXXXXXX 100644 | 321 | + header->grain_tables_offset = le64_to_cpu(header->grain_tables_offset); |
178 | --- a/qemu-io.c | 322 | + header->grain_tables_size = le64_to_cpu(header->grain_tables_size); |
179 | +++ b/qemu-io.c | 323 | + |
180 | @@ -XXX,XX +XXX,XX @@ static void prep_fetchline(void *opaque) | 324 | + header->free_bitmap_offset = le64_to_cpu(header->free_bitmap_offset); |
181 | *fetchable= 1; | 325 | + header->free_bitmap_size = le64_to_cpu(header->free_bitmap_size); |
182 | } | 326 | + |
183 | 327 | + header->backmap_offset = le64_to_cpu(header->backmap_offset); | |
184 | +static int do_qemuio_command(const char *cmd) | 328 | + header->backmap_size = le64_to_cpu(header->backmap_size); |
329 | + | ||
330 | + header->grains_offset = le64_to_cpu(header->grains_offset); | ||
331 | + header->grains_size = le64_to_cpu(header->grains_size); | ||
332 | + | ||
333 | + if (header->magic != SESPARSE_CONST_HEADER_MAGIC) { | ||
334 | + error_setg(errp, "Bad const header magic: 0x%016" PRIx64, | ||
335 | + header->magic); | ||
336 | + return -EINVAL; | ||
337 | + } | ||
338 | + | ||
339 | + if (header->version != 0x0000000200000001) { | ||
340 | + error_setg(errp, "Unsupported version: 0x%016" PRIx64, | ||
341 | + header->version); | ||
342 | + return -ENOTSUP; | ||
343 | + } | ||
344 | + | ||
345 | + if (header->grain_size != 8) { | ||
346 | + error_setg(errp, "Unsupported grain size: %" PRIu64, | ||
347 | + header->grain_size); | ||
348 | + return -ENOTSUP; | ||
349 | + } | ||
350 | + | ||
351 | + if (header->grain_table_size != 64) { | ||
352 | + error_setg(errp, "Unsupported grain table size: %" PRIu64, | ||
353 | + header->grain_table_size); | ||
354 | + return -ENOTSUP; | ||
355 | + } | ||
356 | + | ||
357 | + if (header->flags != 0) { | ||
358 | + error_setg(errp, "Unsupported flags: 0x%016" PRIx64, | ||
359 | + header->flags); | ||
360 | + return -ENOTSUP; | ||
361 | + } | ||
362 | + | ||
363 | + if (header->reserved1 != 0 || header->reserved2 != 0 || | ||
364 | + header->reserved3 != 0 || header->reserved4 != 0) { | ||
365 | + error_setg(errp, "Unsupported reserved bits:" | ||
366 | + " 0x%016" PRIx64 " 0x%016" PRIx64 | ||
367 | + " 0x%016" PRIx64 " 0x%016" PRIx64, | ||
368 | + header->reserved1, header->reserved2, | ||
369 | + header->reserved3, header->reserved4); | ||
370 | + return -ENOTSUP; | ||
371 | + } | ||
372 | + | ||
373 | + /* check that padding is 0 */ | ||
374 | + if (!buffer_is_zero(header->pad, sizeof(header->pad))) { | ||
375 | + error_setg(errp, "Unsupported non-zero const header padding"); | ||
376 | + return -ENOTSUP; | ||
377 | + } | ||
378 | + | ||
379 | + return 0; | ||
380 | +} | ||
381 | + | ||
382 | +static int check_se_sparse_volatile_header(VMDKSESparseVolatileHeader *header, | ||
383 | + Error **errp) | ||
384 | +{ | ||
385 | + header->magic = le64_to_cpu(header->magic); | ||
386 | + header->free_gt_number = le64_to_cpu(header->free_gt_number); | ||
387 | + header->next_txn_seq_number = le64_to_cpu(header->next_txn_seq_number); | ||
388 | + header->replay_journal = le64_to_cpu(header->replay_journal); | ||
389 | + | ||
390 | + if (header->magic != SESPARSE_VOLATILE_HEADER_MAGIC) { | ||
391 | + error_setg(errp, "Bad volatile header magic: 0x%016" PRIx64, | ||
392 | + header->magic); | ||
393 | + return -EINVAL; | ||
394 | + } | ||
395 | + | ||
396 | + if (header->replay_journal) { | ||
397 | + error_setg(errp, "Image is dirty, Replaying journal not supported"); | ||
398 | + return -ENOTSUP; | ||
399 | + } | ||
400 | + | ||
401 | + /* check that padding is 0 */ | ||
402 | + if (!buffer_is_zero(header->pad, sizeof(header->pad))) { | ||
403 | + error_setg(errp, "Unsupported non-zero volatile header padding"); | ||
404 | + return -ENOTSUP; | ||
405 | + } | ||
406 | + | ||
407 | + return 0; | ||
408 | +} | ||
409 | + | ||
410 | +static int vmdk_open_se_sparse(BlockDriverState *bs, | ||
411 | + BdrvChild *file, | ||
412 | + int flags, Error **errp) | ||
185 | +{ | 413 | +{ |
186 | + int ret; | 414 | + int ret; |
187 | + AioContext *ctx = | 415 | + VMDKSESparseConstHeader const_header; |
188 | + qemuio_blk ? blk_get_aio_context(qemuio_blk) : qemu_get_aio_context(); | 416 | + VMDKSESparseVolatileHeader volatile_header; |
189 | + | 417 | + VmdkExtent *extent; |
190 | + aio_context_acquire(ctx); | 418 | + |
191 | + ret = qemuio_command(qemuio_blk, cmd); | 419 | + ret = bdrv_apply_auto_read_only(bs, |
192 | + aio_context_release(ctx); | 420 | + "No write support for seSparse images available", errp); |
421 | + if (ret < 0) { | ||
422 | + return ret; | ||
423 | + } | ||
424 | + | ||
425 | + assert(sizeof(const_header) == SECTOR_SIZE); | ||
426 | + | ||
427 | + ret = bdrv_pread(file, 0, &const_header, sizeof(const_header)); | ||
428 | + if (ret < 0) { | ||
429 | + bdrv_refresh_filename(file->bs); | ||
430 | + error_setg_errno(errp, -ret, | ||
431 | + "Could not read const header from file '%s'", | ||
432 | + file->bs->filename); | ||
433 | + return ret; | ||
434 | + } | ||
435 | + | ||
436 | + /* check const header */ | ||
437 | + ret = check_se_sparse_const_header(&const_header, errp); | ||
438 | + if (ret < 0) { | ||
439 | + return ret; | ||
440 | + } | ||
441 | + | ||
442 | + assert(sizeof(volatile_header) == SECTOR_SIZE); | ||
443 | + | ||
444 | + ret = bdrv_pread(file, | ||
445 | + const_header.volatile_header_offset * SECTOR_SIZE, | ||
446 | + &volatile_header, sizeof(volatile_header)); | ||
447 | + if (ret < 0) { | ||
448 | + bdrv_refresh_filename(file->bs); | ||
449 | + error_setg_errno(errp, -ret, | ||
450 | + "Could not read volatile header from file '%s'", | ||
451 | + file->bs->filename); | ||
452 | + return ret; | ||
453 | + } | ||
454 | + | ||
455 | + /* check volatile header */ | ||
456 | + ret = check_se_sparse_volatile_header(&volatile_header, errp); | ||
457 | + if (ret < 0) { | ||
458 | + return ret; | ||
459 | + } | ||
460 | + | ||
461 | + ret = vmdk_add_extent(bs, file, false, | ||
462 | + const_header.capacity, | ||
463 | + const_header.grain_dir_offset * SECTOR_SIZE, | ||
464 | + 0, | ||
465 | + const_header.grain_dir_size * | ||
466 | + SECTOR_SIZE / sizeof(uint64_t), | ||
467 | + const_header.grain_table_size * | ||
468 | + SECTOR_SIZE / sizeof(uint64_t), | ||
469 | + const_header.grain_size, | ||
470 | + &extent, | ||
471 | + errp); | ||
472 | + if (ret < 0) { | ||
473 | + return ret; | ||
474 | + } | ||
475 | + | ||
476 | + extent->sesparse = true; | ||
477 | + extent->sesparse_l2_tables_offset = const_header.grain_tables_offset; | ||
478 | + extent->sesparse_clusters_offset = const_header.grains_offset; | ||
479 | + extent->entry_size = sizeof(uint64_t); | ||
480 | + | ||
481 | + ret = vmdk_init_tables(bs, extent, errp); | ||
482 | + if (ret) { | ||
483 | + /* free extent allocated by vmdk_add_extent */ | ||
484 | + vmdk_free_last_extent(bs); | ||
485 | + } | ||
193 | + | 486 | + |
194 | + return ret; | 487 | + return ret; |
195 | +} | 488 | +} |
196 | + | 489 | + |
197 | static int command_loop(void) | 490 | static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf, |
491 | QDict *options, Error **errp); | ||
492 | |||
493 | @@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, | ||
494 | * RW [size in sectors] SPARSE "file-name.vmdk" | ||
495 | * RW [size in sectors] VMFS "file-name.vmdk" | ||
496 | * RW [size in sectors] VMFSSPARSE "file-name.vmdk" | ||
497 | + * RW [size in sectors] SESPARSE "file-name.vmdk" | ||
498 | */ | ||
499 | flat_offset = -1; | ||
500 | matches = sscanf(p, "%10s %" SCNd64 " %10s \"%511[^\n\r\"]\" %" SCNd64, | ||
501 | @@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, | ||
502 | |||
503 | if (sectors <= 0 || | ||
504 | (strcmp(type, "FLAT") && strcmp(type, "SPARSE") && | ||
505 | - strcmp(type, "VMFS") && strcmp(type, "VMFSSPARSE")) || | ||
506 | + strcmp(type, "VMFS") && strcmp(type, "VMFSSPARSE") && | ||
507 | + strcmp(type, "SESPARSE")) || | ||
508 | (strcmp(access, "RW"))) { | ||
509 | continue; | ||
510 | } | ||
511 | @@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, | ||
512 | return ret; | ||
513 | } | ||
514 | extent = &s->extents[s->num_extents - 1]; | ||
515 | + } else if (!strcmp(type, "SESPARSE")) { | ||
516 | + ret = vmdk_open_se_sparse(bs, extent_file, bs->open_flags, errp); | ||
517 | + if (ret) { | ||
518 | + bdrv_unref_child(bs, extent_file); | ||
519 | + return ret; | ||
520 | + } | ||
521 | + extent = &s->extents[s->num_extents - 1]; | ||
522 | } else { | ||
523 | error_setg(errp, "Unsupported extent type '%s'", type); | ||
524 | bdrv_unref_child(bs, extent_file); | ||
525 | @@ -XXX,XX +XXX,XX @@ static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf, | ||
526 | if (strcmp(ct, "monolithicFlat") && | ||
527 | strcmp(ct, "vmfs") && | ||
528 | strcmp(ct, "vmfsSparse") && | ||
529 | + strcmp(ct, "seSparse") && | ||
530 | strcmp(ct, "twoGbMaxExtentSparse") && | ||
531 | strcmp(ct, "twoGbMaxExtentFlat")) { | ||
532 | error_setg(errp, "Unsupported image type '%s'", ct); | ||
533 | @@ -XXX,XX +XXX,XX @@ static int get_cluster_offset(BlockDriverState *bs, | ||
198 | { | 534 | { |
199 | int i, fetchable = 0, prompted = 0; | 535 | unsigned int l1_index, l2_offset, l2_index; |
200 | @@ -XXX,XX +XXX,XX @@ static int command_loop(void) | 536 | int min_index, i, j; |
201 | char *input; | 537 | - uint32_t min_count, *l2_table; |
202 | 538 | + uint32_t min_count; | |
203 | for (i = 0; !quit_qemu_io && i < ncmdline; i++) { | 539 | + void *l2_table; |
204 | - ret = qemuio_command(qemuio_blk, cmdline[i]); | 540 | bool zeroed = false; |
205 | + ret = do_qemuio_command(cmdline[i]); | 541 | int64_t ret; |
206 | if (ret < 0) { | 542 | int64_t cluster_sector; |
207 | last_error = ret; | 543 | + unsigned int l2_size_bytes = extent->l2_size * extent->entry_size; |
544 | |||
545 | if (m_data) { | ||
546 | m_data->valid = 0; | ||
547 | @@ -XXX,XX +XXX,XX @@ static int get_cluster_offset(BlockDriverState *bs, | ||
548 | if (l1_index >= extent->l1_size) { | ||
549 | return VMDK_ERROR; | ||
550 | } | ||
551 | - l2_offset = extent->l1_table[l1_index]; | ||
552 | + if (extent->sesparse) { | ||
553 | + uint64_t l2_offset_u64; | ||
554 | + | ||
555 | + assert(extent->entry_size == sizeof(uint64_t)); | ||
556 | + | ||
557 | + l2_offset_u64 = ((uint64_t *)extent->l1_table)[l1_index]; | ||
558 | + if (l2_offset_u64 == 0) { | ||
559 | + l2_offset = 0; | ||
560 | + } else if ((l2_offset_u64 & 0xffffffff00000000) != 0x1000000000000000) { | ||
561 | + /* | ||
562 | + * Top most nibble is 0x1 if grain table is allocated. | ||
563 | + * strict check - top most 4 bytes must be 0x10000000 since max | ||
564 | + * supported size is 64TB for disk - so no more than 64TB / 16MB | ||
565 | + * grain directories which is smaller than uint32, | ||
566 | + * where 16MB is the only supported default grain table coverage. | ||
567 | + */ | ||
568 | + return VMDK_ERROR; | ||
569 | + } else { | ||
570 | + l2_offset_u64 = l2_offset_u64 & 0x00000000ffffffff; | ||
571 | + l2_offset_u64 = extent->sesparse_l2_tables_offset + | ||
572 | + l2_offset_u64 * l2_size_bytes / SECTOR_SIZE; | ||
573 | + if (l2_offset_u64 > 0x00000000ffffffff) { | ||
574 | + return VMDK_ERROR; | ||
575 | + } | ||
576 | + l2_offset = (unsigned int)(l2_offset_u64); | ||
577 | + } | ||
578 | + } else { | ||
579 | + assert(extent->entry_size == sizeof(uint32_t)); | ||
580 | + l2_offset = ((uint32_t *)extent->l1_table)[l1_index]; | ||
581 | + } | ||
582 | if (!l2_offset) { | ||
583 | return VMDK_UNALLOC; | ||
584 | } | ||
585 | @@ -XXX,XX +XXX,XX @@ static int get_cluster_offset(BlockDriverState *bs, | ||
586 | extent->l2_cache_counts[j] >>= 1; | ||
587 | } | ||
588 | } | ||
589 | - l2_table = extent->l2_cache + (i * extent->l2_size); | ||
590 | + l2_table = (char *)extent->l2_cache + (i * l2_size_bytes); | ||
591 | goto found; | ||
208 | } | 592 | } |
209 | @@ -XXX,XX +XXX,XX @@ static int command_loop(void) | 593 | } |
210 | if (input == NULL) { | 594 | @@ -XXX,XX +XXX,XX @@ static int get_cluster_offset(BlockDriverState *bs, |
211 | break; | 595 | min_index = i; |
212 | } | 596 | } |
213 | - ret = qemuio_command(qemuio_blk, input); | 597 | } |
214 | + ret = do_qemuio_command(input); | 598 | - l2_table = extent->l2_cache + (min_index * extent->l2_size); |
215 | g_free(input); | 599 | + l2_table = (char *)extent->l2_cache + (min_index * l2_size_bytes); |
216 | 600 | BLKDBG_EVENT(extent->file, BLKDBG_L2_LOAD); | |
217 | if (ret < 0) { | 601 | if (bdrv_pread(extent->file, |
602 | (int64_t)l2_offset * 512, | ||
603 | l2_table, | ||
604 | - extent->l2_size * sizeof(uint32_t) | ||
605 | - ) != extent->l2_size * sizeof(uint32_t)) { | ||
606 | + l2_size_bytes | ||
607 | + ) != l2_size_bytes) { | ||
608 | return VMDK_ERROR; | ||
609 | } | ||
610 | |||
611 | @@ -XXX,XX +XXX,XX @@ static int get_cluster_offset(BlockDriverState *bs, | ||
612 | extent->l2_cache_counts[min_index] = 1; | ||
613 | found: | ||
614 | l2_index = ((offset >> 9) / extent->cluster_sectors) % extent->l2_size; | ||
615 | - cluster_sector = le32_to_cpu(l2_table[l2_index]); | ||
616 | |||
617 | - if (extent->has_zero_grain && cluster_sector == VMDK_GTE_ZEROED) { | ||
618 | - zeroed = true; | ||
619 | + if (extent->sesparse) { | ||
620 | + cluster_sector = le64_to_cpu(((uint64_t *)l2_table)[l2_index]); | ||
621 | + switch (cluster_sector & 0xf000000000000000) { | ||
622 | + case 0x0000000000000000: | ||
623 | + /* unallocated grain */ | ||
624 | + if (cluster_sector != 0) { | ||
625 | + return VMDK_ERROR; | ||
626 | + } | ||
627 | + break; | ||
628 | + case 0x1000000000000000: | ||
629 | + /* scsi-unmapped grain - fallthrough */ | ||
630 | + case 0x2000000000000000: | ||
631 | + /* zero grain */ | ||
632 | + zeroed = true; | ||
633 | + break; | ||
634 | + case 0x3000000000000000: | ||
635 | + /* allocated grain */ | ||
636 | + cluster_sector = (((cluster_sector & 0x0fff000000000000) >> 48) | | ||
637 | + ((cluster_sector & 0x0000ffffffffffff) << 12)); | ||
638 | + cluster_sector = extent->sesparse_clusters_offset + | ||
639 | + cluster_sector * extent->cluster_sectors; | ||
640 | + break; | ||
641 | + default: | ||
642 | + return VMDK_ERROR; | ||
643 | + } | ||
644 | + } else { | ||
645 | + cluster_sector = le32_to_cpu(((uint32_t *)l2_table)[l2_index]); | ||
646 | + | ||
647 | + if (extent->has_zero_grain && cluster_sector == VMDK_GTE_ZEROED) { | ||
648 | + zeroed = true; | ||
649 | + } | ||
650 | } | ||
651 | |||
652 | if (!cluster_sector || zeroed) { | ||
653 | if (!allocate) { | ||
654 | return zeroed ? VMDK_ZEROED : VMDK_UNALLOC; | ||
655 | } | ||
656 | + assert(!extent->sesparse); | ||
657 | |||
658 | if (extent->next_cluster_sector >= VMDK_EXTENT_MAX_SECTORS) { | ||
659 | return VMDK_ERROR; | ||
660 | @@ -XXX,XX +XXX,XX @@ static int get_cluster_offset(BlockDriverState *bs, | ||
661 | m_data->l1_index = l1_index; | ||
662 | m_data->l2_index = l2_index; | ||
663 | m_data->l2_offset = l2_offset; | ||
664 | - m_data->l2_cache_entry = &l2_table[l2_index]; | ||
665 | + m_data->l2_cache_entry = ((uint32_t *)l2_table) + l2_index; | ||
666 | } | ||
667 | } | ||
668 | *cluster_offset = cluster_sector << BDRV_SECTOR_BITS; | ||
669 | @@ -XXX,XX +XXX,XX @@ static int vmdk_pwritev(BlockDriverState *bs, uint64_t offset, | ||
670 | if (!extent) { | ||
671 | return -EIO; | ||
672 | } | ||
673 | + if (extent->sesparse) { | ||
674 | + return -ENOTSUP; | ||
675 | + } | ||
676 | offset_in_cluster = vmdk_find_offset_in_cluster(extent, offset); | ||
677 | n_bytes = MIN(bytes, extent->cluster_sectors * BDRV_SECTOR_SIZE | ||
678 | - offset_in_cluster); | ||
218 | -- | 679 | -- |
219 | 2.31.1 | 680 | 2.21.0 |
220 | 681 | ||
221 | 682 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
2 | 1 | ||
3 | If mirror is READY than cancel operation is not discarding the whole | ||
4 | result of the operation, but instead it's a documented way get a | ||
5 | point-in-time snapshot of source disk. | ||
6 | |||
7 | So, we should not cancel any requests if mirror is READ and | ||
8 | force=false. Let's fix that case. | ||
9 | |||
10 | Note, that bug that we have before this commit is not critical, as the | ||
11 | only .bdrv_cancel_in_flight implementation is nbd_cancel_in_flight() | ||
12 | and it cancels only requests waiting for reconnection, so it should be | ||
13 | rare case. | ||
14 | |||
15 | Fixes: 521ff8b779b11c394dbdc43f02e158dd99df308a | ||
16 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
17 | Message-Id: <20210421075858.40197-1-vsementsov@virtuozzo.com> | ||
18 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
19 | --- | ||
20 | include/block/block_int.h | 2 +- | ||
21 | include/qemu/job.h | 2 +- | ||
22 | block/backup.c | 2 +- | ||
23 | block/mirror.c | 6 ++++-- | ||
24 | job.c | 2 +- | ||
25 | tests/qemu-iotests/264 | 2 +- | ||
26 | 6 files changed, 9 insertions(+), 7 deletions(-) | ||
27 | |||
28 | diff --git a/include/block/block_int.h b/include/block/block_int.h | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/include/block/block_int.h | ||
31 | +++ b/include/block/block_int.h | ||
32 | @@ -XXX,XX +XXX,XX @@ struct BlockDriver { | ||
33 | * of in-flight requests, so don't waste the time if possible. | ||
34 | * | ||
35 | * One example usage is to avoid waiting for an nbd target node reconnect | ||
36 | - * timeout during job-cancel. | ||
37 | + * timeout during job-cancel with force=true. | ||
38 | */ | ||
39 | void (*bdrv_cancel_in_flight)(BlockDriverState *bs); | ||
40 | |||
41 | diff --git a/include/qemu/job.h b/include/qemu/job.h | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/include/qemu/job.h | ||
44 | +++ b/include/qemu/job.h | ||
45 | @@ -XXX,XX +XXX,XX @@ struct JobDriver { | ||
46 | /** | ||
47 | * If the callback is not NULL, it will be invoked in job_cancel_async | ||
48 | */ | ||
49 | - void (*cancel)(Job *job); | ||
50 | + void (*cancel)(Job *job, bool force); | ||
51 | |||
52 | |||
53 | /** Called when the job is freed */ | ||
54 | diff --git a/block/backup.c b/block/backup.c | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/block/backup.c | ||
57 | +++ b/block/backup.c | ||
58 | @@ -XXX,XX +XXX,XX @@ static void coroutine_fn backup_set_speed(BlockJob *job, int64_t speed) | ||
59 | } | ||
60 | } | ||
61 | |||
62 | -static void backup_cancel(Job *job) | ||
63 | +static void backup_cancel(Job *job, bool force) | ||
64 | { | ||
65 | BackupBlockJob *s = container_of(job, BackupBlockJob, common.job); | ||
66 | |||
67 | diff --git a/block/mirror.c b/block/mirror.c | ||
68 | index XXXXXXX..XXXXXXX 100644 | ||
69 | --- a/block/mirror.c | ||
70 | +++ b/block/mirror.c | ||
71 | @@ -XXX,XX +XXX,XX @@ static bool mirror_drained_poll(BlockJob *job) | ||
72 | return !!s->in_flight; | ||
73 | } | ||
74 | |||
75 | -static void mirror_cancel(Job *job) | ||
76 | +static void mirror_cancel(Job *job, bool force) | ||
77 | { | ||
78 | MirrorBlockJob *s = container_of(job, MirrorBlockJob, common.job); | ||
79 | BlockDriverState *target = blk_bs(s->target); | ||
80 | |||
81 | - bdrv_cancel_in_flight(target); | ||
82 | + if (force || !job_is_ready(job)) { | ||
83 | + bdrv_cancel_in_flight(target); | ||
84 | + } | ||
85 | } | ||
86 | |||
87 | static const BlockJobDriver mirror_job_driver = { | ||
88 | diff --git a/job.c b/job.c | ||
89 | index XXXXXXX..XXXXXXX 100644 | ||
90 | --- a/job.c | ||
91 | +++ b/job.c | ||
92 | @@ -XXX,XX +XXX,XX @@ static int job_finalize_single(Job *job) | ||
93 | static void job_cancel_async(Job *job, bool force) | ||
94 | { | ||
95 | if (job->driver->cancel) { | ||
96 | - job->driver->cancel(job); | ||
97 | + job->driver->cancel(job, force); | ||
98 | } | ||
99 | if (job->user_paused) { | ||
100 | /* Do not call job_enter here, the caller will handle it. */ | ||
101 | diff --git a/tests/qemu-iotests/264 b/tests/qemu-iotests/264 | ||
102 | index XXXXXXX..XXXXXXX 100755 | ||
103 | --- a/tests/qemu-iotests/264 | ||
104 | +++ b/tests/qemu-iotests/264 | ||
105 | @@ -XXX,XX +XXX,XX @@ class TestNbdReconnect(iotests.QMPTestCase): | ||
106 | self.assert_qmp(result, 'return', {}) | ||
107 | |||
108 | def cancel_job(self): | ||
109 | - result = self.vm.qmp('block-job-cancel', device='drive0') | ||
110 | + result = self.vm.qmp('block-job-cancel', device='drive0', force=True) | ||
111 | self.assert_qmp(result, 'return', {}) | ||
112 | |||
113 | start_t = time.time() | ||
114 | -- | ||
115 | 2.31.1 | ||
116 | |||
117 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Paolo Bonzini <pbonzini@redhat.com> | ||
2 | 1 | ||
3 | Instead of buffering the test output into a StringIO, patch it on | ||
4 | the fly by wrapping sys.stdout's write method. This can be | ||
5 | done unconditionally, even if using -d, which makes execute_unittest | ||
6 | a bit simpler. | ||
7 | |||
8 | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> | ||
9 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
10 | Tested-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> | ||
11 | Message-Id: <20210323181928.311862-2-pbonzini@redhat.com> | ||
12 | Message-Id: <20210503110110.476887-2-pbonzini@redhat.com> | ||
13 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
14 | --- | ||
15 | tests/qemu-iotests/240.out | 8 ++-- | ||
16 | tests/qemu-iotests/245.out | 8 ++-- | ||
17 | tests/qemu-iotests/295.out | 6 +-- | ||
18 | tests/qemu-iotests/296.out | 8 ++-- | ||
19 | tests/qemu-iotests/iotests.py | 70 ++++++++++++++++++++--------------- | ||
20 | 5 files changed, 56 insertions(+), 44 deletions(-) | ||
21 | |||
22 | diff --git a/tests/qemu-iotests/240.out b/tests/qemu-iotests/240.out | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/tests/qemu-iotests/240.out | ||
25 | +++ b/tests/qemu-iotests/240.out | ||
26 | @@ -XXX,XX +XXX,XX @@ | ||
27 | {"return": {}} | ||
28 | {"execute": "blockdev-del", "arguments": {"node-name": "hd0"}} | ||
29 | {"return": {}} | ||
30 | -==Attach two SCSI disks using the same block device and the same iothread== | ||
31 | +.==Attach two SCSI disks using the same block device and the same iothread== | ||
32 | {"execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "hd0", "read-only": true, "read-zeroes": true}} | ||
33 | {"return": {}} | ||
34 | {"execute": "object-add", "arguments": {"id": "iothread0", "qom-type": "iothread"}} | ||
35 | @@ -XXX,XX +XXX,XX @@ | ||
36 | {"return": {}} | ||
37 | {"execute": "blockdev-del", "arguments": {"node-name": "hd0"}} | ||
38 | {"return": {}} | ||
39 | -==Attach two SCSI disks using the same block device but different iothreads== | ||
40 | +.==Attach two SCSI disks using the same block device but different iothreads== | ||
41 | {"execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "hd0", "read-only": true, "read-zeroes": true}} | ||
42 | {"return": {}} | ||
43 | {"execute": "object-add", "arguments": {"id": "iothread0", "qom-type": "iothread"}} | ||
44 | @@ -XXX,XX +XXX,XX @@ | ||
45 | {"return": {}} | ||
46 | {"execute": "blockdev-del", "arguments": {"node-name": "hd0"}} | ||
47 | {"return": {}} | ||
48 | -==Attach a SCSI disks using the same block device as a NBD server== | ||
49 | +.==Attach a SCSI disks using the same block device as a NBD server== | ||
50 | {"execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "hd0", "read-only": true, "read-zeroes": true}} | ||
51 | {"return": {}} | ||
52 | {"execute": "nbd-server-start", "arguments": {"addr": {"data": {"path": "SOCK_DIR/PID-nbd.sock"}, "type": "unix"}}} | ||
53 | @@ -XXX,XX +XXX,XX @@ | ||
54 | {"return": {}} | ||
55 | {"execute": "device_add", "arguments": {"drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd0"}} | ||
56 | {"return": {}} | ||
57 | -.... | ||
58 | +. | ||
59 | ---------------------------------------------------------------------- | ||
60 | Ran 4 tests | ||
61 | |||
62 | diff --git a/tests/qemu-iotests/245.out b/tests/qemu-iotests/245.out | ||
63 | index XXXXXXX..XXXXXXX 100644 | ||
64 | --- a/tests/qemu-iotests/245.out | ||
65 | +++ b/tests/qemu-iotests/245.out | ||
66 | @@ -XXX,XX +XXX,XX @@ | ||
67 | -{"execute": "job-finalize", "arguments": {"id": "commit0"}} | ||
68 | +..{"execute": "job-finalize", "arguments": {"id": "commit0"}} | ||
69 | {"return": {}} | ||
70 | {"data": {"id": "commit0", "type": "commit"}, "event": "BLOCK_JOB_PENDING", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} | ||
71 | {"data": {"device": "commit0", "len": 3145728, "offset": 3145728, "speed": 0, "type": "commit"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} | ||
72 | -{"execute": "job-finalize", "arguments": {"id": "stream0"}} | ||
73 | +...{"execute": "job-finalize", "arguments": {"id": "stream0"}} | ||
74 | {"return": {}} | ||
75 | {"data": {"id": "stream0", "type": "stream"}, "event": "BLOCK_JOB_PENDING", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} | ||
76 | {"data": {"device": "stream0", "len": 3145728, "offset": 3145728, "speed": 0, "type": "stream"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} | ||
77 | -{"execute": "job-finalize", "arguments": {"id": "stream0"}} | ||
78 | +.{"execute": "job-finalize", "arguments": {"id": "stream0"}} | ||
79 | {"return": {}} | ||
80 | {"data": {"id": "stream0", "type": "stream"}, "event": "BLOCK_JOB_PENDING", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} | ||
81 | {"data": {"device": "stream0", "len": 3145728, "offset": 3145728, "speed": 0, "type": "stream"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} | ||
82 | -..................... | ||
83 | +............... | ||
84 | ---------------------------------------------------------------------- | ||
85 | Ran 21 tests | ||
86 | |||
87 | diff --git a/tests/qemu-iotests/295.out b/tests/qemu-iotests/295.out | ||
88 | index XXXXXXX..XXXXXXX 100644 | ||
89 | --- a/tests/qemu-iotests/295.out | ||
90 | +++ b/tests/qemu-iotests/295.out | ||
91 | @@ -XXX,XX +XXX,XX @@ | ||
92 | {"return": {}} | ||
93 | {"execute": "job-dismiss", "arguments": {"id": "job_erase_key"}} | ||
94 | {"return": {}} | ||
95 | -{"execute": "job-dismiss", "arguments": {"id": "job_add_key"}} | ||
96 | +.{"execute": "job-dismiss", "arguments": {"id": "job_add_key"}} | ||
97 | {"return": {}} | ||
98 | {"execute": "job-dismiss", "arguments": {"id": "job_erase_key"}} | ||
99 | {"return": {}} | ||
100 | @@ -XXX,XX +XXX,XX @@ Job failed: Invalid password, cannot unlock any keyslot | ||
101 | {"return": {}} | ||
102 | {"execute": "job-dismiss", "arguments": {"id": "job_add_key"}} | ||
103 | {"return": {}} | ||
104 | -{"execute": "job-dismiss", "arguments": {"id": "job_add_key"}} | ||
105 | +.{"execute": "job-dismiss", "arguments": {"id": "job_add_key"}} | ||
106 | {"return": {}} | ||
107 | {"execute": "job-dismiss", "arguments": {"id": "job_add_key"}} | ||
108 | {"return": {}} | ||
109 | @@ -XXX,XX +XXX,XX @@ Job failed: All the active keyslots match the (old) password that was given and | ||
110 | {"return": {}} | ||
111 | {"execute": "job-dismiss", "arguments": {"id": "job_erase_key"}} | ||
112 | {"return": {}} | ||
113 | -... | ||
114 | +. | ||
115 | ---------------------------------------------------------------------- | ||
116 | Ran 3 tests | ||
117 | |||
118 | diff --git a/tests/qemu-iotests/296.out b/tests/qemu-iotests/296.out | ||
119 | index XXXXXXX..XXXXXXX 100644 | ||
120 | --- a/tests/qemu-iotests/296.out | ||
121 | +++ b/tests/qemu-iotests/296.out | ||
122 | @@ -XXX,XX +XXX,XX @@ Job failed: Failed to get shared "consistent read" lock | ||
123 | qemu-img: Failed to get shared "consistent read" lock | ||
124 | Is another process using the image [TEST_DIR/test.img]? | ||
125 | |||
126 | -Formatting 'TEST_DIR/test.img', fmt=luks size=1048576 key-secret=keysec0 iter-time=10 | ||
127 | +.Formatting 'TEST_DIR/test.img', fmt=luks size=1048576 key-secret=keysec0 iter-time=10 | ||
128 | |||
129 | Job failed: Block node is read-only | ||
130 | {"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
131 | @@ -XXX,XX +XXX,XX @@ Job failed: Failed to get shared "consistent read" lock | ||
132 | {"return": {}} | ||
133 | {"execute": "job-dismiss", "arguments": {"id": "job0"}} | ||
134 | {"return": {}} | ||
135 | -Formatting 'TEST_DIR/test.img', fmt=luks size=1048576 key-secret=keysec0 iter-time=10 | ||
136 | +.Formatting 'TEST_DIR/test.img', fmt=luks size=1048576 key-secret=keysec0 iter-time=10 | ||
137 | |||
138 | {"return": {}} | ||
139 | {"error": {"class": "GenericError", "desc": "Failed to get \"write\" lock"}} | ||
140 | -Formatting 'TEST_DIR/test.img', fmt=luks size=1048576 key-secret=keysec0 iter-time=10 | ||
141 | +.Formatting 'TEST_DIR/test.img', fmt=luks size=1048576 key-secret=keysec0 iter-time=10 | ||
142 | |||
143 | {"return": {}} | ||
144 | {"return": {}} | ||
145 | -.... | ||
146 | +. | ||
147 | ---------------------------------------------------------------------- | ||
148 | Ran 4 tests | ||
149 | |||
150 | diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py | ||
151 | index XXXXXXX..XXXXXXX 100644 | ||
152 | --- a/tests/qemu-iotests/iotests.py | ||
153 | +++ b/tests/qemu-iotests/iotests.py | ||
154 | @@ -XXX,XX +XXX,XX @@ | ||
155 | import bz2 | ||
156 | from collections import OrderedDict | ||
157 | import faulthandler | ||
158 | -import io | ||
159 | import json | ||
160 | import logging | ||
161 | import os | ||
162 | @@ -XXX,XX +XXX,XX @@ | ||
163 | import sys | ||
164 | import time | ||
165 | from typing import (Any, Callable, Dict, Iterable, | ||
166 | - List, Optional, Sequence, Tuple, TypeVar) | ||
167 | + List, Optional, Sequence, TextIO, Tuple, Type, TypeVar) | ||
168 | import unittest | ||
169 | |||
170 | from contextlib import contextmanager | ||
171 | @@ -XXX,XX +XXX,XX @@ def func_wrapper(*args, **kwargs): | ||
172 | return func(*args, **kwargs) | ||
173 | return func_wrapper | ||
174 | |||
175 | +# We need to filter out the time taken from the output so that | ||
176 | +# qemu-iotest can reliably diff the results against master output, | ||
177 | +# and hide skipped tests from the reference output. | ||
178 | + | ||
179 | +class ReproducibleTestResult(unittest.TextTestResult): | ||
180 | + def addSkip(self, test, reason): | ||
181 | + # Same as TextTestResult, but print dot instead of "s" | ||
182 | + unittest.TestResult.addSkip(self, test, reason) | ||
183 | + if self.showAll: | ||
184 | + self.stream.writeln("skipped {0!r}".format(reason)) | ||
185 | + elif self.dots: | ||
186 | + self.stream.write(".") | ||
187 | + self.stream.flush() | ||
188 | + | ||
189 | +class ReproducibleStreamWrapper: | ||
190 | + def __init__(self, stream: TextIO): | ||
191 | + self.stream = stream | ||
192 | + | ||
193 | + def __getattr__(self, attr): | ||
194 | + if attr in ('stream', '__getstate__'): | ||
195 | + raise AttributeError(attr) | ||
196 | + return getattr(self.stream, attr) | ||
197 | + | ||
198 | + def write(self, arg=None): | ||
199 | + arg = re.sub(r'Ran (\d+) tests? in [\d.]+s', r'Ran \1 tests', arg) | ||
200 | + arg = re.sub(r' \(skipped=\d+\)', r'', arg) | ||
201 | + self.stream.write(arg) | ||
202 | + | ||
203 | +class ReproducibleTestRunner(unittest.TextTestRunner): | ||
204 | + def __init__(self, stream: Optional[TextIO] = None, | ||
205 | + resultclass: Type[unittest.TestResult] = ReproducibleTestResult, | ||
206 | + **kwargs: Any) -> None: | ||
207 | + rstream = ReproducibleStreamWrapper(stream or sys.stdout) | ||
208 | + super().__init__(stream=rstream, # type: ignore | ||
209 | + descriptions=True, | ||
210 | + resultclass=resultclass, | ||
211 | + **kwargs) | ||
212 | + | ||
213 | def execute_unittest(debug=False): | ||
214 | """Executes unittests within the calling module.""" | ||
215 | |||
216 | verbosity = 2 if debug else 1 | ||
217 | - | ||
218 | - if debug: | ||
219 | - output = sys.stdout | ||
220 | - else: | ||
221 | - # We need to filter out the time taken from the output so that | ||
222 | - # qemu-iotest can reliably diff the results against master output. | ||
223 | - output = io.StringIO() | ||
224 | - | ||
225 | - runner = unittest.TextTestRunner(stream=output, descriptions=True, | ||
226 | - verbosity=verbosity) | ||
227 | - try: | ||
228 | - # unittest.main() will use sys.exit(); so expect a SystemExit | ||
229 | - # exception | ||
230 | - unittest.main(testRunner=runner) | ||
231 | - finally: | ||
232 | - # We need to filter out the time taken from the output so that | ||
233 | - # qemu-iotest can reliably diff the results against master output. | ||
234 | - if not debug: | ||
235 | - out = output.getvalue() | ||
236 | - out = re.sub(r'Ran (\d+) tests? in [\d.]+s', r'Ran \1 tests', out) | ||
237 | - | ||
238 | - # Hide skipped tests from the reference output | ||
239 | - out = re.sub(r'OK \(skipped=\d+\)', 'OK', out) | ||
240 | - out_first_line, out_rest = out.split('\n', 1) | ||
241 | - out = out_first_line.replace('s', '.') + '\n' + out_rest | ||
242 | - | ||
243 | - sys.stderr.write(out) | ||
244 | + runner = ReproducibleTestRunner(verbosity=verbosity) | ||
245 | + unittest.main(testRunner=runner) | ||
246 | |||
247 | def execute_setup_common(supported_fmts: Sequence[str] = (), | ||
248 | supported_platforms: Sequence[str] = (), | ||
249 | -- | ||
250 | 2.31.1 | ||
251 | |||
252 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Paolo Bonzini <pbonzini@redhat.com> | ||
2 | 1 | ||
3 | Python test scripts that use unittest consist of multiple tests. | ||
4 | unittest.main allows selecting which tests to run, but currently this | ||
5 | is not possible because the iotests wrapper ignores sys.argv. | ||
6 | |||
7 | unittest.main command line options also allow the user to pick the | ||
8 | desired options for verbosity, failfast mode, etc. While "-d" is | ||
9 | currently translated to "-v", it also enables extra debug output, | ||
10 | and other options are not available at all. | ||
11 | |||
12 | These command line options only work if the unittest.main testRunner | ||
13 | argument is a type, rather than a TestRunner instance. Therefore, pass | ||
14 | the class name and "verbosity" argument to unittest.main, and adjust for | ||
15 | the different default warnings between TextTestRunner and unittest.main. | ||
16 | |||
17 | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> | ||
18 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
19 | Tested-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> | ||
20 | Message-Id: <20210323181928.311862-3-pbonzini@redhat.com> | ||
21 | Message-Id: <20210503110110.476887-3-pbonzini@redhat.com> | ||
22 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
23 | --- | ||
24 | tests/qemu-iotests/iotests.py | 14 +++++++++----- | ||
25 | 1 file changed, 9 insertions(+), 5 deletions(-) | ||
26 | |||
27 | diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/tests/qemu-iotests/iotests.py | ||
30 | +++ b/tests/qemu-iotests/iotests.py | ||
31 | @@ -XXX,XX +XXX,XX @@ def __init__(self, stream: Optional[TextIO] = None, | ||
32 | resultclass=resultclass, | ||
33 | **kwargs) | ||
34 | |||
35 | -def execute_unittest(debug=False): | ||
36 | +def execute_unittest(argv: List[str], debug: bool = False) -> None: | ||
37 | """Executes unittests within the calling module.""" | ||
38 | |||
39 | - verbosity = 2 if debug else 1 | ||
40 | - runner = ReproducibleTestRunner(verbosity=verbosity) | ||
41 | - unittest.main(testRunner=runner) | ||
42 | + # Some tests have warnings, especially ResourceWarnings for unclosed | ||
43 | + # files and sockets. Ignore them for now to ensure reproducibility of | ||
44 | + # the test output. | ||
45 | + unittest.main(argv=argv, | ||
46 | + testRunner=ReproducibleTestRunner, | ||
47 | + verbosity=2 if debug else 1, | ||
48 | + warnings=None if sys.warnoptions else 'ignore') | ||
49 | |||
50 | def execute_setup_common(supported_fmts: Sequence[str] = (), | ||
51 | supported_platforms: Sequence[str] = (), | ||
52 | @@ -XXX,XX +XXX,XX @@ def execute_test(*args, test_function=None, **kwargs): | ||
53 | |||
54 | debug = execute_setup_common(*args, **kwargs) | ||
55 | if not test_function: | ||
56 | - execute_unittest(debug) | ||
57 | + execute_unittest(sys.argv, debug) | ||
58 | else: | ||
59 | test_function() | ||
60 | |||
61 | -- | ||
62 | 2.31.1 | ||
63 | |||
64 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Paolo Bonzini <pbonzini@redhat.com> | ||
2 | 1 | ||
3 | In the next patch, "check" will learn how to execute a test script without | ||
4 | going through TestRunner. To enable this, keep only the text output | ||
5 | and subprocess handling in the TestRunner; move into TestEnv the logic | ||
6 | to prepare for running a subprocess. | ||
7 | |||
8 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
9 | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> | ||
10 | Tested-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> | ||
11 | Message-Id: <20210323181928.311862-4-pbonzini@redhat.com> | ||
12 | Message-Id: <20210503110110.476887-4-pbonzini@redhat.com> | ||
13 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
14 | --- | ||
15 | tests/qemu-iotests/testenv.py | 17 ++++++++++++++++- | ||
16 | tests/qemu-iotests/testrunner.py | 14 +------------- | ||
17 | 2 files changed, 17 insertions(+), 14 deletions(-) | ||
18 | |||
19 | diff --git a/tests/qemu-iotests/testenv.py b/tests/qemu-iotests/testenv.py | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/tests/qemu-iotests/testenv.py | ||
22 | +++ b/tests/qemu-iotests/testenv.py | ||
23 | @@ -XXX,XX +XXX,XX @@ | ||
24 | import random | ||
25 | import subprocess | ||
26 | import glob | ||
27 | -from typing import Dict, Any, Optional, ContextManager | ||
28 | +from typing import List, Dict, Any, Optional, ContextManager | ||
29 | |||
30 | |||
31 | def isxfile(path: str) -> bool: | ||
32 | @@ -XXX,XX +XXX,XX @@ class TestEnv(ContextManager['TestEnv']): | ||
33 | 'CACHEMODE_IS_DEFAULT', 'IMGFMT_GENERIC', 'IMGOPTSSYNTAX', | ||
34 | 'IMGKEYSECRET', 'QEMU_DEFAULT_MACHINE', 'MALLOC_PERTURB_'] | ||
35 | |||
36 | + def prepare_subprocess(self, args: List[str]) -> Dict[str, str]: | ||
37 | + if self.debug: | ||
38 | + args.append('-d') | ||
39 | + | ||
40 | + with open(args[0], encoding="utf-8") as f: | ||
41 | + try: | ||
42 | + if f.readline().rstrip() == '#!/usr/bin/env python3': | ||
43 | + args.insert(0, self.python) | ||
44 | + except UnicodeDecodeError: # binary test? for future. | ||
45 | + pass | ||
46 | + | ||
47 | + os_env = os.environ.copy() | ||
48 | + os_env.update(self.get_env()) | ||
49 | + return os_env | ||
50 | + | ||
51 | def get_env(self) -> Dict[str, str]: | ||
52 | env = {} | ||
53 | for v in self.env_variables: | ||
54 | diff --git a/tests/qemu-iotests/testrunner.py b/tests/qemu-iotests/testrunner.py | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/tests/qemu-iotests/testrunner.py | ||
57 | +++ b/tests/qemu-iotests/testrunner.py | ||
58 | @@ -XXX,XX +XXX,XX @@ class TestRunner(ContextManager['TestRunner']): | ||
59 | def __init__(self, env: TestEnv, makecheck: bool = False, | ||
60 | color: str = 'auto') -> None: | ||
61 | self.env = env | ||
62 | - self.test_run_env = self.env.get_env() | ||
63 | self.makecheck = makecheck | ||
64 | self.last_elapsed = LastElapsedTime('.last-elapsed-cache', env) | ||
65 | |||
66 | @@ -XXX,XX +XXX,XX @@ def do_run_test(self, test: str) -> TestResult: | ||
67 | silent_unlink(p) | ||
68 | |||
69 | args = [str(f_test.resolve())] | ||
70 | - if self.env.debug: | ||
71 | - args.append('-d') | ||
72 | - | ||
73 | - with f_test.open(encoding="utf-8") as f: | ||
74 | - try: | ||
75 | - if f.readline().rstrip() == '#!/usr/bin/env python3': | ||
76 | - args.insert(0, self.env.python) | ||
77 | - except UnicodeDecodeError: # binary test? for future. | ||
78 | - pass | ||
79 | - | ||
80 | - env = os.environ.copy() | ||
81 | - env.update(self.test_run_env) | ||
82 | + env = self.env.prepare_subprocess(args) | ||
83 | |||
84 | t0 = time.time() | ||
85 | with f_bad.open('w', encoding="utf-8") as f: | ||
86 | -- | ||
87 | 2.31.1 | ||
88 | |||
89 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Paolo Bonzini <pbonzini@redhat.com> | ||
2 | 1 | ||
3 | Right now there is no easy way for "check" to print a reproducer command. | ||
4 | Because such a reproducer command line would be huge, we can instead teach | ||
5 | check to start a command of our choice. This can be for example a Python | ||
6 | unit test with arguments to only run a specific subtest. | ||
7 | |||
8 | Move the trailing empty line to print_env(), since it always looks better | ||
9 | and one caller was not adding it. | ||
10 | |||
11 | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> | ||
12 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
13 | Tested-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> | ||
14 | Message-Id: <20210323181928.311862-5-pbonzini@redhat.com> | ||
15 | Message-Id: <20210503110110.476887-5-pbonzini@redhat.com> | ||
16 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
17 | --- | ||
18 | tests/qemu-iotests/check | 19 ++++++++++++++++++- | ||
19 | tests/qemu-iotests/testenv.py | 3 ++- | ||
20 | tests/qemu-iotests/testrunner.py | 1 - | ||
21 | 3 files changed, 20 insertions(+), 3 deletions(-) | ||
22 | |||
23 | diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check | ||
24 | index XXXXXXX..XXXXXXX 100755 | ||
25 | --- a/tests/qemu-iotests/check | ||
26 | +++ b/tests/qemu-iotests/check | ||
27 | @@ -XXX,XX +XXX,XX @@ | ||
28 | import os | ||
29 | import sys | ||
30 | import argparse | ||
31 | +import shutil | ||
32 | +from pathlib import Path | ||
33 | + | ||
34 | from findtests import TestFinder | ||
35 | from testenv import TestEnv | ||
36 | from testrunner import TestRunner | ||
37 | @@ -XXX,XX +XXX,XX @@ def make_argparser() -> argparse.ArgumentParser: | ||
38 | 'rerun failed ./check command, starting from the ' | ||
39 | 'middle of the process.') | ||
40 | g_sel.add_argument('tests', metavar='TEST_FILES', nargs='*', | ||
41 | - help='tests to run') | ||
42 | + help='tests to run, or "--" followed by a command') | ||
43 | |||
44 | return p | ||
45 | |||
46 | @@ -XXX,XX +XXX,XX @@ if __name__ == '__main__': | ||
47 | imgopts=args.imgopts, misalign=args.misalign, | ||
48 | debug=args.debug, valgrind=args.valgrind) | ||
49 | |||
50 | + if len(sys.argv) > 1 and sys.argv[-len(args.tests)-1] == '--': | ||
51 | + if not args.tests: | ||
52 | + sys.exit("missing command after '--'") | ||
53 | + cmd = args.tests | ||
54 | + env.print_env() | ||
55 | + exec_pathstr = shutil.which(cmd[0]) | ||
56 | + if exec_pathstr is None: | ||
57 | + sys.exit('command not found: ' + cmd[0]) | ||
58 | + exec_path = Path(exec_pathstr).resolve() | ||
59 | + cmd[0] = str(exec_path) | ||
60 | + full_env = env.prepare_subprocess(cmd) | ||
61 | + os.chdir(exec_path.parent) | ||
62 | + os.execve(cmd[0], cmd, full_env) | ||
63 | + | ||
64 | testfinder = TestFinder(test_dir=env.source_iotests) | ||
65 | |||
66 | groups = args.groups.split(',') if args.groups else None | ||
67 | diff --git a/tests/qemu-iotests/testenv.py b/tests/qemu-iotests/testenv.py | ||
68 | index XXXXXXX..XXXXXXX 100644 | ||
69 | --- a/tests/qemu-iotests/testenv.py | ||
70 | +++ b/tests/qemu-iotests/testenv.py | ||
71 | @@ -XXX,XX +XXX,XX @@ def print_env(self) -> None: | ||
72 | PLATFORM -- {platform} | ||
73 | TEST_DIR -- {TEST_DIR} | ||
74 | SOCK_DIR -- {SOCK_DIR} | ||
75 | -SOCKET_SCM_HELPER -- {SOCKET_SCM_HELPER}""" | ||
76 | +SOCKET_SCM_HELPER -- {SOCKET_SCM_HELPER} | ||
77 | +""" | ||
78 | |||
79 | args = collections.defaultdict(str, self.get_env()) | ||
80 | |||
81 | diff --git a/tests/qemu-iotests/testrunner.py b/tests/qemu-iotests/testrunner.py | ||
82 | index XXXXXXX..XXXXXXX 100644 | ||
83 | --- a/tests/qemu-iotests/testrunner.py | ||
84 | +++ b/tests/qemu-iotests/testrunner.py | ||
85 | @@ -XXX,XX +XXX,XX @@ def run_tests(self, tests: List[str]) -> bool: | ||
86 | |||
87 | if not self.makecheck: | ||
88 | self.env.print_env() | ||
89 | - print() | ||
90 | |||
91 | test_field_width = max(len(os.path.basename(t)) for t in tests) + 2 | ||
92 | |||
93 | -- | ||
94 | 2.31.1 | ||
95 | |||
96 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Paolo Bonzini <pbonzini@redhat.com> | ||
2 | 1 | ||
3 | Due to a typo, in this case the SOCK_DIR was not being created. | ||
4 | |||
5 | Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
6 | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> | ||
7 | Tested-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> | ||
8 | Message-Id: <20210323181928.311862-6-pbonzini@redhat.com> | ||
9 | Message-Id: <20210503110110.476887-6-pbonzini@redhat.com> | ||
10 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
11 | --- | ||
12 | tests/qemu-iotests/testenv.py | 2 +- | ||
13 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
14 | |||
15 | diff --git a/tests/qemu-iotests/testenv.py b/tests/qemu-iotests/testenv.py | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/tests/qemu-iotests/testenv.py | ||
18 | +++ b/tests/qemu-iotests/testenv.py | ||
19 | @@ -XXX,XX +XXX,XX @@ def init_directories(self) -> None: | ||
20 | try: | ||
21 | self.sock_dir = os.environ['SOCK_DIR'] | ||
22 | self.tmp_sock_dir = False | ||
23 | - Path(self.test_dir).mkdir(parents=True, exist_ok=True) | ||
24 | + Path(self.sock_dir).mkdir(parents=True, exist_ok=True) | ||
25 | except KeyError: | ||
26 | self.sock_dir = tempfile.mkdtemp() | ||
27 | self.tmp_sock_dir = True | ||
28 | -- | ||
29 | 2.31.1 | ||
30 | |||
31 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Connor Kuehl <ckuehl@redhat.com> | ||
2 | 1 | ||
3 | The contents of this patch were initially developed and posted by Han | ||
4 | Han[1], however, it appears the original patch was not applied. Since | ||
5 | then, the relevant documentation has been moved and adapted to a new | ||
6 | format. | ||
7 | |||
8 | I've taken most of the original wording and tweaked it according to | ||
9 | some of the feedback from the original patch submission. I've also | ||
10 | adapted it to restructured text, which is the format the documentation | ||
11 | currently uses. | ||
12 | |||
13 | [1] https://lists.nongnu.org/archive/html/qemu-block/2019-10/msg01253.html | ||
14 | |||
15 | Fixes: https://bugzilla.redhat.com/1763105 | ||
16 | Signed-off-by: Han Han <hhan@redhat.com> | ||
17 | Suggested-by: Max Reitz <mreitz@redhat.com> | ||
18 | [ Max: provided description of data_file_raw behavior ] | ||
19 | Signed-off-by: Connor Kuehl <ckuehl@redhat.com> | ||
20 | Message-Id: <20210505195512.391128-1-ckuehl@redhat.com> | ||
21 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
22 | --- | ||
23 | docs/tools/qemu-img.rst | 31 +++++++++++++++++++++++++++++++ | ||
24 | 1 file changed, 31 insertions(+) | ||
25 | |||
26 | diff --git a/docs/tools/qemu-img.rst b/docs/tools/qemu-img.rst | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/docs/tools/qemu-img.rst | ||
29 | +++ b/docs/tools/qemu-img.rst | ||
30 | @@ -XXX,XX +XXX,XX @@ Supported image file formats: | ||
31 | issue ``lsattr filename`` to check if the NOCOW flag is set or not | ||
32 | (Capital 'C' is NOCOW flag). | ||
33 | |||
34 | + ``data_file`` | ||
35 | + Filename where all guest data will be stored. If this option is used, | ||
36 | + the qcow2 file will only contain the image's metadata. | ||
37 | + | ||
38 | + Note: Data loss will occur if the given filename already exists when | ||
39 | + using this option with ``qemu-img create`` since ``qemu-img`` will create | ||
40 | + the data file anew, overwriting the file's original contents. To simply | ||
41 | + update the reference to point to the given pre-existing file, use | ||
42 | + ``qemu-img amend``. | ||
43 | + | ||
44 | + ``data_file_raw`` | ||
45 | + If this option is set to ``on``, QEMU will always keep the external data | ||
46 | + file consistent as a standalone read-only raw image. | ||
47 | + | ||
48 | + It does this by forwarding all write accesses to the qcow2 file through to | ||
49 | + the raw data file, including their offsets. Therefore, data that is visible | ||
50 | + on the qcow2 node (i.e., to the guest) at some offset is visible at the same | ||
51 | + offset in the raw data file. This results in a read-only raw image. Writes | ||
52 | + that bypass the qcow2 metadata may corrupt the qcow2 metadata because the | ||
53 | + out-of-band writes may result in the metadata falling out of sync with the | ||
54 | + raw image. | ||
55 | + | ||
56 | + If this option is ``off``, QEMU will use the data file to store data in an | ||
57 | + arbitrary manner. The file’s content will not make sense without the | ||
58 | + accompanying qcow2 metadata. Where data is written will have no relation to | ||
59 | + its offset as seen by the guest, and some writes (specifically zero writes) | ||
60 | + may not be forwarded to the data file at all, but will only be handled by | ||
61 | + modifying qcow2 metadata. | ||
62 | + | ||
63 | + This option can only be enabled if ``data_file`` is set. | ||
64 | + | ||
65 | ``Other`` | ||
66 | |||
67 | QEMU also supports various other image file formats for | ||
68 | -- | ||
69 | 2.31.1 | ||
70 | |||
71 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
2 | 1 | ||
3 | Now, after huge update of block graph permission update algorithm, we | ||
4 | don't need this workaround with active state of the filter. Drop it and | ||
5 | use new smart bdrv_drop_filter() function. | ||
6 | |||
7 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
8 | Message-Id: <20210506194143.394141-1-vsementsov@virtuozzo.com> | ||
9 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
10 | --- | ||
11 | block/copy-on-read.c | 33 +-------------------------------- | ||
12 | 1 file changed, 1 insertion(+), 32 deletions(-) | ||
13 | |||
14 | diff --git a/block/copy-on-read.c b/block/copy-on-read.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/block/copy-on-read.c | ||
17 | +++ b/block/copy-on-read.c | ||
18 | @@ -XXX,XX +XXX,XX @@ | ||
19 | |||
20 | |||
21 | typedef struct BDRVStateCOR { | ||
22 | - bool active; | ||
23 | BlockDriverState *bottom_bs; | ||
24 | bool chain_frozen; | ||
25 | } BDRVStateCOR; | ||
26 | @@ -XXX,XX +XXX,XX @@ static int cor_open(BlockDriverState *bs, QDict *options, int flags, | ||
27 | */ | ||
28 | bdrv_ref(bottom_bs); | ||
29 | } | ||
30 | - state->active = true; | ||
31 | state->bottom_bs = bottom_bs; | ||
32 | |||
33 | /* | ||
34 | @@ -XXX,XX +XXX,XX @@ static void cor_child_perm(BlockDriverState *bs, BdrvChild *c, | ||
35 | uint64_t perm, uint64_t shared, | ||
36 | uint64_t *nperm, uint64_t *nshared) | ||
37 | { | ||
38 | - BDRVStateCOR *s = bs->opaque; | ||
39 | - | ||
40 | - if (!s->active) { | ||
41 | - /* | ||
42 | - * While the filter is being removed | ||
43 | - */ | ||
44 | - *nperm = 0; | ||
45 | - *nshared = BLK_PERM_ALL; | ||
46 | - return; | ||
47 | - } | ||
48 | - | ||
49 | *nperm = perm & PERM_PASSTHROUGH; | ||
50 | *nshared = (shared & PERM_PASSTHROUGH) | PERM_UNCHANGED; | ||
51 | |||
52 | @@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_copy_on_read = { | ||
53 | |||
54 | void bdrv_cor_filter_drop(BlockDriverState *cor_filter_bs) | ||
55 | { | ||
56 | - BdrvChild *child; | ||
57 | - BlockDriverState *bs; | ||
58 | BDRVStateCOR *s = cor_filter_bs->opaque; | ||
59 | |||
60 | - child = bdrv_filter_child(cor_filter_bs); | ||
61 | - if (!child) { | ||
62 | - return; | ||
63 | - } | ||
64 | - bs = child->bs; | ||
65 | - | ||
66 | - /* Retain the BDS until we complete the graph change. */ | ||
67 | - bdrv_ref(bs); | ||
68 | - /* Hold a guest back from writing while permissions are being reset. */ | ||
69 | - bdrv_drained_begin(bs); | ||
70 | - /* Drop permissions before the graph change. */ | ||
71 | - s->active = false; | ||
72 | /* unfreeze, as otherwise bdrv_replace_node() will fail */ | ||
73 | if (s->chain_frozen) { | ||
74 | s->chain_frozen = false; | ||
75 | bdrv_unfreeze_backing_chain(cor_filter_bs, s->bottom_bs); | ||
76 | } | ||
77 | - bdrv_child_refresh_perms(cor_filter_bs, child, &error_abort); | ||
78 | - bdrv_replace_node(cor_filter_bs, bs, &error_abort); | ||
79 | - | ||
80 | - bdrv_drained_end(bs); | ||
81 | - bdrv_unref(bs); | ||
82 | + bdrv_drop_filter(cor_filter_bs, &error_abort); | ||
83 | bdrv_unref(cor_filter_bs); | ||
84 | } | ||
85 | |||
86 | -- | ||
87 | 2.31.1 | ||
88 | |||
89 | diff view generated by jsdifflib |
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 1 | From: Pino Toscano <ptoscano@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | write-notifiers are used only for write-threshold. New code for such | 3 | Rewrite the implementation of the ssh block driver to use libssh instead |
4 | purpose should create filters. | 4 | of libssh2. The libssh library has various advantages over libssh2: |
5 | - easier API for authentication (for example for using ssh-agent) | ||
6 | - easier API for known_hosts handling | ||
7 | - supports newer types of keys in known_hosts | ||
5 | 8 | ||
6 | Let's better special-case write-threshold and drop write notifiers at | 9 | Use APIs/features available in libssh 0.8 conditionally, to support |
7 | all. (Actually, write-threshold is special-cased anyway, as the only | 10 | older versions (which are not recommended though). |
8 | user of write-notifiers) | ||
9 | 11 | ||
10 | So, create a new direct interface for bdrv_co_write_req_prepare() and | 12 | Adjust the iotest 207 according to the different error message, and to |
11 | drop all write-notifier related logic from write-threshold.c. | 13 | find the default key type for localhost (to properly compare the |
14 | fingerprint with). | ||
15 | Contributed-by: Max Reitz <mreitz@redhat.com> | ||
12 | 16 | ||
13 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 17 | Adjust the various Docker/Travis scripts to use libssh when available |
14 | Reviewed-by: Max Reitz <mreitz@redhat.com> | 18 | instead of libssh2. The mingw/mxe testing is dropped for now, as there |
15 | Message-Id: <20210506090621.11848-2-vsementsov@virtuozzo.com> | 19 | are no packages for it. |
16 | Reviewed-by: Eric Blake <eblake@redhat.com> | 20 | |
17 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | 21 | Signed-off-by: Pino Toscano <ptoscano@redhat.com> |
18 | [mreitz: Adjusted comment as per Eric's suggestion] | 22 | Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
23 | Acked-by: Alex Bennée <alex.bennee@linaro.org> | ||
24 | Message-id: 20190620200840.17655-1-ptoscano@redhat.com | ||
25 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
26 | Message-id: 5873173.t2JhDm7DL7@lindworm.usersys.redhat.com | ||
19 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 27 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
20 | --- | 28 | --- |
21 | include/block/block_int.h | 1 - | 29 | configure | 65 +- |
22 | include/block/write-threshold.h | 9 +++++ | 30 | block/Makefile.objs | 6 +- |
23 | block/io.c | 5 ++- | 31 | block/ssh.c | 652 ++++++++++-------- |
24 | block/write-threshold.c | 70 +++++++-------------------------- | 32 | .travis.yml | 4 +- |
25 | 4 files changed, 27 insertions(+), 58 deletions(-) | 33 | block/trace-events | 14 +- |
34 | docs/qemu-block-drivers.texi | 2 +- | ||
35 | .../dockerfiles/debian-win32-cross.docker | 1 - | ||
36 | .../dockerfiles/debian-win64-cross.docker | 1 - | ||
37 | tests/docker/dockerfiles/fedora.docker | 4 +- | ||
38 | tests/docker/dockerfiles/ubuntu.docker | 2 +- | ||
39 | tests/docker/dockerfiles/ubuntu1804.docker | 2 +- | ||
40 | tests/qemu-iotests/207 | 54 +- | ||
41 | tests/qemu-iotests/207.out | 2 +- | ||
42 | 13 files changed, 449 insertions(+), 360 deletions(-) | ||
26 | 43 | ||
27 | diff --git a/include/block/block_int.h b/include/block/block_int.h | 44 | diff --git a/configure b/configure |
45 | index XXXXXXX..XXXXXXX 100755 | ||
46 | --- a/configure | ||
47 | +++ b/configure | ||
48 | @@ -XXX,XX +XXX,XX @@ auth_pam="" | ||
49 | vte="" | ||
50 | virglrenderer="" | ||
51 | tpm="" | ||
52 | -libssh2="" | ||
53 | +libssh="" | ||
54 | live_block_migration="yes" | ||
55 | numa="" | ||
56 | tcmalloc="no" | ||
57 | @@ -XXX,XX +XXX,XX @@ for opt do | ||
58 | ;; | ||
59 | --enable-tpm) tpm="yes" | ||
60 | ;; | ||
61 | - --disable-libssh2) libssh2="no" | ||
62 | + --disable-libssh) libssh="no" | ||
63 | ;; | ||
64 | - --enable-libssh2) libssh2="yes" | ||
65 | + --enable-libssh) libssh="yes" | ||
66 | ;; | ||
67 | --disable-live-block-migration) live_block_migration="no" | ||
68 | ;; | ||
69 | @@ -XXX,XX +XXX,XX @@ disabled with --disable-FEATURE, default is enabled if available: | ||
70 | coroutine-pool coroutine freelist (better performance) | ||
71 | glusterfs GlusterFS backend | ||
72 | tpm TPM support | ||
73 | - libssh2 ssh block device support | ||
74 | + libssh ssh block device support | ||
75 | numa libnuma support | ||
76 | libxml2 for Parallels image format | ||
77 | tcmalloc tcmalloc support | ||
78 | @@ -XXX,XX +XXX,XX @@ EOF | ||
79 | fi | ||
80 | |||
81 | ########################################## | ||
82 | -# libssh2 probe | ||
83 | -min_libssh2_version=1.2.8 | ||
84 | -if test "$libssh2" != "no" ; then | ||
85 | - if $pkg_config --atleast-version=$min_libssh2_version libssh2; then | ||
86 | - libssh2_cflags=$($pkg_config libssh2 --cflags) | ||
87 | - libssh2_libs=$($pkg_config libssh2 --libs) | ||
88 | - libssh2=yes | ||
89 | +# libssh probe | ||
90 | +if test "$libssh" != "no" ; then | ||
91 | + if $pkg_config --exists libssh; then | ||
92 | + libssh_cflags=$($pkg_config libssh --cflags) | ||
93 | + libssh_libs=$($pkg_config libssh --libs) | ||
94 | + libssh=yes | ||
95 | else | ||
96 | - if test "$libssh2" = "yes" ; then | ||
97 | - error_exit "libssh2 >= $min_libssh2_version required for --enable-libssh2" | ||
98 | + if test "$libssh" = "yes" ; then | ||
99 | + error_exit "libssh required for --enable-libssh" | ||
100 | fi | ||
101 | - libssh2=no | ||
102 | + libssh=no | ||
103 | fi | ||
104 | fi | ||
105 | |||
106 | ########################################## | ||
107 | -# libssh2_sftp_fsync probe | ||
108 | +# Check for libssh 0.8 | ||
109 | +# This is done like this instead of using the LIBSSH_VERSION_* and | ||
110 | +# SSH_VERSION_* macros because some distributions in the past shipped | ||
111 | +# snapshots of the future 0.8 from Git, and those snapshots did not | ||
112 | +# have updated version numbers (still referring to 0.7.0). | ||
113 | |||
114 | -if test "$libssh2" = "yes"; then | ||
115 | +if test "$libssh" = "yes"; then | ||
116 | cat > $TMPC <<EOF | ||
117 | -#include <stdio.h> | ||
118 | -#include <libssh2.h> | ||
119 | -#include <libssh2_sftp.h> | ||
120 | -int main(void) { | ||
121 | - LIBSSH2_SESSION *session; | ||
122 | - LIBSSH2_SFTP *sftp; | ||
123 | - LIBSSH2_SFTP_HANDLE *sftp_handle; | ||
124 | - session = libssh2_session_init (); | ||
125 | - sftp = libssh2_sftp_init (session); | ||
126 | - sftp_handle = libssh2_sftp_open (sftp, "/", 0, 0); | ||
127 | - libssh2_sftp_fsync (sftp_handle); | ||
128 | - return 0; | ||
129 | -} | ||
130 | +#include <libssh/libssh.h> | ||
131 | +int main(void) { return ssh_get_server_publickey(NULL, NULL); } | ||
132 | EOF | ||
133 | - # libssh2_cflags/libssh2_libs defined in previous test. | ||
134 | - if compile_prog "$libssh2_cflags" "$libssh2_libs" ; then | ||
135 | - QEMU_CFLAGS="-DHAS_LIBSSH2_SFTP_FSYNC $QEMU_CFLAGS" | ||
136 | + if compile_prog "$libssh_cflags" "$libssh_libs"; then | ||
137 | + libssh_cflags="-DHAVE_LIBSSH_0_8 $libssh_cflags" | ||
138 | fi | ||
139 | fi | ||
140 | |||
141 | @@ -XXX,XX +XXX,XX @@ echo "GlusterFS support $glusterfs" | ||
142 | echo "gcov $gcov_tool" | ||
143 | echo "gcov enabled $gcov" | ||
144 | echo "TPM support $tpm" | ||
145 | -echo "libssh2 support $libssh2" | ||
146 | +echo "libssh support $libssh" | ||
147 | echo "QOM debugging $qom_cast_debug" | ||
148 | echo "Live block migration $live_block_migration" | ||
149 | echo "lzo support $lzo" | ||
150 | @@ -XXX,XX +XXX,XX @@ if test "$glusterfs_iocb_has_stat" = "yes" ; then | ||
151 | echo "CONFIG_GLUSTERFS_IOCB_HAS_STAT=y" >> $config_host_mak | ||
152 | fi | ||
153 | |||
154 | -if test "$libssh2" = "yes" ; then | ||
155 | - echo "CONFIG_LIBSSH2=m" >> $config_host_mak | ||
156 | - echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak | ||
157 | - echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak | ||
158 | +if test "$libssh" = "yes" ; then | ||
159 | + echo "CONFIG_LIBSSH=m" >> $config_host_mak | ||
160 | + echo "LIBSSH_CFLAGS=$libssh_cflags" >> $config_host_mak | ||
161 | + echo "LIBSSH_LIBS=$libssh_libs" >> $config_host_mak | ||
162 | fi | ||
163 | |||
164 | if test "$live_block_migration" = "yes" ; then | ||
165 | diff --git a/block/Makefile.objs b/block/Makefile.objs | ||
28 | index XXXXXXX..XXXXXXX 100644 | 166 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/include/block/block_int.h | 167 | --- a/block/Makefile.objs |
30 | +++ b/include/block/block_int.h | 168 | +++ b/block/Makefile.objs |
31 | @@ -XXX,XX +XXX,XX @@ struct BlockDriverState { | 169 | @@ -XXX,XX +XXX,XX @@ block-obj-$(CONFIG_CURL) += curl.o |
32 | 170 | block-obj-$(CONFIG_RBD) += rbd.o | |
33 | /* threshold limit for writes, in bytes. "High water mark". */ | 171 | block-obj-$(CONFIG_GLUSTERFS) += gluster.o |
34 | uint64_t write_threshold_offset; | 172 | block-obj-$(CONFIG_VXHS) += vxhs.o |
35 | - NotifierWithReturn write_threshold_notifier; | 173 | -block-obj-$(CONFIG_LIBSSH2) += ssh.o |
36 | 174 | +block-obj-$(CONFIG_LIBSSH) += ssh.o | |
37 | /* Writing to the list requires the BQL _and_ the dirty_bitmap_mutex. | 175 | block-obj-y += accounting.o dirty-bitmap.o |
38 | * Reading from the list can be done with either the BQL or the | 176 | block-obj-y += write-threshold.o |
39 | diff --git a/include/block/write-threshold.h b/include/block/write-threshold.h | 177 | block-obj-y += backup.o |
178 | @@ -XXX,XX +XXX,XX @@ rbd.o-libs := $(RBD_LIBS) | ||
179 | gluster.o-cflags := $(GLUSTERFS_CFLAGS) | ||
180 | gluster.o-libs := $(GLUSTERFS_LIBS) | ||
181 | vxhs.o-libs := $(VXHS_LIBS) | ||
182 | -ssh.o-cflags := $(LIBSSH2_CFLAGS) | ||
183 | -ssh.o-libs := $(LIBSSH2_LIBS) | ||
184 | +ssh.o-cflags := $(LIBSSH_CFLAGS) | ||
185 | +ssh.o-libs := $(LIBSSH_LIBS) | ||
186 | block-obj-dmg-bz2-$(CONFIG_BZIP2) += dmg-bz2.o | ||
187 | block-obj-$(if $(CONFIG_DMG),m,n) += $(block-obj-dmg-bz2-y) | ||
188 | dmg-bz2.o-libs := $(BZIP2_LIBS) | ||
189 | diff --git a/block/ssh.c b/block/ssh.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | 190 | index XXXXXXX..XXXXXXX 100644 |
41 | --- a/include/block/write-threshold.h | 191 | --- a/block/ssh.c |
42 | +++ b/include/block/write-threshold.h | 192 | +++ b/block/ssh.c |
43 | @@ -XXX,XX +XXX,XX @@ bool bdrv_write_threshold_is_set(const BlockDriverState *bs); | ||
44 | uint64_t bdrv_write_threshold_exceeded(const BlockDriverState *bs, | ||
45 | const BdrvTrackedRequest *req); | ||
46 | |||
47 | +/* | ||
48 | + * bdrv_write_threshold_check_write | ||
49 | + * | ||
50 | + * Check whether the specified request exceeds the write threshold. | ||
51 | + * If so, send a corresponding event and disable write threshold checking. | ||
52 | + */ | ||
53 | +void bdrv_write_threshold_check_write(BlockDriverState *bs, int64_t offset, | ||
54 | + int64_t bytes); | ||
55 | + | ||
56 | #endif | ||
57 | diff --git a/block/io.c b/block/io.c | ||
58 | index XXXXXXX..XXXXXXX 100644 | ||
59 | --- a/block/io.c | ||
60 | +++ b/block/io.c | ||
61 | @@ -XXX,XX +XXX,XX @@ | 193 | @@ -XXX,XX +XXX,XX @@ |
62 | #include "block/blockjob_int.h" | 194 | |
195 | #include "qemu/osdep.h" | ||
196 | |||
197 | -#include <libssh2.h> | ||
198 | -#include <libssh2_sftp.h> | ||
199 | +#include <libssh/libssh.h> | ||
200 | +#include <libssh/sftp.h> | ||
201 | |||
63 | #include "block/block_int.h" | 202 | #include "block/block_int.h" |
64 | #include "block/coroutines.h" | 203 | #include "block/qdict.h" |
65 | +#include "block/write-threshold.h" | 204 | @@ -XXX,XX +XXX,XX @@ |
66 | #include "qemu/cutils.h" | 205 | #include "trace.h" |
67 | #include "qapi/error.h" | 206 | |
68 | #include "qemu/error-report.h" | 207 | /* |
69 | @@ -XXX,XX +XXX,XX @@ bdrv_co_write_req_prepare(BdrvChild *child, int64_t offset, int64_t bytes, | 208 | - * TRACE_LIBSSH2=<bitmask> enables tracing in libssh2 itself. Note |
70 | } else { | 209 | - * that this requires that libssh2 was specially compiled with the |
71 | assert(child->perm & BLK_PERM_WRITE); | 210 | - * `./configure --enable-debug' option, so most likely you will have |
211 | - * to compile it yourself. The meaning of <bitmask> is described | ||
212 | - * here: http://www.libssh2.org/libssh2_trace.html | ||
213 | + * TRACE_LIBSSH=<level> enables tracing in libssh itself. | ||
214 | + * The meaning of <level> is described here: | ||
215 | + * http://api.libssh.org/master/group__libssh__log.html | ||
216 | */ | ||
217 | -#define TRACE_LIBSSH2 0 /* or try: LIBSSH2_TRACE_SFTP */ | ||
218 | +#define TRACE_LIBSSH 0 /* see: SSH_LOG_* */ | ||
219 | |||
220 | typedef struct BDRVSSHState { | ||
221 | /* Coroutine. */ | ||
222 | @@ -XXX,XX +XXX,XX @@ typedef struct BDRVSSHState { | ||
223 | |||
224 | /* SSH connection. */ | ||
225 | int sock; /* socket */ | ||
226 | - LIBSSH2_SESSION *session; /* ssh session */ | ||
227 | - LIBSSH2_SFTP *sftp; /* sftp session */ | ||
228 | - LIBSSH2_SFTP_HANDLE *sftp_handle; /* sftp remote file handle */ | ||
229 | + ssh_session session; /* ssh session */ | ||
230 | + sftp_session sftp; /* sftp session */ | ||
231 | + sftp_file sftp_handle; /* sftp remote file handle */ | ||
232 | |||
233 | - /* See ssh_seek() function below. */ | ||
234 | - int64_t offset; | ||
235 | - bool offset_op_read; | ||
236 | - | ||
237 | - /* File attributes at open. We try to keep the .filesize field | ||
238 | + /* | ||
239 | + * File attributes at open. We try to keep the .size field | ||
240 | * updated if it changes (eg by writing at the end of the file). | ||
241 | */ | ||
242 | - LIBSSH2_SFTP_ATTRIBUTES attrs; | ||
243 | + sftp_attributes attrs; | ||
244 | |||
245 | InetSocketAddress *inet; | ||
246 | |||
247 | @@ -XXX,XX +XXX,XX @@ static void ssh_state_init(BDRVSSHState *s) | ||
248 | { | ||
249 | memset(s, 0, sizeof *s); | ||
250 | s->sock = -1; | ||
251 | - s->offset = -1; | ||
252 | qemu_co_mutex_init(&s->lock); | ||
253 | } | ||
254 | |||
255 | @@ -XXX,XX +XXX,XX @@ static void ssh_state_free(BDRVSSHState *s) | ||
256 | { | ||
257 | g_free(s->user); | ||
258 | |||
259 | + if (s->attrs) { | ||
260 | + sftp_attributes_free(s->attrs); | ||
261 | + } | ||
262 | if (s->sftp_handle) { | ||
263 | - libssh2_sftp_close(s->sftp_handle); | ||
264 | + sftp_close(s->sftp_handle); | ||
265 | } | ||
266 | if (s->sftp) { | ||
267 | - libssh2_sftp_shutdown(s->sftp); | ||
268 | + sftp_free(s->sftp); | ||
269 | } | ||
270 | if (s->session) { | ||
271 | - libssh2_session_disconnect(s->session, | ||
272 | - "from qemu ssh client: " | ||
273 | - "user closed the connection"); | ||
274 | - libssh2_session_free(s->session); | ||
275 | - } | ||
276 | - if (s->sock >= 0) { | ||
277 | - close(s->sock); | ||
278 | + ssh_disconnect(s->session); | ||
279 | + ssh_free(s->session); /* This frees s->sock */ | ||
280 | } | ||
281 | } | ||
282 | |||
283 | @@ -XXX,XX +XXX,XX @@ session_error_setg(Error **errp, BDRVSSHState *s, const char *fs, ...) | ||
284 | va_end(args); | ||
285 | |||
286 | if (s->session) { | ||
287 | - char *ssh_err; | ||
288 | + const char *ssh_err; | ||
289 | int ssh_err_code; | ||
290 | |||
291 | - /* This is not an errno. See <libssh2.h>. */ | ||
292 | - ssh_err_code = libssh2_session_last_error(s->session, | ||
293 | - &ssh_err, NULL, 0); | ||
294 | - error_setg(errp, "%s: %s (libssh2 error code: %d)", | ||
295 | + /* This is not an errno. See <libssh/libssh.h>. */ | ||
296 | + ssh_err = ssh_get_error(s->session); | ||
297 | + ssh_err_code = ssh_get_error_code(s->session); | ||
298 | + error_setg(errp, "%s: %s (libssh error code: %d)", | ||
299 | msg, ssh_err, ssh_err_code); | ||
300 | } else { | ||
301 | error_setg(errp, "%s", msg); | ||
302 | @@ -XXX,XX +XXX,XX @@ sftp_error_setg(Error **errp, BDRVSSHState *s, const char *fs, ...) | ||
303 | va_end(args); | ||
304 | |||
305 | if (s->sftp) { | ||
306 | - char *ssh_err; | ||
307 | + const char *ssh_err; | ||
308 | int ssh_err_code; | ||
309 | - unsigned long sftp_err_code; | ||
310 | + int sftp_err_code; | ||
311 | |||
312 | - /* This is not an errno. See <libssh2.h>. */ | ||
313 | - ssh_err_code = libssh2_session_last_error(s->session, | ||
314 | - &ssh_err, NULL, 0); | ||
315 | - /* See <libssh2_sftp.h>. */ | ||
316 | - sftp_err_code = libssh2_sftp_last_error((s)->sftp); | ||
317 | + /* This is not an errno. See <libssh/libssh.h>. */ | ||
318 | + ssh_err = ssh_get_error(s->session); | ||
319 | + ssh_err_code = ssh_get_error_code(s->session); | ||
320 | + /* See <libssh/sftp.h>. */ | ||
321 | + sftp_err_code = sftp_get_error(s->sftp); | ||
322 | |||
323 | error_setg(errp, | ||
324 | - "%s: %s (libssh2 error code: %d, sftp error code: %lu)", | ||
325 | + "%s: %s (libssh error code: %d, sftp error code: %d)", | ||
326 | msg, ssh_err, ssh_err_code, sftp_err_code); | ||
327 | } else { | ||
328 | error_setg(errp, "%s", msg); | ||
329 | @@ -XXX,XX +XXX,XX @@ sftp_error_setg(Error **errp, BDRVSSHState *s, const char *fs, ...) | ||
330 | |||
331 | static void sftp_error_trace(BDRVSSHState *s, const char *op) | ||
332 | { | ||
333 | - char *ssh_err; | ||
334 | + const char *ssh_err; | ||
335 | int ssh_err_code; | ||
336 | - unsigned long sftp_err_code; | ||
337 | + int sftp_err_code; | ||
338 | |||
339 | - /* This is not an errno. See <libssh2.h>. */ | ||
340 | - ssh_err_code = libssh2_session_last_error(s->session, | ||
341 | - &ssh_err, NULL, 0); | ||
342 | - /* See <libssh2_sftp.h>. */ | ||
343 | - sftp_err_code = libssh2_sftp_last_error((s)->sftp); | ||
344 | + /* This is not an errno. See <libssh/libssh.h>. */ | ||
345 | + ssh_err = ssh_get_error(s->session); | ||
346 | + ssh_err_code = ssh_get_error_code(s->session); | ||
347 | + /* See <libssh/sftp.h>. */ | ||
348 | + sftp_err_code = sftp_get_error(s->sftp); | ||
349 | |||
350 | trace_sftp_error(op, ssh_err, ssh_err_code, sftp_err_code); | ||
351 | } | ||
352 | @@ -XXX,XX +XXX,XX @@ static void ssh_parse_filename(const char *filename, QDict *options, | ||
353 | parse_uri(filename, options, errp); | ||
354 | } | ||
355 | |||
356 | -static int check_host_key_knownhosts(BDRVSSHState *s, | ||
357 | - const char *host, int port, Error **errp) | ||
358 | +static int check_host_key_knownhosts(BDRVSSHState *s, Error **errp) | ||
359 | { | ||
360 | - const char *home; | ||
361 | - char *knh_file = NULL; | ||
362 | - LIBSSH2_KNOWNHOSTS *knh = NULL; | ||
363 | - struct libssh2_knownhost *found; | ||
364 | - int ret, r; | ||
365 | - const char *hostkey; | ||
366 | - size_t len; | ||
367 | - int type; | ||
368 | - | ||
369 | - hostkey = libssh2_session_hostkey(s->session, &len, &type); | ||
370 | - if (!hostkey) { | ||
371 | + int ret; | ||
372 | +#ifdef HAVE_LIBSSH_0_8 | ||
373 | + enum ssh_known_hosts_e state; | ||
374 | + int r; | ||
375 | + ssh_key pubkey; | ||
376 | + enum ssh_keytypes_e pubkey_type; | ||
377 | + unsigned char *server_hash = NULL; | ||
378 | + size_t server_hash_len; | ||
379 | + char *fingerprint = NULL; | ||
380 | + | ||
381 | + state = ssh_session_is_known_server(s->session); | ||
382 | + trace_ssh_server_status(state); | ||
383 | + | ||
384 | + switch (state) { | ||
385 | + case SSH_KNOWN_HOSTS_OK: | ||
386 | + /* OK */ | ||
387 | + trace_ssh_check_host_key_knownhosts(); | ||
388 | + break; | ||
389 | + case SSH_KNOWN_HOSTS_CHANGED: | ||
390 | ret = -EINVAL; | ||
391 | - session_error_setg(errp, s, "failed to read remote host key"); | ||
392 | + r = ssh_get_server_publickey(s->session, &pubkey); | ||
393 | + if (r == 0) { | ||
394 | + r = ssh_get_publickey_hash(pubkey, SSH_PUBLICKEY_HASH_SHA256, | ||
395 | + &server_hash, &server_hash_len); | ||
396 | + pubkey_type = ssh_key_type(pubkey); | ||
397 | + ssh_key_free(pubkey); | ||
398 | + } | ||
399 | + if (r == 0) { | ||
400 | + fingerprint = ssh_get_fingerprint_hash(SSH_PUBLICKEY_HASH_SHA256, | ||
401 | + server_hash, | ||
402 | + server_hash_len); | ||
403 | + ssh_clean_pubkey_hash(&server_hash); | ||
404 | + } | ||
405 | + if (fingerprint) { | ||
406 | + error_setg(errp, | ||
407 | + "host key (%s key with fingerprint %s) does not match " | ||
408 | + "the one in known_hosts; this may be a possible attack", | ||
409 | + ssh_key_type_to_char(pubkey_type), fingerprint); | ||
410 | + ssh_string_free_char(fingerprint); | ||
411 | + } else { | ||
412 | + error_setg(errp, | ||
413 | + "host key does not match the one in known_hosts; this " | ||
414 | + "may be a possible attack"); | ||
415 | + } | ||
416 | goto out; | ||
417 | - } | ||
418 | - | ||
419 | - knh = libssh2_knownhost_init(s->session); | ||
420 | - if (!knh) { | ||
421 | + case SSH_KNOWN_HOSTS_OTHER: | ||
422 | ret = -EINVAL; | ||
423 | - session_error_setg(errp, s, | ||
424 | - "failed to initialize known hosts support"); | ||
425 | + error_setg(errp, | ||
426 | + "host key for this server not found, another type exists"); | ||
427 | + goto out; | ||
428 | + case SSH_KNOWN_HOSTS_UNKNOWN: | ||
429 | + ret = -EINVAL; | ||
430 | + error_setg(errp, "no host key was found in known_hosts"); | ||
431 | + goto out; | ||
432 | + case SSH_KNOWN_HOSTS_NOT_FOUND: | ||
433 | + ret = -ENOENT; | ||
434 | + error_setg(errp, "known_hosts file not found"); | ||
435 | + goto out; | ||
436 | + case SSH_KNOWN_HOSTS_ERROR: | ||
437 | + ret = -EINVAL; | ||
438 | + error_setg(errp, "error while checking the host"); | ||
439 | + goto out; | ||
440 | + default: | ||
441 | + ret = -EINVAL; | ||
442 | + error_setg(errp, "error while checking for known server (%d)", state); | ||
443 | goto out; | ||
444 | } | ||
445 | +#else /* !HAVE_LIBSSH_0_8 */ | ||
446 | + int state; | ||
447 | |||
448 | - home = getenv("HOME"); | ||
449 | - if (home) { | ||
450 | - knh_file = g_strdup_printf("%s/.ssh/known_hosts", home); | ||
451 | - } else { | ||
452 | - knh_file = g_strdup_printf("/root/.ssh/known_hosts"); | ||
453 | - } | ||
454 | - | ||
455 | - /* Read all known hosts from OpenSSH-style known_hosts file. */ | ||
456 | - libssh2_knownhost_readfile(knh, knh_file, LIBSSH2_KNOWNHOST_FILE_OPENSSH); | ||
457 | + state = ssh_is_server_known(s->session); | ||
458 | + trace_ssh_server_status(state); | ||
459 | |||
460 | - r = libssh2_knownhost_checkp(knh, host, port, hostkey, len, | ||
461 | - LIBSSH2_KNOWNHOST_TYPE_PLAIN| | ||
462 | - LIBSSH2_KNOWNHOST_KEYENC_RAW, | ||
463 | - &found); | ||
464 | - switch (r) { | ||
465 | - case LIBSSH2_KNOWNHOST_CHECK_MATCH: | ||
466 | + switch (state) { | ||
467 | + case SSH_SERVER_KNOWN_OK: | ||
468 | /* OK */ | ||
469 | - trace_ssh_check_host_key_knownhosts(found->key); | ||
470 | + trace_ssh_check_host_key_knownhosts(); | ||
471 | break; | ||
472 | - case LIBSSH2_KNOWNHOST_CHECK_MISMATCH: | ||
473 | + case SSH_SERVER_KNOWN_CHANGED: | ||
474 | ret = -EINVAL; | ||
475 | - session_error_setg(errp, s, | ||
476 | - "host key does not match the one in known_hosts" | ||
477 | - " (found key %s)", found->key); | ||
478 | + error_setg(errp, | ||
479 | + "host key does not match the one in known_hosts; this " | ||
480 | + "may be a possible attack"); | ||
481 | goto out; | ||
482 | - case LIBSSH2_KNOWNHOST_CHECK_NOTFOUND: | ||
483 | + case SSH_SERVER_FOUND_OTHER: | ||
484 | ret = -EINVAL; | ||
485 | - session_error_setg(errp, s, "no host key was found in known_hosts"); | ||
486 | + error_setg(errp, | ||
487 | + "host key for this server not found, another type exists"); | ||
488 | + goto out; | ||
489 | + case SSH_SERVER_FILE_NOT_FOUND: | ||
490 | + ret = -ENOENT; | ||
491 | + error_setg(errp, "known_hosts file not found"); | ||
492 | goto out; | ||
493 | - case LIBSSH2_KNOWNHOST_CHECK_FAILURE: | ||
494 | + case SSH_SERVER_NOT_KNOWN: | ||
495 | ret = -EINVAL; | ||
496 | - session_error_setg(errp, s, | ||
497 | - "failure matching the host key with known_hosts"); | ||
498 | + error_setg(errp, "no host key was found in known_hosts"); | ||
499 | + goto out; | ||
500 | + case SSH_SERVER_ERROR: | ||
501 | + ret = -EINVAL; | ||
502 | + error_setg(errp, "server error"); | ||
503 | goto out; | ||
504 | default: | ||
505 | ret = -EINVAL; | ||
506 | - session_error_setg(errp, s, "unknown error matching the host key" | ||
507 | - " with known_hosts (%d)", r); | ||
508 | + error_setg(errp, "error while checking for known server (%d)", state); | ||
509 | goto out; | ||
510 | } | ||
511 | +#endif /* !HAVE_LIBSSH_0_8 */ | ||
512 | |||
513 | /* known_hosts checking successful. */ | ||
514 | ret = 0; | ||
515 | |||
516 | out: | ||
517 | - if (knh != NULL) { | ||
518 | - libssh2_knownhost_free(knh); | ||
519 | - } | ||
520 | - g_free(knh_file); | ||
521 | return ret; | ||
522 | } | ||
523 | |||
524 | @@ -XXX,XX +XXX,XX @@ static int compare_fingerprint(const unsigned char *fingerprint, size_t len, | ||
525 | |||
526 | static int | ||
527 | check_host_key_hash(BDRVSSHState *s, const char *hash, | ||
528 | - int hash_type, size_t fingerprint_len, Error **errp) | ||
529 | + enum ssh_publickey_hash_type type, Error **errp) | ||
530 | { | ||
531 | - const char *fingerprint; | ||
532 | - | ||
533 | - fingerprint = libssh2_hostkey_hash(s->session, hash_type); | ||
534 | - if (!fingerprint) { | ||
535 | + int r; | ||
536 | + ssh_key pubkey; | ||
537 | + unsigned char *server_hash; | ||
538 | + size_t server_hash_len; | ||
539 | + | ||
540 | +#ifdef HAVE_LIBSSH_0_8 | ||
541 | + r = ssh_get_server_publickey(s->session, &pubkey); | ||
542 | +#else | ||
543 | + r = ssh_get_publickey(s->session, &pubkey); | ||
544 | +#endif | ||
545 | + if (r != SSH_OK) { | ||
546 | session_error_setg(errp, s, "failed to read remote host key"); | ||
547 | return -EINVAL; | ||
548 | } | ||
549 | |||
550 | - if(compare_fingerprint((unsigned char *) fingerprint, fingerprint_len, | ||
551 | - hash) != 0) { | ||
552 | + r = ssh_get_publickey_hash(pubkey, type, &server_hash, &server_hash_len); | ||
553 | + ssh_key_free(pubkey); | ||
554 | + if (r != 0) { | ||
555 | + session_error_setg(errp, s, | ||
556 | + "failed reading the hash of the server SSH key"); | ||
557 | + return -EINVAL; | ||
558 | + } | ||
559 | + | ||
560 | + r = compare_fingerprint(server_hash, server_hash_len, hash); | ||
561 | + ssh_clean_pubkey_hash(&server_hash); | ||
562 | + if (r != 0) { | ||
563 | error_setg(errp, "remote host key does not match host_key_check '%s'", | ||
564 | hash); | ||
565 | return -EPERM; | ||
566 | @@ -XXX,XX +XXX,XX @@ check_host_key_hash(BDRVSSHState *s, const char *hash, | ||
567 | return 0; | ||
568 | } | ||
569 | |||
570 | -static int check_host_key(BDRVSSHState *s, const char *host, int port, | ||
571 | - SshHostKeyCheck *hkc, Error **errp) | ||
572 | +static int check_host_key(BDRVSSHState *s, SshHostKeyCheck *hkc, Error **errp) | ||
573 | { | ||
574 | SshHostKeyCheckMode mode; | ||
575 | |||
576 | @@ -XXX,XX +XXX,XX @@ static int check_host_key(BDRVSSHState *s, const char *host, int port, | ||
577 | case SSH_HOST_KEY_CHECK_MODE_HASH: | ||
578 | if (hkc->u.hash.type == SSH_HOST_KEY_CHECK_HASH_TYPE_MD5) { | ||
579 | return check_host_key_hash(s, hkc->u.hash.hash, | ||
580 | - LIBSSH2_HOSTKEY_HASH_MD5, 16, errp); | ||
581 | + SSH_PUBLICKEY_HASH_MD5, errp); | ||
582 | } else if (hkc->u.hash.type == SSH_HOST_KEY_CHECK_HASH_TYPE_SHA1) { | ||
583 | return check_host_key_hash(s, hkc->u.hash.hash, | ||
584 | - LIBSSH2_HOSTKEY_HASH_SHA1, 20, errp); | ||
585 | + SSH_PUBLICKEY_HASH_SHA1, errp); | ||
72 | } | 586 | } |
73 | - return notifier_with_return_list_notify(&bs->before_write_notifiers, | 587 | g_assert_not_reached(); |
74 | - req); | 588 | break; |
75 | + bdrv_write_threshold_check_write(bs, offset, bytes); | 589 | case SSH_HOST_KEY_CHECK_MODE_KNOWN_HOSTS: |
76 | + return 0; | 590 | - return check_host_key_knownhosts(s, host, port, errp); |
77 | case BDRV_TRACKED_TRUNCATE: | 591 | + return check_host_key_knownhosts(s, errp); |
78 | assert(child->perm & BLK_PERM_RESIZE); | 592 | default: |
79 | return 0; | 593 | g_assert_not_reached(); |
80 | diff --git a/block/write-threshold.c b/block/write-threshold.c | 594 | } |
81 | index XXXXXXX..XXXXXXX 100644 | 595 | @@ -XXX,XX +XXX,XX @@ static int check_host_key(BDRVSSHState *s, const char *host, int port, |
82 | --- a/block/write-threshold.c | 596 | return -EINVAL; |
83 | +++ b/block/write-threshold.c | ||
84 | @@ -XXX,XX +XXX,XX @@ bool bdrv_write_threshold_is_set(const BlockDriverState *bs) | ||
85 | return bs->write_threshold_offset > 0; | ||
86 | } | 597 | } |
87 | 598 | ||
88 | -static void write_threshold_disable(BlockDriverState *bs) | 599 | -static int authenticate(BDRVSSHState *s, const char *user, Error **errp) |
600 | +static int authenticate(BDRVSSHState *s, Error **errp) | ||
601 | { | ||
602 | int r, ret; | ||
603 | - const char *userauthlist; | ||
604 | - LIBSSH2_AGENT *agent = NULL; | ||
605 | - struct libssh2_agent_publickey *identity; | ||
606 | - struct libssh2_agent_publickey *prev_identity = NULL; | ||
607 | + int method; | ||
608 | |||
609 | - userauthlist = libssh2_userauth_list(s->session, user, strlen(user)); | ||
610 | - if (strstr(userauthlist, "publickey") == NULL) { | ||
611 | + /* Try to authenticate with the "none" method. */ | ||
612 | + r = ssh_userauth_none(s->session, NULL); | ||
613 | + if (r == SSH_AUTH_ERROR) { | ||
614 | ret = -EPERM; | ||
615 | - error_setg(errp, | ||
616 | - "remote server does not support \"publickey\" authentication"); | ||
617 | + session_error_setg(errp, s, "failed to authenticate using none " | ||
618 | + "authentication"); | ||
619 | goto out; | ||
620 | - } | ||
621 | - | ||
622 | - /* Connect to ssh-agent and try each identity in turn. */ | ||
623 | - agent = libssh2_agent_init(s->session); | ||
624 | - if (!agent) { | ||
625 | - ret = -EINVAL; | ||
626 | - session_error_setg(errp, s, "failed to initialize ssh-agent support"); | ||
627 | - goto out; | ||
628 | - } | ||
629 | - if (libssh2_agent_connect(agent)) { | ||
630 | - ret = -ECONNREFUSED; | ||
631 | - session_error_setg(errp, s, "failed to connect to ssh-agent"); | ||
632 | - goto out; | ||
633 | - } | ||
634 | - if (libssh2_agent_list_identities(agent)) { | ||
635 | - ret = -EINVAL; | ||
636 | - session_error_setg(errp, s, | ||
637 | - "failed requesting identities from ssh-agent"); | ||
638 | + } else if (r == SSH_AUTH_SUCCESS) { | ||
639 | + /* Authenticated! */ | ||
640 | + ret = 0; | ||
641 | goto out; | ||
642 | } | ||
643 | |||
644 | - for(;;) { | ||
645 | - r = libssh2_agent_get_identity(agent, &identity, prev_identity); | ||
646 | - if (r == 1) { /* end of list */ | ||
647 | - break; | ||
648 | - } | ||
649 | - if (r < 0) { | ||
650 | + method = ssh_userauth_list(s->session, NULL); | ||
651 | + trace_ssh_auth_methods(method); | ||
652 | + | ||
653 | + /* | ||
654 | + * Try to authenticate with publickey, using the ssh-agent | ||
655 | + * if available. | ||
656 | + */ | ||
657 | + if (method & SSH_AUTH_METHOD_PUBLICKEY) { | ||
658 | + r = ssh_userauth_publickey_auto(s->session, NULL, NULL); | ||
659 | + if (r == SSH_AUTH_ERROR) { | ||
660 | ret = -EINVAL; | ||
661 | - session_error_setg(errp, s, | ||
662 | - "failed to obtain identity from ssh-agent"); | ||
663 | + session_error_setg(errp, s, "failed to authenticate using " | ||
664 | + "publickey authentication"); | ||
665 | goto out; | ||
666 | - } | ||
667 | - r = libssh2_agent_userauth(agent, user, identity); | ||
668 | - if (r == 0) { | ||
669 | + } else if (r == SSH_AUTH_SUCCESS) { | ||
670 | /* Authenticated! */ | ||
671 | ret = 0; | ||
672 | goto out; | ||
673 | } | ||
674 | - /* Failed to authenticate with this identity, try the next one. */ | ||
675 | - prev_identity = identity; | ||
676 | } | ||
677 | |||
678 | ret = -EPERM; | ||
679 | @@ -XXX,XX +XXX,XX @@ static int authenticate(BDRVSSHState *s, const char *user, Error **errp) | ||
680 | "and the identities held by your ssh-agent"); | ||
681 | |||
682 | out: | ||
683 | - if (agent != NULL) { | ||
684 | - /* Note: libssh2 implementation implicitly calls | ||
685 | - * libssh2_agent_disconnect if necessary. | ||
686 | - */ | ||
687 | - libssh2_agent_free(agent); | ||
688 | - } | ||
689 | - | ||
690 | return ret; | ||
691 | } | ||
692 | |||
693 | @@ -XXX,XX +XXX,XX @@ static int connect_to_ssh(BDRVSSHState *s, BlockdevOptionsSsh *opts, | ||
694 | int ssh_flags, int creat_mode, Error **errp) | ||
695 | { | ||
696 | int r, ret; | ||
697 | - long port = 0; | ||
698 | + unsigned int port = 0; | ||
699 | + int new_sock = -1; | ||
700 | |||
701 | if (opts->has_user) { | ||
702 | s->user = g_strdup(opts->user); | ||
703 | @@ -XXX,XX +XXX,XX @@ static int connect_to_ssh(BDRVSSHState *s, BlockdevOptionsSsh *opts, | ||
704 | s->inet = opts->server; | ||
705 | opts->server = NULL; | ||
706 | |||
707 | - if (qemu_strtol(s->inet->port, NULL, 10, &port) < 0) { | ||
708 | + if (qemu_strtoui(s->inet->port, NULL, 10, &port) < 0) { | ||
709 | error_setg(errp, "Use only numeric port value"); | ||
710 | ret = -EINVAL; | ||
711 | goto err; | ||
712 | } | ||
713 | |||
714 | /* Open the socket and connect. */ | ||
715 | - s->sock = inet_connect_saddr(s->inet, errp); | ||
716 | - if (s->sock < 0) { | ||
717 | + new_sock = inet_connect_saddr(s->inet, errp); | ||
718 | + if (new_sock < 0) { | ||
719 | ret = -EIO; | ||
720 | goto err; | ||
721 | } | ||
722 | |||
723 | + /* | ||
724 | + * Try to disable the Nagle algorithm on TCP sockets to reduce latency, | ||
725 | + * but do not fail if it cannot be disabled. | ||
726 | + */ | ||
727 | + r = socket_set_nodelay(new_sock); | ||
728 | + if (r < 0) { | ||
729 | + warn_report("can't set TCP_NODELAY for the ssh server %s: %s", | ||
730 | + s->inet->host, strerror(errno)); | ||
731 | + } | ||
732 | + | ||
733 | /* Create SSH session. */ | ||
734 | - s->session = libssh2_session_init(); | ||
735 | + s->session = ssh_new(); | ||
736 | if (!s->session) { | ||
737 | ret = -EINVAL; | ||
738 | - session_error_setg(errp, s, "failed to initialize libssh2 session"); | ||
739 | + session_error_setg(errp, s, "failed to initialize libssh session"); | ||
740 | goto err; | ||
741 | } | ||
742 | |||
743 | -#if TRACE_LIBSSH2 != 0 | ||
744 | - libssh2_trace(s->session, TRACE_LIBSSH2); | ||
745 | -#endif | ||
746 | + /* | ||
747 | + * Make sure we are in blocking mode during the connection and | ||
748 | + * authentication phases. | ||
749 | + */ | ||
750 | + ssh_set_blocking(s->session, 1); | ||
751 | |||
752 | - r = libssh2_session_handshake(s->session, s->sock); | ||
753 | - if (r != 0) { | ||
754 | + r = ssh_options_set(s->session, SSH_OPTIONS_USER, s->user); | ||
755 | + if (r < 0) { | ||
756 | + ret = -EINVAL; | ||
757 | + session_error_setg(errp, s, | ||
758 | + "failed to set the user in the libssh session"); | ||
759 | + goto err; | ||
760 | + } | ||
761 | + | ||
762 | + r = ssh_options_set(s->session, SSH_OPTIONS_HOST, s->inet->host); | ||
763 | + if (r < 0) { | ||
764 | + ret = -EINVAL; | ||
765 | + session_error_setg(errp, s, | ||
766 | + "failed to set the host in the libssh session"); | ||
767 | + goto err; | ||
768 | + } | ||
769 | + | ||
770 | + if (port > 0) { | ||
771 | + r = ssh_options_set(s->session, SSH_OPTIONS_PORT, &port); | ||
772 | + if (r < 0) { | ||
773 | + ret = -EINVAL; | ||
774 | + session_error_setg(errp, s, | ||
775 | + "failed to set the port in the libssh session"); | ||
776 | + goto err; | ||
777 | + } | ||
778 | + } | ||
779 | + | ||
780 | + r = ssh_options_set(s->session, SSH_OPTIONS_COMPRESSION, "none"); | ||
781 | + if (r < 0) { | ||
782 | + ret = -EINVAL; | ||
783 | + session_error_setg(errp, s, | ||
784 | + "failed to disable the compression in the libssh " | ||
785 | + "session"); | ||
786 | + goto err; | ||
787 | + } | ||
788 | + | ||
789 | + /* Read ~/.ssh/config. */ | ||
790 | + r = ssh_options_parse_config(s->session, NULL); | ||
791 | + if (r < 0) { | ||
792 | + ret = -EINVAL; | ||
793 | + session_error_setg(errp, s, "failed to parse ~/.ssh/config"); | ||
794 | + goto err; | ||
795 | + } | ||
796 | + | ||
797 | + r = ssh_options_set(s->session, SSH_OPTIONS_FD, &new_sock); | ||
798 | + if (r < 0) { | ||
799 | + ret = -EINVAL; | ||
800 | + session_error_setg(errp, s, | ||
801 | + "failed to set the socket in the libssh session"); | ||
802 | + goto err; | ||
803 | + } | ||
804 | + /* libssh took ownership of the socket. */ | ||
805 | + s->sock = new_sock; | ||
806 | + new_sock = -1; | ||
807 | + | ||
808 | + /* Connect. */ | ||
809 | + r = ssh_connect(s->session); | ||
810 | + if (r != SSH_OK) { | ||
811 | ret = -EINVAL; | ||
812 | session_error_setg(errp, s, "failed to establish SSH session"); | ||
813 | goto err; | ||
814 | } | ||
815 | |||
816 | /* Check the remote host's key against known_hosts. */ | ||
817 | - ret = check_host_key(s, s->inet->host, port, opts->host_key_check, errp); | ||
818 | + ret = check_host_key(s, opts->host_key_check, errp); | ||
819 | if (ret < 0) { | ||
820 | goto err; | ||
821 | } | ||
822 | |||
823 | /* Authenticate. */ | ||
824 | - ret = authenticate(s, s->user, errp); | ||
825 | + ret = authenticate(s, errp); | ||
826 | if (ret < 0) { | ||
827 | goto err; | ||
828 | } | ||
829 | |||
830 | /* Start SFTP. */ | ||
831 | - s->sftp = libssh2_sftp_init(s->session); | ||
832 | + s->sftp = sftp_new(s->session); | ||
833 | if (!s->sftp) { | ||
834 | - session_error_setg(errp, s, "failed to initialize sftp handle"); | ||
835 | + session_error_setg(errp, s, "failed to create sftp handle"); | ||
836 | + ret = -EINVAL; | ||
837 | + goto err; | ||
838 | + } | ||
839 | + | ||
840 | + r = sftp_init(s->sftp); | ||
841 | + if (r < 0) { | ||
842 | + sftp_error_setg(errp, s, "failed to initialize sftp handle"); | ||
843 | ret = -EINVAL; | ||
844 | goto err; | ||
845 | } | ||
846 | |||
847 | /* Open the remote file. */ | ||
848 | trace_ssh_connect_to_ssh(opts->path, ssh_flags, creat_mode); | ||
849 | - s->sftp_handle = libssh2_sftp_open(s->sftp, opts->path, ssh_flags, | ||
850 | - creat_mode); | ||
851 | + s->sftp_handle = sftp_open(s->sftp, opts->path, ssh_flags, creat_mode); | ||
852 | if (!s->sftp_handle) { | ||
853 | - session_error_setg(errp, s, "failed to open remote file '%s'", | ||
854 | - opts->path); | ||
855 | + sftp_error_setg(errp, s, "failed to open remote file '%s'", | ||
856 | + opts->path); | ||
857 | ret = -EINVAL; | ||
858 | goto err; | ||
859 | } | ||
860 | |||
861 | - r = libssh2_sftp_fstat(s->sftp_handle, &s->attrs); | ||
862 | - if (r < 0) { | ||
863 | + /* Make sure the SFTP file is handled in blocking mode. */ | ||
864 | + sftp_file_set_blocking(s->sftp_handle); | ||
865 | + | ||
866 | + s->attrs = sftp_fstat(s->sftp_handle); | ||
867 | + if (!s->attrs) { | ||
868 | sftp_error_setg(errp, s, "failed to read file attributes"); | ||
869 | return -EINVAL; | ||
870 | } | ||
871 | @@ -XXX,XX +XXX,XX @@ static int connect_to_ssh(BDRVSSHState *s, BlockdevOptionsSsh *opts, | ||
872 | return 0; | ||
873 | |||
874 | err: | ||
875 | + if (s->attrs) { | ||
876 | + sftp_attributes_free(s->attrs); | ||
877 | + } | ||
878 | + s->attrs = NULL; | ||
879 | if (s->sftp_handle) { | ||
880 | - libssh2_sftp_close(s->sftp_handle); | ||
881 | + sftp_close(s->sftp_handle); | ||
882 | } | ||
883 | s->sftp_handle = NULL; | ||
884 | if (s->sftp) { | ||
885 | - libssh2_sftp_shutdown(s->sftp); | ||
886 | + sftp_free(s->sftp); | ||
887 | } | ||
888 | s->sftp = NULL; | ||
889 | if (s->session) { | ||
890 | - libssh2_session_disconnect(s->session, | ||
891 | - "from qemu ssh client: " | ||
892 | - "error opening connection"); | ||
893 | - libssh2_session_free(s->session); | ||
894 | + ssh_disconnect(s->session); | ||
895 | + ssh_free(s->session); | ||
896 | } | ||
897 | s->session = NULL; | ||
898 | + s->sock = -1; | ||
899 | + if (new_sock >= 0) { | ||
900 | + close(new_sock); | ||
901 | + } | ||
902 | |||
903 | return ret; | ||
904 | } | ||
905 | @@ -XXX,XX +XXX,XX @@ static int ssh_file_open(BlockDriverState *bs, QDict *options, int bdrv_flags, | ||
906 | |||
907 | ssh_state_init(s); | ||
908 | |||
909 | - ssh_flags = LIBSSH2_FXF_READ; | ||
910 | + ssh_flags = 0; | ||
911 | if (bdrv_flags & BDRV_O_RDWR) { | ||
912 | - ssh_flags |= LIBSSH2_FXF_WRITE; | ||
913 | + ssh_flags |= O_RDWR; | ||
914 | + } else { | ||
915 | + ssh_flags |= O_RDONLY; | ||
916 | } | ||
917 | |||
918 | opts = ssh_parse_options(options, errp); | ||
919 | @@ -XXX,XX +XXX,XX @@ static int ssh_file_open(BlockDriverState *bs, QDict *options, int bdrv_flags, | ||
920 | } | ||
921 | |||
922 | /* Go non-blocking. */ | ||
923 | - libssh2_session_set_blocking(s->session, 0); | ||
924 | + ssh_set_blocking(s->session, 0); | ||
925 | |||
926 | qapi_free_BlockdevOptionsSsh(opts); | ||
927 | |||
928 | return 0; | ||
929 | |||
930 | err: | ||
931 | - if (s->sock >= 0) { | ||
932 | - close(s->sock); | ||
933 | - } | ||
934 | - s->sock = -1; | ||
935 | - | ||
936 | qapi_free_BlockdevOptionsSsh(opts); | ||
937 | |||
938 | return ret; | ||
939 | @@ -XXX,XX +XXX,XX @@ static int ssh_grow_file(BDRVSSHState *s, int64_t offset, Error **errp) | ||
940 | { | ||
941 | ssize_t ret; | ||
942 | char c[1] = { '\0' }; | ||
943 | - int was_blocking = libssh2_session_get_blocking(s->session); | ||
944 | + int was_blocking = ssh_is_blocking(s->session); | ||
945 | |||
946 | /* offset must be strictly greater than the current size so we do | ||
947 | * not overwrite anything */ | ||
948 | - assert(offset > 0 && offset > s->attrs.filesize); | ||
949 | + assert(offset > 0 && offset > s->attrs->size); | ||
950 | |||
951 | - libssh2_session_set_blocking(s->session, 1); | ||
952 | + ssh_set_blocking(s->session, 1); | ||
953 | |||
954 | - libssh2_sftp_seek64(s->sftp_handle, offset - 1); | ||
955 | - ret = libssh2_sftp_write(s->sftp_handle, c, 1); | ||
956 | + sftp_seek64(s->sftp_handle, offset - 1); | ||
957 | + ret = sftp_write(s->sftp_handle, c, 1); | ||
958 | |||
959 | - libssh2_session_set_blocking(s->session, was_blocking); | ||
960 | + ssh_set_blocking(s->session, was_blocking); | ||
961 | |||
962 | if (ret < 0) { | ||
963 | sftp_error_setg(errp, s, "Failed to grow file"); | ||
964 | return -EIO; | ||
965 | } | ||
966 | |||
967 | - s->attrs.filesize = offset; | ||
968 | + s->attrs->size = offset; | ||
969 | return 0; | ||
970 | } | ||
971 | |||
972 | @@ -XXX,XX +XXX,XX @@ static int ssh_co_create(BlockdevCreateOptions *options, Error **errp) | ||
973 | ssh_state_init(&s); | ||
974 | |||
975 | ret = connect_to_ssh(&s, opts->location, | ||
976 | - LIBSSH2_FXF_READ|LIBSSH2_FXF_WRITE| | ||
977 | - LIBSSH2_FXF_CREAT|LIBSSH2_FXF_TRUNC, | ||
978 | + O_RDWR | O_CREAT | O_TRUNC, | ||
979 | 0644, errp); | ||
980 | if (ret < 0) { | ||
981 | goto fail; | ||
982 | @@ -XXX,XX +XXX,XX @@ static int ssh_has_zero_init(BlockDriverState *bs) | ||
983 | /* Assume false, unless we can positively prove it's true. */ | ||
984 | int has_zero_init = 0; | ||
985 | |||
986 | - if (s->attrs.flags & LIBSSH2_SFTP_ATTR_PERMISSIONS) { | ||
987 | - if (s->attrs.permissions & LIBSSH2_SFTP_S_IFREG) { | ||
988 | - has_zero_init = 1; | ||
989 | - } | ||
990 | + if (s->attrs->type == SSH_FILEXFER_TYPE_REGULAR) { | ||
991 | + has_zero_init = 1; | ||
992 | } | ||
993 | |||
994 | return has_zero_init; | ||
995 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn void co_yield(BDRVSSHState *s, BlockDriverState *bs) | ||
996 | .co = qemu_coroutine_self() | ||
997 | }; | ||
998 | |||
999 | - r = libssh2_session_block_directions(s->session); | ||
1000 | + r = ssh_get_poll_flags(s->session); | ||
1001 | |||
1002 | - if (r & LIBSSH2_SESSION_BLOCK_INBOUND) { | ||
1003 | + if (r & SSH_READ_PENDING) { | ||
1004 | rd_handler = restart_coroutine; | ||
1005 | } | ||
1006 | - if (r & LIBSSH2_SESSION_BLOCK_OUTBOUND) { | ||
1007 | + if (r & SSH_WRITE_PENDING) { | ||
1008 | wr_handler = restart_coroutine; | ||
1009 | } | ||
1010 | |||
1011 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn void co_yield(BDRVSSHState *s, BlockDriverState *bs) | ||
1012 | trace_ssh_co_yield_back(s->sock); | ||
1013 | } | ||
1014 | |||
1015 | -/* SFTP has a function `libssh2_sftp_seek64' which seeks to a position | ||
1016 | - * in the remote file. Notice that it just updates a field in the | ||
1017 | - * sftp_handle structure, so there is no network traffic and it cannot | ||
1018 | - * fail. | ||
1019 | - * | ||
1020 | - * However, `libssh2_sftp_seek64' does have a catastrophic effect on | ||
1021 | - * performance since it causes the handle to throw away all in-flight | ||
1022 | - * reads and buffered readahead data. Therefore this function tries | ||
1023 | - * to be intelligent about when to call the underlying libssh2 function. | ||
1024 | - */ | ||
1025 | -#define SSH_SEEK_WRITE 0 | ||
1026 | -#define SSH_SEEK_READ 1 | ||
1027 | -#define SSH_SEEK_FORCE 2 | ||
1028 | - | ||
1029 | -static void ssh_seek(BDRVSSHState *s, int64_t offset, int flags) | ||
89 | -{ | 1030 | -{ |
90 | - if (bdrv_write_threshold_is_set(bs)) { | 1031 | - bool op_read = (flags & SSH_SEEK_READ) != 0; |
91 | - notifier_with_return_remove(&bs->write_threshold_notifier); | 1032 | - bool force = (flags & SSH_SEEK_FORCE) != 0; |
92 | - bs->write_threshold_offset = 0; | 1033 | - |
1034 | - if (force || op_read != s->offset_op_read || offset != s->offset) { | ||
1035 | - trace_ssh_seek(offset); | ||
1036 | - libssh2_sftp_seek64(s->sftp_handle, offset); | ||
1037 | - s->offset = offset; | ||
1038 | - s->offset_op_read = op_read; | ||
93 | - } | 1039 | - } |
94 | -} | 1040 | -} |
95 | - | 1041 | - |
96 | uint64_t bdrv_write_threshold_exceeded(const BlockDriverState *bs, | 1042 | static coroutine_fn int ssh_read(BDRVSSHState *s, BlockDriverState *bs, |
97 | const BdrvTrackedRequest *req) | 1043 | int64_t offset, size_t size, |
1044 | QEMUIOVector *qiov) | ||
1045 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn int ssh_read(BDRVSSHState *s, BlockDriverState *bs, | ||
1046 | |||
1047 | trace_ssh_read(offset, size); | ||
1048 | |||
1049 | - ssh_seek(s, offset, SSH_SEEK_READ); | ||
1050 | + trace_ssh_seek(offset); | ||
1051 | + sftp_seek64(s->sftp_handle, offset); | ||
1052 | |||
1053 | /* This keeps track of the current iovec element ('i'), where we | ||
1054 | * will write to next ('buf'), and the end of the current iovec | ||
1055 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn int ssh_read(BDRVSSHState *s, BlockDriverState *bs, | ||
1056 | buf = i->iov_base; | ||
1057 | end_of_vec = i->iov_base + i->iov_len; | ||
1058 | |||
1059 | - /* libssh2 has a hard-coded limit of 2000 bytes per request, | ||
1060 | - * although it will also do readahead behind our backs. Therefore | ||
1061 | - * we may have to do repeated reads here until we have read 'size' | ||
1062 | - * bytes. | ||
1063 | - */ | ||
1064 | for (got = 0; got < size; ) { | ||
1065 | + size_t request_read_size; | ||
1066 | again: | ||
1067 | - trace_ssh_read_buf(buf, end_of_vec - buf); | ||
1068 | - r = libssh2_sftp_read(s->sftp_handle, buf, end_of_vec - buf); | ||
1069 | - trace_ssh_read_return(r); | ||
1070 | + /* | ||
1071 | + * The size of SFTP packets is limited to 32K bytes, so limit | ||
1072 | + * the amount of data requested to 16K, as libssh currently | ||
1073 | + * does not handle multiple requests on its own. | ||
1074 | + */ | ||
1075 | + request_read_size = MIN(end_of_vec - buf, 16384); | ||
1076 | + trace_ssh_read_buf(buf, end_of_vec - buf, request_read_size); | ||
1077 | + r = sftp_read(s->sftp_handle, buf, request_read_size); | ||
1078 | + trace_ssh_read_return(r, sftp_get_error(s->sftp)); | ||
1079 | |||
1080 | - if (r == LIBSSH2_ERROR_EAGAIN || r == LIBSSH2_ERROR_TIMEOUT) { | ||
1081 | + if (r == SSH_AGAIN) { | ||
1082 | co_yield(s, bs); | ||
1083 | goto again; | ||
1084 | } | ||
1085 | - if (r < 0) { | ||
1086 | - sftp_error_trace(s, "read"); | ||
1087 | - s->offset = -1; | ||
1088 | - return -EIO; | ||
1089 | - } | ||
1090 | - if (r == 0) { | ||
1091 | + if (r == SSH_EOF || (r == 0 && sftp_get_error(s->sftp) == SSH_FX_EOF)) { | ||
1092 | /* EOF: Short read so pad the buffer with zeroes and return it. */ | ||
1093 | qemu_iovec_memset(qiov, got, 0, size - got); | ||
1094 | return 0; | ||
1095 | } | ||
1096 | + if (r <= 0) { | ||
1097 | + sftp_error_trace(s, "read"); | ||
1098 | + return -EIO; | ||
1099 | + } | ||
1100 | |||
1101 | got += r; | ||
1102 | buf += r; | ||
1103 | - s->offset += r; | ||
1104 | if (buf >= end_of_vec && got < size) { | ||
1105 | i++; | ||
1106 | buf = i->iov_base; | ||
1107 | @@ -XXX,XX +XXX,XX @@ static int ssh_write(BDRVSSHState *s, BlockDriverState *bs, | ||
1108 | |||
1109 | trace_ssh_write(offset, size); | ||
1110 | |||
1111 | - ssh_seek(s, offset, SSH_SEEK_WRITE); | ||
1112 | + trace_ssh_seek(offset); | ||
1113 | + sftp_seek64(s->sftp_handle, offset); | ||
1114 | |||
1115 | /* This keeps track of the current iovec element ('i'), where we | ||
1116 | * will read from next ('buf'), and the end of the current iovec | ||
1117 | @@ -XXX,XX +XXX,XX @@ static int ssh_write(BDRVSSHState *s, BlockDriverState *bs, | ||
1118 | end_of_vec = i->iov_base + i->iov_len; | ||
1119 | |||
1120 | for (written = 0; written < size; ) { | ||
1121 | + size_t request_write_size; | ||
1122 | again: | ||
1123 | - trace_ssh_write_buf(buf, end_of_vec - buf); | ||
1124 | - r = libssh2_sftp_write(s->sftp_handle, buf, end_of_vec - buf); | ||
1125 | - trace_ssh_write_return(r); | ||
1126 | + /* | ||
1127 | + * Avoid too large data packets, as libssh currently does not | ||
1128 | + * handle multiple requests on its own. | ||
1129 | + */ | ||
1130 | + request_write_size = MIN(end_of_vec - buf, 131072); | ||
1131 | + trace_ssh_write_buf(buf, end_of_vec - buf, request_write_size); | ||
1132 | + r = sftp_write(s->sftp_handle, buf, request_write_size); | ||
1133 | + trace_ssh_write_return(r, sftp_get_error(s->sftp)); | ||
1134 | |||
1135 | - if (r == LIBSSH2_ERROR_EAGAIN || r == LIBSSH2_ERROR_TIMEOUT) { | ||
1136 | + if (r == SSH_AGAIN) { | ||
1137 | co_yield(s, bs); | ||
1138 | goto again; | ||
1139 | } | ||
1140 | if (r < 0) { | ||
1141 | sftp_error_trace(s, "write"); | ||
1142 | - s->offset = -1; | ||
1143 | return -EIO; | ||
1144 | } | ||
1145 | - /* The libssh2 API is very unclear about this. A comment in | ||
1146 | - * the code says "nothing was acked, and no EAGAIN was | ||
1147 | - * received!" which apparently means that no data got sent | ||
1148 | - * out, and the underlying channel didn't return any EAGAIN | ||
1149 | - * indication. I think this is a bug in either libssh2 or | ||
1150 | - * OpenSSH (server-side). In any case, forcing a seek (to | ||
1151 | - * discard libssh2 internal buffers), and then trying again | ||
1152 | - * works for me. | ||
1153 | - */ | ||
1154 | - if (r == 0) { | ||
1155 | - ssh_seek(s, offset + written, SSH_SEEK_WRITE|SSH_SEEK_FORCE); | ||
1156 | - co_yield(s, bs); | ||
1157 | - goto again; | ||
1158 | - } | ||
1159 | |||
1160 | written += r; | ||
1161 | buf += r; | ||
1162 | - s->offset += r; | ||
1163 | if (buf >= end_of_vec && written < size) { | ||
1164 | i++; | ||
1165 | buf = i->iov_base; | ||
1166 | end_of_vec = i->iov_base + i->iov_len; | ||
1167 | } | ||
1168 | |||
1169 | - if (offset + written > s->attrs.filesize) | ||
1170 | - s->attrs.filesize = offset + written; | ||
1171 | + if (offset + written > s->attrs->size) { | ||
1172 | + s->attrs->size = offset + written; | ||
1173 | + } | ||
1174 | } | ||
1175 | |||
1176 | return 0; | ||
1177 | @@ -XXX,XX +XXX,XX @@ static void unsafe_flush_warning(BDRVSSHState *s, const char *what) | ||
1178 | } | ||
1179 | } | ||
1180 | |||
1181 | -#ifdef HAS_LIBSSH2_SFTP_FSYNC | ||
1182 | +#ifdef HAVE_LIBSSH_0_8 | ||
1183 | |||
1184 | static coroutine_fn int ssh_flush(BDRVSSHState *s, BlockDriverState *bs) | ||
98 | { | 1185 | { |
99 | @@ -XXX,XX +XXX,XX @@ uint64_t bdrv_write_threshold_exceeded(const BlockDriverState *bs, | 1186 | int r; |
1187 | |||
1188 | trace_ssh_flush(); | ||
1189 | + | ||
1190 | + if (!sftp_extension_supported(s->sftp, "fsync@openssh.com", "1")) { | ||
1191 | + unsafe_flush_warning(s, "OpenSSH >= 6.3"); | ||
1192 | + return 0; | ||
1193 | + } | ||
1194 | again: | ||
1195 | - r = libssh2_sftp_fsync(s->sftp_handle); | ||
1196 | - if (r == LIBSSH2_ERROR_EAGAIN || r == LIBSSH2_ERROR_TIMEOUT) { | ||
1197 | + r = sftp_fsync(s->sftp_handle); | ||
1198 | + if (r == SSH_AGAIN) { | ||
1199 | co_yield(s, bs); | ||
1200 | goto again; | ||
1201 | } | ||
1202 | - if (r == LIBSSH2_ERROR_SFTP_PROTOCOL && | ||
1203 | - libssh2_sftp_last_error(s->sftp) == LIBSSH2_FX_OP_UNSUPPORTED) { | ||
1204 | - unsafe_flush_warning(s, "OpenSSH >= 6.3"); | ||
1205 | - return 0; | ||
1206 | - } | ||
1207 | if (r < 0) { | ||
1208 | sftp_error_trace(s, "fsync"); | ||
1209 | return -EIO; | ||
1210 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn int ssh_co_flush(BlockDriverState *bs) | ||
1211 | return ret; | ||
1212 | } | ||
1213 | |||
1214 | -#else /* !HAS_LIBSSH2_SFTP_FSYNC */ | ||
1215 | +#else /* !HAVE_LIBSSH_0_8 */ | ||
1216 | |||
1217 | static coroutine_fn int ssh_co_flush(BlockDriverState *bs) | ||
1218 | { | ||
1219 | BDRVSSHState *s = bs->opaque; | ||
1220 | |||
1221 | - unsafe_flush_warning(s, "libssh2 >= 1.4.4"); | ||
1222 | + unsafe_flush_warning(s, "libssh >= 0.8.0"); | ||
100 | return 0; | 1223 | return 0; |
101 | } | 1224 | } |
102 | 1225 | ||
103 | -static int coroutine_fn before_write_notify(NotifierWithReturn *notifier, | 1226 | -#endif /* !HAS_LIBSSH2_SFTP_FSYNC */ |
104 | - void *opaque) | 1227 | +#endif /* !HAVE_LIBSSH_0_8 */ |
105 | -{ | 1228 | |
106 | - BdrvTrackedRequest *req = opaque; | 1229 | static int64_t ssh_getlength(BlockDriverState *bs) |
107 | - BlockDriverState *bs = req->bs; | 1230 | { |
108 | - uint64_t amount = 0; | 1231 | BDRVSSHState *s = bs->opaque; |
1232 | int64_t length; | ||
1233 | |||
1234 | - /* Note we cannot make a libssh2 call here. */ | ||
1235 | - length = (int64_t) s->attrs.filesize; | ||
1236 | + /* Note we cannot make a libssh call here. */ | ||
1237 | + length = (int64_t) s->attrs->size; | ||
1238 | trace_ssh_getlength(length); | ||
1239 | |||
1240 | return length; | ||
1241 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn ssh_co_truncate(BlockDriverState *bs, int64_t offset, | ||
1242 | return -ENOTSUP; | ||
1243 | } | ||
1244 | |||
1245 | - if (offset < s->attrs.filesize) { | ||
1246 | + if (offset < s->attrs->size) { | ||
1247 | error_setg(errp, "ssh driver does not support shrinking files"); | ||
1248 | return -ENOTSUP; | ||
1249 | } | ||
1250 | |||
1251 | - if (offset == s->attrs.filesize) { | ||
1252 | + if (offset == s->attrs->size) { | ||
1253 | return 0; | ||
1254 | } | ||
1255 | |||
1256 | @@ -XXX,XX +XXX,XX @@ static void bdrv_ssh_init(void) | ||
1257 | { | ||
1258 | int r; | ||
1259 | |||
1260 | - r = libssh2_init(0); | ||
1261 | + r = ssh_init(); | ||
1262 | if (r != 0) { | ||
1263 | - fprintf(stderr, "libssh2 initialization failed, %d\n", r); | ||
1264 | + fprintf(stderr, "libssh initialization failed, %d\n", r); | ||
1265 | exit(EXIT_FAILURE); | ||
1266 | } | ||
1267 | |||
1268 | +#if TRACE_LIBSSH != 0 | ||
1269 | + ssh_set_log_level(TRACE_LIBSSH); | ||
1270 | +#endif | ||
1271 | + | ||
1272 | bdrv_register(&bdrv_ssh); | ||
1273 | } | ||
1274 | |||
1275 | diff --git a/.travis.yml b/.travis.yml | ||
1276 | index XXXXXXX..XXXXXXX 100644 | ||
1277 | --- a/.travis.yml | ||
1278 | +++ b/.travis.yml | ||
1279 | @@ -XXX,XX +XXX,XX @@ addons: | ||
1280 | - libseccomp-dev | ||
1281 | - libspice-protocol-dev | ||
1282 | - libspice-server-dev | ||
1283 | - - libssh2-1-dev | ||
1284 | + - libssh-dev | ||
1285 | - liburcu-dev | ||
1286 | - libusb-1.0-0-dev | ||
1287 | - libvte-2.91-dev | ||
1288 | @@ -XXX,XX +XXX,XX @@ matrix: | ||
1289 | - libseccomp-dev | ||
1290 | - libspice-protocol-dev | ||
1291 | - libspice-server-dev | ||
1292 | - - libssh2-1-dev | ||
1293 | + - libssh-dev | ||
1294 | - liburcu-dev | ||
1295 | - libusb-1.0-0-dev | ||
1296 | - libvte-2.91-dev | ||
1297 | diff --git a/block/trace-events b/block/trace-events | ||
1298 | index XXXXXXX..XXXXXXX 100644 | ||
1299 | --- a/block/trace-events | ||
1300 | +++ b/block/trace-events | ||
1301 | @@ -XXX,XX +XXX,XX @@ nbd_client_connect_success(const char *export_name) "export '%s'" | ||
1302 | # ssh.c | ||
1303 | ssh_restart_coroutine(void *co) "co=%p" | ||
1304 | ssh_flush(void) "fsync" | ||
1305 | -ssh_check_host_key_knownhosts(const char *key) "host key OK: %s" | ||
1306 | +ssh_check_host_key_knownhosts(void) "host key OK" | ||
1307 | ssh_connect_to_ssh(char *path, int flags, int mode) "opening file %s flags=0x%x creat_mode=0%o" | ||
1308 | ssh_co_yield(int sock, void *rd_handler, void *wr_handler) "s->sock=%d rd_handler=%p wr_handler=%p" | ||
1309 | ssh_co_yield_back(int sock) "s->sock=%d - back" | ||
1310 | ssh_getlength(int64_t length) "length=%" PRIi64 | ||
1311 | ssh_co_create_opts(uint64_t size) "total_size=%" PRIu64 | ||
1312 | ssh_read(int64_t offset, size_t size) "offset=%" PRIi64 " size=%zu" | ||
1313 | -ssh_read_buf(void *buf, size_t size) "sftp_read buf=%p size=%zu" | ||
1314 | -ssh_read_return(ssize_t ret) "sftp_read returned %zd" | ||
1315 | +ssh_read_buf(void *buf, size_t size, size_t actual_size) "sftp_read buf=%p size=%zu (actual size=%zu)" | ||
1316 | +ssh_read_return(ssize_t ret, int sftp_err) "sftp_read returned %zd (sftp error=%d)" | ||
1317 | ssh_write(int64_t offset, size_t size) "offset=%" PRIi64 " size=%zu" | ||
1318 | -ssh_write_buf(void *buf, size_t size) "sftp_write buf=%p size=%zu" | ||
1319 | -ssh_write_return(ssize_t ret) "sftp_write returned %zd" | ||
1320 | +ssh_write_buf(void *buf, size_t size, size_t actual_size) "sftp_write buf=%p size=%zu (actual size=%zu)" | ||
1321 | +ssh_write_return(ssize_t ret, int sftp_err) "sftp_write returned %zd (sftp error=%d)" | ||
1322 | ssh_seek(int64_t offset) "seeking to offset=%" PRIi64 | ||
1323 | +ssh_auth_methods(int methods) "auth methods=0x%x" | ||
1324 | +ssh_server_status(int status) "server status=%d" | ||
1325 | |||
1326 | # curl.c | ||
1327 | curl_timer_cb(long timeout_ms) "timer callback timeout_ms %ld" | ||
1328 | @@ -XXX,XX +XXX,XX @@ sheepdog_snapshot_create(const char *sn_name, const char *id) "%s %s" | ||
1329 | sheepdog_snapshot_create_inode(const char *name, uint32_t snap, uint32_t vdi) "s->inode: name %s snap_id 0x%" PRIx32 " vdi 0x%" PRIx32 | ||
1330 | |||
1331 | # ssh.c | ||
1332 | -sftp_error(const char *op, const char *ssh_err, int ssh_err_code, unsigned long sftp_err_code) "%s failed: %s (libssh2 error code: %d, sftp error code: %lu)" | ||
1333 | +sftp_error(const char *op, const char *ssh_err, int ssh_err_code, int sftp_err_code) "%s failed: %s (libssh error code: %d, sftp error code: %d)" | ||
1334 | diff --git a/docs/qemu-block-drivers.texi b/docs/qemu-block-drivers.texi | ||
1335 | index XXXXXXX..XXXXXXX 100644 | ||
1336 | --- a/docs/qemu-block-drivers.texi | ||
1337 | +++ b/docs/qemu-block-drivers.texi | ||
1338 | @@ -XXX,XX +XXX,XX @@ print a warning when @code{fsync} is not supported: | ||
1339 | |||
1340 | warning: ssh server @code{ssh.example.com:22} does not support fsync | ||
1341 | |||
1342 | -With sufficiently new versions of libssh2 and OpenSSH, @code{fsync} is | ||
1343 | +With sufficiently new versions of libssh and OpenSSH, @code{fsync} is | ||
1344 | supported. | ||
1345 | |||
1346 | @node disk_images_nvme | ||
1347 | diff --git a/tests/docker/dockerfiles/debian-win32-cross.docker b/tests/docker/dockerfiles/debian-win32-cross.docker | ||
1348 | index XXXXXXX..XXXXXXX 100644 | ||
1349 | --- a/tests/docker/dockerfiles/debian-win32-cross.docker | ||
1350 | +++ b/tests/docker/dockerfiles/debian-win32-cross.docker | ||
1351 | @@ -XXX,XX +XXX,XX @@ RUN DEBIAN_FRONTEND=noninteractive eatmydata \ | ||
1352 | mxe-$TARGET-w64-mingw32.shared-curl \ | ||
1353 | mxe-$TARGET-w64-mingw32.shared-glib \ | ||
1354 | mxe-$TARGET-w64-mingw32.shared-libgcrypt \ | ||
1355 | - mxe-$TARGET-w64-mingw32.shared-libssh2 \ | ||
1356 | mxe-$TARGET-w64-mingw32.shared-libusb1 \ | ||
1357 | mxe-$TARGET-w64-mingw32.shared-lzo \ | ||
1358 | mxe-$TARGET-w64-mingw32.shared-nettle \ | ||
1359 | diff --git a/tests/docker/dockerfiles/debian-win64-cross.docker b/tests/docker/dockerfiles/debian-win64-cross.docker | ||
1360 | index XXXXXXX..XXXXXXX 100644 | ||
1361 | --- a/tests/docker/dockerfiles/debian-win64-cross.docker | ||
1362 | +++ b/tests/docker/dockerfiles/debian-win64-cross.docker | ||
1363 | @@ -XXX,XX +XXX,XX @@ RUN DEBIAN_FRONTEND=noninteractive eatmydata \ | ||
1364 | mxe-$TARGET-w64-mingw32.shared-curl \ | ||
1365 | mxe-$TARGET-w64-mingw32.shared-glib \ | ||
1366 | mxe-$TARGET-w64-mingw32.shared-libgcrypt \ | ||
1367 | - mxe-$TARGET-w64-mingw32.shared-libssh2 \ | ||
1368 | mxe-$TARGET-w64-mingw32.shared-libusb1 \ | ||
1369 | mxe-$TARGET-w64-mingw32.shared-lzo \ | ||
1370 | mxe-$TARGET-w64-mingw32.shared-nettle \ | ||
1371 | diff --git a/tests/docker/dockerfiles/fedora.docker b/tests/docker/dockerfiles/fedora.docker | ||
1372 | index XXXXXXX..XXXXXXX 100644 | ||
1373 | --- a/tests/docker/dockerfiles/fedora.docker | ||
1374 | +++ b/tests/docker/dockerfiles/fedora.docker | ||
1375 | @@ -XXX,XX +XXX,XX @@ ENV PACKAGES \ | ||
1376 | libpng-devel \ | ||
1377 | librbd-devel \ | ||
1378 | libseccomp-devel \ | ||
1379 | - libssh2-devel \ | ||
1380 | + libssh-devel \ | ||
1381 | libubsan \ | ||
1382 | libusbx-devel \ | ||
1383 | libxml2-devel \ | ||
1384 | @@ -XXX,XX +XXX,XX @@ ENV PACKAGES \ | ||
1385 | mingw32-gtk3 \ | ||
1386 | mingw32-libjpeg-turbo \ | ||
1387 | mingw32-libpng \ | ||
1388 | - mingw32-libssh2 \ | ||
1389 | mingw32-libtasn1 \ | ||
1390 | mingw32-nettle \ | ||
1391 | mingw32-pixman \ | ||
1392 | @@ -XXX,XX +XXX,XX @@ ENV PACKAGES \ | ||
1393 | mingw64-gtk3 \ | ||
1394 | mingw64-libjpeg-turbo \ | ||
1395 | mingw64-libpng \ | ||
1396 | - mingw64-libssh2 \ | ||
1397 | mingw64-libtasn1 \ | ||
1398 | mingw64-nettle \ | ||
1399 | mingw64-pixman \ | ||
1400 | diff --git a/tests/docker/dockerfiles/ubuntu.docker b/tests/docker/dockerfiles/ubuntu.docker | ||
1401 | index XXXXXXX..XXXXXXX 100644 | ||
1402 | --- a/tests/docker/dockerfiles/ubuntu.docker | ||
1403 | +++ b/tests/docker/dockerfiles/ubuntu.docker | ||
1404 | @@ -XXX,XX +XXX,XX @@ ENV PACKAGES flex bison \ | ||
1405 | libsnappy-dev \ | ||
1406 | libspice-protocol-dev \ | ||
1407 | libspice-server-dev \ | ||
1408 | - libssh2-1-dev \ | ||
1409 | + libssh-dev \ | ||
1410 | libusb-1.0-0-dev \ | ||
1411 | libusbredirhost-dev \ | ||
1412 | libvdeplug-dev \ | ||
1413 | diff --git a/tests/docker/dockerfiles/ubuntu1804.docker b/tests/docker/dockerfiles/ubuntu1804.docker | ||
1414 | index XXXXXXX..XXXXXXX 100644 | ||
1415 | --- a/tests/docker/dockerfiles/ubuntu1804.docker | ||
1416 | +++ b/tests/docker/dockerfiles/ubuntu1804.docker | ||
1417 | @@ -XXX,XX +XXX,XX @@ ENV PACKAGES flex bison \ | ||
1418 | libsnappy-dev \ | ||
1419 | libspice-protocol-dev \ | ||
1420 | libspice-server-dev \ | ||
1421 | - libssh2-1-dev \ | ||
1422 | + libssh-dev \ | ||
1423 | libusb-1.0-0-dev \ | ||
1424 | libusbredirhost-dev \ | ||
1425 | libvdeplug-dev \ | ||
1426 | diff --git a/tests/qemu-iotests/207 b/tests/qemu-iotests/207 | ||
1427 | index XXXXXXX..XXXXXXX 100755 | ||
1428 | --- a/tests/qemu-iotests/207 | ||
1429 | +++ b/tests/qemu-iotests/207 | ||
1430 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.img') as disk_path, \ | ||
1431 | |||
1432 | iotests.img_info_log(remote_path) | ||
1433 | |||
1434 | - md5_key = subprocess.check_output( | ||
1435 | - 'ssh-keyscan -t rsa 127.0.0.1 2>/dev/null | grep -v "\\^#" | ' + | ||
1436 | - 'cut -d" " -f3 | base64 -d | md5sum -b | cut -d" " -f1', | ||
1437 | - shell=True).rstrip().decode('ascii') | ||
1438 | + keys = subprocess.check_output( | ||
1439 | + 'ssh-keyscan 127.0.0.1 2>/dev/null | grep -v "\\^#" | ' + | ||
1440 | + 'cut -d" " -f3', | ||
1441 | + shell=True).rstrip().decode('ascii').split('\n') | ||
1442 | + | ||
1443 | + # Mappings of base64 representations to digests | ||
1444 | + md5_keys = {} | ||
1445 | + sha1_keys = {} | ||
1446 | + | ||
1447 | + for key in keys: | ||
1448 | + md5_keys[key] = subprocess.check_output( | ||
1449 | + 'echo %s | base64 -d | md5sum -b | cut -d" " -f1' % key, | ||
1450 | + shell=True).rstrip().decode('ascii') | ||
1451 | + | ||
1452 | + sha1_keys[key] = subprocess.check_output( | ||
1453 | + 'echo %s | base64 -d | sha1sum -b | cut -d" " -f1' % key, | ||
1454 | + shell=True).rstrip().decode('ascii') | ||
1455 | |||
1456 | vm.launch() | ||
1457 | + | ||
1458 | + # Find correct key first | ||
1459 | + matching_key = None | ||
1460 | + for key in keys: | ||
1461 | + result = vm.qmp('blockdev-add', | ||
1462 | + driver='ssh', node_name='node0', path=disk_path, | ||
1463 | + server={ | ||
1464 | + 'host': '127.0.0.1', | ||
1465 | + 'port': '22', | ||
1466 | + }, host_key_check={ | ||
1467 | + 'mode': 'hash', | ||
1468 | + 'type': 'md5', | ||
1469 | + 'hash': md5_keys[key], | ||
1470 | + }) | ||
1471 | + | ||
1472 | + if 'error' not in result: | ||
1473 | + vm.qmp('blockdev-del', node_name='node0') | ||
1474 | + matching_key = key | ||
1475 | + break | ||
1476 | + | ||
1477 | + if matching_key is None: | ||
1478 | + vm.shutdown() | ||
1479 | + iotests.notrun('Did not find a key that fits 127.0.0.1') | ||
1480 | + | ||
1481 | blockdev_create(vm, { 'driver': 'ssh', | ||
1482 | 'location': { | ||
1483 | 'path': disk_path, | ||
1484 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.img') as disk_path, \ | ||
1485 | 'host-key-check': { | ||
1486 | 'mode': 'hash', | ||
1487 | 'type': 'md5', | ||
1488 | - 'hash': md5_key, | ||
1489 | + 'hash': md5_keys[matching_key], | ||
1490 | } | ||
1491 | }, | ||
1492 | 'size': 8388608 }) | ||
1493 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.img') as disk_path, \ | ||
1494 | |||
1495 | iotests.img_info_log(remote_path) | ||
1496 | |||
1497 | - sha1_key = subprocess.check_output( | ||
1498 | - 'ssh-keyscan -t rsa 127.0.0.1 2>/dev/null | grep -v "\\^#" | ' + | ||
1499 | - 'cut -d" " -f3 | base64 -d | sha1sum -b | cut -d" " -f1', | ||
1500 | - shell=True).rstrip().decode('ascii') | ||
109 | - | 1501 | - |
110 | - amount = bdrv_write_threshold_exceeded(bs, req); | 1502 | vm.launch() |
111 | - if (amount > 0) { | 1503 | blockdev_create(vm, { 'driver': 'ssh', |
112 | - qapi_event_send_block_write_threshold( | 1504 | 'location': { |
113 | - bs->node_name, | 1505 | @@ -XXX,XX +XXX,XX @@ with iotests.FilePath('t.img') as disk_path, \ |
114 | - amount, | 1506 | 'host-key-check': { |
115 | - bs->write_threshold_offset); | 1507 | 'mode': 'hash', |
116 | - | 1508 | 'type': 'sha1', |
117 | - /* autodisable to avoid flooding the monitor */ | 1509 | - 'hash': sha1_key, |
118 | - write_threshold_disable(bs); | 1510 | + 'hash': sha1_keys[matching_key], |
119 | - } | 1511 | } |
120 | - | 1512 | }, |
121 | - return 0; /* should always let other notifiers run */ | 1513 | 'size': 4194304 }) |
122 | -} | 1514 | diff --git a/tests/qemu-iotests/207.out b/tests/qemu-iotests/207.out |
123 | - | 1515 | index XXXXXXX..XXXXXXX 100644 |
124 | -static void write_threshold_register_notifier(BlockDriverState *bs) | 1516 | --- a/tests/qemu-iotests/207.out |
125 | -{ | 1517 | +++ b/tests/qemu-iotests/207.out |
126 | - bs->write_threshold_notifier.notify = before_write_notify; | 1518 | @@ -XXX,XX +XXX,XX @@ virtual size: 4 MiB (4194304 bytes) |
127 | - bdrv_add_before_write_notifier(bs, &bs->write_threshold_notifier); | 1519 | |
128 | -} | 1520 | {"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "ssh", "location": {"host-key-check": {"mode": "none"}, "path": "/this/is/not/an/existing/path", "server": {"host": "127.0.0.1", "port": "22"}}, "size": 4194304}}} |
129 | - | 1521 | {"return": {}} |
130 | -static void write_threshold_update(BlockDriverState *bs, | 1522 | -Job failed: failed to open remote file '/this/is/not/an/existing/path': Failed opening remote file (libssh2 error code: -31) |
131 | - int64_t threshold_bytes) | 1523 | +Job failed: failed to open remote file '/this/is/not/an/existing/path': SFTP server: No such file (libssh error code: 1, sftp error code: 2) |
132 | -{ | 1524 | {"execute": "job-dismiss", "arguments": {"id": "job0"}} |
133 | - bs->write_threshold_offset = threshold_bytes; | 1525 | {"return": {}} |
134 | -} | 1526 | |
135 | - | ||
136 | void bdrv_write_threshold_set(BlockDriverState *bs, uint64_t threshold_bytes) | ||
137 | { | ||
138 | - if (bdrv_write_threshold_is_set(bs)) { | ||
139 | - if (threshold_bytes > 0) { | ||
140 | - write_threshold_update(bs, threshold_bytes); | ||
141 | - } else { | ||
142 | - write_threshold_disable(bs); | ||
143 | - } | ||
144 | - } else { | ||
145 | - if (threshold_bytes > 0) { | ||
146 | - /* avoid multiple registration */ | ||
147 | - write_threshold_register_notifier(bs); | ||
148 | - write_threshold_update(bs, threshold_bytes); | ||
149 | - } | ||
150 | - /* discard bogus disable request */ | ||
151 | - } | ||
152 | + bs->write_threshold_offset = threshold_bytes; | ||
153 | } | ||
154 | |||
155 | void qmp_block_set_write_threshold(const char *node_name, | ||
156 | @@ -XXX,XX +XXX,XX @@ void qmp_block_set_write_threshold(const char *node_name, | ||
157 | |||
158 | aio_context_release(aio_context); | ||
159 | } | ||
160 | + | ||
161 | +void bdrv_write_threshold_check_write(BlockDriverState *bs, int64_t offset, | ||
162 | + int64_t bytes) | ||
163 | +{ | ||
164 | + int64_t end = offset + bytes; | ||
165 | + uint64_t wtr = bs->write_threshold_offset; | ||
166 | + | ||
167 | + if (wtr > 0 && end > wtr) { | ||
168 | + qapi_event_send_block_write_threshold(bs->node_name, end - wtr, wtr); | ||
169 | + | ||
170 | + /* autodisable to avoid flooding the monitor */ | ||
171 | + bdrv_write_threshold_set(bs, 0); | ||
172 | + } | ||
173 | +} | ||
174 | -- | 1527 | -- |
175 | 2.31.1 | 1528 | 2.21.0 |
176 | 1529 | ||
177 | 1530 | diff view generated by jsdifflib |
1 | From: Emanuele Giuseppe Esposito <eesposit@redhat.com> | 1 | Tests should place their files into the test directory. This includes |
---|---|---|---|
2 | Unix sockets. 205 currently fails to do so, which prevents it from | ||
3 | being run concurrently. | ||
2 | 4 | ||
3 | pylint 2.8 introduces consider-using-with error, suggesting | 5 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
4 | to use the 'with' block statement when possible. | 6 | Message-id: 20190618210238.9524-1-mreitz@redhat.com |
5 | 7 | Reviewed-by: Eric Blake <eblake@redhat.com> | |
6 | Modify all subprocess.Popen call to use the 'with' statement, | ||
7 | except the one in __init__ of QemuIoInteractive class, since | ||
8 | it is assigned to a class field and used in other methods. | ||
9 | |||
10 | Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> | ||
11 | Message-Id: <20210510190449.65948-1-eesposit@redhat.com> | ||
12 | [mreitz: Disable bad-option-value warning in the iotests' pylintrc, so | ||
13 | that disabling consider-using-with in QemuIoInteractive will | ||
14 | not produce a warning in pre-2.8 pylint versions] | ||
15 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 8 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
16 | --- | 9 | --- |
17 | tests/qemu-iotests/iotests.py | 65 ++++++++++++++++---------------- | 10 | tests/qemu-iotests/205 | 2 +- |
18 | tests/qemu-iotests/pylintrc | 3 ++ | 11 | 1 file changed, 1 insertion(+), 1 deletion(-) |
19 | tests/qemu-iotests/testrunner.py | 22 +++++------ | ||
20 | 3 files changed, 47 insertions(+), 43 deletions(-) | ||
21 | 12 | ||
22 | diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py | 13 | diff --git a/tests/qemu-iotests/205 b/tests/qemu-iotests/205 |
23 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100755 |
24 | --- a/tests/qemu-iotests/iotests.py | 15 | --- a/tests/qemu-iotests/205 |
25 | +++ b/tests/qemu-iotests/iotests.py | 16 | +++ b/tests/qemu-iotests/205 |
26 | @@ -XXX,XX +XXX,XX @@ def qemu_tool_pipe_and_status(tool: str, args: Sequence[str], | 17 | @@ -XXX,XX +XXX,XX @@ import iotests |
27 | Run a tool and return both its output and its exit code | 18 | import time |
28 | """ | 19 | from iotests import qemu_img_create, qemu_io, filter_qemu_io, QemuIoInteractive |
29 | stderr = subprocess.STDOUT if connect_stderr else None | 20 | |
30 | - subp = subprocess.Popen(args, | 21 | -nbd_sock = 'nbd_sock' |
31 | - stdout=subprocess.PIPE, | 22 | +nbd_sock = os.path.join(iotests.test_dir, 'nbd_sock') |
32 | - stderr=stderr, | 23 | nbd_uri = 'nbd+unix:///exp?socket=' + nbd_sock |
33 | - universal_newlines=True) | 24 | disk = os.path.join(iotests.test_dir, 'disk') |
34 | - output = subp.communicate()[0] | ||
35 | - if subp.returncode < 0: | ||
36 | - cmd = ' '.join(args) | ||
37 | - sys.stderr.write(f'{tool} received signal {-subp.returncode}: {cmd}\n') | ||
38 | - return (output, subp.returncode) | ||
39 | + with subprocess.Popen(args, stdout=subprocess.PIPE, | ||
40 | + stderr=stderr, universal_newlines=True) as subp: | ||
41 | + output = subp.communicate()[0] | ||
42 | + if subp.returncode < 0: | ||
43 | + cmd = ' '.join(args) | ||
44 | + sys.stderr.write(f'{tool} received signal \ | ||
45 | + {-subp.returncode}: {cmd}\n') | ||
46 | + return (output, subp.returncode) | ||
47 | |||
48 | def qemu_img_pipe_and_status(*args: str) -> Tuple[str, int]: | ||
49 | """ | ||
50 | @@ -XXX,XX +XXX,XX @@ def qemu_io_silent_check(*args): | ||
51 | class QemuIoInteractive: | ||
52 | def __init__(self, *args): | ||
53 | self.args = qemu_io_args_no_fmt + list(args) | ||
54 | + # We need to keep the Popen objext around, and not | ||
55 | + # close it immediately. Therefore, disable the pylint check: | ||
56 | + # pylint: disable=consider-using-with | ||
57 | self._p = subprocess.Popen(self.args, stdin=subprocess.PIPE, | ||
58 | stdout=subprocess.PIPE, | ||
59 | stderr=subprocess.STDOUT, | ||
60 | @@ -XXX,XX +XXX,XX @@ def qemu_nbd_popen(*args): | ||
61 | cmd.extend(args) | ||
62 | |||
63 | log('Start NBD server') | ||
64 | - p = subprocess.Popen(cmd) | ||
65 | - try: | ||
66 | - while not os.path.exists(pid_file): | ||
67 | - if p.poll() is not None: | ||
68 | - raise RuntimeError( | ||
69 | - "qemu-nbd terminated with exit code {}: {}" | ||
70 | - .format(p.returncode, ' '.join(cmd))) | ||
71 | - | ||
72 | - time.sleep(0.01) | ||
73 | - yield | ||
74 | - finally: | ||
75 | - if os.path.exists(pid_file): | ||
76 | - os.remove(pid_file) | ||
77 | - log('Kill NBD server') | ||
78 | - p.kill() | ||
79 | - p.wait() | ||
80 | + with subprocess.Popen(cmd) as p: | ||
81 | + try: | ||
82 | + while not os.path.exists(pid_file): | ||
83 | + if p.poll() is not None: | ||
84 | + raise RuntimeError( | ||
85 | + "qemu-nbd terminated with exit code {}: {}" | ||
86 | + .format(p.returncode, ' '.join(cmd))) | ||
87 | + | ||
88 | + time.sleep(0.01) | ||
89 | + yield | ||
90 | + finally: | ||
91 | + if os.path.exists(pid_file): | ||
92 | + os.remove(pid_file) | ||
93 | + log('Kill NBD server') | ||
94 | + p.kill() | ||
95 | + p.wait() | ||
96 | |||
97 | def compare_images(img1, img2, fmt1=imgfmt, fmt2=imgfmt): | ||
98 | '''Return True if two image files are identical''' | ||
99 | @@ -XXX,XX +XXX,XX @@ def compare_images(img1, img2, fmt1=imgfmt, fmt2=imgfmt): | ||
100 | |||
101 | def create_image(name, size): | ||
102 | '''Create a fully-allocated raw image with sector markers''' | ||
103 | - file = open(name, 'wb') | ||
104 | - i = 0 | ||
105 | - while i < size: | ||
106 | - sector = struct.pack('>l504xl', i // 512, i // 512) | ||
107 | - file.write(sector) | ||
108 | - i = i + 512 | ||
109 | - file.close() | ||
110 | + with open(name, 'wb') as file: | ||
111 | + i = 0 | ||
112 | + while i < size: | ||
113 | + sector = struct.pack('>l504xl', i // 512, i // 512) | ||
114 | + file.write(sector) | ||
115 | + i = i + 512 | ||
116 | |||
117 | def image_size(img): | ||
118 | '''Return image's virtual size''' | ||
119 | diff --git a/tests/qemu-iotests/pylintrc b/tests/qemu-iotests/pylintrc | ||
120 | index XXXXXXX..XXXXXXX 100644 | ||
121 | --- a/tests/qemu-iotests/pylintrc | ||
122 | +++ b/tests/qemu-iotests/pylintrc | ||
123 | @@ -XXX,XX +XXX,XX @@ disable=invalid-name, | ||
124 | too-many-public-methods, | ||
125 | # pylint warns about Optional[] etc. as unsubscriptable in 3.9 | ||
126 | unsubscriptable-object, | ||
127 | + # Sometimes we need to disable a newly introduced pylint warning. | ||
128 | + # Doing so should not produce a warning in older versions of pylint. | ||
129 | + bad-option-value, | ||
130 | # These are temporary, and should be removed: | ||
131 | missing-docstring, | ||
132 | too-many-return-statements, | ||
133 | diff --git a/tests/qemu-iotests/testrunner.py b/tests/qemu-iotests/testrunner.py | ||
134 | index XXXXXXX..XXXXXXX 100644 | ||
135 | --- a/tests/qemu-iotests/testrunner.py | ||
136 | +++ b/tests/qemu-iotests/testrunner.py | ||
137 | @@ -XXX,XX +XXX,XX @@ def do_run_test(self, test: str) -> TestResult: | ||
138 | |||
139 | t0 = time.time() | ||
140 | with f_bad.open('w', encoding="utf-8") as f: | ||
141 | - proc = subprocess.Popen(args, cwd=str(f_test.parent), env=env, | ||
142 | - stdout=f, stderr=subprocess.STDOUT) | ||
143 | - try: | ||
144 | - proc.wait() | ||
145 | - except KeyboardInterrupt: | ||
146 | - proc.terminate() | ||
147 | - proc.wait() | ||
148 | - return TestResult(status='not run', | ||
149 | - description='Interrupted by user', | ||
150 | - interrupted=True) | ||
151 | - ret = proc.returncode | ||
152 | + with subprocess.Popen(args, cwd=str(f_test.parent), env=env, | ||
153 | + stdout=f, stderr=subprocess.STDOUT) as proc: | ||
154 | + try: | ||
155 | + proc.wait() | ||
156 | + except KeyboardInterrupt: | ||
157 | + proc.terminate() | ||
158 | + proc.wait() | ||
159 | + return TestResult(status='not run', | ||
160 | + description='Interrupted by user', | ||
161 | + interrupted=True) | ||
162 | + ret = proc.returncode | ||
163 | |||
164 | elapsed = round(time.time() - t0, 1) | ||
165 | 25 | ||
166 | -- | 26 | -- |
167 | 2.31.1 | 27 | 2.21.0 |
168 | 28 | ||
169 | 29 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
2 | 1 | ||
3 | They are unused now. | ||
4 | |||
5 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
6 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
7 | Message-Id: <20210506090621.11848-3-vsementsov@virtuozzo.com> | ||
8 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
9 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
10 | --- | ||
11 | include/block/block_int.h | 12 ------------ | ||
12 | block.c | 1 - | ||
13 | block/io.c | 6 ------ | ||
14 | 3 files changed, 19 deletions(-) | ||
15 | |||
16 | diff --git a/include/block/block_int.h b/include/block/block_int.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/include/block/block_int.h | ||
19 | +++ b/include/block/block_int.h | ||
20 | @@ -XXX,XX +XXX,XX @@ struct BlockDriverState { | ||
21 | */ | ||
22 | int64_t total_sectors; | ||
23 | |||
24 | - /* Callback before write request is processed */ | ||
25 | - NotifierWithReturnList before_write_notifiers; | ||
26 | - | ||
27 | /* threshold limit for writes, in bytes. "High water mark". */ | ||
28 | uint64_t write_threshold_offset; | ||
29 | |||
30 | @@ -XXX,XX +XXX,XX @@ void bdrv_parse_filename_strip_prefix(const char *filename, const char *prefix, | ||
31 | bool bdrv_backing_overridden(BlockDriverState *bs); | ||
32 | |||
33 | |||
34 | -/** | ||
35 | - * bdrv_add_before_write_notifier: | ||
36 | - * | ||
37 | - * Register a callback that is invoked before write requests are processed but | ||
38 | - * after any throttling or waiting for overlapping requests. | ||
39 | - */ | ||
40 | -void bdrv_add_before_write_notifier(BlockDriverState *bs, | ||
41 | - NotifierWithReturn *notifier); | ||
42 | - | ||
43 | /** | ||
44 | * bdrv_add_aio_context_notifier: | ||
45 | * | ||
46 | diff --git a/block.c b/block.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/block.c | ||
49 | +++ b/block.c | ||
50 | @@ -XXX,XX +XXX,XX @@ BlockDriverState *bdrv_new(void) | ||
51 | for (i = 0; i < BLOCK_OP_TYPE_MAX; i++) { | ||
52 | QLIST_INIT(&bs->op_blockers[i]); | ||
53 | } | ||
54 | - notifier_with_return_list_init(&bs->before_write_notifiers); | ||
55 | qemu_co_mutex_init(&bs->reqs_lock); | ||
56 | qemu_mutex_init(&bs->dirty_bitmap_mutex); | ||
57 | bs->refcnt = 1; | ||
58 | diff --git a/block/io.c b/block/io.c | ||
59 | index XXXXXXX..XXXXXXX 100644 | ||
60 | --- a/block/io.c | ||
61 | +++ b/block/io.c | ||
62 | @@ -XXX,XX +XXX,XX @@ bool bdrv_qiov_is_aligned(BlockDriverState *bs, QEMUIOVector *qiov) | ||
63 | return true; | ||
64 | } | ||
65 | |||
66 | -void bdrv_add_before_write_notifier(BlockDriverState *bs, | ||
67 | - NotifierWithReturn *notifier) | ||
68 | -{ | ||
69 | - notifier_with_return_list_add(&bs->before_write_notifiers, notifier); | ||
70 | -} | ||
71 | - | ||
72 | void bdrv_io_plug(BlockDriverState *bs) | ||
73 | { | ||
74 | BdrvChild *child; | ||
75 | -- | ||
76 | 2.31.1 | ||
77 | |||
78 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
2 | 1 | ||
3 | These tests use bdrv_write_threshold_exceeded() API, which is used only | ||
4 | for test (since pre-previous commit). Better is testing real API, which | ||
5 | is used in block.c as well. | ||
6 | |||
7 | So, let's call bdrv_write_threshold_check_write(), and check is | ||
8 | bs->write_threshold_offset cleared or not (it's cleared iff threshold | ||
9 | triggered). | ||
10 | |||
11 | Also we get rid of BdrvTrackedRequest use here. Note, that paranoiac | ||
12 | bdrv_check_request() calls were added in 8b1170012b1 to protect | ||
13 | BdrvTrackedRequest. Drop them now. | ||
14 | |||
15 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
16 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
17 | Message-Id: <20210506090621.11848-4-vsementsov@virtuozzo.com> | ||
18 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
19 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
20 | --- | ||
21 | tests/unit/test-write-threshold.c | 22 ++++------------------ | ||
22 | 1 file changed, 4 insertions(+), 18 deletions(-) | ||
23 | |||
24 | diff --git a/tests/unit/test-write-threshold.c b/tests/unit/test-write-threshold.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/tests/unit/test-write-threshold.c | ||
27 | +++ b/tests/unit/test-write-threshold.c | ||
28 | @@ -XXX,XX +XXX,XX @@ static void test_threshold_multi_set_get(void) | ||
29 | |||
30 | static void test_threshold_not_trigger(void) | ||
31 | { | ||
32 | - uint64_t amount = 0; | ||
33 | uint64_t threshold = 4 * 1024 * 1024; | ||
34 | BlockDriverState bs; | ||
35 | - BdrvTrackedRequest req; | ||
36 | |||
37 | memset(&bs, 0, sizeof(bs)); | ||
38 | - memset(&req, 0, sizeof(req)); | ||
39 | - req.offset = 1024; | ||
40 | - req.bytes = 1024; | ||
41 | - | ||
42 | - bdrv_check_request(req.offset, req.bytes, &error_abort); | ||
43 | |||
44 | bdrv_write_threshold_set(&bs, threshold); | ||
45 | - amount = bdrv_write_threshold_exceeded(&bs, &req); | ||
46 | - g_assert_cmpuint(amount, ==, 0); | ||
47 | + bdrv_write_threshold_check_write(&bs, 1024, 1024); | ||
48 | + g_assert_cmpuint(bdrv_write_threshold_get(&bs), ==, threshold); | ||
49 | } | ||
50 | |||
51 | |||
52 | static void test_threshold_trigger(void) | ||
53 | { | ||
54 | - uint64_t amount = 0; | ||
55 | uint64_t threshold = 4 * 1024 * 1024; | ||
56 | BlockDriverState bs; | ||
57 | - BdrvTrackedRequest req; | ||
58 | |||
59 | memset(&bs, 0, sizeof(bs)); | ||
60 | - memset(&req, 0, sizeof(req)); | ||
61 | - req.offset = (4 * 1024 * 1024) - 1024; | ||
62 | - req.bytes = 2 * 1024; | ||
63 | - | ||
64 | - bdrv_check_request(req.offset, req.bytes, &error_abort); | ||
65 | |||
66 | bdrv_write_threshold_set(&bs, threshold); | ||
67 | - amount = bdrv_write_threshold_exceeded(&bs, &req); | ||
68 | - g_assert_cmpuint(amount, >=, 1024); | ||
69 | + bdrv_write_threshold_check_write(&bs, threshold - 1024, 2 * 1024); | ||
70 | + g_assert_cmpuint(bdrv_write_threshold_get(&bs), ==, 0); | ||
71 | } | ||
72 | |||
73 | typedef struct TestStruct { | ||
74 | -- | ||
75 | 2.31.1 | ||
76 | |||
77 | diff view generated by jsdifflib |