1
The following changes since commit bfec359afba088aaacc7d316f43302f28c6e642a:
1
The following changes since commit 54b89db5309d5fa8b5d3fe5fe56f81704e2f9706:
2
2
3
Merge remote-tracking branch 'remotes/armbru/tags/pull-qdev-2017-04-21' into staging (2017-04-21 11:42:03 +0100)
3
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging (2019-09-03 09:43:26 +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/codyprime/qemu-kvm-jtc.git tags/block-pull-request
7
https://github.com/XanClic/qemu.git tags/pull-block-2019-09-03
8
8
9
for you to fetch changes up to 1507631e438930bc07f776f303af127a9cdb4d41:
9
for you to fetch changes up to 755c5fe79d88717600356d3edf04835bba43dcb6:
10
10
11
qemu-iotests: _cleanup_qemu must be called on exit (2017-04-21 08:32:44 -0400)
11
iotests: Unify cache mode quoting (2019-09-03 14:56:06 +0200)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
14
Block patches:
15
Block patches for 2.10
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
16
19
17
----------------------------------------------------------------
20
----------------------------------------------------------------
21
v2:
22
- Added a patch we already had on the list to keep the iotests passing
23
when $DISPLAY is not set
18
24
19
Ashish Mittal (2):
25
----------------------------------------------------------------
20
block/vxhs.c: Add support for a new block device type called "vxhs"
26
Denis Plotnikov (1):
21
block/vxhs.c: Add qemu-iotests for new block device type "vxhs"
27
qemu-io: add pattern file for write command
22
28
23
Jeff Cody (10):
29
Max Reitz (8):
24
qemu-iotests: exclude vxhs from image creation via protocol
30
iotests: Fix _filter_img_create()
25
block: add bdrv_set_read_only() helper function
31
vmdk: Use bdrv_dirname() for relative extent paths
26
block: do not set BDS read_only if copy_on_read enabled
32
iotests: Keep testing broken relative extent paths
27
block: honor BDRV_O_ALLOW_RDWR when clearing bs->read_only
33
vmdk: Reject invalid compressed writes
28
block: code movement
34
iotests: Disable broken streamOptimized tests
29
block: introduce bdrv_can_set_read_only()
35
iotests: Disable 110 for vmdk.twoGbMaxExtentSparse
30
block: use bdrv_can_set_read_only() during reopen
36
iotests: Disable 126 for flat vmdk subformats
31
block/rbd - update variable names to more apt names
37
iotests: Add -display none to the qemu options
32
block/rbd: Add support for reopen()
33
qemu-iotests: _cleanup_qemu must be called on exit
34
38
35
block.c | 56 +++-
39
Nir Soffer (3):
36
block/Makefile.objs | 2 +
40
block: posix: Always allocate the first block
37
block/bochs.c | 5 +-
41
iotests: Test allocate_first_block() with O_DIRECT
38
block/cloop.c | 5 +-
42
iotests: Unify cache mode quoting
39
block/dmg.c | 6 +-
43
40
block/rbd.c | 65 +++--
44
Stefan Hajnoczi (1):
41
block/trace-events | 17 ++
45
file-posix: fix request_alignment typo
42
block/vvfat.c | 19 +-
46
43
block/vxhs.c | 575 +++++++++++++++++++++++++++++++++++++++
47
Thomas Huth (2):
44
configure | 39 +++
48
iotests: Check for enabled drivers before testing them
45
include/block/block.h | 2 +
49
tests/check-block: Skip iotests when sanitizers are enabled
46
qapi/block-core.json | 23 +-
50
47
tests/qemu-iotests/017 | 1 +
51
Vladimir Sementsov-Ogievskiy (1):
48
tests/qemu-iotests/020 | 1 +
52
block: fix permission update in bdrv_replace_node
49
tests/qemu-iotests/028 | 1 +
53
50
tests/qemu-iotests/029 | 1 +
54
block.c | 5 +-
51
tests/qemu-iotests/073 | 1 +
55
block/file-posix.c | 53 +++++++++-
52
tests/qemu-iotests/094 | 11 +-
56
block/vmdk.c | 64 ++++++++----
53
tests/qemu-iotests/102 | 5 +-
57
qemu-io-cmds.c | 99 +++++++++++++++++--
54
tests/qemu-iotests/109 | 1 +
58
tests/check-block.sh | 5 +
55
tests/qemu-iotests/114 | 1 +
59
tests/qemu-iotests/002 | 1 +
56
tests/qemu-iotests/117 | 1 +
60
tests/qemu-iotests/003 | 1 +
57
tests/qemu-iotests/130 | 2 +
61
tests/qemu-iotests/005 | 3 +-
58
tests/qemu-iotests/134 | 1 +
62
tests/qemu-iotests/009 | 1 +
59
tests/qemu-iotests/140 | 1 +
63
tests/qemu-iotests/010 | 1 +
60
tests/qemu-iotests/141 | 1 +
64
tests/qemu-iotests/011 | 1 +
61
tests/qemu-iotests/143 | 1 +
65
tests/qemu-iotests/017 | 3 +-
62
tests/qemu-iotests/156 | 2 +
66
tests/qemu-iotests/018 | 3 +-
63
tests/qemu-iotests/158 | 1 +
67
tests/qemu-iotests/019 | 3 +-
64
tests/qemu-iotests/common | 6 +
68
tests/qemu-iotests/020 | 3 +-
65
tests/qemu-iotests/common.config | 13 +
69
tests/qemu-iotests/026 | 4 +-
66
tests/qemu-iotests/common.filter | 1 +
70
tests/qemu-iotests/027 | 1 +
67
tests/qemu-iotests/common.rc | 19 ++
71
tests/qemu-iotests/032 | 1 +
68
33 files changed, 844 insertions(+), 42 deletions(-)
72
tests/qemu-iotests/033 | 1 +
69
create mode 100644 block/vxhs.c
73
tests/qemu-iotests/034 | 3 +-
74
tests/qemu-iotests/037 | 3 +-
75
tests/qemu-iotests/039 | 4 +-
76
tests/qemu-iotests/052 | 2 +-
77
tests/qemu-iotests/059 | 34 ++++++-
78
tests/qemu-iotests/059.out | 26 +++--
79
tests/qemu-iotests/063 | 3 +-
80
tests/qemu-iotests/071 | 1 +
81
tests/qemu-iotests/072 | 1 +
82
tests/qemu-iotests/081 | 4 +-
83
tests/qemu-iotests/091 | 4 +-
84
tests/qemu-iotests/099 | 1 +
85
tests/qemu-iotests/105 | 3 +-
86
tests/qemu-iotests/110 | 3 +-
87
tests/qemu-iotests/120 | 1 +
88
tests/qemu-iotests/126 | 2 +
89
tests/qemu-iotests/{150.out => 150.out.qcow2} | 0
90
tests/qemu-iotests/150.out.raw | 12 +++
91
tests/qemu-iotests/162 | 4 +-
92
tests/qemu-iotests/175 | 47 +++++++--
93
tests/qemu-iotests/175.out | 16 ++-
94
tests/qemu-iotests/178.out.qcow2 | 4 +-
95
tests/qemu-iotests/184 | 1 +
96
tests/qemu-iotests/186 | 1 +
97
tests/qemu-iotests/197 | 1 +
98
tests/qemu-iotests/215 | 1 +
99
tests/qemu-iotests/221.out | 12 ++-
100
tests/qemu-iotests/251 | 1 +
101
tests/qemu-iotests/253.out | 12 ++-
102
tests/qemu-iotests/check | 6 +-
103
tests/qemu-iotests/common.filter | 4 +-
104
tests/qemu-iotests/common.rc | 14 +++
105
51 files changed, 394 insertions(+), 90 deletions(-)
106
rename tests/qemu-iotests/{150.out => 150.out.qcow2} (100%)
107
create mode 100644 tests/qemu-iotests/150.out.raw
70
108
71
--
109
--
72
2.9.3
110
2.21.0
73
111
74
112
diff view generated by jsdifflib
1
A few block drivers will set the BDS read_only flag from their
1
From: Denis Plotnikov <dplotnikov@virtuozzo.com>
2
.bdrv_open() function. This means the bs->read_only flag could
3
be set after we enable copy_on_read, as the BDRV_O_COPY_ON_READ
4
flag check occurs prior to the call to bdrv->bdrv_open().
5
2
6
This adds an error return to bdrv_set_read_only(), and an error will be
3
The patch allows to provide a pattern file for write
7
return if we try to set the BDS to read_only while copy_on_read is
4
command. There was no similar ability before.
8
enabled.
9
5
10
This patch also changes the behavior of vvfat. Before, vvfat could
6
Signed-off-by: Denis Plotnikov <dplotnikov@virtuozzo.com>
11
override the drive 'readonly' flag with its own, internal 'rw' flag.
7
Message-id: 20190820164616.4072-1-dplotnikov@virtuozzo.com
8
Reviewed-by: Eric Blake <eblake@redhat.com>
9
[mreitz: Keep optstring in alphabetical order]
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
11
---
12
qemu-io-cmds.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++---
13
1 file changed, 93 insertions(+), 6 deletions(-)
12
14
13
For instance, this -drive parameter would result in a writable image:
15
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
14
15
"-drive format=vvfat,dir=/tmp/vvfat,rw,if=virtio,readonly=on"
16
17
This is not correct. Now, attempting to use the above -drive parameter
18
will result in an error (i.e., 'rw' is incompatible with 'readonly=on').
19
20
Signed-off-by: Jeff Cody <jcody@redhat.com>
21
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
22
Reviewed-by: John Snow <jsnow@redhat.com>
23
Message-id: 0c5b4c1cc2c651471b131f21376dfd5ea24d2196.1491597120.git.jcody@redhat.com
24
---
25
block.c | 10 +++++++++-
26
block/bochs.c | 5 ++++-
27
block/cloop.c | 5 ++++-
28
block/dmg.c | 6 +++++-
29
block/rbd.c | 11 ++++++++++-
30
block/vvfat.c | 19 +++++++++++++++----
31
include/block/block.h | 2 +-
32
7 files changed, 48 insertions(+), 10 deletions(-)
33
34
diff --git a/block.c b/block.c
35
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
36
--- a/block.c
17
--- a/qemu-io-cmds.c
37
+++ b/block.c
18
+++ b/qemu-io-cmds.c
38
@@ -XXX,XX +XXX,XX @@ void path_combine(char *dest, int dest_size,
19
@@ -XXX,XX +XXX,XX @@ static void qemu_io_free(void *p)
39
}
20
qemu_vfree(p);
40
}
21
}
41
22
42
-void bdrv_set_read_only(BlockDriverState *bs, bool read_only)
23
+/*
43
+int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
24
+ * qemu_io_alloc_from_file()
44
{
25
+ *
45
+ /* Do not set read_only if copy_on_read is enabled */
26
+ * Allocates the buffer and populates it with the content of the given file
46
+ if (bs->copy_on_read && read_only) {
27
+ * up to @len bytes. If the file length is less than @len, then the buffer
47
+ error_setg(errp, "Can't set node '%s' to r/o with copy-on-read enabled",
28
+ * is populated with the file content cyclically.
48
+ bdrv_get_device_or_node_name(bs));
29
+ *
49
+ return -EINVAL;
30
+ * @blk - the block backend where the buffer content is going to be written to
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;
50
+ }
47
+ }
51
+
48
+
52
bs->read_only = read_only;
49
+ if (qemuio_misalign) {
53
+ return 0;
50
+ len += MISALIGN_OFFSET;
54
}
51
+ }
55
52
+
56
void bdrv_get_full_backing_filename_from_filename(const char *backed,
53
+ buf_origin = buf = blk_blockalign(blk, len);
57
diff --git a/block/bochs.c b/block/bochs.c
54
+
58
index XXXXXXX..XXXXXXX 100644
55
+ if (qemuio_misalign) {
59
--- a/block/bochs.c
56
+ buf_origin += MISALIGN_OFFSET;
60
+++ b/block/bochs.c
57
+ buf += MISALIGN_OFFSET;
61
@@ -XXX,XX +XXX,XX @@ static int bochs_open(BlockDriverState *bs, QDict *options, int flags,
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)
62
return -EINVAL;
148
return -EINVAL;
63
}
149
}
64
150
65
- bdrv_set_read_only(bs, true); /* no write support yet */
151
- if (zflag && Pflag) {
66
+ ret = bdrv_set_read_only(bs, true, errp); /* no write support yet */
152
- printf("-z and -P cannot be specified at the same time\n");
67
+ if (ret < 0) {
153
+ if (zflag + Pflag + sflag > 1) {
68
+ return ret;
154
+ printf("Only one of -z, -P, and -s "
69
+ }
155
+ "can be specified at the same time\n");
70
71
ret = bdrv_pread(bs->file, 0, &bochs, sizeof(bochs));
72
if (ret < 0) {
73
diff --git a/block/cloop.c b/block/cloop.c
74
index XXXXXXX..XXXXXXX 100644
75
--- a/block/cloop.c
76
+++ b/block/cloop.c
77
@@ -XXX,XX +XXX,XX @@ static int cloop_open(BlockDriverState *bs, QDict *options, int flags,
78
return -EINVAL;
156
return -EINVAL;
79
}
157
}
80
158
81
- bdrv_set_read_only(bs, true);
159
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
82
+ ret = bdrv_set_read_only(bs, true, errp);
83
+ if (ret < 0) {
84
+ return ret;
85
+ }
86
87
/* read header */
88
ret = bdrv_pread(bs->file, 128, &s->block_size, 4);
89
diff --git a/block/dmg.c b/block/dmg.c
90
index XXXXXXX..XXXXXXX 100644
91
--- a/block/dmg.c
92
+++ b/block/dmg.c
93
@@ -XXX,XX +XXX,XX @@ static int dmg_open(BlockDriverState *bs, QDict *options, int flags,
94
return -EINVAL;
95
}
160
}
96
161
97
+ ret = bdrv_set_read_only(bs, true, errp);
162
if (!zflag) {
98
+ if (ret < 0) {
163
- buf = qemu_io_alloc(blk, count, pattern);
99
+ return ret;
164
+ if (sflag) {
100
+ }
165
+ buf = qemu_io_alloc_from_file(blk, count, file_name);
101
+
166
+ if (!buf) {
102
block_module_load_one("dmg-bz2");
167
+ return -EINVAL;
103
- bdrv_set_read_only(bs, true);
104
105
s->n_chunks = 0;
106
s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL;
107
diff --git a/block/rbd.c b/block/rbd.c
108
index XXXXXXX..XXXXXXX 100644
109
--- a/block/rbd.c
110
+++ b/block/rbd.c
111
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
112
goto failed_shutdown;
113
}
114
115
+ /* rbd_open is always r/w */
116
r = rbd_open(s->io_ctx, s->name, &s->image, s->snap);
117
if (r < 0) {
118
error_setg_errno(errp, -r, "error reading header from %s", s->name);
119
goto failed_open;
120
}
121
122
- bdrv_set_read_only(bs, (s->snap != NULL));
123
+ /* If we are using an rbd snapshot, we must be r/o, otherwise
124
+ * leave as-is */
125
+ if (s->snap != NULL) {
126
+ r = bdrv_set_read_only(bs, true, &local_err);
127
+ if (r < 0) {
128
+ error_propagate(errp, local_err);
129
+ goto failed_open;
130
+ }
131
+ }
132
133
qemu_opts_del(opts);
134
return 0;
135
diff --git a/block/vvfat.c b/block/vvfat.c
136
index XXXXXXX..XXXXXXX 100644
137
--- a/block/vvfat.c
138
+++ b/block/vvfat.c
139
@@ -XXX,XX +XXX,XX @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
140
141
s->current_cluster=0xffffffff;
142
143
- /* read only is the default for safety */
144
- bdrv_set_read_only(bs, true);
145
s->qcow = NULL;
146
s->qcow_filename = NULL;
147
s->fat2 = NULL;
148
@@ -XXX,XX +XXX,XX @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
149
s->sector_count = cyls * heads * secs - (s->first_sectors_number - 1);
150
151
if (qemu_opt_get_bool(opts, "rw", false)) {
152
- ret = enable_write_target(bs, errp);
153
+ if (!bdrv_is_read_only(bs)) {
154
+ ret = enable_write_target(bs, errp);
155
+ if (ret < 0) {
156
+ goto fail;
157
+ }
168
+ }
158
+ } else {
169
+ } else {
159
+ ret = -EPERM;
170
+ buf = qemu_io_alloc(blk, count, pattern);
160
+ error_setg(errp,
161
+ "Unable to set VVFAT to 'rw' when drive is read-only");
162
+ goto fail;
163
+ }
171
+ }
164
+ } else {
165
+ /* read only is the default for safety */
166
+ ret = bdrv_set_read_only(bs, true, &local_err);
167
if (ret < 0) {
168
+ error_propagate(errp, local_err);
169
goto fail;
170
}
171
- bdrv_set_read_only(bs, false);
172
}
172
}
173
173
174
bs->total_sectors = cyls * heads * secs;
174
clock_gettime(CLOCK_MONOTONIC, &t1);
175
diff --git a/include/block/block.h b/include/block/block.h
176
index XXXXXXX..XXXXXXX 100644
177
--- a/include/block/block.h
178
+++ b/include/block/block.h
179
@@ -XXX,XX +XXX,XX @@ int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base,
180
int64_t sector_num, int nb_sectors, int *pnum);
181
182
bool bdrv_is_read_only(BlockDriverState *bs);
183
-void bdrv_set_read_only(BlockDriverState *bs, bool read_only);
184
+int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp);
185
bool bdrv_is_sg(BlockDriverState *bs);
186
bool bdrv_is_inserted(BlockDriverState *bs);
187
int bdrv_media_changed(BlockDriverState *bs);
188
--
175
--
189
2.9.3
176
2.21.0
190
177
191
178
diff view generated by jsdifflib
1
The BDRV_O_ALLOW_RDWR flag allows / prohibits the changing of
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
2
the BDS 'read_only' state, but there are a few places where it
3
is ignored. In the bdrv_set_read_only() helper, make sure to
4
honor the flag.
5
2
6
Signed-off-by: Jeff Cody <jcody@redhat.com>
3
It's wrong to OR shared permissions. It may lead to crash on further
7
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
4
permission updates.
8
Reviewed-by: John Snow <jsnow@redhat.com>
5
Also, no needs to consider previously calculated permissions, as at
9
Message-id: be2e5fb2d285cbece2b6d06bed54a6f56520d251.1491597120.git.jcody@redhat.com
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>
10
---
15
---
11
block.c | 7 +++++++
16
block.c | 5 ++---
12
1 file changed, 7 insertions(+)
17
1 file changed, 2 insertions(+), 3 deletions(-)
13
18
14
diff --git a/block.c b/block.c
19
diff --git a/block.c b/block.c
15
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
16
--- a/block.c
21
--- a/block.c
17
+++ b/block.c
22
+++ b/block.c
18
@@ -XXX,XX +XXX,XX @@ int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
23
@@ -XXX,XX +XXX,XX @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
19
return -EINVAL;
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);
20
}
33
}
21
34
22
+ /* Do not clear read_only if it is prohibited */
35
- bdrv_get_cumulative_perm(to, &old_perm, &old_shared);
23
+ if (!read_only && !(bs->open_flags & BDRV_O_ALLOW_RDWR)) {
36
- bdrv_set_perm(to, old_perm | perm, old_shared | shared);
24
+ error_setg(errp, "Node '%s' is read only",
37
+ bdrv_get_cumulative_perm(to, &perm, &shared);
25
+ bdrv_get_device_or_node_name(bs));
38
+ bdrv_set_perm(to, perm, shared);
26
+ return -EPERM;
39
27
+ }
40
out:
28
+
41
g_slist_free(list);
29
bs->read_only = read_only;
30
return 0;
31
}
32
--
42
--
33
2.9.3
43
2.21.0
34
44
35
45
diff view generated by jsdifflib
1
Move bdrv_is_read_only() up with its friends.
1
From: Nir Soffer <nirsof@gmail.com>
2
2
3
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
3
When creating an image with preallocation "off" or "falloc", the first
4
Reviewed-by: John Snow <jsnow@redhat.com>
4
block of the image is typically not allocated. When using Gluster
5
Signed-off-by: Jeff Cody <jcody@redhat.com>
5
storage backed by XFS filesystem, reading this block using direct I/O
6
Message-id: 73b2399459760c32506f9407efb9dddb3a2789de.1491597120.git.jcody@redhat.com
6
succeeds regardless of request length, fooling alignment detection.
7
8
In this case we fallback to a safe value (4096) instead of the optimal
9
value (512), which may lead to unneeded data copying when aligning
10
requests. Allocating the first block avoids the fallback.
11
12
Since we allocate the first block even with preallocation=off, we no
13
longer create images with zero disk size:
14
15
$ ./qemu-img create -f raw test.raw 1g
16
Formatting 'test.raw', fmt=raw size=1073741824
17
18
$ ls -lhs test.raw
19
4.0K -rw-r--r--. 1 nsoffer nsoffer 1.0G Aug 16 23:48 test.raw
20
21
And converting the image requires additional cluster:
22
23
$ ./qemu-img measure -f raw -O qcow2 test.raw
24
required size: 458752
25
fully allocated size: 1074135040
26
27
When using format like vmdk with multiple files per image, we allocate
28
one block per file:
29
30
$ ./qemu-img create -f vmdk -o subformat=twoGbMaxExtentFlat test.vmdk 4g
31
Formatting 'test.vmdk', fmt=vmdk size=4294967296 compat6=off hwversion=undefined subformat=twoGbMaxExtentFlat
32
33
$ ls -lhs test*.vmdk
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>
7
---
61
---
8
block.c | 10 +++++-----
62
block/file-posix.c | 51 +++++++++++++++++++
9
1 file changed, 5 insertions(+), 5 deletions(-)
63
tests/qemu-iotests/059.out | 2 +-
10
64
tests/qemu-iotests/{150.out => 150.out.qcow2} | 0
11
diff --git a/block.c b/block.c
65
tests/qemu-iotests/150.out.raw | 12 +++++
12
index XXXXXXX..XXXXXXX 100644
66
tests/qemu-iotests/175 | 19 ++++---
13
--- a/block.c
67
tests/qemu-iotests/175.out | 8 +--
14
+++ b/block.c
68
tests/qemu-iotests/178.out.qcow2 | 4 +-
15
@@ -XXX,XX +XXX,XX @@ void path_combine(char *dest, int dest_size,
69
tests/qemu-iotests/221.out | 12 +++--
16
}
70
tests/qemu-iotests/253.out | 12 +++--
71
9 files changed, 99 insertions(+), 21 deletions(-)
72
rename tests/qemu-iotests/{150.out => 150.out.qcow2} (100%)
73
create mode 100644 tests/qemu-iotests/150.out.raw
74
75
diff --git a/block/file-posix.c b/block/file-posix.c
76
index XXXXXXX..XXXXXXX 100644
77
--- a/block/file-posix.c
78
+++ b/block/file-posix.c
79
@@ -XXX,XX +XXX,XX @@ static int handle_aiocb_discard(void *opaque)
80
return ret;
17
}
81
}
18
82
19
+bool bdrv_is_read_only(BlockDriverState *bs)
83
+/*
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.
96
+ */
97
+static int allocate_first_block(int fd, size_t max_size)
20
+{
98
+{
21
+ return bs->read_only;
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;
22
+}
118
+}
23
+
119
+
24
int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
120
static int handle_aiocb_truncate(void *opaque)
25
{
121
{
26
/* Do not set read_only if copy_on_read is enabled */
122
RawPosixAIOData *aiocb = opaque;
27
@@ -XXX,XX +XXX,XX @@ void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr)
123
@@ -XXX,XX +XXX,XX @@ static int handle_aiocb_truncate(void *opaque)
28
*nb_sectors_ptr = nb_sectors < 0 ? 0 : nb_sectors;
124
/* posix_fallocate() doesn't set errno. */
125
error_setg_errno(errp, -result,
126
"Could not preallocate new data");
127
+ } else if (current_length == 0) {
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/"
29
}
208
}
30
209
31
-bool bdrv_is_read_only(BlockDriverState *bs)
210
# get standard environment, filters and checks
32
-{
211
@@ -XXX,XX +XXX,XX @@ size=$((1 * 1024 * 1024))
33
- return bs->read_only;
212
touch "$TEST_DIR/empty"
34
-}
213
extra_blocks=$(stat -c '%b' "$TEST_DIR/empty")
35
-
214
36
bool bdrv_is_sg(BlockDriverState *bs)
215
+# We always write the first byte; check how many blocks this filesystem
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
37
{
277
{
38
return bs->sg;
278
- "required": 393216,
279
+ "required": 458752,
280
"fully-allocated": 1074135040
281
}
282
wrote 512/512 bytes at offset 512
283
diff --git a/tests/qemu-iotests/221.out b/tests/qemu-iotests/221.out
284
index XXXXXXX..XXXXXXX 100644
285
--- a/tests/qemu-iotests/221.out
286
+++ b/tests/qemu-iotests/221.out
287
@@ -XXX,XX +XXX,XX @@ QA output created by 221
288
=== Check mapping of unaligned raw image ===
289
290
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=65537
291
-[{ "start": 0, "length": 66048, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
292
-[{ "start": 0, "length": 66048, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
293
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
294
+{ "start": 4096, "length": 61952, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
295
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
296
+{ "start": 4096, "length": 61952, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
297
wrote 1/1 bytes at offset 65536
298
1 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
299
-[{ "start": 0, "length": 65536, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
300
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
301
+{ "start": 4096, "length": 61440, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
302
{ "start": 65536, "length": 1, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
303
{ "start": 65537, "length": 511, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
304
-[{ "start": 0, "length": 65536, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
305
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
306
+{ "start": 4096, "length": 61440, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
307
{ "start": 65536, "length": 1, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
308
{ "start": 65537, "length": 511, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
309
*** done
310
diff --git a/tests/qemu-iotests/253.out b/tests/qemu-iotests/253.out
311
index XXXXXXX..XXXXXXX 100644
312
--- a/tests/qemu-iotests/253.out
313
+++ b/tests/qemu-iotests/253.out
314
@@ -XXX,XX +XXX,XX @@ QA output created by 253
315
=== Check mapping of unaligned raw image ===
316
317
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048575
318
-[{ "start": 0, "length": 1048576, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
319
-[{ "start": 0, "length": 1048576, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
320
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
321
+{ "start": 4096, "length": 1044480, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
322
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
323
+{ "start": 4096, "length": 1044480, "depth": 0, "zero": true, "data": false, "offset": OFFSET}]
324
wrote 65535/65535 bytes at offset 983040
325
63.999 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
326
-[{ "start": 0, "length": 983040, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
327
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
328
+{ "start": 4096, "length": 978944, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
329
{ "start": 983040, "length": 65536, "depth": 0, "zero": false, "data": true, "offset": OFFSET}]
330
-[{ "start": 0, "length": 983040, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
331
+[{ "start": 0, "length": 4096, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
332
+{ "start": 4096, "length": 978944, "depth": 0, "zero": true, "data": false, "offset": OFFSET},
333
{ "start": 983040, "length": 65536, "depth": 0, "zero": false, "data": true, "offset": OFFSET}]
334
*** done
39
--
335
--
40
2.9.3
336
2.21.0
41
337
42
338
diff view generated by jsdifflib
1
This adds support for reopen in rbd, for changing between r/w and r/o.
1
From: Nir Soffer <nirsof@gmail.com>
2
2
3
Note, that this is only a flag change, but we will block a change from
3
Using block_resize we can test allocate_first_block() with file
4
r/o to r/w if we are using an RBD internal snapshot.
4
descriptor opened with O_DIRECT, ensuring that it works for any size
5
larger than 4096 bytes.
5
6
6
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
7
Testing smaller sizes is tricky as the result depends on the filesystem
7
Signed-off-by: Jeff Cody <jcody@redhat.com>
8
used for testing. For example on NFS any size will work since O_DIRECT
8
Reviewed-by: John Snow <jsnow@redhat.com>
9
does not require any alignment.
9
Message-id: d4e87539167ec6527d44c97b164eabcccf96e4f3.1491597120.git.jcody@redhat.com
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
block/rbd.c | 21 +++++++++++++++++++++
16
tests/qemu-iotests/175 | 28 ++++++++++++++++++++++++++++
12
1 file changed, 21 insertions(+)
17
tests/qemu-iotests/175.out | 8 ++++++++
18
2 files changed, 36 insertions(+)
13
19
14
diff --git a/block/rbd.c b/block/rbd.c
20
diff --git a/tests/qemu-iotests/175 b/tests/qemu-iotests/175
15
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100755
16
--- a/block/rbd.c
22
--- a/tests/qemu-iotests/175
17
+++ b/block/rbd.c
23
+++ b/tests/qemu-iotests/175
18
@@ -XXX,XX +XXX,XX @@ failed_opts:
24
@@ -XXX,XX +XXX,XX @@ _filter_blocks()
19
return r;
25
-e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/max allocation/"
20
}
26
}
21
27
28
+# Resize image using block_resize.
29
+# Parameter 1: image path
30
+# Parameter 2: new size
31
+_block_resize()
32
+{
33
+ local path=$1
34
+ local size=$2
22
+
35
+
23
+/* Since RBD is currently always opened R/W via the API,
36
+ $QEMU -qmp stdio -nographic -nodefaults \
24
+ * we just need to check if we are using a snapshot or not, in
37
+ -blockdev file,node-name=file,filename=$path,cache.direct=on \
25
+ * order to determine if we will allow it to be R/W */
38
+ <<EOF
26
+static int qemu_rbd_reopen_prepare(BDRVReopenState *state,
39
+{'execute': 'qmp_capabilities'}
27
+ BlockReopenQueue *queue, Error **errp)
40
+{'execute': 'block_resize', 'arguments': {'node-name': 'file', 'size': $size}}
28
+{
41
+{'execute': 'quit'}
29
+ BDRVRBDState *s = state->bs->opaque;
42
+EOF
30
+ int ret = 0;
31
+
32
+ if (s->snap && state->flags & BDRV_O_RDWR) {
33
+ error_setg(errp,
34
+ "Cannot change node '%s' to r/w when using RBD snapshot",
35
+ bdrv_get_device_or_node_name(state->bs));
36
+ ret = -EINVAL;
37
+ }
38
+
39
+ return ret;
40
+}
43
+}
41
+
44
+
42
static void qemu_rbd_close(BlockDriverState *bs)
45
# get standard environment, filters and checks
43
{
46
. ./common.rc
44
BDRVRBDState *s = bs->opaque;
47
. ./common.filter
45
@@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_rbd = {
48
@@ -XXX,XX +XXX,XX @@ _supported_fmt raw
46
.bdrv_parse_filename = qemu_rbd_parse_filename,
49
_supported_proto file
47
.bdrv_file_open = qemu_rbd_open,
50
_supported_os Linux
48
.bdrv_close = qemu_rbd_close,
51
49
+ .bdrv_reopen_prepare = qemu_rbd_reopen_prepare,
52
+_default_cache_mode none
50
.bdrv_create = qemu_rbd_create,
53
+_supported_cache_modes none directsync
51
.bdrv_has_zero_init = bdrv_has_zero_init_1,
54
+
52
.bdrv_get_info = qemu_rbd_getinfo,
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
69
+
70
# success, all done
71
echo "*** done"
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
53
--
90
--
54
2.9.3
91
2.21.0
55
92
56
93
diff view generated by jsdifflib
1
From: Ashish Mittal <ashmit602@gmail.com>
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.
2
4
3
These changes use a vxhs test server that is a part of the following
5
Fixes: fe646693acc13ac48b98435d14149ab04dc597bc
4
repository:
6
Signed-off-by: Max Reitz <mreitz@redhat.com>
5
https://github.com/VeritasHyperScale/libqnio.git
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(-)
6
15
7
Signed-off-by: Ashish Mittal <Ashish.Mittal@veritas.com>
16
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
8
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
9
Reviewed-by: Jeff Cody <jcody@redhat.com>
10
Signed-off-by: Jeff Cody <jcody@redhat.com>
11
Message-id: 1491277689-24949-3-git-send-email-Ashish.Mittal@veritas.com
12
---
13
tests/qemu-iotests/common | 6 ++++++
14
tests/qemu-iotests/common.config | 13 +++++++++++++
15
tests/qemu-iotests/common.filter | 1 +
16
tests/qemu-iotests/common.rc | 19 +++++++++++++++++++
17
4 files changed, 39 insertions(+)
18
19
diff --git a/tests/qemu-iotests/common b/tests/qemu-iotests/common
20
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
21
--- a/tests/qemu-iotests/common
18
--- a/tests/qemu-iotests/059.out
22
+++ b/tests/qemu-iotests/common
19
+++ b/tests/qemu-iotests/059.out
23
@@ -XXX,XX +XXX,XX @@ check options
20
@@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
24
-ssh test ssh
21
qemu-io: can't open device TEST_DIR/t.vmdk: L1 size too big
25
-nfs test nfs
22
26
-luks test luks
23
=== Testing monolithicFlat creation and opening ===
27
+ -vxhs test vxhs
24
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 subformat=monolithicFlat
28
-xdiff graphical mode diff
25
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648
29
-nocache use O_DIRECT on backing file
26
image: TEST_DIR/t.IMGFMT
30
-misalign misalign memory allocations
27
file format: IMGFMT
31
@@ -XXX,XX +XXX,XX @@ testlist options
28
virtual size: 2 GiB (2147483648 bytes)
32
xpand=false
29
33
;;
30
=== Testing monolithicFlat with zeroed_grain ===
34
31
qemu-img: TEST_DIR/t.IMGFMT: Flat image can't enable zeroed grain
35
+ -vxhs)
32
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 subformat=monolithicFlat
36
+ IMGPROTO=vxhs
33
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648
37
+ xpand=false
34
38
+ ;;
35
=== Testing big twoGbMaxExtentFlat ===
39
+
36
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000 subformat=twoGbMaxExtentFlat
40
-ssh)
37
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000
41
IMGPROTO=ssh
38
image: TEST_DIR/t.vmdk
42
xpand=false
39
file format: vmdk
43
diff --git a/tests/qemu-iotests/common.config b/tests/qemu-iotests/common.config
40
virtual size: 0.977 TiB (1073741824000 bytes)
44
index XXXXXXX..XXXXXXX 100644
41
@@ -XXX,XX +XXX,XX @@ Format specific information:
45
--- a/tests/qemu-iotests/common.config
42
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Invalid extent line: RW 12582912 VMFS "dummy.IMGFMT" 1
46
+++ b/tests/qemu-iotests/common.config
43
47
@@ -XXX,XX +XXX,XX @@ if [ -z "$QEMU_NBD_PROG" ]; then
44
=== Testing truncated sparse ===
48
export QEMU_NBD_PROG="`set_prog_path qemu-nbd`"
45
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=107374182400 subformat=monolithicSparse
49
fi
46
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=107374182400
50
47
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': File truncated, expecting at least 13172736 bytes
51
+if [ -z "$QEMU_VXHS_PROG" ]; then
48
52
+ export QEMU_VXHS_PROG="`set_prog_path qnio_server`"
49
=== Converting to streamOptimized from image with small cluster size===
53
+fi
50
@@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240
54
+
51
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
55
_qemu_wrapper()
52
56
{
53
=== Testing monolithicFlat with internally generated JSON file name ===
57
(
54
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 subformat=monolithicFlat
58
@@ -XXX,XX +XXX,XX @@ _qemu_nbd_wrapper()
55
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
59
)
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"}'
60
}
57
61
58
=== Testing version 3 ===
62
+_qemu_vxhs_wrapper()
59
@@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 64931328
63
+{
60
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
64
+ (
61
65
+ echo $BASHPID > "${TEST_DIR}/qemu-vxhs.pid"
62
=== Testing 4TB monolithicFlat creation and IO ===
66
+ exec "$QEMU_VXHS_PROG" $QEMU_VXHS_OPTIONS "$@"
63
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4398046511104 subformat=monolithicFlat
67
+ )
64
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4398046511104
68
+}
65
image: TEST_DIR/t.IMGFMT
69
+
66
file format: IMGFMT
70
export QEMU=_qemu_wrapper
67
virtual size: 4 TiB (4398046511104 bytes)
71
export QEMU_IMG=_qemu_img_wrapper
68
@@ -XXX,XX +XXX,XX @@ read 1024/1024 bytes at offset 966367641600
72
export QEMU_IO=_qemu_io_wrapper
69
1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
73
export QEMU_NBD=_qemu_nbd_wrapper
70
74
+export QEMU_VXHS=_qemu_vxhs_wrapper
71
=== Testing qemu-img map on extents ===
75
72
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544 subformat=monolithicSparse
76
QEMU_IMG_EXTRA_ARGS=
73
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544
77
if [ "$IMGOPTSSYNTAX" = "true" ]; then
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
78
diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
86
diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
79
index XXXXXXX..XXXXXXX 100644
87
index XXXXXXX..XXXXXXX 100644
80
--- a/tests/qemu-iotests/common.filter
88
--- a/tests/qemu-iotests/common.filter
81
+++ b/tests/qemu-iotests/common.filter
89
+++ b/tests/qemu-iotests/common.filter
82
@@ -XXX,XX +XXX,XX @@ _filter_img_info()
90
@@ -XXX,XX +XXX,XX @@ _filter_img_create()
83
-e "s#$TEST_DIR#TEST_DIR#g" \
91
-e "s# compat6=\\(on\\|off\\)##g" \
84
-e "s#$IMGFMT#IMGFMT#g" \
92
-e "s# static=\\(on\\|off\\)##g" \
85
-e 's#nbd://127.0.0.1:10810$#TEST_DIR/t.IMGFMT#g' \
93
-e "s# zeroed_grain=\\(on\\|off\\)##g" \
86
+ -e 's#json.*vdisk-id.*vxhs"}}#TEST_DIR/t.IMGFMT#' \
94
- -e "s# subformat='[^']*'##g" \
87
-e "/encrypted: yes/d" \
95
- -e "s# adapter_type='[^']*'##g" \
88
-e "/cluster_size: [0-9]\\+/d" \
96
+ -e "s# subformat=[^ ]*##g" \
89
-e "/table_size: [0-9]\\+/d" \
97
+ -e "s# adapter_type=[^ ]*##g" \
90
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
98
-e "s# hwversion=[^ ]*##g" \
91
index XXXXXXX..XXXXXXX 100644
99
-e "s# lazy_refcounts=\\(on\\|off\\)##g" \
92
--- a/tests/qemu-iotests/common.rc
100
-e "s# block_size=[0-9]\\+##g" \
93
+++ b/tests/qemu-iotests/common.rc
94
@@ -XXX,XX +XXX,XX @@ else
95
elif [ "$IMGPROTO" = "nfs" ]; then
96
TEST_DIR="nfs://127.0.0.1/$TEST_DIR"
97
TEST_IMG=$TEST_DIR/t.$IMGFMT
98
+ elif [ "$IMGPROTO" = "vxhs" ]; then
99
+ TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT
100
+ TEST_IMG="vxhs://127.0.0.1:9999/t.$IMGFMT"
101
else
102
TEST_IMG=$IMGPROTO:$TEST_DIR/t.$IMGFMT
103
fi
104
@@ -XXX,XX +XXX,XX @@ _make_test_img()
105
eval "$QEMU_NBD -v -t -b 127.0.0.1 -p 10810 -f $IMGFMT $TEST_IMG_FILE >/dev/null &"
106
sleep 1 # FIXME: qemu-nbd needs to be listening before we continue
107
fi
108
+
109
+ # Start QNIO server on image directory for vxhs protocol
110
+ if [ $IMGPROTO = "vxhs" ]; then
111
+ eval "$QEMU_VXHS -d $TEST_DIR > /dev/null &"
112
+ sleep 1 # Wait for server to come up.
113
+ fi
114
}
115
116
_rm_test_img()
117
@@ -XXX,XX +XXX,XX @@ _cleanup_test_img()
118
fi
119
rm -f "$TEST_IMG_FILE"
120
;;
121
+ vxhs)
122
+ if [ -f "${TEST_DIR}/qemu-vxhs.pid" ]; then
123
+ local QEMU_VXHS_PID
124
+ read QEMU_VXHS_PID < "${TEST_DIR}/qemu-vxhs.pid"
125
+ kill ${QEMU_VXHS_PID} >/dev/null 2>&1
126
+ rm -f "${TEST_DIR}/qemu-vxhs.pid"
127
+ fi
128
+ rm -f "$TEST_IMG_FILE"
129
+ ;;
130
+
131
file)
132
_rm_test_img "$TEST_DIR/t.$IMGFMT"
133
_rm_test_img "$TEST_DIR/t.$IMGFMT.orig"
134
--
101
--
135
2.9.3
102
2.21.0
136
103
137
104
diff view generated by jsdifflib
1
Introduce check function for setting read_only flags. Will return < 0 on
1
This makes iotest 033 pass with e.g. subformat=monolithicFlat. It also
2
error, with appropriate Error value set. Does not alter any flags.
2
turns a former error in 059 into success.
3
3
4
Signed-off-by: Jeff Cody <jcody@redhat.com>
4
Signed-off-by: Max Reitz <mreitz@redhat.com>
5
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
5
Message-id: 20190815153638.4600-3-mreitz@redhat.com
6
Reviewed-by: John Snow <jsnow@redhat.com>
6
Reviewed-by: John Snow <jsnow@redhat.com>
7
Message-id: e2bba34ac3bc76a0c42adc390413f358ae0566e8.1491597120.git.jcody@redhat.com
7
Signed-off-by: Max Reitz <mreitz@redhat.com>
8
---
8
---
9
block.c | 14 +++++++++++++-
9
block/vmdk.c | 54 ++++++++++++++++++++++++--------------
10
include/block/block.h | 1 +
10
tests/qemu-iotests/059 | 7 +++--
11
2 files changed, 14 insertions(+), 1 deletion(-)
11
tests/qemu-iotests/059.out | 4 ++-
12
3 files changed, 42 insertions(+), 23 deletions(-)
12
13
13
diff --git a/block.c b/block.c
14
diff --git a/block/vmdk.c b/block/vmdk.c
14
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
15
--- a/block.c
16
--- a/block/vmdk.c
16
+++ b/block.c
17
+++ b/block/vmdk.c
17
@@ -XXX,XX +XXX,XX @@ bool bdrv_is_read_only(BlockDriverState *bs)
18
@@ -XXX,XX +XXX,XX @@ static const char *next_line(const char *s)
18
return bs->read_only;
19
}
19
}
20
20
21
-int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
21
static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
22
+int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
22
- const char *desc_file_path, QDict *options,
23
- Error **errp)
24
+ QDict *options, Error **errp)
23
{
25
{
24
/* Do not set read_only if copy_on_read is enabled */
26
int ret;
25
if (bs->copy_on_read && read_only) {
27
int matches;
26
@@ -XXX,XX +XXX,XX @@ int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
28
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
27
return -EPERM;
29
const char *p, *np;
30
int64_t sectors = 0;
31
int64_t flat_offset;
32
+ char *desc_file_dir = NULL;
33
char *extent_path;
34
BdrvChild *extent_file;
35
BDRVVmdkState *s = bs->opaque;
36
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
37
continue;
38
}
39
40
- if (!path_is_absolute(fname) && !path_has_protocol(fname) &&
41
- !desc_file_path[0])
42
- {
43
- bdrv_refresh_filename(bs->file->bs);
44
- error_setg(errp, "Cannot use relative extent paths with VMDK "
45
- "descriptor file '%s'", bs->file->bs->filename);
46
- return -EINVAL;
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);
28
}
112
}
29
113
- return 0;
30
+ return 0;
31
+}
32
+
114
+
33
+int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp)
115
+ ret = 0;
34
+{
116
+ goto out;
35
+ int ret = 0;
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;
36
+
126
+
37
+ ret = bdrv_can_set_read_only(bs, read_only, errp);
127
+out:
38
+ if (ret < 0) {
128
+ g_free(desc_file_dir);
39
+ return ret;
129
+ return ret;
40
+ }
41
+
42
bs->read_only = read_only;
43
return 0;
44
}
130
}
45
diff --git a/include/block/block.h b/include/block/block.h
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
46
index XXXXXXX..XXXXXXX 100644
163
index XXXXXXX..XXXXXXX 100644
47
--- a/include/block/block.h
164
--- a/tests/qemu-iotests/059.out
48
+++ b/include/block/block.h
165
+++ b/tests/qemu-iotests/059.out
49
@@ -XXX,XX +XXX,XX @@ int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base,
166
@@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240
50
int64_t sector_num, int nb_sectors, int *pnum);
167
51
168
=== Testing monolithicFlat with internally generated JSON file name ===
52
bool bdrv_is_read_only(BlockDriverState *bs);
169
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
53
+int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only, Error **errp);
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"}'
54
int bdrv_set_read_only(BlockDriverState *bs, bool read_only, Error **errp);
171
+format name: IMGFMT
55
bool bdrv_is_sg(BlockDriverState *bs);
172
+cluster size: 0 bytes
56
bool bdrv_is_inserted(BlockDriverState *bs);
173
+vm state offset: 0 bytes
174
175
=== Testing version 3 ===
176
image: TEST_DIR/iotest-version3.IMGFMT
57
--
177
--
58
2.9.3
178
2.21.0
59
179
60
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
1
The protocol VXHS does not support image creation. Some tests expect
1
streamOptimized does not support writes that do not span exactly one
2
to be able to create images through the protocol. Exclude VXHS from
2
cluster. Furthermore, it cannot rewrite already allocated clusters.
3
these tests.
3
As such, many iotests do not work with it. Disable them.
4
4
5
Signed-off-by: Jeff Cody <jcody@redhat.com>
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>
6
---
9
---
7
tests/qemu-iotests/017 | 1 +
10
tests/qemu-iotests/002 | 1 +
8
tests/qemu-iotests/020 | 1 +
11
tests/qemu-iotests/003 | 1 +
9
tests/qemu-iotests/029 | 1 +
12
tests/qemu-iotests/005 | 3 ++-
10
tests/qemu-iotests/073 | 1 +
13
tests/qemu-iotests/009 | 1 +
11
tests/qemu-iotests/114 | 1 +
14
tests/qemu-iotests/010 | 1 +
12
tests/qemu-iotests/130 | 1 +
15
tests/qemu-iotests/011 | 1 +
13
tests/qemu-iotests/134 | 1 +
16
tests/qemu-iotests/017 | 3 ++-
14
tests/qemu-iotests/156 | 1 +
17
tests/qemu-iotests/018 | 3 ++-
15
tests/qemu-iotests/158 | 1 +
18
tests/qemu-iotests/019 | 3 ++-
16
9 files changed, 9 insertions(+)
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(-)
17
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
18
diff --git a/tests/qemu-iotests/017 b/tests/qemu-iotests/017
107
diff --git a/tests/qemu-iotests/017 b/tests/qemu-iotests/017
19
index XXXXXXX..XXXXXXX 100755
108
index XXXXXXX..XXXXXXX 100755
20
--- a/tests/qemu-iotests/017
109
--- a/tests/qemu-iotests/017
21
+++ b/tests/qemu-iotests/017
110
+++ b/tests/qemu-iotests/017
22
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
111
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
23
# Any format supporting backing files
24
_supported_fmt qcow qcow2 vmdk qed
112
_supported_fmt qcow qcow2 vmdk qed
25
_supported_proto generic
113
_supported_proto generic
26
+_unsupported_proto vxhs
114
_unsupported_proto vxhs
27
_supported_os Linux
115
-_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
28
_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
116
+_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \
29
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
30
diff --git a/tests/qemu-iotests/020 b/tests/qemu-iotests/020
149
diff --git a/tests/qemu-iotests/020 b/tests/qemu-iotests/020
31
index XXXXXXX..XXXXXXX 100755
150
index XXXXXXX..XXXXXXX 100755
32
--- a/tests/qemu-iotests/020
151
--- a/tests/qemu-iotests/020
33
+++ b/tests/qemu-iotests/020
152
+++ b/tests/qemu-iotests/020
34
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
153
@@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed
35
# Any format supporting backing files
154
_supported_proto file
36
_supported_fmt qcow qcow2 vmdk qed
155
_unsupported_imgopts "subformat=monolithicFlat" \
37
_supported_proto generic
156
"subformat=twoGbMaxExtentFlat" \
38
+_unsupported_proto vxhs
157
- "subformat=twoGbMaxExtentSparse"
39
_supported_os Linux
158
+ "subformat=twoGbMaxExtentSparse" \
40
_unsupported_imgopts "subformat=monolithicFlat" \
159
+ "subformat=streamOptimized"
41
"subformat=twoGbMaxExtentFlat" \
160
42
diff --git a/tests/qemu-iotests/029 b/tests/qemu-iotests/029
161
TEST_OFFSETS="0 4294967296"
43
index XXXXXXX..XXXXXXX 100755
162
44
--- a/tests/qemu-iotests/029
163
diff --git a/tests/qemu-iotests/027 b/tests/qemu-iotests/027
45
+++ b/tests/qemu-iotests/029
164
index XXXXXXX..XXXXXXX 100755
46
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
165
--- a/tests/qemu-iotests/027
47
# Any format supporting intenal snapshots
166
+++ b/tests/qemu-iotests/027
48
_supported_fmt qcow2
167
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
49
_supported_proto generic
168
50
+_unsupported_proto vxhs
169
_supported_fmt vmdk qcow qcow2 qed
51
_supported_os Linux
170
_supported_proto generic
52
# Internal snapshots are (currently) impossible with refcount_bits=1
171
+_unsupported_imgopts "subformat=streamOptimized"
53
_unsupported_imgopts 'refcount_bits=1[^0-9]'
172
54
diff --git a/tests/qemu-iotests/073 b/tests/qemu-iotests/073
173
55
index XXXXXXX..XXXXXXX 100755
174
size=128M
56
--- a/tests/qemu-iotests/073
175
diff --git a/tests/qemu-iotests/032 b/tests/qemu-iotests/032
57
+++ b/tests/qemu-iotests/073
176
index XXXXXXX..XXXXXXX 100755
58
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
177
--- a/tests/qemu-iotests/032
59
178
+++ b/tests/qemu-iotests/032
60
_supported_fmt qcow2
179
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
61
_supported_proto generic
180
# This works for any image format (though unlikely to segfault for raw)
62
+_unsupported_proto vxhs
181
_supported_fmt generic
63
_supported_os Linux
182
_supported_proto generic
64
183
+_unsupported_imgopts "subformat=streamOptimized"
65
CLUSTER_SIZE=64k
184
66
diff --git a/tests/qemu-iotests/114 b/tests/qemu-iotests/114
185
echo
67
index XXXXXXX..XXXXXXX 100755
186
echo === Prepare image ===
68
--- a/tests/qemu-iotests/114
187
diff --git a/tests/qemu-iotests/033 b/tests/qemu-iotests/033
69
+++ b/tests/qemu-iotests/114
188
index XXXXXXX..XXXXXXX 100755
70
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
189
--- a/tests/qemu-iotests/033
71
190
+++ b/tests/qemu-iotests/033
72
_supported_fmt qcow2
191
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
73
_supported_proto generic
192
74
+_unsupported_proto vxhs
193
_supported_fmt generic
75
_supported_os Linux
194
_supported_proto generic
76
195
+_unsupported_imgopts "subformat=streamOptimized"
77
196
78
diff --git a/tests/qemu-iotests/130 b/tests/qemu-iotests/130
197
79
index XXXXXXX..XXXXXXX 100755
198
size=128M
80
--- a/tests/qemu-iotests/130
199
diff --git a/tests/qemu-iotests/034 b/tests/qemu-iotests/034
81
+++ b/tests/qemu-iotests/130
200
index XXXXXXX..XXXXXXX 100755
82
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
201
--- a/tests/qemu-iotests/034
83
202
+++ b/tests/qemu-iotests/034
84
_supported_fmt qcow2
203
@@ -XXX,XX +XXX,XX @@ _supported_proto file
85
_supported_proto generic
204
_supported_os Linux
86
+_unsupported_proto vxhs
205
_unsupported_imgopts "subformat=monolithicFlat" \
87
_supported_os Linux
206
"subformat=twoGbMaxExtentFlat" \
88
207
- "subformat=twoGbMaxExtentSparse"
89
qemu_comm_method="monitor"
208
+ "subformat=twoGbMaxExtentSparse" \
90
diff --git a/tests/qemu-iotests/134 b/tests/qemu-iotests/134
209
+ "subformat=streamOptimized"
91
index XXXXXXX..XXXXXXX 100755
210
92
--- a/tests/qemu-iotests/134
211
CLUSTER_SIZE=4k
93
+++ b/tests/qemu-iotests/134
212
size=128M
94
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
213
diff --git a/tests/qemu-iotests/037 b/tests/qemu-iotests/037
95
214
index XXXXXXX..XXXXXXX 100755
96
_supported_fmt qcow2
215
--- a/tests/qemu-iotests/037
97
_supported_proto generic
216
+++ b/tests/qemu-iotests/037
98
+_unsupported_proto vxhs
217
@@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed
99
_supported_os Linux
218
_supported_proto file
100
219
_unsupported_imgopts "subformat=monolithicFlat" \
101
220
"subformat=twoGbMaxExtentFlat" \
102
diff --git a/tests/qemu-iotests/156 b/tests/qemu-iotests/156
221
- "subformat=twoGbMaxExtentSparse"
103
index XXXXXXX..XXXXXXX 100755
222
+ "subformat=twoGbMaxExtentSparse" \
104
--- a/tests/qemu-iotests/156
223
+ "subformat=streamOptimized"
105
+++ b/tests/qemu-iotests/156
224
106
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
225
CLUSTER_SIZE=4k
107
226
size=128M
108
_supported_fmt qcow2 qed
227
diff --git a/tests/qemu-iotests/063 b/tests/qemu-iotests/063
109
_supported_proto generic
228
index XXXXXXX..XXXXXXX 100755
110
+_unsupported_proto vxhs
229
--- a/tests/qemu-iotests/063
111
_supported_os Linux
230
+++ b/tests/qemu-iotests/063
112
231
@@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed raw
113
# Create source disk
232
_supported_proto file
114
diff --git a/tests/qemu-iotests/158 b/tests/qemu-iotests/158
233
_unsupported_imgopts "subformat=monolithicFlat" \
115
index XXXXXXX..XXXXXXX 100755
234
"subformat=twoGbMaxExtentFlat" \
116
--- a/tests/qemu-iotests/158
235
- "subformat=twoGbMaxExtentSparse"
117
+++ b/tests/qemu-iotests/158
236
+ "subformat=twoGbMaxExtentSparse" \
118
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
237
+ "subformat=streamOptimized"
119
238
120
_supported_fmt qcow2
239
_make_test_img 4M
121
_supported_proto generic
240
122
+_unsupported_proto vxhs
241
diff --git a/tests/qemu-iotests/072 b/tests/qemu-iotests/072
123
_supported_os Linux
242
index XXXXXXX..XXXXXXX 100755
124
243
--- a/tests/qemu-iotests/072
125
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.
126
--
303
--
127
2.9.3
304
2.21.0
128
305
129
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
1
For the tests that use the common.qemu functions for running a QEMU
1
iotest 126 requires backing file support, which flat vmdks cannot offer.
2
process, _cleanup_qemu must be called in the exit function.
2
Skip this test for such subformats.
3
3
4
If it is not, if the qemu process aborts, then not all of the droppings
4
Signed-off-by: Max Reitz <mreitz@redhat.com>
5
are cleaned up (e.g. pidfile, fifos).
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(+)
6
11
7
This updates those tests that did not have a cleanup in qemu-iotests.
12
diff --git a/tests/qemu-iotests/126 b/tests/qemu-iotests/126
8
9
(I swapped spaces for tabs in test 102 as well)
10
11
Reported-by: Eric Blake <eblake@redhat.com>
12
Reviewed-by: Eric Blake <eblake@redhat.com>
13
Signed-off-by: Jeff Cody <jcody@redhat.com>
14
Message-id: d59c2f6ad6c1da8b9b3c7f357c94a7122ccfc55a.1492544096.git.jcody@redhat.com
15
---
16
tests/qemu-iotests/028 | 1 +
17
tests/qemu-iotests/094 | 11 ++++++++---
18
tests/qemu-iotests/102 | 5 +++--
19
tests/qemu-iotests/109 | 1 +
20
tests/qemu-iotests/117 | 1 +
21
tests/qemu-iotests/130 | 1 +
22
tests/qemu-iotests/140 | 1 +
23
tests/qemu-iotests/141 | 1 +
24
tests/qemu-iotests/143 | 1 +
25
tests/qemu-iotests/156 | 1 +
26
10 files changed, 19 insertions(+), 5 deletions(-)
27
28
diff --git a/tests/qemu-iotests/028 b/tests/qemu-iotests/028
29
index XXXXXXX..XXXXXXX 100755
13
index XXXXXXX..XXXXXXX 100755
30
--- a/tests/qemu-iotests/028
14
--- a/tests/qemu-iotests/126
31
+++ b/tests/qemu-iotests/028
15
+++ b/tests/qemu-iotests/126
32
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
16
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
33
17
34
_cleanup()
18
# Needs backing file support
35
{
19
_supported_fmt qcow qcow2 qed vmdk
36
+ _cleanup_qemu
20
+_unsupported_imgopts "subformat=monolithicFlat" \
37
rm -f "${TEST_IMG}.copy"
21
+ "subformat=twoGbMaxExtentFlat"
38
_cleanup_test_img
22
# This is the default protocol (and we want to test the difference between
39
}
23
# colons which separate a protocol prefix from the rest and colons which are
40
diff --git a/tests/qemu-iotests/094 b/tests/qemu-iotests/094
24
# just part of the filename, so we cannot test protocols which require a prefix)
41
index XXXXXXX..XXXXXXX 100755
42
--- a/tests/qemu-iotests/094
43
+++ b/tests/qemu-iotests/094
44
@@ -XXX,XX +XXX,XX @@ echo "QA output created by $seq"
45
here="$PWD"
46
status=1    # failure is the default!
47
48
-trap "exit \$status" 0 1 2 3 15
49
+_cleanup()
50
+{
51
+ _cleanup_qemu
52
+ _cleanup_test_img
53
+ rm -f "$TEST_DIR/source.$IMGFMT"
54
+}
55
+
56
+trap "_cleanup; exit \$status" 0 1 2 3 15
57
58
# get standard environment, filters and checks
59
. ./common.rc
60
@@ -XXX,XX +XXX,XX @@ _send_qemu_cmd $QEMU_HANDLE \
61
62
wait=1 _cleanup_qemu
63
64
-_cleanup_test_img
65
-rm -f "$TEST_DIR/source.$IMGFMT"
66
67
# success, all done
68
echo '*** done'
69
diff --git a/tests/qemu-iotests/102 b/tests/qemu-iotests/102
70
index XXXXXXX..XXXXXXX 100755
71
--- a/tests/qemu-iotests/102
72
+++ b/tests/qemu-iotests/102
73
@@ -XXX,XX +XXX,XX @@ seq=$(basename $0)
74
echo "QA output created by $seq"
75
76
here=$PWD
77
-status=1    # failure is the default!
78
+status=1 # failure is the default!
79
80
_cleanup()
81
{
82
-    _cleanup_test_img
83
+ _cleanup_qemu
84
+ _cleanup_test_img
85
}
86
trap "_cleanup; exit \$status" 0 1 2 3 15
87
88
diff --git a/tests/qemu-iotests/109 b/tests/qemu-iotests/109
89
index XXXXXXX..XXXXXXX 100755
90
--- a/tests/qemu-iotests/109
91
+++ b/tests/qemu-iotests/109
92
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
93
94
_cleanup()
95
{
96
+ _cleanup_qemu
97
rm -f $TEST_IMG.src
98
    _cleanup_test_img
99
}
100
diff --git a/tests/qemu-iotests/117 b/tests/qemu-iotests/117
101
index XXXXXXX..XXXXXXX 100755
102
--- a/tests/qemu-iotests/117
103
+++ b/tests/qemu-iotests/117
104
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
105
106
_cleanup()
107
{
108
+ _cleanup_qemu
109
    _cleanup_test_img
110
}
111
trap "_cleanup; exit \$status" 0 1 2 3 15
112
diff --git a/tests/qemu-iotests/130 b/tests/qemu-iotests/130
113
index XXXXXXX..XXXXXXX 100755
114
--- a/tests/qemu-iotests/130
115
+++ b/tests/qemu-iotests/130
116
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
117
118
_cleanup()
119
{
120
+ _cleanup_qemu
121
_cleanup_test_img
122
}
123
trap "_cleanup; exit \$status" 0 1 2 3 15
124
diff --git a/tests/qemu-iotests/140 b/tests/qemu-iotests/140
125
index XXXXXXX..XXXXXXX 100755
126
--- a/tests/qemu-iotests/140
127
+++ b/tests/qemu-iotests/140
128
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
129
130
_cleanup()
131
{
132
+ _cleanup_qemu
133
_cleanup_test_img
134
rm -f "$TEST_DIR/nbd"
135
}
136
diff --git a/tests/qemu-iotests/141 b/tests/qemu-iotests/141
137
index XXXXXXX..XXXXXXX 100755
138
--- a/tests/qemu-iotests/141
139
+++ b/tests/qemu-iotests/141
140
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
141
142
_cleanup()
143
{
144
+ _cleanup_qemu
145
_cleanup_test_img
146
rm -f "$TEST_DIR/{b,m,o}.$IMGFMT"
147
}
148
diff --git a/tests/qemu-iotests/143 b/tests/qemu-iotests/143
149
index XXXXXXX..XXXXXXX 100755
150
--- a/tests/qemu-iotests/143
151
+++ b/tests/qemu-iotests/143
152
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
153
154
_cleanup()
155
{
156
+ _cleanup_qemu
157
rm -f "$TEST_DIR/nbd"
158
}
159
trap "_cleanup; exit \$status" 0 1 2 3 15
160
diff --git a/tests/qemu-iotests/156 b/tests/qemu-iotests/156
161
index XXXXXXX..XXXXXXX 100755
162
--- a/tests/qemu-iotests/156
163
+++ b/tests/qemu-iotests/156
164
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
165
166
_cleanup()
167
{
168
+ _cleanup_qemu
169
rm -f "$TEST_IMG{,.target}{,.backing,.overlay}"
170
}
171
trap "_cleanup; exit \$status" 0 1 2 3 15
172
--
25
--
173
2.9.3
26
2.21.0
174
27
175
28
diff view generated by jsdifflib
New patch
1
From: Stefan Hajnoczi <stefanha@redhat.com>
1
2
3
Fixes: a6b257a08e3d72219f03e461a52152672fec0612
4
("file-posix: Handle undetectable alignment")
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>
9
---
10
block/file-posix.c | 2 +-
11
1 file changed, 1 insertion(+), 1 deletion(-)
12
13
diff --git a/block/file-posix.c b/block/file-posix.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/block/file-posix.c
16
+++ b/block/file-posix.c
17
@@ -XXX,XX +XXX,XX @@ static void raw_probe_alignment(BlockDriverState *bs, int fd, Error **errp)
18
for (i = 0; i < ARRAY_SIZE(alignments); i++) {
19
align = alignments[i];
20
if (raw_is_io_aligned(fd, buf + align, max_align)) {
21
- /* Fallback to request_aligment. */
22
+ /* Fallback to request_alignment. */
23
s->buf_align = (align != 1) ? align : bs->bl.request_alignment;
24
break;
25
}
26
--
27
2.21.0
28
29
diff view generated by jsdifflib
1
Update 'clientname' to be 'user', which tracks better with both
1
Without this argument, qemu will print an angry message about not being
2
the QAPI and rados variable naming.
2
able to connect to a display server if $DISPLAY is not set. For me,
3
that breaks iotests.supported_formats() because it thus only sees
4
["Could", "not", "connect"] as the supported formats.
3
5
4
Update 'name' to be 'image_name', as it indicates the rbd image.
6
Signed-off-by: Max Reitz <mreitz@redhat.com>
5
Naming it 'image' would have been ideal, but we are using that for
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
the rados_image_t value returned by rbd_open().
8
Message-id: 20190819201851.24418-2-mreitz@redhat.com
9
Reviewed-by: Thomas Huth <thuth@redhat.com>
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
11
---
12
tests/qemu-iotests/check | 6 +++---
13
1 file changed, 3 insertions(+), 3 deletions(-)
7
14
8
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
15
diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
9
Signed-off-by: Jeff Cody <jcody@redhat.com>
16
index XXXXXXX..XXXXXXX 100755
10
Reviewed-by: John Snow <jsnow@redhat.com>
17
--- a/tests/qemu-iotests/check
11
Message-id: b7ec1fb2e1cf36f9b6911631447a5b0422590b7d.1491597120.git.jcody@redhat.com
18
+++ b/tests/qemu-iotests/check
12
---
19
@@ -XXX,XX +XXX,XX @@ export QEMU_PROG="$(type -p "$QEMU_PROG")"
13
block/rbd.c | 33 +++++++++++++++++----------------
20
14
1 file changed, 17 insertions(+), 16 deletions(-)
21
case "$QEMU_PROG" in
15
22
*qemu-system-arm|*qemu-system-aarch64)
16
diff --git a/block/rbd.c b/block/rbd.c
23
- export QEMU_OPTIONS="-nodefaults -machine virt,accel=qtest"
17
index XXXXXXX..XXXXXXX 100644
24
+ export QEMU_OPTIONS="-nodefaults -display none -machine virt,accel=qtest"
18
--- a/block/rbd.c
25
;;
19
+++ b/block/rbd.c
26
*qemu-system-tricore)
20
@@ -XXX,XX +XXX,XX @@ typedef struct BDRVRBDState {
27
- export QEMU_OPTIONS="-nodefaults -machine tricore_testboard,accel=qtest"
21
rados_t cluster;
28
+ export QEMU_OPTIONS="-nodefaults -display none -machine tricore_testboard,accel=qtest"
22
rados_ioctx_t io_ctx;
29
;;
23
rbd_image_t image;
30
*)
24
- char *name;
31
- export QEMU_OPTIONS="-nodefaults -machine accel=qtest"
25
+ char *image_name;
32
+ export QEMU_OPTIONS="-nodefaults -display none -machine accel=qtest"
26
char *snap;
33
;;
27
} BDRVRBDState;
34
esac
28
29
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp)
30
int64_t bytes = 0;
31
int64_t objsize;
32
int obj_order = 0;
33
- const char *pool, *name, *conf, *clientname, *keypairs;
34
+ const char *pool, *image_name, *conf, *user, *keypairs;
35
const char *secretid;
36
rados_t cluster;
37
rados_ioctx_t io_ctx;
38
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp)
39
*/
40
pool = qdict_get_try_str(options, "pool");
41
conf = qdict_get_try_str(options, "conf");
42
- clientname = qdict_get_try_str(options, "user");
43
- name = qdict_get_try_str(options, "image");
44
+ user = qdict_get_try_str(options, "user");
45
+ image_name = qdict_get_try_str(options, "image");
46
keypairs = qdict_get_try_str(options, "=keyvalue-pairs");
47
48
- ret = rados_create(&cluster, clientname);
49
+ ret = rados_create(&cluster, user);
50
if (ret < 0) {
51
error_setg_errno(errp, -ret, "error initializing");
52
goto exit;
53
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp)
54
goto shutdown;
55
}
56
57
- ret = rbd_create(io_ctx, name, bytes, &obj_order);
58
+ ret = rbd_create(io_ctx, image_name, bytes, &obj_order);
59
if (ret < 0) {
60
error_setg_errno(errp, -ret, "error rbd create");
61
}
62
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
63
Error **errp)
64
{
65
BDRVRBDState *s = bs->opaque;
66
- const char *pool, *snap, *conf, *clientname, *name, *keypairs;
67
+ const char *pool, *snap, *conf, *user, *image_name, *keypairs;
68
const char *secretid;
69
QemuOpts *opts;
70
Error *local_err = NULL;
71
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
72
pool = qemu_opt_get(opts, "pool");
73
conf = qemu_opt_get(opts, "conf");
74
snap = qemu_opt_get(opts, "snapshot");
75
- clientname = qemu_opt_get(opts, "user");
76
- name = qemu_opt_get(opts, "image");
77
+ user = qemu_opt_get(opts, "user");
78
+ image_name = qemu_opt_get(opts, "image");
79
keypairs = qemu_opt_get(opts, "=keyvalue-pairs");
80
81
- if (!pool || !name) {
82
+ if (!pool || !image_name) {
83
error_setg(errp, "Parameters 'pool' and 'image' are required");
84
r = -EINVAL;
85
goto failed_opts;
86
}
87
88
- r = rados_create(&s->cluster, clientname);
89
+ r = rados_create(&s->cluster, user);
90
if (r < 0) {
91
error_setg_errno(errp, -r, "error initializing");
92
goto failed_opts;
93
}
94
95
s->snap = g_strdup(snap);
96
- s->name = g_strdup(name);
97
+ s->image_name = g_strdup(image_name);
98
99
/* try default location when conf=NULL, but ignore failure */
100
r = rados_conf_read_file(s->cluster, conf);
101
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
102
}
103
104
/* rbd_open is always r/w */
105
- r = rbd_open(s->io_ctx, s->name, &s->image, s->snap);
106
+ r = rbd_open(s->io_ctx, s->image_name, &s->image, s->snap);
107
if (r < 0) {
108
- error_setg_errno(errp, -r, "error reading header from %s", s->name);
109
+ error_setg_errno(errp, -r, "error reading header from %s",
110
+ s->image_name);
111
goto failed_open;
112
}
113
114
@@ -XXX,XX +XXX,XX @@ failed_open:
115
failed_shutdown:
116
rados_shutdown(s->cluster);
117
g_free(s->snap);
118
- g_free(s->name);
119
+ g_free(s->image_name);
120
failed_opts:
121
qemu_opts_del(opts);
122
g_free(mon_host);
123
@@ -XXX,XX +XXX,XX @@ static void qemu_rbd_close(BlockDriverState *bs)
124
rbd_close(s->image);
125
rados_ioctx_destroy(s->io_ctx);
126
g_free(s->snap);
127
- g_free(s->name);
128
+ g_free(s->image_name);
129
rados_shutdown(s->cluster);
130
}
131
35
132
--
36
--
133
2.9.3
37
2.21.0
134
38
135
39
diff view generated by jsdifflib
1
We have a helper wrapper for checking for the BDS read_only flag,
1
From: Thomas Huth <thuth@redhat.com>
2
add a helper wrapper to set the read_only flag as well.
3
2
4
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
3
It is possible to enable only a subset of the block drivers with the
5
Signed-off-by: Jeff Cody <jcody@redhat.com>
4
"--block-drv-rw-whitelist" option of the "configure" script. All other
6
Reviewed-by: John Snow <jsnow@redhat.com>
5
drivers are marked as unusable (or only included as read-only with the
7
Message-id: 9b18972d05f5fa2ac16c014f0af98d680553048d.1491597120.git.jcody@redhat.com
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.
12
13
This patch mainly targets the test in the "auto" group which should
14
never fail in such a case, but also improves some of the other tests
15
along the way. Note that we also assume that the "qcow2" and "file"
16
drivers are always available - otherwise it does not make sense to
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>
8
---
22
---
9
block.c | 5 +++++
23
tests/qemu-iotests/071 | 1 +
10
block/bochs.c | 2 +-
24
tests/qemu-iotests/081 | 4 +---
11
block/cloop.c | 2 +-
25
tests/qemu-iotests/099 | 1 +
12
block/dmg.c | 2 +-
26
tests/qemu-iotests/120 | 1 +
13
block/rbd.c | 2 +-
27
tests/qemu-iotests/162 | 4 +---
14
block/vvfat.c | 4 ++--
28
tests/qemu-iotests/184 | 1 +
15
include/block/block.h | 1 +
29
tests/qemu-iotests/186 | 1 +
16
7 files changed, 12 insertions(+), 6 deletions(-)
30
tests/qemu-iotests/common.rc | 14 ++++++++++++++
31
8 files changed, 21 insertions(+), 6 deletions(-)
17
32
18
diff --git a/block.c b/block.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
19
index XXXXXXX..XXXXXXX 100644
131
index XXXXXXX..XXXXXXX 100644
20
--- a/block.c
132
--- a/tests/qemu-iotests/common.rc
21
+++ b/block.c
133
+++ b/tests/qemu-iotests/common.rc
22
@@ -XXX,XX +XXX,XX @@ void path_combine(char *dest, int dest_size,
134
@@ -XXX,XX +XXX,XX @@ _require_command()
23
}
135
[ -x "$c" ] || _notrun "$1 utility required, skipped this test"
24
}
136
}
25
137
26
+void bdrv_set_read_only(BlockDriverState *bs, bool read_only)
138
+# Check that a set of drivers has been whitelisted in the QEMU binary
139
+#
140
+_require_drivers()
27
+{
141
+{
28
+ bs->read_only = read_only;
142
+ available=$($QEMU -drive format=help | \
143
+ sed -e '/Supported formats:/!d' -e 's/Supported formats://')
144
+ for driver
145
+ do
146
+ if ! echo "$available" | grep -q " $driver\( \|$\)"; then
147
+ _notrun "$driver not available"
148
+ fi
149
+ done
29
+}
150
+}
30
+
151
+
31
void bdrv_get_full_backing_filename_from_filename(const char *backed,
152
# make sure this script returns success
32
const char *backing,
153
true
33
char *dest, size_t sz,
34
diff --git a/block/bochs.c b/block/bochs.c
35
index XXXXXXX..XXXXXXX 100644
36
--- a/block/bochs.c
37
+++ b/block/bochs.c
38
@@ -XXX,XX +XXX,XX @@ static int bochs_open(BlockDriverState *bs, QDict *options, int flags,
39
return -EINVAL;
40
}
41
42
- bs->read_only = true; /* no write support yet */
43
+ bdrv_set_read_only(bs, true); /* no write support yet */
44
45
ret = bdrv_pread(bs->file, 0, &bochs, sizeof(bochs));
46
if (ret < 0) {
47
diff --git a/block/cloop.c b/block/cloop.c
48
index XXXXXXX..XXXXXXX 100644
49
--- a/block/cloop.c
50
+++ b/block/cloop.c
51
@@ -XXX,XX +XXX,XX @@ static int cloop_open(BlockDriverState *bs, QDict *options, int flags,
52
return -EINVAL;
53
}
54
55
- bs->read_only = true;
56
+ bdrv_set_read_only(bs, true);
57
58
/* read header */
59
ret = bdrv_pread(bs->file, 128, &s->block_size, 4);
60
diff --git a/block/dmg.c b/block/dmg.c
61
index XXXXXXX..XXXXXXX 100644
62
--- a/block/dmg.c
63
+++ b/block/dmg.c
64
@@ -XXX,XX +XXX,XX @@ static int dmg_open(BlockDriverState *bs, QDict *options, int flags,
65
}
66
67
block_module_load_one("dmg-bz2");
68
- bs->read_only = true;
69
+ bdrv_set_read_only(bs, true);
70
71
s->n_chunks = 0;
72
s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL;
73
diff --git a/block/rbd.c b/block/rbd.c
74
index XXXXXXX..XXXXXXX 100644
75
--- a/block/rbd.c
76
+++ b/block/rbd.c
77
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
78
goto failed_open;
79
}
80
81
- bs->read_only = (s->snap != NULL);
82
+ bdrv_set_read_only(bs, (s->snap != NULL));
83
84
qemu_opts_del(opts);
85
return 0;
86
diff --git a/block/vvfat.c b/block/vvfat.c
87
index XXXXXXX..XXXXXXX 100644
88
--- a/block/vvfat.c
89
+++ b/block/vvfat.c
90
@@ -XXX,XX +XXX,XX @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
91
s->current_cluster=0xffffffff;
92
93
/* read only is the default for safety */
94
- bs->read_only = true;
95
+ bdrv_set_read_only(bs, true);
96
s->qcow = NULL;
97
s->qcow_filename = NULL;
98
s->fat2 = NULL;
99
@@ -XXX,XX +XXX,XX @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
100
if (ret < 0) {
101
goto fail;
102
}
103
- bs->read_only = false;
104
+ bdrv_set_read_only(bs, false);
105
}
106
107
bs->total_sectors = cyls * heads * secs;
108
diff --git a/include/block/block.h b/include/block/block.h
109
index XXXXXXX..XXXXXXX 100644
110
--- a/include/block/block.h
111
+++ b/include/block/block.h
112
@@ -XXX,XX +XXX,XX @@ int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base,
113
int64_t sector_num, int nb_sectors, int *pnum);
114
115
bool bdrv_is_read_only(BlockDriverState *bs);
116
+void bdrv_set_read_only(BlockDriverState *bs, bool read_only);
117
bool bdrv_is_sg(BlockDriverState *bs);
118
bool bdrv_is_inserted(BlockDriverState *bs);
119
int bdrv_media_changed(BlockDriverState *bs);
120
--
154
--
121
2.9.3
155
2.21.0
122
156
123
157
diff view generated by jsdifflib
1
From: Ashish Mittal <ashmit602@gmail.com>
1
From: Thomas Huth <thuth@redhat.com>
2
2
3
Source code for the qnio library that this code loads can be downloaded from:
3
The sanitizers (especially the address sanitizer from Clang) are
4
https://github.com/VeritasHyperScale/libqnio.git
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.
5
8
6
Sample command line using JSON syntax:
9
Signed-off-by: Thomas Huth <thuth@redhat.com>
7
./x86_64-softmmu/qemu-system-x86_64 -name instance-00000008 -S -vnc 0.0.0.0:0
10
Message-id: 20190823084203.29734-1-thuth@redhat.com
8
-k en-us -vga cirrus -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
-msg timestamp=on
12
---
10
'json:{"driver":"vxhs","vdisk-id":"c3e9095a-a5ee-4dce-afeb-2a59fb387410",
13
tests/check-block.sh | 5 +++++
11
"server":{"host":"172.172.17.4","port":"9999"}}'
14
1 file changed, 5 insertions(+)
12
15
13
Sample command line using URI syntax:
16
diff --git a/tests/check-block.sh b/tests/check-block.sh
14
qemu-img convert -f raw -O raw -n
15
/var/lib/nova/instances/_base/0c5eacd5ebea5ed914b6a3e7b18f1ce734c386ad
16
vxhs://192.168.0.1:9999/c6718f6b-0401-441d-a8c3-1f0064d75ee0
17
18
Sample command line using TLS credentials (run in secure mode):
19
./qemu-io --object
20
tls-creds-x509,id=tls0,dir=/etc/pki/qemu/vxhs,endpoint=client -c 'read
21
-v 66000 2.5k' 'json:{"server.host": "127.0.0.1", "server.port": "9999",
22
"vdisk-id": "/test.raw", "driver": "vxhs", "tls-creds":"tls0"}'
23
24
Signed-off-by: Ashish Mittal <Ashish.Mittal@veritas.com>
25
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
26
Reviewed-by: Jeff Cody <jcody@redhat.com>
27
Signed-off-by: Jeff Cody <jcody@redhat.com>
28
Message-id: 1491277689-24949-2-git-send-email-Ashish.Mittal@veritas.com
29
---
30
block/Makefile.objs | 2 +
31
block/trace-events | 17 ++
32
block/vxhs.c | 575 +++++++++++++++++++++++++++++++++++++++++++++++++++
33
configure | 39 ++++
34
qapi/block-core.json | 23 ++-
35
5 files changed, 654 insertions(+), 2 deletions(-)
36
create mode 100644 block/vxhs.c
37
38
diff --git a/block/Makefile.objs b/block/Makefile.objs
39
index XXXXXXX..XXXXXXX 100644
40
--- a/block/Makefile.objs
41
+++ b/block/Makefile.objs
42
@@ -XXX,XX +XXX,XX @@ block-obj-$(CONFIG_LIBNFS) += nfs.o
43
block-obj-$(CONFIG_CURL) += curl.o
44
block-obj-$(CONFIG_RBD) += rbd.o
45
block-obj-$(CONFIG_GLUSTERFS) += gluster.o
46
+block-obj-$(CONFIG_VXHS) += vxhs.o
47
block-obj-$(CONFIG_LIBSSH2) += ssh.o
48
block-obj-y += accounting.o dirty-bitmap.o
49
block-obj-y += write-threshold.o
50
@@ -XXX,XX +XXX,XX @@ rbd.o-cflags := $(RBD_CFLAGS)
51
rbd.o-libs := $(RBD_LIBS)
52
gluster.o-cflags := $(GLUSTERFS_CFLAGS)
53
gluster.o-libs := $(GLUSTERFS_LIBS)
54
+vxhs.o-libs := $(VXHS_LIBS)
55
ssh.o-cflags := $(LIBSSH2_CFLAGS)
56
ssh.o-libs := $(LIBSSH2_LIBS)
57
block-obj-$(if $(CONFIG_BZIP2),m,n) += dmg-bz2.o
58
diff --git a/block/trace-events b/block/trace-events
59
index XXXXXXX..XXXXXXX 100644
60
--- a/block/trace-events
61
+++ b/block/trace-events
62
@@ -XXX,XX +XXX,XX @@ qed_aio_write_data(void *s, void *acb, int ret, uint64_t offset, size_t len) "s
63
qed_aio_write_prefill(void *s, void *acb, uint64_t start, size_t len, uint64_t offset) "s %p acb %p start %"PRIu64" len %zu offset %"PRIu64
64
qed_aio_write_postfill(void *s, void *acb, uint64_t start, size_t len, uint64_t offset) "s %p acb %p start %"PRIu64" len %zu offset %"PRIu64
65
qed_aio_write_main(void *s, void *acb, int ret, uint64_t offset, size_t len) "s %p acb %p ret %d offset %"PRIu64" len %zu"
66
+
67
+# block/vxhs.c
68
+vxhs_iio_callback(int error) "ctx is NULL: error %d"
69
+vxhs_iio_callback_chnfail(int err, int error) "QNIO channel failed, no i/o %d, %d"
70
+vxhs_iio_callback_unknwn(int opcode, int err) "unexpected opcode %d, errno %d"
71
+vxhs_aio_rw_invalid(int req) "Invalid I/O request iodir %d"
72
+vxhs_aio_rw_ioerr(char *guid, int iodir, uint64_t size, uint64_t off, void *acb, int ret, int err) "IO ERROR (vDisk %s) FOR : Read/Write = %d size = %lu offset = %lu ACB = %p. Error = %d, errno = %d"
73
+vxhs_get_vdisk_stat_err(char *guid, int ret, int err) "vDisk (%s) stat ioctl failed, ret = %d, errno = %d"
74
+vxhs_get_vdisk_stat(char *vdisk_guid, uint64_t vdisk_size) "vDisk %s stat ioctl returned size %lu"
75
+vxhs_complete_aio(void *acb, uint64_t ret) "aio failed acb %p ret %ld"
76
+vxhs_parse_uri_filename(const char *filename) "URI passed via bdrv_parse_filename %s"
77
+vxhs_open_vdiskid(const char *vdisk_id) "Opening vdisk-id %s"
78
+vxhs_open_hostinfo(char *of_vsa_addr, int port) "Adding host %s:%d to BDRVVXHSState"
79
+vxhs_open_iio_open(const char *host) "Failed to connect to storage agent on host %s"
80
+vxhs_parse_uri_hostinfo(char *host, int port) "Host: IP %s, Port %d"
81
+vxhs_close(char *vdisk_guid) "Closing vdisk %s"
82
+vxhs_get_creds(const char *cacert, const char *client_key, const char *client_cert) "cacert %s, client_key %s, client_cert %s"
83
diff --git a/block/vxhs.c b/block/vxhs.c
84
new file mode 100644
85
index XXXXXXX..XXXXXXX
86
--- /dev/null
87
+++ b/block/vxhs.c
88
@@ -XXX,XX +XXX,XX @@
89
+/*
90
+ * QEMU Block driver for Veritas HyperScale (VxHS)
91
+ *
92
+ * Copyright (c) 2017 Veritas Technologies LLC.
93
+ *
94
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
95
+ * See the COPYING file in the top-level directory.
96
+ *
97
+ */
98
+
99
+#include "qemu/osdep.h"
100
+#include <qnio/qnio_api.h>
101
+#include <sys/param.h>
102
+#include "block/block_int.h"
103
+#include "qapi/qmp/qerror.h"
104
+#include "qapi/qmp/qdict.h"
105
+#include "qapi/qmp/qstring.h"
106
+#include "trace.h"
107
+#include "qemu/uri.h"
108
+#include "qapi/error.h"
109
+#include "qemu/uuid.h"
110
+#include "crypto/tlscredsx509.h"
111
+
112
+#define VXHS_OPT_FILENAME "filename"
113
+#define VXHS_OPT_VDISK_ID "vdisk-id"
114
+#define VXHS_OPT_SERVER "server"
115
+#define VXHS_OPT_HOST "host"
116
+#define VXHS_OPT_PORT "port"
117
+
118
+/* Only accessed under QEMU global mutex */
119
+static uint32_t vxhs_ref;
120
+
121
+typedef enum {
122
+ VDISK_AIO_READ,
123
+ VDISK_AIO_WRITE,
124
+} VDISKAIOCmd;
125
+
126
+/*
127
+ * HyperScale AIO callbacks structure
128
+ */
129
+typedef struct VXHSAIOCB {
130
+ BlockAIOCB common;
131
+ int err;
132
+} VXHSAIOCB;
133
+
134
+typedef struct VXHSvDiskHostsInfo {
135
+ void *dev_handle; /* Device handle */
136
+ char *host; /* Host name or IP */
137
+ int port; /* Host's port number */
138
+} VXHSvDiskHostsInfo;
139
+
140
+/*
141
+ * Structure per vDisk maintained for state
142
+ */
143
+typedef struct BDRVVXHSState {
144
+ VXHSvDiskHostsInfo vdisk_hostinfo; /* Per host info */
145
+ char *vdisk_guid;
146
+ char *tlscredsid; /* tlscredsid */
147
+} BDRVVXHSState;
148
+
149
+static void vxhs_complete_aio_bh(void *opaque)
150
+{
151
+ VXHSAIOCB *acb = opaque;
152
+ BlockCompletionFunc *cb = acb->common.cb;
153
+ void *cb_opaque = acb->common.opaque;
154
+ int ret = 0;
155
+
156
+ if (acb->err != 0) {
157
+ trace_vxhs_complete_aio(acb, acb->err);
158
+ ret = (-EIO);
159
+ }
160
+
161
+ qemu_aio_unref(acb);
162
+ cb(cb_opaque, ret);
163
+}
164
+
165
+/*
166
+ * Called from a libqnio thread
167
+ */
168
+static void vxhs_iio_callback(void *ctx, uint32_t opcode, uint32_t error)
169
+{
170
+ VXHSAIOCB *acb = NULL;
171
+
172
+ switch (opcode) {
173
+ case IRP_READ_REQUEST:
174
+ case IRP_WRITE_REQUEST:
175
+
176
+ /*
177
+ * ctx is VXHSAIOCB*
178
+ * ctx is NULL if error is QNIOERROR_CHANNEL_HUP
179
+ */
180
+ if (ctx) {
181
+ acb = ctx;
182
+ } else {
183
+ trace_vxhs_iio_callback(error);
184
+ goto out;
185
+ }
186
+
187
+ if (error) {
188
+ if (!acb->err) {
189
+ acb->err = error;
190
+ }
191
+ trace_vxhs_iio_callback(error);
192
+ }
193
+
194
+ aio_bh_schedule_oneshot(bdrv_get_aio_context(acb->common.bs),
195
+ vxhs_complete_aio_bh, acb);
196
+ break;
197
+
198
+ default:
199
+ if (error == QNIOERROR_HUP) {
200
+ /*
201
+ * Channel failed, spontaneous notification,
202
+ * not in response to I/O
203
+ */
204
+ trace_vxhs_iio_callback_chnfail(error, errno);
205
+ } else {
206
+ trace_vxhs_iio_callback_unknwn(opcode, error);
207
+ }
208
+ break;
209
+ }
210
+out:
211
+ return;
212
+}
213
+
214
+static QemuOptsList runtime_opts = {
215
+ .name = "vxhs",
216
+ .head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head),
217
+ .desc = {
218
+ {
219
+ .name = VXHS_OPT_FILENAME,
220
+ .type = QEMU_OPT_STRING,
221
+ .help = "URI to the Veritas HyperScale image",
222
+ },
223
+ {
224
+ .name = VXHS_OPT_VDISK_ID,
225
+ .type = QEMU_OPT_STRING,
226
+ .help = "UUID of the VxHS vdisk",
227
+ },
228
+ {
229
+ .name = "tls-creds",
230
+ .type = QEMU_OPT_STRING,
231
+ .help = "ID of the TLS/SSL credentials to use",
232
+ },
233
+ { /* end of list */ }
234
+ },
235
+};
236
+
237
+static QemuOptsList runtime_tcp_opts = {
238
+ .name = "vxhs_tcp",
239
+ .head = QTAILQ_HEAD_INITIALIZER(runtime_tcp_opts.head),
240
+ .desc = {
241
+ {
242
+ .name = VXHS_OPT_HOST,
243
+ .type = QEMU_OPT_STRING,
244
+ .help = "host address (ipv4 addresses)",
245
+ },
246
+ {
247
+ .name = VXHS_OPT_PORT,
248
+ .type = QEMU_OPT_NUMBER,
249
+ .help = "port number on which VxHSD is listening (default 9999)",
250
+ .def_value_str = "9999"
251
+ },
252
+ { /* end of list */ }
253
+ },
254
+};
255
+
256
+/*
257
+ * Parse incoming URI and populate *options with the host
258
+ * and device information
259
+ */
260
+static int vxhs_parse_uri(const char *filename, QDict *options)
261
+{
262
+ URI *uri = NULL;
263
+ char *port;
264
+ int ret = 0;
265
+
266
+ trace_vxhs_parse_uri_filename(filename);
267
+ uri = uri_parse(filename);
268
+ if (!uri || !uri->server || !uri->path) {
269
+ uri_free(uri);
270
+ return -EINVAL;
271
+ }
272
+
273
+ qdict_put(options, VXHS_OPT_SERVER".host", qstring_from_str(uri->server));
274
+
275
+ if (uri->port) {
276
+ port = g_strdup_printf("%d", uri->port);
277
+ qdict_put(options, VXHS_OPT_SERVER".port", qstring_from_str(port));
278
+ g_free(port);
279
+ }
280
+
281
+ qdict_put(options, "vdisk-id", qstring_from_str(uri->path));
282
+
283
+ trace_vxhs_parse_uri_hostinfo(uri->server, uri->port);
284
+ uri_free(uri);
285
+
286
+ return ret;
287
+}
288
+
289
+static void vxhs_parse_filename(const char *filename, QDict *options,
290
+ Error **errp)
291
+{
292
+ if (qdict_haskey(options, "vdisk-id") || qdict_haskey(options, "server")) {
293
+ error_setg(errp, "vdisk-id/server and a file name may not be specified "
294
+ "at the same time");
295
+ return;
296
+ }
297
+
298
+ if (strstr(filename, "://")) {
299
+ int ret = vxhs_parse_uri(filename, options);
300
+ if (ret < 0) {
301
+ error_setg(errp, "Invalid URI. URI should be of the form "
302
+ " vxhs://<host_ip>:<port>/<vdisk-id>");
303
+ }
304
+ }
305
+}
306
+
307
+static int vxhs_init_and_ref(void)
308
+{
309
+ if (vxhs_ref++ == 0) {
310
+ if (iio_init(QNIO_VERSION, vxhs_iio_callback)) {
311
+ return -ENODEV;
312
+ }
313
+ }
314
+ return 0;
315
+}
316
+
317
+static void vxhs_unref(void)
318
+{
319
+ if (--vxhs_ref == 0) {
320
+ iio_fini();
321
+ }
322
+}
323
+
324
+static void vxhs_get_tls_creds(const char *id, char **cacert,
325
+ char **key, char **cert, Error **errp)
326
+{
327
+ Object *obj;
328
+ QCryptoTLSCreds *creds;
329
+ QCryptoTLSCredsX509 *creds_x509;
330
+
331
+ obj = object_resolve_path_component(
332
+ object_get_objects_root(), id);
333
+
334
+ if (!obj) {
335
+ error_setg(errp, "No TLS credentials with id '%s'",
336
+ id);
337
+ return;
338
+ }
339
+
340
+ creds_x509 = (QCryptoTLSCredsX509 *)
341
+ object_dynamic_cast(obj, TYPE_QCRYPTO_TLS_CREDS_X509);
342
+
343
+ if (!creds_x509) {
344
+ error_setg(errp, "Object with id '%s' is not TLS credentials",
345
+ id);
346
+ return;
347
+ }
348
+
349
+ creds = &creds_x509->parent_obj;
350
+
351
+ if (creds->endpoint != QCRYPTO_TLS_CREDS_ENDPOINT_CLIENT) {
352
+ error_setg(errp,
353
+ "Expecting TLS credentials with a client endpoint");
354
+ return;
355
+ }
356
+
357
+ /*
358
+ * Get the cacert, client_cert and client_key file names.
359
+ */
360
+ if (!creds->dir) {
361
+ error_setg(errp, "TLS object missing 'dir' property value");
362
+ return;
363
+ }
364
+
365
+ *cacert = g_strdup_printf("%s/%s", creds->dir,
366
+ QCRYPTO_TLS_CREDS_X509_CA_CERT);
367
+ *cert = g_strdup_printf("%s/%s", creds->dir,
368
+ QCRYPTO_TLS_CREDS_X509_CLIENT_CERT);
369
+ *key = g_strdup_printf("%s/%s", creds->dir,
370
+ QCRYPTO_TLS_CREDS_X509_CLIENT_KEY);
371
+}
372
+
373
+static int vxhs_open(BlockDriverState *bs, QDict *options,
374
+ int bdrv_flags, Error **errp)
375
+{
376
+ BDRVVXHSState *s = bs->opaque;
377
+ void *dev_handlep;
378
+ QDict *backing_options = NULL;
379
+ QemuOpts *opts = NULL;
380
+ QemuOpts *tcp_opts = NULL;
381
+ char *of_vsa_addr = NULL;
382
+ Error *local_err = NULL;
383
+ const char *vdisk_id_opt;
384
+ const char *server_host_opt;
385
+ int ret = 0;
386
+ char *cacert = NULL;
387
+ char *client_key = NULL;
388
+ char *client_cert = NULL;
389
+
390
+ ret = vxhs_init_and_ref();
391
+ if (ret < 0) {
392
+ ret = -EINVAL;
393
+ goto out;
394
+ }
395
+
396
+ /* Create opts info from runtime_opts and runtime_tcp_opts list */
397
+ opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
398
+ tcp_opts = qemu_opts_create(&runtime_tcp_opts, NULL, 0, &error_abort);
399
+
400
+ qemu_opts_absorb_qdict(opts, options, &local_err);
401
+ if (local_err) {
402
+ ret = -EINVAL;
403
+ goto out;
404
+ }
405
+
406
+ /* vdisk-id is the disk UUID */
407
+ vdisk_id_opt = qemu_opt_get(opts, VXHS_OPT_VDISK_ID);
408
+ if (!vdisk_id_opt) {
409
+ error_setg(&local_err, QERR_MISSING_PARAMETER, VXHS_OPT_VDISK_ID);
410
+ ret = -EINVAL;
411
+ goto out;
412
+ }
413
+
414
+ /* vdisk-id may contain a leading '/' */
415
+ if (strlen(vdisk_id_opt) > UUID_FMT_LEN + 1) {
416
+ error_setg(&local_err, "vdisk-id cannot be more than %d characters",
417
+ UUID_FMT_LEN);
418
+ ret = -EINVAL;
419
+ goto out;
420
+ }
421
+
422
+ s->vdisk_guid = g_strdup(vdisk_id_opt);
423
+ trace_vxhs_open_vdiskid(vdisk_id_opt);
424
+
425
+ /* get the 'server.' arguments */
426
+ qdict_extract_subqdict(options, &backing_options, VXHS_OPT_SERVER".");
427
+
428
+ qemu_opts_absorb_qdict(tcp_opts, backing_options, &local_err);
429
+ if (local_err != NULL) {
430
+ ret = -EINVAL;
431
+ goto out;
432
+ }
433
+
434
+ server_host_opt = qemu_opt_get(tcp_opts, VXHS_OPT_HOST);
435
+ if (!server_host_opt) {
436
+ error_setg(&local_err, QERR_MISSING_PARAMETER,
437
+ VXHS_OPT_SERVER"."VXHS_OPT_HOST);
438
+ ret = -EINVAL;
439
+ goto out;
440
+ }
441
+
442
+ if (strlen(server_host_opt) > MAXHOSTNAMELEN) {
443
+ error_setg(&local_err, "server.host cannot be more than %d characters",
444
+ MAXHOSTNAMELEN);
445
+ ret = -EINVAL;
446
+ goto out;
447
+ }
448
+
449
+ /* check if we got tls-creds via the --object argument */
450
+ s->tlscredsid = g_strdup(qemu_opt_get(opts, "tls-creds"));
451
+ if (s->tlscredsid) {
452
+ vxhs_get_tls_creds(s->tlscredsid, &cacert, &client_key,
453
+ &client_cert, &local_err);
454
+ if (local_err != NULL) {
455
+ ret = -EINVAL;
456
+ goto out;
457
+ }
458
+ trace_vxhs_get_creds(cacert, client_key, client_cert);
459
+ }
460
+
461
+ s->vdisk_hostinfo.host = g_strdup(server_host_opt);
462
+ s->vdisk_hostinfo.port = g_ascii_strtoll(qemu_opt_get(tcp_opts,
463
+ VXHS_OPT_PORT),
464
+ NULL, 0);
465
+
466
+ trace_vxhs_open_hostinfo(s->vdisk_hostinfo.host,
467
+ s->vdisk_hostinfo.port);
468
+
469
+ of_vsa_addr = g_strdup_printf("of://%s:%d",
470
+ s->vdisk_hostinfo.host,
471
+ s->vdisk_hostinfo.port);
472
+
473
+ /*
474
+ * Open qnio channel to storage agent if not opened before
475
+ */
476
+ dev_handlep = iio_open(of_vsa_addr, s->vdisk_guid, 0,
477
+ cacert, client_key, client_cert);
478
+ if (dev_handlep == NULL) {
479
+ trace_vxhs_open_iio_open(of_vsa_addr);
480
+ ret = -ENODEV;
481
+ goto out;
482
+ }
483
+ s->vdisk_hostinfo.dev_handle = dev_handlep;
484
+
485
+out:
486
+ g_free(of_vsa_addr);
487
+ QDECREF(backing_options);
488
+ qemu_opts_del(tcp_opts);
489
+ qemu_opts_del(opts);
490
+ g_free(cacert);
491
+ g_free(client_key);
492
+ g_free(client_cert);
493
+
494
+ if (ret < 0) {
495
+ vxhs_unref();
496
+ error_propagate(errp, local_err);
497
+ g_free(s->vdisk_hostinfo.host);
498
+ g_free(s->vdisk_guid);
499
+ g_free(s->tlscredsid);
500
+ s->vdisk_guid = NULL;
501
+ }
502
+
503
+ return ret;
504
+}
505
+
506
+static const AIOCBInfo vxhs_aiocb_info = {
507
+ .aiocb_size = sizeof(VXHSAIOCB)
508
+};
509
+
510
+/*
511
+ * This allocates QEMU-VXHS callback for each IO
512
+ * and is passed to QNIO. When QNIO completes the work,
513
+ * it will be passed back through the callback.
514
+ */
515
+static BlockAIOCB *vxhs_aio_rw(BlockDriverState *bs, int64_t sector_num,
516
+ QEMUIOVector *qiov, int nb_sectors,
517
+ BlockCompletionFunc *cb, void *opaque,
518
+ VDISKAIOCmd iodir)
519
+{
520
+ VXHSAIOCB *acb = NULL;
521
+ BDRVVXHSState *s = bs->opaque;
522
+ size_t size;
523
+ uint64_t offset;
524
+ int iio_flags = 0;
525
+ int ret = 0;
526
+ void *dev_handle = s->vdisk_hostinfo.dev_handle;
527
+
528
+ offset = sector_num * BDRV_SECTOR_SIZE;
529
+ size = nb_sectors * BDRV_SECTOR_SIZE;
530
+ acb = qemu_aio_get(&vxhs_aiocb_info, bs, cb, opaque);
531
+
532
+ /*
533
+ * Initialize VXHSAIOCB.
534
+ */
535
+ acb->err = 0;
536
+
537
+ iio_flags = IIO_FLAG_ASYNC;
538
+
539
+ switch (iodir) {
540
+ case VDISK_AIO_WRITE:
541
+ ret = iio_writev(dev_handle, acb, qiov->iov, qiov->niov,
542
+ offset, (uint64_t)size, iio_flags);
543
+ break;
544
+ case VDISK_AIO_READ:
545
+ ret = iio_readv(dev_handle, acb, qiov->iov, qiov->niov,
546
+ offset, (uint64_t)size, iio_flags);
547
+ break;
548
+ default:
549
+ trace_vxhs_aio_rw_invalid(iodir);
550
+ goto errout;
551
+ }
552
+
553
+ if (ret != 0) {
554
+ trace_vxhs_aio_rw_ioerr(s->vdisk_guid, iodir, size, offset,
555
+ acb, ret, errno);
556
+ goto errout;
557
+ }
558
+ return &acb->common;
559
+
560
+errout:
561
+ qemu_aio_unref(acb);
562
+ return NULL;
563
+}
564
+
565
+static BlockAIOCB *vxhs_aio_readv(BlockDriverState *bs,
566
+ int64_t sector_num, QEMUIOVector *qiov,
567
+ int nb_sectors,
568
+ BlockCompletionFunc *cb, void *opaque)
569
+{
570
+ return vxhs_aio_rw(bs, sector_num, qiov, nb_sectors, cb,
571
+ opaque, VDISK_AIO_READ);
572
+}
573
+
574
+static BlockAIOCB *vxhs_aio_writev(BlockDriverState *bs,
575
+ int64_t sector_num, QEMUIOVector *qiov,
576
+ int nb_sectors,
577
+ BlockCompletionFunc *cb, void *opaque)
578
+{
579
+ return vxhs_aio_rw(bs, sector_num, qiov, nb_sectors,
580
+ cb, opaque, VDISK_AIO_WRITE);
581
+}
582
+
583
+static void vxhs_close(BlockDriverState *bs)
584
+{
585
+ BDRVVXHSState *s = bs->opaque;
586
+
587
+ trace_vxhs_close(s->vdisk_guid);
588
+
589
+ g_free(s->vdisk_guid);
590
+ s->vdisk_guid = NULL;
591
+
592
+ /*
593
+ * Close vDisk device
594
+ */
595
+ if (s->vdisk_hostinfo.dev_handle) {
596
+ iio_close(s->vdisk_hostinfo.dev_handle);
597
+ s->vdisk_hostinfo.dev_handle = NULL;
598
+ }
599
+
600
+ vxhs_unref();
601
+
602
+ /*
603
+ * Free the dynamically allocated host string etc
604
+ */
605
+ g_free(s->vdisk_hostinfo.host);
606
+ g_free(s->tlscredsid);
607
+ s->tlscredsid = NULL;
608
+ s->vdisk_hostinfo.host = NULL;
609
+ s->vdisk_hostinfo.port = 0;
610
+}
611
+
612
+static int64_t vxhs_get_vdisk_stat(BDRVVXHSState *s)
613
+{
614
+ int64_t vdisk_size = -1;
615
+ int ret = 0;
616
+ void *dev_handle = s->vdisk_hostinfo.dev_handle;
617
+
618
+ ret = iio_ioctl(dev_handle, IOR_VDISK_STAT, &vdisk_size, 0);
619
+ if (ret < 0) {
620
+ trace_vxhs_get_vdisk_stat_err(s->vdisk_guid, ret, errno);
621
+ return -EIO;
622
+ }
623
+
624
+ trace_vxhs_get_vdisk_stat(s->vdisk_guid, vdisk_size);
625
+ return vdisk_size;
626
+}
627
+
628
+/*
629
+ * Returns the size of vDisk in bytes. This is required
630
+ * by QEMU block upper block layer so that it is visible
631
+ * to guest.
632
+ */
633
+static int64_t vxhs_getlength(BlockDriverState *bs)
634
+{
635
+ BDRVVXHSState *s = bs->opaque;
636
+ int64_t vdisk_size;
637
+
638
+ vdisk_size = vxhs_get_vdisk_stat(s);
639
+ if (vdisk_size < 0) {
640
+ return -EIO;
641
+ }
642
+
643
+ return vdisk_size;
644
+}
645
+
646
+static BlockDriver bdrv_vxhs = {
647
+ .format_name = "vxhs",
648
+ .protocol_name = "vxhs",
649
+ .instance_size = sizeof(BDRVVXHSState),
650
+ .bdrv_file_open = vxhs_open,
651
+ .bdrv_parse_filename = vxhs_parse_filename,
652
+ .bdrv_close = vxhs_close,
653
+ .bdrv_getlength = vxhs_getlength,
654
+ .bdrv_aio_readv = vxhs_aio_readv,
655
+ .bdrv_aio_writev = vxhs_aio_writev,
656
+};
657
+
658
+static void bdrv_vxhs_init(void)
659
+{
660
+ bdrv_register(&bdrv_vxhs);
661
+}
662
+
663
+block_init(bdrv_vxhs_init);
664
diff --git a/configure b/configure
665
index XXXXXXX..XXXXXXX 100755
17
index XXXXXXX..XXXXXXX 100755
666
--- a/configure
18
--- a/tests/check-block.sh
667
+++ b/configure
19
+++ b/tests/check-block.sh
668
@@ -XXX,XX +XXX,XX @@ numa=""
20
@@ -XXX,XX +XXX,XX @@ if grep -q "TARGET_GPROF=y" *-softmmu/config-target.mak 2>/dev/null ; then
669
tcmalloc="no"
21
exit 0
670
jemalloc="no"
671
replication="yes"
672
+vxhs=""
673
674
supported_cpu="no"
675
supported_os="no"
676
@@ -XXX,XX +XXX,XX @@ for opt do
677
;;
678
--enable-replication) replication="yes"
679
;;
680
+ --disable-vxhs) vxhs="no"
681
+ ;;
682
+ --enable-vxhs) vxhs="yes"
683
+ ;;
684
*)
685
echo "ERROR: unknown option $opt"
686
echo "Try '$0 --help' for more information"
687
@@ -XXX,XX +XXX,XX @@ disabled with --disable-FEATURE, default is enabled if available:
688
xfsctl xfsctl support
689
qom-cast-debug cast debugging support
690
tools build qemu-io, qemu-nbd and qemu-image tools
691
+ vxhs Veritas HyperScale vDisk backend support
692
693
NOTE: The object files are built at the place where configure is launched
694
EOF
695
@@ -XXX,XX +XXX,XX @@ if compile_prog "" "" ; then
696
fi
22
fi
697
23
698
##########################################
24
+if grep -q "CFLAGS.*-fsanitize" config-host.mak 2>/dev/null ; then
699
+# Veritas HyperScale block driver VxHS
25
+ echo "Sanitizers are enabled ==> Not running the qemu-iotests."
700
+# Check if libvxhs is installed
26
+ exit 0
701
+
702
+if test "$vxhs" != "no" ; then
703
+ cat > $TMPC <<EOF
704
+#include <stdint.h>
705
+#include <qnio/qnio_api.h>
706
+
707
+void *vxhs_callback;
708
+
709
+int main(void) {
710
+ iio_init(QNIO_VERSION, vxhs_callback);
711
+ return 0;
712
+}
713
+EOF
714
+ vxhs_libs="-lvxhs -lssl"
715
+ if compile_prog "" "$vxhs_libs" ; then
716
+ vxhs=yes
717
+ else
718
+ if test "$vxhs" = "yes" ; then
719
+ feature_not_found "vxhs block device" "Install libvxhs See github"
720
+ fi
721
+ vxhs=no
722
+ fi
723
+fi
27
+fi
724
+
28
+
725
+##########################################
29
if [ -z "$(find . -name 'qemu-system-*' -print)" ]; then
726
# End of CC checks
30
echo "No qemu-system binary available ==> Not running the qemu-iotests."
727
# After here, no more $cc or $ld runs
31
exit 0
728
729
@@ -XXX,XX +XXX,XX @@ echo "tcmalloc support $tcmalloc"
730
echo "jemalloc support $jemalloc"
731
echo "avx2 optimization $avx2_opt"
732
echo "replication support $replication"
733
+echo "VxHS block device $vxhs"
734
735
if test "$sdl_too_old" = "yes"; then
736
echo "-> Your SDL version is too old - please upgrade to have SDL support"
737
@@ -XXX,XX +XXX,XX @@ if test "$pthread_setname_np" = "yes" ; then
738
echo "CONFIG_PTHREAD_SETNAME_NP=y" >> $config_host_mak
739
fi
740
741
+if test "$vxhs" = "yes" ; then
742
+ echo "CONFIG_VXHS=y" >> $config_host_mak
743
+ echo "VXHS_LIBS=$vxhs_libs" >> $config_host_mak
744
+fi
745
+
746
if test "$tcg_interpreter" = "yes"; then
747
QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/tci $QEMU_INCLUDES"
748
elif test "$ARCH" = "sparc64" ; then
749
diff --git a/qapi/block-core.json b/qapi/block-core.json
750
index XXXXXXX..XXXXXXX 100644
751
--- a/qapi/block-core.json
752
+++ b/qapi/block-core.json
753
@@ -XXX,XX +XXX,XX @@
754
#
755
# Drivers that are supported in block device operations.
756
#
757
+# @vxhs: Since 2.10
758
+#
759
# Since: 2.9
760
##
761
{ 'enum': 'BlockdevDriver',
762
@@ -XXX,XX +XXX,XX @@
763
'host_device', 'http', 'https', 'iscsi', 'luks', 'nbd', 'nfs',
764
'null-aio', 'null-co', 'parallels', 'qcow', 'qcow2', 'qed',
765
'quorum', 'raw', 'rbd', 'replication', 'sheepdog', 'ssh',
766
- 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat' ] }
767
+ 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat', 'vxhs' ] }
768
769
##
770
# @BlockdevOptionsFile:
771
@@ -XXX,XX +XXX,XX @@
772
'data': { '*offset': 'int', '*size': 'int' } }
773
774
##
775
+# @BlockdevOptionsVxHS:
776
+#
777
+# Driver specific block device options for VxHS
778
+#
779
+# @vdisk-id: UUID of VxHS volume
780
+# @server: vxhs server IP, port
781
+# @tls-creds: TLS credentials ID
782
+#
783
+# Since: 2.10
784
+##
785
+{ 'struct': 'BlockdevOptionsVxHS',
786
+ 'data': { 'vdisk-id': 'str',
787
+ 'server': 'InetSocketAddressBase',
788
+ '*tls-creds': 'str' } }
789
+
790
+##
791
# @BlockdevOptions:
792
#
793
# Options for creating a block device. Many options are available for all
794
@@ -XXX,XX +XXX,XX @@
795
'vhdx': 'BlockdevOptionsGenericFormat',
796
'vmdk': 'BlockdevOptionsGenericCOWFormat',
797
'vpc': 'BlockdevOptionsGenericFormat',
798
- 'vvfat': 'BlockdevOptionsVVFAT'
799
+ 'vvfat': 'BlockdevOptionsVVFAT',
800
+ 'vxhs': 'BlockdevOptionsVxHS'
801
} }
802
803
##
804
--
32
--
805
2.9.3
33
2.21.0
806
34
807
35
diff view generated by jsdifflib
1
Signed-off-by: Jeff Cody <jcody@redhat.com>
1
From: Nir Soffer <nirsof@gmail.com>
2
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2
3
Reviewed-by: John Snow <jsnow@redhat.com>
3
Quoting cache mode is not needed, and most tests use unquoted values.
4
Message-id: 00aed7ffdd7be4b9ed9ce1007d50028a72b34ebe.1491597120.git.jcody@redhat.com
4
Unify all test to use the same style.
5
6
Message-id: 20190827173432.7656-1-nsoffer@redhat.com
7
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
5
---
9
---
6
block.c | 14 ++++++++------
10
tests/qemu-iotests/026 | 4 ++--
7
1 file changed, 8 insertions(+), 6 deletions(-)
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(-)
8
15
9
diff --git a/block.c b/block.c
16
diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026
10
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100755
11
--- a/block.c
18
--- a/tests/qemu-iotests/026
12
+++ b/block.c
19
+++ b/tests/qemu-iotests/026
13
@@ -XXX,XX +XXX,XX @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
20
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
14
BlockDriver *drv;
21
# Currently only qcow2 supports rebasing
15
QemuOpts *opts;
22
_supported_fmt qcow2
16
const char *value;
23
_supported_proto file
17
+ bool read_only;
24
-_default_cache_mode "writethrough"
18
25
-_supported_cache_modes "writethrough" "none"
19
assert(reopen_state != NULL);
26
+_default_cache_mode writethrough
20
assert(reopen_state->bs->drv != NULL);
27
+_supported_cache_modes writethrough none
21
@@ -XXX,XX +XXX,XX @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,
28
# The refcount table tests expect a certain minimum width for refcount entries
22
qdict_put(reopen_state->options, "driver", qstring_from_str(value));
29
# (so that the refcount table actually needs to grow); that minimum is 16 bits,
23
}
30
# being the default refcount entry width.
24
31
diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039
25
- /* if we are to stay read-only, do not allow permission change
32
index XXXXXXX..XXXXXXX 100755
26
- * to r/w */
33
--- a/tests/qemu-iotests/039
27
- if (!(reopen_state->bs->open_flags & BDRV_O_ALLOW_RDWR) &&
34
+++ b/tests/qemu-iotests/039
28
- reopen_state->flags & BDRV_O_RDWR) {
35
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
29
- error_setg(errp, "Node '%s' is read only",
36
_supported_fmt qcow2
30
- bdrv_get_device_or_node_name(reopen_state->bs));
37
_supported_proto file
31
+ /* If we are to stay read-only, do not allow permission change
38
_supported_os Linux
32
+ * to r/w. Attempting to set to r/w may fail if either BDRV_O_ALLOW_RDWR is
39
-_default_cache_mode "writethrough"
33
+ * not set, or if the BDS still has copy_on_read enabled */
40
-_supported_cache_modes "writethrough"
34
+ read_only = !(reopen_state->flags & BDRV_O_RDWR);
41
+_default_cache_mode writethrough
35
+ ret = bdrv_can_set_read_only(reopen_state->bs, read_only, &local_err);
42
+_supported_cache_modes writethrough
36
+ if (local_err) {
43
37
+ error_propagate(errp, local_err);
44
size=128M
38
goto error;
45
39
}
46
diff --git a/tests/qemu-iotests/052 b/tests/qemu-iotests/052
47
index XXXXXXX..XXXXXXX 100755
48
--- a/tests/qemu-iotests/052
49
+++ b/tests/qemu-iotests/052
50
@@ -XXX,XX +XXX,XX @@ _supported_fmt generic
51
_supported_proto file
52
53
# Don't do O_DIRECT on tmpfs
54
-_supported_cache_modes "writeback" "writethrough" "unsafe"
55
+_supported_cache_modes writeback writethrough unsafe
56
57
size=128M
58
_make_test_img $size
59
diff --git a/tests/qemu-iotests/091 b/tests/qemu-iotests/091
60
index XXXXXXX..XXXXXXX 100755
61
--- a/tests/qemu-iotests/091
62
+++ b/tests/qemu-iotests/091
63
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
64
_supported_fmt qcow2
65
_supported_proto file
66
_supported_os Linux
67
-_default_cache_mode "none"
68
-_supported_cache_modes "writethrough" "none" "writeback"
69
+_default_cache_mode none
70
+_supported_cache_modes writethrough none writeback
71
72
size=1G
40
73
41
--
74
--
42
2.9.3
75
2.21.0
43
76
44
77
diff view generated by jsdifflib