1
The following changes since commit 136c67e07869227b21b3f627316e03679ce7b738:
1
The following changes since commit 23919ddfd56135cad3cb468a8f54d5a595f024f4:
2
2
3
Merge remote-tracking branch 'remotes/bkoppelmann/tags/pull-tricore-2018-03-02' into staging (2018-03-02 16:56:20 +0000)
3
Merge remote-tracking branch 'remotes/aperard/tags/pull-xen-20190827' into staging (2019-08-27 15:52:36 +0100)
4
4
5
are available in the Git repository at:
5
are available in the Git repository at:
6
6
7
git://github.com/stefanha/qemu.git tags/block-pull-request
7
https://github.com/XanClic/qemu.git tags/pull-block-2019-08-27
8
8
9
for you to fetch changes up to 23500c6a9409efc80d696aede0629bfbe7556a90:
9
for you to fetch changes up to bb043c056cffcc2f3ce88bfdaf2e76e455c09e2c:
10
10
11
README: Document 'git-publish' workflow (2018-03-05 09:03:17 +0000)
11
iotests: Unify cache mode quoting (2019-08-27 19:48:44 +0200)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Pull request
14
Block patches:
15
15
- qemu-io now accepts a file to read a write pattern from
16
Mostly patches that are only indirectly related to the block layer, but I've
16
- Ensure that raw files have their first block allocated so we can probe
17
reviewed them and there is no maintainer.
17
the O_DIRECT alignment if necessary
18
- Various fixes
18
19
19
----------------------------------------------------------------
20
----------------------------------------------------------------
21
Denis Plotnikov (1):
22
qemu-io: add pattern file for write command
20
23
21
Fam Zheng (2):
24
Max Reitz (7):
22
Add a git-publish configuration file
25
iotests: Fix _filter_img_create()
23
README: Document 'git-publish' workflow
26
vmdk: Use bdrv_dirname() for relative extent paths
27
iotests: Keep testing broken relative extent paths
28
vmdk: Reject invalid compressed writes
29
iotests: Disable broken streamOptimized tests
30
iotests: Disable 110 for vmdk.twoGbMaxExtentSparse
31
iotests: Disable 126 for flat vmdk subformats
24
32
25
Su Hang (3):
33
Nir Soffer (3):
26
util/uri.c: Coding style check, Only whitespace involved
34
block: posix: Always allocate the first block
27
util/uri.c: remove brackets that wrap `return` statement's content.
35
iotests: Test allocate_first_block() with O_DIRECT
28
util/uri.c: wrap single statement blocks with braces {}
36
iotests: Unify cache mode quoting
29
37
30
Thomas Huth (1):
38
Stefan Hajnoczi (1):
31
tests/libqos: Check for valid dev pointer when looking for PCI devices
39
file-posix: fix request_alignment typo
32
40
33
tests/libqos/virtio-pci.c | 4 +-
41
Thomas Huth (2):
34
util/uri.c | 1733 ++++++++++++++++++++++++---------------------
42
iotests: Check for enabled drivers before testing them
35
.gitpublish | 51 ++
43
tests/check-block: Skip iotests when sanitizers are enabled
36
README | 31 +-
44
37
4 files changed, 1014 insertions(+), 805 deletions(-)
45
Vladimir Sementsov-Ogievskiy (1):
38
create mode 100644 .gitpublish
46
block: fix permission update in bdrv_replace_node
47
48
block.c | 5 +-
49
block/file-posix.c | 53 +++++++++-
50
block/vmdk.c | 64 ++++++++----
51
qemu-io-cmds.c | 99 +++++++++++++++++--
52
tests/check-block.sh | 5 +
53
tests/qemu-iotests/002 | 1 +
54
tests/qemu-iotests/003 | 1 +
55
tests/qemu-iotests/005 | 3 +-
56
tests/qemu-iotests/009 | 1 +
57
tests/qemu-iotests/010 | 1 +
58
tests/qemu-iotests/011 | 1 +
59
tests/qemu-iotests/017 | 3 +-
60
tests/qemu-iotests/018 | 3 +-
61
tests/qemu-iotests/019 | 3 +-
62
tests/qemu-iotests/020 | 3 +-
63
tests/qemu-iotests/026 | 4 +-
64
tests/qemu-iotests/027 | 1 +
65
tests/qemu-iotests/032 | 1 +
66
tests/qemu-iotests/033 | 1 +
67
tests/qemu-iotests/034 | 3 +-
68
tests/qemu-iotests/037 | 3 +-
69
tests/qemu-iotests/039 | 4 +-
70
tests/qemu-iotests/052 | 2 +-
71
tests/qemu-iotests/059 | 34 ++++++-
72
tests/qemu-iotests/059.out | 26 +++--
73
tests/qemu-iotests/063 | 3 +-
74
tests/qemu-iotests/071 | 1 +
75
tests/qemu-iotests/072 | 1 +
76
tests/qemu-iotests/081 | 4 +-
77
tests/qemu-iotests/091 | 4 +-
78
tests/qemu-iotests/099 | 1 +
79
tests/qemu-iotests/105 | 3 +-
80
tests/qemu-iotests/110 | 3 +-
81
tests/qemu-iotests/120 | 1 +
82
tests/qemu-iotests/126 | 2 +
83
tests/qemu-iotests/{150.out => 150.out.qcow2} | 0
84
tests/qemu-iotests/150.out.raw | 12 +++
85
tests/qemu-iotests/162 | 4 +-
86
tests/qemu-iotests/175 | 47 +++++++--
87
tests/qemu-iotests/175.out | 16 ++-
88
tests/qemu-iotests/178.out.qcow2 | 4 +-
89
tests/qemu-iotests/184 | 1 +
90
tests/qemu-iotests/186 | 1 +
91
tests/qemu-iotests/197 | 1 +
92
tests/qemu-iotests/215 | 1 +
93
tests/qemu-iotests/221.out | 12 ++-
94
tests/qemu-iotests/251 | 1 +
95
tests/qemu-iotests/253.out | 12 ++-
96
tests/qemu-iotests/common.filter | 4 +-
97
tests/qemu-iotests/common.rc | 14 +++
98
50 files changed, 391 insertions(+), 87 deletions(-)
99
rename tests/qemu-iotests/{150.out => 150.out.qcow2} (100%)
100
create mode 100644 tests/qemu-iotests/150.out.raw
39
101
40
--
102
--
41
2.14.3
103
2.21.0
42
104
43
105
diff view generated by jsdifflib
1
From: Su Hang <suhang16@mails.ucas.ac.cn>
1
From: Denis Plotnikov <dplotnikov@virtuozzo.com>
2
2
3
Using `clang-format -i util/uri.c` first, then change back few code
3
The patch allows to provide a pattern file for write
4
manually, to make sure only whitespace involved.
4
command. There was no similar ability before.
5
5
6
Signed-off-by: Su Hang <suhang16@mails.ucas.ac.cn>
6
Signed-off-by: Denis Plotnikov <dplotnikov@virtuozzo.com>
7
Reviewed-by: Thomas Huth <thuth@redhat.com>
7
Message-id: 20190820164616.4072-1-dplotnikov@virtuozzo.com
8
Message-id: 1519533358-13759-2-git-send-email-suhang16@mails.ucas.ac.cn
8
Reviewed-by: Eric Blake <eblake@redhat.com>
9
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9
[mreitz: Keep optstring in alphabetical order]
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
---
11
---
11
util/uri.c | 1450 ++++++++++++++++++++++++++++++------------------------------
12
qemu-io-cmds.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++---
12
1 file changed, 726 insertions(+), 724 deletions(-)
13
1 file changed, 93 insertions(+), 6 deletions(-)
13
14
14
diff --git a/util/uri.c b/util/uri.c
15
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
15
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
16
--- a/util/uri.c
17
--- a/qemu-io-cmds.c
17
+++ b/util/uri.c
18
+++ b/qemu-io-cmds.c
18
@@ -XXX,XX +XXX,XX @@ static void uri_clean(URI *uri);
19
@@ -XXX,XX +XXX,XX @@ static void qemu_io_free(void *p)
19
*/
20
qemu_vfree(p);
20
#define IS_ALPHA(x) (IS_LOWALPHA(x) || IS_UPALPHA(x))
21
}
21
22
22
-
23
+/*
23
/*
24
+ * qemu_io_alloc_from_file()
24
* lowalpha = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" |
25
+ *
25
* "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" |
26
+ * Allocates the buffer and populates it with the content of the given file
26
@@ -XXX,XX +XXX,XX @@ static void uri_clean(URI *uri);
27
+ * up to @len bytes. If the file length is less than @len, then the buffer
27
* mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")"
28
+ * is populated with the file content cyclically.
28
*/
29
+ *
29
30
+ * @blk - the block backend where the buffer content is going to be written to
30
-#define IS_MARK(x) (((x) == '-') || ((x) == '_') || ((x) == '.') || \
31
+ * @len - the buffer length
31
- ((x) == '!') || ((x) == '~') || ((x) == '*') || ((x) == '\'') || \
32
+ * @file_name - the file to read the content from
32
+#define IS_MARK(x) (((x) == '-') || ((x) == '_') || ((x) == '.') || \
33
+ *
33
+ ((x) == '!') || ((x) == '~') || ((x) == '*') || ((x) == '\'') || \
34
+ * Returns: the buffer pointer on success
34
((x) == '(') || ((x) == ')'))
35
+ * NULL on error
35
36
+ */
36
/*
37
+static void *qemu_io_alloc_from_file(BlockBackend *blk, size_t len,
37
* unwise = "{" | "}" | "|" | "\" | "^" | "`"
38
+ const char *file_name)
38
*/
39
40
-#define IS_UNWISE(p) \
41
- (((*(p) == '{')) || ((*(p) == '}')) || ((*(p) == '|')) || \
42
- ((*(p) == '\\')) || ((*(p) == '^')) || ((*(p) == '[')) || \
43
- ((*(p) == ']')) || ((*(p) == '`')))
44
+#define IS_UNWISE(p) \
45
+ (((*(p) == '{')) || ((*(p) == '}')) || ((*(p) == '|')) || \
46
+ ((*(p) == '\\')) || ((*(p) == '^')) || ((*(p) == '[')) || \
47
+ ((*(p) == ']')) || ((*(p) == '`')))
48
/*
49
* reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | "," |
50
* "[" | "]"
51
*/
52
53
-#define IS_RESERVED(x) (((x) == ';') || ((x) == '/') || ((x) == '?') || \
54
- ((x) == ':') || ((x) == '@') || ((x) == '&') || ((x) == '=') || \
55
- ((x) == '+') || ((x) == '$') || ((x) == ',') || ((x) == '[') || \
56
- ((x) == ']'))
57
+#define IS_RESERVED(x) (((x) == ';') || ((x) == '/') || ((x) == '?') || \
58
+ ((x) == ':') || ((x) == '@') || ((x) == '&') || ((x) == '=') || \
59
+ ((x) == '+') || ((x) == '$') || ((x) == ',') || ((x) == '[') || \
60
+ ((x) == ']'))
61
62
/*
63
* unreserved = alphanum | mark
64
@@ -XXX,XX +XXX,XX @@ static void uri_clean(URI *uri);
65
* Skip to next pointer char, handle escaped sequences
66
*/
67
68
-#define NEXT(p) ((*p == '%')? p += 3 : p++)
69
+#define NEXT(p) ((*p == '%') ? p += 3 : p++)
70
71
/*
72
* Productions from the spec.
73
@@ -XXX,XX +XXX,XX @@ static void uri_clean(URI *uri);
74
* path = [ abs_path | opaque_part ]
75
*/
76
77
-
78
/************************************************************************
79
- *                                    *
80
- * RFC 3986 parser                *
81
- *                                    *
82
+ * *
83
+ * RFC 3986 parser *
84
+ * *
85
************************************************************************/
86
87
#define ISA_DIGIT(p) ((*(p) >= '0') && (*(p) <= '9'))
88
-#define ISA_ALPHA(p) (((*(p) >= 'a') && (*(p) <= 'z')) ||        \
89
+#define ISA_ALPHA(p) (((*(p) >= 'a') && (*(p) <= 'z')) || \
90
((*(p) >= 'A') && (*(p) <= 'Z')))
91
-#define ISA_HEXDIG(p)                            \
92
- (ISA_DIGIT(p) || ((*(p) >= 'a') && (*(p) <= 'f')) ||        \
93
- ((*(p) >= 'A') && (*(p) <= 'F')))
94
+#define ISA_HEXDIG(p) \
95
+ (ISA_DIGIT(p) || ((*(p) >= 'a') && (*(p) <= 'f')) || \
96
+ ((*(p) >= 'A') && (*(p) <= 'F')))
97
98
/*
99
* sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
100
* / "*" / "+" / "," / ";" / "="
101
*/
102
-#define ISA_SUB_DELIM(p)                        \
103
- (((*(p) == '!')) || ((*(p) == '$')) || ((*(p) == '&')) ||        \
104
- ((*(p) == '(')) || ((*(p) == ')')) || ((*(p) == '*')) ||        \
105
- ((*(p) == '+')) || ((*(p) == ',')) || ((*(p) == ';')) ||        \
106
- ((*(p) == '=')) || ((*(p) == '\'')))
107
+#define ISA_SUB_DELIM(p) \
108
+ (((*(p) == '!')) || ((*(p) == '$')) || ((*(p) == '&')) || \
109
+ ((*(p) == '(')) || ((*(p) == ')')) || ((*(p) == '*')) || \
110
+ ((*(p) == '+')) || ((*(p) == ',')) || ((*(p) == ';')) || \
111
+ ((*(p) == '=')) || ((*(p) == '\'')))
112
113
/*
114
* gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@"
115
*/
116
-#define ISA_GEN_DELIM(p)                        \
117
- (((*(p) == ':')) || ((*(p) == '/')) || ((*(p) == '?')) || \
118
- ((*(p) == '#')) || ((*(p) == '[')) || ((*(p) == ']')) || \
119
- ((*(p) == '@')))
120
+#define ISA_GEN_DELIM(p) \
121
+ (((*(p) == ':')) || ((*(p) == '/')) || ((*(p) == '?')) || \
122
+ ((*(p) == '#')) || ((*(p) == '[')) || ((*(p) == ']')) || \
123
+ ((*(p) == '@')))
124
125
/*
126
* reserved = gen-delims / sub-delims
127
@@ -XXX,XX +XXX,XX @@ static void uri_clean(URI *uri);
128
/*
129
* unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
130
*/
131
-#define ISA_UNRESERVED(p)                        \
132
- ((ISA_ALPHA(p)) || (ISA_DIGIT(p)) || ((*(p) == '-')) ||        \
133
- ((*(p) == '.')) || ((*(p) == '_')) || ((*(p) == '~')))
134
+#define ISA_UNRESERVED(p) \
135
+ ((ISA_ALPHA(p)) || (ISA_DIGIT(p)) || ((*(p) == '-')) || \
136
+ ((*(p) == '.')) || ((*(p) == '_')) || ((*(p) == '~')))
137
138
/*
139
* pct-encoded = "%" HEXDIG HEXDIG
140
*/
141
-#define ISA_PCT_ENCODED(p)                        \
142
- ((*(p) == '%') && (ISA_HEXDIG(p + 1)) && (ISA_HEXDIG(p + 2)))
143
+#define ISA_PCT_ENCODED(p) \
144
+ ((*(p) == '%') && (ISA_HEXDIG(p + 1)) && (ISA_HEXDIG(p + 2)))
145
146
/*
147
* pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
148
*/
149
-#define ISA_PCHAR(p)                            \
150
- (ISA_UNRESERVED(p) || ISA_PCT_ENCODED(p) || ISA_SUB_DELIM(p) ||    \
151
- ((*(p) == ':')) || ((*(p) == '@')))
152
+#define ISA_PCHAR(p) \
153
+ (ISA_UNRESERVED(p) || ISA_PCT_ENCODED(p) || ISA_SUB_DELIM(p) || \
154
+ ((*(p) == ':')) || ((*(p) == '@')))
155
156
/**
157
* rfc3986_parse_scheme:
158
@@ -XXX,XX +XXX,XX @@ static void uri_clean(URI *uri);
159
*
160
* Returns 0 or the error code
161
*/
162
-static int
163
-rfc3986_parse_scheme(URI *uri, const char **str) {
164
+static int rfc3986_parse_scheme(URI *uri, const char **str)
165
+{
39
+{
166
const char *cur;
40
+ char *buf, *buf_origin;
167
41
+ FILE *f = fopen(file_name, "r");
168
if (str == NULL)
42
+ int pattern_len;
169
-    return(-1);
43
+
170
+ return (-1);
44
+ if (!f) {
171
45
+ perror(file_name);
172
cur = *str;
46
+ return NULL;
173
if (!ISA_ALPHA(cur))
47
+ }
174
-    return(2);
48
+
175
+ return (2);
49
+ if (qemuio_misalign) {
176
cur++;
50
+ len += MISALIGN_OFFSET;
177
- while (ISA_ALPHA(cur) || ISA_DIGIT(cur) ||
51
+ }
178
- (*cur == '+') || (*cur == '-') || (*cur == '.')) cur++;
52
+
179
+ while (ISA_ALPHA(cur) || ISA_DIGIT(cur) || (*cur == '+') || (*cur == '-') ||
53
+ buf_origin = buf = blk_blockalign(blk, len);
180
+ (*cur == '.'))
54
+
181
+ cur++;
55
+ if (qemuio_misalign) {
182
if (uri != NULL) {
56
+ buf_origin += MISALIGN_OFFSET;
183
g_free(uri->scheme);
57
+ buf += MISALIGN_OFFSET;
184
-    uri->scheme = g_strndup(*str, cur - *str);
58
+ len -= MISALIGN_OFFSET;
185
+ uri->scheme = g_strndup(*str, cur - *str);
59
+ }
60
+
61
+ pattern_len = fread(buf_origin, 1, len, f);
62
+
63
+ if (ferror(f)) {
64
+ perror(file_name);
65
+ goto error;
66
+ }
67
+
68
+ if (pattern_len == 0) {
69
+ fprintf(stderr, "%s: file is empty\n", file_name);
70
+ goto error;
71
+ }
72
+
73
+ fclose(f);
74
+
75
+ if (len > pattern_len) {
76
+ len -= pattern_len;
77
+ buf += pattern_len;
78
+
79
+ while (len > 0) {
80
+ size_t len_to_copy = MIN(pattern_len, len);
81
+
82
+ memcpy(buf, buf_origin, len_to_copy);
83
+
84
+ len -= len_to_copy;
85
+ buf += len_to_copy;
86
+ }
87
+ }
88
+
89
+ return buf_origin;
90
+
91
+error:
92
+ qemu_io_free(buf_origin);
93
+ return NULL;
94
+}
95
+
96
static void dump_buffer(const void *buffer, int64_t offset, int64_t len)
97
{
98
uint64_t i;
99
@@ -XXX,XX +XXX,XX @@ static void write_help(void)
100
" -n, -- with -z, don't allow slow fallback\n"
101
" -p, -- ignored for backwards compatibility\n"
102
" -P, -- use different pattern to fill file\n"
103
+" -s, -- use a pattern file to fill the write buffer\n"
104
" -C, -- report statistics in a machine parsable format\n"
105
" -q, -- quiet mode, do not show I/O statistics\n"
106
" -u, -- with -z, allow unmapping\n"
107
@@ -XXX,XX +XXX,XX @@ static const cmdinfo_t write_cmd = {
108
.perm = BLK_PERM_WRITE,
109
.argmin = 2,
110
.argmax = -1,
111
- .args = "[-bcCfnquz] [-P pattern] off len",
112
+ .args = "[-bcCfnquz] [-P pattern | -s source_file] off len",
113
.oneline = "writes a number of bytes at a specified offset",
114
.help = write_help,
115
};
116
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
117
{
118
struct timespec t1, t2;
119
bool Cflag = false, qflag = false, bflag = false;
120
- bool Pflag = false, zflag = false, cflag = false;
121
+ bool Pflag = false, zflag = false, cflag = false, sflag = false;
122
int flags = 0;
123
int c, cnt, ret;
124
char *buf = NULL;
125
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
126
/* Some compilers get confused and warn if this is not initialized. */
127
int64_t total = 0;
128
int pattern = 0xcd;
129
+ const char *file_name = NULL;
130
131
- while ((c = getopt(argc, argv, "bcCfnpP:quz")) != -1) {
132
+ while ((c = getopt(argc, argv, "bcCfnpP:qs:uz")) != -1) {
133
switch (c) {
134
case 'b':
135
bflag = true;
136
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
137
case 'q':
138
qflag = true;
139
break;
140
+ case 's':
141
+ sflag = true;
142
+ file_name = optarg;
143
+ break;
144
case 'u':
145
flags |= BDRV_REQ_MAY_UNMAP;
146
break;
147
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
148
return -EINVAL;
186
}
149
}
187
*str = cur;
150
188
- return(0);
151
- if (zflag && Pflag) {
189
+ return (0);
152
- printf("-z and -P cannot be specified at the same time\n");
190
}
153
+ if (zflag + Pflag + sflag > 1) {
191
154
+ printf("Only one of -z, -P, and -s "
192
/**
155
+ "can be specified at the same time\n");
193
@@ -XXX,XX +XXX,XX @@ rfc3986_parse_scheme(URI *uri, const char **str) {
156
return -EINVAL;
194
*
195
* Returns 0 or the error code
196
*/
197
-static int
198
-rfc3986_parse_fragment(URI *uri, const char **str)
199
+static int rfc3986_parse_fragment(URI *uri, const char **str)
200
{
201
const char *cur;
202
203
@@ -XXX,XX +XXX,XX @@ rfc3986_parse_fragment(URI *uri, const char **str)
204
NEXT(cur);
205
if (uri != NULL) {
206
g_free(uri->fragment);
207
-    if (uri->cleanup & 2)
208
-     uri->fragment = g_strndup(*str, cur - *str);
209
-    else
210
-     uri->fragment = uri_string_unescape(*str, cur - *str, NULL);
211
+ if (uri->cleanup & 2)
212
+ uri->fragment = g_strndup(*str, cur - *str);
213
+ else
214
+ uri->fragment = uri_string_unescape(*str, cur - *str, NULL);
215
}
157
}
216
*str = cur;
158
217
return (0);
159
@@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv)
218
@@ -XXX,XX +XXX,XX @@ rfc3986_parse_fragment(URI *uri, const char **str)
219
*
220
* Returns 0 or the error code
221
*/
222
-static int
223
-rfc3986_parse_query(URI *uri, const char **str)
224
+static int rfc3986_parse_query(URI *uri, const char **str)
225
{
226
const char *cur;
227
228
@@ -XXX,XX +XXX,XX @@ rfc3986_parse_query(URI *uri, const char **str)
229
NEXT(cur);
230
if (uri != NULL) {
231
g_free(uri->query);
232
-    uri->query = g_strndup (*str, cur - *str);
233
+ uri->query = g_strndup(*str, cur - *str);
234
}
160
}
235
*str = cur;
161
236
return (0);
162
if (!zflag) {
237
@@ -XXX,XX +XXX,XX @@ rfc3986_parse_query(URI *uri, const char **str)
163
- buf = qemu_io_alloc(blk, count, pattern);
238
*
164
+ if (sflag) {
239
* Returns 0 or the error code
165
+ buf = qemu_io_alloc_from_file(blk, count, file_name);
240
*/
166
+ if (!buf) {
241
-static int
167
+ return -EINVAL;
242
-rfc3986_parse_port(URI *uri, const char **str)
168
+ }
243
+static int rfc3986_parse_port(URI *uri, const char **str)
169
+ } else {
244
{
170
+ buf = qemu_io_alloc(blk, count, pattern);
245
const char *cur = *str;
246
int port = 0;
247
@@ -XXX,XX +XXX,XX @@ rfc3986_parse_port(URI *uri, const char **str)
248
*
249
* Returns 0 or the error code
250
*/
251
-static int
252
-rfc3986_parse_user_info(URI *uri, const char **str)
253
+static int rfc3986_parse_user_info(URI *uri, const char **str)
254
{
255
const char *cur;
256
257
cur = *str;
258
- while (ISA_UNRESERVED(cur) || ISA_PCT_ENCODED(cur) ||
259
- ISA_SUB_DELIM(cur) || (*cur == ':'))
260
-    NEXT(cur);
261
+ while (ISA_UNRESERVED(cur) || ISA_PCT_ENCODED(cur) || ISA_SUB_DELIM(cur) ||
262
+ (*cur == ':'))
263
+ NEXT(cur);
264
if (*cur == '@') {
265
-    if (uri != NULL) {
266
+ if (uri != NULL) {
267
g_free(uri->user);
268
-     if (uri->cleanup & 2)
269
-        uri->user = g_strndup(*str, cur - *str);
270
-     else
271
-        uri->user = uri_string_unescape(*str, cur - *str, NULL);
272
-    }
273
-    *str = cur;
274
-    return(0);
275
+ if (uri->cleanup & 2)
276
+ uri->user = g_strndup(*str, cur - *str);
277
+ else
278
+ uri->user = uri_string_unescape(*str, cur - *str, NULL);
279
+ }
280
+ *str = cur;
281
+ return (0);
282
}
283
- return(1);
284
+ return (1);
285
}
286
287
/**
288
@@ -XXX,XX +XXX,XX @@ rfc3986_parse_user_info(URI *uri, const char **str)
289
*
290
* Returns 0 if found and skipped, 1 otherwise
291
*/
292
-static int
293
-rfc3986_parse_dec_octet(const char **str) {
294
+static int rfc3986_parse_dec_octet(const char **str)
295
+{
296
const char *cur = *str;
297
298
if (!(ISA_DIGIT(cur)))
299
- return(1);
300
- if (!ISA_DIGIT(cur+1))
301
-    cur++;
302
- else if ((*cur != '0') && (ISA_DIGIT(cur + 1)) && (!ISA_DIGIT(cur+2)))
303
-    cur += 2;
304
+ return (1);
305
+ if (!ISA_DIGIT(cur + 1))
306
+ cur++;
307
+ else if ((*cur != '0') && (ISA_DIGIT(cur + 1)) && (!ISA_DIGIT(cur + 2)))
308
+ cur += 2;
309
else if ((*cur == '1') && (ISA_DIGIT(cur + 1)) && (ISA_DIGIT(cur + 2)))
310
-    cur += 3;
311
- else if ((*cur == '2') && (*(cur + 1) >= '0') &&
312
-     (*(cur + 1) <= '4') && (ISA_DIGIT(cur + 2)))
313
-    cur += 3;
314
- else if ((*cur == '2') && (*(cur + 1) == '5') &&
315
-     (*(cur + 2) >= '0') && (*(cur + 1) <= '5'))
316
-    cur += 3;
317
+ cur += 3;
318
+ else if ((*cur == '2') && (*(cur + 1) >= '0') && (*(cur + 1) <= '4') &&
319
+ (ISA_DIGIT(cur + 2)))
320
+ cur += 3;
321
+ else if ((*cur == '2') && (*(cur + 1) == '5') && (*(cur + 2) >= '0') &&
322
+ (*(cur + 1) <= '5'))
323
+ cur += 3;
324
else
325
- return(1);
326
+ return (1);
327
*str = cur;
328
- return(0);
329
+ return (0);
330
}
331
/**
332
* rfc3986_parse_host:
333
@@ -XXX,XX +XXX,XX @@ rfc3986_parse_dec_octet(const char **str) {
334
*
335
* Returns 0 or the error code
336
*/
337
-static int
338
-rfc3986_parse_host(URI *uri, const char **str)
339
+static int rfc3986_parse_host(URI *uri, const char **str)
340
{
341
const char *cur = *str;
342
const char *host;
343
@@ -XXX,XX +XXX,XX @@ rfc3986_parse_host(URI *uri, const char **str)
344
*/
345
if (*cur == '[') {
346
cur++;
347
-    while ((*cur != ']') && (*cur != 0))
348
-     cur++;
349
-    if (*cur != ']')
350
-     return(1);
351
-    cur++;
352
-    goto found;
353
+ while ((*cur != ']') && (*cur != 0))
354
+ cur++;
355
+ if (*cur != ']')
356
+ return (1);
357
+ cur++;
358
+ goto found;
359
}
360
/*
361
* try to parse an IPv4
362
*/
363
if (ISA_DIGIT(cur)) {
364
if (rfc3986_parse_dec_octet(&cur) != 0)
365
-     goto not_ipv4;
366
-    if (*cur != '.')
367
-     goto not_ipv4;
368
-    cur++;
369
+ goto not_ipv4;
370
+ if (*cur != '.')
371
+ goto not_ipv4;
372
+ cur++;
373
if (rfc3986_parse_dec_octet(&cur) != 0)
374
-     goto not_ipv4;
375
-    if (*cur != '.')
376
-     goto not_ipv4;
377
+ goto not_ipv4;
378
+ if (*cur != '.')
379
+ goto not_ipv4;
380
if (rfc3986_parse_dec_octet(&cur) != 0)
381
-     goto not_ipv4;
382
-    if (*cur != '.')
383
-     goto not_ipv4;
384
+ goto not_ipv4;
385
+ if (*cur != '.')
386
+ goto not_ipv4;
387
if (rfc3986_parse_dec_octet(&cur) != 0)
388
-     goto not_ipv4;
389
-    goto found;
390
-not_ipv4:
391
+ goto not_ipv4;
392
+ goto found;
393
+ not_ipv4:
394
cur = *str;
395
}
396
/*
397
@@ -XXX,XX +XXX,XX @@ not_ipv4:
398
found:
399
if (uri != NULL) {
400
g_free(uri->authority);
401
-    uri->authority = NULL;
402
+ uri->authority = NULL;
403
g_free(uri->server);
404
-    if (cur != host) {
405
-     if (uri->cleanup & 2)
406
-        uri->server = g_strndup(host, cur - host);
407
-     else
408
-        uri->server = uri_string_unescape(host, cur - host, NULL);
409
-    } else
410
-     uri->server = NULL;
411
+ if (cur != host) {
412
+ if (uri->cleanup & 2)
413
+ uri->server = g_strndup(host, cur - host);
414
+ else
415
+ uri->server = uri_string_unescape(host, cur - host, NULL);
416
+ } else
417
+ uri->server = NULL;
418
}
419
*str = cur;
420
- return(0);
421
+ return (0);
422
}
423
424
/**
425
@@ -XXX,XX +XXX,XX @@ found:
426
*
427
* Returns 0 or the error code
428
*/
429
-static int
430
-rfc3986_parse_authority(URI *uri, const char **str)
431
+static int rfc3986_parse_authority(URI *uri, const char **str)
432
{
433
const char *cur;
434
int ret;
435
@@ -XXX,XX +XXX,XX @@ rfc3986_parse_authority(URI *uri, const char **str)
436
else
437
cur++;
438
ret = rfc3986_parse_host(uri, &cur);
439
- if (ret != 0) return(ret);
440
+ if (ret != 0)
441
+ return (ret);
442
if (*cur == ':') {
443
cur++;
444
ret = rfc3986_parse_port(uri, &cur);
445
-    if (ret != 0) return(ret);
446
+ if (ret != 0)
447
+ return (ret);
448
}
449
*str = cur;
450
- return(0);
451
+ return (0);
452
}
453
454
/**
455
@@ -XXX,XX +XXX,XX @@ rfc3986_parse_authority(URI *uri, const char **str)
456
*
457
* Returns 0 or the error code
458
*/
459
-static int
460
-rfc3986_parse_segment(const char **str, char forbid, int empty)
461
+static int rfc3986_parse_segment(const char **str, char forbid, int empty)
462
{
463
const char *cur;
464
465
cur = *str;
466
if (!ISA_PCHAR(cur)) {
467
if (empty)
468
-     return(0);
469
-    return(1);
470
+ return (0);
471
+ return (1);
472
}
473
while (ISA_PCHAR(cur) && (*cur != forbid))
474
NEXT(cur);
475
@@ -XXX,XX +XXX,XX @@ rfc3986_parse_segment(const char **str, char forbid, int empty)
476
*
477
* Returns 0 or the error code
478
*/
479
-static int
480
-rfc3986_parse_path_ab_empty(URI *uri, const char **str)
481
+static int rfc3986_parse_path_ab_empty(URI *uri, const char **str)
482
{
483
const char *cur;
484
int ret;
485
@@ -XXX,XX +XXX,XX @@ rfc3986_parse_path_ab_empty(URI *uri, const char **str)
486
487
while (*cur == '/') {
488
cur++;
489
-    ret = rfc3986_parse_segment(&cur, 0, 1);
490
-    if (ret != 0) return(ret);
491
+ ret = rfc3986_parse_segment(&cur, 0, 1);
492
+ if (ret != 0)
493
+ return (ret);
494
}
495
if (uri != NULL) {
496
g_free(uri->path);
497
@@ -XXX,XX +XXX,XX @@ rfc3986_parse_path_ab_empty(URI *uri, const char **str)
498
*
499
* Returns 0 or the error code
500
*/
501
-static int
502
-rfc3986_parse_path_absolute(URI *uri, const char **str)
503
+static int rfc3986_parse_path_absolute(URI *uri, const char **str)
504
{
505
const char *cur;
506
int ret;
507
@@ -XXX,XX +XXX,XX @@ rfc3986_parse_path_absolute(URI *uri, const char **str)
508
cur = *str;
509
510
if (*cur != '/')
511
- return(1);
512
+ return (1);
513
cur++;
514
ret = rfc3986_parse_segment(&cur, 0, 0);
515
if (ret == 0) {
516
-    while (*cur == '/') {
517
-     cur++;
518
-     ret = rfc3986_parse_segment(&cur, 0, 1);
519
-     if (ret != 0) return(ret);
520
-    }
521
+ while (*cur == '/') {
522
+ cur++;
523
+ ret = rfc3986_parse_segment(&cur, 0, 1);
524
+ if (ret != 0)
525
+ return (ret);
526
+ }
171
+ }
527
}
172
}
528
if (uri != NULL) {
173
529
g_free(uri->path);
174
clock_gettime(CLOCK_MONOTONIC, &t1);
530
@@ -XXX,XX +XXX,XX @@ rfc3986_parse_path_absolute(URI *uri, const char **str)
531
*
532
* Returns 0 or the error code
533
*/
534
-static int
535
-rfc3986_parse_path_rootless(URI *uri, const char **str)
536
+static int rfc3986_parse_path_rootless(URI *uri, const char **str)
537
{
538
const char *cur;
539
int ret;
540
@@ -XXX,XX +XXX,XX @@ rfc3986_parse_path_rootless(URI *uri, const char **str)
541
cur = *str;
542
543
ret = rfc3986_parse_segment(&cur, 0, 0);
544
- if (ret != 0) return(ret);
545
+ if (ret != 0)
546
+ return (ret);
547
while (*cur == '/') {
548
cur++;
549
-    ret = rfc3986_parse_segment(&cur, 0, 1);
550
-    if (ret != 0) return(ret);
551
+ ret = rfc3986_parse_segment(&cur, 0, 1);
552
+ if (ret != 0)
553
+ return (ret);
554
}
555
if (uri != NULL) {
556
g_free(uri->path);
557
@@ -XXX,XX +XXX,XX @@ rfc3986_parse_path_rootless(URI *uri, const char **str)
558
*
559
* Returns 0 or the error code
560
*/
561
-static int
562
-rfc3986_parse_path_no_scheme(URI *uri, const char **str)
563
+static int rfc3986_parse_path_no_scheme(URI *uri, const char **str)
564
{
565
const char *cur;
566
int ret;
567
@@ -XXX,XX +XXX,XX @@ rfc3986_parse_path_no_scheme(URI *uri, const char **str)
568
cur = *str;
569
570
ret = rfc3986_parse_segment(&cur, ':', 0);
571
- if (ret != 0) return(ret);
572
+ if (ret != 0)
573
+ return (ret);
574
while (*cur == '/') {
575
cur++;
576
-    ret = rfc3986_parse_segment(&cur, 0, 1);
577
-    if (ret != 0) return(ret);
578
+ ret = rfc3986_parse_segment(&cur, 0, 1);
579
+ if (ret != 0)
580
+ return (ret);
581
}
582
if (uri != NULL) {
583
g_free(uri->path);
584
@@ -XXX,XX +XXX,XX @@ rfc3986_parse_path_no_scheme(URI *uri, const char **str)
585
*
586
* Returns 0 or the error code
587
*/
588
-static int
589
-rfc3986_parse_hier_part(URI *uri, const char **str)
590
+static int rfc3986_parse_hier_part(URI *uri, const char **str)
591
{
592
const char *cur;
593
int ret;
594
@@ -XXX,XX +XXX,XX @@ rfc3986_parse_hier_part(URI *uri, const char **str)
595
596
if ((*cur == '/') && (*(cur + 1) == '/')) {
597
cur += 2;
598
-    ret = rfc3986_parse_authority(uri, &cur);
599
-    if (ret != 0) return(ret);
600
-    ret = rfc3986_parse_path_ab_empty(uri, &cur);
601
-    if (ret != 0) return(ret);
602
-    *str = cur;
603
-    return(0);
604
+ ret = rfc3986_parse_authority(uri, &cur);
605
+ if (ret != 0)
606
+ return (ret);
607
+ ret = rfc3986_parse_path_ab_empty(uri, &cur);
608
+ if (ret != 0)
609
+ return (ret);
610
+ *str = cur;
611
+ return (0);
612
} else if (*cur == '/') {
613
ret = rfc3986_parse_path_absolute(uri, &cur);
614
-    if (ret != 0) return(ret);
615
+ if (ret != 0)
616
+ return (ret);
617
} else if (ISA_PCHAR(cur)) {
618
ret = rfc3986_parse_path_rootless(uri, &cur);
619
-    if (ret != 0) return(ret);
620
+ if (ret != 0)
621
+ return (ret);
622
} else {
623
-    /* path-empty is effectively empty */
624
-    if (uri != NULL) {
625
+ /* path-empty is effectively empty */
626
+ if (uri != NULL) {
627
g_free(uri->path);
628
-     uri->path = NULL;
629
-    }
630
+ uri->path = NULL;
631
+ }
632
}
633
*str = cur;
634
return (0);
635
@@ -XXX,XX +XXX,XX @@ rfc3986_parse_hier_part(URI *uri, const char **str)
636
*
637
* Returns 0 or the error code
638
*/
639
-static int
640
-rfc3986_parse_relative_ref(URI *uri, const char *str) {
641
+static int rfc3986_parse_relative_ref(URI *uri, const char *str)
642
+{
643
int ret;
644
645
if ((*str == '/') && (*(str + 1) == '/')) {
646
str += 2;
647
-    ret = rfc3986_parse_authority(uri, &str);
648
-    if (ret != 0) return(ret);
649
-    ret = rfc3986_parse_path_ab_empty(uri, &str);
650
-    if (ret != 0) return(ret);
651
+ ret = rfc3986_parse_authority(uri, &str);
652
+ if (ret != 0)
653
+ return (ret);
654
+ ret = rfc3986_parse_path_ab_empty(uri, &str);
655
+ if (ret != 0)
656
+ return (ret);
657
} else if (*str == '/') {
658
-    ret = rfc3986_parse_path_absolute(uri, &str);
659
-    if (ret != 0) return(ret);
660
+ ret = rfc3986_parse_path_absolute(uri, &str);
661
+ if (ret != 0)
662
+ return (ret);
663
} else if (ISA_PCHAR(str)) {
664
ret = rfc3986_parse_path_no_scheme(uri, &str);
665
-    if (ret != 0) return(ret);
666
+ if (ret != 0)
667
+ return (ret);
668
} else {
669
-    /* path-empty is effectively empty */
670
-    if (uri != NULL) {
671
+ /* path-empty is effectively empty */
672
+ if (uri != NULL) {
673
g_free(uri->path);
674
-     uri->path = NULL;
675
-    }
676
+ uri->path = NULL;
677
+ }
678
}
679
680
if (*str == '?') {
681
-    str++;
682
-    ret = rfc3986_parse_query(uri, &str);
683
-    if (ret != 0) return(ret);
684
+ str++;
685
+ ret = rfc3986_parse_query(uri, &str);
686
+ if (ret != 0)
687
+ return (ret);
688
}
689
if (*str == '#') {
690
-    str++;
691
-    ret = rfc3986_parse_fragment(uri, &str);
692
-    if (ret != 0) return(ret);
693
+ str++;
694
+ ret = rfc3986_parse_fragment(uri, &str);
695
+ if (ret != 0)
696
+ return (ret);
697
}
698
if (*str != 0) {
699
-    uri_clean(uri);
700
-    return(1);
701
+ uri_clean(uri);
702
+ return (1);
703
}
704
- return(0);
705
+ return (0);
706
}
707
708
-
709
/**
710
* rfc3986_parse:
711
* @uri: pointer to an URI structure
712
@@ -XXX,XX +XXX,XX @@ rfc3986_parse_relative_ref(URI *uri, const char *str) {
713
*
714
* Returns 0 or the error code
715
*/
716
-static int
717
-rfc3986_parse(URI *uri, const char *str) {
718
+static int rfc3986_parse(URI *uri, const char *str)
719
+{
720
int ret;
721
722
ret = rfc3986_parse_scheme(uri, &str);
723
- if (ret != 0) return(ret);
724
+ if (ret != 0)
725
+ return (ret);
726
if (*str != ':') {
727
-    return(1);
728
+ return (1);
729
}
730
str++;
731
ret = rfc3986_parse_hier_part(uri, &str);
732
- if (ret != 0) return(ret);
733
+ if (ret != 0)
734
+ return (ret);
735
if (*str == '?') {
736
-    str++;
737
-    ret = rfc3986_parse_query(uri, &str);
738
-    if (ret != 0) return(ret);
739
+ str++;
740
+ ret = rfc3986_parse_query(uri, &str);
741
+ if (ret != 0)
742
+ return (ret);
743
}
744
if (*str == '#') {
745
-    str++;
746
-    ret = rfc3986_parse_fragment(uri, &str);
747
-    if (ret != 0) return(ret);
748
+ str++;
749
+ ret = rfc3986_parse_fragment(uri, &str);
750
+ if (ret != 0)
751
+ return (ret);
752
}
753
if (*str != 0) {
754
-    uri_clean(uri);
755
-    return(1);
756
+ uri_clean(uri);
757
+ return (1);
758
}
759
- return(0);
760
+ return (0);
761
}
762
763
/**
764
@@ -XXX,XX +XXX,XX @@ rfc3986_parse(URI *uri, const char *str) {
765
*
766
* Returns 0 or the error code
767
*/
768
-static int
769
-rfc3986_parse_uri_reference(URI *uri, const char *str) {
770
+static int rfc3986_parse_uri_reference(URI *uri, const char *str)
771
+{
772
int ret;
773
774
if (str == NULL)
775
-    return(-1);
776
+ return (-1);
777
uri_clean(uri);
778
779
/*
780
@@ -XXX,XX +XXX,XX @@ rfc3986_parse_uri_reference(URI *uri, const char *str) {
781
*/
782
ret = rfc3986_parse(uri, str);
783
if (ret != 0) {
784
-    uri_clean(uri);
785
+ uri_clean(uri);
786
ret = rfc3986_parse_relative_ref(uri, str);
787
-    if (ret != 0) {
788
-     uri_clean(uri);
789
-     return(ret);
790
-    }
791
+ if (ret != 0) {
792
+ uri_clean(uri);
793
+ return (ret);
794
+ }
795
}
796
- return(0);
797
+ return (0);
798
}
799
800
/**
801
@@ -XXX,XX +XXX,XX @@ rfc3986_parse_uri_reference(URI *uri, const char *str) {
802
*
803
* Returns a newly built URI or NULL in case of error
804
*/
805
-URI *
806
-uri_parse(const char *str) {
807
+URI *uri_parse(const char *str)
808
+{
809
URI *uri;
810
int ret;
811
812
if (str == NULL)
813
-    return(NULL);
814
+ return (NULL);
815
uri = uri_new();
816
ret = rfc3986_parse_uri_reference(uri, str);
817
if (ret) {
818
uri_free(uri);
819
- return(NULL);
820
+ return (NULL);
821
}
822
- return(uri);
823
+ return (uri);
824
}
825
826
/**
827
@@ -XXX,XX +XXX,XX @@ uri_parse(const char *str) {
828
*
829
* Returns 0 or the error code
830
*/
831
-int
832
-uri_parse_into(URI *uri, const char *str) {
833
- return(rfc3986_parse_uri_reference(uri, str));
834
+int uri_parse_into(URI *uri, const char *str)
835
+{
836
+ return (rfc3986_parse_uri_reference(uri, str));
837
}
838
839
/**
840
@@ -XXX,XX +XXX,XX @@ uri_parse_into(URI *uri, const char *str) {
841
*
842
* Returns a newly built URI or NULL in case of error
843
*/
844
-URI *
845
-uri_parse_raw(const char *str, int raw) {
846
+URI *uri_parse_raw(const char *str, int raw)
847
+{
848
URI *uri;
849
int ret;
850
851
if (str == NULL)
852
-    return(NULL);
853
+ return (NULL);
854
uri = uri_new();
855
if (raw) {
856
uri->cleanup |= 2;
857
@@ -XXX,XX +XXX,XX @@ uri_parse_raw(const char *str, int raw) {
858
ret = uri_parse_into(uri, str);
859
if (ret) {
860
uri_free(uri);
861
- return(NULL);
862
+ return (NULL);
863
}
864
- return(uri);
865
+ return (uri);
866
}
867
868
/************************************************************************
869
- *                                    *
870
- *            Generic URI structure functions            *
871
- *                                    *
872
+ * *
873
+ * Generic URI structure functions *
874
+ * *
875
************************************************************************/
876
877
/**
878
@@ -XXX,XX +XXX,XX @@ uri_parse_raw(const char *str, int raw) {
879
*
880
* Returns the new structure or NULL in case of error
881
*/
882
-URI *
883
-uri_new(void) {
884
+URI *uri_new(void)
885
+{
886
URI *ret;
887
888
ret = g_new0(URI, 1);
889
- return(ret);
890
+ return (ret);
891
}
892
893
/**
894
@@ -XXX,XX +XXX,XX @@ uri_new(void) {
895
* Function to handle properly a reallocation when saving an URI
896
* Also imposes some limit on the length of an URI string output
897
*/
898
-static char *
899
-realloc2n(char *ret, int *max) {
900
+static char *realloc2n(char *ret, int *max)
901
+{
902
char *temp;
903
int tmp;
904
905
tmp = *max * 2;
906
temp = g_realloc(ret, (tmp + 1));
907
*max = tmp;
908
- return(temp);
909
+ return (temp);
910
}
911
912
/**
913
@@ -XXX,XX +XXX,XX @@ realloc2n(char *ret, int *max) {
914
*
915
* Returns a new string (to be deallocated by caller)
916
*/
917
-char *
918
-uri_to_string(URI *uri) {
919
+char *uri_to_string(URI *uri)
920
+{
921
char *ret = NULL;
922
char *temp;
923
const char *p;
924
int len;
925
int max;
926
927
- if (uri == NULL) return(NULL);
928
-
929
+ if (uri == NULL)
930
+ return (NULL);
931
932
max = 80;
933
ret = g_malloc(max + 1);
934
len = 0;
935
936
if (uri->scheme != NULL) {
937
-    p = uri->scheme;
938
-    while (*p != 0) {
939
-     if (len >= max) {
940
+ p = uri->scheme;
941
+ while (*p != 0) {
942
+ if (len >= max) {
943
temp = realloc2n(ret, &max);
944
-        ret = temp;
945
-     }
946
-     ret[len++] = *p++;
947
-    }
948
-    if (len >= max) {
949
+ ret = temp;
950
+ }
951
+ ret[len++] = *p++;
952
+ }
953
+ if (len >= max) {
954
temp = realloc2n(ret, &max);
955
ret = temp;
956
-    }
957
-    ret[len++] = ':';
958
+ }
959
+ ret[len++] = ':';
960
}
961
if (uri->opaque != NULL) {
962
-    p = uri->opaque;
963
-    while (*p != 0) {
964
-     if (len + 3 >= max) {
965
+ p = uri->opaque;
966
+ while (*p != 0) {
967
+ if (len + 3 >= max) {
968
temp = realloc2n(ret, &max);
969
ret = temp;
970
-     }
971
-     if (IS_RESERVED(*(p)) || IS_UNRESERVED(*(p)))
972
-        ret[len++] = *p++;
973
-     else {
974
-        int val = *(unsigned char *)p++;
975
-        int hi = val / 0x10, lo = val % 0x10;
976
-        ret[len++] = '%';
977
-        ret[len++] = hi + (hi > 9? 'A'-10 : '0');
978
-        ret[len++] = lo + (lo > 9? 'A'-10 : '0');
979
-     }
980
-    }
981
+ }
982
+ if (IS_RESERVED(*(p)) || IS_UNRESERVED(*(p)))
983
+ ret[len++] = *p++;
984
+ else {
985
+ int val = *(unsigned char *)p++;
986
+ int hi = val / 0x10, lo = val % 0x10;
987
+ ret[len++] = '%';
988
+ ret[len++] = hi + (hi > 9 ? 'A' - 10 : '0');
989
+ ret[len++] = lo + (lo > 9 ? 'A' - 10 : '0');
990
+ }
991
+ }
992
} else {
993
-    if (uri->server != NULL) {
994
-     if (len + 3 >= max) {
995
+ if (uri->server != NULL) {
996
+ if (len + 3 >= max) {
997
temp = realloc2n(ret, &max);
998
ret = temp;
999
-     }
1000
-     ret[len++] = '/';
1001
-     ret[len++] = '/';
1002
-     if (uri->user != NULL) {
1003
-        p = uri->user;
1004
-        while (*p != 0) {
1005
-         if (len + 3 >= max) {
1006
+ }
1007
+ ret[len++] = '/';
1008
+ ret[len++] = '/';
1009
+ if (uri->user != NULL) {
1010
+ p = uri->user;
1011
+ while (*p != 0) {
1012
+ if (len + 3 >= max) {
1013
temp = realloc2n(ret, &max);
1014
ret = temp;
1015
-         }
1016
-         if ((IS_UNRESERVED(*(p))) ||
1017
-            ((*(p) == ';')) || ((*(p) == ':')) ||
1018
-            ((*(p) == '&')) || ((*(p) == '=')) ||
1019
-            ((*(p) == '+')) || ((*(p) == '$')) ||
1020
-            ((*(p) == ',')))
1021
-            ret[len++] = *p++;
1022
-         else {
1023
-            int val = *(unsigned char *)p++;
1024
-            int hi = val / 0x10, lo = val % 0x10;
1025
-            ret[len++] = '%';
1026
-            ret[len++] = hi + (hi > 9? 'A'-10 : '0');
1027
-            ret[len++] = lo + (lo > 9? 'A'-10 : '0');
1028
-         }
1029
-        }
1030
-        if (len + 3 >= max) {
1031
+ }
1032
+ if ((IS_UNRESERVED(*(p))) || ((*(p) == ';')) ||
1033
+ ((*(p) == ':')) || ((*(p) == '&')) || ((*(p) == '=')) ||
1034
+ ((*(p) == '+')) || ((*(p) == '$')) || ((*(p) == ',')))
1035
+ ret[len++] = *p++;
1036
+ else {
1037
+ int val = *(unsigned char *)p++;
1038
+ int hi = val / 0x10, lo = val % 0x10;
1039
+ ret[len++] = '%';
1040
+ ret[len++] = hi + (hi > 9 ? 'A' - 10 : '0');
1041
+ ret[len++] = lo + (lo > 9 ? 'A' - 10 : '0');
1042
+ }
1043
+ }
1044
+ if (len + 3 >= max) {
1045
temp = realloc2n(ret, &max);
1046
ret = temp;
1047
-        }
1048
-        ret[len++] = '@';
1049
-     }
1050
-     p = uri->server;
1051
-     while (*p != 0) {
1052
-        if (len >= max) {
1053
+ }
1054
+ ret[len++] = '@';
1055
+ }
1056
+ p = uri->server;
1057
+ while (*p != 0) {
1058
+ if (len >= max) {
1059
temp = realloc2n(ret, &max);
1060
ret = temp;
1061
-        }
1062
-        ret[len++] = *p++;
1063
-     }
1064
-     if (uri->port > 0) {
1065
-        if (len + 10 >= max) {
1066
+ }
1067
+ ret[len++] = *p++;
1068
+ }
1069
+ if (uri->port > 0) {
1070
+ if (len + 10 >= max) {
1071
temp = realloc2n(ret, &max);
1072
ret = temp;
1073
-        }
1074
-        len += snprintf(&ret[len], max - len, ":%d", uri->port);
1075
-     }
1076
-    } else if (uri->authority != NULL) {
1077
-     if (len + 3 >= max) {
1078
+ }
1079
+ len += snprintf(&ret[len], max - len, ":%d", uri->port);
1080
+ }
1081
+ } else if (uri->authority != NULL) {
1082
+ if (len + 3 >= max) {
1083
temp = realloc2n(ret, &max);
1084
ret = temp;
1085
-     }
1086
-     ret[len++] = '/';
1087
-     ret[len++] = '/';
1088
-     p = uri->authority;
1089
-     while (*p != 0) {
1090
-        if (len + 3 >= max) {
1091
+ }
1092
+ ret[len++] = '/';
1093
+ ret[len++] = '/';
1094
+ p = uri->authority;
1095
+ while (*p != 0) {
1096
+ if (len + 3 >= max) {
1097
temp = realloc2n(ret, &max);
1098
ret = temp;
1099
-        }
1100
-        if ((IS_UNRESERVED(*(p))) ||
1101
- ((*(p) == '$')) || ((*(p) == ',')) || ((*(p) == ';')) ||
1102
- ((*(p) == ':')) || ((*(p) == '@')) || ((*(p) == '&')) ||
1103
- ((*(p) == '=')) || ((*(p) == '+')))
1104
-         ret[len++] = *p++;
1105
-        else {
1106
-         int val = *(unsigned char *)p++;
1107
-         int hi = val / 0x10, lo = val % 0x10;
1108
-         ret[len++] = '%';
1109
-         ret[len++] = hi + (hi > 9? 'A'-10 : '0');
1110
-         ret[len++] = lo + (lo > 9? 'A'-10 : '0');
1111
-        }
1112
-     }
1113
-    } else if (uri->scheme != NULL) {
1114
-     if (len + 3 >= max) {
1115
+ }
1116
+ if ((IS_UNRESERVED(*(p))) || ((*(p) == '$')) ||
1117
+ ((*(p) == ',')) || ((*(p) == ';')) || ((*(p) == ':')) ||
1118
+ ((*(p) == '@')) || ((*(p) == '&')) || ((*(p) == '=')) ||
1119
+ ((*(p) == '+')))
1120
+ ret[len++] = *p++;
1121
+ else {
1122
+ int val = *(unsigned char *)p++;
1123
+ int hi = val / 0x10, lo = val % 0x10;
1124
+ ret[len++] = '%';
1125
+ ret[len++] = hi + (hi > 9 ? 'A' - 10 : '0');
1126
+ ret[len++] = lo + (lo > 9 ? 'A' - 10 : '0');
1127
+ }
1128
+ }
1129
+ } else if (uri->scheme != NULL) {
1130
+ if (len + 3 >= max) {
1131
temp = realloc2n(ret, &max);
1132
ret = temp;
1133
-     }
1134
-     ret[len++] = '/';
1135
-     ret[len++] = '/';
1136
-    }
1137
-    if (uri->path != NULL) {
1138
-     p = uri->path;
1139
-     /*
1140
-     * the colon in file:///d: should not be escaped or
1141
-     * Windows accesses fail later.
1142
-     */
1143
-     if ((uri->scheme != NULL) &&
1144
-        (p[0] == '/') &&
1145
-        (((p[1] >= 'a') && (p[1] <= 'z')) ||
1146
-         ((p[1] >= 'A') && (p[1] <= 'Z'))) &&
1147
-        (p[2] == ':') &&
1148
-     (!strcmp(uri->scheme, "file"))) {
1149
-        if (len + 3 >= max) {
1150
+ }
1151
+ ret[len++] = '/';
1152
+ ret[len++] = '/';
1153
+ }
1154
+ if (uri->path != NULL) {
1155
+ p = uri->path;
1156
+ /*
1157
+ * the colon in file:///d: should not be escaped or
1158
+ * Windows accesses fail later.
1159
+ */
1160
+ if ((uri->scheme != NULL) && (p[0] == '/') &&
1161
+ (((p[1] >= 'a') && (p[1] <= 'z')) ||
1162
+ ((p[1] >= 'A') && (p[1] <= 'Z'))) &&
1163
+ (p[2] == ':') && (!strcmp(uri->scheme, "file"))) {
1164
+ if (len + 3 >= max) {
1165
temp = realloc2n(ret, &max);
1166
ret = temp;
1167
-        }
1168
-        ret[len++] = *p++;
1169
-        ret[len++] = *p++;
1170
-        ret[len++] = *p++;
1171
-     }
1172
-     while (*p != 0) {
1173
-        if (len + 3 >= max) {
1174
+ }
1175
+ ret[len++] = *p++;
1176
+ ret[len++] = *p++;
1177
+ ret[len++] = *p++;
1178
+ }
1179
+ while (*p != 0) {
1180
+ if (len + 3 >= max) {
1181
temp = realloc2n(ret, &max);
1182
ret = temp;
1183
-        }
1184
-        if ((IS_UNRESERVED(*(p))) || ((*(p) == '/')) ||
1185
+ }
1186
+ if ((IS_UNRESERVED(*(p))) || ((*(p) == '/')) ||
1187
((*(p) == ';')) || ((*(p) == '@')) || ((*(p) == '&')) ||
1188
-     ((*(p) == '=')) || ((*(p) == '+')) || ((*(p) == '$')) ||
1189
-     ((*(p) == ',')))
1190
-         ret[len++] = *p++;
1191
-        else {
1192
-         int val = *(unsigned char *)p++;
1193
-         int hi = val / 0x10, lo = val % 0x10;
1194
-         ret[len++] = '%';
1195
-         ret[len++] = hi + (hi > 9? 'A'-10 : '0');
1196
-         ret[len++] = lo + (lo > 9? 'A'-10 : '0');
1197
-        }
1198
-     }
1199
-    }
1200
-    if (uri->query != NULL) {
1201
-     if (len + 1 >= max) {
1202
+ ((*(p) == '=')) || ((*(p) == '+')) || ((*(p) == '$')) ||
1203
+ ((*(p) == ',')))
1204
+ ret[len++] = *p++;
1205
+ else {
1206
+ int val = *(unsigned char *)p++;
1207
+ int hi = val / 0x10, lo = val % 0x10;
1208
+ ret[len++] = '%';
1209
+ ret[len++] = hi + (hi > 9 ? 'A' - 10 : '0');
1210
+ ret[len++] = lo + (lo > 9 ? 'A' - 10 : '0');
1211
+ }
1212
+ }
1213
+ }
1214
+ if (uri->query != NULL) {
1215
+ if (len + 1 >= max) {
1216
temp = realloc2n(ret, &max);
1217
ret = temp;
1218
-     }
1219
-     ret[len++] = '?';
1220
-     p = uri->query;
1221
-     while (*p != 0) {
1222
-        if (len + 1 >= max) {
1223
+ }
1224
+ ret[len++] = '?';
1225
+ p = uri->query;
1226
+ while (*p != 0) {
1227
+ if (len + 1 >= max) {
1228
temp = realloc2n(ret, &max);
1229
ret = temp;
1230
-        }
1231
-        ret[len++] = *p++;
1232
-     }
1233
-    }
1234
+ }
1235
+ ret[len++] = *p++;
1236
+ }
1237
+ }
1238
}
1239
if (uri->fragment != NULL) {
1240
-    if (len + 3 >= max) {
1241
+ if (len + 3 >= max) {
1242
temp = realloc2n(ret, &max);
1243
ret = temp;
1244
-    }
1245
-    ret[len++] = '#';
1246
-    p = uri->fragment;
1247
-    while (*p != 0) {
1248
-     if (len + 3 >= max) {
1249
+ }
1250
+ ret[len++] = '#';
1251
+ p = uri->fragment;
1252
+ while (*p != 0) {
1253
+ if (len + 3 >= max) {
1254
temp = realloc2n(ret, &max);
1255
ret = temp;
1256
-     }
1257
-     if ((IS_UNRESERVED(*(p))) || (IS_RESERVED(*(p))))
1258
-        ret[len++] = *p++;
1259
-     else {
1260
-        int val = *(unsigned char *)p++;
1261
-        int hi = val / 0x10, lo = val % 0x10;
1262
-        ret[len++] = '%';
1263
-        ret[len++] = hi + (hi > 9? 'A'-10 : '0');
1264
-        ret[len++] = lo + (lo > 9? 'A'-10 : '0');
1265
-     }
1266
-    }
1267
+ }
1268
+ if ((IS_UNRESERVED(*(p))) || (IS_RESERVED(*(p))))
1269
+ ret[len++] = *p++;
1270
+ else {
1271
+ int val = *(unsigned char *)p++;
1272
+ int hi = val / 0x10, lo = val % 0x10;
1273
+ ret[len++] = '%';
1274
+ ret[len++] = hi + (hi > 9 ? 'A' - 10 : '0');
1275
+ ret[len++] = lo + (lo > 9 ? 'A' - 10 : '0');
1276
+ }
1277
+ }
1278
}
1279
if (len >= max) {
1280
temp = realloc2n(ret, &max);
1281
ret = temp;
1282
}
1283
ret[len] = 0;
1284
- return(ret);
1285
+ return (ret);
1286
}
1287
1288
/**
1289
@@ -XXX,XX +XXX,XX @@ uri_to_string(URI *uri) {
1290
*
1291
* Make sure the URI struct is free of content
1292
*/
1293
-static void
1294
-uri_clean(URI *uri) {
1295
- if (uri == NULL) return;
1296
+static void uri_clean(URI *uri)
1297
+{
1298
+ if (uri == NULL)
1299
+ return;
1300
1301
g_free(uri->scheme);
1302
uri->scheme = NULL;
1303
@@ -XXX,XX +XXX,XX @@ uri_clean(URI *uri) {
1304
*
1305
* Free up the URI struct
1306
*/
1307
-void
1308
-uri_free(URI *uri) {
1309
+void uri_free(URI *uri)
1310
+{
1311
uri_clean(uri);
1312
g_free(uri);
1313
}
1314
1315
/************************************************************************
1316
- *                                    *
1317
- *            Helper functions                *
1318
- *                                    *
1319
+ * *
1320
+ * Helper functions *
1321
+ * *
1322
************************************************************************/
1323
1324
/**
1325
@@ -XXX,XX +XXX,XX @@ uri_free(URI *uri) {
1326
*
1327
* Returns 0 or an error code
1328
*/
1329
-static int
1330
-normalize_uri_path(char *path) {
1331
+static int normalize_uri_path(char *path)
1332
+{
1333
char *cur, *out;
1334
1335
if (path == NULL)
1336
-    return(-1);
1337
+ return (-1);
1338
1339
/* Skip all initial "/" chars. We want to get to the beginning of the
1340
* first non-empty segment.
1341
*/
1342
cur = path;
1343
while (cur[0] == '/')
1344
- ++cur;
1345
+ ++cur;
1346
if (cur[0] == '\0')
1347
- return(0);
1348
+ return (0);
1349
1350
/* Keep everything we've seen so far. */
1351
out = cur;
1352
@@ -XXX,XX +XXX,XX @@ normalize_uri_path(char *path) {
1353
* Analyze each segment in sequence for cases (c) and (d).
1354
*/
1355
while (cur[0] != '\0') {
1356
-    /*
1357
-     * c) All occurrences of "./", where "." is a complete path segment,
1358
-     * are removed from the buffer string.
1359
-     */
1360
-    if ((cur[0] == '.') && (cur[1] == '/')) {
1361
-     cur += 2;
1362
-     /* '//' normalization should be done at this point too */
1363
-     while (cur[0] == '/')
1364
-        cur++;
1365
-     continue;
1366
-    }
1367
+ /*
1368
+ * c) All occurrences of "./", where "." is a complete path segment,
1369
+ * are removed from the buffer string.
1370
+ */
1371
+ if ((cur[0] == '.') && (cur[1] == '/')) {
1372
+ cur += 2;
1373
+ /* '//' normalization should be done at this point too */
1374
+ while (cur[0] == '/')
1375
+ cur++;
1376
+ continue;
1377
+ }
1378
1379
-    /*
1380
-     * d) If the buffer string ends with "." as a complete path segment,
1381
-     * that "." is removed.
1382
-     */
1383
-    if ((cur[0] == '.') && (cur[1] == '\0'))
1384
-     break;
1385
+ /*
1386
+ * d) If the buffer string ends with "." as a complete path segment,
1387
+ * that "." is removed.
1388
+ */
1389
+ if ((cur[0] == '.') && (cur[1] == '\0'))
1390
+ break;
1391
1392
-    /* Otherwise keep the segment. */
1393
-    while (cur[0] != '/') {
1394
+ /* Otherwise keep the segment. */
1395
+ while (cur[0] != '/') {
1396
if (cur[0] == '\0')
1397
- goto done_cd;
1398
-     (out++)[0] = (cur++)[0];
1399
-    }
1400
-    /* nomalize // */
1401
-    while ((cur[0] == '/') && (cur[1] == '/'))
1402
-     cur++;
1403
+ goto done_cd;
1404
+ (out++)[0] = (cur++)[0];
1405
+ }
1406
+ /* nomalize // */
1407
+ while ((cur[0] == '/') && (cur[1] == '/'))
1408
+ cur++;
1409
1410
(out++)[0] = (cur++)[0];
1411
}
1412
- done_cd:
1413
+done_cd:
1414
out[0] = '\0';
1415
1416
/* Reset to the beginning of the first segment for the next sequence. */
1417
cur = path;
1418
while (cur[0] == '/')
1419
- ++cur;
1420
+ ++cur;
1421
if (cur[0] == '\0')
1422
-    return(0);
1423
+ return (0);
1424
1425
/*
1426
* Analyze each segment in sequence for cases (e) and (f).
1427
@@ -XXX,XX +XXX,XX @@ normalize_uri_path(char *path) {
1428
/* Find the end of the current segment. */
1429
segp = cur;
1430
while ((segp[0] != '/') && (segp[0] != '\0'))
1431
- ++segp;
1432
+ ++segp;
1433
1434
/* If this is the last segment, we're done (we need at least two
1435
* segments to meet the criteria for the (e) and (f) cases).
1436
*/
1437
if (segp[0] == '\0')
1438
- break;
1439
+ break;
1440
1441
/* If the first segment is "..", or if the next segment _isn't_ "..",
1442
* keep this segment and try the next one.
1443
*/
1444
++segp;
1445
- if (((cur[0] == '.') && (cur[1] == '.') && (segp == cur+3))
1446
- || ((segp[0] != '.') || (segp[1] != '.')
1447
- || ((segp[2] != '/') && (segp[2] != '\0')))) {
1448
- cur = segp;
1449
- continue;
1450
+ if (((cur[0] == '.') && (cur[1] == '.') && (segp == cur + 3)) ||
1451
+ ((segp[0] != '.') || (segp[1] != '.') ||
1452
+ ((segp[2] != '/') && (segp[2] != '\0')))) {
1453
+ cur = segp;
1454
+ continue;
1455
}
1456
1457
/* If we get here, remove this segment and the next one and back up
1458
@@ -XXX,XX +XXX,XX @@ normalize_uri_path(char *path) {
1459
1460
/* If this is the end of the buffer, we're done. */
1461
if (segp[2] == '\0') {
1462
- cur[0] = '\0';
1463
- break;
1464
+ cur[0] = '\0';
1465
+ break;
1466
}
1467
/* Valgrind complained, strcpy(cur, segp + 3); */
1468
/* string will overlap, do not use strcpy */
1469
tmp = cur;
1470
segp += 3;
1471
while ((*tmp++ = *segp++) != 0)
1472
- ;
1473
+ ;
1474
1475
/* If there are no previous segments, then keep going from here. */
1476
segp = cur;
1477
while ((segp > path) && ((--segp)[0] == '/'))
1478
- ;
1479
+ ;
1480
if (segp == path)
1481
- continue;
1482
+ continue;
1483
1484
/* "segp" is pointing to the end of a previous segment; find it's
1485
* start. We need to back up to the previous segment and start
1486
@@ -XXX,XX +XXX,XX @@ normalize_uri_path(char *path) {
1487
*/
1488
cur = segp;
1489
while ((cur > path) && (cur[-1] != '/'))
1490
- --cur;
1491
+ --cur;
1492
}
1493
out[0] = '\0';
1494
1495
@@ -XXX,XX +XXX,XX @@ normalize_uri_path(char *path) {
1496
* We discard them from the final path.
1497
*/
1498
if (path[0] == '/') {
1499
- cur = path;
1500
- while ((cur[0] == '/') && (cur[1] == '.') && (cur[2] == '.')
1501
- && ((cur[3] == '/') || (cur[3] == '\0')))
1502
-    cur += 3;
1503
+ cur = path;
1504
+ while ((cur[0] == '/') && (cur[1] == '.') && (cur[2] == '.') &&
1505
+ ((cur[3] == '/') || (cur[3] == '\0')))
1506
+ cur += 3;
1507
1508
- if (cur != path) {
1509
-    out = path;
1510
-    while (cur[0] != '\0')
1511
- (out++)[0] = (cur++)[0];
1512
-    out[0] = 0;
1513
- }
1514
+ if (cur != path) {
1515
+ out = path;
1516
+ while (cur[0] != '\0')
1517
+ (out++)[0] = (cur++)[0];
1518
+ out[0] = 0;
1519
+ }
1520
}
1521
1522
- return(0);
1523
+ return (0);
1524
}
1525
1526
-static int is_hex(char c) {
1527
- if (((c >= '0') && (c <= '9')) ||
1528
- ((c >= 'a') && (c <= 'f')) ||
1529
+static int is_hex(char c)
1530
+{
1531
+ if (((c >= '0') && (c <= '9')) || ((c >= 'a') && (c <= 'f')) ||
1532
((c >= 'A') && (c <= 'F')))
1533
-    return(1);
1534
- return(0);
1535
+ return (1);
1536
+ return (0);
1537
}
1538
1539
-
1540
/**
1541
* uri_string_unescape:
1542
* @str: the string to unescape
1543
@@ -XXX,XX +XXX,XX @@ static int is_hex(char c) {
1544
* Returns a copy of the string, but unescaped, will return NULL only in case
1545
* of error
1546
*/
1547
-char *
1548
-uri_string_unescape(const char *str, int len, char *target) {
1549
+char *uri_string_unescape(const char *str, int len, char *target)
1550
+{
1551
char *ret, *out;
1552
const char *in;
1553
1554
if (str == NULL)
1555
-    return(NULL);
1556
- if (len <= 0) len = strlen(str);
1557
- if (len < 0) return(NULL);
1558
+ return (NULL);
1559
+ if (len <= 0)
1560
+ len = strlen(str);
1561
+ if (len < 0)
1562
+ return (NULL);
1563
1564
if (target == NULL) {
1565
-    ret = g_malloc(len + 1);
1566
+ ret = g_malloc(len + 1);
1567
} else
1568
-    ret = target;
1569
+ ret = target;
1570
in = str;
1571
out = ret;
1572
- while(len > 0) {
1573
-    if ((len > 2) && (*in == '%') && (is_hex(in[1])) && (is_hex(in[2]))) {
1574
-     in++;
1575
-     if ((*in >= '0') && (*in <= '9'))
1576
-     *out = (*in - '0');
1577
-     else if ((*in >= 'a') && (*in <= 'f'))
1578
-     *out = (*in - 'a') + 10;
1579
-     else if ((*in >= 'A') && (*in <= 'F'))
1580
-     *out = (*in - 'A') + 10;
1581
-     in++;
1582
-     if ((*in >= '0') && (*in <= '9'))
1583
-     *out = *out * 16 + (*in - '0');
1584
-     else if ((*in >= 'a') && (*in <= 'f'))
1585
-     *out = *out * 16 + (*in - 'a') + 10;
1586
-     else if ((*in >= 'A') && (*in <= 'F'))
1587
-     *out = *out * 16 + (*in - 'A') + 10;
1588
-     in++;
1589
-     len -= 3;
1590
-     out++;
1591
-    } else {
1592
-     *out++ = *in++;
1593
-     len--;
1594
-    }
1595
+ while (len > 0) {
1596
+ if ((len > 2) && (*in == '%') && (is_hex(in[1])) && (is_hex(in[2]))) {
1597
+ in++;
1598
+ if ((*in >= '0') && (*in <= '9'))
1599
+ *out = (*in - '0');
1600
+ else if ((*in >= 'a') && (*in <= 'f'))
1601
+ *out = (*in - 'a') + 10;
1602
+ else if ((*in >= 'A') && (*in <= 'F'))
1603
+ *out = (*in - 'A') + 10;
1604
+ in++;
1605
+ if ((*in >= '0') && (*in <= '9'))
1606
+ *out = *out * 16 + (*in - '0');
1607
+ else if ((*in >= 'a') && (*in <= 'f'))
1608
+ *out = *out * 16 + (*in - 'a') + 10;
1609
+ else if ((*in >= 'A') && (*in <= 'F'))
1610
+ *out = *out * 16 + (*in - 'A') + 10;
1611
+ in++;
1612
+ len -= 3;
1613
+ out++;
1614
+ } else {
1615
+ *out++ = *in++;
1616
+ len--;
1617
+ }
1618
}
1619
*out = 0;
1620
- return(ret);
1621
+ return (ret);
1622
}
1623
1624
/**
1625
@@ -XXX,XX +XXX,XX @@ uri_string_unescape(const char *str, int len, char *target) {
1626
*
1627
* Returns a new escaped string or NULL in case of error.
1628
*/
1629
-char *
1630
-uri_string_escape(const char *str, const char *list) {
1631
+char *uri_string_escape(const char *str, const char *list)
1632
+{
1633
char *ret, ch;
1634
char *temp;
1635
const char *in;
1636
int len, out;
1637
1638
if (str == NULL)
1639
-    return(NULL);
1640
+ return (NULL);
1641
if (str[0] == 0)
1642
-    return(g_strdup(str));
1643
+ return (g_strdup(str));
1644
len = strlen(str);
1645
- if (!(len > 0)) return(NULL);
1646
+ if (!(len > 0))
1647
+ return (NULL);
1648
1649
len += 20;
1650
ret = g_malloc(len);
1651
in = str;
1652
out = 0;
1653
- while(*in != 0) {
1654
-    if (len - out <= 3) {
1655
+ while (*in != 0) {
1656
+ if (len - out <= 3) {
1657
temp = realloc2n(ret, &len);
1658
-     ret = temp;
1659
-    }
1660
+ ret = temp;
1661
+ }
1662
1663
-    ch = *in;
1664
-
1665
-    if ((ch != '@') && (!IS_UNRESERVED(ch)) && (!strchr(list, ch))) {
1666
-     unsigned char val;
1667
-     ret[out++] = '%';
1668
-     val = ch >> 4;
1669
-     if (val <= 9)
1670
-        ret[out++] = '0' + val;
1671
-     else
1672
-        ret[out++] = 'A' + val - 0xA;
1673
-     val = ch & 0xF;
1674
-     if (val <= 9)
1675
-        ret[out++] = '0' + val;
1676
-     else
1677
-        ret[out++] = 'A' + val - 0xA;
1678
-     in++;
1679
-    } else {
1680
-     ret[out++] = *in++;
1681
-    }
1682
+ ch = *in;
1683
1684
+ if ((ch != '@') && (!IS_UNRESERVED(ch)) && (!strchr(list, ch))) {
1685
+ unsigned char val;
1686
+ ret[out++] = '%';
1687
+ val = ch >> 4;
1688
+ if (val <= 9)
1689
+ ret[out++] = '0' + val;
1690
+ else
1691
+ ret[out++] = 'A' + val - 0xA;
1692
+ val = ch & 0xF;
1693
+ if (val <= 9)
1694
+ ret[out++] = '0' + val;
1695
+ else
1696
+ ret[out++] = 'A' + val - 0xA;
1697
+ in++;
1698
+ } else {
1699
+ ret[out++] = *in++;
1700
+ }
1701
}
1702
ret[out] = 0;
1703
- return(ret);
1704
+ return (ret);
1705
}
1706
1707
/************************************************************************
1708
- *                                    *
1709
- *            Public functions                *
1710
- *                                    *
1711
+ * *
1712
+ * Public functions *
1713
+ * *
1714
************************************************************************/
1715
1716
/**
1717
@@ -XXX,XX +XXX,XX @@ uri_string_escape(const char *str, const char *list) {
1718
* Returns a new URI string (to be freed by the caller) or NULL in case
1719
* of error.
1720
*/
1721
-char *
1722
-uri_resolve(const char *uri, const char *base) {
1723
+char *uri_resolve(const char *uri, const char *base)
1724
+{
1725
char *val = NULL;
1726
int ret, len, indx, cur, out;
1727
URI *ref = NULL;
1728
@@ -XXX,XX +XXX,XX @@ uri_resolve(const char *uri, const char *base) {
1729
* URI. Should we do that here?
1730
*/
1731
if (uri == NULL)
1732
-    ret = -1;
1733
+ ret = -1;
1734
else {
1735
-    if (*uri) {
1736
-     ref = uri_new();
1737
-     ret = uri_parse_into(ref, uri);
1738
-    }
1739
-    else
1740
-     ret = 0;
1741
+ if (*uri) {
1742
+ ref = uri_new();
1743
+ ret = uri_parse_into(ref, uri);
1744
+ } else
1745
+ ret = 0;
1746
}
1747
if (ret != 0)
1748
-    goto done;
1749
+ goto done;
1750
if ((ref != NULL) && (ref->scheme != NULL)) {
1751
-    /*
1752
-     * The URI is absolute don't modify.
1753
-     */
1754
-    val = g_strdup(uri);
1755
-    goto done;
1756
+ /*
1757
+ * The URI is absolute don't modify.
1758
+ */
1759
+ val = g_strdup(uri);
1760
+ goto done;
1761
}
1762
if (base == NULL)
1763
-    ret = -1;
1764
+ ret = -1;
1765
else {
1766
-    bas = uri_new();
1767
-    ret = uri_parse_into(bas, base);
1768
+ bas = uri_new();
1769
+ ret = uri_parse_into(bas, base);
1770
}
1771
if (ret != 0) {
1772
-    if (ref)
1773
-     val = uri_to_string(ref);
1774
-    goto done;
1775
+ if (ref)
1776
+ val = uri_to_string(ref);
1777
+ goto done;
1778
}
1779
if (ref == NULL) {
1780
-    /*
1781
-     * the base fragment must be ignored
1782
-     */
1783
+ /*
1784
+ * the base fragment must be ignored
1785
+ */
1786
g_free(bas->fragment);
1787
bas->fragment = NULL;
1788
-    val = uri_to_string(bas);
1789
-    goto done;
1790
+ val = uri_to_string(bas);
1791
+ goto done;
1792
}
1793
1794
/*
1795
@@ -XXX,XX +XXX,XX @@ uri_resolve(const char *uri, const char *base) {
1796
*/
1797
res = uri_new();
1798
if ((ref->scheme == NULL) && (ref->path == NULL) &&
1799
-    ((ref->authority == NULL) && (ref->server == NULL))) {
1800
+ ((ref->authority == NULL) && (ref->server == NULL))) {
1801
res->scheme = g_strdup(bas->scheme);
1802
-    if (bas->authority != NULL)
1803
-     res->authority = g_strdup(bas->authority);
1804
-    else if (bas->server != NULL) {
1805
+ if (bas->authority != NULL)
1806
+ res->authority = g_strdup(bas->authority);
1807
+ else if (bas->server != NULL) {
1808
res->server = g_strdup(bas->server);
1809
res->user = g_strdup(bas->user);
1810
res->port = bas->port;
1811
-    }
1812
+ }
1813
res->path = g_strdup(bas->path);
1814
if (ref->query != NULL) {
1815
-     res->query = g_strdup (ref->query);
1816
+ res->query = g_strdup(ref->query);
1817
} else {
1818
res->query = g_strdup(bas->query);
1819
}
1820
res->fragment = g_strdup(ref->fragment);
1821
-    goto step_7;
1822
+ goto step_7;
1823
}
1824
1825
/*
1826
@@ -XXX,XX +XXX,XX @@ uri_resolve(const char *uri, const char *base) {
1827
* scheme is inherited from the base URI's scheme component.
1828
*/
1829
if (ref->scheme != NULL) {
1830
-    val = uri_to_string(ref);
1831
-    goto done;
1832
+ val = uri_to_string(ref);
1833
+ goto done;
1834
}
1835
res->scheme = g_strdup(bas->scheme);
1836
1837
@@ -XXX,XX +XXX,XX @@ uri_resolve(const char *uri, const char *base) {
1838
* use an authority component.
1839
*/
1840
if ((ref->authority != NULL) || (ref->server != NULL)) {
1841
-    if (ref->authority != NULL)
1842
-     res->authority = g_strdup(ref->authority);
1843
-    else {
1844
-     res->server = g_strdup(ref->server);
1845
+ if (ref->authority != NULL)
1846
+ res->authority = g_strdup(ref->authority);
1847
+ else {
1848
+ res->server = g_strdup(ref->server);
1849
res->user = g_strdup(ref->user);
1850
res->port = ref->port;
1851
-    }
1852
+ }
1853
res->path = g_strdup(ref->path);
1854
-    goto step_7;
1855
+ goto step_7;
1856
}
1857
if (bas->authority != NULL)
1858
-    res->authority = g_strdup(bas->authority);
1859
+ res->authority = g_strdup(bas->authority);
1860
else if (bas->server != NULL) {
1861
res->server = g_strdup(bas->server);
1862
res->user = g_strdup(bas->user);
1863
-    res->port = bas->port;
1864
+ res->port = bas->port;
1865
}
1866
1867
/*
1868
@@ -XXX,XX +XXX,XX @@ uri_resolve(const char *uri, const char *base) {
1869
* the reference is an absolute-path and we skip to step 7.
1870
*/
1871
if ((ref->path != NULL) && (ref->path[0] == '/')) {
1872
-    res->path = g_strdup(ref->path);
1873
-    goto step_7;
1874
+ res->path = g_strdup(ref->path);
1875
+ goto step_7;
1876
}
1877
1878
-
1879
/*
1880
* 6) If this step is reached, then we are resolving a relative-path
1881
* reference. The relative path needs to be merged with the base
1882
@@ -XXX,XX +XXX,XX @@ uri_resolve(const char *uri, const char *base) {
1883
*/
1884
len = 2; /* extra / and 0 */
1885
if (ref->path != NULL)
1886
-    len += strlen(ref->path);
1887
+ len += strlen(ref->path);
1888
if (bas->path != NULL)
1889
-    len += strlen(bas->path);
1890
+ len += strlen(bas->path);
1891
res->path = g_malloc(len);
1892
res->path[0] = 0;
1893
1894
@@ -XXX,XX +XXX,XX @@ uri_resolve(const char *uri, const char *base) {
1895
cur = 0;
1896
out = 0;
1897
if (bas->path != NULL) {
1898
-    while (bas->path[cur] != 0) {
1899
-     while ((bas->path[cur] != 0) && (bas->path[cur] != '/'))
1900
-        cur++;
1901
-     if (bas->path[cur] == 0)
1902
-        break;
1903
+ while (bas->path[cur] != 0) {
1904
+ while ((bas->path[cur] != 0) && (bas->path[cur] != '/'))
1905
+ cur++;
1906
+ if (bas->path[cur] == 0)
1907
+ break;
1908
1909
-     cur++;
1910
-     while (out < cur) {
1911
-        res->path[out] = bas->path[out];
1912
-        out++;
1913
-     }
1914
-    }
1915
+ cur++;
1916
+ while (out < cur) {
1917
+ res->path[out] = bas->path[out];
1918
+ out++;
1919
+ }
1920
+ }
1921
}
1922
res->path[out] = 0;
1923
1924
@@ -XXX,XX +XXX,XX @@ uri_resolve(const char *uri, const char *base) {
1925
* string.
1926
*/
1927
if (ref->path != NULL && ref->path[0] != 0) {
1928
-    indx = 0;
1929
-    /*
1930
-     * Ensure the path includes a '/'
1931
-     */
1932
-    if ((out == 0) && (bas->server != NULL))
1933
-     res->path[out++] = '/';
1934
-    while (ref->path[indx] != 0) {
1935
-     res->path[out++] = ref->path[indx++];
1936
-    }
1937
+ indx = 0;
1938
+ /*
1939
+ * Ensure the path includes a '/'
1940
+ */
1941
+ if ((out == 0) && (bas->server != NULL))
1942
+ res->path[out++] = '/';
1943
+ while (ref->path[indx] != 0) {
1944
+ res->path[out++] = ref->path[indx++];
1945
+ }
1946
}
1947
res->path[out] = 0;
1948
1949
@@ -XXX,XX +XXX,XX @@ step_7:
1950
1951
done:
1952
if (ref != NULL)
1953
-    uri_free(ref);
1954
+ uri_free(ref);
1955
if (bas != NULL)
1956
-    uri_free(bas);
1957
+ uri_free(bas);
1958
if (res != NULL)
1959
-    uri_free(res);
1960
- return(val);
1961
+ uri_free(res);
1962
+ return (val);
1963
}
1964
1965
/**
1966
@@ -XXX,XX +XXX,XX @@ done:
1967
* Returns a new URI string (to be freed by the caller) or NULL in case
1968
* error.
1969
*/
1970
-char *
1971
-uri_resolve_relative (const char *uri, const char * base)
1972
+char *uri_resolve_relative(const char *uri, const char *base)
1973
{
1974
char *val = NULL;
1975
int ret;
1976
@@ -XXX,XX +XXX,XX @@ uri_resolve_relative (const char *uri, const char * base)
1977
int remove_path = 0;
1978
1979
if ((uri == NULL) || (*uri == 0))
1980
-    return NULL;
1981
+ return NULL;
1982
1983
/*
1984
* First parse URI into a standard form
1985
*/
1986
- ref = uri_new ();
1987
+ ref = uri_new();
1988
/* If URI not already in "relative" form */
1989
if (uri[0] != '.') {
1990
-    ret = uri_parse_into (ref, uri);
1991
-    if (ret != 0)
1992
-     goto done;        /* Error in URI, return NULL */
1993
+ ret = uri_parse_into(ref, uri);
1994
+ if (ret != 0)
1995
+ goto done; /* Error in URI, return NULL */
1996
} else
1997
-    ref->path = g_strdup(uri);
1998
+ ref->path = g_strdup(uri);
1999
2000
/*
2001
* Next parse base into the same standard form
2002
*/
2003
if ((base == NULL) || (*base == 0)) {
2004
-    val = g_strdup (uri);
2005
-    goto done;
2006
+ val = g_strdup(uri);
2007
+ goto done;
2008
}
2009
- bas = uri_new ();
2010
+ bas = uri_new();
2011
if (base[0] != '.') {
2012
-    ret = uri_parse_into (bas, base);
2013
-    if (ret != 0)
2014
-     goto done;        /* Error in base, return NULL */
2015
+ ret = uri_parse_into(bas, base);
2016
+ if (ret != 0)
2017
+ goto done; /* Error in base, return NULL */
2018
} else
2019
-    bas->path = g_strdup(base);
2020
+ bas->path = g_strdup(base);
2021
2022
/*
2023
* If the scheme / server on the URI differs from the base,
2024
* just return the URI
2025
*/
2026
if ((ref->scheme != NULL) &&
2027
-    ((bas->scheme == NULL) ||
2028
-     (strcmp (bas->scheme, ref->scheme)) ||
2029
-     (strcmp (bas->server, ref->server)))) {
2030
-    val = g_strdup (uri);
2031
-    goto done;
2032
+ ((bas->scheme == NULL) || (strcmp(bas->scheme, ref->scheme)) ||
2033
+ (strcmp(bas->server, ref->server)))) {
2034
+ val = g_strdup(uri);
2035
+ goto done;
2036
}
2037
if (bas->path == ref->path ||
2038
(bas->path && ref->path && !strcmp(bas->path, ref->path))) {
2039
-    val = g_strdup("");
2040
-    goto done;
2041
+ val = g_strdup("");
2042
+ goto done;
2043
}
2044
if (bas->path == NULL) {
2045
-    val = g_strdup(ref->path);
2046
-    goto done;
2047
+ val = g_strdup(ref->path);
2048
+ goto done;
2049
}
2050
if (ref->path == NULL) {
2051
- ref->path = (char *) "/";
2052
-    remove_path = 1;
2053
+ ref->path = (char *)"/";
2054
+ remove_path = 1;
2055
}
2056
2057
/*
2058
@@ -XXX,XX +XXX,XX @@ uri_resolve_relative (const char *uri, const char * base)
2059
* two path components may be missing (bug 316224)
2060
*/
2061
if (bas->path == NULL) {
2062
-    if (ref->path != NULL) {
2063
-     uptr = ref->path;
2064
-     if (*uptr == '/')
2065
-        uptr++;
2066
-     /* exception characters from uri_to_string */
2067
-     val = uri_string_escape(uptr, "/;&=+$,");
2068
-    }
2069
-    goto done;
2070
+ if (ref->path != NULL) {
2071
+ uptr = ref->path;
2072
+ if (*uptr == '/')
2073
+ uptr++;
2074
+ /* exception characters from uri_to_string */
2075
+ val = uri_string_escape(uptr, "/;&=+$,");
2076
+ }
2077
+ goto done;
2078
}
2079
bptr = bas->path;
2080
if (ref->path == NULL) {
2081
-    for (ix = 0; bptr[ix] != 0; ix++) {
2082
-     if (bptr[ix] == '/')
2083
-        nbslash++;
2084
-    }
2085
-    uptr = NULL;
2086
-    len = 1;    /* this is for a string terminator only */
2087
+ for (ix = 0; bptr[ix] != 0; ix++) {
2088
+ if (bptr[ix] == '/')
2089
+ nbslash++;
2090
+ }
2091
+ uptr = NULL;
2092
+ len = 1; /* this is for a string terminator only */
2093
} else {
2094
- /*
2095
- * Next we compare the two strings and find where they first differ
2096
- */
2097
-    if ((ref->path[pos] == '.') && (ref->path[pos+1] == '/'))
2098
+ /*
2099
+ * Next we compare the two strings and find where they first differ
2100
+ */
2101
+ if ((ref->path[pos] == '.') && (ref->path[pos + 1] == '/'))
2102
pos += 2;
2103
-    if ((*bptr == '.') && (bptr[1] == '/'))
2104
+ if ((*bptr == '.') && (bptr[1] == '/'))
2105
bptr += 2;
2106
-    else if ((*bptr == '/') && (ref->path[pos] != '/'))
2107
-     bptr++;
2108
-    while ((bptr[pos] == ref->path[pos]) && (bptr[pos] != 0))
2109
-     pos++;
2110
+ else if ((*bptr == '/') && (ref->path[pos] != '/'))
2111
+ bptr++;
2112
+ while ((bptr[pos] == ref->path[pos]) && (bptr[pos] != 0))
2113
+ pos++;
2114
2115
-    if (bptr[pos] == ref->path[pos]) {
2116
-     val = g_strdup("");
2117
-     goto done;        /* (I can't imagine why anyone would do this) */
2118
-    }
2119
+ if (bptr[pos] == ref->path[pos]) {
2120
+ val = g_strdup("");
2121
+ goto done; /* (I can't imagine why anyone would do this) */
2122
+ }
2123
2124
-    /*
2125
-     * In URI, "back up" to the last '/' encountered. This will be the
2126
-     * beginning of the "unique" suffix of URI
2127
-     */
2128
-    ix = pos;
2129
-    if ((ref->path[ix] == '/') && (ix > 0))
2130
-     ix--;
2131
-    else if ((ref->path[ix] == 0) && (ix > 1) && (ref->path[ix - 1] == '/'))
2132
-     ix -= 2;
2133
-    for (; ix > 0; ix--) {
2134
-     if (ref->path[ix] == '/')
2135
-        break;
2136
-    }
2137
-    if (ix == 0) {
2138
-     uptr = ref->path;
2139
-    } else {
2140
-     ix++;
2141
-     uptr = &ref->path[ix];
2142
-    }
2143
+ /*
2144
+ * In URI, "back up" to the last '/' encountered. This will be the
2145
+ * beginning of the "unique" suffix of URI
2146
+ */
2147
+ ix = pos;
2148
+ if ((ref->path[ix] == '/') && (ix > 0))
2149
+ ix--;
2150
+ else if ((ref->path[ix] == 0) && (ix > 1) && (ref->path[ix - 1] == '/'))
2151
+ ix -= 2;
2152
+ for (; ix > 0; ix--) {
2153
+ if (ref->path[ix] == '/')
2154
+ break;
2155
+ }
2156
+ if (ix == 0) {
2157
+ uptr = ref->path;
2158
+ } else {
2159
+ ix++;
2160
+ uptr = &ref->path[ix];
2161
+ }
2162
2163
-    /*
2164
-     * In base, count the number of '/' from the differing point
2165
-     */
2166
-    if (bptr[pos] != ref->path[pos]) {/* check for trivial URI == base */
2167
-     for (; bptr[ix] != 0; ix++) {
2168
-        if (bptr[ix] == '/')
2169
-         nbslash++;
2170
-     }
2171
-    }
2172
-    len = strlen (uptr) + 1;
2173
+ /*
2174
+ * In base, count the number of '/' from the differing point
2175
+ */
2176
+ if (bptr[pos] != ref->path[pos]) { /* check for trivial URI == base */
2177
+ for (; bptr[ix] != 0; ix++) {
2178
+ if (bptr[ix] == '/')
2179
+ nbslash++;
2180
+ }
2181
+ }
2182
+ len = strlen(uptr) + 1;
2183
}
2184
2185
if (nbslash == 0) {
2186
-    if (uptr != NULL)
2187
-     /* exception characters from uri_to_string */
2188
-     val = uri_string_escape(uptr, "/;&=+$,");
2189
-    goto done;
2190
+ if (uptr != NULL)
2191
+ /* exception characters from uri_to_string */
2192
+ val = uri_string_escape(uptr, "/;&=+$,");
2193
+ goto done;
2194
}
2195
2196
/*
2197
@@ -XXX,XX +XXX,XX @@ uri_resolve_relative (const char *uri, const char * base)
2198
* length of the remainder of the URI, plus enough space
2199
* for the "../" groups, plus one for the terminator
2200
*/
2201
- val = g_malloc (len + 3 * nbslash);
2202
+ val = g_malloc(len + 3 * nbslash);
2203
vptr = val;
2204
/*
2205
* Put in as many "../" as needed
2206
*/
2207
- for (; nbslash>0; nbslash--) {
2208
-    *vptr++ = '.';
2209
-    *vptr++ = '.';
2210
-    *vptr++ = '/';
2211
+ for (; nbslash > 0; nbslash--) {
2212
+ *vptr++ = '.';
2213
+ *vptr++ = '.';
2214
+ *vptr++ = '/';
2215
}
2216
/*
2217
* Finish up with the end of the URI
2218
*/
2219
if (uptr != NULL) {
2220
- if ((vptr > val) && (len > 0) &&
2221
-     (uptr[0] == '/') && (vptr[-1] == '/')) {
2222
-     memcpy (vptr, uptr + 1, len - 1);
2223
-     vptr[len - 2] = 0;
2224
-    } else {
2225
-     memcpy (vptr, uptr, len);
2226
-     vptr[len - 1] = 0;
2227
-    }
2228
+ if ((vptr > val) && (len > 0) && (uptr[0] == '/') &&
2229
+ (vptr[-1] == '/')) {
2230
+ memcpy(vptr, uptr + 1, len - 1);
2231
+ vptr[len - 2] = 0;
2232
+ } else {
2233
+ memcpy(vptr, uptr, len);
2234
+ vptr[len - 1] = 0;
2235
+ }
2236
} else {
2237
-    vptr[len - 1] = 0;
2238
+ vptr[len - 1] = 0;
2239
}
2240
2241
/* escape the freshly-built path */
2242
vptr = val;
2243
-    /* exception characters from uri_to_string */
2244
+ /* exception characters from uri_to_string */
2245
val = uri_string_escape(vptr, "/;&=+$,");
2246
g_free(vptr);
2247
2248
@@ -XXX,XX +XXX,XX @@ done:
2249
if (remove_path != 0)
2250
ref->path = NULL;
2251
if (ref != NULL)
2252
-    uri_free (ref);
2253
+ uri_free(ref);
2254
if (bas != NULL)
2255
-    uri_free (bas);
2256
+ uri_free(bas);
2257
2258
return val;
2259
}
2260
@@ -XXX,XX +XXX,XX @@ done:
2261
* Utility functions to help parse and assemble query strings.
2262
*/
2263
2264
-struct QueryParams *
2265
-query_params_new (int init_alloc)
2266
+struct QueryParams *query_params_new(int init_alloc)
2267
{
2268
struct QueryParams *ps;
2269
2270
- if (init_alloc <= 0) init_alloc = 1;
2271
+ if (init_alloc <= 0)
2272
+ init_alloc = 1;
2273
2274
ps = g_new(QueryParams, 1);
2275
ps->n = 0;
2276
@@ -XXX,XX +XXX,XX @@ query_params_new (int init_alloc)
2277
/* Ensure there is space to store at least one more parameter
2278
* at the end of the set.
2279
*/
2280
-static int
2281
-query_params_append (struct QueryParams *ps,
2282
- const char *name, const char *value)
2283
+static int query_params_append(struct QueryParams *ps, const char *name,
2284
+ const char *value)
2285
{
2286
if (ps->n >= ps->alloc) {
2287
ps->p = g_renew(QueryParam, ps->p, ps->alloc * 2);
2288
@@ -XXX,XX +XXX,XX @@ query_params_append (struct QueryParams *ps,
2289
return 0;
2290
}
2291
2292
-void
2293
-query_params_free (struct QueryParams *ps)
2294
+void query_params_free(struct QueryParams *ps)
2295
{
2296
int i;
2297
2298
for (i = 0; i < ps->n; ++i) {
2299
- g_free (ps->p[i].name);
2300
- g_free (ps->p[i].value);
2301
+ g_free(ps->p[i].name);
2302
+ g_free(ps->p[i].value);
2303
}
2304
- g_free (ps->p);
2305
- g_free (ps);
2306
+ g_free(ps->p);
2307
+ g_free(ps);
2308
}
2309
2310
-struct QueryParams *
2311
-query_params_parse (const char *query)
2312
+struct QueryParams *query_params_parse(const char *query)
2313
{
2314
struct QueryParams *ps;
2315
const char *end, *eq;
2316
2317
- ps = query_params_new (0);
2318
- if (!query || query[0] == '\0') return ps;
2319
+ ps = query_params_new(0);
2320
+ if (!query || query[0] == '\0')
2321
+ return ps;
2322
2323
while (*query) {
2324
char *name = NULL, *value = NULL;
2325
2326
/* Find the next separator, or end of the string. */
2327
- end = strchr (query, '&');
2328
+ end = strchr(query, '&');
2329
if (!end)
2330
- end = strchr (query, ';');
2331
+ end = strchr(query, ';');
2332
if (!end)
2333
- end = query + strlen (query);
2334
+ end = query + strlen(query);
2335
2336
/* Find the first '=' character between here and end. */
2337
- eq = strchr (query, '=');
2338
- if (eq && eq >= end) eq = NULL;
2339
+ eq = strchr(query, '=');
2340
+ if (eq && eq >= end)
2341
+ eq = NULL;
2342
2343
/* Empty section (eg. "&&"). */
2344
if (end == query)
2345
@@ -XXX,XX +XXX,XX @@ query_params_parse (const char *query)
2346
* and consistent with CGI.pm we assume value is "".
2347
*/
2348
else if (!eq) {
2349
- name = uri_string_unescape (query, end - query, NULL);
2350
+ name = uri_string_unescape(query, end - query, NULL);
2351
value = NULL;
2352
}
2353
/* Or if we have "name=" here (works around annoying
2354
* problem when calling uri_string_unescape with len = 0).
2355
*/
2356
- else if (eq+1 == end) {
2357
- name = uri_string_unescape (query, eq - query, NULL);
2358
+ else if (eq + 1 == end) {
2359
+ name = uri_string_unescape(query, eq - query, NULL);
2360
value = g_new0(char, 1);
2361
}
2362
/* If the '=' character is at the beginning then we have
2363
@@ -XXX,XX +XXX,XX @@ query_params_parse (const char *query)
2364
2365
/* Otherwise it's "name=value". */
2366
else {
2367
- name = uri_string_unescape (query, eq - query, NULL);
2368
- value = uri_string_unescape (eq+1, end - (eq+1), NULL);
2369
+ name = uri_string_unescape(query, eq - query, NULL);
2370
+ value = uri_string_unescape(eq + 1, end - (eq + 1), NULL);
2371
}
2372
2373
/* Append to the parameter set. */
2374
- query_params_append (ps, name, value);
2375
+ query_params_append(ps, name, value);
2376
g_free(name);
2377
g_free(value);
2378
2379
next:
2380
query = end;
2381
- if (*query) query ++; /* skip '&' separator */
2382
+ if (*query)
2383
+ query++; /* skip '&' separator */
2384
}
2385
2386
return ps;
2387
--
175
--
2388
2.14.3
176
2.21.0
2389
177
2390
178
diff view generated by jsdifflib
New patch
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
2
3
It's wrong to OR shared permissions. It may lead to crash on further
4
permission updates.
5
Also, no needs to consider previously calculated permissions, as at
6
this point we already bind all new parents and bdrv_get_cumulative_perm
7
result is enough. So fix the bug by just set permissions by
8
bdrv_get_cumulative_perm result.
9
10
Bug was introduced in long ago 234ac1a9025, in 2.9.
11
12
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
13
Message-id: 20190824100740.61635-1-vsementsov@virtuozzo.com
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
15
---
16
block.c | 5 ++---
17
1 file changed, 2 insertions(+), 3 deletions(-)
18
19
diff --git a/block.c b/block.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/block.c
22
+++ b/block.c
23
@@ -XXX,XX +XXX,XX @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
24
{
25
BdrvChild *c, *next;
26
GSList *list = NULL, *p;
27
- uint64_t old_perm, old_shared;
28
uint64_t perm = 0, shared = BLK_PERM_ALL;
29
int ret;
30
31
@@ -XXX,XX +XXX,XX @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
32
bdrv_unref(from);
33
}
34
35
- bdrv_get_cumulative_perm(to, &old_perm, &old_shared);
36
- bdrv_set_perm(to, old_perm | perm, old_shared | shared);
37
+ bdrv_get_cumulative_perm(to, &perm, &shared);
38
+ bdrv_set_perm(to, perm, shared);
39
40
out:
41
g_slist_free(list);
42
--
43
2.21.0
44
45
diff view generated by jsdifflib
New patch
1
1
From: Nir Soffer <nirsof@gmail.com>
2
3
When creating an image with preallocation "off" or "falloc", the first
4
block of the image is typically not allocated. When using Gluster
5
storage backed by XFS filesystem, reading this block using direct I/O
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>
61
---
62
block/file-posix.c | 51 +++++++++++++++++++
63
tests/qemu-iotests/059.out | 2 +-
64
tests/qemu-iotests/{150.out => 150.out.qcow2} | 0
65
tests/qemu-iotests/150.out.raw | 12 +++++
66
tests/qemu-iotests/175 | 19 ++++---
67
tests/qemu-iotests/175.out | 8 +--
68
tests/qemu-iotests/178.out.qcow2 | 4 +-
69
tests/qemu-iotests/221.out | 12 +++--
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;
81
}
82
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)
98
+{
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;
118
+}
119
+
120
static int handle_aiocb_truncate(void *opaque)
121
{
122
RawPosixAIOData *aiocb = opaque;
123
@@ -XXX,XX +XXX,XX @@ static int handle_aiocb_truncate(void *opaque)
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/"
208
}
209
210
# get standard environment, filters and checks
211
@@ -XXX,XX +XXX,XX @@ size=$((1 * 1024 * 1024))
212
touch "$TEST_DIR/empty"
213
extra_blocks=$(stat -c '%b' "$TEST_DIR/empty")
214
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
277
{
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
335
--
336
2.21.0
337
338
diff view generated by jsdifflib
New patch
1
From: Nir Soffer <nirsof@gmail.com>
1
2
3
Using block_resize we can test allocate_first_block() with file
4
descriptor opened with O_DIRECT, ensuring that it works for any size
5
larger than 4096 bytes.
6
7
Testing smaller sizes is tricky as the result depends on the filesystem
8
used for testing. For example on NFS any size will work since O_DIRECT
9
does not require any alignment.
10
11
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
12
Reviewed-by: Max Reitz <mreitz@redhat.com>
13
Message-id: 20190827010528.8818-3-nsoffer@redhat.com
14
Signed-off-by: Max Reitz <mreitz@redhat.com>
15
---
16
tests/qemu-iotests/175 | 28 ++++++++++++++++++++++++++++
17
tests/qemu-iotests/175.out | 8 ++++++++
18
2 files changed, 36 insertions(+)
19
20
diff --git a/tests/qemu-iotests/175 b/tests/qemu-iotests/175
21
index XXXXXXX..XXXXXXX 100755
22
--- a/tests/qemu-iotests/175
23
+++ b/tests/qemu-iotests/175
24
@@ -XXX,XX +XXX,XX @@ _filter_blocks()
25
-e "s/blocks=$((extra_blocks + img_size / 512))\\(\$\\|[^0-9]\\)/max allocation/"
26
}
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
35
+
36
+ $QEMU -qmp stdio -nographic -nodefaults \
37
+ -blockdev file,node-name=file,filename=$path,cache.direct=on \
38
+ <<EOF
39
+{'execute': 'qmp_capabilities'}
40
+{'execute': 'block_resize', 'arguments': {'node-name': 'file', 'size': $size}}
41
+{'execute': 'quit'}
42
+EOF
43
+}
44
+
45
# get standard environment, filters and checks
46
. ./common.rc
47
. ./common.filter
48
@@ -XXX,XX +XXX,XX @@ _supported_fmt raw
49
_supported_proto file
50
_supported_os Linux
51
52
+_default_cache_mode none
53
+_supported_cache_modes none directsync
54
+
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
90
--
91
2.21.0
92
93
diff view generated by jsdifflib
New patch
1
fe646693acc changed qemu-img create's output so that it no longer prints
2
single quotes around parameter values. The subformat and adapter_type
3
filters in _filter_img_create() have never been adapted to that change.
1
4
5
Fixes: fe646693acc13ac48b98435d14149ab04dc597bc
6
Signed-off-by: Max Reitz <mreitz@redhat.com>
7
Reviewed-by: John Snow <jsnow@redhat.com>
8
Message-id: 20190815153638.4600-2-mreitz@redhat.com
9
Reviewed-by: John Snow <jsnow@redhat.com>
10
Signed-off-by: Max Reitz <mreitz@redhat.com>
11
---
12
tests/qemu-iotests/059.out | 16 ++++++++--------
13
tests/qemu-iotests/common.filter | 4 ++--
14
2 files changed, 10 insertions(+), 10 deletions(-)
15
16
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
17
index XXXXXXX..XXXXXXX 100644
18
--- a/tests/qemu-iotests/059.out
19
+++ b/tests/qemu-iotests/059.out
20
@@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
21
qemu-io: can't open device TEST_DIR/t.vmdk: L1 size too big
22
23
=== Testing monolithicFlat creation and opening ===
24
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 subformat=monolithicFlat
25
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648
26
image: TEST_DIR/t.IMGFMT
27
file format: IMGFMT
28
virtual size: 2 GiB (2147483648 bytes)
29
30
=== Testing monolithicFlat with zeroed_grain ===
31
qemu-img: TEST_DIR/t.IMGFMT: Flat image can't enable zeroed grain
32
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 subformat=monolithicFlat
33
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648
34
35
=== Testing big twoGbMaxExtentFlat ===
36
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000 subformat=twoGbMaxExtentFlat
37
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000
38
image: TEST_DIR/t.vmdk
39
file format: vmdk
40
virtual size: 0.977 TiB (1073741824000 bytes)
41
@@ -XXX,XX +XXX,XX @@ Format specific information:
42
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Invalid extent line: RW 12582912 VMFS "dummy.IMGFMT" 1
43
44
=== Testing truncated sparse ===
45
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=107374182400 subformat=monolithicSparse
46
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=107374182400
47
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': File truncated, expecting at least 13172736 bytes
48
49
=== Converting to streamOptimized from image with small cluster size===
50
@@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240
51
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
52
53
=== Testing monolithicFlat with internally generated JSON file name ===
54
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 subformat=monolithicFlat
55
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
56
qemu-io: can't open: Cannot use relative extent paths with VMDK descriptor file 'json:{"image": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, "driver": "blkdebug", "inject-error.0.event": "read_aio"}'
57
58
=== Testing version 3 ===
59
@@ -XXX,XX +XXX,XX @@ read 512/512 bytes at offset 64931328
60
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
61
62
=== Testing 4TB monolithicFlat creation and IO ===
63
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4398046511104 subformat=monolithicFlat
64
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4398046511104
65
image: TEST_DIR/t.IMGFMT
66
file format: IMGFMT
67
virtual size: 4 TiB (4398046511104 bytes)
68
@@ -XXX,XX +XXX,XX @@ read 1024/1024 bytes at offset 966367641600
69
1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
70
71
=== Testing qemu-img map on extents ===
72
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544 subformat=monolithicSparse
73
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544
74
wrote 1024/1024 bytes at offset 65024
75
1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
76
wrote 1024/1024 bytes at offset 2147483136
77
@@ -XXX,XX +XXX,XX @@ Offset Length Mapped to File
78
0 0x20000 0x3f0000 TEST_DIR/t.vmdk
79
0x7fff0000 0x20000 0x410000 TEST_DIR/t.vmdk
80
0x140000000 0x10000 0x430000 TEST_DIR/t.vmdk
81
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544 subformat=twoGbMaxExtentSparse
82
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33285996544
83
wrote 1024/1024 bytes at offset 65024
84
1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
85
wrote 1024/1024 bytes at offset 2147483136
86
diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
87
index XXXXXXX..XXXXXXX 100644
88
--- a/tests/qemu-iotests/common.filter
89
+++ b/tests/qemu-iotests/common.filter
90
@@ -XXX,XX +XXX,XX @@ _filter_img_create()
91
-e "s# compat6=\\(on\\|off\\)##g" \
92
-e "s# static=\\(on\\|off\\)##g" \
93
-e "s# zeroed_grain=\\(on\\|off\\)##g" \
94
- -e "s# subformat='[^']*'##g" \
95
- -e "s# adapter_type='[^']*'##g" \
96
+ -e "s# subformat=[^ ]*##g" \
97
+ -e "s# adapter_type=[^ ]*##g" \
98
-e "s# hwversion=[^ ]*##g" \
99
-e "s# lazy_refcounts=\\(on\\|off\\)##g" \
100
-e "s# block_size=[0-9]\\+##g" \
101
--
102
2.21.0
103
104
diff view generated by jsdifflib
1
From: Su Hang <suhang16@mails.ucas.ac.cn>
1
This makes iotest 033 pass with e.g. subformat=monolithicFlat. It also
2
turns a former error in 059 into success.
2
3
3
For this patch, using curly braces to wrap `if` `while` `else` statements,
4
Signed-off-by: Max Reitz <mreitz@redhat.com>
4
which only hold single statement. For example:
5
Message-id: 20190815153638.4600-3-mreitz@redhat.com
5
'''
6
Reviewed-by: John Snow <jsnow@redhat.com>
6
if (cond)
7
Signed-off-by: Max Reitz <mreitz@redhat.com>
7
statement;
8
---
8
'''
9
block/vmdk.c | 54 ++++++++++++++++++++++++--------------
9
to
10
tests/qemu-iotests/059 | 7 +++--
10
'''
11
tests/qemu-iotests/059.out | 4 ++-
11
if (cond) {
12
3 files changed, 42 insertions(+), 23 deletions(-)
12
statement;
13
}
14
'''
15
13
16
And using tricks that compare the disassemblies before and after
14
diff --git a/block/vmdk.c b/block/vmdk.c
17
code changes, to make sure code logic isn't changed:
18
'''
19
git checkout master
20
make util/uri.o
21
strip util/uri.o
22
objdump -Drx util/uri.o > /tmp/uri-master.txt
23
git checkout cleanupbranch
24
make util/uri.o
25
strip util/uri.o
26
objdump -Drx util/uri.o > /tmp/uri-cleanup.txt
27
28
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
29
---
30
util/uri.c | 463 +++++++++++++++++++++++++++++++++++++++----------------------
31
1 file changed, 294 insertions(+), 169 deletions(-)
32
33
diff --git a/util/uri.c b/util/uri.c
34
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
35
--- a/util/uri.c
16
--- a/block/vmdk.c
36
+++ b/util/uri.c
17
+++ b/block/vmdk.c
37
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_scheme(URI *uri, const char **str)
18
@@ -XXX,XX +XXX,XX @@ static const char *next_line(const char *s)
38
{
39
const char *cur;
40
41
- if (str == NULL)
42
+ if (str == NULL) {
43
return -1;
44
+ }
45
46
cur = *str;
47
- if (!ISA_ALPHA(cur))
48
+ if (!ISA_ALPHA(cur)) {
49
return 2;
50
+ }
51
cur++;
52
while (ISA_ALPHA(cur) || ISA_DIGIT(cur) || (*cur == '+') || (*cur == '-') ||
53
- (*cur == '.'))
54
+ (*cur == '.')) {
55
cur++;
56
+ }
57
if (uri != NULL) {
58
g_free(uri->scheme);
59
uri->scheme = g_strndup(*str, cur - *str);
60
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_fragment(URI *uri, const char **str)
61
{
62
const char *cur;
63
64
- if (str == NULL)
65
+ if (str == NULL) {
66
return -1;
67
+ }
68
69
cur = *str;
70
71
while ((ISA_PCHAR(cur)) || (*cur == '/') || (*cur == '?') ||
72
(*cur == '[') || (*cur == ']') ||
73
- ((uri != NULL) && (uri->cleanup & 1) && (IS_UNWISE(cur))))
74
+ ((uri != NULL) && (uri->cleanup & 1) && (IS_UNWISE(cur)))) {
75
NEXT(cur);
76
+ }
77
if (uri != NULL) {
78
g_free(uri->fragment);
79
- if (uri->cleanup & 2)
80
+ if (uri->cleanup & 2) {
81
uri->fragment = g_strndup(*str, cur - *str);
82
- else
83
+ } else {
84
uri->fragment = uri_string_unescape(*str, cur - *str, NULL);
85
+ }
86
}
87
*str = cur;
88
return 0;
89
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_query(URI *uri, const char **str)
90
{
91
const char *cur;
92
93
- if (str == NULL)
94
+ if (str == NULL) {
95
return -1;
96
+ }
97
98
cur = *str;
99
100
while ((ISA_PCHAR(cur)) || (*cur == '/') || (*cur == '?') ||
101
- ((uri != NULL) && (uri->cleanup & 1) && (IS_UNWISE(cur))))
102
+ ((uri != NULL) && (uri->cleanup & 1) && (IS_UNWISE(cur)))) {
103
NEXT(cur);
104
+ }
105
if (uri != NULL) {
106
g_free(uri->query);
107
uri->query = g_strndup(*str, cur - *str);
108
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_user_info(URI *uri, const char **str)
109
110
cur = *str;
111
while (ISA_UNRESERVED(cur) || ISA_PCT_ENCODED(cur) || ISA_SUB_DELIM(cur) ||
112
- (*cur == ':'))
113
+ (*cur == ':')) {
114
NEXT(cur);
115
+ }
116
if (*cur == '@') {
117
if (uri != NULL) {
118
g_free(uri->user);
119
- if (uri->cleanup & 2)
120
+ if (uri->cleanup & 2) {
121
uri->user = g_strndup(*str, cur - *str);
122
- else
123
+ } else {
124
uri->user = uri_string_unescape(*str, cur - *str, NULL);
125
+ }
126
}
127
*str = cur;
128
return 0;
129
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_dec_octet(const char **str)
130
{
131
const char *cur = *str;
132
133
- if (!(ISA_DIGIT(cur)))
134
+ if (!(ISA_DIGIT(cur))) {
135
return 1;
136
- if (!ISA_DIGIT(cur + 1))
137
+ }
138
+ if (!ISA_DIGIT(cur + 1)) {
139
cur++;
140
- else if ((*cur != '0') && (ISA_DIGIT(cur + 1)) && (!ISA_DIGIT(cur + 2)))
141
+ } else if ((*cur != '0') && (ISA_DIGIT(cur + 1)) && (!ISA_DIGIT(cur + 2))) {
142
cur += 2;
143
- else if ((*cur == '1') && (ISA_DIGIT(cur + 1)) && (ISA_DIGIT(cur + 2)))
144
+ } else if ((*cur == '1') && (ISA_DIGIT(cur + 1)) && (ISA_DIGIT(cur + 2))) {
145
cur += 3;
146
- else if ((*cur == '2') && (*(cur + 1) >= '0') && (*(cur + 1) <= '4') &&
147
- (ISA_DIGIT(cur + 2)))
148
+ } else if ((*cur == '2') && (*(cur + 1) >= '0') && (*(cur + 1) <= '4') &&
149
+ (ISA_DIGIT(cur + 2))) {
150
cur += 3;
151
- else if ((*cur == '2') && (*(cur + 1) == '5') && (*(cur + 2) >= '0') &&
152
- (*(cur + 1) <= '5'))
153
+ } else if ((*cur == '2') && (*(cur + 1) == '5') && (*(cur + 2) >= '0') &&
154
+ (*(cur + 1) <= '5')) {
155
cur += 3;
156
- else
157
+ } else {
158
return 1;
159
+ }
160
*str = cur;
161
return 0;
162
}
19
}
163
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_host(URI *uri, const char **str)
20
164
*/
21
static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
165
if (*cur == '[') {
22
- const char *desc_file_path, QDict *options,
166
cur++;
23
- Error **errp)
167
- while ((*cur != ']') && (*cur != 0))
24
+ QDict *options, Error **errp)
168
+ while ((*cur != ']') && (*cur != 0)) {
169
cur++;
170
- if (*cur != ']')
171
+ }
172
+ if (*cur != ']') {
173
return 1;
174
+ }
175
cur++;
176
goto found;
177
}
178
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_host(URI *uri, const char **str)
179
* try to parse an IPv4
180
*/
181
if (ISA_DIGIT(cur)) {
182
- if (rfc3986_parse_dec_octet(&cur) != 0)
183
+ if (rfc3986_parse_dec_octet(&cur) != 0) {
184
goto not_ipv4;
185
- if (*cur != '.')
186
+ }
187
+ if (*cur != '.') {
188
goto not_ipv4;
189
+ }
190
cur++;
191
- if (rfc3986_parse_dec_octet(&cur) != 0)
192
+ if (rfc3986_parse_dec_octet(&cur) != 0) {
193
goto not_ipv4;
194
- if (*cur != '.')
195
+ }
196
+ if (*cur != '.') {
197
goto not_ipv4;
198
- if (rfc3986_parse_dec_octet(&cur) != 0)
199
+ }
200
+ if (rfc3986_parse_dec_octet(&cur) != 0) {
201
goto not_ipv4;
202
- if (*cur != '.')
203
+ }
204
+ if (*cur != '.') {
205
goto not_ipv4;
206
- if (rfc3986_parse_dec_octet(&cur) != 0)
207
+ }
208
+ if (rfc3986_parse_dec_octet(&cur) != 0) {
209
goto not_ipv4;
210
+ }
211
goto found;
212
not_ipv4:
213
cur = *str;
214
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_host(URI *uri, const char **str)
215
/*
216
* then this should be a hostname which can be empty
217
*/
218
- while (ISA_UNRESERVED(cur) || ISA_PCT_ENCODED(cur) || ISA_SUB_DELIM(cur))
219
+ while (ISA_UNRESERVED(cur) || ISA_PCT_ENCODED(cur) || ISA_SUB_DELIM(cur)) {
220
NEXT(cur);
221
+ }
222
found:
223
if (uri != NULL) {
224
g_free(uri->authority);
225
uri->authority = NULL;
226
g_free(uri->server);
227
if (cur != host) {
228
- if (uri->cleanup & 2)
229
+ if (uri->cleanup & 2) {
230
uri->server = g_strndup(host, cur - host);
231
- else
232
+ } else {
233
uri->server = uri_string_unescape(host, cur - host, NULL);
234
- } else
235
+ }
236
+ } else {
237
uri->server = NULL;
238
+ }
239
}
240
*str = cur;
241
return 0;
242
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_authority(URI *uri, const char **str)
243
* try to parse a userinfo and check for the trailing @
244
*/
245
ret = rfc3986_parse_user_info(uri, &cur);
246
- if ((ret != 0) || (*cur != '@'))
247
+ if ((ret != 0) || (*cur != '@')) {
248
cur = *str;
249
- else
250
+ } else {
251
cur++;
252
+ }
253
ret = rfc3986_parse_host(uri, &cur);
254
- if (ret != 0)
255
+ if (ret != 0) {
256
return ret;
257
+ }
258
if (*cur == ':') {
259
cur++;
260
ret = rfc3986_parse_port(uri, &cur);
261
- if (ret != 0)
262
+ if (ret != 0) {
263
return ret;
264
+ }
265
}
266
*str = cur;
267
return 0;
268
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_segment(const char **str, char forbid, int empty)
269
270
cur = *str;
271
if (!ISA_PCHAR(cur)) {
272
- if (empty)
273
+ if (empty) {
274
return 0;
275
+ }
276
return 1;
277
}
278
- while (ISA_PCHAR(cur) && (*cur != forbid))
279
+ while (ISA_PCHAR(cur) && (*cur != forbid)) {
280
NEXT(cur);
281
+ }
282
*str = cur;
283
return 0;
284
}
285
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_path_ab_empty(URI *uri, const char **str)
286
while (*cur == '/') {
287
cur++;
288
ret = rfc3986_parse_segment(&cur, 0, 1);
289
- if (ret != 0)
290
+ if (ret != 0) {
291
return ret;
292
+ }
293
}
294
if (uri != NULL) {
295
g_free(uri->path);
296
if (*str != cur) {
297
- if (uri->cleanup & 2)
298
+ if (uri->cleanup & 2) {
299
uri->path = g_strndup(*str, cur - *str);
300
- else
301
+ } else {
302
uri->path = uri_string_unescape(*str, cur - *str, NULL);
303
+ }
304
} else {
305
uri->path = NULL;
306
}
307
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_path_absolute(URI *uri, const char **str)
308
309
cur = *str;
310
311
- if (*cur != '/')
312
+ if (*cur != '/') {
313
return 1;
314
+ }
315
cur++;
316
ret = rfc3986_parse_segment(&cur, 0, 0);
317
if (ret == 0) {
318
while (*cur == '/') {
319
cur++;
320
ret = rfc3986_parse_segment(&cur, 0, 1);
321
- if (ret != 0)
322
+ if (ret != 0) {
323
return ret;
324
+ }
325
}
326
}
327
if (uri != NULL) {
328
g_free(uri->path);
329
if (cur != *str) {
330
- if (uri->cleanup & 2)
331
+ if (uri->cleanup & 2) {
332
uri->path = g_strndup(*str, cur - *str);
333
- else
334
+ } else {
335
uri->path = uri_string_unescape(*str, cur - *str, NULL);
336
+ }
337
} else {
338
uri->path = NULL;
339
}
340
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_path_rootless(URI *uri, const char **str)
341
cur = *str;
342
343
ret = rfc3986_parse_segment(&cur, 0, 0);
344
- if (ret != 0)
345
+ if (ret != 0) {
346
return ret;
347
+ }
348
while (*cur == '/') {
349
cur++;
350
ret = rfc3986_parse_segment(&cur, 0, 1);
351
- if (ret != 0)
352
+ if (ret != 0) {
353
return ret;
354
+ }
355
}
356
if (uri != NULL) {
357
g_free(uri->path);
358
if (cur != *str) {
359
- if (uri->cleanup & 2)
360
+ if (uri->cleanup & 2) {
361
uri->path = g_strndup(*str, cur - *str);
362
- else
363
+ } else {
364
uri->path = uri_string_unescape(*str, cur - *str, NULL);
365
+ }
366
} else {
367
uri->path = NULL;
368
}
369
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_path_no_scheme(URI *uri, const char **str)
370
cur = *str;
371
372
ret = rfc3986_parse_segment(&cur, ':', 0);
373
- if (ret != 0)
374
+ if (ret != 0) {
375
return ret;
376
+ }
377
while (*cur == '/') {
378
cur++;
379
ret = rfc3986_parse_segment(&cur, 0, 1);
380
- if (ret != 0)
381
+ if (ret != 0) {
382
return ret;
383
+ }
384
}
385
if (uri != NULL) {
386
g_free(uri->path);
387
if (cur != *str) {
388
- if (uri->cleanup & 2)
389
+ if (uri->cleanup & 2) {
390
uri->path = g_strndup(*str, cur - *str);
391
- else
392
+ } else {
393
uri->path = uri_string_unescape(*str, cur - *str, NULL);
394
+ }
395
} else {
396
uri->path = NULL;
397
}
398
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_hier_part(URI *uri, const char **str)
399
if ((*cur == '/') && (*(cur + 1) == '/')) {
400
cur += 2;
401
ret = rfc3986_parse_authority(uri, &cur);
402
- if (ret != 0)
403
+ if (ret != 0) {
404
return ret;
405
+ }
406
ret = rfc3986_parse_path_ab_empty(uri, &cur);
407
- if (ret != 0)
408
+ if (ret != 0) {
409
return ret;
410
+ }
411
*str = cur;
412
return 0;
413
} else if (*cur == '/') {
414
ret = rfc3986_parse_path_absolute(uri, &cur);
415
- if (ret != 0)
416
+ if (ret != 0) {
417
return ret;
418
+ }
419
} else if (ISA_PCHAR(cur)) {
420
ret = rfc3986_parse_path_rootless(uri, &cur);
421
- if (ret != 0)
422
+ if (ret != 0) {
423
return ret;
424
+ }
425
} else {
426
/* path-empty is effectively empty */
427
if (uri != NULL) {
428
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_relative_ref(URI *uri, const char *str)
429
if ((*str == '/') && (*(str + 1) == '/')) {
430
str += 2;
431
ret = rfc3986_parse_authority(uri, &str);
432
- if (ret != 0)
433
+ if (ret != 0) {
434
return ret;
435
+ }
436
ret = rfc3986_parse_path_ab_empty(uri, &str);
437
- if (ret != 0)
438
+ if (ret != 0) {
439
return ret;
440
+ }
441
} else if (*str == '/') {
442
ret = rfc3986_parse_path_absolute(uri, &str);
443
- if (ret != 0)
444
+ if (ret != 0) {
445
return ret;
446
+ }
447
} else if (ISA_PCHAR(str)) {
448
ret = rfc3986_parse_path_no_scheme(uri, &str);
449
- if (ret != 0)
450
+ if (ret != 0) {
451
return ret;
452
+ }
453
} else {
454
/* path-empty is effectively empty */
455
if (uri != NULL) {
456
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_relative_ref(URI *uri, const char *str)
457
if (*str == '?') {
458
str++;
459
ret = rfc3986_parse_query(uri, &str);
460
- if (ret != 0)
461
+ if (ret != 0) {
462
return ret;
463
+ }
464
}
465
if (*str == '#') {
466
str++;
467
ret = rfc3986_parse_fragment(uri, &str);
468
- if (ret != 0)
469
+ if (ret != 0) {
470
return ret;
471
+ }
472
}
473
if (*str != 0) {
474
uri_clean(uri);
475
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse(URI *uri, const char *str)
476
int ret;
477
478
ret = rfc3986_parse_scheme(uri, &str);
479
- if (ret != 0)
480
+ if (ret != 0) {
481
return ret;
482
+ }
483
if (*str != ':') {
484
return 1;
485
}
486
str++;
487
ret = rfc3986_parse_hier_part(uri, &str);
488
- if (ret != 0)
489
+ if (ret != 0) {
490
return ret;
491
+ }
492
if (*str == '?') {
493
str++;
494
ret = rfc3986_parse_query(uri, &str);
495
- if (ret != 0)
496
+ if (ret != 0) {
497
return ret;
498
+ }
499
}
500
if (*str == '#') {
501
str++;
502
ret = rfc3986_parse_fragment(uri, &str);
503
- if (ret != 0)
504
+ if (ret != 0) {
505
return ret;
506
+ }
507
}
508
if (*str != 0) {
509
uri_clean(uri);
510
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_uri_reference(URI *uri, const char *str)
511
{
25
{
512
int ret;
26
int ret;
513
27
int matches;
514
- if (str == NULL)
28
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
515
+ if (str == NULL) {
29
const char *p, *np;
516
return -1;
30
int64_t sectors = 0;
517
+ }
31
int64_t flat_offset;
518
uri_clean(uri);
32
+ char *desc_file_dir = NULL;
519
33
char *extent_path;
520
/*
34
BdrvChild *extent_file;
521
@@ -XXX,XX +XXX,XX @@ URI *uri_parse(const char *str)
35
BDRVVmdkState *s = bs->opaque;
522
URI *uri;
36
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
523
int ret;
524
525
- if (str == NULL)
526
+ if (str == NULL) {
527
return NULL;
528
+ }
529
uri = uri_new();
530
ret = rfc3986_parse_uri_reference(uri, str);
531
if (ret) {
532
@@ -XXX,XX +XXX,XX @@ URI *uri_parse_raw(const char *str, int raw)
533
URI *uri;
534
int ret;
535
536
- if (str == NULL)
537
+ if (str == NULL) {
538
return NULL;
539
+ }
540
uri = uri_new();
541
if (raw) {
542
uri->cleanup |= 2;
543
@@ -XXX,XX +XXX,XX @@ char *uri_to_string(URI *uri)
544
int len;
545
int max;
546
547
- if (uri == NULL)
548
+ if (uri == NULL) {
549
return NULL;
550
+ }
551
552
max = 80;
553
ret = g_malloc(max + 1);
554
@@ -XXX,XX +XXX,XX @@ char *uri_to_string(URI *uri)
555
temp = realloc2n(ret, &max);
556
ret = temp;
557
}
558
- if (IS_RESERVED(*(p)) || IS_UNRESERVED(*(p)))
559
+ if (IS_RESERVED(*(p)) || IS_UNRESERVED(*(p))) {
560
ret[len++] = *p++;
561
- else {
562
+ } else {
563
int val = *(unsigned char *)p++;
564
int hi = val / 0x10, lo = val % 0x10;
565
ret[len++] = '%';
566
@@ -XXX,XX +XXX,XX @@ char *uri_to_string(URI *uri)
567
}
568
if ((IS_UNRESERVED(*(p))) || ((*(p) == ';')) ||
569
((*(p) == ':')) || ((*(p) == '&')) || ((*(p) == '=')) ||
570
- ((*(p) == '+')) || ((*(p) == '$')) || ((*(p) == ',')))
571
+ ((*(p) == '+')) || ((*(p) == '$')) || ((*(p) == ','))) {
572
ret[len++] = *p++;
573
- else {
574
+ } else {
575
int val = *(unsigned char *)p++;
576
int hi = val / 0x10, lo = val % 0x10;
577
ret[len++] = '%';
578
@@ -XXX,XX +XXX,XX @@ char *uri_to_string(URI *uri)
579
if ((IS_UNRESERVED(*(p))) || ((*(p) == '$')) ||
580
((*(p) == ',')) || ((*(p) == ';')) || ((*(p) == ':')) ||
581
((*(p) == '@')) || ((*(p) == '&')) || ((*(p) == '=')) ||
582
- ((*(p) == '+')))
583
+ ((*(p) == '+'))) {
584
ret[len++] = *p++;
585
- else {
586
+ } else {
587
int val = *(unsigned char *)p++;
588
int hi = val / 0x10, lo = val % 0x10;
589
ret[len++] = '%';
590
@@ -XXX,XX +XXX,XX @@ char *uri_to_string(URI *uri)
591
if ((IS_UNRESERVED(*(p))) || ((*(p) == '/')) ||
592
((*(p) == ';')) || ((*(p) == '@')) || ((*(p) == '&')) ||
593
((*(p) == '=')) || ((*(p) == '+')) || ((*(p) == '$')) ||
594
- ((*(p) == ',')))
595
+ ((*(p) == ','))) {
596
ret[len++] = *p++;
597
- else {
598
+ } else {
599
int val = *(unsigned char *)p++;
600
int hi = val / 0x10, lo = val % 0x10;
601
ret[len++] = '%';
602
@@ -XXX,XX +XXX,XX @@ char *uri_to_string(URI *uri)
603
temp = realloc2n(ret, &max);
604
ret = temp;
605
}
606
- if ((IS_UNRESERVED(*(p))) || (IS_RESERVED(*(p))))
607
+ if ((IS_UNRESERVED(*(p))) || (IS_RESERVED(*(p)))) {
608
ret[len++] = *p++;
609
- else {
610
+ } else {
611
int val = *(unsigned char *)p++;
612
int hi = val / 0x10, lo = val % 0x10;
613
ret[len++] = '%';
614
@@ -XXX,XX +XXX,XX @@ char *uri_to_string(URI *uri)
615
*/
616
static void uri_clean(URI *uri)
617
{
618
- if (uri == NULL)
619
+ if (uri == NULL) {
620
return;
621
+ }
622
623
g_free(uri->scheme);
624
uri->scheme = NULL;
625
@@ -XXX,XX +XXX,XX @@ static int normalize_uri_path(char *path)
626
{
627
char *cur, *out;
628
629
- if (path == NULL)
630
+ if (path == NULL) {
631
return -1;
632
+ }
633
634
/* Skip all initial "/" chars. We want to get to the beginning of the
635
* first non-empty segment.
636
*/
637
cur = path;
638
- while (cur[0] == '/')
639
+ while (cur[0] == '/') {
640
++cur;
641
- if (cur[0] == '\0')
642
+ }
643
+ if (cur[0] == '\0') {
644
return 0;
645
+ }
646
647
/* Keep everything we've seen so far. */
648
out = cur;
649
@@ -XXX,XX +XXX,XX @@ static int normalize_uri_path(char *path)
650
if ((cur[0] == '.') && (cur[1] == '/')) {
651
cur += 2;
652
/* '//' normalization should be done at this point too */
653
- while (cur[0] == '/')
654
+ while (cur[0] == '/') {
655
cur++;
656
+ }
657
continue;
37
continue;
658
}
38
}
659
39
660
@@ -XXX,XX +XXX,XX @@ static int normalize_uri_path(char *path)
40
- if (!path_is_absolute(fname) && !path_has_protocol(fname) &&
661
* d) If the buffer string ends with "." as a complete path segment,
41
- !desc_file_path[0])
662
* that "." is removed.
42
- {
663
*/
43
- bdrv_refresh_filename(bs->file->bs);
664
- if ((cur[0] == '.') && (cur[1] == '\0'))
44
- error_setg(errp, "Cannot use relative extent paths with VMDK "
665
+ if ((cur[0] == '.') && (cur[1] == '\0')) {
45
- "descriptor file '%s'", bs->file->bs->filename);
666
break;
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);
667
+ }
65
+ }
668
66
669
/* Otherwise keep the segment. */
67
ret = snprintf(extent_opt_prefix, 32, "extents.%d", s->num_extents);
670
while (cur[0] != '/') {
68
assert(ret < 32);
671
- if (cur[0] == '\0')
69
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
672
+ if (cur[0] == '\0') {
70
g_free(extent_path);
673
goto done_cd;
71
if (local_err) {
674
+ }
72
error_propagate(errp, local_err);
675
(out++)[0] = (cur++)[0];
73
- return -EINVAL;
74
+ ret = -EINVAL;
75
+ goto out;
676
}
76
}
677
/* nomalize // */
77
678
- while ((cur[0] == '/') && (cur[1] == '/'))
78
/* save to extents array */
679
+ while ((cur[0] == '/') && (cur[1] == '/')) {
79
@@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
680
cur++;
80
0, 0, 0, 0, 0, &extent, errp);
681
+ }
81
if (ret < 0) {
682
82
bdrv_unref_child(bs, extent_file);
683
(out++)[0] = (cur++)[0];
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);
684
}
112
}
685
@@ -XXX,XX +XXX,XX @@ done_cd:
113
- return 0;
686
114
+
687
/* Reset to the beginning of the first segment for the next sequence. */
115
+ ret = 0;
688
cur = path;
116
+ goto out;
689
- while (cur[0] == '/')
117
690
+ while (cur[0] == '/') {
118
invalid:
691
++cur;
119
np = next_line(p);
692
- if (cur[0] == '\0')
120
@@ -XXX,XX +XXX,XX @@ invalid:
693
+ }
121
np--;
694
+ if (cur[0] == '\0') {
695
return 0;
696
+ }
697
698
/*
699
* Analyze each segment in sequence for cases (e) and (f).
700
@@ -XXX,XX +XXX,XX @@ done_cd:
701
702
/* Find the end of the current segment. */
703
segp = cur;
704
- while ((segp[0] != '/') && (segp[0] != '\0'))
705
+ while ((segp[0] != '/') && (segp[0] != '\0')) {
706
++segp;
707
+ }
708
709
/* If this is the last segment, we're done (we need at least two
710
* segments to meet the criteria for the (e) and (f) cases).
711
*/
712
- if (segp[0] == '\0')
713
+ if (segp[0] == '\0') {
714
break;
715
+ }
716
717
/* If the first segment is "..", or if the next segment _isn't_ "..",
718
* keep this segment and try the next one.
719
@@ -XXX,XX +XXX,XX @@ done_cd:
720
/* string will overlap, do not use strcpy */
721
tmp = cur;
722
segp += 3;
723
- while ((*tmp++ = *segp++) != 0)
724
- ;
725
+ while ((*tmp++ = *segp++) != 0) {
726
+ /* No further work */
727
+ }
728
729
/* If there are no previous segments, then keep going from here. */
730
segp = cur;
731
- while ((segp > path) && ((--segp)[0] == '/'))
732
- ;
733
- if (segp == path)
734
+ while ((segp > path) && ((--segp)[0] == '/')) {
735
+ /* No further work */
736
+ }
737
+ if (segp == path) {
738
continue;
739
+ }
740
741
/* "segp" is pointing to the end of a previous segment; find it's
742
* start. We need to back up to the previous segment and start
743
@@ -XXX,XX +XXX,XX @@ done_cd:
744
* remove the "foo/..".
745
*/
746
cur = segp;
747
- while ((cur > path) && (cur[-1] != '/'))
748
+ while ((cur > path) && (cur[-1] != '/')) {
749
--cur;
750
+ }
751
}
122
}
752
out[0] = '\0';
123
error_setg(errp, "Invalid extent line: %.*s", (int)(np - p), p);
753
124
- return -EINVAL;
754
@@ -XXX,XX +XXX,XX @@ done_cd:
125
+ ret = -EINVAL;
755
if (path[0] == '/') {
126
+
756
cur = path;
127
+out:
757
while ((cur[0] == '/') && (cur[1] == '.') && (cur[2] == '.') &&
128
+ g_free(desc_file_dir);
758
- ((cur[3] == '/') || (cur[3] == '\0')))
129
+ return ret;
759
+ ((cur[3] == '/') || (cur[3] == '\0'))) {
130
}
760
cur += 3;
131
761
+ }
132
static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf,
762
133
@@ -XXX,XX +XXX,XX @@ static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf,
763
if (cur != path) {
764
out = path;
765
- while (cur[0] != '\0')
766
+ while (cur[0] != '\0') {
767
(out++)[0] = (cur++)[0];
768
+ }
769
out[0] = 0;
770
}
771
}
134
}
772
@@ -XXX,XX +XXX,XX @@ done_cd:
135
s->create_type = g_strdup(ct);
773
static int is_hex(char c)
136
s->desc_offset = 0;
774
{
137
- ret = vmdk_parse_extents(buf, bs, bs->file->bs->exact_filename, options,
775
if (((c >= '0') && (c <= '9')) || ((c >= 'a') && (c <= 'f')) ||
138
- errp);
776
- ((c >= 'A') && (c <= 'F')))
139
+ ret = vmdk_parse_extents(buf, bs, options, errp);
777
+ ((c >= 'A') && (c <= 'F'))) {
140
exit:
778
return 1;
141
return ret;
779
+ }
780
return 0;
781
}
142
}
782
143
diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059
783
@@ -XXX,XX +XXX,XX @@ char *uri_string_unescape(const char *str, int len, char *target)
144
index XXXXXXX..XXXXXXX 100755
784
char *ret, *out;
145
--- a/tests/qemu-iotests/059
785
const char *in;
146
+++ b/tests/qemu-iotests/059
786
147
@@ -XXX,XX +XXX,XX @@ $QEMU_IMG convert -f qcow2 -O vmdk -o subformat=streamOptimized "$TEST_IMG.qcow2
787
- if (str == NULL)
148
788
+ if (str == NULL) {
149
echo
789
return NULL;
150
echo "=== Testing monolithicFlat with internally generated JSON file name ==="
790
- if (len <= 0)
151
+# Should work, because bdrv_dirname() works fine with blkdebug
791
+ }
152
IMGOPTS="subformat=monolithicFlat" _make_test_img 64M
792
+ if (len <= 0) {
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 \
793
len = strlen(str);
154
- | _filter_testdir | _filter_imgfmt
794
- if (len < 0)
155
+$QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" \
795
+ }
156
+ -c info \
796
+ if (len < 0) {
157
+ 2>&1 \
797
return NULL;
158
+ | _filter_testdir | _filter_imgfmt | _filter_img_info
798
+ }
159
_cleanup_test_img
799
160
800
if (target == NULL) {
161
echo
801
ret = g_malloc(len + 1);
162
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
802
- } else
163
index XXXXXXX..XXXXXXX 100644
803
+ } else {
164
--- a/tests/qemu-iotests/059.out
804
ret = target;
165
+++ b/tests/qemu-iotests/059.out
805
+ }
166
@@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240
806
in = str;
167
807
out = ret;
168
=== Testing monolithicFlat with internally generated JSON file name ===
808
while (len > 0) {
169
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
809
if ((len > 2) && (*in == '%') && (is_hex(in[1])) && (is_hex(in[2]))) {
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"}'
810
in++;
171
+format name: IMGFMT
811
- if ((*in >= '0') && (*in <= '9'))
172
+cluster size: 0 bytes
812
+ if ((*in >= '0') && (*in <= '9')) {
173
+vm state offset: 0 bytes
813
*out = (*in - '0');
174
814
- else if ((*in >= 'a') && (*in <= 'f'))
175
=== Testing version 3 ===
815
+ } else if ((*in >= 'a') && (*in <= 'f')) {
176
image: TEST_DIR/iotest-version3.IMGFMT
816
*out = (*in - 'a') + 10;
817
- else if ((*in >= 'A') && (*in <= 'F'))
818
+ } else if ((*in >= 'A') && (*in <= 'F')) {
819
*out = (*in - 'A') + 10;
820
+ }
821
in++;
822
- if ((*in >= '0') && (*in <= '9'))
823
+ if ((*in >= '0') && (*in <= '9')) {
824
*out = *out * 16 + (*in - '0');
825
- else if ((*in >= 'a') && (*in <= 'f'))
826
+ } else if ((*in >= 'a') && (*in <= 'f')) {
827
*out = *out * 16 + (*in - 'a') + 10;
828
- else if ((*in >= 'A') && (*in <= 'F'))
829
+ } else if ((*in >= 'A') && (*in <= 'F')) {
830
*out = *out * 16 + (*in - 'A') + 10;
831
+ }
832
in++;
833
len -= 3;
834
out++;
835
@@ -XXX,XX +XXX,XX @@ char *uri_string_escape(const char *str, const char *list)
836
const char *in;
837
int len, out;
838
839
- if (str == NULL)
840
+ if (str == NULL) {
841
return NULL;
842
- if (str[0] == 0)
843
+ }
844
+ if (str[0] == 0) {
845
return g_strdup(str);
846
+ }
847
len = strlen(str);
848
- if (!(len > 0))
849
+ if (!(len > 0)) {
850
return NULL;
851
+ }
852
853
len += 20;
854
ret = g_malloc(len);
855
@@ -XXX,XX +XXX,XX @@ char *uri_string_escape(const char *str, const char *list)
856
unsigned char val;
857
ret[out++] = '%';
858
val = ch >> 4;
859
- if (val <= 9)
860
+ if (val <= 9) {
861
ret[out++] = '0' + val;
862
- else
863
+ } else {
864
ret[out++] = 'A' + val - 0xA;
865
+ }
866
val = ch & 0xF;
867
- if (val <= 9)
868
+ if (val <= 9) {
869
ret[out++] = '0' + val;
870
- else
871
+ } else {
872
ret[out++] = 'A' + val - 0xA;
873
+ }
874
in++;
875
} else {
876
ret[out++] = *in++;
877
@@ -XXX,XX +XXX,XX @@ char *uri_resolve(const char *uri, const char *base)
878
* as a reference to "." rather than as a synonym for the current
879
* URI. Should we do that here?
880
*/
881
- if (uri == NULL)
882
+ if (uri == NULL) {
883
ret = -1;
884
- else {
885
+ } else {
886
if (*uri) {
887
ref = uri_new();
888
ret = uri_parse_into(ref, uri);
889
- } else
890
+ } else {
891
ret = 0;
892
+ }
893
}
894
- if (ret != 0)
895
+ if (ret != 0) {
896
goto done;
897
+ }
898
if ((ref != NULL) && (ref->scheme != NULL)) {
899
/*
900
* The URI is absolute don't modify.
901
@@ -XXX,XX +XXX,XX @@ char *uri_resolve(const char *uri, const char *base)
902
val = g_strdup(uri);
903
goto done;
904
}
905
- if (base == NULL)
906
+ if (base == NULL) {
907
ret = -1;
908
- else {
909
+ } else {
910
bas = uri_new();
911
ret = uri_parse_into(bas, base);
912
}
913
if (ret != 0) {
914
- if (ref)
915
+ if (ref) {
916
val = uri_to_string(ref);
917
+ }
918
goto done;
919
}
920
if (ref == NULL) {
921
@@ -XXX,XX +XXX,XX @@ char *uri_resolve(const char *uri, const char *base)
922
if ((ref->scheme == NULL) && (ref->path == NULL) &&
923
((ref->authority == NULL) && (ref->server == NULL))) {
924
res->scheme = g_strdup(bas->scheme);
925
- if (bas->authority != NULL)
926
+ if (bas->authority != NULL) {
927
res->authority = g_strdup(bas->authority);
928
- else if (bas->server != NULL) {
929
+ } else if (bas->server != NULL) {
930
res->server = g_strdup(bas->server);
931
res->user = g_strdup(bas->user);
932
res->port = bas->port;
933
@@ -XXX,XX +XXX,XX @@ char *uri_resolve(const char *uri, const char *base)
934
* use an authority component.
935
*/
936
if ((ref->authority != NULL) || (ref->server != NULL)) {
937
- if (ref->authority != NULL)
938
+ if (ref->authority != NULL) {
939
res->authority = g_strdup(ref->authority);
940
- else {
941
+ } else {
942
res->server = g_strdup(ref->server);
943
res->user = g_strdup(ref->user);
944
res->port = ref->port;
945
@@ -XXX,XX +XXX,XX @@ char *uri_resolve(const char *uri, const char *base)
946
res->path = g_strdup(ref->path);
947
goto step_7;
948
}
949
- if (bas->authority != NULL)
950
+ if (bas->authority != NULL) {
951
res->authority = g_strdup(bas->authority);
952
- else if (bas->server != NULL) {
953
+ } else if (bas->server != NULL) {
954
res->server = g_strdup(bas->server);
955
res->user = g_strdup(bas->user);
956
res->port = bas->port;
957
@@ -XXX,XX +XXX,XX @@ char *uri_resolve(const char *uri, const char *base)
958
* Allocate a buffer large enough for the result string.
959
*/
960
len = 2; /* extra / and 0 */
961
- if (ref->path != NULL)
962
+ if (ref->path != NULL) {
963
len += strlen(ref->path);
964
- if (bas->path != NULL)
965
+ }
966
+ if (bas->path != NULL) {
967
len += strlen(bas->path);
968
+ }
969
res->path = g_malloc(len);
970
res->path[0] = 0;
971
972
@@ -XXX,XX +XXX,XX @@ char *uri_resolve(const char *uri, const char *base)
973
out = 0;
974
if (bas->path != NULL) {
975
while (bas->path[cur] != 0) {
976
- while ((bas->path[cur] != 0) && (bas->path[cur] != '/'))
977
+ while ((bas->path[cur] != 0) && (bas->path[cur] != '/')) {
978
cur++;
979
- if (bas->path[cur] == 0)
980
+ }
981
+ if (bas->path[cur] == 0) {
982
break;
983
+ }
984
985
cur++;
986
while (out < cur) {
987
@@ -XXX,XX +XXX,XX @@ char *uri_resolve(const char *uri, const char *base)
988
/*
989
* Ensure the path includes a '/'
990
*/
991
- if ((out == 0) && (bas->server != NULL))
992
+ if ((out == 0) && (bas->server != NULL)) {
993
res->path[out++] = '/';
994
+ }
995
while (ref->path[indx] != 0) {
996
res->path[out++] = ref->path[indx++];
997
}
998
@@ -XXX,XX +XXX,XX @@ step_7:
999
val = uri_to_string(res);
1000
1001
done:
1002
- if (ref != NULL)
1003
+ if (ref != NULL) {
1004
uri_free(ref);
1005
- if (bas != NULL)
1006
+ }
1007
+ if (bas != NULL) {
1008
uri_free(bas);
1009
- if (res != NULL)
1010
+ }
1011
+ if (res != NULL) {
1012
uri_free(res);
1013
+ }
1014
return val;
1015
}
1016
1017
@@ -XXX,XX +XXX,XX @@ char *uri_resolve_relative(const char *uri, const char *base)
1018
char *bptr, *uptr, *vptr;
1019
int remove_path = 0;
1020
1021
- if ((uri == NULL) || (*uri == 0))
1022
+ if ((uri == NULL) || (*uri == 0)) {
1023
return NULL;
1024
+ }
1025
1026
/*
1027
* First parse URI into a standard form
1028
@@ -XXX,XX +XXX,XX @@ char *uri_resolve_relative(const char *uri, const char *base)
1029
/* If URI not already in "relative" form */
1030
if (uri[0] != '.') {
1031
ret = uri_parse_into(ref, uri);
1032
- if (ret != 0)
1033
+ if (ret != 0) {
1034
goto done; /* Error in URI, return NULL */
1035
- } else
1036
+ }
1037
+ } else {
1038
ref->path = g_strdup(uri);
1039
+ }
1040
1041
/*
1042
* Next parse base into the same standard form
1043
@@ -XXX,XX +XXX,XX @@ char *uri_resolve_relative(const char *uri, const char *base)
1044
bas = uri_new();
1045
if (base[0] != '.') {
1046
ret = uri_parse_into(bas, base);
1047
- if (ret != 0)
1048
+ if (ret != 0) {
1049
goto done; /* Error in base, return NULL */
1050
- } else
1051
+ }
1052
+ } else {
1053
bas->path = g_strdup(base);
1054
+ }
1055
1056
/*
1057
* If the scheme / server on the URI differs from the base,
1058
@@ -XXX,XX +XXX,XX @@ char *uri_resolve_relative(const char *uri, const char *base)
1059
if (bas->path == NULL) {
1060
if (ref->path != NULL) {
1061
uptr = ref->path;
1062
- if (*uptr == '/')
1063
+ if (*uptr == '/') {
1064
uptr++;
1065
+ }
1066
/* exception characters from uri_to_string */
1067
val = uri_string_escape(uptr, "/;&=+$,");
1068
}
1069
@@ -XXX,XX +XXX,XX @@ char *uri_resolve_relative(const char *uri, const char *base)
1070
bptr = bas->path;
1071
if (ref->path == NULL) {
1072
for (ix = 0; bptr[ix] != 0; ix++) {
1073
- if (bptr[ix] == '/')
1074
+ if (bptr[ix] == '/') {
1075
nbslash++;
1076
+ }
1077
}
1078
uptr = NULL;
1079
len = 1; /* this is for a string terminator only */
1080
@@ -XXX,XX +XXX,XX @@ char *uri_resolve_relative(const char *uri, const char *base)
1081
/*
1082
* Next we compare the two strings and find where they first differ
1083
*/
1084
- if ((ref->path[pos] == '.') && (ref->path[pos + 1] == '/'))
1085
+ if ((ref->path[pos] == '.') && (ref->path[pos + 1] == '/')) {
1086
pos += 2;
1087
- if ((*bptr == '.') && (bptr[1] == '/'))
1088
+ }
1089
+ if ((*bptr == '.') && (bptr[1] == '/')) {
1090
bptr += 2;
1091
- else if ((*bptr == '/') && (ref->path[pos] != '/'))
1092
+ } else if ((*bptr == '/') && (ref->path[pos] != '/')) {
1093
bptr++;
1094
- while ((bptr[pos] == ref->path[pos]) && (bptr[pos] != 0))
1095
+ }
1096
+ while ((bptr[pos] == ref->path[pos]) && (bptr[pos] != 0)) {
1097
pos++;
1098
+ }
1099
1100
if (bptr[pos] == ref->path[pos]) {
1101
val = g_strdup("");
1102
@@ -XXX,XX +XXX,XX @@ char *uri_resolve_relative(const char *uri, const char *base)
1103
* beginning of the "unique" suffix of URI
1104
*/
1105
ix = pos;
1106
- if ((ref->path[ix] == '/') && (ix > 0))
1107
+ if ((ref->path[ix] == '/') && (ix > 0)) {
1108
ix--;
1109
- else if ((ref->path[ix] == 0) && (ix > 1) && (ref->path[ix - 1] == '/'))
1110
+ } else if ((ref->path[ix] == 0) && (ix > 1)
1111
+ && (ref->path[ix - 1] == '/')) {
1112
ix -= 2;
1113
+ }
1114
for (; ix > 0; ix--) {
1115
- if (ref->path[ix] == '/')
1116
+ if (ref->path[ix] == '/') {
1117
break;
1118
+ }
1119
}
1120
if (ix == 0) {
1121
uptr = ref->path;
1122
@@ -XXX,XX +XXX,XX @@ char *uri_resolve_relative(const char *uri, const char *base)
1123
*/
1124
if (bptr[pos] != ref->path[pos]) { /* check for trivial URI == base */
1125
for (; bptr[ix] != 0; ix++) {
1126
- if (bptr[ix] == '/')
1127
+ if (bptr[ix] == '/') {
1128
nbslash++;
1129
+ }
1130
}
1131
}
1132
len = strlen(uptr) + 1;
1133
}
1134
1135
if (nbslash == 0) {
1136
- if (uptr != NULL)
1137
+ if (uptr != NULL) {
1138
/* exception characters from uri_to_string */
1139
val = uri_string_escape(uptr, "/;&=+$,");
1140
+ }
1141
goto done;
1142
}
1143
1144
@@ -XXX,XX +XXX,XX @@ done:
1145
/*
1146
* Free the working variables
1147
*/
1148
- if (remove_path != 0)
1149
+ if (remove_path != 0) {
1150
ref->path = NULL;
1151
- if (ref != NULL)
1152
+ }
1153
+ if (ref != NULL) {
1154
uri_free(ref);
1155
- if (bas != NULL)
1156
+ }
1157
+ if (bas != NULL) {
1158
uri_free(bas);
1159
+ }
1160
1161
return val;
1162
}
1163
@@ -XXX,XX +XXX,XX @@ struct QueryParams *query_params_new(int init_alloc)
1164
{
1165
struct QueryParams *ps;
1166
1167
- if (init_alloc <= 0)
1168
+ if (init_alloc <= 0) {
1169
init_alloc = 1;
1170
+ }
1171
1172
ps = g_new(QueryParams, 1);
1173
ps->n = 0;
1174
@@ -XXX,XX +XXX,XX @@ struct QueryParams *query_params_parse(const char *query)
1175
const char *end, *eq;
1176
1177
ps = query_params_new(0);
1178
- if (!query || query[0] == '\0')
1179
+ if (!query || query[0] == '\0') {
1180
return ps;
1181
+ }
1182
1183
while (*query) {
1184
char *name = NULL, *value = NULL;
1185
1186
/* Find the next separator, or end of the string. */
1187
end = strchr(query, '&');
1188
- if (!end)
1189
+ if (!end) {
1190
end = strchr(query, ';');
1191
- if (!end)
1192
+ }
1193
+ if (!end) {
1194
end = query + strlen(query);
1195
+ }
1196
1197
/* Find the first '=' character between here and end. */
1198
eq = strchr(query, '=');
1199
- if (eq && eq >= end)
1200
+ if (eq && eq >= end) {
1201
eq = NULL;
1202
+ }
1203
1204
/* Empty section (eg. "&&"). */
1205
- if (end == query)
1206
+ if (end == query) {
1207
goto next;
1208
+ }
1209
1210
/* If there is no '=' character, then we have just "name"
1211
* and consistent with CGI.pm we assume value is "".
1212
@@ -XXX,XX +XXX,XX @@ struct QueryParams *query_params_parse(const char *query)
1213
/* If the '=' character is at the beginning then we have
1214
* "=value" and consistent with CGI.pm we _ignore_ this.
1215
*/
1216
- else if (query == eq)
1217
+ else if (query == eq) {
1218
goto next;
1219
+ }
1220
1221
/* Otherwise it's "name=value". */
1222
else {
1223
@@ -XXX,XX +XXX,XX @@ struct QueryParams *query_params_parse(const char *query)
1224
1225
next:
1226
query = end;
1227
- if (*query)
1228
+ if (*query) {
1229
query++; /* skip '&' separator */
1230
+ }
1231
}
1232
1233
return ps;
1234
--
177
--
1235
2.14.3
178
2.21.0
1236
179
1237
180
diff view generated by jsdifflib
New patch
1
We had a test for a case where relative extent paths did not work, but
2
unfortunately we just fixed the underlying problem, so it works now.
3
This patch adds a new test case that still fails.
1
4
5
Signed-off-by: Max Reitz <mreitz@redhat.com>
6
Reviewed-by: John Snow <jsnow@redhat.com>
7
Message-id: 20190815153638.4600-4-mreitz@redhat.com
8
Reviewed-by: John Snow <jsnow@redhat.com>
9
Signed-off-by: Max Reitz <mreitz@redhat.com>
10
---
11
tests/qemu-iotests/059 | 27 +++++++++++++++++++++++++++
12
tests/qemu-iotests/059.out | 4 ++++
13
2 files changed, 31 insertions(+)
14
15
diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059
16
index XXXXXXX..XXXXXXX 100755
17
--- a/tests/qemu-iotests/059
18
+++ b/tests/qemu-iotests/059
19
@@ -XXX,XX +XXX,XX @@ $QEMU_IMG convert -f qcow2 -O vmdk -o subformat=streamOptimized "$TEST_IMG.qcow2
20
21
echo
22
echo "=== Testing monolithicFlat with internally generated JSON file name ==="
23
+
24
+echo '--- blkdebug ---'
25
# Should work, because bdrv_dirname() works fine with blkdebug
26
IMGOPTS="subformat=monolithicFlat" _make_test_img 64M
27
$QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" \
28
@@ -XXX,XX +XXX,XX @@ $QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TE
29
| _filter_testdir | _filter_imgfmt | _filter_img_info
30
_cleanup_test_img
31
32
+echo '--- quorum ---'
33
+# Should not work, because bdrv_dirname() does not work with quorum
34
+IMGOPTS="subformat=monolithicFlat" _make_test_img 64M
35
+cp "$TEST_IMG" "$TEST_IMG.orig"
36
+
37
+filename="json:{
38
+ \"driver\": \"$IMGFMT\",
39
+ \"file\": {
40
+ \"driver\": \"quorum\",
41
+ \"children\": [ {
42
+ \"driver\": \"file\",
43
+ \"filename\": \"$TEST_IMG\"
44
+ }, {
45
+ \"driver\": \"file\",
46
+ \"filename\": \"$TEST_IMG.orig\"
47
+ } ],
48
+ \"vote-threshold\": 1
49
+ } }"
50
+
51
+filename=$(echo "$filename" | tr '\n' ' ' | sed -e 's/\s\+/ /g')
52
+$QEMU_IMG info "$filename" 2>&1 \
53
+ | sed -e "s/'json:[^']*'/\$QUORUM_FILE/g" \
54
+ | _filter_testdir | _filter_imgfmt | _filter_img_info
55
+
56
+
57
echo
58
echo "=== Testing version 3 ==="
59
_use_sample_img iotest-version3.vmdk.bz2
60
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
61
index XXXXXXX..XXXXXXX 100644
62
--- a/tests/qemu-iotests/059.out
63
+++ b/tests/qemu-iotests/059.out
64
@@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240
65
512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
66
67
=== Testing monolithicFlat with internally generated JSON file name ===
68
+--- blkdebug ---
69
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
70
format name: IMGFMT
71
cluster size: 0 bytes
72
vm state offset: 0 bytes
73
+--- quorum ---
74
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
75
+qemu-img: Could not open $QUORUM_FILE: Cannot use relative paths with VMDK descriptor file $QUORUM_FILE: Cannot generate a base directory for quorum nodes
76
77
=== Testing version 3 ===
78
image: TEST_DIR/iotest-version3.IMGFMT
79
--
80
2.21.0
81
82
diff view generated by jsdifflib
New patch
1
Compressed writes generally have to write full clusters, not just in
2
theory but also in practice when it comes to vmdk's streamOptimized
3
subformat. It currently is just silently broken for writes with
4
non-zero in-cluster offsets:
1
5
6
$ qemu-img create -f vmdk -o subformat=streamOptimized foo.vmdk 1M
7
$ qemu-io -c 'write 4k 4k' -c 'read 4k 4k' foo.vmdk
8
wrote 4096/4096 bytes at offset 4096
9
4 KiB, 1 ops; 00.01 sec (443.724 KiB/sec and 110.9309 ops/sec)
10
read failed: Invalid argument
11
12
(The technical reason is that vmdk_write_extent() just writes the
13
incomplete compressed data actually to offset 4k. When reading the
14
data, vmdk_read_extent() looks at offset 0 and finds the compressed data
15
size to be 0, because that is what it reads from there. This yields an
16
error.)
17
18
For incomplete writes with zero in-cluster offsets, the error path when
19
reading the rest of the cluster is a bit different, but the result is
20
the same:
21
22
$ qemu-img create -f vmdk -o subformat=streamOptimized foo.vmdk 1M
23
$ qemu-io -c 'write 0k 4k' -c 'read 4k 4k' foo.vmdk
24
wrote 4096/4096 bytes at offset 0
25
4 KiB, 1 ops; 00.01 sec (362.641 KiB/sec and 90.6603 ops/sec)
26
read failed: Invalid argument
27
28
(Here, vmdk_read_extent() finds the data and then sees that the
29
uncompressed data is short.)
30
31
It is better to reject invalid writes than to make the user believe they
32
might have succeeded and then fail when trying to read it back.
33
34
Signed-off-by: Max Reitz <mreitz@redhat.com>
35
Reviewed-by: John Snow <jsnow@redhat.com>
36
Message-id: 20190815153638.4600-5-mreitz@redhat.com
37
Reviewed-by: John Snow <jsnow@redhat.com>
38
Signed-off-by: Max Reitz <mreitz@redhat.com>
39
---
40
block/vmdk.c | 10 ++++++++++
41
1 file changed, 10 insertions(+)
42
43
diff --git a/block/vmdk.c b/block/vmdk.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/block/vmdk.c
46
+++ b/block/vmdk.c
47
@@ -XXX,XX +XXX,XX @@ static int vmdk_write_extent(VmdkExtent *extent, int64_t cluster_offset,
48
if (extent->compressed) {
49
void *compressed_data;
50
51
+ /* Only whole clusters */
52
+ if (offset_in_cluster ||
53
+ n_bytes > (extent->cluster_sectors * SECTOR_SIZE) ||
54
+ (n_bytes < (extent->cluster_sectors * SECTOR_SIZE) &&
55
+ offset + n_bytes != extent->end_sector * SECTOR_SIZE))
56
+ {
57
+ ret = -EINVAL;
58
+ goto out;
59
+ }
60
+
61
if (!extent->has_marker) {
62
ret = -EINVAL;
63
goto out;
64
--
65
2.21.0
66
67
diff view generated by jsdifflib
New patch
1
streamOptimized does not support writes that do not span exactly one
2
cluster. Furthermore, it cannot rewrite already allocated clusters.
3
As such, many iotests do not work with it. Disable them.
1
4
5
Signed-off-by: Max Reitz <mreitz@redhat.com>
6
Message-id: 20190815153638.4600-6-mreitz@redhat.com
7
Reviewed-by: John Snow <jsnow@redhat.com>
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
---
10
tests/qemu-iotests/002 | 1 +
11
tests/qemu-iotests/003 | 1 +
12
tests/qemu-iotests/005 | 3 ++-
13
tests/qemu-iotests/009 | 1 +
14
tests/qemu-iotests/010 | 1 +
15
tests/qemu-iotests/011 | 1 +
16
tests/qemu-iotests/017 | 3 ++-
17
tests/qemu-iotests/018 | 3 ++-
18
tests/qemu-iotests/019 | 3 ++-
19
tests/qemu-iotests/020 | 3 ++-
20
tests/qemu-iotests/027 | 1 +
21
tests/qemu-iotests/032 | 1 +
22
tests/qemu-iotests/033 | 1 +
23
tests/qemu-iotests/034 | 3 ++-
24
tests/qemu-iotests/037 | 3 ++-
25
tests/qemu-iotests/063 | 3 ++-
26
tests/qemu-iotests/072 | 1 +
27
tests/qemu-iotests/105 | 3 ++-
28
tests/qemu-iotests/197 | 1 +
29
tests/qemu-iotests/215 | 1 +
30
tests/qemu-iotests/251 | 1 +
31
21 files changed, 30 insertions(+), 9 deletions(-)
32
33
diff --git a/tests/qemu-iotests/002 b/tests/qemu-iotests/002
34
index XXXXXXX..XXXXXXX 100755
35
--- a/tests/qemu-iotests/002
36
+++ b/tests/qemu-iotests/002
37
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
38
39
_supported_fmt generic
40
_supported_proto generic
41
+_unsupported_imgopts "subformat=streamOptimized"
42
43
44
size=128M
45
diff --git a/tests/qemu-iotests/003 b/tests/qemu-iotests/003
46
index XXXXXXX..XXXXXXX 100755
47
--- a/tests/qemu-iotests/003
48
+++ b/tests/qemu-iotests/003
49
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
50
51
_supported_fmt generic
52
_supported_proto generic
53
+_unsupported_imgopts "subformat=streamOptimized"
54
55
size=128M
56
offset=67M
57
diff --git a/tests/qemu-iotests/005 b/tests/qemu-iotests/005
58
index XXXXXXX..XXXXXXX 100755
59
--- a/tests/qemu-iotests/005
60
+++ b/tests/qemu-iotests/005
61
@@ -XXX,XX +XXX,XX @@ _supported_fmt generic
62
_supported_proto generic
63
_supported_os Linux
64
_unsupported_imgopts "subformat=twoGbMaxExtentFlat" \
65
- "subformat=twoGbMaxExtentSparse"
66
+ "subformat=twoGbMaxExtentSparse" \
67
+ "subformat=streamOptimized"
68
69
# vpc is limited to 127GB, so we can't test it here
70
if [ "$IMGFMT" = "vpc" ]; then
71
diff --git a/tests/qemu-iotests/009 b/tests/qemu-iotests/009
72
index XXXXXXX..XXXXXXX 100755
73
--- a/tests/qemu-iotests/009
74
+++ b/tests/qemu-iotests/009
75
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
76
77
_supported_fmt generic
78
_supported_proto generic
79
+_unsupported_imgopts "subformat=streamOptimized"
80
81
82
size=6G
83
diff --git a/tests/qemu-iotests/010 b/tests/qemu-iotests/010
84
index XXXXXXX..XXXXXXX 100755
85
--- a/tests/qemu-iotests/010
86
+++ b/tests/qemu-iotests/010
87
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
88
89
_supported_fmt generic
90
_supported_proto generic
91
+_unsupported_imgopts "subformat=streamOptimized"
92
93
94
size=6G
95
diff --git a/tests/qemu-iotests/011 b/tests/qemu-iotests/011
96
index XXXXXXX..XXXXXXX 100755
97
--- a/tests/qemu-iotests/011
98
+++ b/tests/qemu-iotests/011
99
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
100
101
_supported_fmt generic
102
_supported_proto generic
103
+_unsupported_imgopts "subformat=streamOptimized"
104
105
106
size=6G
107
diff --git a/tests/qemu-iotests/017 b/tests/qemu-iotests/017
108
index XXXXXXX..XXXXXXX 100755
109
--- a/tests/qemu-iotests/017
110
+++ b/tests/qemu-iotests/017
111
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
112
_supported_fmt qcow qcow2 vmdk qed
113
_supported_proto generic
114
_unsupported_proto vxhs
115
-_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
116
+_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \
117
+ "subformat=streamOptimized"
118
119
TEST_OFFSETS="0 4294967296"
120
121
diff --git a/tests/qemu-iotests/018 b/tests/qemu-iotests/018
122
index XXXXXXX..XXXXXXX 100755
123
--- a/tests/qemu-iotests/018
124
+++ b/tests/qemu-iotests/018
125
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
126
_supported_fmt qcow qcow2 vmdk qed
127
_supported_proto file
128
_supported_os Linux
129
-_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
130
+_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \
131
+ "streamOptimized"
132
133
TEST_OFFSETS="0 4294967296"
134
135
diff --git a/tests/qemu-iotests/019 b/tests/qemu-iotests/019
136
index XXXXXXX..XXXXXXX 100755
137
--- a/tests/qemu-iotests/019
138
+++ b/tests/qemu-iotests/019
139
@@ -XXX,XX +XXX,XX @@ _supported_proto file
140
_supported_os Linux
141
_unsupported_imgopts "subformat=monolithicFlat" \
142
"subformat=twoGbMaxExtentFlat" \
143
- "subformat=twoGbMaxExtentSparse"
144
+ "subformat=twoGbMaxExtentSparse" \
145
+ "subformat=streamOptimized"
146
147
TEST_OFFSETS="0 4294967296"
148
CLUSTER_SIZE=65536
149
diff --git a/tests/qemu-iotests/020 b/tests/qemu-iotests/020
150
index XXXXXXX..XXXXXXX 100755
151
--- a/tests/qemu-iotests/020
152
+++ b/tests/qemu-iotests/020
153
@@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed
154
_supported_proto file
155
_unsupported_imgopts "subformat=monolithicFlat" \
156
"subformat=twoGbMaxExtentFlat" \
157
- "subformat=twoGbMaxExtentSparse"
158
+ "subformat=twoGbMaxExtentSparse" \
159
+ "subformat=streamOptimized"
160
161
TEST_OFFSETS="0 4294967296"
162
163
diff --git a/tests/qemu-iotests/027 b/tests/qemu-iotests/027
164
index XXXXXXX..XXXXXXX 100755
165
--- a/tests/qemu-iotests/027
166
+++ b/tests/qemu-iotests/027
167
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
168
169
_supported_fmt vmdk qcow qcow2 qed
170
_supported_proto generic
171
+_unsupported_imgopts "subformat=streamOptimized"
172
173
174
size=128M
175
diff --git a/tests/qemu-iotests/032 b/tests/qemu-iotests/032
176
index XXXXXXX..XXXXXXX 100755
177
--- a/tests/qemu-iotests/032
178
+++ b/tests/qemu-iotests/032
179
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
180
# This works for any image format (though unlikely to segfault for raw)
181
_supported_fmt generic
182
_supported_proto generic
183
+_unsupported_imgopts "subformat=streamOptimized"
184
185
echo
186
echo === Prepare image ===
187
diff --git a/tests/qemu-iotests/033 b/tests/qemu-iotests/033
188
index XXXXXXX..XXXXXXX 100755
189
--- a/tests/qemu-iotests/033
190
+++ b/tests/qemu-iotests/033
191
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
192
193
_supported_fmt generic
194
_supported_proto generic
195
+_unsupported_imgopts "subformat=streamOptimized"
196
197
198
size=128M
199
diff --git a/tests/qemu-iotests/034 b/tests/qemu-iotests/034
200
index XXXXXXX..XXXXXXX 100755
201
--- a/tests/qemu-iotests/034
202
+++ b/tests/qemu-iotests/034
203
@@ -XXX,XX +XXX,XX @@ _supported_proto file
204
_supported_os Linux
205
_unsupported_imgopts "subformat=monolithicFlat" \
206
"subformat=twoGbMaxExtentFlat" \
207
- "subformat=twoGbMaxExtentSparse"
208
+ "subformat=twoGbMaxExtentSparse" \
209
+ "subformat=streamOptimized"
210
211
CLUSTER_SIZE=4k
212
size=128M
213
diff --git a/tests/qemu-iotests/037 b/tests/qemu-iotests/037
214
index XXXXXXX..XXXXXXX 100755
215
--- a/tests/qemu-iotests/037
216
+++ b/tests/qemu-iotests/037
217
@@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed
218
_supported_proto file
219
_unsupported_imgopts "subformat=monolithicFlat" \
220
"subformat=twoGbMaxExtentFlat" \
221
- "subformat=twoGbMaxExtentSparse"
222
+ "subformat=twoGbMaxExtentSparse" \
223
+ "subformat=streamOptimized"
224
225
CLUSTER_SIZE=4k
226
size=128M
227
diff --git a/tests/qemu-iotests/063 b/tests/qemu-iotests/063
228
index XXXXXXX..XXXXXXX 100755
229
--- a/tests/qemu-iotests/063
230
+++ b/tests/qemu-iotests/063
231
@@ -XXX,XX +XXX,XX @@ _supported_fmt qcow qcow2 vmdk qed raw
232
_supported_proto file
233
_unsupported_imgopts "subformat=monolithicFlat" \
234
"subformat=twoGbMaxExtentFlat" \
235
- "subformat=twoGbMaxExtentSparse"
236
+ "subformat=twoGbMaxExtentSparse" \
237
+ "subformat=streamOptimized"
238
239
_make_test_img 4M
240
241
diff --git a/tests/qemu-iotests/072 b/tests/qemu-iotests/072
242
index XXXXXXX..XXXXXXX 100755
243
--- a/tests/qemu-iotests/072
244
+++ b/tests/qemu-iotests/072
245
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
246
247
_supported_fmt vpc vmdk vhdx vdi qed qcow2 qcow
248
_supported_proto file
249
+_unsupported_imgopts "subformat=streamOptimized"
250
251
IMG_SIZE=64M
252
253
diff --git a/tests/qemu-iotests/105 b/tests/qemu-iotests/105
254
index XXXXXXX..XXXXXXX 100755
255
--- a/tests/qemu-iotests/105
256
+++ b/tests/qemu-iotests/105
257
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
258
_supported_fmt qcow2 vmdk vhdx qed
259
_supported_proto generic
260
_unsupported_imgopts "subformat=twoGbMaxExtentFlat" \
261
- "subformat=twoGbMaxExtentSparse"
262
+ "subformat=twoGbMaxExtentSparse" \
263
+ "subformat=streamOptimized"
264
265
echo
266
echo "creating large image"
267
diff --git a/tests/qemu-iotests/197 b/tests/qemu-iotests/197
268
index XXXXXXX..XXXXXXX 100755
269
--- a/tests/qemu-iotests/197
270
+++ b/tests/qemu-iotests/197
271
@@ -XXX,XX +XXX,XX @@ _supported_fmt generic
272
_supported_proto generic
273
# LUKS support may be possible, but it complicates things.
274
_unsupported_fmt luks
275
+_unsupported_imgopts "subformat=streamOptimized"
276
277
echo
278
echo '=== Copy-on-read ==='
279
diff --git a/tests/qemu-iotests/215 b/tests/qemu-iotests/215
280
index XXXXXXX..XXXXXXX 100755
281
--- a/tests/qemu-iotests/215
282
+++ b/tests/qemu-iotests/215
283
@@ -XXX,XX +XXX,XX @@ _supported_fmt generic
284
_supported_proto generic
285
# LUKS support may be possible, but it complicates things.
286
_unsupported_fmt luks
287
+_unsupported_imgopts "subformat=streamOptimized"
288
289
echo
290
echo '=== Copy-on-read ==='
291
diff --git a/tests/qemu-iotests/251 b/tests/qemu-iotests/251
292
index XXXXXXX..XXXXXXX 100755
293
--- a/tests/qemu-iotests/251
294
+++ b/tests/qemu-iotests/251
295
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
296
_supported_fmt generic
297
_supported_proto file
298
_supported_os Linux
299
+_unsupported_imgopts "subformat=streamOptimized"
300
301
if [ "$IMGOPTSSYNTAX" = "true" ]; then
302
# We use json:{} filenames here, so we cannot work with additional options.
303
--
304
2.21.0
305
306
diff view generated by jsdifflib
New patch
1
The error message for the test case where we have a quorum node for
2
which no directory name can be generated is different: For
3
twoGbMaxExtentSparse, it complains that it cannot open the extent file.
4
For other (sub)formats, it just notes that it cannot determine the
5
backing file path. Both are fine, but just disable twoGbMaxExtentSparse
6
for simplicity's sake.
1
7
8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
Reviewed-by: John Snow <jsnow@redhat.com>
10
Message-id: 20190815153638.4600-7-mreitz@redhat.com
11
Reviewed-by: John Snow <jsnow@redhat.com>
12
Signed-off-by: Max Reitz <mreitz@redhat.com>
13
---
14
tests/qemu-iotests/110 | 3 ++-
15
1 file changed, 2 insertions(+), 1 deletion(-)
16
17
diff --git a/tests/qemu-iotests/110 b/tests/qemu-iotests/110
18
index XXXXXXX..XXXXXXX 100755
19
--- a/tests/qemu-iotests/110
20
+++ b/tests/qemu-iotests/110
21
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
22
# Any format supporting backing files
23
_supported_fmt qed qcow qcow2 vmdk
24
_supported_proto file
25
-_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat"
26
+_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \
27
+ "subformat=twoGbMaxExtentSparse"
28
29
TEST_IMG_REL=$(basename "$TEST_IMG")
30
31
--
32
2.21.0
33
34
diff view generated by jsdifflib
New patch
1
iotest 126 requires backing file support, which flat vmdks cannot offer.
2
Skip this test for such subformats.
1
3
4
Signed-off-by: Max Reitz <mreitz@redhat.com>
5
Message-id: 20190815153638.4600-8-mreitz@redhat.com
6
Reviewed-by: John Snow <jsnow@redhat.com>
7
Signed-off-by: Max Reitz <mreitz@redhat.com>
8
---
9
tests/qemu-iotests/126 | 2 ++
10
1 file changed, 2 insertions(+)
11
12
diff --git a/tests/qemu-iotests/126 b/tests/qemu-iotests/126
13
index XXXXXXX..XXXXXXX 100755
14
--- a/tests/qemu-iotests/126
15
+++ b/tests/qemu-iotests/126
16
@@ -XXX,XX +XXX,XX @@ status=1    # failure is the default!
17
18
# Needs backing file support
19
_supported_fmt qcow qcow2 qed vmdk
20
+_unsupported_imgopts "subformat=monolithicFlat" \
21
+ "subformat=twoGbMaxExtentFlat"
22
# This is the default protocol (and we want to test the difference between
23
# colons which separate a protocol prefix from the rest and colons which are
24
# just part of the filename, so we cannot test protocols which require a prefix)
25
--
26
2.21.0
27
28
diff view generated by jsdifflib
1
From: Fam Zheng <famz@redhat.com>
1
From: Stefan Hajnoczi <stefanha@redhat.com>
2
2
3
git-publish [1] is a convenient tool to send patches and has been
3
Fixes: a6b257a08e3d72219f03e461a52152672fec0612
4
popular among QEMU developers. Recently it has been made available in
4
("file-posix: Handle undetectable alignment")
5
Fedora/Debian official repo.
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(-)
6
12
7
One nice feature of the tool is a per-project configuration with
13
diff --git a/block/file-posix.c b/block/file-posix.c
8
profiles, especially in which the cccmd option is a handy method to
14
index XXXXXXX..XXXXXXX 100644
9
create the Cc list.
15
--- a/block/file-posix.c
10
16
+++ b/block/file-posix.c
11
[1]: https://github.com/stefanha/git-publish
17
@@ -XXX,XX +XXX,XX @@ static void raw_probe_alignment(BlockDriverState *bs, int fd, Error **errp)
12
18
for (i = 0; i < ARRAY_SIZE(alignments); i++) {
13
Signed-off-by: Fam Zheng <famz@redhat.com>
19
align = alignments[i];
14
Message-id: 20180226030326.20219-2-famz@redhat.com
20
if (raw_is_io_aligned(fd, buf + align, max_align)) {
15
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
21
- /* Fallback to request_aligment. */
16
---
22
+ /* Fallback to request_alignment. */
17
.gitpublish | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
23
s->buf_align = (align != 1) ? align : bs->bl.request_alignment;
18
1 file changed, 51 insertions(+)
24
break;
19
create mode 100644 .gitpublish
25
}
20
21
diff --git a/.gitpublish b/.gitpublish
22
new file mode 100644
23
index XXXXXXX..XXXXXXX
24
--- /dev/null
25
+++ b/.gitpublish
26
@@ -XXX,XX +XXX,XX @@
27
+#
28
+# Common git-publish profiles that can be used to send patches to QEMU upstream.
29
+#
30
+# See https://github.com/stefanha/git-publish for more information
31
+#
32
+[gitpublishprofile "default"]
33
+base = master
34
+to = qemu-devel@nongnu.org
35
+cccmd = scripts/get_maintainer.pl --noroles --norolestats --nogit --nogit-fallback 2>/dev/null
36
+
37
+[gitpublishprofile "rfc"]
38
+base = master
39
+prefix = RFC PATCH
40
+to = qemu-devel@nongnu.org
41
+cccmd = scripts/get_maintainer.pl --noroles --norolestats --nogit --nogit-fallback 2>/dev/null
42
+
43
+[gitpublishprofile "stable"]
44
+base = master
45
+to = qemu-devel@nongnu.org
46
+cc = qemu-stable@nongnu.org
47
+cccmd = scripts/get_maintainer.pl --noroles --norolestats --nogit --nogit-fallback 2>/dev/null
48
+
49
+[gitpublishprofile "trivial"]
50
+base = master
51
+to = qemu-devel@nongnu.org
52
+cc = qemu-trivial@nongnu.org
53
+cccmd = scripts/get_maintainer.pl --noroles --norolestats --nogit --nogit-fallback 2>/dev/null
54
+
55
+[gitpublishprofile "block"]
56
+base = master
57
+to = qemu-devel@nongnu.org
58
+cc = qemu-block@nongnu.org
59
+cccmd = scripts/get_maintainer.pl --noroles --norolestats --nogit --nogit-fallback 2>/dev/null
60
+
61
+[gitpublishprofile "arm"]
62
+base = master
63
+to = qemu-devel@nongnu.org
64
+cc = qemu-arm@nongnu.org
65
+cccmd = scripts/get_maintainer.pl --noroles --norolestats --nogit --nogit-fallback 2>/dev/null
66
+
67
+[gitpublishprofile "s390"]
68
+base = master
69
+to = qemu-devel@nongnu.org
70
+cc = qemu-s390@nongnu.org
71
+cccmd = scripts/get_maintainer.pl --noroles --norolestats --nogit --nogit-fallback 2>/dev/null
72
+
73
+[gitpublishprofile "ppc"]
74
+base = master
75
+to = qemu-devel@nongnu.org
76
+cc = qemu-ppc@nongnu.org
77
+cccmd = scripts/get_maintainer.pl --noroles --norolestats --nogit --nogit-fallback 2>/dev/null
78
--
26
--
79
2.14.3
27
2.21.0
80
28
81
29
diff view generated by jsdifflib
1
From: Su Hang <suhang16@mails.ucas.ac.cn>
1
From: Thomas Huth <thuth@redhat.com>
2
2
3
only remove brackets that wrap `return` statements' content.
3
It is possible to enable only a subset of the block drivers with the
4
"--block-drv-rw-whitelist" option of the "configure" script. All other
5
drivers are marked as unusable (or only included as read-only with the
6
"--block-drv-ro-whitelist" option). If an iotest is now using such a
7
disabled block driver, it is failing - which is bad, since at least the
8
tests in the "auto" group should be able to deal with this situation.
9
Thus let's introduce a "_require_drivers" function that can be used by
10
the shell tests to check for the availability of certain drivers first,
11
and marks the test as "not run" if one of the drivers is missing.
4
12
5
use `perl -pi -e "s/return \((.*?)\);/return \1;/g" util/uri.c`
13
This patch mainly targets the test in the "auto" group which should
6
to remove pattern like this: "return (1);"
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).
7
18
8
Signed-off-by: Su Hang <suhang16@mails.ucas.ac.cn>
19
Signed-off-by: Thomas Huth <thuth@redhat.com>
9
Reviewed-by: Thomas Huth <thuth@redhat.com>
20
Message-id: 20190823133552.11680-1-thuth@redhat.com
10
Message-id: 1519533358-13759-3-git-send-email-suhang16@mails.ucas.ac.cn
21
Signed-off-by: Max Reitz <mreitz@redhat.com>
11
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
12
---
22
---
13
util/uri.c | 160 ++++++++++++++++++++++++++++++-------------------------------
23
tests/qemu-iotests/071 | 1 +
14
1 file changed, 80 insertions(+), 80 deletions(-)
24
tests/qemu-iotests/081 | 4 +---
25
tests/qemu-iotests/099 | 1 +
26
tests/qemu-iotests/120 | 1 +
27
tests/qemu-iotests/162 | 4 +---
28
tests/qemu-iotests/184 | 1 +
29
tests/qemu-iotests/186 | 1 +
30
tests/qemu-iotests/common.rc | 14 ++++++++++++++
31
8 files changed, 21 insertions(+), 6 deletions(-)
15
32
16
diff --git a/util/uri.c b/util/uri.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
17
index XXXXXXX..XXXXXXX 100644
131
index XXXXXXX..XXXXXXX 100644
18
--- a/util/uri.c
132
--- a/tests/qemu-iotests/common.rc
19
+++ b/util/uri.c
133
+++ b/tests/qemu-iotests/common.rc
20
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_scheme(URI *uri, const char **str)
134
@@ -XXX,XX +XXX,XX @@ _require_command()
21
const char *cur;
135
[ -x "$c" ] || _notrun "$1 utility required, skipped this test"
22
23
if (str == NULL)
24
- return (-1);
25
+ return -1;
26
27
cur = *str;
28
if (!ISA_ALPHA(cur))
29
- return (2);
30
+ return 2;
31
cur++;
32
while (ISA_ALPHA(cur) || ISA_DIGIT(cur) || (*cur == '+') || (*cur == '-') ||
33
(*cur == '.'))
34
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_scheme(URI *uri, const char **str)
35
uri->scheme = g_strndup(*str, cur - *str);
36
}
37
*str = cur;
38
- return (0);
39
+ return 0;
40
}
136
}
41
137
42
/**
138
+# Check that a set of drivers has been whitelisted in the QEMU binary
43
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_fragment(URI *uri, const char **str)
139
+#
44
const char *cur;
140
+_require_drivers()
45
141
+{
46
if (str == NULL)
142
+ available=$($QEMU -drive format=help | \
47
- return (-1);
143
+ sed -e '/Supported formats:/!d' -e 's/Supported formats://')
48
+ return -1;
144
+ for driver
49
145
+ do
50
cur = *str;
146
+ if ! echo "$available" | grep -q " $driver\( \|$\)"; then
51
147
+ _notrun "$driver not available"
52
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_fragment(URI *uri, const char **str)
148
+ fi
53
uri->fragment = uri_string_unescape(*str, cur - *str, NULL);
149
+ done
54
}
150
+}
55
*str = cur;
151
+
56
- return (0);
152
# make sure this script returns success
57
+ return 0;
153
true
58
}
59
60
/**
61
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_query(URI *uri, const char **str)
62
const char *cur;
63
64
if (str == NULL)
65
- return (-1);
66
+ return -1;
67
68
cur = *str;
69
70
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_query(URI *uri, const char **str)
71
uri->query = g_strndup(*str, cur - *str);
72
}
73
*str = cur;
74
- return (0);
75
+ return 0;
76
}
77
78
/**
79
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_user_info(URI *uri, const char **str)
80
uri->user = uri_string_unescape(*str, cur - *str, NULL);
81
}
82
*str = cur;
83
- return (0);
84
+ return 0;
85
}
86
- return (1);
87
+ return 1;
88
}
89
90
/**
91
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_dec_octet(const char **str)
92
const char *cur = *str;
93
94
if (!(ISA_DIGIT(cur)))
95
- return (1);
96
+ return 1;
97
if (!ISA_DIGIT(cur + 1))
98
cur++;
99
else if ((*cur != '0') && (ISA_DIGIT(cur + 1)) && (!ISA_DIGIT(cur + 2)))
100
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_dec_octet(const char **str)
101
(*(cur + 1) <= '5'))
102
cur += 3;
103
else
104
- return (1);
105
+ return 1;
106
*str = cur;
107
- return (0);
108
+ return 0;
109
}
110
/**
111
* rfc3986_parse_host:
112
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_host(URI *uri, const char **str)
113
while ((*cur != ']') && (*cur != 0))
114
cur++;
115
if (*cur != ']')
116
- return (1);
117
+ return 1;
118
cur++;
119
goto found;
120
}
121
@@ -XXX,XX +XXX,XX @@ found:
122
uri->server = NULL;
123
}
124
*str = cur;
125
- return (0);
126
+ return 0;
127
}
128
129
/**
130
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_authority(URI *uri, const char **str)
131
cur++;
132
ret = rfc3986_parse_host(uri, &cur);
133
if (ret != 0)
134
- return (ret);
135
+ return ret;
136
if (*cur == ':') {
137
cur++;
138
ret = rfc3986_parse_port(uri, &cur);
139
if (ret != 0)
140
- return (ret);
141
+ return ret;
142
}
143
*str = cur;
144
- return (0);
145
+ return 0;
146
}
147
148
/**
149
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_segment(const char **str, char forbid, int empty)
150
cur = *str;
151
if (!ISA_PCHAR(cur)) {
152
if (empty)
153
- return (0);
154
- return (1);
155
+ return 0;
156
+ return 1;
157
}
158
while (ISA_PCHAR(cur) && (*cur != forbid))
159
NEXT(cur);
160
*str = cur;
161
- return (0);
162
+ return 0;
163
}
164
165
/**
166
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_path_ab_empty(URI *uri, const char **str)
167
cur++;
168
ret = rfc3986_parse_segment(&cur, 0, 1);
169
if (ret != 0)
170
- return (ret);
171
+ return ret;
172
}
173
if (uri != NULL) {
174
g_free(uri->path);
175
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_path_ab_empty(URI *uri, const char **str)
176
}
177
}
178
*str = cur;
179
- return (0);
180
+ return 0;
181
}
182
183
/**
184
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_path_absolute(URI *uri, const char **str)
185
cur = *str;
186
187
if (*cur != '/')
188
- return (1);
189
+ return 1;
190
cur++;
191
ret = rfc3986_parse_segment(&cur, 0, 0);
192
if (ret == 0) {
193
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_path_absolute(URI *uri, const char **str)
194
cur++;
195
ret = rfc3986_parse_segment(&cur, 0, 1);
196
if (ret != 0)
197
- return (ret);
198
+ return ret;
199
}
200
}
201
if (uri != NULL) {
202
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_path_absolute(URI *uri, const char **str)
203
}
204
}
205
*str = cur;
206
- return (0);
207
+ return 0;
208
}
209
210
/**
211
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_path_rootless(URI *uri, const char **str)
212
213
ret = rfc3986_parse_segment(&cur, 0, 0);
214
if (ret != 0)
215
- return (ret);
216
+ return ret;
217
while (*cur == '/') {
218
cur++;
219
ret = rfc3986_parse_segment(&cur, 0, 1);
220
if (ret != 0)
221
- return (ret);
222
+ return ret;
223
}
224
if (uri != NULL) {
225
g_free(uri->path);
226
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_path_rootless(URI *uri, const char **str)
227
}
228
}
229
*str = cur;
230
- return (0);
231
+ return 0;
232
}
233
234
/**
235
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_path_no_scheme(URI *uri, const char **str)
236
237
ret = rfc3986_parse_segment(&cur, ':', 0);
238
if (ret != 0)
239
- return (ret);
240
+ return ret;
241
while (*cur == '/') {
242
cur++;
243
ret = rfc3986_parse_segment(&cur, 0, 1);
244
if (ret != 0)
245
- return (ret);
246
+ return ret;
247
}
248
if (uri != NULL) {
249
g_free(uri->path);
250
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_path_no_scheme(URI *uri, const char **str)
251
}
252
}
253
*str = cur;
254
- return (0);
255
+ return 0;
256
}
257
258
/**
259
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_hier_part(URI *uri, const char **str)
260
cur += 2;
261
ret = rfc3986_parse_authority(uri, &cur);
262
if (ret != 0)
263
- return (ret);
264
+ return ret;
265
ret = rfc3986_parse_path_ab_empty(uri, &cur);
266
if (ret != 0)
267
- return (ret);
268
+ return ret;
269
*str = cur;
270
- return (0);
271
+ return 0;
272
} else if (*cur == '/') {
273
ret = rfc3986_parse_path_absolute(uri, &cur);
274
if (ret != 0)
275
- return (ret);
276
+ return ret;
277
} else if (ISA_PCHAR(cur)) {
278
ret = rfc3986_parse_path_rootless(uri, &cur);
279
if (ret != 0)
280
- return (ret);
281
+ return ret;
282
} else {
283
/* path-empty is effectively empty */
284
if (uri != NULL) {
285
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_hier_part(URI *uri, const char **str)
286
}
287
}
288
*str = cur;
289
- return (0);
290
+ return 0;
291
}
292
293
/**
294
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_relative_ref(URI *uri, const char *str)
295
str += 2;
296
ret = rfc3986_parse_authority(uri, &str);
297
if (ret != 0)
298
- return (ret);
299
+ return ret;
300
ret = rfc3986_parse_path_ab_empty(uri, &str);
301
if (ret != 0)
302
- return (ret);
303
+ return ret;
304
} else if (*str == '/') {
305
ret = rfc3986_parse_path_absolute(uri, &str);
306
if (ret != 0)
307
- return (ret);
308
+ return ret;
309
} else if (ISA_PCHAR(str)) {
310
ret = rfc3986_parse_path_no_scheme(uri, &str);
311
if (ret != 0)
312
- return (ret);
313
+ return ret;
314
} else {
315
/* path-empty is effectively empty */
316
if (uri != NULL) {
317
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_relative_ref(URI *uri, const char *str)
318
str++;
319
ret = rfc3986_parse_query(uri, &str);
320
if (ret != 0)
321
- return (ret);
322
+ return ret;
323
}
324
if (*str == '#') {
325
str++;
326
ret = rfc3986_parse_fragment(uri, &str);
327
if (ret != 0)
328
- return (ret);
329
+ return ret;
330
}
331
if (*str != 0) {
332
uri_clean(uri);
333
- return (1);
334
+ return 1;
335
}
336
- return (0);
337
+ return 0;
338
}
339
340
/**
341
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse(URI *uri, const char *str)
342
343
ret = rfc3986_parse_scheme(uri, &str);
344
if (ret != 0)
345
- return (ret);
346
+ return ret;
347
if (*str != ':') {
348
- return (1);
349
+ return 1;
350
}
351
str++;
352
ret = rfc3986_parse_hier_part(uri, &str);
353
if (ret != 0)
354
- return (ret);
355
+ return ret;
356
if (*str == '?') {
357
str++;
358
ret = rfc3986_parse_query(uri, &str);
359
if (ret != 0)
360
- return (ret);
361
+ return ret;
362
}
363
if (*str == '#') {
364
str++;
365
ret = rfc3986_parse_fragment(uri, &str);
366
if (ret != 0)
367
- return (ret);
368
+ return ret;
369
}
370
if (*str != 0) {
371
uri_clean(uri);
372
- return (1);
373
+ return 1;
374
}
375
- return (0);
376
+ return 0;
377
}
378
379
/**
380
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_uri_reference(URI *uri, const char *str)
381
int ret;
382
383
if (str == NULL)
384
- return (-1);
385
+ return -1;
386
uri_clean(uri);
387
388
/*
389
@@ -XXX,XX +XXX,XX @@ static int rfc3986_parse_uri_reference(URI *uri, const char *str)
390
ret = rfc3986_parse_relative_ref(uri, str);
391
if (ret != 0) {
392
uri_clean(uri);
393
- return (ret);
394
+ return ret;
395
}
396
}
397
- return (0);
398
+ return 0;
399
}
400
401
/**
402
@@ -XXX,XX +XXX,XX @@ URI *uri_parse(const char *str)
403
int ret;
404
405
if (str == NULL)
406
- return (NULL);
407
+ return NULL;
408
uri = uri_new();
409
ret = rfc3986_parse_uri_reference(uri, str);
410
if (ret) {
411
uri_free(uri);
412
- return (NULL);
413
+ return NULL;
414
}
415
- return (uri);
416
+ return uri;
417
}
418
419
/**
420
@@ -XXX,XX +XXX,XX @@ URI *uri_parse(const char *str)
421
*/
422
int uri_parse_into(URI *uri, const char *str)
423
{
424
- return (rfc3986_parse_uri_reference(uri, str));
425
+ return rfc3986_parse_uri_reference(uri, str);
426
}
427
428
/**
429
@@ -XXX,XX +XXX,XX @@ URI *uri_parse_raw(const char *str, int raw)
430
int ret;
431
432
if (str == NULL)
433
- return (NULL);
434
+ return NULL;
435
uri = uri_new();
436
if (raw) {
437
uri->cleanup |= 2;
438
@@ -XXX,XX +XXX,XX @@ URI *uri_parse_raw(const char *str, int raw)
439
ret = uri_parse_into(uri, str);
440
if (ret) {
441
uri_free(uri);
442
- return (NULL);
443
+ return NULL;
444
}
445
- return (uri);
446
+ return uri;
447
}
448
449
/************************************************************************
450
@@ -XXX,XX +XXX,XX @@ URI *uri_new(void)
451
URI *ret;
452
453
ret = g_new0(URI, 1);
454
- return (ret);
455
+ return ret;
456
}
457
458
/**
459
@@ -XXX,XX +XXX,XX @@ static char *realloc2n(char *ret, int *max)
460
tmp = *max * 2;
461
temp = g_realloc(ret, (tmp + 1));
462
*max = tmp;
463
- return (temp);
464
+ return temp;
465
}
466
467
/**
468
@@ -XXX,XX +XXX,XX @@ char *uri_to_string(URI *uri)
469
int max;
470
471
if (uri == NULL)
472
- return (NULL);
473
+ return NULL;
474
475
max = 80;
476
ret = g_malloc(max + 1);
477
@@ -XXX,XX +XXX,XX @@ char *uri_to_string(URI *uri)
478
ret = temp;
479
}
480
ret[len] = 0;
481
- return (ret);
482
+ return ret;
483
}
484
485
/**
486
@@ -XXX,XX +XXX,XX @@ static int normalize_uri_path(char *path)
487
char *cur, *out;
488
489
if (path == NULL)
490
- return (-1);
491
+ return -1;
492
493
/* Skip all initial "/" chars. We want to get to the beginning of the
494
* first non-empty segment.
495
@@ -XXX,XX +XXX,XX @@ static int normalize_uri_path(char *path)
496
while (cur[0] == '/')
497
++cur;
498
if (cur[0] == '\0')
499
- return (0);
500
+ return 0;
501
502
/* Keep everything we've seen so far. */
503
out = cur;
504
@@ -XXX,XX +XXX,XX @@ done_cd:
505
while (cur[0] == '/')
506
++cur;
507
if (cur[0] == '\0')
508
- return (0);
509
+ return 0;
510
511
/*
512
* Analyze each segment in sequence for cases (e) and (f).
513
@@ -XXX,XX +XXX,XX @@ done_cd:
514
}
515
}
516
517
- return (0);
518
+ return 0;
519
}
520
521
static int is_hex(char c)
522
{
523
if (((c >= '0') && (c <= '9')) || ((c >= 'a') && (c <= 'f')) ||
524
((c >= 'A') && (c <= 'F')))
525
- return (1);
526
- return (0);
527
+ return 1;
528
+ return 0;
529
}
530
531
/**
532
@@ -XXX,XX +XXX,XX @@ char *uri_string_unescape(const char *str, int len, char *target)
533
const char *in;
534
535
if (str == NULL)
536
- return (NULL);
537
+ return NULL;
538
if (len <= 0)
539
len = strlen(str);
540
if (len < 0)
541
- return (NULL);
542
+ return NULL;
543
544
if (target == NULL) {
545
ret = g_malloc(len + 1);
546
@@ -XXX,XX +XXX,XX @@ char *uri_string_unescape(const char *str, int len, char *target)
547
}
548
}
549
*out = 0;
550
- return (ret);
551
+ return ret;
552
}
553
554
/**
555
@@ -XXX,XX +XXX,XX @@ char *uri_string_escape(const char *str, const char *list)
556
int len, out;
557
558
if (str == NULL)
559
- return (NULL);
560
+ return NULL;
561
if (str[0] == 0)
562
- return (g_strdup(str));
563
+ return g_strdup(str);
564
len = strlen(str);
565
if (!(len > 0))
566
- return (NULL);
567
+ return NULL;
568
569
len += 20;
570
ret = g_malloc(len);
571
@@ -XXX,XX +XXX,XX @@ char *uri_string_escape(const char *str, const char *list)
572
}
573
}
574
ret[out] = 0;
575
- return (ret);
576
+ return ret;
577
}
578
579
/************************************************************************
580
@@ -XXX,XX +XXX,XX @@ done:
581
uri_free(bas);
582
if (res != NULL)
583
uri_free(res);
584
- return (val);
585
+ return val;
586
}
587
588
/**
589
--
154
--
590
2.14.3
155
2.21.0
591
156
592
157
diff view generated by jsdifflib
1
From: Thomas Huth <thuth@redhat.com>
1
From: Thomas Huth <thuth@redhat.com>
2
2
3
dev could be NULL if the PCI device can not be found due to some
3
The sanitizers (especially the address sanitizer from Clang) are
4
reasons, so we must not dereference the pointer in this case.
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
Signed-off-by: Thomas Huth <thuth@redhat.com>
9
Signed-off-by: Thomas Huth <thuth@redhat.com>
7
Message-id: 1519713884-2346-1-git-send-email-thuth@redhat.com
10
Message-id: 20190823084203.29734-1-thuth@redhat.com
8
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11
Signed-off-by: Max Reitz <mreitz@redhat.com>
9
---
12
---
10
tests/libqos/virtio-pci.c | 4 +++-
13
tests/check-block.sh | 5 +++++
11
1 file changed, 3 insertions(+), 1 deletion(-)
14
1 file changed, 5 insertions(+)
12
15
13
diff --git a/tests/libqos/virtio-pci.c b/tests/libqos/virtio-pci.c
16
diff --git a/tests/check-block.sh b/tests/check-block.sh
14
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100755
15
--- a/tests/libqos/virtio-pci.c
18
--- a/tests/check-block.sh
16
+++ b/tests/libqos/virtio-pci.c
19
+++ b/tests/check-block.sh
17
@@ -XXX,XX +XXX,XX @@ QVirtioPCIDevice *qvirtio_pci_device_find(QPCIBus *bus, uint16_t device_type)
20
@@ -XXX,XX +XXX,XX @@ if grep -q "TARGET_GPROF=y" *-softmmu/config-target.mak 2>/dev/null ; then
18
qvirtio_pci_foreach(bus, device_type, false, 0,
21
exit 0
19
qvirtio_pci_assign_device, &dev);
22
fi
20
23
21
- dev->vdev.bus = &qvirtio_pci;
24
+if grep -q "CFLAGS.*-fsanitize" config-host.mak 2>/dev/null ; then
22
+ if (dev) {
25
+ echo "Sanitizers are enabled ==> Not running the qemu-iotests."
23
+ dev->vdev.bus = &qvirtio_pci;
26
+ exit 0
24
+ }
27
+fi
25
28
+
26
return dev;
29
if [ -z "$(find . -name 'qemu-system-*' -print)" ]; then
27
}
30
echo "No qemu-system binary available ==> Not running the qemu-iotests."
31
exit 0
28
--
32
--
29
2.14.3
33
2.21.0
30
34
31
35
diff view generated by jsdifflib
1
From: Fam Zheng <famz@redhat.com>
1
From: Nir Soffer <nirsof@gmail.com>
2
2
3
Signed-off-by: Fam Zheng <famz@redhat.com>
3
Quoting cache mode is not needed, and most tests use unquoted values.
4
Message-id: 20180226030326.20219-3-famz@redhat.com
4
Unify all test to use the same style.
5
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
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>
6
---
9
---
7
README | 31 ++++++++++++++++++++++++++++++-
10
tests/qemu-iotests/026 | 4 ++--
8
1 file changed, 30 insertions(+), 1 deletion(-)
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(-)
9
15
10
diff --git a/README b/README
16
diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026
11
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100755
12
--- a/README
18
--- a/tests/qemu-iotests/026
13
+++ b/README
19
+++ b/tests/qemu-iotests/026
14
@@ -XXX,XX +XXX,XX @@ The QEMU source code is maintained under the GIT version control system.
20
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
15
21
# Currently only qcow2 supports rebasing
16
git clone git://git.qemu.org/qemu.git
22
_supported_fmt qcow2
17
23
_supported_proto file
18
-When submitting patches, the preferred approach is to use 'git
24
-_default_cache_mode "writethrough"
19
+When submitting patches, one common approach is to use 'git
25
-_supported_cache_modes "writethrough" "none"
20
format-patch' and/or 'git send-email' to format & send the mail to the
26
+_default_cache_mode writethrough
21
qemu-devel@nongnu.org mailing list. All patches submitted must contain
27
+_supported_cache_modes writethrough none
22
a 'Signed-off-by' line from the author. Patches should follow the
28
# The refcount table tests expect a certain minimum width for refcount entries
23
@@ -XXX,XX +XXX,XX @@ The QEMU website is also maintained under source control.
29
# (so that the refcount table actually needs to grow); that minimum is 16 bits,
24
git clone git://git.qemu.org/qemu-web.git
30
# being the default refcount entry width.
25
https://www.qemu.org/2017/02/04/the-new-qemu-website-is-up/
31
diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039
26
32
index XXXXXXX..XXXXXXX 100755
27
+A 'git-profile' utility was created to make above process less
33
--- a/tests/qemu-iotests/039
28
+cumbersome, and is highly recommended for making regular contributions,
34
+++ b/tests/qemu-iotests/039
29
+or even just for sending consecutive patch series revisions. It also
35
@@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15
30
+requires a working 'git send-email' setup, and by default doesn't
36
_supported_fmt qcow2
31
+automate everything, so you may want to go through the above steps
37
_supported_proto file
32
+manually for once.
38
_supported_os Linux
33
+
39
-_default_cache_mode "writethrough"
34
+For installation instructions, please go to
40
-_supported_cache_modes "writethrough"
35
+
41
+_default_cache_mode writethrough
36
+ https://github.com/stefanha/git-publish
42
+_supported_cache_modes writethrough
37
+
43
38
+The workflow with 'git-publish' is:
44
size=128M
39
+
45
40
+ $ git checkout master -b my-feature
46
diff --git a/tests/qemu-iotests/052 b/tests/qemu-iotests/052
41
+ $ # work on new commits, add your 'Signed-off-by' lines to each
47
index XXXXXXX..XXXXXXX 100755
42
+ $ git publish
48
--- a/tests/qemu-iotests/052
43
+
49
+++ b/tests/qemu-iotests/052
44
+Your patch series will be sent and tagged as my-feature-v1 if you need to refer
50
@@ -XXX,XX +XXX,XX @@ _supported_fmt generic
45
+back to it in the future.
51
_supported_proto file
46
+
52
47
+Sending v2:
53
# Don't do O_DIRECT on tmpfs
48
+
54
-_supported_cache_modes "writeback" "writethrough" "unsafe"
49
+ $ git checkout my-feature # same topic branch
55
+_supported_cache_modes writeback writethrough unsafe
50
+ $ # making changes to the commits (using 'git rebase', for example)
56
51
+ $ git publish
57
size=128M
52
+
58
_make_test_img $size
53
+Your patch series will be sent with 'v2' tag in the subject and the git tip
59
diff --git a/tests/qemu-iotests/091 b/tests/qemu-iotests/091
54
+will be tagged as my-feature-v2.
60
index XXXXXXX..XXXXXXX 100755
55
+
61
--- a/tests/qemu-iotests/091
56
Bug reporting
62
+++ b/tests/qemu-iotests/091
57
=============
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
58
73
59
--
74
--
60
2.14.3
75
2.21.0
61
76
62
77
diff view generated by jsdifflib