1 | The following changes since commit 0ab4537f08e09b13788db67efd760592fb7db769: | 1 | The following changes since commit 23919ddfd56135cad3cb468a8f54d5a595f024f4: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/stefanberger/tags/pull-tpm-2018-03-07-1' into staging (2018-03-08 12:56:39 +0000) | 3 | Merge remote-tracking branch 'remotes/aperard/tags/pull-xen-20190827' into staging (2019-08-27 15:52:36 +0100) |
4 | 4 | ||
5 | are available in the Git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | git://github.com/stefanha/qemu.git tags/block-pull-request | 7 | https://github.com/XanClic/qemu.git tags/pull-block-2019-08-27 |
8 | 8 | ||
9 | for you to fetch changes up to 4486e89c219c0d1b9bd8dfa0b1dd5b0d51ff2268: | 9 | for you to fetch changes up to bb043c056cffcc2f3ce88bfdaf2e76e455c09e2c: |
10 | 10 | ||
11 | vl: introduce vm_shutdown() (2018-03-08 17:38:51 +0000) | 11 | iotests: Unify cache mode quoting (2019-08-27 19:48:44 +0200) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Block patches: | ||
15 | - qemu-io now accepts a file to read a write pattern from | ||
16 | - Ensure that raw files have their first block allocated so we can probe | ||
17 | the O_DIRECT alignment if necessary | ||
18 | - Various fixes | ||
14 | 19 | ||
15 | ---------------------------------------------------------------- | 20 | ---------------------------------------------------------------- |
21 | Denis Plotnikov (1): | ||
22 | qemu-io: add pattern file for write command | ||
16 | 23 | ||
17 | Deepa Srinivasan (1): | 24 | Max Reitz (7): |
18 | block: Fix qemu crash when using scsi-block | 25 | iotests: Fix _filter_img_create() |
26 | vmdk: Use bdrv_dirname() for relative extent paths | ||
27 | iotests: Keep testing broken relative extent paths | ||
28 | vmdk: Reject invalid compressed writes | ||
29 | iotests: Disable broken streamOptimized tests | ||
30 | iotests: Disable 110 for vmdk.twoGbMaxExtentSparse | ||
31 | iotests: Disable 126 for flat vmdk subformats | ||
19 | 32 | ||
20 | Fam Zheng (1): | 33 | Nir Soffer (3): |
21 | README: Fix typo 'git-publish' | 34 | block: posix: Always allocate the first block |
35 | iotests: Test allocate_first_block() with O_DIRECT | ||
36 | iotests: Unify cache mode quoting | ||
22 | 37 | ||
23 | Sergio Lopez (1): | 38 | Stefan Hajnoczi (1): |
24 | virtio-blk: dataplane: Don't batch notifications if EVENT_IDX is | 39 | file-posix: fix request_alignment typo |
25 | present | ||
26 | 40 | ||
27 | Stefan Hajnoczi (4): | 41 | Thomas Huth (2): |
28 | block: add aio_wait_bh_oneshot() | 42 | iotests: Check for enabled drivers before testing them |
29 | virtio-blk: fix race between .ioeventfd_stop() and vq handler | 43 | tests/check-block: Skip iotests when sanitizers are enabled |
30 | virtio-scsi: fix race between .ioeventfd_stop() and vq handler | ||
31 | vl: introduce vm_shutdown() | ||
32 | 44 | ||
33 | include/block/aio-wait.h | 13 +++++++++++ | 45 | Vladimir Sementsov-Ogievskiy (1): |
34 | include/sysemu/iothread.h | 1 - | 46 | block: fix permission update in bdrv_replace_node |
35 | include/sysemu/sysemu.h | 1 + | 47 | |
36 | block/block-backend.c | 51 ++++++++++++++++++++--------------------- | 48 | block.c | 5 +- |
37 | cpus.c | 16 ++++++++++--- | 49 | block/file-posix.c | 53 +++++++++- |
38 | hw/block/dataplane/virtio-blk.c | 39 +++++++++++++++++++++++-------- | 50 | block/vmdk.c | 64 ++++++++---- |
39 | hw/scsi/virtio-scsi-dataplane.c | 9 ++++---- | 51 | qemu-io-cmds.c | 99 +++++++++++++++++-- |
40 | iothread.c | 31 ------------------------- | 52 | tests/check-block.sh | 5 + |
41 | util/aio-wait.c | 31 +++++++++++++++++++++++++ | 53 | tests/qemu-iotests/002 | 1 + |
42 | vl.c | 13 +++-------- | 54 | tests/qemu-iotests/003 | 1 + |
43 | README | 2 +- | 55 | tests/qemu-iotests/005 | 3 +- |
44 | 11 files changed, 122 insertions(+), 85 deletions(-) | 56 | tests/qemu-iotests/009 | 1 + |
57 | tests/qemu-iotests/010 | 1 + | ||
58 | tests/qemu-iotests/011 | 1 + | ||
59 | tests/qemu-iotests/017 | 3 +- | ||
60 | tests/qemu-iotests/018 | 3 +- | ||
61 | tests/qemu-iotests/019 | 3 +- | ||
62 | tests/qemu-iotests/020 | 3 +- | ||
63 | tests/qemu-iotests/026 | 4 +- | ||
64 | tests/qemu-iotests/027 | 1 + | ||
65 | tests/qemu-iotests/032 | 1 + | ||
66 | tests/qemu-iotests/033 | 1 + | ||
67 | tests/qemu-iotests/034 | 3 +- | ||
68 | tests/qemu-iotests/037 | 3 +- | ||
69 | tests/qemu-iotests/039 | 4 +- | ||
70 | tests/qemu-iotests/052 | 2 +- | ||
71 | tests/qemu-iotests/059 | 34 ++++++- | ||
72 | tests/qemu-iotests/059.out | 26 +++-- | ||
73 | tests/qemu-iotests/063 | 3 +- | ||
74 | tests/qemu-iotests/071 | 1 + | ||
75 | tests/qemu-iotests/072 | 1 + | ||
76 | tests/qemu-iotests/081 | 4 +- | ||
77 | tests/qemu-iotests/091 | 4 +- | ||
78 | tests/qemu-iotests/099 | 1 + | ||
79 | tests/qemu-iotests/105 | 3 +- | ||
80 | tests/qemu-iotests/110 | 3 +- | ||
81 | tests/qemu-iotests/120 | 1 + | ||
82 | tests/qemu-iotests/126 | 2 + | ||
83 | tests/qemu-iotests/{150.out => 150.out.qcow2} | 0 | ||
84 | tests/qemu-iotests/150.out.raw | 12 +++ | ||
85 | tests/qemu-iotests/162 | 4 +- | ||
86 | tests/qemu-iotests/175 | 47 +++++++-- | ||
87 | tests/qemu-iotests/175.out | 16 ++- | ||
88 | tests/qemu-iotests/178.out.qcow2 | 4 +- | ||
89 | tests/qemu-iotests/184 | 1 + | ||
90 | tests/qemu-iotests/186 | 1 + | ||
91 | tests/qemu-iotests/197 | 1 + | ||
92 | tests/qemu-iotests/215 | 1 + | ||
93 | tests/qemu-iotests/221.out | 12 ++- | ||
94 | tests/qemu-iotests/251 | 1 + | ||
95 | tests/qemu-iotests/253.out | 12 ++- | ||
96 | tests/qemu-iotests/common.filter | 4 +- | ||
97 | tests/qemu-iotests/common.rc | 14 +++ | ||
98 | 50 files changed, 391 insertions(+), 87 deletions(-) | ||
99 | rename tests/qemu-iotests/{150.out => 150.out.qcow2} (100%) | ||
100 | create mode 100644 tests/qemu-iotests/150.out.raw | ||
45 | 101 | ||
46 | -- | 102 | -- |
47 | 2.14.3 | 103 | 2.21.0 |
48 | 104 | ||
49 | 105 | diff view generated by jsdifflib |
1 | From: Sergio Lopez <slp@redhat.com> | 1 | From: Denis Plotnikov <dplotnikov@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | Commit 5b2ffbe4d99843fd8305c573a100047a8c962327 ("virtio-blk: dataplane: | 3 | The patch allows to provide a pattern file for write |
4 | notify guest as a batch") deferred guest notification to a BH in order | 4 | command. There was no similar ability before. |
5 | batch notifications, with purpose of avoiding flooding the guest with | ||
6 | interruptions. | ||
7 | 5 | ||
8 | This optimization came with a cost. The average latency perceived in the | 6 | Signed-off-by: Denis Plotnikov <dplotnikov@virtuozzo.com> |
9 | guest is increased by a few microseconds, but also when multiple IO | 7 | Message-id: 20190820164616.4072-1-dplotnikov@virtuozzo.com |
10 | operations finish at the same time, the guest won't be notified until | 8 | Reviewed-by: Eric Blake <eblake@redhat.com> |
11 | all completions from each operation has been run. On the contrary, | 9 | [mreitz: Keep optstring in alphabetical order] |
12 | virtio-scsi issues the notification at the end of each completion. | 10 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
11 | --- | ||
12 | qemu-io-cmds.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++--- | ||
13 | 1 file changed, 93 insertions(+), 6 deletions(-) | ||
13 | 14 | ||
14 | On the other hand, nowadays we have the EVENT_IDX feature that allows a | 15 | diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c |
15 | better coordination between QEMU and the Guest OS to avoid sending | ||
16 | unnecessary interruptions. | ||
17 | |||
18 | With this change, virtio-blk/dataplane only batches notifications if the | ||
19 | EVENT_IDX feature is not present. | ||
20 | |||
21 | Some numbers obtained with fio (ioengine=sync, iodepth=1, direct=1): | ||
22 | - Test specs: | ||
23 | * fio-3.4 (ioengine=sync, iodepth=1, direct=1) | ||
24 | * qemu master | ||
25 | * virtio-blk with a dedicated iothread (default poll-max-ns) | ||
26 | * backend: null_blk nr_devices=1 irqmode=2 completion_nsec=280000 | ||
27 | * 8 vCPUs pinned to isolated physical cores | ||
28 | * Emulator and iothread also pinned to separate isolated cores | ||
29 | * variance between runs < 1% | ||
30 | |||
31 | - Not patched | ||
32 | * numjobs=1: lat_avg=327.32 irqs=29998 | ||
33 | * numjobs=4: lat_avg=337.89 irqs=29073 | ||
34 | * numjobs=8: lat_avg=342.98 irqs=28643 | ||
35 | |||
36 | - Patched: | ||
37 | * numjobs=1: lat_avg=323.92 irqs=30262 | ||
38 | * numjobs=4: lat_avg=332.65 irqs=29520 | ||
39 | * numjobs=8: lat_avg=335.54 irqs=29323 | ||
40 | |||
41 | Signed-off-by: Sergio Lopez <slp@redhat.com> | ||
42 | Message-id: 20180307114459.26636-1-slp@redhat.com | ||
43 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
44 | --- | ||
45 | hw/block/dataplane/virtio-blk.c | 15 +++++++++++++-- | ||
46 | 1 file changed, 13 insertions(+), 2 deletions(-) | ||
47 | |||
48 | diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
50 | --- a/hw/block/dataplane/virtio-blk.c | 17 | --- a/qemu-io-cmds.c |
51 | +++ b/hw/block/dataplane/virtio-blk.c | 18 | +++ b/qemu-io-cmds.c |
52 | @@ -XXX,XX +XXX,XX @@ struct VirtIOBlockDataPlane { | 19 | @@ -XXX,XX +XXX,XX @@ static void qemu_io_free(void *p) |
53 | VirtIODevice *vdev; | 20 | qemu_vfree(p); |
54 | QEMUBH *bh; /* bh for guest notification */ | ||
55 | unsigned long *batch_notify_vqs; | ||
56 | + bool batch_notifications; | ||
57 | |||
58 | /* Note that these EventNotifiers are assigned by value. This is | ||
59 | * fine as long as you do not call event_notifier_cleanup on them | ||
60 | @@ -XXX,XX +XXX,XX @@ struct VirtIOBlockDataPlane { | ||
61 | /* Raise an interrupt to signal guest, if necessary */ | ||
62 | void virtio_blk_data_plane_notify(VirtIOBlockDataPlane *s, VirtQueue *vq) | ||
63 | { | ||
64 | - set_bit(virtio_get_queue_index(vq), s->batch_notify_vqs); | ||
65 | - qemu_bh_schedule(s->bh); | ||
66 | + if (s->batch_notifications) { | ||
67 | + set_bit(virtio_get_queue_index(vq), s->batch_notify_vqs); | ||
68 | + qemu_bh_schedule(s->bh); | ||
69 | + } else { | ||
70 | + virtio_notify_irqfd(s->vdev, vq); | ||
71 | + } | ||
72 | } | 21 | } |
73 | 22 | ||
74 | static void notify_guest_bh(void *opaque) | 23 | +/* |
75 | @@ -XXX,XX +XXX,XX @@ int virtio_blk_data_plane_start(VirtIODevice *vdev) | 24 | + * qemu_io_alloc_from_file() |
76 | 25 | + * | |
77 | s->starting = true; | 26 | + * Allocates the buffer and populates it with the content of the given file |
78 | 27 | + * up to @len bytes. If the file length is less than @len, then the buffer | |
79 | + if (!virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { | 28 | + * is populated with the file content cyclically. |
80 | + s->batch_notifications = true; | 29 | + * |
81 | + } else { | 30 | + * @blk - the block backend where the buffer content is going to be written to |
82 | + s->batch_notifications = false; | 31 | + * @len - the buffer length |
32 | + * @file_name - the file to read the content from | ||
33 | + * | ||
34 | + * Returns: the buffer pointer on success | ||
35 | + * NULL on error | ||
36 | + */ | ||
37 | +static void *qemu_io_alloc_from_file(BlockBackend *blk, size_t len, | ||
38 | + const char *file_name) | ||
39 | +{ | ||
40 | + char *buf, *buf_origin; | ||
41 | + FILE *f = fopen(file_name, "r"); | ||
42 | + int pattern_len; | ||
43 | + | ||
44 | + if (!f) { | ||
45 | + perror(file_name); | ||
46 | + return NULL; | ||
83 | + } | 47 | + } |
84 | + | 48 | + |
85 | /* Set up guest notifier (irq) */ | 49 | + if (qemuio_misalign) { |
86 | r = k->set_guest_notifiers(qbus->parent, nvqs, true); | 50 | + len += MISALIGN_OFFSET; |
87 | if (r != 0) { | 51 | + } |
52 | + | ||
53 | + buf_origin = buf = blk_blockalign(blk, len); | ||
54 | + | ||
55 | + if (qemuio_misalign) { | ||
56 | + buf_origin += MISALIGN_OFFSET; | ||
57 | + buf += MISALIGN_OFFSET; | ||
58 | + len -= MISALIGN_OFFSET; | ||
59 | + } | ||
60 | + | ||
61 | + pattern_len = fread(buf_origin, 1, len, f); | ||
62 | + | ||
63 | + if (ferror(f)) { | ||
64 | + perror(file_name); | ||
65 | + goto error; | ||
66 | + } | ||
67 | + | ||
68 | + if (pattern_len == 0) { | ||
69 | + fprintf(stderr, "%s: file is empty\n", file_name); | ||
70 | + goto error; | ||
71 | + } | ||
72 | + | ||
73 | + fclose(f); | ||
74 | + | ||
75 | + if (len > pattern_len) { | ||
76 | + len -= pattern_len; | ||
77 | + buf += pattern_len; | ||
78 | + | ||
79 | + while (len > 0) { | ||
80 | + size_t len_to_copy = MIN(pattern_len, len); | ||
81 | + | ||
82 | + memcpy(buf, buf_origin, len_to_copy); | ||
83 | + | ||
84 | + len -= len_to_copy; | ||
85 | + buf += len_to_copy; | ||
86 | + } | ||
87 | + } | ||
88 | + | ||
89 | + return buf_origin; | ||
90 | + | ||
91 | +error: | ||
92 | + qemu_io_free(buf_origin); | ||
93 | + return NULL; | ||
94 | +} | ||
95 | + | ||
96 | static void dump_buffer(const void *buffer, int64_t offset, int64_t len) | ||
97 | { | ||
98 | uint64_t i; | ||
99 | @@ -XXX,XX +XXX,XX @@ static void write_help(void) | ||
100 | " -n, -- with -z, don't allow slow fallback\n" | ||
101 | " -p, -- ignored for backwards compatibility\n" | ||
102 | " -P, -- use different pattern to fill file\n" | ||
103 | +" -s, -- use a pattern file to fill the write buffer\n" | ||
104 | " -C, -- report statistics in a machine parsable format\n" | ||
105 | " -q, -- quiet mode, do not show I/O statistics\n" | ||
106 | " -u, -- with -z, allow unmapping\n" | ||
107 | @@ -XXX,XX +XXX,XX @@ static const cmdinfo_t write_cmd = { | ||
108 | .perm = BLK_PERM_WRITE, | ||
109 | .argmin = 2, | ||
110 | .argmax = -1, | ||
111 | - .args = "[-bcCfnquz] [-P pattern] off len", | ||
112 | + .args = "[-bcCfnquz] [-P pattern | -s source_file] off len", | ||
113 | .oneline = "writes a number of bytes at a specified offset", | ||
114 | .help = write_help, | ||
115 | }; | ||
116 | @@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv) | ||
117 | { | ||
118 | struct timespec t1, t2; | ||
119 | bool Cflag = false, qflag = false, bflag = false; | ||
120 | - bool Pflag = false, zflag = false, cflag = false; | ||
121 | + bool Pflag = false, zflag = false, cflag = false, sflag = false; | ||
122 | int flags = 0; | ||
123 | int c, cnt, ret; | ||
124 | char *buf = NULL; | ||
125 | @@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv) | ||
126 | /* Some compilers get confused and warn if this is not initialized. */ | ||
127 | int64_t total = 0; | ||
128 | int pattern = 0xcd; | ||
129 | + const char *file_name = NULL; | ||
130 | |||
131 | - while ((c = getopt(argc, argv, "bcCfnpP:quz")) != -1) { | ||
132 | + while ((c = getopt(argc, argv, "bcCfnpP:qs:uz")) != -1) { | ||
133 | switch (c) { | ||
134 | case 'b': | ||
135 | bflag = true; | ||
136 | @@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv) | ||
137 | case 'q': | ||
138 | qflag = true; | ||
139 | break; | ||
140 | + case 's': | ||
141 | + sflag = true; | ||
142 | + file_name = optarg; | ||
143 | + break; | ||
144 | case 'u': | ||
145 | flags |= BDRV_REQ_MAY_UNMAP; | ||
146 | break; | ||
147 | @@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv) | ||
148 | return -EINVAL; | ||
149 | } | ||
150 | |||
151 | - if (zflag && Pflag) { | ||
152 | - printf("-z and -P cannot be specified at the same time\n"); | ||
153 | + if (zflag + Pflag + sflag > 1) { | ||
154 | + printf("Only one of -z, -P, and -s " | ||
155 | + "can be specified at the same time\n"); | ||
156 | return -EINVAL; | ||
157 | } | ||
158 | |||
159 | @@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv) | ||
160 | } | ||
161 | |||
162 | if (!zflag) { | ||
163 | - buf = qemu_io_alloc(blk, count, pattern); | ||
164 | + if (sflag) { | ||
165 | + buf = qemu_io_alloc_from_file(blk, count, file_name); | ||
166 | + if (!buf) { | ||
167 | + return -EINVAL; | ||
168 | + } | ||
169 | + } else { | ||
170 | + buf = qemu_io_alloc(blk, count, pattern); | ||
171 | + } | ||
172 | } | ||
173 | |||
174 | clock_gettime(CLOCK_MONOTONIC, &t1); | ||
88 | -- | 175 | -- |
89 | 2.14.3 | 176 | 2.21.0 |
90 | 177 | ||
91 | 178 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
1 | 2 | ||
3 | It's wrong to OR shared permissions. It may lead to crash on further | ||
4 | permission updates. | ||
5 | Also, no needs to consider previously calculated permissions, as at | ||
6 | this point we already bind all new parents and bdrv_get_cumulative_perm | ||
7 | result is enough. So fix the bug by just set permissions by | ||
8 | bdrv_get_cumulative_perm result. | ||
9 | |||
10 | Bug was introduced in long ago 234ac1a9025, in 2.9. | ||
11 | |||
12 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
13 | Message-id: 20190824100740.61635-1-vsementsov@virtuozzo.com | ||
14 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
15 | --- | ||
16 | block.c | 5 ++--- | ||
17 | 1 file changed, 2 insertions(+), 3 deletions(-) | ||
18 | |||
19 | diff --git a/block.c b/block.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/block.c | ||
22 | +++ b/block.c | ||
23 | @@ -XXX,XX +XXX,XX @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to, | ||
24 | { | ||
25 | BdrvChild *c, *next; | ||
26 | GSList *list = NULL, *p; | ||
27 | - uint64_t old_perm, old_shared; | ||
28 | uint64_t perm = 0, shared = BLK_PERM_ALL; | ||
29 | int ret; | ||
30 | |||
31 | @@ -XXX,XX +XXX,XX @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to, | ||
32 | bdrv_unref(from); | ||
33 | } | ||
34 | |||
35 | - bdrv_get_cumulative_perm(to, &old_perm, &old_shared); | ||
36 | - bdrv_set_perm(to, old_perm | perm, old_shared | shared); | ||
37 | + bdrv_get_cumulative_perm(to, &perm, &shared); | ||
38 | + bdrv_set_perm(to, perm, shared); | ||
39 | |||
40 | out: | ||
41 | g_slist_free(list); | ||
42 | -- | ||
43 | 2.21.0 | ||
44 | |||
45 | diff view generated by jsdifflib |
1 | Commit 00d09fdbbae5f7864ce754913efc84c12fdf9f1a ("vl: pause vcpus before | 1 | From: Nir Soffer <nirsof@gmail.com> |
---|---|---|---|
2 | stopping iothreads") and commit dce8921b2baaf95974af8176406881872067adfa | 2 | |
3 | ("iothread: Stop threads before main() quits") tried to work around the | 3 | When creating an image with preallocation "off" or "falloc", the first |
4 | fact that emulation was still active during termination by stopping | 4 | block of the image is typically not allocated. When using Gluster |
5 | iothreads. They suffer from race conditions: | 5 | storage backed by XFS filesystem, reading this block using direct I/O |
6 | 1. virtio_scsi_handle_cmd_vq() racing with iothread_stop_all() hits the | 6 | succeeds regardless of request length, fooling alignment detection. |
7 | virtio_scsi_ctx_check() assertion failure because the BDS AioContext | 7 | |
8 | has been modified by iothread_stop_all(). | 8 | In this case we fallback to a safe value (4096) instead of the optimal |
9 | 2. Guest vq kick racing with main loop termination leaves a readable | 9 | value (512), which may lead to unneeded data copying when aligning |
10 | ioeventfd that is handled by the next aio_poll() when external | 10 | requests. Allocating the first block avoids the fallback. |
11 | clients are enabled again, resulting in unwanted emulation activity. | 11 | |
12 | 12 | Since we allocate the first block even with preallocation=off, we no | |
13 | This patch obsoletes those commits by fully disabling emulation activity | 13 | longer create images with zero disk size: |
14 | when vcpus are stopped. | 14 | |
15 | 15 | $ ./qemu-img create -f raw test.raw 1g | |
16 | Use the new vm_shutdown() function instead of pause_all_vcpus() so that | 16 | Formatting 'test.raw', fmt=raw size=1073741824 |
17 | vm change state handlers are invoked too. Virtio devices will now stop | 17 | |
18 | their ioeventfds, preventing further emulation activity after vm_stop(). | 18 | $ ls -lhs test.raw |
19 | 19 | 4.0K -rw-r--r--. 1 nsoffer nsoffer 1.0G Aug 16 23:48 test.raw | |
20 | Note that vm_stop(RUN_STATE_SHUTDOWN) cannot be used because it emits a | 20 | |
21 | QMP STOP event that may affect existing clients. | 21 | And converting the image requires additional cluster: |
22 | 22 | ||
23 | It is no longer necessary to call replay_disable_events() directly since | 23 | $ ./qemu-img measure -f raw -O qcow2 test.raw |
24 | vm_shutdown() does so already. | 24 | required size: 458752 |
25 | 25 | fully allocated size: 1074135040 | |
26 | Drop iothread_stop_all() since it is no longer used. | 26 | |
27 | 27 | When using format like vmdk with multiple files per image, we allocate | |
28 | Cc: Fam Zheng <famz@redhat.com> | 28 | one block per file: |
29 | Cc: Kevin Wolf <kwolf@redhat.com> | 29 | |
30 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 30 | $ ./qemu-img create -f vmdk -o subformat=twoGbMaxExtentFlat test.vmdk 4g |
31 | Reviewed-by: Fam Zheng <famz@redhat.com> | 31 | Formatting 'test.vmdk', fmt=vmdk size=4294967296 compat6=off hwversion=undefined subformat=twoGbMaxExtentFlat |
32 | Acked-by: Paolo Bonzini <pbonzini@redhat.com> | 32 | |
33 | Message-id: 20180307144205.20619-5-stefanha@redhat.com | 33 | $ ls -lhs test*.vmdk |
34 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 34 | 4.0K -rw-r--r--. 1 nsoffer nsoffer 2.0G Aug 27 03:23 test-f001.vmdk |
35 | 4.0K -rw-r--r--. 1 nsoffer nsoffer 2.0G Aug 27 03:23 test-f002.vmdk | ||
36 | 4.0K -rw-r--r--. 1 nsoffer nsoffer 353 Aug 27 03:23 test.vmdk | ||
37 | |||
38 | I did quick performance test for copying disks with qemu-img convert to | ||
39 | new raw target image to Gluster storage with sector size of 512 bytes: | ||
40 | |||
41 | for i in $(seq 10); do | ||
42 | rm -f dst.raw | ||
43 | sleep 10 | ||
44 | time ./qemu-img convert -f raw -O raw -t none -T none src.raw dst.raw | ||
45 | done | ||
46 | |||
47 | Here is a table comparing the total time spent: | ||
48 | |||
49 | Type Before(s) After(s) Diff(%) | ||
50 | --------------------------------------- | ||
51 | real 530.028 469.123 -11.4 | ||
52 | user 17.204 10.768 -37.4 | ||
53 | sys 17.881 7.011 -60.7 | ||
54 | |||
55 | We can see very clear improvement in CPU usage. | ||
56 | |||
57 | Signed-off-by: Nir Soffer <nsoffer@redhat.com> | ||
58 | Message-id: 20190827010528.8818-2-nsoffer@redhat.com | ||
59 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
60 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
35 | --- | 61 | --- |
36 | include/sysemu/iothread.h | 1 - | 62 | block/file-posix.c | 51 +++++++++++++++++++ |
37 | include/sysemu/sysemu.h | 1 + | 63 | tests/qemu-iotests/059.out | 2 +- |
38 | cpus.c | 16 +++++++++++++--- | 64 | tests/qemu-iotests/{150.out => 150.out.qcow2} | 0 |
39 | iothread.c | 31 ------------------------------- | 65 | tests/qemu-iotests/150.out.raw | 12 +++++ |
40 | vl.c | 13 +++---------- | 66 | tests/qemu-iotests/175 | 19 ++++--- |
41 | 5 files changed, 17 insertions(+), 45 deletions(-) | 67 | tests/qemu-iotests/175.out | 8 +-- |
42 | 68 | tests/qemu-iotests/178.out.qcow2 | 4 +- | |
43 | diff --git a/include/sysemu/iothread.h b/include/sysemu/iothread.h | 69 | tests/qemu-iotests/221.out | 12 +++-- |
44 | index XXXXXXX..XXXXXXX 100644 | 70 | tests/qemu-iotests/253.out | 12 +++-- |
45 | --- a/include/sysemu/iothread.h | 71 | 9 files changed, 99 insertions(+), 21 deletions(-) |
46 | +++ b/include/sysemu/iothread.h | 72 | rename tests/qemu-iotests/{150.out => 150.out.qcow2} (100%) |
47 | @@ -XXX,XX +XXX,XX @@ typedef struct { | 73 | create mode 100644 tests/qemu-iotests/150.out.raw |
48 | char *iothread_get_id(IOThread *iothread); | 74 | |
49 | IOThread *iothread_by_id(const char *id); | 75 | diff --git a/block/file-posix.c b/block/file-posix.c |
50 | AioContext *iothread_get_aio_context(IOThread *iothread); | 76 | index XXXXXXX..XXXXXXX 100644 |
51 | -void iothread_stop_all(void); | 77 | --- a/block/file-posix.c |
52 | GMainContext *iothread_get_g_main_context(IOThread *iothread); | 78 | +++ b/block/file-posix.c |
53 | 79 | @@ -XXX,XX +XXX,XX @@ static int handle_aiocb_discard(void *opaque) | |
54 | /* | ||
55 | diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/include/sysemu/sysemu.h | ||
58 | +++ b/include/sysemu/sysemu.h | ||
59 | @@ -XXX,XX +XXX,XX @@ void vm_start(void); | ||
60 | int vm_prepare_start(void); | ||
61 | int vm_stop(RunState state); | ||
62 | int vm_stop_force_state(RunState state); | ||
63 | +int vm_shutdown(void); | ||
64 | |||
65 | typedef enum WakeupReason { | ||
66 | /* Always keep QEMU_WAKEUP_REASON_NONE = 0 */ | ||
67 | diff --git a/cpus.c b/cpus.c | ||
68 | index XXXXXXX..XXXXXXX 100644 | ||
69 | --- a/cpus.c | ||
70 | +++ b/cpus.c | ||
71 | @@ -XXX,XX +XXX,XX @@ void cpu_synchronize_all_pre_loadvm(void) | ||
72 | } | ||
73 | } | ||
74 | |||
75 | -static int do_vm_stop(RunState state) | ||
76 | +static int do_vm_stop(RunState state, bool send_stop) | ||
77 | { | ||
78 | int ret = 0; | ||
79 | |||
80 | @@ -XXX,XX +XXX,XX @@ static int do_vm_stop(RunState state) | ||
81 | pause_all_vcpus(); | ||
82 | runstate_set(state); | ||
83 | vm_state_notify(0, state); | ||
84 | - qapi_event_send_stop(&error_abort); | ||
85 | + if (send_stop) { | ||
86 | + qapi_event_send_stop(&error_abort); | ||
87 | + } | ||
88 | } | ||
89 | |||
90 | bdrv_drain_all(); | ||
91 | @@ -XXX,XX +XXX,XX @@ static int do_vm_stop(RunState state) | ||
92 | return ret; | 80 | return ret; |
93 | } | 81 | } |
94 | 82 | ||
95 | +/* Special vm_stop() variant for terminating the process. Historically clients | 83 | +/* |
96 | + * did not expect a QMP STOP event and so we need to retain compatibility. | 84 | + * Help alignment probing by allocating the first block. |
85 | + * | ||
86 | + * When reading with direct I/O from unallocated area on Gluster backed by XFS, | ||
87 | + * reading succeeds regardless of request length. In this case we fallback to | ||
88 | + * safe alignment which is not optimal. Allocating the first block avoids this | ||
89 | + * fallback. | ||
90 | + * | ||
91 | + * fd may be opened with O_DIRECT, but we don't know the buffer alignment or | ||
92 | + * request alignment, so we use safe values. | ||
93 | + * | ||
94 | + * Returns: 0 on success, -errno on failure. Since this is an optimization, | ||
95 | + * caller may ignore failures. | ||
97 | + */ | 96 | + */ |
98 | +int vm_shutdown(void) | 97 | +static int allocate_first_block(int fd, size_t max_size) |
99 | +{ | 98 | +{ |
100 | + return do_vm_stop(RUN_STATE_SHUTDOWN, false); | 99 | + size_t write_size = (max_size < MAX_BLOCKSIZE) |
100 | + ? BDRV_SECTOR_SIZE | ||
101 | + : MAX_BLOCKSIZE; | ||
102 | + size_t max_align = MAX(MAX_BLOCKSIZE, getpagesize()); | ||
103 | + void *buf; | ||
104 | + ssize_t n; | ||
105 | + int ret; | ||
106 | + | ||
107 | + buf = qemu_memalign(max_align, write_size); | ||
108 | + memset(buf, 0, write_size); | ||
109 | + | ||
110 | + do { | ||
111 | + n = pwrite(fd, buf, write_size, 0); | ||
112 | + } while (n == -1 && errno == EINTR); | ||
113 | + | ||
114 | + ret = (n == -1) ? -errno : 0; | ||
115 | + | ||
116 | + qemu_vfree(buf); | ||
117 | + return ret; | ||
101 | +} | 118 | +} |
102 | + | 119 | + |
103 | static bool cpu_can_run(CPUState *cpu) | 120 | static int handle_aiocb_truncate(void *opaque) |
104 | { | 121 | { |
105 | if (cpu->stop) { | 122 | RawPosixAIOData *aiocb = opaque; |
106 | @@ -XXX,XX +XXX,XX @@ int vm_stop(RunState state) | 123 | @@ -XXX,XX +XXX,XX @@ static int handle_aiocb_truncate(void *opaque) |
107 | return 0; | 124 | /* posix_fallocate() doesn't set errno. */ |
108 | } | 125 | error_setg_errno(errp, -result, |
109 | 126 | "Could not preallocate new data"); | |
110 | - return do_vm_stop(state); | 127 | + } else if (current_length == 0) { |
111 | + return do_vm_stop(state, true); | 128 | + /* |
129 | + * posix_fallocate() uses fallocate() if the filesystem | ||
130 | + * supports it, or fallback to manually writing zeroes. If | ||
131 | + * fallocate() was used, unaligned reads from the fallocated | ||
132 | + * area in raw_probe_alignment() will succeed, hence we need to | ||
133 | + * allocate the first block. | ||
134 | + * | ||
135 | + * Optimize future alignment probing; ignore failures. | ||
136 | + */ | ||
137 | + allocate_first_block(fd, offset); | ||
138 | } | ||
139 | } else { | ||
140 | result = 0; | ||
141 | @@ -XXX,XX +XXX,XX @@ static int handle_aiocb_truncate(void *opaque) | ||
142 | if (ftruncate(fd, offset) != 0) { | ||
143 | result = -errno; | ||
144 | error_setg_errno(errp, -result, "Could not resize file"); | ||
145 | + } else if (current_length == 0 && offset > current_length) { | ||
146 | + /* Optimize future alignment probing; ignore failures. */ | ||
147 | + allocate_first_block(fd, offset); | ||
148 | } | ||
149 | return result; | ||
150 | default: | ||
151 | diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out | ||
152 | index XXXXXXX..XXXXXXX 100644 | ||
153 | --- a/tests/qemu-iotests/059.out | ||
154 | +++ b/tests/qemu-iotests/059.out | ||
155 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000 subformat=twoGbMax | ||
156 | image: TEST_DIR/t.vmdk | ||
157 | file format: vmdk | ||
158 | virtual size: 0.977 TiB (1073741824000 bytes) | ||
159 | -disk size: 16 KiB | ||
160 | +disk size: 1.97 MiB | ||
161 | Format specific information: | ||
162 | cid: XXXXXXXX | ||
163 | parent cid: XXXXXXXX | ||
164 | diff --git a/tests/qemu-iotests/150.out b/tests/qemu-iotests/150.out.qcow2 | ||
165 | similarity index 100% | ||
166 | rename from tests/qemu-iotests/150.out | ||
167 | rename to tests/qemu-iotests/150.out.qcow2 | ||
168 | diff --git a/tests/qemu-iotests/150.out.raw b/tests/qemu-iotests/150.out.raw | ||
169 | new file mode 100644 | ||
170 | index XXXXXXX..XXXXXXX | ||
171 | --- /dev/null | ||
172 | +++ b/tests/qemu-iotests/150.out.raw | ||
173 | @@ -XXX,XX +XXX,XX @@ | ||
174 | +QA output created by 150 | ||
175 | + | ||
176 | +=== Mapping sparse conversion === | ||
177 | + | ||
178 | +Offset Length File | ||
179 | +0 0x1000 TEST_DIR/t.IMGFMT | ||
180 | + | ||
181 | +=== Mapping non-sparse conversion === | ||
182 | + | ||
183 | +Offset Length File | ||
184 | +0 0x100000 TEST_DIR/t.IMGFMT | ||
185 | +*** done | ||
186 | diff --git a/tests/qemu-iotests/175 b/tests/qemu-iotests/175 | ||
187 | index XXXXXXX..XXXXXXX 100755 | ||
188 | --- a/tests/qemu-iotests/175 | ||
189 | +++ b/tests/qemu-iotests/175 | ||
190 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
191 | # the file size. This function hides the resulting difference in the | ||
192 | # stat -c '%b' output. | ||
193 | # Parameter 1: Number of blocks an empty file occupies | ||
194 | -# Parameter 2: Image size in bytes | ||
195 | +# Parameter 2: Minimal number of blocks in an image | ||
196 | +# Parameter 3: Image size in bytes | ||
197 | _filter_blocks() | ||
198 | { | ||
199 | extra_blocks=$1 | ||
200 | - img_size=$2 | ||
201 | + min_blocks=$2 | ||
202 | + img_size=$3 | ||
203 | |||
204 | - sed -e "s/blocks=$extra_blocks\\(\$\\|[^0-9]\\)/nothing allocated/" \ | ||
205 | - -e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/everything allocated/" | ||
206 | + sed -e "s/blocks=$min_blocks\\(\$\\|[^0-9]\\)/min allocation/" \ | ||
207 | + -e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/max allocation/" | ||
112 | } | 208 | } |
113 | 209 | ||
114 | /** | 210 | # get standard environment, filters and checks |
115 | diff --git a/iothread.c b/iothread.c | 211 | @@ -XXX,XX +XXX,XX @@ size=$((1 * 1024 * 1024)) |
116 | index XXXXXXX..XXXXXXX 100644 | 212 | touch "$TEST_DIR/empty" |
117 | --- a/iothread.c | 213 | extra_blocks=$(stat -c '%b' "$TEST_DIR/empty") |
118 | +++ b/iothread.c | 214 | |
119 | @@ -XXX,XX +XXX,XX @@ void iothread_stop(IOThread *iothread) | 215 | +# We always write the first byte; check how many blocks this filesystem |
120 | qemu_thread_join(&iothread->thread); | 216 | +# allocates to match empty image alloation. |
217 | +printf "\0" > "$TEST_DIR/empty" | ||
218 | +min_blocks=$(stat -c '%b' "$TEST_DIR/empty") | ||
219 | + | ||
220 | echo | ||
221 | echo "== creating image with default preallocation ==" | ||
222 | _make_test_img $size | _filter_imgfmt | ||
223 | -stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $size | ||
224 | +stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $size | ||
225 | |||
226 | for mode in off full falloc; do | ||
227 | echo | ||
228 | echo "== creating image with preallocation $mode ==" | ||
229 | IMGOPTS=preallocation=$mode _make_test_img $size | _filter_imgfmt | ||
230 | - stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $size | ||
231 | + stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $size | ||
232 | done | ||
233 | |||
234 | # success, all done | ||
235 | diff --git a/tests/qemu-iotests/175.out b/tests/qemu-iotests/175.out | ||
236 | index XXXXXXX..XXXXXXX 100644 | ||
237 | --- a/tests/qemu-iotests/175.out | ||
238 | +++ b/tests/qemu-iotests/175.out | ||
239 | @@ -XXX,XX +XXX,XX @@ QA output created by 175 | ||
240 | |||
241 | == creating image with default preallocation == | ||
242 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 | ||
243 | -size=1048576, nothing allocated | ||
244 | +size=1048576, min allocation | ||
245 | |||
246 | == creating image with preallocation off == | ||
247 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=off | ||
248 | -size=1048576, nothing allocated | ||
249 | +size=1048576, min allocation | ||
250 | |||
251 | == creating image with preallocation full == | ||
252 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=full | ||
253 | -size=1048576, everything allocated | ||
254 | +size=1048576, max allocation | ||
255 | |||
256 | == creating image with preallocation falloc == | ||
257 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=falloc | ||
258 | -size=1048576, everything allocated | ||
259 | +size=1048576, max allocation | ||
260 | *** done | ||
261 | diff --git a/tests/qemu-iotests/178.out.qcow2 b/tests/qemu-iotests/178.out.qcow2 | ||
262 | index XXXXXXX..XXXXXXX 100644 | ||
263 | --- a/tests/qemu-iotests/178.out.qcow2 | ||
264 | +++ b/tests/qemu-iotests/178.out.qcow2 | ||
265 | @@ -XXX,XX +XXX,XX @@ converted image file size in bytes: 196608 | ||
266 | == raw input image with data (human) == | ||
267 | |||
268 | Formatting 'TEST_DIR/t.qcow2', fmt=IMGFMT size=1073741824 | ||
269 | -required size: 393216 | ||
270 | +required size: 458752 | ||
271 | fully allocated size: 1074135040 | ||
272 | wrote 512/512 bytes at offset 512 | ||
273 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
274 | @@ -XXX,XX +XXX,XX @@ converted image file size in bytes: 196608 | ||
275 | |||
276 | Formatting 'TEST_DIR/t.qcow2', fmt=IMGFMT size=1073741824 | ||
277 | { | ||
278 | - "required": 393216, | ||
279 | + "required": 458752, | ||
280 | "fully-allocated": 1074135040 | ||
121 | } | 281 | } |
122 | 282 | wrote 512/512 bytes at offset 512 | |
123 | -static int iothread_stop_iter(Object *object, void *opaque) | 283 | diff --git a/tests/qemu-iotests/221.out b/tests/qemu-iotests/221.out |
124 | -{ | 284 | index XXXXXXX..XXXXXXX 100644 |
125 | - IOThread *iothread; | 285 | --- a/tests/qemu-iotests/221.out |
126 | - | 286 | +++ b/tests/qemu-iotests/221.out |
127 | - iothread = (IOThread *)object_dynamic_cast(object, TYPE_IOTHREAD); | 287 | @@ -XXX,XX +XXX,XX @@ QA output created by 221 |
128 | - if (!iothread) { | 288 | === Check mapping of unaligned raw image === |
129 | - return 0; | 289 | |
130 | - } | 290 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=65537 |
131 | - iothread_stop(iothread); | 291 | -[{ "start": 0, "length": 66048, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] |
132 | - return 0; | 292 | -[{ "start": 0, "length": 66048, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] |
133 | -} | 293 | +[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, |
134 | - | 294 | +{ "start": 4096, "length": 61952, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] |
135 | static void iothread_instance_init(Object *obj) | 295 | +[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, |
136 | { | 296 | +{ "start": 4096, "length": 61952, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] |
137 | IOThread *iothread = IOTHREAD(obj); | 297 | wrote 1/1 bytes at offset 65536 |
138 | @@ -XXX,XX +XXX,XX @@ IOThreadInfoList *qmp_query_iothreads(Error **errp) | 298 | 1 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) |
139 | return head; | 299 | -[{ "start": 0, "length": 65536, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, |
140 | } | 300 | +[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, |
141 | 301 | +{ "start": 4096, "length": 61440, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, | |
142 | -void iothread_stop_all(void) | 302 | { "start": 65536, "length": 1, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, |
143 | -{ | 303 | { "start": 65537, "length": 511, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] |
144 | - Object *container = object_get_objects_root(); | 304 | -[{ "start": 0, "length": 65536, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, |
145 | - BlockDriverState *bs; | 305 | +[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, |
146 | - BdrvNextIterator it; | 306 | +{ "start": 4096, "length": 61440, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, |
147 | - | 307 | { "start": 65536, "length": 1, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, |
148 | - for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) { | 308 | { "start": 65537, "length": 511, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] |
149 | - AioContext *ctx = bdrv_get_aio_context(bs); | 309 | *** done |
150 | - if (ctx == qemu_get_aio_context()) { | 310 | diff --git a/tests/qemu-iotests/253.out b/tests/qemu-iotests/253.out |
151 | - continue; | 311 | index XXXXXXX..XXXXXXX 100644 |
152 | - } | 312 | --- a/tests/qemu-iotests/253.out |
153 | - aio_context_acquire(ctx); | 313 | +++ b/tests/qemu-iotests/253.out |
154 | - bdrv_set_aio_context(bs, qemu_get_aio_context()); | 314 | @@ -XXX,XX +XXX,XX @@ QA output created by 253 |
155 | - aio_context_release(ctx); | 315 | === Check mapping of unaligned raw image === |
156 | - } | 316 | |
157 | - | 317 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048575 |
158 | - object_child_foreach(container, iothread_stop_iter, NULL); | 318 | -[{ "start": 0, "length": 1048576, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] |
159 | -} | 319 | -[{ "start": 0, "length": 1048576, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] |
160 | - | 320 | +[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, |
161 | static gpointer iothread_g_main_context_init(gpointer opaque) | 321 | +{ "start": 4096, "length": 1044480, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] |
162 | { | 322 | +[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, |
163 | AioContext *ctx; | 323 | +{ "start": 4096, "length": 1044480, "depth": 0, "zero": true, "data": false, "offset": OFFSET}] |
164 | diff --git a/vl.c b/vl.c | 324 | wrote 65535/65535 bytes at offset 983040 |
165 | index XXXXXXX..XXXXXXX 100644 | 325 | 63.999 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) |
166 | --- a/vl.c | 326 | -[{ "start": 0, "length": 983040, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, |
167 | +++ b/vl.c | 327 | +[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, |
168 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv, char **envp) | 328 | +{ "start": 4096, "length": 978944, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, |
169 | os_setup_post(); | 329 | { "start": 983040, "length": 65536, "depth": 0, "zero": false, "data": true, "offset": OFFSET}] |
170 | 330 | -[{ "start": 0, "length": 983040, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, | |
171 | main_loop(); | 331 | +[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET}, |
172 | - replay_disable_events(); | 332 | +{ "start": 4096, "length": 978944, "depth": 0, "zero": true, "data": false, "offset": OFFSET}, |
173 | 333 | { "start": 983040, "length": 65536, "depth": 0, "zero": false, "data": true, "offset": OFFSET}] | |
174 | - /* The ordering of the following is delicate. Stop vcpus to prevent new | 334 | *** done |
175 | - * I/O requests being queued by the guest. Then stop IOThreads (this | ||
176 | - * includes a drain operation and completes all request processing). At | ||
177 | - * this point emulated devices are still associated with their IOThreads | ||
178 | - * (if any) but no longer have any work to do. Only then can we close | ||
179 | - * block devices safely because we know there is no more I/O coming. | ||
180 | - */ | ||
181 | - pause_all_vcpus(); | ||
182 | - iothread_stop_all(); | ||
183 | + /* No more vcpu or device emulation activity beyond this point */ | ||
184 | + vm_shutdown(); | ||
185 | + | ||
186 | bdrv_close_all(); | ||
187 | |||
188 | res_free(); | ||
189 | -- | 335 | -- |
190 | 2.14.3 | 336 | 2.21.0 |
191 | 337 | ||
192 | 338 | diff view generated by jsdifflib |
1 | Sometimes it's necessary for the main loop thread to run a BH in an | 1 | From: Nir Soffer <nirsof@gmail.com> |
---|---|---|---|
2 | IOThread and wait for its completion. This primitive is useful during | ||
3 | startup/shutdown to synchronize and avoid race conditions. | ||
4 | 2 | ||
5 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 3 | Using block_resize we can test allocate_first_block() with file |
6 | Reviewed-by: Fam Zheng <famz@redhat.com> | 4 | descriptor opened with O_DIRECT, ensuring that it works for any size |
7 | Acked-by: Paolo Bonzini <pbonzini@redhat.com> | 5 | larger than 4096 bytes. |
8 | Message-id: 20180307144205.20619-2-stefanha@redhat.com | 6 | |
9 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 7 | Testing smaller sizes is tricky as the result depends on the filesystem |
8 | used for testing. For example on NFS any size will work since O_DIRECT | ||
9 | does not require any alignment. | ||
10 | |||
11 | Signed-off-by: Nir Soffer <nsoffer@redhat.com> | ||
12 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
13 | Message-id: 20190827010528.8818-3-nsoffer@redhat.com | ||
14 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
10 | --- | 15 | --- |
11 | include/block/aio-wait.h | 13 +++++++++++++ | 16 | tests/qemu-iotests/175 | 28 ++++++++++++++++++++++++++++ |
12 | util/aio-wait.c | 31 +++++++++++++++++++++++++++++++ | 17 | tests/qemu-iotests/175.out | 8 ++++++++ |
13 | 2 files changed, 44 insertions(+) | 18 | 2 files changed, 36 insertions(+) |
14 | 19 | ||
15 | diff --git a/include/block/aio-wait.h b/include/block/aio-wait.h | 20 | diff --git a/tests/qemu-iotests/175 b/tests/qemu-iotests/175 |
16 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100755 |
17 | --- a/include/block/aio-wait.h | 22 | --- a/tests/qemu-iotests/175 |
18 | +++ b/include/block/aio-wait.h | 23 | +++ b/tests/qemu-iotests/175 |
19 | @@ -XXX,XX +XXX,XX @@ typedef struct { | 24 | @@ -XXX,XX +XXX,XX @@ _filter_blocks() |
20 | */ | 25 | -e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/max allocation/" |
21 | void aio_wait_kick(AioWait *wait); | 26 | } |
22 | 27 | ||
23 | +/** | 28 | +# Resize image using block_resize. |
24 | + * aio_wait_bh_oneshot: | 29 | +# Parameter 1: image path |
25 | + * @ctx: the aio context | 30 | +# Parameter 2: new size |
26 | + * @cb: the BH callback function | 31 | +_block_resize() |
27 | + * @opaque: user data for the BH callback function | 32 | +{ |
28 | + * | 33 | + local path=$1 |
29 | + * Run a BH in @ctx and wait for it to complete. | 34 | + local size=$2 |
30 | + * | ||
31 | + * Must be called from the main loop thread with @ctx acquired exactly once. | ||
32 | + * Note that main loop event processing may occur. | ||
33 | + */ | ||
34 | +void aio_wait_bh_oneshot(AioContext *ctx, QEMUBHFunc *cb, void *opaque); | ||
35 | + | 35 | + |
36 | #endif /* QEMU_AIO_WAIT */ | 36 | + $QEMU -qmp stdio -nographic -nodefaults \ |
37 | diff --git a/util/aio-wait.c b/util/aio-wait.c | 37 | + -blockdev file,node-name=file,filename=$path,cache.direct=on \ |
38 | index XXXXXXX..XXXXXXX 100644 | 38 | + <<EOF |
39 | --- a/util/aio-wait.c | 39 | +{'execute': 'qmp_capabilities'} |
40 | +++ b/util/aio-wait.c | 40 | +{'execute': 'block_resize', 'arguments': {'node-name': 'file', 'size': $size}} |
41 | @@ -XXX,XX +XXX,XX @@ void aio_wait_kick(AioWait *wait) | 41 | +{'execute': 'quit'} |
42 | aio_bh_schedule_oneshot(qemu_get_aio_context(), dummy_bh_cb, NULL); | 42 | +EOF |
43 | } | ||
44 | } | ||
45 | + | ||
46 | +typedef struct { | ||
47 | + AioWait wait; | ||
48 | + bool done; | ||
49 | + QEMUBHFunc *cb; | ||
50 | + void *opaque; | ||
51 | +} AioWaitBHData; | ||
52 | + | ||
53 | +/* Context: BH in IOThread */ | ||
54 | +static void aio_wait_bh(void *opaque) | ||
55 | +{ | ||
56 | + AioWaitBHData *data = opaque; | ||
57 | + | ||
58 | + data->cb(data->opaque); | ||
59 | + | ||
60 | + data->done = true; | ||
61 | + aio_wait_kick(&data->wait); | ||
62 | +} | 43 | +} |
63 | + | 44 | + |
64 | +void aio_wait_bh_oneshot(AioContext *ctx, QEMUBHFunc *cb, void *opaque) | 45 | # get standard environment, filters and checks |
65 | +{ | 46 | . ./common.rc |
66 | + AioWaitBHData data = { | 47 | . ./common.filter |
67 | + .cb = cb, | 48 | @@ -XXX,XX +XXX,XX @@ _supported_fmt raw |
68 | + .opaque = opaque, | 49 | _supported_proto file |
69 | + }; | 50 | _supported_os Linux |
51 | |||
52 | +_default_cache_mode none | ||
53 | +_supported_cache_modes none directsync | ||
70 | + | 54 | + |
71 | + assert(qemu_get_current_aio_context() == qemu_get_aio_context()); | 55 | size=$((1 * 1024 * 1024)) |
56 | |||
57 | touch "$TEST_DIR/empty" | ||
58 | @@ -XXX,XX +XXX,XX @@ for mode in off full falloc; do | ||
59 | stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $size | ||
60 | done | ||
61 | |||
62 | +for new_size in 4096 1048576; do | ||
63 | + echo | ||
64 | + echo "== resize empty image with block_resize ==" | ||
65 | + _make_test_img 0 | _filter_imgfmt | ||
66 | + _block_resize $TEST_IMG $new_size >/dev/null | ||
67 | + stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $new_size | ||
68 | +done | ||
72 | + | 69 | + |
73 | + aio_bh_schedule_oneshot(ctx, aio_wait_bh, &data); | 70 | # success, all done |
74 | + AIO_WAIT_WHILE(&data.wait, ctx, !data.done); | 71 | echo "*** done" |
75 | +} | 72 | rm -f $seq.full |
73 | diff --git a/tests/qemu-iotests/175.out b/tests/qemu-iotests/175.out | ||
74 | index XXXXXXX..XXXXXXX 100644 | ||
75 | --- a/tests/qemu-iotests/175.out | ||
76 | +++ b/tests/qemu-iotests/175.out | ||
77 | @@ -XXX,XX +XXX,XX @@ size=1048576, max allocation | ||
78 | == creating image with preallocation falloc == | ||
79 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 preallocation=falloc | ||
80 | size=1048576, max allocation | ||
81 | + | ||
82 | +== resize empty image with block_resize == | ||
83 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=0 | ||
84 | +size=4096, min allocation | ||
85 | + | ||
86 | +== resize empty image with block_resize == | ||
87 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=0 | ||
88 | +size=1048576, min allocation | ||
89 | *** done | ||
76 | -- | 90 | -- |
77 | 2.14.3 | 91 | 2.21.0 |
78 | 92 | ||
79 | 93 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | fe646693acc changed qemu-img create's output so that it no longer prints | ||
2 | single quotes around parameter values. The subformat and adapter_type | ||
3 | filters in _filter_img_create() have never been adapted to that change. | ||
1 | 4 | ||
5 | Fixes: fe646693acc13ac48b98435d14149ab04dc597bc | ||
6 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
7 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
8 | Message-id: 20190815153638.4600-2-mreitz@redhat.com | ||
9 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
10 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
11 | --- | ||
12 | tests/qemu-iotests/059.out | 16 ++++++++-------- | ||
13 | tests/qemu-iotests/common.filter | 4 ++-- | ||
14 | 2 files changed, 10 insertions(+), 10 deletions(-) | ||
15 | |||
16 | diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/tests/qemu-iotests/059.out | ||
19 | +++ b/tests/qemu-iotests/059.out | ||
20 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
21 | qemu-io: can't open device TEST_DIR/t.vmdk: L1 size too big | ||
22 | |||
23 | === Testing monolithicFlat creation and opening === | ||
24 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 subformat=monolithicFlat | ||
25 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 | ||
26 | image: TEST_DIR/t.IMGFMT | ||
27 | file format: IMGFMT | ||
28 | virtual size: 2 GiB (2147483648 bytes) | ||
29 | |||
30 | === Testing monolithicFlat with zeroed_grain === | ||
31 | qemu-img: TEST_DIR/t.IMGFMT: Flat image can't enable zeroed grain | ||
32 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 subformat=monolithicFlat | ||
33 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 | ||
34 | |||
35 | === Testing big twoGbMaxExtentFlat === | ||
36 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000 subformat=twoGbMaxExtentFlat | ||
37 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000 | ||
38 | image: TEST_DIR/t.vmdk | ||
39 | file format: vmdk | ||
40 | virtual size: 0.977 TiB (1073741824000 bytes) | ||
41 | @@ -XXX,XX +XXX,XX @@ Format specific information: | ||
42 | qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Invalid extent line: RW 12582912 VMFS "dummy.IMGFMT" 1 | ||
43 | |||
44 | === Testing truncated sparse === | ||
45 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=107374182400 subformat=monolithicSparse | ||
46 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=107374182400 | ||
47 | qemu-img: Could not open 'TEST_DIR/t.IMGFMT': File truncated, expecting at least 13172736 bytes | ||
48 | |||
49 | === Converting to streamOptimized from image with small cluster size=== | ||
50 | @@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240 | ||
51 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
52 | |||
53 | === Testing monolithicFlat with internally generated JSON file name === | ||
54 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 subformat=monolithicFlat | ||
55 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
56 | qemu-io: can't open: Cannot use relative extent paths with VMDK descriptor file 'json:{"image": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, "driver": "blkdebug", "inject-error.0.event": "read_aio"}' | ||
57 | |||
58 | === Testing version 3 === | ||
59 | @@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 64931328 | ||
60 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
61 | |||
62 | === Testing 4TB monolithicFlat creation and IO === | ||
63 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4398046511104 subformat=monolithicFlat | ||
64 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4398046511104 | ||
65 | image: TEST_DIR/t.IMGFMT | ||
66 | file format: IMGFMT | ||
67 | virtual size: 4 TiB (4398046511104 bytes) | ||
68 | @@ -XXX,XX +XXX,XX @@ read 1024/1024 bytes at offset 966367641600 | ||
69 | 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
70 | |||
71 | === Testing qemu-img map on extents === | ||
72 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544 subformat=monolithicSparse | ||
73 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544 | ||
74 | wrote 1024/1024 bytes at offset 65024 | ||
75 | 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
76 | wrote 1024/1024 bytes at offset 2147483136 | ||
77 | @@ -XXX,XX +XXX,XX @@ Offset Length Mapped to File | ||
78 | 0 0x20000 0x3f0000 TEST_DIR/t.vmdk | ||
79 | 0x7fff0000 0x20000 0x410000 TEST_DIR/t.vmdk | ||
80 | 0x140000000 0x10000 0x430000 TEST_DIR/t.vmdk | ||
81 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544 subformat=twoGbMaxExtentSparse | ||
82 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544 | ||
83 | wrote 1024/1024 bytes at offset 65024 | ||
84 | 1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
85 | wrote 1024/1024 bytes at offset 2147483136 | ||
86 | diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter | ||
87 | index XXXXXXX..XXXXXXX 100644 | ||
88 | --- a/tests/qemu-iotests/common.filter | ||
89 | +++ b/tests/qemu-iotests/common.filter | ||
90 | @@ -XXX,XX +XXX,XX @@ _filter_img_create() | ||
91 | -e "s# compat6=\\(on\\|off\\)##g" \ | ||
92 | -e "s# static=\\(on\\|off\\)##g" \ | ||
93 | -e "s# zeroed_grain=\\(on\\|off\\)##g" \ | ||
94 | - -e "s# subformat='[^']*'##g" \ | ||
95 | - -e "s# adapter_type='[^']*'##g" \ | ||
96 | + -e "s# subformat=[^ ]*##g" \ | ||
97 | + -e "s# adapter_type=[^ ]*##g" \ | ||
98 | -e "s# hwversion=[^ ]*##g" \ | ||
99 | -e "s# lazy_refcounts=\\(on\\|off\\)##g" \ | ||
100 | -e "s# block_size=[0-9]\\+##g" \ | ||
101 | -- | ||
102 | 2.21.0 | ||
103 | |||
104 | diff view generated by jsdifflib |
1 | If the main loop thread invokes .ioeventfd_stop() just as the vq handler | 1 | This makes iotest 033 pass with e.g. subformat=monolithicFlat. It also |
---|---|---|---|
2 | function begins in the IOThread then the handler may lose the race for | 2 | turns a former error in 059 into success. |
3 | the AioContext lock. By the time the vq handler is able to acquire the | ||
4 | AioContext lock the ioeventfd has already been removed and the handler | ||
5 | isn't supposed to run anymore! | ||
6 | 3 | ||
7 | Use the new aio_wait_bh_oneshot() function to perform ioeventfd removal | 4 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
8 | from within the IOThread. This way no races with the vq handler are | 5 | Message-id: 20190815153638.4600-3-mreitz@redhat.com |
9 | possible. | 6 | Reviewed-by: John Snow <jsnow@redhat.com> |
7 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
8 | --- | ||
9 | block/vmdk.c | 54 ++++++++++++++++++++++++-------------- | ||
10 | tests/qemu-iotests/059 | 7 +++-- | ||
11 | tests/qemu-iotests/059.out | 4 ++- | ||
12 | 3 files changed, 42 insertions(+), 23 deletions(-) | ||
10 | 13 | ||
11 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 14 | diff --git a/block/vmdk.c b/block/vmdk.c |
12 | Reviewed-by: Fam Zheng <famz@redhat.com> | ||
13 | Acked-by: Paolo Bonzini <pbonzini@redhat.com> | ||
14 | Message-id: 20180307144205.20619-4-stefanha@redhat.com | ||
15 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
16 | --- | ||
17 | hw/scsi/virtio-scsi-dataplane.c | 9 +++++---- | ||
18 | 1 file changed, 5 insertions(+), 4 deletions(-) | ||
19 | |||
20 | diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplane.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/scsi/virtio-scsi-dataplane.c | 16 | --- a/block/vmdk.c |
23 | +++ b/hw/scsi/virtio-scsi-dataplane.c | 17 | +++ b/block/vmdk.c |
24 | @@ -XXX,XX +XXX,XX @@ static int virtio_scsi_vring_init(VirtIOSCSI *s, VirtQueue *vq, int n, | 18 | @@ -XXX,XX +XXX,XX @@ static const char *next_line(const char *s) |
25 | return 0; | ||
26 | } | 19 | } |
27 | 20 | ||
28 | -/* assumes s->ctx held */ | 21 | static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, |
29 | -static void virtio_scsi_clear_aio(VirtIOSCSI *s) | 22 | - const char *desc_file_path, QDict *options, |
30 | +/* Context: BH in IOThread */ | 23 | - Error **errp) |
31 | +static void virtio_scsi_dataplane_stop_bh(void *opaque) | 24 | + QDict *options, Error **errp) |
32 | { | 25 | { |
33 | + VirtIOSCSI *s = opaque; | 26 | int ret; |
34 | VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s); | 27 | int matches; |
35 | int i; | 28 | @@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, |
36 | 29 | const char *p, *np; | |
37 | @@ -XXX,XX +XXX,XX @@ int virtio_scsi_dataplane_start(VirtIODevice *vdev) | 30 | int64_t sectors = 0; |
38 | return 0; | 31 | int64_t flat_offset; |
39 | 32 | + char *desc_file_dir = NULL; | |
40 | fail_vrings: | 33 | char *extent_path; |
41 | - virtio_scsi_clear_aio(s); | 34 | BdrvChild *extent_file; |
42 | + aio_wait_bh_oneshot(s->ctx, virtio_scsi_dataplane_stop_bh, s); | 35 | BDRVVmdkState *s = bs->opaque; |
43 | aio_context_release(s->ctx); | 36 | @@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, |
44 | for (i = 0; i < vs->conf.num_queues + 2; i++) { | 37 | continue; |
45 | virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, false); | 38 | } |
46 | @@ -XXX,XX +XXX,XX @@ void virtio_scsi_dataplane_stop(VirtIODevice *vdev) | 39 | |
47 | s->dataplane_stopping = true; | 40 | - if (!path_is_absolute(fname) && !path_has_protocol(fname) && |
48 | 41 | - !desc_file_path[0]) | |
49 | aio_context_acquire(s->ctx); | 42 | - { |
50 | - virtio_scsi_clear_aio(s); | 43 | - bdrv_refresh_filename(bs->file->bs); |
51 | + aio_wait_bh_oneshot(s->ctx, virtio_scsi_dataplane_stop_bh, s); | 44 | - error_setg(errp, "Cannot use relative extent paths with VMDK " |
52 | aio_context_release(s->ctx); | 45 | - "descriptor file '%s'", bs->file->bs->filename); |
53 | 46 | - return -EINVAL; | |
54 | blk_drain_all(); /* ensure there are no in-flight requests */ | 47 | - } |
48 | + if (path_is_absolute(fname)) { | ||
49 | + extent_path = g_strdup(fname); | ||
50 | + } else { | ||
51 | + if (!desc_file_dir) { | ||
52 | + desc_file_dir = bdrv_dirname(bs->file->bs, errp); | ||
53 | + if (!desc_file_dir) { | ||
54 | + bdrv_refresh_filename(bs->file->bs); | ||
55 | + error_prepend(errp, "Cannot use relative paths with VMDK " | ||
56 | + "descriptor file '%s': ", | ||
57 | + bs->file->bs->filename); | ||
58 | + ret = -EINVAL; | ||
59 | + goto out; | ||
60 | + } | ||
61 | + } | ||
62 | |||
63 | - extent_path = path_combine(desc_file_path, fname); | ||
64 | + extent_path = g_strconcat(desc_file_dir, fname, NULL); | ||
65 | + } | ||
66 | |||
67 | ret = snprintf(extent_opt_prefix, 32, "extents.%d", s->num_extents); | ||
68 | assert(ret < 32); | ||
69 | @@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, | ||
70 | g_free(extent_path); | ||
71 | if (local_err) { | ||
72 | error_propagate(errp, local_err); | ||
73 | - return -EINVAL; | ||
74 | + ret = -EINVAL; | ||
75 | + goto out; | ||
76 | } | ||
77 | |||
78 | /* save to extents array */ | ||
79 | @@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, | ||
80 | 0, 0, 0, 0, 0, &extent, errp); | ||
81 | if (ret < 0) { | ||
82 | bdrv_unref_child(bs, extent_file); | ||
83 | - return ret; | ||
84 | + goto out; | ||
85 | } | ||
86 | extent->flat_start_offset = flat_offset << 9; | ||
87 | } else if (!strcmp(type, "SPARSE") || !strcmp(type, "VMFSSPARSE")) { | ||
88 | @@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, | ||
89 | g_free(buf); | ||
90 | if (ret) { | ||
91 | bdrv_unref_child(bs, extent_file); | ||
92 | - return ret; | ||
93 | + goto out; | ||
94 | } | ||
95 | extent = &s->extents[s->num_extents - 1]; | ||
96 | } else if (!strcmp(type, "SESPARSE")) { | ||
97 | ret = vmdk_open_se_sparse(bs, extent_file, bs->open_flags, errp); | ||
98 | if (ret) { | ||
99 | bdrv_unref_child(bs, extent_file); | ||
100 | - return ret; | ||
101 | + goto out; | ||
102 | } | ||
103 | extent = &s->extents[s->num_extents - 1]; | ||
104 | } else { | ||
105 | error_setg(errp, "Unsupported extent type '%s'", type); | ||
106 | bdrv_unref_child(bs, extent_file); | ||
107 | - return -ENOTSUP; | ||
108 | + ret = -ENOTSUP; | ||
109 | + goto out; | ||
110 | } | ||
111 | extent->type = g_strdup(type); | ||
112 | } | ||
113 | - return 0; | ||
114 | + | ||
115 | + ret = 0; | ||
116 | + goto out; | ||
117 | |||
118 | invalid: | ||
119 | np = next_line(p); | ||
120 | @@ -XXX,XX +XXX,XX @@ invalid: | ||
121 | np--; | ||
122 | } | ||
123 | error_setg(errp, "Invalid extent line: %.*s", (int)(np - p), p); | ||
124 | - return -EINVAL; | ||
125 | + ret = -EINVAL; | ||
126 | + | ||
127 | +out: | ||
128 | + g_free(desc_file_dir); | ||
129 | + return ret; | ||
130 | } | ||
131 | |||
132 | static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf, | ||
133 | @@ -XXX,XX +XXX,XX @@ static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf, | ||
134 | } | ||
135 | s->create_type = g_strdup(ct); | ||
136 | s->desc_offset = 0; | ||
137 | - ret = vmdk_parse_extents(buf, bs, bs->file->bs->exact_filename, options, | ||
138 | - errp); | ||
139 | + ret = vmdk_parse_extents(buf, bs, options, errp); | ||
140 | exit: | ||
141 | return ret; | ||
142 | } | ||
143 | diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059 | ||
144 | index XXXXXXX..XXXXXXX 100755 | ||
145 | --- a/tests/qemu-iotests/059 | ||
146 | +++ b/tests/qemu-iotests/059 | ||
147 | @@ -XXX,XX +XXX,XX @@ $QEMU_IMG convert -f qcow2 -O vmdk -o subformat=streamOptimized "$TEST_IMG.qcow2 | ||
148 | |||
149 | echo | ||
150 | echo "=== Testing monolithicFlat with internally generated JSON file name ===" | ||
151 | +# Should work, because bdrv_dirname() works fine with blkdebug | ||
152 | IMGOPTS="subformat=monolithicFlat" _make_test_img 64M | ||
153 | -$QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" 2>&1 \ | ||
154 | - | _filter_testdir | _filter_imgfmt | ||
155 | +$QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" \ | ||
156 | + -c info \ | ||
157 | + 2>&1 \ | ||
158 | + | _filter_testdir | _filter_imgfmt | _filter_img_info | ||
159 | _cleanup_test_img | ||
160 | |||
161 | echo | ||
162 | diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out | ||
163 | index XXXXXXX..XXXXXXX 100644 | ||
164 | --- a/tests/qemu-iotests/059.out | ||
165 | +++ b/tests/qemu-iotests/059.out | ||
166 | @@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240 | ||
167 | |||
168 | === Testing monolithicFlat with internally generated JSON file name === | ||
169 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
170 | -qemu-io: can't open: Cannot use relative extent paths with VMDK descriptor file 'json:{"image": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, "driver": "blkdebug", "inject-error.0.event": "read_aio"}' | ||
171 | +format name: IMGFMT | ||
172 | +cluster size: 0 bytes | ||
173 | +vm state offset: 0 bytes | ||
174 | |||
175 | === Testing version 3 === | ||
176 | image: TEST_DIR/iotest-version3.IMGFMT | ||
55 | -- | 177 | -- |
56 | 2.14.3 | 178 | 2.21.0 |
57 | 179 | ||
58 | 180 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | We had a test for a case where relative extent paths did not work, but | ||
2 | unfortunately we just fixed the underlying problem, so it works now. | ||
3 | This patch adds a new test case that still fails. | ||
1 | 4 | ||
5 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
6 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
7 | Message-id: 20190815153638.4600-4-mreitz@redhat.com | ||
8 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
9 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
10 | --- | ||
11 | tests/qemu-iotests/059 | 27 +++++++++++++++++++++++++++ | ||
12 | tests/qemu-iotests/059.out | 4 ++++ | ||
13 | 2 files changed, 31 insertions(+) | ||
14 | |||
15 | diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059 | ||
16 | index XXXXXXX..XXXXXXX 100755 | ||
17 | --- a/tests/qemu-iotests/059 | ||
18 | +++ b/tests/qemu-iotests/059 | ||
19 | @@ -XXX,XX +XXX,XX @@ $QEMU_IMG convert -f qcow2 -O vmdk -o subformat=streamOptimized "$TEST_IMG.qcow2 | ||
20 | |||
21 | echo | ||
22 | echo "=== Testing monolithicFlat with internally generated JSON file name ===" | ||
23 | + | ||
24 | +echo '--- blkdebug ---' | ||
25 | # Should work, because bdrv_dirname() works fine with blkdebug | ||
26 | IMGOPTS="subformat=monolithicFlat" _make_test_img 64M | ||
27 | $QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" \ | ||
28 | @@ -XXX,XX +XXX,XX @@ $QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TE | ||
29 | | _filter_testdir | _filter_imgfmt | _filter_img_info | ||
30 | _cleanup_test_img | ||
31 | |||
32 | +echo '--- quorum ---' | ||
33 | +# Should not work, because bdrv_dirname() does not work with quorum | ||
34 | +IMGOPTS="subformat=monolithicFlat" _make_test_img 64M | ||
35 | +cp "$TEST_IMG" "$TEST_IMG.orig" | ||
36 | + | ||
37 | +filename="json:{ | ||
38 | + \"driver\": \"$IMGFMT\", | ||
39 | + \"file\": { | ||
40 | + \"driver\": \"quorum\", | ||
41 | + \"children\": [ { | ||
42 | + \"driver\": \"file\", | ||
43 | + \"filename\": \"$TEST_IMG\" | ||
44 | + }, { | ||
45 | + \"driver\": \"file\", | ||
46 | + \"filename\": \"$TEST_IMG.orig\" | ||
47 | + } ], | ||
48 | + \"vote-threshold\": 1 | ||
49 | + } }" | ||
50 | + | ||
51 | +filename=$(echo "$filename" | tr '\n' ' ' | sed -e 's/\s\+/ /g') | ||
52 | +$QEMU_IMG info "$filename" 2>&1 \ | ||
53 | + | sed -e "s/'json:[^']*'/\$QUORUM_FILE/g" \ | ||
54 | + | _filter_testdir | _filter_imgfmt | _filter_img_info | ||
55 | + | ||
56 | + | ||
57 | echo | ||
58 | echo "=== Testing version 3 ===" | ||
59 | _use_sample_img iotest-version3.vmdk.bz2 | ||
60 | diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/tests/qemu-iotests/059.out | ||
63 | +++ b/tests/qemu-iotests/059.out | ||
64 | @@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240 | ||
65 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) | ||
66 | |||
67 | === Testing monolithicFlat with internally generated JSON file name === | ||
68 | +--- blkdebug --- | ||
69 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
70 | format name: IMGFMT | ||
71 | cluster size: 0 bytes | ||
72 | vm state offset: 0 bytes | ||
73 | +--- quorum --- | ||
74 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
75 | +qemu-img: Could not open $QUORUM_FILE: Cannot use relative paths with VMDK descriptor file $QUORUM_FILE: Cannot generate a base directory for quorum nodes | ||
76 | |||
77 | === Testing version 3 === | ||
78 | image: TEST_DIR/iotest-version3.IMGFMT | ||
79 | -- | ||
80 | 2.21.0 | ||
81 | |||
82 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Compressed writes generally have to write full clusters, not just in | ||
2 | theory but also in practice when it comes to vmdk's streamOptimized | ||
3 | subformat. It currently is just silently broken for writes with | ||
4 | non-zero in-cluster offsets: | ||
1 | 5 | ||
6 | $ qemu-img create -f vmdk -o subformat=streamOptimized foo.vmdk 1M | ||
7 | $ qemu-io -c 'write 4k 4k' -c 'read 4k 4k' foo.vmdk | ||
8 | wrote 4096/4096 bytes at offset 4096 | ||
9 | 4 KiB, 1 ops; 00.01 sec (443.724 KiB/sec and 110.9309 ops/sec) | ||
10 | read failed: Invalid argument | ||
11 | |||
12 | (The technical reason is that vmdk_write_extent() just writes the | ||
13 | incomplete compressed data actually to offset 4k. When reading the | ||
14 | data, vmdk_read_extent() looks at offset 0 and finds the compressed data | ||
15 | size to be 0, because that is what it reads from there. This yields an | ||
16 | error.) | ||
17 | |||
18 | For incomplete writes with zero in-cluster offsets, the error path when | ||
19 | reading the rest of the cluster is a bit different, but the result is | ||
20 | the same: | ||
21 | |||
22 | $ qemu-img create -f vmdk -o subformat=streamOptimized foo.vmdk 1M | ||
23 | $ qemu-io -c 'write 0k 4k' -c 'read 4k 4k' foo.vmdk | ||
24 | wrote 4096/4096 bytes at offset 0 | ||
25 | 4 KiB, 1 ops; 00.01 sec (362.641 KiB/sec and 90.6603 ops/sec) | ||
26 | read failed: Invalid argument | ||
27 | |||
28 | (Here, vmdk_read_extent() finds the data and then sees that the | ||
29 | uncompressed data is short.) | ||
30 | |||
31 | It is better to reject invalid writes than to make the user believe they | ||
32 | might have succeeded and then fail when trying to read it back. | ||
33 | |||
34 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
35 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
36 | Message-id: 20190815153638.4600-5-mreitz@redhat.com | ||
37 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
38 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
39 | --- | ||
40 | block/vmdk.c | 10 ++++++++++ | ||
41 | 1 file changed, 10 insertions(+) | ||
42 | |||
43 | diff --git a/block/vmdk.c b/block/vmdk.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/block/vmdk.c | ||
46 | +++ b/block/vmdk.c | ||
47 | @@ -XXX,XX +XXX,XX @@ static int vmdk_write_extent(VmdkExtent *extent, int64_t cluster_offset, | ||
48 | if (extent->compressed) { | ||
49 | void *compressed_data; | ||
50 | |||
51 | + /* Only whole clusters */ | ||
52 | + if (offset_in_cluster || | ||
53 | + n_bytes > (extent->cluster_sectors * SECTOR_SIZE) || | ||
54 | + (n_bytes < (extent->cluster_sectors * SECTOR_SIZE) && | ||
55 | + offset + n_bytes != extent->end_sector * SECTOR_SIZE)) | ||
56 | + { | ||
57 | + ret = -EINVAL; | ||
58 | + goto out; | ||
59 | + } | ||
60 | + | ||
61 | if (!extent->has_marker) { | ||
62 | ret = -EINVAL; | ||
63 | goto out; | ||
64 | -- | ||
65 | 2.21.0 | ||
66 | |||
67 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | streamOptimized does not support writes that do not span exactly one | ||
2 | cluster. Furthermore, it cannot rewrite already allocated clusters. | ||
3 | As such, many iotests do not work with it. Disable them. | ||
1 | 4 | ||
5 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
6 | Message-id: 20190815153638.4600-6-mreitz@redhat.com | ||
7 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
8 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
9 | --- | ||
10 | tests/qemu-iotests/002 | 1 + | ||
11 | tests/qemu-iotests/003 | 1 + | ||
12 | tests/qemu-iotests/005 | 3 ++- | ||
13 | tests/qemu-iotests/009 | 1 + | ||
14 | tests/qemu-iotests/010 | 1 + | ||
15 | tests/qemu-iotests/011 | 1 + | ||
16 | tests/qemu-iotests/017 | 3 ++- | ||
17 | tests/qemu-iotests/018 | 3 ++- | ||
18 | tests/qemu-iotests/019 | 3 ++- | ||
19 | tests/qemu-iotests/020 | 3 ++- | ||
20 | tests/qemu-iotests/027 | 1 + | ||
21 | tests/qemu-iotests/032 | 1 + | ||
22 | tests/qemu-iotests/033 | 1 + | ||
23 | tests/qemu-iotests/034 | 3 ++- | ||
24 | tests/qemu-iotests/037 | 3 ++- | ||
25 | tests/qemu-iotests/063 | 3 ++- | ||
26 | tests/qemu-iotests/072 | 1 + | ||
27 | tests/qemu-iotests/105 | 3 ++- | ||
28 | tests/qemu-iotests/197 | 1 + | ||
29 | tests/qemu-iotests/215 | 1 + | ||
30 | tests/qemu-iotests/251 | 1 + | ||
31 | 21 files changed, 30 insertions(+), 9 deletions(-) | ||
32 | |||
33 | diff --git a/tests/qemu-iotests/002 b/tests/qemu-iotests/002 | ||
34 | index XXXXXXX..XXXXXXX 100755 | ||
35 | --- a/tests/qemu-iotests/002 | ||
36 | +++ b/tests/qemu-iotests/002 | ||
37 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
38 | |||
39 | _supported_fmt generic | ||
40 | _supported_proto generic | ||
41 | +_unsupported_imgopts "subformat=streamOptimized" | ||
42 | |||
43 | |||
44 | size=128M | ||
45 | diff --git a/tests/qemu-iotests/003 b/tests/qemu-iotests/003 | ||
46 | index XXXXXXX..XXXXXXX 100755 | ||
47 | --- a/tests/qemu-iotests/003 | ||
48 | +++ b/tests/qemu-iotests/003 | ||
49 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
50 | |||
51 | _supported_fmt generic | ||
52 | _supported_proto generic | ||
53 | +_unsupported_imgopts "subformat=streamOptimized" | ||
54 | |||
55 | size=128M | ||
56 | offset=67M | ||
57 | diff --git a/tests/qemu-iotests/005 b/tests/qemu-iotests/005 | ||
58 | index XXXXXXX..XXXXXXX 100755 | ||
59 | --- a/tests/qemu-iotests/005 | ||
60 | +++ b/tests/qemu-iotests/005 | ||
61 | @@ -XXX,XX +XXX,XX @@ _supported_fmt generic | ||
62 | _supported_proto generic | ||
63 | _supported_os Linux | ||
64 | _unsupported_imgopts "subformat=twoGbMaxExtentFlat" \ | ||
65 | - "subformat=twoGbMaxExtentSparse" | ||
66 | + "subformat=twoGbMaxExtentSparse" \ | ||
67 | + "subformat=streamOptimized" | ||
68 | |||
69 | # vpc is limited to 127GB, so we can't test it here | ||
70 | if [ "$IMGFMT" = "vpc" ]; then | ||
71 | diff --git a/tests/qemu-iotests/009 b/tests/qemu-iotests/009 | ||
72 | index XXXXXXX..XXXXXXX 100755 | ||
73 | --- a/tests/qemu-iotests/009 | ||
74 | +++ b/tests/qemu-iotests/009 | ||
75 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
76 | |||
77 | _supported_fmt generic | ||
78 | _supported_proto generic | ||
79 | +_unsupported_imgopts "subformat=streamOptimized" | ||
80 | |||
81 | |||
82 | size=6G | ||
83 | diff --git a/tests/qemu-iotests/010 b/tests/qemu-iotests/010 | ||
84 | index XXXXXXX..XXXXXXX 100755 | ||
85 | --- a/tests/qemu-iotests/010 | ||
86 | +++ b/tests/qemu-iotests/010 | ||
87 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
88 | |||
89 | _supported_fmt generic | ||
90 | _supported_proto generic | ||
91 | +_unsupported_imgopts "subformat=streamOptimized" | ||
92 | |||
93 | |||
94 | size=6G | ||
95 | diff --git a/tests/qemu-iotests/011 b/tests/qemu-iotests/011 | ||
96 | index XXXXXXX..XXXXXXX 100755 | ||
97 | --- a/tests/qemu-iotests/011 | ||
98 | +++ b/tests/qemu-iotests/011 | ||
99 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
100 | |||
101 | _supported_fmt generic | ||
102 | _supported_proto generic | ||
103 | +_unsupported_imgopts "subformat=streamOptimized" | ||
104 | |||
105 | |||
106 | size=6G | ||
107 | diff --git a/tests/qemu-iotests/017 b/tests/qemu-iotests/017 | ||
108 | index XXXXXXX..XXXXXXX 100755 | ||
109 | --- a/tests/qemu-iotests/017 | ||
110 | +++ b/tests/qemu-iotests/017 | ||
111 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
112 | _supported_fmt qcow qcow2 vmdk qed | ||
113 | _supported_proto generic | ||
114 | _unsupported_proto vxhs | ||
115 | -_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" | ||
116 | +_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \ | ||
117 | + "subformat=streamOptimized" | ||
118 | |||
119 | TEST_OFFSETS="0 4294967296" | ||
120 | |||
121 | diff --git a/tests/qemu-iotests/018 b/tests/qemu-iotests/018 | ||
122 | index XXXXXXX..XXXXXXX 100755 | ||
123 | --- a/tests/qemu-iotests/018 | ||
124 | +++ b/tests/qemu-iotests/018 | ||
125 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
126 | _supported_fmt qcow qcow2 vmdk qed | ||
127 | _supported_proto file | ||
128 | _supported_os Linux | ||
129 | -_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" | ||
130 | +_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \ | ||
131 | + "streamOptimized" | ||
132 | |||
133 | TEST_OFFSETS="0 4294967296" | ||
134 | |||
135 | diff --git a/tests/qemu-iotests/019 b/tests/qemu-iotests/019 | ||
136 | index XXXXXXX..XXXXXXX 100755 | ||
137 | --- a/tests/qemu-iotests/019 | ||
138 | +++ b/tests/qemu-iotests/019 | ||
139 | @@ -XXX,XX +XXX,XX @@ _supported_proto file | ||
140 | _supported_os Linux | ||
141 | _unsupported_imgopts "subformat=monolithicFlat" \ | ||
142 | "subformat=twoGbMaxExtentFlat" \ | ||
143 | - "subformat=twoGbMaxExtentSparse" | ||
144 | + "subformat=twoGbMaxExtentSparse" \ | ||
145 | + "subformat=streamOptimized" | ||
146 | |||
147 | TEST_OFFSETS="0 4294967296" | ||
148 | CLUSTER_SIZE=65536 | ||
149 | diff --git a/tests/qemu-iotests/020 b/tests/qemu-iotests/020 | ||
150 | index XXXXXXX..XXXXXXX 100755 | ||
151 | --- a/tests/qemu-iotests/020 | ||
152 | +++ b/tests/qemu-iotests/020 | ||
153 | @@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed | ||
154 | _supported_proto file | ||
155 | _unsupported_imgopts "subformat=monolithicFlat" \ | ||
156 | "subformat=twoGbMaxExtentFlat" \ | ||
157 | - "subformat=twoGbMaxExtentSparse" | ||
158 | + "subformat=twoGbMaxExtentSparse" \ | ||
159 | + "subformat=streamOptimized" | ||
160 | |||
161 | TEST_OFFSETS="0 4294967296" | ||
162 | |||
163 | diff --git a/tests/qemu-iotests/027 b/tests/qemu-iotests/027 | ||
164 | index XXXXXXX..XXXXXXX 100755 | ||
165 | --- a/tests/qemu-iotests/027 | ||
166 | +++ b/tests/qemu-iotests/027 | ||
167 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
168 | |||
169 | _supported_fmt vmdk qcow qcow2 qed | ||
170 | _supported_proto generic | ||
171 | +_unsupported_imgopts "subformat=streamOptimized" | ||
172 | |||
173 | |||
174 | size=128M | ||
175 | diff --git a/tests/qemu-iotests/032 b/tests/qemu-iotests/032 | ||
176 | index XXXXXXX..XXXXXXX 100755 | ||
177 | --- a/tests/qemu-iotests/032 | ||
178 | +++ b/tests/qemu-iotests/032 | ||
179 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
180 | # This works for any image format (though unlikely to segfault for raw) | ||
181 | _supported_fmt generic | ||
182 | _supported_proto generic | ||
183 | +_unsupported_imgopts "subformat=streamOptimized" | ||
184 | |||
185 | echo | ||
186 | echo === Prepare image === | ||
187 | diff --git a/tests/qemu-iotests/033 b/tests/qemu-iotests/033 | ||
188 | index XXXXXXX..XXXXXXX 100755 | ||
189 | --- a/tests/qemu-iotests/033 | ||
190 | +++ b/tests/qemu-iotests/033 | ||
191 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
192 | |||
193 | _supported_fmt generic | ||
194 | _supported_proto generic | ||
195 | +_unsupported_imgopts "subformat=streamOptimized" | ||
196 | |||
197 | |||
198 | size=128M | ||
199 | diff --git a/tests/qemu-iotests/034 b/tests/qemu-iotests/034 | ||
200 | index XXXXXXX..XXXXXXX 100755 | ||
201 | --- a/tests/qemu-iotests/034 | ||
202 | +++ b/tests/qemu-iotests/034 | ||
203 | @@ -XXX,XX +XXX,XX @@ _supported_proto file | ||
204 | _supported_os Linux | ||
205 | _unsupported_imgopts "subformat=monolithicFlat" \ | ||
206 | "subformat=twoGbMaxExtentFlat" \ | ||
207 | - "subformat=twoGbMaxExtentSparse" | ||
208 | + "subformat=twoGbMaxExtentSparse" \ | ||
209 | + "subformat=streamOptimized" | ||
210 | |||
211 | CLUSTER_SIZE=4k | ||
212 | size=128M | ||
213 | diff --git a/tests/qemu-iotests/037 b/tests/qemu-iotests/037 | ||
214 | index XXXXXXX..XXXXXXX 100755 | ||
215 | --- a/tests/qemu-iotests/037 | ||
216 | +++ b/tests/qemu-iotests/037 | ||
217 | @@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed | ||
218 | _supported_proto file | ||
219 | _unsupported_imgopts "subformat=monolithicFlat" \ | ||
220 | "subformat=twoGbMaxExtentFlat" \ | ||
221 | - "subformat=twoGbMaxExtentSparse" | ||
222 | + "subformat=twoGbMaxExtentSparse" \ | ||
223 | + "subformat=streamOptimized" | ||
224 | |||
225 | CLUSTER_SIZE=4k | ||
226 | size=128M | ||
227 | diff --git a/tests/qemu-iotests/063 b/tests/qemu-iotests/063 | ||
228 | index XXXXXXX..XXXXXXX 100755 | ||
229 | --- a/tests/qemu-iotests/063 | ||
230 | +++ b/tests/qemu-iotests/063 | ||
231 | @@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed raw | ||
232 | _supported_proto file | ||
233 | _unsupported_imgopts "subformat=monolithicFlat" \ | ||
234 | "subformat=twoGbMaxExtentFlat" \ | ||
235 | - "subformat=twoGbMaxExtentSparse" | ||
236 | + "subformat=twoGbMaxExtentSparse" \ | ||
237 | + "subformat=streamOptimized" | ||
238 | |||
239 | _make_test_img 4M | ||
240 | |||
241 | diff --git a/tests/qemu-iotests/072 b/tests/qemu-iotests/072 | ||
242 | index XXXXXXX..XXXXXXX 100755 | ||
243 | --- a/tests/qemu-iotests/072 | ||
244 | +++ b/tests/qemu-iotests/072 | ||
245 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
246 | |||
247 | _supported_fmt vpc vmdk vhdx vdi qed qcow2 qcow | ||
248 | _supported_proto file | ||
249 | +_unsupported_imgopts "subformat=streamOptimized" | ||
250 | |||
251 | IMG_SIZE=64M | ||
252 | |||
253 | diff --git a/tests/qemu-iotests/105 b/tests/qemu-iotests/105 | ||
254 | index XXXXXXX..XXXXXXX 100755 | ||
255 | --- a/tests/qemu-iotests/105 | ||
256 | +++ b/tests/qemu-iotests/105 | ||
257 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
258 | _supported_fmt qcow2 vmdk vhdx qed | ||
259 | _supported_proto generic | ||
260 | _unsupported_imgopts "subformat=twoGbMaxExtentFlat" \ | ||
261 | - "subformat=twoGbMaxExtentSparse" | ||
262 | + "subformat=twoGbMaxExtentSparse" \ | ||
263 | + "subformat=streamOptimized" | ||
264 | |||
265 | echo | ||
266 | echo "creating large image" | ||
267 | diff --git a/tests/qemu-iotests/197 b/tests/qemu-iotests/197 | ||
268 | index XXXXXXX..XXXXXXX 100755 | ||
269 | --- a/tests/qemu-iotests/197 | ||
270 | +++ b/tests/qemu-iotests/197 | ||
271 | @@ -XXX,XX +XXX,XX @@ _supported_fmt generic | ||
272 | _supported_proto generic | ||
273 | # LUKS support may be possible, but it complicates things. | ||
274 | _unsupported_fmt luks | ||
275 | +_unsupported_imgopts "subformat=streamOptimized" | ||
276 | |||
277 | echo | ||
278 | echo '=== Copy-on-read ===' | ||
279 | diff --git a/tests/qemu-iotests/215 b/tests/qemu-iotests/215 | ||
280 | index XXXXXXX..XXXXXXX 100755 | ||
281 | --- a/tests/qemu-iotests/215 | ||
282 | +++ b/tests/qemu-iotests/215 | ||
283 | @@ -XXX,XX +XXX,XX @@ _supported_fmt generic | ||
284 | _supported_proto generic | ||
285 | # LUKS support may be possible, but it complicates things. | ||
286 | _unsupported_fmt luks | ||
287 | +_unsupported_imgopts "subformat=streamOptimized" | ||
288 | |||
289 | echo | ||
290 | echo '=== Copy-on-read ===' | ||
291 | diff --git a/tests/qemu-iotests/251 b/tests/qemu-iotests/251 | ||
292 | index XXXXXXX..XXXXXXX 100755 | ||
293 | --- a/tests/qemu-iotests/251 | ||
294 | +++ b/tests/qemu-iotests/251 | ||
295 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
296 | _supported_fmt generic | ||
297 | _supported_proto file | ||
298 | _supported_os Linux | ||
299 | +_unsupported_imgopts "subformat=streamOptimized" | ||
300 | |||
301 | if [ "$IMGOPTSSYNTAX" = "true" ]; then | ||
302 | # We use json:{} filenames here, so we cannot work with additional options. | ||
303 | -- | ||
304 | 2.21.0 | ||
305 | |||
306 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The error message for the test case where we have a quorum node for | ||
2 | which no directory name can be generated is different: For | ||
3 | twoGbMaxExtentSparse, it complains that it cannot open the extent file. | ||
4 | For other (sub)formats, it just notes that it cannot determine the | ||
5 | backing file path. Both are fine, but just disable twoGbMaxExtentSparse | ||
6 | for simplicity's sake. | ||
1 | 7 | ||
8 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
9 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
10 | Message-id: 20190815153638.4600-7-mreitz@redhat.com | ||
11 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
12 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
13 | --- | ||
14 | tests/qemu-iotests/110 | 3 ++- | ||
15 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
16 | |||
17 | diff --git a/tests/qemu-iotests/110 b/tests/qemu-iotests/110 | ||
18 | index XXXXXXX..XXXXXXX 100755 | ||
19 | --- a/tests/qemu-iotests/110 | ||
20 | +++ b/tests/qemu-iotests/110 | ||
21 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
22 | # Any format supporting backing files | ||
23 | _supported_fmt qed qcow qcow2 vmdk | ||
24 | _supported_proto file | ||
25 | -_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" | ||
26 | +_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \ | ||
27 | + "subformat=twoGbMaxExtentSparse" | ||
28 | |||
29 | TEST_IMG_REL=$(basename "$TEST_IMG") | ||
30 | |||
31 | -- | ||
32 | 2.21.0 | ||
33 | |||
34 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | iotest 126 requires backing file support, which flat vmdks cannot offer. | ||
2 | Skip this test for such subformats. | ||
1 | 3 | ||
4 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
5 | Message-id: 20190815153638.4600-8-mreitz@redhat.com | ||
6 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
7 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
8 | --- | ||
9 | tests/qemu-iotests/126 | 2 ++ | ||
10 | 1 file changed, 2 insertions(+) | ||
11 | |||
12 | diff --git a/tests/qemu-iotests/126 b/tests/qemu-iotests/126 | ||
13 | index XXXXXXX..XXXXXXX 100755 | ||
14 | --- a/tests/qemu-iotests/126 | ||
15 | +++ b/tests/qemu-iotests/126 | ||
16 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! | ||
17 | |||
18 | # Needs backing file support | ||
19 | _supported_fmt qcow qcow2 qed vmdk | ||
20 | +_unsupported_imgopts "subformat=monolithicFlat" \ | ||
21 | + "subformat=twoGbMaxExtentFlat" | ||
22 | # This is the default protocol (and we want to test the difference between | ||
23 | # colons which separate a protocol prefix from the rest and colons which are | ||
24 | # just part of the filename, so we cannot test protocols which require a prefix) | ||
25 | -- | ||
26 | 2.21.0 | ||
27 | |||
28 | diff view generated by jsdifflib |
1 | From: Fam Zheng <famz@redhat.com> | 1 | From: Stefan Hajnoczi <stefanha@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Reported-by: Alberto Garcia <berto@igalia.com> | 3 | Fixes: a6b257a08e3d72219f03e461a52152672fec0612 |
4 | Signed-off-by: Fam Zheng <famz@redhat.com> | 4 | ("file-posix: Handle undetectable alignment") |
5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Message-id: 20180306024328.19195-1-famz@redhat.com | ||
7 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 5 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
6 | Message-id: 20190827101328.4062-1-stefanha@redhat.com | ||
7 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
8 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
8 | --- | 9 | --- |
9 | README | 2 +- | 10 | block/file-posix.c | 2 +- |
10 | 1 file changed, 1 insertion(+), 1 deletion(-) | 11 | 1 file changed, 1 insertion(+), 1 deletion(-) |
11 | 12 | ||
12 | diff --git a/README b/README | 13 | diff --git a/block/file-posix.c b/block/file-posix.c |
13 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/README | 15 | --- a/block/file-posix.c |
15 | +++ b/README | 16 | +++ b/block/file-posix.c |
16 | @@ -XXX,XX +XXX,XX @@ The QEMU website is also maintained under source control. | 17 | @@ -XXX,XX +XXX,XX @@ static void raw_probe_alignment(BlockDriverState *bs, int fd, Error **errp) |
17 | git clone git://git.qemu.org/qemu-web.git | 18 | for (i = 0; i < ARRAY_SIZE(alignments); i++) { |
18 | https://www.qemu.org/2017/02/04/the-new-qemu-website-is-up/ | 19 | align = alignments[i]; |
19 | 20 | if (raw_is_io_aligned(fd, buf + align, max_align)) { | |
20 | -A 'git-profile' utility was created to make above process less | 21 | - /* Fallback to request_aligment. */ |
21 | +A 'git-publish' utility was created to make above process less | 22 | + /* Fallback to request_alignment. */ |
22 | cumbersome, and is highly recommended for making regular contributions, | 23 | s->buf_align = (align != 1) ? align : bs->bl.request_alignment; |
23 | or even just for sending consecutive patch series revisions. It also | 24 | break; |
24 | requires a working 'git send-email' setup, and by default doesn't | 25 | } |
25 | -- | 26 | -- |
26 | 2.14.3 | 27 | 2.21.0 |
27 | 28 | ||
28 | 29 | diff view generated by jsdifflib |
1 | If the main loop thread invokes .ioeventfd_stop() just as the vq handler | 1 | From: Thomas Huth <thuth@redhat.com> |
---|---|---|---|
2 | function begins in the IOThread then the handler may lose the race for | ||
3 | the AioContext lock. By the time the vq handler is able to acquire the | ||
4 | AioContext lock the ioeventfd has already been removed and the handler | ||
5 | isn't supposed to run anymore! | ||
6 | 2 | ||
7 | Use the new aio_wait_bh_oneshot() function to perform ioeventfd removal | 3 | It is possible to enable only a subset of the block drivers with the |
8 | from within the IOThread. This way no races with the vq handler are | 4 | "--block-drv-rw-whitelist" option of the "configure" script. All other |
9 | possible. | 5 | drivers are marked as unusable (or only included as read-only with the |
6 | "--block-drv-ro-whitelist" option). If an iotest is now using such a | ||
7 | disabled block driver, it is failing - which is bad, since at least the | ||
8 | tests in the "auto" group should be able to deal with this situation. | ||
9 | Thus let's introduce a "_require_drivers" function that can be used by | ||
10 | the shell tests to check for the availability of certain drivers first, | ||
11 | and marks the test as "not run" if one of the drivers is missing. | ||
10 | 12 | ||
11 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 13 | This patch mainly targets the test in the "auto" group which should |
12 | Reviewed-by: Fam Zheng <famz@redhat.com> | 14 | never fail in such a case, but also improves some of the other tests |
13 | Acked-by: Paolo Bonzini <pbonzini@redhat.com> | 15 | along the way. Note that we also assume that the "qcow2" and "file" |
14 | Message-id: 20180307144205.20619-3-stefanha@redhat.com | 16 | drivers are always available - otherwise it does not make sense to |
15 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 17 | run "make check-block" at all (which only tests with qcow2 by default). |
18 | |||
19 | Signed-off-by: Thomas Huth <thuth@redhat.com> | ||
20 | Message-id: 20190823133552.11680-1-thuth@redhat.com | ||
21 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
16 | --- | 22 | --- |
17 | hw/block/dataplane/virtio-blk.c | 24 +++++++++++++++++------- | 23 | tests/qemu-iotests/071 | 1 + |
18 | 1 file changed, 17 insertions(+), 7 deletions(-) | 24 | tests/qemu-iotests/081 | 4 +--- |
25 | tests/qemu-iotests/099 | 1 + | ||
26 | tests/qemu-iotests/120 | 1 + | ||
27 | tests/qemu-iotests/162 | 4 +--- | ||
28 | tests/qemu-iotests/184 | 1 + | ||
29 | tests/qemu-iotests/186 | 1 + | ||
30 | tests/qemu-iotests/common.rc | 14 ++++++++++++++ | ||
31 | 8 files changed, 21 insertions(+), 6 deletions(-) | ||
19 | 32 | ||
20 | diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c | 33 | diff --git a/tests/qemu-iotests/071 b/tests/qemu-iotests/071 |
34 | index XXXXXXX..XXXXXXX 100755 | ||
35 | --- a/tests/qemu-iotests/071 | ||
36 | +++ b/tests/qemu-iotests/071 | ||
37 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
38 | |||
39 | _supported_fmt qcow2 | ||
40 | _supported_proto file | ||
41 | +_require_drivers blkdebug blkverify | ||
42 | |||
43 | do_run_qemu() | ||
44 | { | ||
45 | diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081 | ||
46 | index XXXXXXX..XXXXXXX 100755 | ||
47 | --- a/tests/qemu-iotests/081 | ||
48 | +++ b/tests/qemu-iotests/081 | ||
49 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
50 | _supported_fmt raw | ||
51 | _supported_proto file | ||
52 | _supported_os Linux | ||
53 | +_require_drivers quorum | ||
54 | |||
55 | do_run_qemu() | ||
56 | { | ||
57 | @@ -XXX,XX +XXX,XX @@ run_qemu() | ||
58 | | _filter_qemu_io | _filter_generated_node_ids | ||
59 | } | ||
60 | |||
61 | -test_quorum=$($QEMU_IMG --help|grep quorum) | ||
62 | -[ "$test_quorum" = "" ] && _supported_fmt quorum | ||
63 | - | ||
64 | quorum="driver=raw,file.driver=quorum,file.vote-threshold=2" | ||
65 | quorum="$quorum,file.children.0.file.filename=$TEST_DIR/1.raw" | ||
66 | quorum="$quorum,file.children.1.file.filename=$TEST_DIR/2.raw" | ||
67 | diff --git a/tests/qemu-iotests/099 b/tests/qemu-iotests/099 | ||
68 | index XXXXXXX..XXXXXXX 100755 | ||
69 | --- a/tests/qemu-iotests/099 | ||
70 | +++ b/tests/qemu-iotests/099 | ||
71 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
72 | _supported_fmt qcow qcow2 qed vdi vhdx vmdk vpc | ||
73 | _supported_proto file | ||
74 | _supported_os Linux | ||
75 | +_require_drivers blkdebug blkverify | ||
76 | _unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \ | ||
77 | "subformat=twoGbMaxExtentSparse" | ||
78 | |||
79 | diff --git a/tests/qemu-iotests/120 b/tests/qemu-iotests/120 | ||
80 | index XXXXXXX..XXXXXXX 100755 | ||
81 | --- a/tests/qemu-iotests/120 | ||
82 | +++ b/tests/qemu-iotests/120 | ||
83 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
84 | _supported_fmt generic | ||
85 | _supported_proto file | ||
86 | _unsupported_fmt luks | ||
87 | +_require_drivers raw | ||
88 | |||
89 | _make_test_img 64M | ||
90 | |||
91 | diff --git a/tests/qemu-iotests/162 b/tests/qemu-iotests/162 | ||
92 | index XXXXXXX..XXXXXXX 100755 | ||
93 | --- a/tests/qemu-iotests/162 | ||
94 | +++ b/tests/qemu-iotests/162 | ||
95 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
96 | . ./common.filter | ||
97 | |||
98 | _supported_fmt generic | ||
99 | - | ||
100 | -test_ssh=$($QEMU_IMG --help | grep '^Supported formats:.* ssh\( \|$\)') | ||
101 | -[ "$test_ssh" = "" ] && _notrun "ssh support required" | ||
102 | +_require_drivers ssh | ||
103 | |||
104 | echo | ||
105 | echo '=== NBD ===' | ||
106 | diff --git a/tests/qemu-iotests/184 b/tests/qemu-iotests/184 | ||
107 | index XXXXXXX..XXXXXXX 100755 | ||
108 | --- a/tests/qemu-iotests/184 | ||
109 | +++ b/tests/qemu-iotests/184 | ||
110 | @@ -XXX,XX +XXX,XX @@ trap "exit \$status" 0 1 2 3 15 | ||
111 | . ./common.filter | ||
112 | |||
113 | _supported_os Linux | ||
114 | +_require_drivers throttle | ||
115 | |||
116 | do_run_qemu() | ||
117 | { | ||
118 | diff --git a/tests/qemu-iotests/186 b/tests/qemu-iotests/186 | ||
119 | index XXXXXXX..XXXXXXX 100755 | ||
120 | --- a/tests/qemu-iotests/186 | ||
121 | +++ b/tests/qemu-iotests/186 | ||
122 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
123 | |||
124 | _supported_fmt qcow2 | ||
125 | _supported_proto file | ||
126 | +_require_drivers null-co | ||
127 | |||
128 | if [ "$QEMU_DEFAULT_MACHINE" != "pc" ]; then | ||
129 | _notrun "Requires a PC machine" | ||
130 | diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc | ||
21 | index XXXXXXX..XXXXXXX 100644 | 131 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/block/dataplane/virtio-blk.c | 132 | --- a/tests/qemu-iotests/common.rc |
23 | +++ b/hw/block/dataplane/virtio-blk.c | 133 | +++ b/tests/qemu-iotests/common.rc |
24 | @@ -XXX,XX +XXX,XX @@ int virtio_blk_data_plane_start(VirtIODevice *vdev) | 134 | @@ -XXX,XX +XXX,XX @@ _require_command() |
25 | return -ENOSYS; | 135 | [ -x "$c" ] || _notrun "$1 utility required, skipped this test" |
26 | } | 136 | } |
27 | 137 | ||
28 | +/* Stop notifications for new requests from guest. | 138 | +# Check that a set of drivers has been whitelisted in the QEMU binary |
29 | + * | 139 | +# |
30 | + * Context: BH in IOThread | 140 | +_require_drivers() |
31 | + */ | ||
32 | +static void virtio_blk_data_plane_stop_bh(void *opaque) | ||
33 | +{ | 141 | +{ |
34 | + VirtIOBlockDataPlane *s = opaque; | 142 | + available=$($QEMU -drive format=help | \ |
35 | + unsigned i; | 143 | + sed -e '/Supported formats:/!d' -e 's/Supported formats://') |
36 | + | 144 | + for driver |
37 | + for (i = 0; i < s->conf->num_queues; i++) { | 145 | + do |
38 | + VirtQueue *vq = virtio_get_queue(s->vdev, i); | 146 | + if ! echo "$available" | grep -q " $driver\( \|$\)"; then |
39 | + | 147 | + _notrun "$driver not available" |
40 | + virtio_queue_aio_set_host_notifier_handler(vq, s->ctx, NULL); | 148 | + fi |
41 | + } | 149 | + done |
42 | +} | 150 | +} |
43 | + | 151 | + |
44 | /* Context: QEMU global mutex held */ | 152 | # make sure this script returns success |
45 | void virtio_blk_data_plane_stop(VirtIODevice *vdev) | 153 | true |
46 | { | ||
47 | @@ -XXX,XX +XXX,XX @@ void virtio_blk_data_plane_stop(VirtIODevice *vdev) | ||
48 | trace_virtio_blk_data_plane_stop(s); | ||
49 | |||
50 | aio_context_acquire(s->ctx); | ||
51 | - | ||
52 | - /* Stop notifications for new requests from guest */ | ||
53 | - for (i = 0; i < nvqs; i++) { | ||
54 | - VirtQueue *vq = virtio_get_queue(s->vdev, i); | ||
55 | - | ||
56 | - virtio_queue_aio_set_host_notifier_handler(vq, s->ctx, NULL); | ||
57 | - } | ||
58 | + aio_wait_bh_oneshot(s->ctx, virtio_blk_data_plane_stop_bh, s); | ||
59 | |||
60 | /* Drain and switch bs back to the QEMU main loop */ | ||
61 | blk_set_aio_context(s->conf->conf.blk, qemu_get_aio_context()); | ||
62 | -- | 154 | -- |
63 | 2.14.3 | 155 | 2.21.0 |
64 | 156 | ||
65 | 157 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Thomas Huth <thuth@redhat.com> | ||
1 | 2 | ||
3 | The sanitizers (especially the address sanitizer from Clang) are | ||
4 | sometimes printing out warnings or false positives - this spoils | ||
5 | the output of the iotests, causing some of the tests to fail. | ||
6 | Thus let's skip the automatic iotests during "make check" when the | ||
7 | user configured QEMU with --enable-sanitizers. | ||
8 | |||
9 | Signed-off-by: Thomas Huth <thuth@redhat.com> | ||
10 | Message-id: 20190823084203.29734-1-thuth@redhat.com | ||
11 | Signed-off-by: Max Reitz <mreitz@redhat.com> | ||
12 | --- | ||
13 | tests/check-block.sh | 5 +++++ | ||
14 | 1 file changed, 5 insertions(+) | ||
15 | |||
16 | diff --git a/tests/check-block.sh b/tests/check-block.sh | ||
17 | index XXXXXXX..XXXXXXX 100755 | ||
18 | --- a/tests/check-block.sh | ||
19 | +++ b/tests/check-block.sh | ||
20 | @@ -XXX,XX +XXX,XX @@ if grep -q "TARGET_GPROF=y" *-softmmu/config-target.mak 2>/dev/null ; then | ||
21 | exit 0 | ||
22 | fi | ||
23 | |||
24 | +if grep -q "CFLAGS.*-fsanitize" config-host.mak 2>/dev/null ; then | ||
25 | + echo "Sanitizers are enabled ==> Not running the qemu-iotests." | ||
26 | + exit 0 | ||
27 | +fi | ||
28 | + | ||
29 | if [ -z "$(find . -name 'qemu-system-*' -print)" ]; then | ||
30 | echo "No qemu-system binary available ==> Not running the qemu-iotests." | ||
31 | exit 0 | ||
32 | -- | ||
33 | 2.21.0 | ||
34 | |||
35 | diff view generated by jsdifflib |
1 | From: Deepa Srinivasan <deepa.srinivasan@oracle.com> | 1 | From: Nir Soffer <nirsof@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | Starting qemu with the following arguments causes qemu to segfault: | 3 | Quoting cache mode is not needed, and most tests use unquoted values. |
4 | ... -device lsi,id=lsi0 -drive file=iscsi:<...>,format=raw,if=none,node-name= | 4 | Unify all test to use the same style. |
5 | iscsi1 -device scsi-block,bus=lsi0.0,id=<...>,drive=iscsi1 | ||
6 | 5 | ||
7 | This patch fixes blk_aio_ioctl() so it does not pass stack addresses to | 6 | Message-id: 20190827173432.7656-1-nsoffer@redhat.com |
8 | blk_aio_ioctl_entry() which may be invoked after blk_aio_ioctl() returns. More | 7 | Signed-off-by: Nir Soffer <nsoffer@redhat.com> |
9 | details about the bug follow. | 8 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
9 | --- | ||
10 | tests/qemu-iotests/026 | 4 ++-- | ||
11 | tests/qemu-iotests/039 | 4 ++-- | ||
12 | tests/qemu-iotests/052 | 2 +- | ||
13 | tests/qemu-iotests/091 | 4 ++-- | ||
14 | 4 files changed, 7 insertions(+), 7 deletions(-) | ||
10 | 15 | ||
11 | blk_aio_ioctl() invokes blk_aio_prwv() with blk_aio_ioctl_entry as the | 16 | diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026 |
12 | coroutine parameter. blk_aio_prwv() ultimately calls aio_co_enter(). | 17 | index XXXXXXX..XXXXXXX 100755 |
13 | 18 | --- a/tests/qemu-iotests/026 | |
14 | When blk_aio_ioctl() is executed from within a coroutine context (e.g. | 19 | +++ b/tests/qemu-iotests/026 |
15 | iscsi_bh_cb()), aio_co_enter() adds the coroutine (blk_aio_ioctl_entry) to | 20 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
16 | the current coroutine's wakeup queue. blk_aio_ioctl() then returns. | 21 | # Currently only qcow2 supports rebasing |
17 | 22 | _supported_fmt qcow2 | |
18 | When blk_aio_ioctl_entry() executes later, it accesses an invalid pointer: | 23 | _supported_proto file |
19 | .... | 24 | -_default_cache_mode "writethrough" |
20 | BlkRwCo *rwco = &acb->rwco; | 25 | -_supported_cache_modes "writethrough" "none" |
21 | 26 | +_default_cache_mode writethrough | |
22 | rwco->ret = blk_co_ioctl(rwco->blk, rwco->offset, | 27 | +_supported_cache_modes writethrough none |
23 | rwco->qiov->iov[0].iov_base); <--- qiov is | 28 | # The refcount table tests expect a certain minimum width for refcount entries |
24 | invalid here | 29 | # (so that the refcount table actually needs to grow); that minimum is 16 bits, |
25 | ... | 30 | # being the default refcount entry width. |
26 | 31 | diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039 | |
27 | In the case when blk_aio_ioctl() is called from a non-coroutine context, | 32 | index XXXXXXX..XXXXXXX 100755 |
28 | blk_aio_ioctl_entry() executes immediately. But if bdrv_co_ioctl() calls | 33 | --- a/tests/qemu-iotests/039 |
29 | qemu_coroutine_yield(), blk_aio_ioctl() will return. When the coroutine | 34 | +++ b/tests/qemu-iotests/039 |
30 | execution is complete, control returns to blk_aio_ioctl_entry() after the call | 35 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
31 | to blk_co_ioctl(). There is no invalid reference after this point, but the | 36 | _supported_fmt qcow2 |
32 | function is still holding on to invalid pointers. | 37 | _supported_proto file |
33 | 38 | _supported_os Linux | |
34 | The fix is to change blk_aio_prwv() to accept a void pointer for the IO buffer | 39 | -_default_cache_mode "writethrough" |
35 | rather than a QEMUIOVector. blk_aio_prwv() passes this through in BlkRwCo and the | 40 | -_supported_cache_modes "writethrough" |
36 | coroutine function casts it to QEMUIOVector or uses the void pointer directly. | 41 | +_default_cache_mode writethrough |
37 | 42 | +_supported_cache_modes writethrough | |
38 | Signed-off-by: Deepa Srinivasan <deepa.srinivasan@oracle.com> | 43 | |
39 | Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 44 | size=128M |
40 | Reviewed-by: Mark Kanda <mark.kanda@oracle.com> | 45 | |
41 | Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> | 46 | diff --git a/tests/qemu-iotests/052 b/tests/qemu-iotests/052 |
42 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 47 | index XXXXXXX..XXXXXXX 100755 |
43 | --- | 48 | --- a/tests/qemu-iotests/052 |
44 | block/block-backend.c | 51 +++++++++++++++++++++++++-------------------------- | 49 | +++ b/tests/qemu-iotests/052 |
45 | 1 file changed, 25 insertions(+), 26 deletions(-) | 50 | @@ -XXX,XX +XXX,XX @@ _supported_fmt generic |
46 | 51 | _supported_proto file | |
47 | diff --git a/block/block-backend.c b/block/block-backend.c | 52 | |
48 | index XXXXXXX..XXXXXXX 100644 | 53 | # Don't do O_DIRECT on tmpfs |
49 | --- a/block/block-backend.c | 54 | -_supported_cache_modes "writeback" "writethrough" "unsafe" |
50 | +++ b/block/block-backend.c | 55 | +_supported_cache_modes writeback writethrough unsafe |
51 | @@ -XXX,XX +XXX,XX @@ int coroutine_fn blk_co_pwritev(BlockBackend *blk, int64_t offset, | 56 | |
52 | typedef struct BlkRwCo { | 57 | size=128M |
53 | BlockBackend *blk; | 58 | _make_test_img $size |
54 | int64_t offset; | 59 | diff --git a/tests/qemu-iotests/091 b/tests/qemu-iotests/091 |
55 | - QEMUIOVector *qiov; | 60 | index XXXXXXX..XXXXXXX 100755 |
56 | + void *iobuf; | 61 | --- a/tests/qemu-iotests/091 |
57 | int ret; | 62 | +++ b/tests/qemu-iotests/091 |
58 | BdrvRequestFlags flags; | 63 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
59 | } BlkRwCo; | 64 | _supported_fmt qcow2 |
60 | @@ -XXX,XX +XXX,XX @@ typedef struct BlkRwCo { | 65 | _supported_proto file |
61 | static void blk_read_entry(void *opaque) | 66 | _supported_os Linux |
62 | { | 67 | -_default_cache_mode "none" |
63 | BlkRwCo *rwco = opaque; | 68 | -_supported_cache_modes "writethrough" "none" "writeback" |
64 | + QEMUIOVector *qiov = rwco->iobuf; | 69 | +_default_cache_mode none |
65 | 70 | +_supported_cache_modes writethrough none writeback | |
66 | - rwco->ret = blk_co_preadv(rwco->blk, rwco->offset, rwco->qiov->size, | 71 | |
67 | - rwco->qiov, rwco->flags); | 72 | size=1G |
68 | + rwco->ret = blk_co_preadv(rwco->blk, rwco->offset, qiov->size, | 73 | |
69 | + qiov, rwco->flags); | ||
70 | } | ||
71 | |||
72 | static void blk_write_entry(void *opaque) | ||
73 | { | ||
74 | BlkRwCo *rwco = opaque; | ||
75 | + QEMUIOVector *qiov = rwco->iobuf; | ||
76 | |||
77 | - rwco->ret = blk_co_pwritev(rwco->blk, rwco->offset, rwco->qiov->size, | ||
78 | - rwco->qiov, rwco->flags); | ||
79 | + rwco->ret = blk_co_pwritev(rwco->blk, rwco->offset, qiov->size, | ||
80 | + qiov, rwco->flags); | ||
81 | } | ||
82 | |||
83 | static int blk_prw(BlockBackend *blk, int64_t offset, uint8_t *buf, | ||
84 | @@ -XXX,XX +XXX,XX @@ static int blk_prw(BlockBackend *blk, int64_t offset, uint8_t *buf, | ||
85 | rwco = (BlkRwCo) { | ||
86 | .blk = blk, | ||
87 | .offset = offset, | ||
88 | - .qiov = &qiov, | ||
89 | + .iobuf = &qiov, | ||
90 | .flags = flags, | ||
91 | .ret = NOT_DONE, | ||
92 | }; | ||
93 | @@ -XXX,XX +XXX,XX @@ static void blk_aio_complete_bh(void *opaque) | ||
94 | } | ||
95 | |||
96 | static BlockAIOCB *blk_aio_prwv(BlockBackend *blk, int64_t offset, int bytes, | ||
97 | - QEMUIOVector *qiov, CoroutineEntry co_entry, | ||
98 | + void *iobuf, CoroutineEntry co_entry, | ||
99 | BdrvRequestFlags flags, | ||
100 | BlockCompletionFunc *cb, void *opaque) | ||
101 | { | ||
102 | @@ -XXX,XX +XXX,XX @@ static BlockAIOCB *blk_aio_prwv(BlockBackend *blk, int64_t offset, int bytes, | ||
103 | acb->rwco = (BlkRwCo) { | ||
104 | .blk = blk, | ||
105 | .offset = offset, | ||
106 | - .qiov = qiov, | ||
107 | + .iobuf = iobuf, | ||
108 | .flags = flags, | ||
109 | .ret = NOT_DONE, | ||
110 | }; | ||
111 | @@ -XXX,XX +XXX,XX @@ static void blk_aio_read_entry(void *opaque) | ||
112 | { | ||
113 | BlkAioEmAIOCB *acb = opaque; | ||
114 | BlkRwCo *rwco = &acb->rwco; | ||
115 | + QEMUIOVector *qiov = rwco->iobuf; | ||
116 | |||
117 | - assert(rwco->qiov->size == acb->bytes); | ||
118 | + assert(qiov->size == acb->bytes); | ||
119 | rwco->ret = blk_co_preadv(rwco->blk, rwco->offset, acb->bytes, | ||
120 | - rwco->qiov, rwco->flags); | ||
121 | + qiov, rwco->flags); | ||
122 | blk_aio_complete(acb); | ||
123 | } | ||
124 | |||
125 | @@ -XXX,XX +XXX,XX @@ static void blk_aio_write_entry(void *opaque) | ||
126 | { | ||
127 | BlkAioEmAIOCB *acb = opaque; | ||
128 | BlkRwCo *rwco = &acb->rwco; | ||
129 | + QEMUIOVector *qiov = rwco->iobuf; | ||
130 | |||
131 | - assert(!rwco->qiov || rwco->qiov->size == acb->bytes); | ||
132 | + assert(!qiov || qiov->size == acb->bytes); | ||
133 | rwco->ret = blk_co_pwritev(rwco->blk, rwco->offset, acb->bytes, | ||
134 | - rwco->qiov, rwco->flags); | ||
135 | + qiov, rwco->flags); | ||
136 | blk_aio_complete(acb); | ||
137 | } | ||
138 | |||
139 | @@ -XXX,XX +XXX,XX @@ int blk_co_ioctl(BlockBackend *blk, unsigned long int req, void *buf) | ||
140 | static void blk_ioctl_entry(void *opaque) | ||
141 | { | ||
142 | BlkRwCo *rwco = opaque; | ||
143 | + QEMUIOVector *qiov = rwco->iobuf; | ||
144 | + | ||
145 | rwco->ret = blk_co_ioctl(rwco->blk, rwco->offset, | ||
146 | - rwco->qiov->iov[0].iov_base); | ||
147 | + qiov->iov[0].iov_base); | ||
148 | } | ||
149 | |||
150 | int blk_ioctl(BlockBackend *blk, unsigned long int req, void *buf) | ||
151 | @@ -XXX,XX +XXX,XX @@ static void blk_aio_ioctl_entry(void *opaque) | ||
152 | BlkAioEmAIOCB *acb = opaque; | ||
153 | BlkRwCo *rwco = &acb->rwco; | ||
154 | |||
155 | - rwco->ret = blk_co_ioctl(rwco->blk, rwco->offset, | ||
156 | - rwco->qiov->iov[0].iov_base); | ||
157 | + rwco->ret = blk_co_ioctl(rwco->blk, rwco->offset, rwco->iobuf); | ||
158 | + | ||
159 | blk_aio_complete(acb); | ||
160 | } | ||
161 | |||
162 | BlockAIOCB *blk_aio_ioctl(BlockBackend *blk, unsigned long int req, void *buf, | ||
163 | BlockCompletionFunc *cb, void *opaque) | ||
164 | { | ||
165 | - QEMUIOVector qiov; | ||
166 | - struct iovec iov; | ||
167 | - | ||
168 | - iov = (struct iovec) { | ||
169 | - .iov_base = buf, | ||
170 | - .iov_len = 0, | ||
171 | - }; | ||
172 | - qemu_iovec_init_external(&qiov, &iov, 1); | ||
173 | - | ||
174 | - return blk_aio_prwv(blk, req, 0, &qiov, blk_aio_ioctl_entry, 0, cb, opaque); | ||
175 | + return blk_aio_prwv(blk, req, 0, buf, blk_aio_ioctl_entry, 0, cb, opaque); | ||
176 | } | ||
177 | |||
178 | int blk_co_pdiscard(BlockBackend *blk, int64_t offset, int bytes) | ||
179 | @@ -XXX,XX +XXX,XX @@ int blk_truncate(BlockBackend *blk, int64_t offset, PreallocMode prealloc, | ||
180 | static void blk_pdiscard_entry(void *opaque) | ||
181 | { | ||
182 | BlkRwCo *rwco = opaque; | ||
183 | - rwco->ret = blk_co_pdiscard(rwco->blk, rwco->offset, rwco->qiov->size); | ||
184 | + QEMUIOVector *qiov = rwco->iobuf; | ||
185 | + | ||
186 | + rwco->ret = blk_co_pdiscard(rwco->blk, rwco->offset, qiov->size); | ||
187 | } | ||
188 | |||
189 | int blk_pdiscard(BlockBackend *blk, int64_t offset, int bytes) | ||
190 | -- | 74 | -- |
191 | 2.14.3 | 75 | 2.21.0 |
192 | 76 | ||
193 | 77 | diff view generated by jsdifflib |