1 | The following changes since commit b4fbe1f65a4769c09e6bf2d79fc84360f840f40e: | 1 | The following changes since commit 23919ddfd56135cad3cb468a8f54d5a595f024f4: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20190129' into staging (2019-01-29 12:00:19 +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 | https://git.xanclic.moe/XanClic/qemu.git tags/pull-block-2019-01-31 | 7 | https://github.com/XanClic/qemu.git tags/pull-block-2019-08-27 |
8 | 8 | ||
9 | for you to fetch changes up to 908b30164bbffad7430d551b2a03a8fbcaa631ef: | 9 | for you to fetch changes up to bb043c056cffcc2f3ce88bfdaf2e76e455c09e2c: |
10 | 10 | ||
11 | iotests: Allow 147 to be run concurrently (2019-01-31 00:44:55 +0100) | 11 | iotests: Unify cache mode quoting (2019-08-27 19:48:44 +0200) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Block patches: | 14 | Block patches: |
15 | - New debugging QMP command to explore block graphs | 15 | - qemu-io now accepts a file to read a write pattern from |
16 | - Converted DPRINTF()s to trace events | 16 | - Ensure that raw files have their first block allocated so we can probe |
17 | - Fixed qemu-io's use of getopt() for systems with optreset | 17 | the O_DIRECT alignment if necessary |
18 | - Minor NVMe emulation fixes | 18 | - Various fixes |
19 | - An iotest fix | ||
20 | 19 | ||
21 | ---------------------------------------------------------------- | 20 | ---------------------------------------------------------------- |
22 | Laurent Vivier (4): | 21 | Denis Plotnikov (1): |
23 | block/ssh: Convert from DPRINTF() macro to trace events | 22 | qemu-io: add pattern file for write command |
24 | block/curl: Convert from DPRINTF() macro to trace events | ||
25 | block/file-posix: Convert from DPRINTF() macro to trace events | ||
26 | block/sheepdog: Convert from DPRINTF() macro to trace events | ||
27 | 23 | ||
28 | Li Qiang (3): | 24 | Max Reitz (7): |
29 | nvme: use TYPE_NVME instead of constant string | 25 | iotests: Fix _filter_img_create() |
30 | nvme: ensure the num_queues is not zero | 26 | vmdk: Use bdrv_dirname() for relative extent paths |
31 | nvme: use pci_dev directly in nvme_realize | 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 | ||
32 | 32 | ||
33 | Max Reitz (3): | 33 | Nir Soffer (3): |
34 | iotests.py: Add qemu_nbd_pipe() | 34 | block: posix: Always allocate the first block |
35 | iotests: Bind qemu-nbd to localhost in 147 | 35 | iotests: Test allocate_first_block() with O_DIRECT |
36 | iotests: Allow 147 to be run concurrently | 36 | iotests: Unify cache mode quoting |
37 | 37 | ||
38 | Richard W.M. Jones (1): | 38 | Stefan Hajnoczi (1): |
39 | qemu-io: Add generic function for reinitializing optind. | 39 | file-posix: fix request_alignment typo |
40 | 40 | ||
41 | Vladimir Sementsov-Ogievskiy (2): | 41 | Thomas Huth (2): |
42 | qapi: add x-debug-query-block-graph | 42 | iotests: Check for enabled drivers before testing them |
43 | scripts: add render_block_graph function for QEMUMachine | 43 | tests/check-block: Skip iotests when sanitizers are enabled |
44 | 44 | ||
45 | configure | 14 ++++ | 45 | Vladimir Sementsov-Ogievskiy (1): |
46 | qapi/block-core.json | 108 ++++++++++++++++++++++++ | 46 | block: fix permission update in bdrv_replace_node |
47 | include/block/block.h | 1 + | 47 | |
48 | include/qemu/osdep.h | 16 ++++ | 48 | block.c | 5 +- |
49 | include/sysemu/block-backend.h | 2 + | 49 | block/file-posix.c | 53 +++++++++- |
50 | block.c | 148 +++++++++++++++++++++++++++++++++ | 50 | block/vmdk.c | 64 ++++++++---- |
51 | block/block-backend.c | 5 ++ | 51 | qemu-io-cmds.c | 99 +++++++++++++++++-- |
52 | block/curl.c | 29 ++----- | 52 | tests/check-block.sh | 5 + |
53 | block/file-posix.c | 25 ++---- | 53 | tests/qemu-iotests/002 | 1 + |
54 | block/sheepdog.c | 47 ++++------- | 54 | tests/qemu-iotests/003 | 1 + |
55 | block/ssh.c | 46 ++++------ | 55 | tests/qemu-iotests/005 | 3 +- |
56 | blockdev.c | 5 ++ | 56 | tests/qemu-iotests/009 | 1 + |
57 | hw/block/nvme.c | 15 ++-- | 57 | tests/qemu-iotests/010 | 1 + |
58 | qemu-img.c | 2 +- | 58 | tests/qemu-iotests/011 | 1 + |
59 | qemu-io-cmds.c | 2 +- | 59 | tests/qemu-iotests/017 | 3 +- |
60 | block/trace-events | 47 +++++++++++ | 60 | tests/qemu-iotests/018 | 3 +- |
61 | scripts/render_block_graph.py | 120 ++++++++++++++++++++++++++ | 61 | tests/qemu-iotests/019 | 3 +- |
62 | tests/qemu-iotests/147 | 98 +++++++++++++++------- | 62 | tests/qemu-iotests/020 | 3 +- |
63 | tests/qemu-iotests/iotests.py | 14 ++++ | 63 | tests/qemu-iotests/026 | 4 +- |
64 | 19 files changed, 608 insertions(+), 136 deletions(-) | 64 | tests/qemu-iotests/027 | 1 + |
65 | create mode 100755 scripts/render_block_graph.py | 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 | ||
66 | 101 | ||
67 | -- | 102 | -- |
68 | 2.20.1 | 103 | 2.21.0 |
69 | 104 | ||
70 | 105 | diff view generated by jsdifflib |
1 | From: Laurent Vivier <lvivier@redhat.com> | 1 | From: Denis Plotnikov <dplotnikov@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Laurent Vivier <lvivier@redhat.com> | 3 | The patch allows to provide a pattern file for write |
4 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 4 | command. There was no similar ability before. |
5 | Message-id: 20181213162727.17438-5-lvivier@redhat.com | 5 | |
6 | [mreitz: Fixed sheepdog_snapshot_create_inode's format string to use | 6 | Signed-off-by: Denis Plotnikov <dplotnikov@virtuozzo.com> |
7 | PRIx32 for uint32_ts] | 7 | Message-id: 20190820164616.4072-1-dplotnikov@virtuozzo.com |
8 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
9 | [mreitz: Keep optstring in alphabetical order] | ||
8 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 10 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
9 | --- | 11 | --- |
10 | block/sheepdog.c | 47 +++++++++++++++++----------------------------- | 12 | qemu-io-cmds.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++--- |
11 | block/trace-events | 14 ++++++++++++++ | 13 | 1 file changed, 93 insertions(+), 6 deletions(-) |
12 | 2 files changed, 31 insertions(+), 30 deletions(-) | ||
13 | 14 | ||
14 | diff --git a/block/sheepdog.c b/block/sheepdog.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/block/sheepdog.c | 17 | --- a/qemu-io-cmds.c |
17 | +++ b/block/sheepdog.c | 18 | +++ b/qemu-io-cmds.c |
18 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ static void qemu_io_free(void *p) |
19 | #include "sysemu/block-backend.h" | 20 | qemu_vfree(p); |
20 | #include "qemu/bitops.h" | ||
21 | #include "qemu/cutils.h" | ||
22 | +#include "trace.h" | ||
23 | |||
24 | #define SD_PROTO_VER 0x01 | ||
25 | |||
26 | @@ -XXX,XX +XXX,XX @@ static inline size_t count_data_objs(const struct SheepdogInode *inode) | ||
27 | (1UL << inode->block_size_shift)); | ||
28 | } | 21 | } |
29 | 22 | ||
30 | -#undef DPRINTF | 23 | +/* |
31 | -#ifdef DEBUG_SDOG | 24 | + * qemu_io_alloc_from_file() |
32 | -#define DEBUG_SDOG_PRINT 1 | 25 | + * |
33 | -#else | 26 | + * Allocates the buffer and populates it with the content of the given file |
34 | -#define DEBUG_SDOG_PRINT 0 | 27 | + * up to @len bytes. If the file length is less than @len, then the buffer |
35 | -#endif | 28 | + * is populated with the file content cyclically. |
36 | -#define DPRINTF(fmt, args...) \ | 29 | + * |
37 | - do { \ | 30 | + * @blk - the block backend where the buffer content is going to be written to |
38 | - if (DEBUG_SDOG_PRINT) { \ | 31 | + * @len - the buffer length |
39 | - fprintf(stderr, "%s %d: " fmt, __func__, __LINE__, ##args); \ | 32 | + * @file_name - the file to read the content from |
40 | - } \ | 33 | + * |
41 | - } while (0) | 34 | + * Returns: the buffer pointer on success |
42 | - | 35 | + * NULL on error |
43 | typedef struct SheepdogAIOCB SheepdogAIOCB; | 36 | + */ |
44 | typedef struct BDRVSheepdogState BDRVSheepdogState; | 37 | +static void *qemu_io_alloc_from_file(BlockBackend *blk, size_t len, |
45 | 38 | + const char *file_name) | |
46 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn void reconnect_to_sdog(void *opaque) | 39 | +{ |
47 | Error *local_err = NULL; | 40 | + char *buf, *buf_origin; |
48 | s->fd = get_sheep_fd(s, &local_err); | 41 | + FILE *f = fopen(file_name, "r"); |
49 | if (s->fd < 0) { | 42 | + int pattern_len; |
50 | - DPRINTF("Wait for connection to be established\n"); | 43 | + |
51 | + trace_sheepdog_reconnect_to_sdog(); | 44 | + if (!f) { |
52 | error_report_err(local_err); | 45 | + perror(file_name); |
53 | qemu_co_sleep_ns(QEMU_CLOCK_REALTIME, 1000000000ULL); | 46 | + return NULL; |
54 | } | 47 | + } |
55 | @@ -XXX,XX +XXX,XX @@ static void coroutine_fn aio_read_response(void *opaque) | 48 | + |
56 | break; | 49 | + if (qemuio_misalign) { |
57 | case AIOCB_FLUSH_CACHE: | 50 | + len += MISALIGN_OFFSET; |
58 | if (rsp.result == SD_RES_INVALID_PARMS) { | 51 | + } |
59 | - DPRINTF("disable cache since the server doesn't support it\n"); | 52 | + |
60 | + trace_sheepdog_aio_read_response(); | 53 | + buf_origin = buf = blk_blockalign(blk, len); |
61 | s->cache_flags = SD_FLAG_CMD_DIRECT; | 54 | + |
62 | rsp.result = SD_RES_SUCCESS; | 55 | + if (qemuio_misalign) { |
63 | } | 56 | + buf_origin += MISALIGN_OFFSET; |
64 | @@ -XXX,XX +XXX,XX @@ static int sd_open(BlockDriverState *bs, QDict *options, int flags, | 57 | + buf += MISALIGN_OFFSET; |
65 | s->discard_supported = true; | 58 | + len -= MISALIGN_OFFSET; |
66 | 59 | + } | |
67 | if (snap_id || tag[0]) { | 60 | + |
68 | - DPRINTF("%" PRIx32 " snapshot inode was open.\n", vid); | 61 | + pattern_len = fread(buf_origin, 1, len, f); |
69 | + trace_sheepdog_open(vid); | 62 | + |
70 | s->is_snapshot = true; | 63 | + if (ferror(f)) { |
71 | } | 64 | + perror(file_name); |
72 | 65 | + goto error; | |
73 | @@ -XXX,XX +XXX,XX @@ static void sd_close(BlockDriverState *bs) | 66 | + } |
74 | unsigned int wlen, rlen = 0; | 67 | + |
75 | int fd, ret; | 68 | + if (pattern_len == 0) { |
76 | 69 | + fprintf(stderr, "%s: file is empty\n", file_name); | |
77 | - DPRINTF("%s\n", s->name); | 70 | + goto error; |
78 | + trace_sheepdog_close(s->name); | 71 | + } |
79 | 72 | + | |
80 | fd = connect_to_sdog(s, &local_err); | 73 | + fclose(f); |
81 | if (fd < 0) { | 74 | + |
82 | @@ -XXX,XX +XXX,XX @@ static int sd_create_branch(BDRVSheepdogState *s) | 75 | + if (len > pattern_len) { |
83 | char *buf; | 76 | + len -= pattern_len; |
84 | bool deleted; | 77 | + buf += pattern_len; |
85 | 78 | + | |
86 | - DPRINTF("%" PRIx32 " is snapshot.\n", s->inode.vdi_id); | 79 | + while (len > 0) { |
87 | + trace_sheepdog_create_branch_snapshot(s->inode.vdi_id); | 80 | + size_t len_to_copy = MIN(pattern_len, len); |
88 | 81 | + | |
89 | buf = g_malloc(SD_INODE_SIZE); | 82 | + memcpy(buf, buf_origin, len_to_copy); |
90 | 83 | + | |
91 | @@ -XXX,XX +XXX,XX @@ static int sd_create_branch(BDRVSheepdogState *s) | 84 | + len -= len_to_copy; |
92 | goto out; | 85 | + buf += len_to_copy; |
93 | } | 86 | + } |
94 | 87 | + } | |
95 | - DPRINTF("%" PRIx32 " is created.\n", vid); | 88 | + |
96 | + trace_sheepdog_create_branch_created(vid); | 89 | + return buf_origin; |
97 | 90 | + | |
98 | fd = connect_to_sdog(s, &local_err); | 91 | +error: |
99 | if (fd < 0) { | 92 | + qemu_io_free(buf_origin); |
100 | @@ -XXX,XX +XXX,XX @@ static int sd_create_branch(BDRVSheepdogState *s) | 93 | + return NULL; |
101 | 94 | +} | |
102 | s->is_snapshot = false; | 95 | + |
103 | ret = 0; | 96 | static void dump_buffer(const void *buffer, int64_t offset, int64_t len) |
104 | - DPRINTF("%" PRIx32 " was newly created.\n", s->inode.vdi_id); | 97 | { |
105 | + trace_sheepdog_create_branch_new(s->inode.vdi_id); | 98 | uint64_t i; |
106 | 99 | @@ -XXX,XX +XXX,XX @@ static void write_help(void) | |
107 | out: | 100 | " -n, -- with -z, don't allow slow fallback\n" |
108 | g_free(buf); | 101 | " -p, -- ignored for backwards compatibility\n" |
109 | @@ -XXX,XX +XXX,XX @@ static void coroutine_fn sd_co_rw_vector(SheepdogAIOCB *acb) | 102 | " -P, -- use different pattern to fill file\n" |
110 | } | 103 | +" -s, -- use a pattern file to fill the write buffer\n" |
111 | 104 | " -C, -- report statistics in a machine parsable format\n" | |
112 | if (create) { | 105 | " -q, -- quiet mode, do not show I/O statistics\n" |
113 | - DPRINTF("update ino (%" PRIu32 ") %" PRIu64 " %" PRIu64 " %ld\n", | 106 | " -u, -- with -z, allow unmapping\n" |
114 | - inode->vdi_id, oid, | 107 | @@ -XXX,XX +XXX,XX @@ static const cmdinfo_t write_cmd = { |
115 | - vid_to_data_oid(inode->data_vdi_id[idx], idx), idx); | 108 | .perm = BLK_PERM_WRITE, |
116 | + trace_sheepdog_co_rw_vector_update(inode->vdi_id, oid, | 109 | .argmin = 2, |
117 | + vid_to_data_oid(inode->data_vdi_id[idx], idx), | 110 | .argmax = -1, |
118 | + idx); | 111 | - .args = "[-bcCfnquz] [-P pattern] off len", |
119 | oid = vid_to_data_oid(inode->vdi_id, idx); | 112 | + .args = "[-bcCfnquz] [-P pattern | -s source_file] off len", |
120 | - DPRINTF("new oid %" PRIx64 "\n", oid); | 113 | .oneline = "writes a number of bytes at a specified offset", |
121 | + trace_sheepdog_co_rw_vector_new(oid); | 114 | .help = write_help, |
122 | } | 115 | }; |
123 | 116 | @@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv) | |
124 | aio_req = alloc_aio_req(s, acb, oid, len, offset, flags, create, | 117 | { |
125 | @@ -XXX,XX +XXX,XX @@ static int sd_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info) | 118 | struct timespec t1, t2; |
126 | SheepdogInode *inode; | 119 | bool Cflag = false, qflag = false, bflag = false; |
127 | unsigned int datalen; | 120 | - bool Pflag = false, zflag = false, cflag = false; |
128 | 121 | + bool Pflag = false, zflag = false, cflag = false, sflag = false; | |
129 | - DPRINTF("sn_info: name %s id_str %s s: name %s vm_state_size %" PRId64 " " | 122 | int flags = 0; |
130 | - "is_snapshot %d\n", sn_info->name, sn_info->id_str, | 123 | int c, cnt, ret; |
131 | - s->name, sn_info->vm_state_size, s->is_snapshot); | 124 | char *buf = NULL; |
132 | + trace_sheepdog_snapshot_create_info(sn_info->name, sn_info->id_str, s->name, | 125 | @@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv) |
133 | + sn_info->vm_state_size, s->is_snapshot); | 126 | /* Some compilers get confused and warn if this is not initialized. */ |
134 | 127 | int64_t total = 0; | |
135 | if (s->is_snapshot) { | 128 | int pattern = 0xcd; |
136 | error_report("You can't create a snapshot of a snapshot VDI, " | 129 | + const char *file_name = NULL; |
137 | @@ -XXX,XX +XXX,XX @@ static int sd_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info) | 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) | ||
138 | return -EINVAL; | 148 | return -EINVAL; |
139 | } | 149 | } |
140 | 150 | ||
141 | - DPRINTF("%s %s\n", sn_info->name, sn_info->id_str); | 151 | - if (zflag && Pflag) { |
142 | + trace_sheepdog_snapshot_create(sn_info->name, sn_info->id_str); | 152 | - printf("-z and -P cannot be specified at the same time\n"); |
143 | 153 | + if (zflag + Pflag + sflag > 1) { | |
144 | s->inode.vm_state_size = sn_info->vm_state_size; | 154 | + printf("Only one of -z, -P, and -s " |
145 | s->inode.vm_clock_nsec = sn_info->vm_clock_nsec; | 155 | + "can be specified at the same time\n"); |
146 | @@ -XXX,XX +XXX,XX @@ static int sd_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info) | 156 | return -EINVAL; |
147 | } | 157 | } |
148 | 158 | ||
149 | memcpy(&s->inode, inode, datalen); | 159 | @@ -XXX,XX +XXX,XX @@ static int write_f(BlockBackend *blk, int argc, char **argv) |
150 | - DPRINTF("s->inode: name %s snap_id %x oid %x\n", | 160 | } |
151 | - s->inode.name, s->inode.snap_id, s->inode.vdi_id); | 161 | |
152 | + trace_sheepdog_snapshot_create_inode(s->inode.name, s->inode.snap_id, | 162 | if (!zflag) { |
153 | + s->inode.vdi_id); | 163 | - buf = qemu_io_alloc(blk, count, pattern); |
154 | 164 | + if (sflag) { | |
155 | cleanup: | 165 | + buf = qemu_io_alloc_from_file(blk, count, file_name); |
156 | g_free(inode); | 166 | + if (!buf) { |
157 | diff --git a/block/trace-events b/block/trace-events | 167 | + return -EINVAL; |
158 | index XXXXXXX..XXXXXXX 100644 | 168 | + } |
159 | --- a/block/trace-events | 169 | + } else { |
160 | +++ b/block/trace-events | 170 | + buf = qemu_io_alloc(blk, count, pattern); |
161 | @@ -XXX,XX +XXX,XX @@ file_xfs_discard(const char *error) "cannot punch hole (%s)" | 171 | + } |
162 | file_FindEjectableOpticalMedia(const char *media) "Matching using %s" | 172 | } |
163 | file_setup_cdrom(const char *partition) "Using %s as optical disc" | 173 | |
164 | file_hdev_is_sg(int type, int version) "SG device found: type=%d, version=%d" | 174 | clock_gettime(CLOCK_MONOTONIC, &t1); |
165 | + | ||
166 | +# block/sheepdog.c | ||
167 | +sheepdog_reconnect_to_sdog(void) "Wait for connection to be established" | ||
168 | +sheepdog_aio_read_response(void) "disable cache since the server doesn't support it" | ||
169 | +sheepdog_open(uint32_t vid) "0x%" PRIx32 " snapshot inode was open" | ||
170 | +sheepdog_close(const char *name) "%s" | ||
171 | +sheepdog_create_branch_snapshot(uint32_t vdi) "0x%" PRIx32 " is snapshot" | ||
172 | +sheepdog_create_branch_created(uint32_t vdi) "0x%" PRIx32 " is created" | ||
173 | +sheepdog_create_branch_new(uint32_t vdi) "0x%" PRIx32 " was newly created" | ||
174 | +sheepdog_co_rw_vector_update(uint32_t vdi, uint64_t oid, uint64_t data, long idx) "update ino (%" PRIu32 ") %" PRIu64 " %" PRIu64 " %ld" | ||
175 | +sheepdog_co_rw_vector_new(uint64_t oid) "new oid 0x%" PRIx64 | ||
176 | +sheepdog_snapshot_create_info(const char *sn_name, const char *id, const char *name, int64_t size, int is_snapshot) "sn_info: name %s id_str %s s: name %s vm_state_size %" PRId64 " " "is_snapshot %d" | ||
177 | +sheepdog_snapshot_create(const char *sn_name, const char *id) "%s %s" | ||
178 | +sheepdog_snapshot_create_inode(const char *name, uint32_t snap, uint32_t vdi) "s->inode: name %s snap_id 0x%" PRIx32 " vdi 0x%" PRIx32 | ||
179 | -- | 175 | -- |
180 | 2.20.1 | 176 | 2.21.0 |
181 | 177 | ||
182 | 178 | diff view generated by jsdifflib |
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | Add a new command, returning block nodes (and their users) graph. | 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. | ||
4 | 11 | ||
5 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 12 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
6 | Message-id: 20181221170909.25584-2-vsementsov@virtuozzo.com | 13 | Message-id: 20190824100740.61635-1-vsementsov@virtuozzo.com |
7 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 14 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
8 | --- | 15 | --- |
9 | qapi/block-core.json | 108 ++++++++++++++++++++++++ | 16 | block.c | 5 ++--- |
10 | include/block/block.h | 1 + | 17 | 1 file changed, 2 insertions(+), 3 deletions(-) |
11 | include/sysemu/block-backend.h | 2 + | ||
12 | block.c | 148 +++++++++++++++++++++++++++++++++ | ||
13 | block/block-backend.c | 5 ++ | ||
14 | blockdev.c | 5 ++ | ||
15 | 6 files changed, 269 insertions(+) | ||
16 | 18 | ||
17 | diff --git a/qapi/block-core.json b/qapi/block-core.json | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/qapi/block-core.json | ||
20 | +++ b/qapi/block-core.json | ||
21 | @@ -XXX,XX +XXX,XX @@ | ||
22 | ## | ||
23 | { 'command': 'query-named-block-nodes', 'returns': [ 'BlockDeviceInfo' ] } | ||
24 | |||
25 | +## | ||
26 | +# @XDbgBlockGraphNodeType: | ||
27 | +# | ||
28 | +# @block-backend: corresponds to BlockBackend | ||
29 | +# | ||
30 | +# @block-job: corresonds to BlockJob | ||
31 | +# | ||
32 | +# @block-driver: corresponds to BlockDriverState | ||
33 | +# | ||
34 | +# Since: 4.0 | ||
35 | +## | ||
36 | +{ 'enum': 'XDbgBlockGraphNodeType', | ||
37 | + 'data': [ 'block-backend', 'block-job', 'block-driver' ] } | ||
38 | + | ||
39 | +## | ||
40 | +# @XDbgBlockGraphNode: | ||
41 | +# | ||
42 | +# @id: Block graph node identifier. This @id is generated only for | ||
43 | +# x-debug-query-block-graph and does not relate to any other identifiers in | ||
44 | +# Qemu. | ||
45 | +# | ||
46 | +# @type: Type of graph node. Can be one of block-backend, block-job or | ||
47 | +# block-driver-state. | ||
48 | +# | ||
49 | +# @name: Human readable name of the node. Corresponds to node-name for | ||
50 | +# block-driver-state nodes; is not guaranteed to be unique in the whole | ||
51 | +# graph (with block-jobs and block-backends). | ||
52 | +# | ||
53 | +# Since: 4.0 | ||
54 | +## | ||
55 | +{ 'struct': 'XDbgBlockGraphNode', | ||
56 | + 'data': { 'id': 'uint64', 'type': 'XDbgBlockGraphNodeType', 'name': 'str' } } | ||
57 | + | ||
58 | +## | ||
59 | +# @BlockPermission: | ||
60 | +# | ||
61 | +# Enum of base block permissions. | ||
62 | +# | ||
63 | +# @consistent-read: A user that has the "permission" of consistent reads is | ||
64 | +# guaranteed that their view of the contents of the block | ||
65 | +# device is complete and self-consistent, representing the | ||
66 | +# contents of a disk at a specific point. | ||
67 | +# For most block devices (including their backing files) this | ||
68 | +# is true, but the property cannot be maintained in a few | ||
69 | +# situations like for intermediate nodes of a commit block | ||
70 | +# job. | ||
71 | +# | ||
72 | +# @write: This permission is required to change the visible disk contents. | ||
73 | +# | ||
74 | +# @write-unchanged: This permission (which is weaker than BLK_PERM_WRITE) is | ||
75 | +# both enough and required for writes to the block node when | ||
76 | +# the caller promises that the visible disk content doesn't | ||
77 | +# change. | ||
78 | +# As the BLK_PERM_WRITE permission is strictly stronger, | ||
79 | +# either is sufficient to perform an unchanging write. | ||
80 | +# | ||
81 | +# @resize: This permission is required to change the size of a block node. | ||
82 | +# | ||
83 | +# @graph-mod: This permission is required to change the node that this | ||
84 | +# BdrvChild points to. | ||
85 | +# | ||
86 | +# Since: 4.0 | ||
87 | +## | ||
88 | + { 'enum': 'BlockPermission', | ||
89 | + 'data': [ 'consistent-read', 'write', 'write-unchanged', 'resize', | ||
90 | + 'graph-mod' ] } | ||
91 | +## | ||
92 | +# @XDbgBlockGraphEdge: | ||
93 | +# | ||
94 | +# Block Graph edge description for x-debug-query-block-graph. | ||
95 | +# | ||
96 | +# @parent: parent id | ||
97 | +# | ||
98 | +# @child: child id | ||
99 | +# | ||
100 | +# @name: name of the relation (examples are 'file' and 'backing') | ||
101 | +# | ||
102 | +# @perm: granted permissions for the parent operating on the child | ||
103 | +# | ||
104 | +# @shared-perm: permissions that can still be granted to other users of the | ||
105 | +# child while it is still attached to this parent | ||
106 | +# | ||
107 | +# Since: 4.0 | ||
108 | +## | ||
109 | +{ 'struct': 'XDbgBlockGraphEdge', | ||
110 | + 'data': { 'parent': 'uint64', 'child': 'uint64', | ||
111 | + 'name': 'str', 'perm': [ 'BlockPermission' ], | ||
112 | + 'shared-perm': [ 'BlockPermission' ] } } | ||
113 | + | ||
114 | +## | ||
115 | +# @XDbgBlockGraph: | ||
116 | +# | ||
117 | +# Block Graph - list of nodes and list of edges. | ||
118 | +# | ||
119 | +# Since: 4.0 | ||
120 | +## | ||
121 | +{ 'struct': 'XDbgBlockGraph', | ||
122 | + 'data': { 'nodes': ['XDbgBlockGraphNode'], 'edges': ['XDbgBlockGraphEdge'] } } | ||
123 | + | ||
124 | +## | ||
125 | +# @x-debug-query-block-graph: | ||
126 | +# | ||
127 | +# Get the block graph. | ||
128 | +# | ||
129 | +# Since: 4.0 | ||
130 | +## | ||
131 | +{ 'command': 'x-debug-query-block-graph', 'returns': 'XDbgBlockGraph' } | ||
132 | + | ||
133 | ## | ||
134 | # @drive-mirror: | ||
135 | # | ||
136 | diff --git a/include/block/block.h b/include/block/block.h | ||
137 | index XXXXXXX..XXXXXXX 100644 | ||
138 | --- a/include/block/block.h | ||
139 | +++ b/include/block/block.h | ||
140 | @@ -XXX,XX +XXX,XX @@ void bdrv_eject(BlockDriverState *bs, bool eject_flag); | ||
141 | const char *bdrv_get_format_name(BlockDriverState *bs); | ||
142 | BlockDriverState *bdrv_find_node(const char *node_name); | ||
143 | BlockDeviceInfoList *bdrv_named_nodes_list(Error **errp); | ||
144 | +XDbgBlockGraph *bdrv_get_xdbg_block_graph(Error **errp); | ||
145 | BlockDriverState *bdrv_lookup_bs(const char *device, | ||
146 | const char *node_name, | ||
147 | Error **errp); | ||
148 | diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h | ||
149 | index XXXXXXX..XXXXXXX 100644 | ||
150 | --- a/include/sysemu/block-backend.h | ||
151 | +++ b/include/sysemu/block-backend.h | ||
152 | @@ -XXX,XX +XXX,XX @@ int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in, | ||
153 | int bytes, BdrvRequestFlags read_flags, | ||
154 | BdrvRequestFlags write_flags); | ||
155 | |||
156 | +const BdrvChild *blk_root(BlockBackend *blk); | ||
157 | + | ||
158 | #endif | ||
159 | diff --git a/block.c b/block.c | 19 | diff --git a/block.c b/block.c |
160 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
161 | --- a/block.c | 21 | --- a/block.c |
162 | +++ b/block.c | 22 | +++ b/block.c |
163 | @@ -XXX,XX +XXX,XX @@ BlockDeviceInfoList *bdrv_named_nodes_list(Error **errp) | 23 | @@ -XXX,XX +XXX,XX @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to, |
164 | return list; | ||
165 | } | ||
166 | |||
167 | +#define QAPI_LIST_ADD(list, element) do { \ | ||
168 | + typeof(list) _tmp = g_new(typeof(*(list)), 1); \ | ||
169 | + _tmp->value = (element); \ | ||
170 | + _tmp->next = (list); \ | ||
171 | + (list) = _tmp; \ | ||
172 | +} while (0) | ||
173 | + | ||
174 | +typedef struct XDbgBlockGraphConstructor { | ||
175 | + XDbgBlockGraph *graph; | ||
176 | + GHashTable *graph_nodes; | ||
177 | +} XDbgBlockGraphConstructor; | ||
178 | + | ||
179 | +static XDbgBlockGraphConstructor *xdbg_graph_new(void) | ||
180 | +{ | ||
181 | + XDbgBlockGraphConstructor *gr = g_new(XDbgBlockGraphConstructor, 1); | ||
182 | + | ||
183 | + gr->graph = g_new0(XDbgBlockGraph, 1); | ||
184 | + gr->graph_nodes = g_hash_table_new(NULL, NULL); | ||
185 | + | ||
186 | + return gr; | ||
187 | +} | ||
188 | + | ||
189 | +static XDbgBlockGraph *xdbg_graph_finalize(XDbgBlockGraphConstructor *gr) | ||
190 | +{ | ||
191 | + XDbgBlockGraph *graph = gr->graph; | ||
192 | + | ||
193 | + g_hash_table_destroy(gr->graph_nodes); | ||
194 | + g_free(gr); | ||
195 | + | ||
196 | + return graph; | ||
197 | +} | ||
198 | + | ||
199 | +static uintptr_t xdbg_graph_node_num(XDbgBlockGraphConstructor *gr, void *node) | ||
200 | +{ | ||
201 | + uintptr_t ret = (uintptr_t)g_hash_table_lookup(gr->graph_nodes, node); | ||
202 | + | ||
203 | + if (ret != 0) { | ||
204 | + return ret; | ||
205 | + } | ||
206 | + | ||
207 | + /* | ||
208 | + * Start counting from 1, not 0, because 0 interferes with not-found (NULL) | ||
209 | + * answer of g_hash_table_lookup. | ||
210 | + */ | ||
211 | + ret = g_hash_table_size(gr->graph_nodes) + 1; | ||
212 | + g_hash_table_insert(gr->graph_nodes, node, (void *)ret); | ||
213 | + | ||
214 | + return ret; | ||
215 | +} | ||
216 | + | ||
217 | +static void xdbg_graph_add_node(XDbgBlockGraphConstructor *gr, void *node, | ||
218 | + XDbgBlockGraphNodeType type, const char *name) | ||
219 | +{ | ||
220 | + XDbgBlockGraphNode *n; | ||
221 | + | ||
222 | + n = g_new0(XDbgBlockGraphNode, 1); | ||
223 | + | ||
224 | + n->id = xdbg_graph_node_num(gr, node); | ||
225 | + n->type = type; | ||
226 | + n->name = g_strdup(name); | ||
227 | + | ||
228 | + QAPI_LIST_ADD(gr->graph->nodes, n); | ||
229 | +} | ||
230 | + | ||
231 | +static void xdbg_graph_add_edge(XDbgBlockGraphConstructor *gr, void *parent, | ||
232 | + const BdrvChild *child) | ||
233 | +{ | ||
234 | + typedef struct { | ||
235 | + unsigned int flag; | ||
236 | + BlockPermission num; | ||
237 | + } PermissionMap; | ||
238 | + | ||
239 | + static const PermissionMap permissions[] = { | ||
240 | + { BLK_PERM_CONSISTENT_READ, BLOCK_PERMISSION_CONSISTENT_READ }, | ||
241 | + { BLK_PERM_WRITE, BLOCK_PERMISSION_WRITE }, | ||
242 | + { BLK_PERM_WRITE_UNCHANGED, BLOCK_PERMISSION_WRITE_UNCHANGED }, | ||
243 | + { BLK_PERM_RESIZE, BLOCK_PERMISSION_RESIZE }, | ||
244 | + { BLK_PERM_GRAPH_MOD, BLOCK_PERMISSION_GRAPH_MOD }, | ||
245 | + { 0, 0 } | ||
246 | + }; | ||
247 | + const PermissionMap *p; | ||
248 | + XDbgBlockGraphEdge *edge; | ||
249 | + | ||
250 | + QEMU_BUILD_BUG_ON(1UL << (ARRAY_SIZE(permissions) - 1) != BLK_PERM_ALL + 1); | ||
251 | + | ||
252 | + edge = g_new0(XDbgBlockGraphEdge, 1); | ||
253 | + | ||
254 | + edge->parent = xdbg_graph_node_num(gr, parent); | ||
255 | + edge->child = xdbg_graph_node_num(gr, child->bs); | ||
256 | + edge->name = g_strdup(child->name); | ||
257 | + | ||
258 | + for (p = permissions; p->flag; p++) { | ||
259 | + if (p->flag & child->perm) { | ||
260 | + QAPI_LIST_ADD(edge->perm, p->num); | ||
261 | + } | ||
262 | + if (p->flag & child->shared_perm) { | ||
263 | + QAPI_LIST_ADD(edge->shared_perm, p->num); | ||
264 | + } | ||
265 | + } | ||
266 | + | ||
267 | + QAPI_LIST_ADD(gr->graph->edges, edge); | ||
268 | +} | ||
269 | + | ||
270 | + | ||
271 | +XDbgBlockGraph *bdrv_get_xdbg_block_graph(Error **errp) | ||
272 | +{ | ||
273 | + BlockBackend *blk; | ||
274 | + BlockJob *job; | ||
275 | + BlockDriverState *bs; | ||
276 | + BdrvChild *child; | ||
277 | + XDbgBlockGraphConstructor *gr = xdbg_graph_new(); | ||
278 | + | ||
279 | + for (blk = blk_all_next(NULL); blk; blk = blk_all_next(blk)) { | ||
280 | + char *allocated_name = NULL; | ||
281 | + const char *name = blk_name(blk); | ||
282 | + | ||
283 | + if (!*name) { | ||
284 | + name = allocated_name = blk_get_attached_dev_id(blk); | ||
285 | + } | ||
286 | + xdbg_graph_add_node(gr, blk, X_DBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_BACKEND, | ||
287 | + name); | ||
288 | + g_free(allocated_name); | ||
289 | + if (blk_root(blk)) { | ||
290 | + xdbg_graph_add_edge(gr, blk, blk_root(blk)); | ||
291 | + } | ||
292 | + } | ||
293 | + | ||
294 | + for (job = block_job_next(NULL); job; job = block_job_next(job)) { | ||
295 | + GSList *el; | ||
296 | + | ||
297 | + xdbg_graph_add_node(gr, job, X_DBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_JOB, | ||
298 | + job->job.id); | ||
299 | + for (el = job->nodes; el; el = el->next) { | ||
300 | + xdbg_graph_add_edge(gr, job, (BdrvChild *)el->data); | ||
301 | + } | ||
302 | + } | ||
303 | + | ||
304 | + QTAILQ_FOREACH(bs, &graph_bdrv_states, node_list) { | ||
305 | + xdbg_graph_add_node(gr, bs, X_DBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_DRIVER, | ||
306 | + bs->node_name); | ||
307 | + QLIST_FOREACH(child, &bs->children, next) { | ||
308 | + xdbg_graph_add_edge(gr, bs, child); | ||
309 | + } | ||
310 | + } | ||
311 | + | ||
312 | + return xdbg_graph_finalize(gr); | ||
313 | +} | ||
314 | + | ||
315 | BlockDriverState *bdrv_lookup_bs(const char *device, | ||
316 | const char *node_name, | ||
317 | Error **errp) | ||
318 | diff --git a/block/block-backend.c b/block/block-backend.c | ||
319 | index XXXXXXX..XXXXXXX 100644 | ||
320 | --- a/block/block-backend.c | ||
321 | +++ b/block/block-backend.c | ||
322 | @@ -XXX,XX +XXX,XX @@ int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in, | ||
323 | blk_out->root, off_out, | ||
324 | bytes, read_flags, write_flags); | ||
325 | } | ||
326 | + | ||
327 | +const BdrvChild *blk_root(BlockBackend *blk) | ||
328 | +{ | ||
329 | + return blk->root; | ||
330 | +} | ||
331 | diff --git a/blockdev.c b/blockdev.c | ||
332 | index XXXXXXX..XXXXXXX 100644 | ||
333 | --- a/blockdev.c | ||
334 | +++ b/blockdev.c | ||
335 | @@ -XXX,XX +XXX,XX @@ BlockDeviceInfoList *qmp_query_named_block_nodes(Error **errp) | ||
336 | return bdrv_named_nodes_list(errp); | ||
337 | } | ||
338 | |||
339 | +XDbgBlockGraph *qmp_x_debug_query_block_graph(Error **errp) | ||
340 | +{ | ||
341 | + return bdrv_get_xdbg_block_graph(errp); | ||
342 | +} | ||
343 | + | ||
344 | BlockJob *do_blockdev_backup(BlockdevBackup *backup, JobTxn *txn, | ||
345 | Error **errp) | ||
346 | { | 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); | ||
347 | -- | 42 | -- |
348 | 2.20.1 | 43 | 2.21.0 |
349 | 44 | ||
350 | 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 |
1 | From: Li Qiang <liq3ea@163.com> | 1 | fe646693acc changed qemu-img create's output so that it no longer prints |
---|---|---|---|
2 | single quotes around parameter values. The subformat and adapter_type | ||
3 | filters in _filter_img_create() have never been adapted to that change. | ||
2 | 4 | ||
3 | When it is zero, it causes segv. | 5 | Fixes: fe646693acc13ac48b98435d14149ab04dc597bc |
4 | Using following command: | 6 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
5 | 7 | Reviewed-by: John Snow <jsnow@redhat.com> | |
6 | "-drive file=//home/test/test1.img,if=none,id=id0 | 8 | Message-id: 20190815153638.4600-2-mreitz@redhat.com |
7 | -device nvme,drive=id0,serial=test,num_queues=0" | 9 | Reviewed-by: John Snow <jsnow@redhat.com> |
8 | causes following Backtrack: | ||
9 | |||
10 | Thread 4 "qemu-system-x86" received signal SIGSEGV, Segmentation fault. | ||
11 | [Switching to Thread 0x7fffe9735700 (LWP 30952)] | ||
12 | 0x0000555555a7a77c in nvme_start_ctrl (n=0x5555577473f0) at hw/block/nvme.c:825 | ||
13 | 825 if (unlikely(n->cq[0])) { | ||
14 | (gdb) bt | ||
15 | 0 0x0000555555a7a77c in nvme_start_ctrl (n=0x5555577473f0) | ||
16 | at hw/block/nvme.c:825 | ||
17 | 1 0x0000555555a7af7f in nvme_write_bar (n=0x5555577473f0, offset=20, | ||
18 | data=4587521, size=4) at hw/block/nvme.c:969 | ||
19 | 2 0x0000555555a7b81a in nvme_mmio_write (opaque=0x5555577473f0, addr=20, | ||
20 | data=4587521, size=4) at hw/block/nvme.c:1163 | ||
21 | 3 0x0000555555869236 in memory_region_write_accessor (mr=0x555557747cd0, | ||
22 | addr=20, value=0x7fffe97320f8, size=4, shift=0, mask=4294967295, attrs=...) | ||
23 | at /home/test/qemu1/qemu/memory.c:502 | ||
24 | 4 0x0000555555869446 in access_with_adjusted_size (addr=20, | ||
25 | value=0x7fffe97320f8, size=4, access_size_min=2, access_size_max=8, | ||
26 | access_fn=0x55555586914d <memory_region_write_accessor>, | ||
27 | mr=0x555557747cd0, attrs=...) at /home/test/qemu1/qemu/memory.c:568 | ||
28 | 5 0x000055555586c479 in memory_region_dispatch_write (mr=0x555557747cd0, | ||
29 | addr=20, data=4587521, size=4, attrs=...) | ||
30 | at /home/test/qemu1/qemu/memory.c:1499 | ||
31 | 6 0x00005555558030af in flatview_write_continue (fv=0x7fffe0061130, | ||
32 | addr=4273930260, attrs=..., buf=0x7ffff7ff0028 "\001", len=4, addr1=20, | ||
33 | l=4, mr=0x555557747cd0) at /home/test/qemu1/qemu/exec.c:3234 | ||
34 | 7 0x00005555558031f9 in flatview_write (fv=0x7fffe0061130, addr=4273930260, | ||
35 | attrs=..., buf=0x7ffff7ff0028 "\001", len=4) | ||
36 | at /home/test/qemu1/qemu/exec.c:3273 | ||
37 | 8 0x00005555558034ff in address_space_write ( | ||
38 | ---Type <return> to continue, or q <return> to quit--- | ||
39 | as=0x555556758480 <address_space_memory>, addr=4273930260, attrs=..., | ||
40 | buf=0x7ffff7ff0028 "\001", len=4) at /home/test/qemu1/qemu/exec.c:3363 | ||
41 | 9 0x0000555555803550 in address_space_rw ( | ||
42 | as=0x555556758480 <address_space_memory>, addr=4273930260, attrs=..., | ||
43 | buf=0x7ffff7ff0028 "\001", len=4, is_write=true) | ||
44 | at /home/test/qemu1/qemu/exec.c:3374 | ||
45 | 10 0x00005555558884a1 in kvm_cpu_exec (cpu=0x555556920e40) | ||
46 | at /home/test/qemu1/qemu/accel/kvm/kvm-all.c:2031 | ||
47 | 11 0x000055555584cd9d in qemu_kvm_cpu_thread_fn (arg=0x555556920e40) | ||
48 | at /home/test/qemu1/qemu/cpus.c:1281 | ||
49 | 12 0x0000555555dbaf6d in qemu_thread_start (args=0x5555569438a0) | ||
50 | at util/qemu-thread-posix.c:502 | ||
51 | 13 0x00007ffff5dc86db in start_thread (arg=0x7fffe9735700) | ||
52 | at pthread_create.c:463 | ||
53 | 14 0x00007ffff5af188f in clone () | ||
54 | at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 | ||
55 | |||
56 | Signed-off-by: Li Qiang <liq3ea@163.com> | ||
57 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
58 | Message-id: 20190120055558.32984-3-liq3ea@163.com | ||
59 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 10 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
60 | --- | 11 | --- |
61 | hw/block/nvme.c | 5 +++++ | 12 | tests/qemu-iotests/059.out | 16 ++++++++-------- |
62 | 1 file changed, 5 insertions(+) | 13 | tests/qemu-iotests/common.filter | 4 ++-- |
14 | 2 files changed, 10 insertions(+), 10 deletions(-) | ||
63 | 15 | ||
64 | diff --git a/hw/block/nvme.c b/hw/block/nvme.c | 16 | diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out |
65 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
66 | --- a/hw/block/nvme.c | 18 | --- a/tests/qemu-iotests/059.out |
67 | +++ b/hw/block/nvme.c | 19 | +++ b/tests/qemu-iotests/059.out |
68 | @@ -XXX,XX +XXX,XX @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp) | 20 | @@ -XXX,XX +XXX,XX @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 |
69 | int64_t bs_size; | 21 | qemu-io: can't open device TEST_DIR/t.vmdk: L1 size too big |
70 | uint8_t *pci_conf; | 22 | |
71 | 23 | === Testing monolithicFlat creation and opening === | |
72 | + if (!n->num_queues) { | 24 | -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 subformat=monolithicFlat |
73 | + error_setg(errp, "num_queues can't be zero"); | 25 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648 |
74 | + return; | 26 | image: TEST_DIR/t.IMGFMT |
75 | + } | 27 | file format: IMGFMT |
76 | + | 28 | virtual size: 2 GiB (2147483648 bytes) |
77 | if (!n->conf.blk) { | 29 | |
78 | error_setg(errp, "drive property not set"); | 30 | === Testing monolithicFlat with zeroed_grain === |
79 | return; | 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" \ | ||
80 | -- | 101 | -- |
81 | 2.20.1 | 102 | 2.21.0 |
82 | 103 | ||
83 | 104 | diff view generated by jsdifflib |
1 | From: Li Qiang <liq3ea@163.com> | 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 | Signed-off-by: Li Qiang <liq3ea@163.com> | 4 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
4 | Reviewed-by: Max Reitz <mreitz@redhat.com> | 5 | Message-id: 20190815153638.4600-3-mreitz@redhat.com |
5 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 6 | Reviewed-by: John Snow <jsnow@redhat.com> |
6 | Message-id: 20190120055558.32984-2-liq3ea@163.com | ||
7 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 7 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
8 | --- | 8 | --- |
9 | hw/block/nvme.c | 2 +- | 9 | block/vmdk.c | 54 ++++++++++++++++++++++++-------------- |
10 | 1 file changed, 1 insertion(+), 1 deletion(-) | 10 | tests/qemu-iotests/059 | 7 +++-- |
11 | tests/qemu-iotests/059.out | 4 ++- | ||
12 | 3 files changed, 42 insertions(+), 23 deletions(-) | ||
11 | 13 | ||
12 | diff --git a/hw/block/nvme.c b/hw/block/nvme.c | 14 | diff --git a/block/vmdk.c b/block/vmdk.c |
13 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/block/nvme.c | 16 | --- a/block/vmdk.c |
15 | +++ b/hw/block/nvme.c | 17 | +++ b/block/vmdk.c |
16 | @@ -XXX,XX +XXX,XX @@ static void nvme_instance_init(Object *obj) | 18 | @@ -XXX,XX +XXX,XX @@ static const char *next_line(const char *s) |
17 | } | 19 | } |
18 | 20 | ||
19 | static const TypeInfo nvme_info = { | 21 | static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, |
20 | - .name = "nvme", | 22 | - const char *desc_file_path, QDict *options, |
21 | + .name = TYPE_NVME, | 23 | - Error **errp) |
22 | .parent = TYPE_PCI_DEVICE, | 24 | + QDict *options, Error **errp) |
23 | .instance_size = sizeof(NvmeCtrl), | 25 | { |
24 | .class_init = nvme_class_init, | 26 | int ret; |
27 | int matches; | ||
28 | @@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, | ||
29 | const char *p, *np; | ||
30 | int64_t sectors = 0; | ||
31 | int64_t flat_offset; | ||
32 | + char *desc_file_dir = NULL; | ||
33 | char *extent_path; | ||
34 | BdrvChild *extent_file; | ||
35 | BDRVVmdkState *s = bs->opaque; | ||
36 | @@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, | ||
37 | continue; | ||
38 | } | ||
39 | |||
40 | - if (!path_is_absolute(fname) && !path_has_protocol(fname) && | ||
41 | - !desc_file_path[0]) | ||
42 | - { | ||
43 | - bdrv_refresh_filename(bs->file->bs); | ||
44 | - error_setg(errp, "Cannot use relative extent paths with VMDK " | ||
45 | - "descriptor file '%s'", bs->file->bs->filename); | ||
46 | - return -EINVAL; | ||
47 | - } | ||
48 | + if (path_is_absolute(fname)) { | ||
49 | + extent_path = g_strdup(fname); | ||
50 | + } else { | ||
51 | + if (!desc_file_dir) { | ||
52 | + desc_file_dir = bdrv_dirname(bs->file->bs, errp); | ||
53 | + if (!desc_file_dir) { | ||
54 | + bdrv_refresh_filename(bs->file->bs); | ||
55 | + error_prepend(errp, "Cannot use relative paths with VMDK " | ||
56 | + "descriptor file '%s': ", | ||
57 | + bs->file->bs->filename); | ||
58 | + ret = -EINVAL; | ||
59 | + goto out; | ||
60 | + } | ||
61 | + } | ||
62 | |||
63 | - extent_path = path_combine(desc_file_path, fname); | ||
64 | + extent_path = g_strconcat(desc_file_dir, fname, NULL); | ||
65 | + } | ||
66 | |||
67 | ret = snprintf(extent_opt_prefix, 32, "extents.%d", s->num_extents); | ||
68 | assert(ret < 32); | ||
69 | @@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, | ||
70 | g_free(extent_path); | ||
71 | if (local_err) { | ||
72 | error_propagate(errp, local_err); | ||
73 | - return -EINVAL; | ||
74 | + ret = -EINVAL; | ||
75 | + goto out; | ||
76 | } | ||
77 | |||
78 | /* save to extents array */ | ||
79 | @@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, | ||
80 | 0, 0, 0, 0, 0, &extent, errp); | ||
81 | if (ret < 0) { | ||
82 | bdrv_unref_child(bs, extent_file); | ||
83 | - return ret; | ||
84 | + goto out; | ||
85 | } | ||
86 | extent->flat_start_offset = flat_offset << 9; | ||
87 | } else if (!strcmp(type, "SPARSE") || !strcmp(type, "VMFSSPARSE")) { | ||
88 | @@ -XXX,XX +XXX,XX @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs, | ||
89 | g_free(buf); | ||
90 | if (ret) { | ||
91 | bdrv_unref_child(bs, extent_file); | ||
92 | - return ret; | ||
93 | + goto out; | ||
94 | } | ||
95 | extent = &s->extents[s->num_extents - 1]; | ||
96 | } else if (!strcmp(type, "SESPARSE")) { | ||
97 | ret = vmdk_open_se_sparse(bs, extent_file, bs->open_flags, errp); | ||
98 | if (ret) { | ||
99 | bdrv_unref_child(bs, extent_file); | ||
100 | - return ret; | ||
101 | + goto out; | ||
102 | } | ||
103 | extent = &s->extents[s->num_extents - 1]; | ||
104 | } else { | ||
105 | error_setg(errp, "Unsupported extent type '%s'", type); | ||
106 | bdrv_unref_child(bs, extent_file); | ||
107 | - return -ENOTSUP; | ||
108 | + ret = -ENOTSUP; | ||
109 | + goto out; | ||
110 | } | ||
111 | extent->type = g_strdup(type); | ||
112 | } | ||
113 | - return 0; | ||
114 | + | ||
115 | + ret = 0; | ||
116 | + goto out; | ||
117 | |||
118 | invalid: | ||
119 | np = next_line(p); | ||
120 | @@ -XXX,XX +XXX,XX @@ invalid: | ||
121 | np--; | ||
122 | } | ||
123 | error_setg(errp, "Invalid extent line: %.*s", (int)(np - p), p); | ||
124 | - return -EINVAL; | ||
125 | + ret = -EINVAL; | ||
126 | + | ||
127 | +out: | ||
128 | + g_free(desc_file_dir); | ||
129 | + return ret; | ||
130 | } | ||
131 | |||
132 | static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf, | ||
133 | @@ -XXX,XX +XXX,XX @@ static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf, | ||
134 | } | ||
135 | s->create_type = g_strdup(ct); | ||
136 | s->desc_offset = 0; | ||
137 | - ret = vmdk_parse_extents(buf, bs, bs->file->bs->exact_filename, options, | ||
138 | - errp); | ||
139 | + ret = vmdk_parse_extents(buf, bs, options, errp); | ||
140 | exit: | ||
141 | return ret; | ||
142 | } | ||
143 | diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059 | ||
144 | index XXXXXXX..XXXXXXX 100755 | ||
145 | --- a/tests/qemu-iotests/059 | ||
146 | +++ b/tests/qemu-iotests/059 | ||
147 | @@ -XXX,XX +XXX,XX @@ $QEMU_IMG convert -f qcow2 -O vmdk -o subformat=streamOptimized "$TEST_IMG.qcow2 | ||
148 | |||
149 | echo | ||
150 | echo "=== Testing monolithicFlat with internally generated JSON file name ===" | ||
151 | +# Should work, because bdrv_dirname() works fine with blkdebug | ||
152 | IMGOPTS="subformat=monolithicFlat" _make_test_img 64M | ||
153 | -$QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" 2>&1 \ | ||
154 | - | _filter_testdir | _filter_imgfmt | ||
155 | +$QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" \ | ||
156 | + -c info \ | ||
157 | + 2>&1 \ | ||
158 | + | _filter_testdir | _filter_imgfmt | _filter_img_info | ||
159 | _cleanup_test_img | ||
160 | |||
161 | echo | ||
162 | diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out | ||
163 | index XXXXXXX..XXXXXXX 100644 | ||
164 | --- a/tests/qemu-iotests/059.out | ||
165 | +++ b/tests/qemu-iotests/059.out | ||
166 | @@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240 | ||
167 | |||
168 | === Testing monolithicFlat with internally generated JSON file name === | ||
169 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 | ||
170 | -qemu-io: can't open: Cannot use relative extent paths with VMDK descriptor file 'json:{"image": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, "driver": "blkdebug", "inject-error.0.event": "read_aio"}' | ||
171 | +format name: IMGFMT | ||
172 | +cluster size: 0 bytes | ||
173 | +vm state offset: 0 bytes | ||
174 | |||
175 | === Testing version 3 === | ||
176 | image: TEST_DIR/iotest-version3.IMGFMT | ||
25 | -- | 177 | -- |
26 | 2.20.1 | 178 | 2.21.0 |
27 | 179 | ||
28 | 180 | diff view generated by jsdifflib |
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 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. | ||
2 | 4 | ||
3 | Render block nodes graph with help of graphviz. This new function is | 5 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
4 | for debugging, so there is no sense to put it into qemu.py as a method | 6 | Reviewed-by: John Snow <jsnow@redhat.com> |
5 | of QEMUMachine. Let's instead put it separately. | 7 | Message-id: 20190815153638.4600-4-mreitz@redhat.com |
6 | 8 | Reviewed-by: John Snow <jsnow@redhat.com> | |
7 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
8 | Acked-by: Eduardo Habkost <ehabkost@redhat.com> | ||
9 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
10 | Message-id: 20181221170909.25584-3-vsementsov@virtuozzo.com | ||
11 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 9 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
12 | --- | 10 | --- |
13 | scripts/render_block_graph.py | 120 ++++++++++++++++++++++++++++++++++ | 11 | tests/qemu-iotests/059 | 27 +++++++++++++++++++++++++++ |
14 | 1 file changed, 120 insertions(+) | 12 | tests/qemu-iotests/059.out | 4 ++++ |
15 | create mode 100755 scripts/render_block_graph.py | 13 | 2 files changed, 31 insertions(+) |
16 | 14 | ||
17 | diff --git a/scripts/render_block_graph.py b/scripts/render_block_graph.py | 15 | diff --git a/tests/qemu-iotests/059 b/tests/qemu-iotests/059 |
18 | new file mode 100755 | 16 | index XXXXXXX..XXXXXXX 100755 |
19 | index XXXXXXX..XXXXXXX | 17 | --- a/tests/qemu-iotests/059 |
20 | --- /dev/null | 18 | +++ b/tests/qemu-iotests/059 |
21 | +++ b/scripts/render_block_graph.py | 19 | @@ -XXX,XX +XXX,XX @@ $QEMU_IMG convert -f qcow2 -O vmdk -o subformat=streamOptimized "$TEST_IMG.qcow2 |
22 | @@ -XXX,XX +XXX,XX @@ | 20 | |
23 | +#!/usr/bin/env python | 21 | echo |
24 | +# | 22 | echo "=== Testing monolithicFlat with internally generated JSON file name ===" |
25 | +# Render Qemu Block Graph | ||
26 | +# | ||
27 | +# Copyright (c) 2018 Virtuozzo International GmbH. All rights reserved. | ||
28 | +# | ||
29 | +# This program is free software; you can redistribute it and/or modify | ||
30 | +# it under the terms of the GNU General Public License as published by | ||
31 | +# the Free Software Foundation; either version 2 of the License, or | ||
32 | +# (at your option) any later version. | ||
33 | +# | ||
34 | +# This program is distributed in the hope that it will be useful, | ||
35 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
36 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
37 | +# GNU General Public License for more details. | ||
38 | +# | ||
39 | +# You should have received a copy of the GNU General Public License | ||
40 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
41 | +# | ||
42 | + | 23 | + |
43 | +import os | 24 | +echo '--- blkdebug ---' |
44 | +import sys | 25 | # Should work, because bdrv_dirname() works fine with blkdebug |
45 | +import subprocess | 26 | IMGOPTS="subformat=monolithicFlat" _make_test_img 64M |
46 | +import json | 27 | $QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" \ |
47 | +from graphviz import Digraph | 28 | @@ -XXX,XX +XXX,XX @@ $QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TE |
48 | +from qemu import MonitorResponseError | 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 | ||
49 | + | 55 | + |
50 | + | 56 | + |
51 | +def perm(arr): | 57 | echo |
52 | + s = 'w' if 'write' in arr else '_' | 58 | echo "=== Testing version 3 ===" |
53 | + s += 'r' if 'consistent-read' in arr else '_' | 59 | _use_sample_img iotest-version3.vmdk.bz2 |
54 | + s += 'u' if 'write-unchanged' in arr else '_' | 60 | diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out |
55 | + s += 'g' if 'graph-mod' in arr else '_' | 61 | index XXXXXXX..XXXXXXX 100644 |
56 | + s += 's' if 'resize' in arr else '_' | 62 | --- a/tests/qemu-iotests/059.out |
57 | + return s | 63 | +++ b/tests/qemu-iotests/059.out |
58 | + | 64 | @@ -XXX,XX +XXX,XX @@ wrote 512/512 bytes at offset 10240 |
59 | + | 65 | 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) |
60 | +def render_block_graph(qmp, filename, format='png'): | 66 | |
61 | + ''' | 67 | === Testing monolithicFlat with internally generated JSON file name === |
62 | + Render graph in text (dot) representation into "@filename" and | 68 | +--- blkdebug --- |
63 | + representation in @format into "@filename.@format" | 69 | Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 |
64 | + ''' | 70 | format name: IMGFMT |
65 | + | 71 | cluster size: 0 bytes |
66 | + bds_nodes = qmp.command('query-named-block-nodes') | 72 | vm state offset: 0 bytes |
67 | + bds_nodes = {n['node-name']: n for n in bds_nodes} | 73 | +--- quorum --- |
68 | + | 74 | +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 |
69 | + job_nodes = qmp.command('query-block-jobs') | 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 |
70 | + job_nodes = {n['device']: n for n in job_nodes} | 76 | |
71 | + | 77 | === Testing version 3 === |
72 | + block_graph = qmp.command('x-debug-query-block-graph') | 78 | image: TEST_DIR/iotest-version3.IMGFMT |
73 | + | ||
74 | + graph = Digraph(comment='Block Nodes Graph') | ||
75 | + graph.format = format | ||
76 | + graph.node('permission symbols:\l' | ||
77 | + ' w - Write\l' | ||
78 | + ' r - consistent-Read\l' | ||
79 | + ' u - write - Unchanged\l' | ||
80 | + ' g - Graph-mod\l' | ||
81 | + ' s - reSize\l' | ||
82 | + 'edge label scheme:\l' | ||
83 | + ' <child type>\l' | ||
84 | + ' <perm>\l' | ||
85 | + ' <shared_perm>\l', shape='none') | ||
86 | + | ||
87 | + for n in block_graph['nodes']: | ||
88 | + if n['type'] == 'block-driver': | ||
89 | + info = bds_nodes[n['name']] | ||
90 | + label = n['name'] + ' [' + info['drv'] + ']' | ||
91 | + if info['drv'] == 'file': | ||
92 | + label += '\n' + os.path.basename(info['file']) | ||
93 | + shape = 'ellipse' | ||
94 | + elif n['type'] == 'block-job': | ||
95 | + info = job_nodes[n['name']] | ||
96 | + label = info['type'] + ' job (' + n['name'] + ')' | ||
97 | + shape = 'box' | ||
98 | + else: | ||
99 | + assert n['type'] == 'block-backend' | ||
100 | + label = n['name'] if n['name'] else 'unnamed blk' | ||
101 | + shape = 'box' | ||
102 | + | ||
103 | + graph.node(str(n['id']), label, shape=shape) | ||
104 | + | ||
105 | + for e in block_graph['edges']: | ||
106 | + label = '%s\l%s\l%s\l' % (e['name'], perm(e['perm']), | ||
107 | + perm(e['shared-perm'])) | ||
108 | + graph.edge(str(e['parent']), str(e['child']), label=label) | ||
109 | + | ||
110 | + graph.render(filename) | ||
111 | + | ||
112 | + | ||
113 | +class LibvirtGuest(): | ||
114 | + def __init__(self, name): | ||
115 | + self.name = name | ||
116 | + | ||
117 | + def command(self, cmd): | ||
118 | + # only supports qmp commands without parameters | ||
119 | + m = {'execute': cmd} | ||
120 | + ar = ['virsh', 'qemu-monitor-command', self.name, json.dumps(m)] | ||
121 | + | ||
122 | + reply = json.loads(subprocess.check_output(ar)) | ||
123 | + | ||
124 | + if 'error' in reply: | ||
125 | + raise MonitorResponseError(reply) | ||
126 | + | ||
127 | + return reply['return'] | ||
128 | + | ||
129 | + | ||
130 | +if __name__ == '__main__': | ||
131 | + obj = sys.argv[1] | ||
132 | + out = sys.argv[2] | ||
133 | + | ||
134 | + if os.path.exists(obj): | ||
135 | + # assume unix socket | ||
136 | + qmp = QEMUMonitorProtocol(obj) | ||
137 | + qmp.connect() | ||
138 | + else: | ||
139 | + # assume libvirt guest name | ||
140 | + qmp = LibvirtGuest(obj) | ||
141 | + | ||
142 | + render_block_graph(qmp, out) | ||
143 | -- | 79 | -- |
144 | 2.20.1 | 80 | 2.21.0 |
145 | 81 | ||
146 | 82 | diff view generated by jsdifflib |
1 | By default, qemu-nbd binds to 0.0.0.0. However, we then proceed to | 1 | Compressed writes generally have to write full clusters, not just in |
---|---|---|---|
2 | connect to "localhost". Usually, this works out fine; but if this test | 2 | theory but also in practice when it comes to vmdk's streamOptimized |
3 | is run concurrently, some other test function may have bound a different | 3 | subformat. It currently is just silently broken for writes with |
4 | server to ::1 (on the same port -- you can bind different serves to the | 4 | non-zero in-cluster offsets: |
5 | same port, as long as one is on IPv4 and the other on IPv6). | ||
6 | 5 | ||
7 | So running qemu-nbd works, it can bind to 0.0.0.0:NBD_PORT. But | 6 | $ qemu-img create -f vmdk -o subformat=streamOptimized foo.vmdk 1M |
8 | potentially a concurrent test has successfully taken [::1]:NBD_PORT. In | 7 | $ qemu-io -c 'write 4k 4k' -c 'read 4k 4k' foo.vmdk |
9 | this case, trying to connect to "localhost" will lead us to the IPv6 | 8 | wrote 4096/4096 bytes at offset 4096 |
10 | instance, where we do not want to end up. | 9 | 4 KiB, 1 ops; 00.01 sec (443.724 KiB/sec and 110.9309 ops/sec) |
10 | read failed: Invalid argument | ||
11 | 11 | ||
12 | Fix this by just binding to "localhost". This will make qemu-nbd error | 12 | (The technical reason is that vmdk_write_extent() just writes the |
13 | out immediately and not give us cryptic errors later. | 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.) | ||
14 | 17 | ||
15 | (Also, it will allow us to just try a different port as of a future | 18 | For incomplete writes with zero in-cluster offsets, the error path when |
16 | patch.) | 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. | ||
17 | 33 | ||
18 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 34 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
19 | Message-id: 20181221234750.23577-3-mreitz@redhat.com | ||
20 | Reviewed-by: John Snow <jsnow@redhat.com> | 35 | Reviewed-by: John Snow <jsnow@redhat.com> |
21 | Reviewed-by: Eric Blake <eblake@redhat.com> | 36 | Message-id: 20190815153638.4600-5-mreitz@redhat.com |
37 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
22 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 38 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
23 | --- | 39 | --- |
24 | tests/qemu-iotests/147 | 2 +- | 40 | block/vmdk.c | 10 ++++++++++ |
25 | 1 file changed, 1 insertion(+), 1 deletion(-) | 41 | 1 file changed, 10 insertions(+) |
26 | 42 | ||
27 | diff --git a/tests/qemu-iotests/147 b/tests/qemu-iotests/147 | 43 | diff --git a/block/vmdk.c b/block/vmdk.c |
28 | index XXXXXXX..XXXXXXX 100755 | 44 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/tests/qemu-iotests/147 | 45 | --- a/block/vmdk.c |
30 | +++ b/tests/qemu-iotests/147 | 46 | +++ b/block/vmdk.c |
31 | @@ -XXX,XX +XXX,XX @@ class QemuNBD(NBDBlockdevAddBase): | 47 | @@ -XXX,XX +XXX,XX @@ static int vmdk_write_extent(VmdkExtent *extent, int64_t cluster_offset, |
32 | self.assertEqual(qemu_nbd('-f', imgfmt, test_img, *args), 0) | 48 | if (extent->compressed) { |
33 | 49 | void *compressed_data; | |
34 | def test_inet(self): | 50 | |
35 | - self._server_up('-p', str(NBD_PORT)) | 51 | + /* Only whole clusters */ |
36 | + self._server_up('-b', 'localhost', '-p', str(NBD_PORT)) | 52 | + if (offset_in_cluster || |
37 | address = { 'type': 'inet', | 53 | + n_bytes > (extent->cluster_sectors * SECTOR_SIZE) || |
38 | 'data': { | 54 | + (n_bytes < (extent->cluster_sectors * SECTOR_SIZE) && |
39 | 'host': 'localhost', | 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; | ||
40 | -- | 64 | -- |
41 | 2.20.1 | 65 | 2.21.0 |
42 | 66 | ||
43 | 67 | diff view generated by jsdifflib |
1 | From: Laurent Vivier <lvivier@redhat.com> | 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. | ||
2 | 4 | ||
3 | Signed-off-by: Laurent Vivier <lvivier@redhat.com> | 5 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
4 | Reviewed-by: Richard W.M. Jones <rjones@redhat.com> | 6 | Message-id: 20190815153638.4600-6-mreitz@redhat.com |
5 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 7 | Reviewed-by: John Snow <jsnow@redhat.com> |
6 | Message-id: 20181213162727.17438-3-lvivier@redhat.com | ||
7 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 8 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
8 | --- | 9 | --- |
9 | block/curl.c | 29 ++++++++--------------------- | 10 | tests/qemu-iotests/002 | 1 + |
10 | block/trace-events | 9 +++++++++ | 11 | tests/qemu-iotests/003 | 1 + |
11 | 2 files changed, 17 insertions(+), 21 deletions(-) | 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(-) | ||
12 | 32 | ||
13 | diff --git a/block/curl.c b/block/curl.c | 33 | diff --git a/tests/qemu-iotests/002 b/tests/qemu-iotests/002 |
14 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100755 |
15 | --- a/block/curl.c | 35 | --- a/tests/qemu-iotests/002 |
16 | +++ b/block/curl.c | 36 | +++ b/tests/qemu-iotests/002 |
17 | @@ -XXX,XX +XXX,XX @@ | 37 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
18 | #include "crypto/secret.h" | 38 | |
19 | #include <curl/curl.h> | 39 | _supported_fmt generic |
20 | #include "qemu/cutils.h" | 40 | _supported_proto generic |
21 | +#include "trace.h" | 41 | +_unsupported_imgopts "subformat=streamOptimized" |
22 | 42 | ||
23 | -// #define DEBUG_CURL | 43 | |
24 | // #define DEBUG_VERBOSE | 44 | size=128M |
25 | 45 | diff --git a/tests/qemu-iotests/003 b/tests/qemu-iotests/003 | |
26 | -#ifdef DEBUG_CURL | 46 | index XXXXXXX..XXXXXXX 100755 |
27 | -#define DEBUG_CURL_PRINT 1 | 47 | --- a/tests/qemu-iotests/003 |
28 | -#else | 48 | +++ b/tests/qemu-iotests/003 |
29 | -#define DEBUG_CURL_PRINT 0 | 49 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
30 | -#endif | 50 | |
31 | -#define DPRINTF(fmt, ...) \ | 51 | _supported_fmt generic |
32 | - do { \ | 52 | _supported_proto generic |
33 | - if (DEBUG_CURL_PRINT) { \ | 53 | +_unsupported_imgopts "subformat=streamOptimized" |
34 | - fprintf(stderr, fmt, ## __VA_ARGS__); \ | 54 | |
35 | - } \ | 55 | size=128M |
36 | - } while (0) | 56 | offset=67M |
37 | - | 57 | diff --git a/tests/qemu-iotests/005 b/tests/qemu-iotests/005 |
38 | #if LIBCURL_VERSION_NUM >= 0x071000 | 58 | index XXXXXXX..XXXXXXX 100755 |
39 | /* The multi interface timer callback was introduced in 7.16.0 */ | 59 | --- a/tests/qemu-iotests/005 |
40 | #define NEED_CURL_TIMER_CALLBACK | 60 | +++ b/tests/qemu-iotests/005 |
41 | @@ -XXX,XX +XXX,XX @@ static int curl_timer_cb(CURLM *multi, long timeout_ms, void *opaque) | 61 | @@ -XXX,XX +XXX,XX @@ _supported_fmt generic |
42 | { | 62 | _supported_proto generic |
43 | BDRVCURLState *s = opaque; | 63 | _supported_os Linux |
44 | 64 | _unsupported_imgopts "subformat=twoGbMaxExtentFlat" \ | |
45 | - DPRINTF("CURL: timer callback timeout_ms %ld\n", timeout_ms); | 65 | - "subformat=twoGbMaxExtentSparse" |
46 | + trace_curl_timer_cb(timeout_ms); | 66 | + "subformat=twoGbMaxExtentSparse" \ |
47 | if (timeout_ms == -1) { | 67 | + "subformat=streamOptimized" |
48 | timer_del(&s->timer); | 68 | |
49 | } else { | 69 | # vpc is limited to 127GB, so we can't test it here |
50 | @@ -XXX,XX +XXX,XX @@ static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action, | 70 | if [ "$IMGFMT" = "vpc" ]; then |
51 | } | 71 | diff --git a/tests/qemu-iotests/009 b/tests/qemu-iotests/009 |
52 | socket = NULL; | 72 | index XXXXXXX..XXXXXXX 100755 |
53 | 73 | --- a/tests/qemu-iotests/009 | |
54 | - DPRINTF("CURL (AIO): Sock action %d on fd %d\n", action, (int)fd); | 74 | +++ b/tests/qemu-iotests/009 |
55 | + trace_curl_sock_cb(action, (int)fd); | 75 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
56 | switch (action) { | 76 | |
57 | case CURL_POLL_IN: | 77 | _supported_fmt generic |
58 | aio_set_fd_handler(s->aio_context, fd, false, | 78 | _supported_proto generic |
59 | @@ -XXX,XX +XXX,XX @@ static size_t curl_read_cb(void *ptr, size_t size, size_t nmemb, void *opaque) | 79 | +_unsupported_imgopts "subformat=streamOptimized" |
60 | size_t realsize = size * nmemb; | 80 | |
61 | int i; | 81 | |
62 | 82 | size=6G | |
63 | - DPRINTF("CURL: Just reading %zd bytes\n", realsize); | 83 | diff --git a/tests/qemu-iotests/010 b/tests/qemu-iotests/010 |
64 | + trace_curl_read_cb(realsize); | 84 | index XXXXXXX..XXXXXXX 100755 |
65 | 85 | --- a/tests/qemu-iotests/010 | |
66 | if (!s || !s->orig_buf) { | 86 | +++ b/tests/qemu-iotests/010 |
67 | goto read_end; | 87 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
68 | @@ -XXX,XX +XXX,XX @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags, | 88 | |
69 | } | 89 | _supported_fmt generic |
70 | } | 90 | _supported_proto generic |
71 | 91 | +_unsupported_imgopts "subformat=streamOptimized" | |
72 | - DPRINTF("CURL: Opening %s\n", file); | 92 | |
73 | + trace_curl_open(file); | 93 | |
74 | qemu_co_queue_init(&s->free_state_waitq); | 94 | size=6G |
75 | s->aio_context = bdrv_get_aio_context(bs); | 95 | diff --git a/tests/qemu-iotests/011 b/tests/qemu-iotests/011 |
76 | s->url = g_strdup(file); | 96 | index XXXXXXX..XXXXXXX 100755 |
77 | @@ -XXX,XX +XXX,XX @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags, | 97 | --- a/tests/qemu-iotests/011 |
78 | "Server does not support 'range' (byte ranges)."); | 98 | +++ b/tests/qemu-iotests/011 |
79 | goto out; | 99 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
80 | } | 100 | |
81 | - DPRINTF("CURL: Size = %" PRIu64 "\n", s->len); | 101 | _supported_fmt generic |
82 | + trace_curl_open_size(s->len); | 102 | _supported_proto generic |
83 | 103 | +_unsupported_imgopts "subformat=streamOptimized" | |
84 | qemu_mutex_lock(&s->mutex); | 104 | |
85 | curl_clean_state(state); | 105 | |
86 | @@ -XXX,XX +XXX,XX @@ static void curl_setup_preadv(BlockDriverState *bs, CURLAIOCB *acb) | 106 | size=6G |
87 | state->acb[0] = acb; | 107 | diff --git a/tests/qemu-iotests/017 b/tests/qemu-iotests/017 |
88 | 108 | index XXXXXXX..XXXXXXX 100755 | |
89 | snprintf(state->range, 127, "%" PRIu64 "-%" PRIu64, start, end); | 109 | --- a/tests/qemu-iotests/017 |
90 | - DPRINTF("CURL (AIO): Reading %" PRIu64 " at %" PRIu64 " (%s)\n", | 110 | +++ b/tests/qemu-iotests/017 |
91 | - acb->bytes, start, state->range); | 111 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
92 | + trace_curl_setup_preadv(acb->bytes, start, state->range); | 112 | _supported_fmt qcow qcow2 vmdk qed |
93 | curl_easy_setopt(state->curl, CURLOPT_RANGE, state->range); | 113 | _supported_proto generic |
94 | 114 | _unsupported_proto vxhs | |
95 | curl_multi_add_handle(s->multi, state->curl); | 115 | -_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" |
96 | @@ -XXX,XX +XXX,XX @@ static void curl_close(BlockDriverState *bs) | 116 | +_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \ |
97 | { | 117 | + "subformat=streamOptimized" |
98 | BDRVCURLState *s = bs->opaque; | 118 | |
99 | 119 | TEST_OFFSETS="0 4294967296" | |
100 | - DPRINTF("CURL: Close\n"); | 120 | |
101 | + trace_curl_close(); | 121 | diff --git a/tests/qemu-iotests/018 b/tests/qemu-iotests/018 |
102 | curl_detach_aio_context(bs); | 122 | index XXXXXXX..XXXXXXX 100755 |
103 | qemu_mutex_destroy(&s->mutex); | 123 | --- a/tests/qemu-iotests/018 |
104 | 124 | +++ b/tests/qemu-iotests/018 | |
105 | diff --git a/block/trace-events b/block/trace-events | 125 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
106 | index XXXXXXX..XXXXXXX 100644 | 126 | _supported_fmt qcow qcow2 vmdk qed |
107 | --- a/block/trace-events | 127 | _supported_proto file |
108 | +++ b/block/trace-events | 128 | _supported_os Linux |
109 | @@ -XXX,XX +XXX,XX @@ ssh_write(int64_t offset, size_t size) "offset=%" PRIi64 " size=%zu" | 129 | -_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" |
110 | ssh_write_buf(void *buf, size_t size) "sftp_write buf=%p size=%zu" | 130 | +_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \ |
111 | ssh_write_return(ssize_t ret) "sftp_write returned %zd" | 131 | + "streamOptimized" |
112 | ssh_seek(int64_t offset) "seeking to offset=%" PRIi64 | 132 | |
113 | + | 133 | TEST_OFFSETS="0 4294967296" |
114 | +# block/curl.c | 134 | |
115 | +curl_timer_cb(long timeout_ms) "timer callback timeout_ms %ld" | 135 | diff --git a/tests/qemu-iotests/019 b/tests/qemu-iotests/019 |
116 | +curl_sock_cb(int action, int fd) "sock action %d on fd %d" | 136 | index XXXXXXX..XXXXXXX 100755 |
117 | +curl_read_cb(size_t realsize) "just reading %zu bytes" | 137 | --- a/tests/qemu-iotests/019 |
118 | +curl_open(const char *file) "opening %s" | 138 | +++ b/tests/qemu-iotests/019 |
119 | +curl_open_size(uint64_t size) "size = %" PRIu64 | 139 | @@ -XXX,XX +XXX,XX @@ _supported_proto file |
120 | +curl_setup_preadv(uint64_t bytes, uint64_t start, const char *range) "reading %" PRIu64 " at %" PRIu64 " (%s)" | 140 | _supported_os Linux |
121 | +curl_close(void) "close" | 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. | ||
122 | -- | 303 | -- |
123 | 2.20.1 | 304 | 2.21.0 |
124 | 305 | ||
125 | 306 | diff view generated by jsdifflib |
1 | To do this, we need to allow creating the NBD server on various ports | 1 | The error message for the test case where we have a quorum node for |
---|---|---|---|
2 | instead of a single one (which may not even work if you run just one | 2 | which no directory name can be generated is different: For |
3 | instance, because something entirely else might be using that port). | 3 | twoGbMaxExtentSparse, it complains that it cannot open the extent file. |
4 | 4 | For other (sub)formats, it just notes that it cannot determine the | |
5 | So we just pick a random port in [32768, 32768 + 1024) and try to create | 5 | backing file path. Both are fine, but just disable twoGbMaxExtentSparse |
6 | a server there. If that fails, we just retry until something sticks. | 6 | for simplicity's sake. |
7 | |||
8 | For the IPv6 test, we need a different range, though (just above that | ||
9 | one). This is because "localhost" resolves to both 127.0.0.1 and ::1. | ||
10 | This means that if you bind to it, it will bind to both, if possible, or | ||
11 | just one if the other is already in use. Therefore, if the IPv6 test | ||
12 | has already taken [::1]:some_port and we then try to take | ||
13 | localhost:some_port, that will work -- only the second server will be | ||
14 | bound to 127.0.0.1:some_port alone and not [::1]:some_port in addition. | ||
15 | So we have two different servers on the same port, one for IPv4 and one | ||
16 | for IPv6. | ||
17 | |||
18 | But when we then try to connect to the server through | ||
19 | localhost:some_port, we will always end up at the IPv6 one (as long as | ||
20 | it is up), and this may not be the one we want. | ||
21 | |||
22 | Thus, we must make sure not to create an IPv6-only NBD server on the | ||
23 | same port as a normal "dual-stack" NBD server -- which is done by using | ||
24 | distinct port ranges, as explained above. | ||
25 | 7 | ||
26 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 8 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
27 | Message-id: 20181221234750.23577-4-mreitz@redhat.com | 9 | Reviewed-by: John Snow <jsnow@redhat.com> |
10 | Message-id: 20190815153638.4600-7-mreitz@redhat.com | ||
28 | Reviewed-by: John Snow <jsnow@redhat.com> | 11 | Reviewed-by: John Snow <jsnow@redhat.com> |
29 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 12 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
30 | --- | 13 | --- |
31 | tests/qemu-iotests/147 | 98 +++++++++++++++++++++++++++++------------- | 14 | tests/qemu-iotests/110 | 3 ++- |
32 | 1 file changed, 68 insertions(+), 30 deletions(-) | 15 | 1 file changed, 2 insertions(+), 1 deletion(-) |
33 | 16 | ||
34 | diff --git a/tests/qemu-iotests/147 b/tests/qemu-iotests/147 | 17 | diff --git a/tests/qemu-iotests/110 b/tests/qemu-iotests/110 |
35 | index XXXXXXX..XXXXXXX 100755 | 18 | index XXXXXXX..XXXXXXX 100755 |
36 | --- a/tests/qemu-iotests/147 | 19 | --- a/tests/qemu-iotests/110 |
37 | +++ b/tests/qemu-iotests/147 | 20 | +++ b/tests/qemu-iotests/110 |
38 | @@ -XXX,XX +XXX,XX @@ | 21 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
39 | # | 22 | # Any format supporting backing files |
40 | 23 | _supported_fmt qed qcow qcow2 vmdk | |
41 | import os | 24 | _supported_proto file |
42 | +import random | 25 | -_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" |
43 | import socket | 26 | +_unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \ |
44 | import stat | 27 | + "subformat=twoGbMaxExtentSparse" |
45 | import time | 28 | |
46 | import iotests | 29 | TEST_IMG_REL=$(basename "$TEST_IMG") |
47 | -from iotests import cachemode, imgfmt, qemu_img, qemu_nbd | ||
48 | +from iotests import cachemode, imgfmt, qemu_img, qemu_nbd, qemu_nbd_pipe | ||
49 | |||
50 | -NBD_PORT = 10811 | ||
51 | +NBD_PORT_START = 32768 | ||
52 | +NBD_PORT_END = NBD_PORT_START + 1024 | ||
53 | +NBD_IPV6_PORT_START = NBD_PORT_END | ||
54 | +NBD_IPV6_PORT_END = NBD_IPV6_PORT_START + 1024 | ||
55 | |||
56 | test_img = os.path.join(iotests.test_dir, 'test.img') | ||
57 | unix_socket = os.path.join(iotests.test_dir, 'nbd.socket') | ||
58 | @@ -XXX,XX +XXX,XX @@ class QemuNBD(NBDBlockdevAddBase): | ||
59 | except OSError: | ||
60 | pass | ||
61 | |||
62 | + def _try_server_up(self, *args): | ||
63 | + status, msg = qemu_nbd_pipe('-f', imgfmt, test_img, *args) | ||
64 | + if status == 0: | ||
65 | + return True | ||
66 | + if 'Address already in use' in msg: | ||
67 | + return False | ||
68 | + self.fail(msg) | ||
69 | + | ||
70 | def _server_up(self, *args): | ||
71 | - self.assertEqual(qemu_nbd('-f', imgfmt, test_img, *args), 0) | ||
72 | + self.assertTrue(self._try_server_up(*args)) | ||
73 | |||
74 | def test_inet(self): | ||
75 | - self._server_up('-b', 'localhost', '-p', str(NBD_PORT)) | ||
76 | + while True: | ||
77 | + nbd_port = random.randrange(NBD_PORT_START, NBD_PORT_END) | ||
78 | + if self._try_server_up('-b', 'localhost', '-p', str(nbd_port)): | ||
79 | + break | ||
80 | + | ||
81 | address = { 'type': 'inet', | ||
82 | 'data': { | ||
83 | 'host': 'localhost', | ||
84 | - 'port': str(NBD_PORT) | ||
85 | + 'port': str(nbd_port) | ||
86 | } } | ||
87 | - self.client_test('nbd://localhost:%i' % NBD_PORT, | ||
88 | + self.client_test('nbd://localhost:%i' % nbd_port, | ||
89 | flatten_sock_addr(address)) | ||
90 | |||
91 | def test_unix(self): | ||
92 | @@ -XXX,XX +XXX,XX @@ class BuiltinNBD(NBDBlockdevAddBase): | ||
93 | except OSError: | ||
94 | pass | ||
95 | |||
96 | - def _server_up(self, address, export_name=None, export_name2=None): | ||
97 | + # Returns False on EADDRINUSE; fails an assertion on other errors. | ||
98 | + # Returns True on success. | ||
99 | + def _try_server_up(self, address, export_name=None, export_name2=None): | ||
100 | result = self.server.qmp('nbd-server-start', addr=address) | ||
101 | + if 'error' in result and \ | ||
102 | + 'Address already in use' in result['error']['desc']: | ||
103 | + return False | ||
104 | self.assert_qmp(result, 'return', {}) | ||
105 | |||
106 | if export_name is None: | ||
107 | @@ -XXX,XX +XXX,XX @@ class BuiltinNBD(NBDBlockdevAddBase): | ||
108 | name=export_name2) | ||
109 | self.assert_qmp(result, 'return', {}) | ||
110 | |||
111 | + return True | ||
112 | + | ||
113 | + def _server_up(self, address, export_name=None, export_name2=None): | ||
114 | + self.assertTrue(self._try_server_up(address, export_name, export_name2)) | ||
115 | |||
116 | def _server_down(self): | ||
117 | result = self.server.qmp('nbd-server-stop') | ||
118 | self.assert_qmp(result, 'return', {}) | ||
119 | |||
120 | def do_test_inet(self, export_name=None): | ||
121 | - address = { 'type': 'inet', | ||
122 | - 'data': { | ||
123 | - 'host': 'localhost', | ||
124 | - 'port': str(NBD_PORT) | ||
125 | - } } | ||
126 | - self._server_up(address, export_name) | ||
127 | + while True: | ||
128 | + nbd_port = random.randrange(NBD_PORT_START, NBD_PORT_END) | ||
129 | + address = { 'type': 'inet', | ||
130 | + 'data': { | ||
131 | + 'host': 'localhost', | ||
132 | + 'port': str(nbd_port) | ||
133 | + } } | ||
134 | + if self._try_server_up(address, export_name): | ||
135 | + break | ||
136 | + | ||
137 | export_name = export_name or 'nbd-export' | ||
138 | - self.client_test('nbd://localhost:%i/%s' % (NBD_PORT, export_name), | ||
139 | + self.client_test('nbd://localhost:%i/%s' % (nbd_port, export_name), | ||
140 | flatten_sock_addr(address), export_name) | ||
141 | self._server_down() | ||
142 | |||
143 | @@ -XXX,XX +XXX,XX @@ class BuiltinNBD(NBDBlockdevAddBase): | ||
144 | self.do_test_inet('shadow') | ||
145 | |||
146 | def test_inet_two_exports(self): | ||
147 | - address = { 'type': 'inet', | ||
148 | - 'data': { | ||
149 | - 'host': 'localhost', | ||
150 | - 'port': str(NBD_PORT) | ||
151 | - } } | ||
152 | - self._server_up(address, 'exp1', 'exp2') | ||
153 | - self.client_test('nbd://localhost:%i/%s' % (NBD_PORT, 'exp1'), | ||
154 | + while True: | ||
155 | + nbd_port = random.randrange(NBD_PORT_START, NBD_PORT_END) | ||
156 | + address = { 'type': 'inet', | ||
157 | + 'data': { | ||
158 | + 'host': 'localhost', | ||
159 | + 'port': str(nbd_port) | ||
160 | + } } | ||
161 | + if self._try_server_up(address, 'exp1', 'exp2'): | ||
162 | + break | ||
163 | + | ||
164 | + self.client_test('nbd://localhost:%i/%s' % (nbd_port, 'exp1'), | ||
165 | flatten_sock_addr(address), 'exp1', 'node1', False) | ||
166 | - self.client_test('nbd://localhost:%i/%s' % (NBD_PORT, 'exp2'), | ||
167 | + self.client_test('nbd://localhost:%i/%s' % (nbd_port, 'exp2'), | ||
168 | flatten_sock_addr(address), 'exp2', 'node2', False) | ||
169 | result = self.vm.qmp('blockdev-del', node_name='node1') | ||
170 | self.assert_qmp(result, 'return', {}) | ||
171 | @@ -XXX,XX +XXX,XX @@ class BuiltinNBD(NBDBlockdevAddBase): | ||
172 | except socket.gaierror: | ||
173 | # IPv6 not available, skip | ||
174 | return | ||
175 | - address = { 'type': 'inet', | ||
176 | - 'data': { | ||
177 | - 'host': '::1', | ||
178 | - 'port': str(NBD_PORT), | ||
179 | - 'ipv4': False, | ||
180 | - 'ipv6': True | ||
181 | - } } | ||
182 | + | ||
183 | + while True: | ||
184 | + nbd_port = random.randrange(NBD_IPV6_PORT_START, NBD_IPV6_PORT_END) | ||
185 | + address = { 'type': 'inet', | ||
186 | + 'data': { | ||
187 | + 'host': '::1', | ||
188 | + 'port': str(nbd_port), | ||
189 | + 'ipv4': False, | ||
190 | + 'ipv6': True | ||
191 | + } } | ||
192 | + if self._try_server_up(address): | ||
193 | + break | ||
194 | + | ||
195 | filename = { 'driver': 'raw', | ||
196 | 'file': { | ||
197 | 'driver': 'nbd', | ||
198 | 'export': 'nbd-export', | ||
199 | 'server': flatten_sock_addr(address) | ||
200 | } } | ||
201 | - self._server_up(address) | ||
202 | self.client_test(filename, flatten_sock_addr(address), 'nbd-export') | ||
203 | self._server_down() | ||
204 | 30 | ||
205 | -- | 31 | -- |
206 | 2.20.1 | 32 | 2.21.0 |
207 | 33 | ||
208 | 34 | diff view generated by jsdifflib |
1 | In some cases, we may want to deal with qemu-nbd errors (e.g. by | 1 | iotest 126 requires backing file support, which flat vmdks cannot offer. |
---|---|---|---|
2 | launching it in a different configuration until it no longer throws | 2 | Skip this test for such subformats. |
3 | any). In that case, we do not want its output ending up in the test | ||
4 | output. | ||
5 | |||
6 | It may still be useful for handling the error, though, so add a new | ||
7 | function that works basically like qemu_nbd(), only that it returns the | ||
8 | qemu-nbd output instead of making it end up in the log. In contrast to | ||
9 | qemu_img_pipe(), it does still return the exit code as well, though, | ||
10 | because that is even more important for error handling. | ||
11 | 3 | ||
12 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 4 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
13 | Message-id: 20181221234750.23577-2-mreitz@redhat.com | 5 | Message-id: 20190815153638.4600-8-mreitz@redhat.com |
14 | Reviewed-by: John Snow <jsnow@redhat.com> | 6 | Reviewed-by: John Snow <jsnow@redhat.com> |
15 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
16 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 7 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
17 | --- | 8 | --- |
18 | tests/qemu-iotests/iotests.py | 14 ++++++++++++++ | 9 | tests/qemu-iotests/126 | 2 ++ |
19 | 1 file changed, 14 insertions(+) | 10 | 1 file changed, 2 insertions(+) |
20 | 11 | ||
21 | diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py | 12 | diff --git a/tests/qemu-iotests/126 b/tests/qemu-iotests/126 |
22 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100755 |
23 | --- a/tests/qemu-iotests/iotests.py | 14 | --- a/tests/qemu-iotests/126 |
24 | +++ b/tests/qemu-iotests/iotests.py | 15 | +++ b/tests/qemu-iotests/126 |
25 | @@ -XXX,XX +XXX,XX @@ def qemu_nbd(*args): | 16 | @@ -XXX,XX +XXX,XX @@ status=1 # failure is the default! |
26 | '''Run qemu-nbd in daemon mode and return the parent's exit code''' | 17 | |
27 | return subprocess.call(qemu_nbd_args + ['--fork'] + list(args)) | 18 | # Needs backing file support |
28 | 19 | _supported_fmt qcow qcow2 qed vmdk | |
29 | +def qemu_nbd_pipe(*args): | 20 | +_unsupported_imgopts "subformat=monolithicFlat" \ |
30 | + '''Run qemu-nbd in daemon mode and return both the parent's exit code | 21 | + "subformat=twoGbMaxExtentFlat" |
31 | + and its output''' | 22 | # This is the default protocol (and we want to test the difference between |
32 | + subp = subprocess.Popen(qemu_nbd_args + ['--fork'] + list(args), | 23 | # colons which separate a protocol prefix from the rest and colons which are |
33 | + stdout=subprocess.PIPE, | 24 | # just part of the filename, so we cannot test protocols which require a prefix) |
34 | + stderr=subprocess.STDOUT, | ||
35 | + universal_newlines=True) | ||
36 | + exitcode = subp.wait() | ||
37 | + if exitcode < 0: | ||
38 | + sys.stderr.write('qemu-nbd received signal %i: %s\n' % | ||
39 | + (-exitcode, | ||
40 | + ' '.join(qemu_nbd_args + ['--fork'] + list(args)))) | ||
41 | + return exitcode, subp.communicate()[0] | ||
42 | + | ||
43 | def compare_images(img1, img2, fmt1=imgfmt, fmt2=imgfmt): | ||
44 | '''Return True if two image files are identical''' | ||
45 | return qemu_img('compare', '-f', fmt1, | ||
46 | -- | 25 | -- |
47 | 2.20.1 | 26 | 2.21.0 |
48 | 27 | ||
49 | 28 | diff view generated by jsdifflib |
1 | From: Laurent Vivier <lvivier@redhat.com> | 1 | From: Stefan Hajnoczi <stefanha@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Laurent Vivier <lvivier@redhat.com> | 3 | Fixes: a6b257a08e3d72219f03e461a52152672fec0612 |
4 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 4 | ("file-posix: Handle undetectable alignment") |
5 | Message-id: 20181213162727.17438-4-lvivier@redhat.com | 5 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
6 | Message-id: 20190827101328.4062-1-stefanha@redhat.com | ||
7 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
6 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 8 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
7 | --- | 9 | --- |
8 | block/file-posix.c | 25 ++++++------------------- | 10 | block/file-posix.c | 2 +- |
9 | block/trace-events | 7 +++++++ | 11 | 1 file changed, 1 insertion(+), 1 deletion(-) |
10 | 2 files changed, 13 insertions(+), 19 deletions(-) | ||
11 | 12 | ||
12 | diff --git a/block/file-posix.c b/block/file-posix.c | 13 | diff --git a/block/file-posix.c b/block/file-posix.c |
13 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/block/file-posix.c | 15 | --- a/block/file-posix.c |
15 | +++ b/block/file-posix.c | 16 | +++ b/block/file-posix.c |
16 | @@ -XXX,XX +XXX,XX @@ | 17 | @@ -XXX,XX +XXX,XX @@ static void raw_probe_alignment(BlockDriverState *bs, int fd, Error **errp) |
17 | #include <xfs/xfs.h> | 18 | for (i = 0; i < ARRAY_SIZE(alignments); i++) { |
18 | #endif | 19 | align = alignments[i]; |
19 | 20 | if (raw_is_io_aligned(fd, buf + align, max_align)) { | |
20 | -//#define DEBUG_BLOCK | 21 | - /* Fallback to request_aligment. */ |
21 | - | 22 | + /* Fallback to request_alignment. */ |
22 | -#ifdef DEBUG_BLOCK | 23 | s->buf_align = (align != 1) ? align : bs->bl.request_alignment; |
23 | -# define DEBUG_BLOCK_PRINT 1 | 24 | break; |
24 | -#else | 25 | } |
25 | -# define DEBUG_BLOCK_PRINT 0 | ||
26 | -#endif | ||
27 | -#define DPRINTF(fmt, ...) \ | ||
28 | -do { \ | ||
29 | - if (DEBUG_BLOCK_PRINT) { \ | ||
30 | - printf(fmt, ## __VA_ARGS__); \ | ||
31 | - } \ | ||
32 | -} while (0) | ||
33 | +#include "trace.h" | ||
34 | |||
35 | /* OS X does not have O_DSYNC */ | ||
36 | #ifndef O_DSYNC | ||
37 | @@ -XXX,XX +XXX,XX @@ static int xfs_write_zeroes(BDRVRawState *s, int64_t offset, uint64_t bytes) | ||
38 | |||
39 | if (xfsctl(NULL, s->fd, XFS_IOC_ZERO_RANGE, &fl) < 0) { | ||
40 | err = errno; | ||
41 | - DPRINTF("cannot write zero range (%s)\n", strerror(errno)); | ||
42 | + trace_file_xfs_write_zeroes(strerror(errno)); | ||
43 | return -err; | ||
44 | } | ||
45 | |||
46 | @@ -XXX,XX +XXX,XX @@ static int xfs_discard(BDRVRawState *s, int64_t offset, uint64_t bytes) | ||
47 | |||
48 | if (xfsctl(NULL, s->fd, XFS_IOC_UNRESVSP64, &fl) < 0) { | ||
49 | err = errno; | ||
50 | - DPRINTF("cannot punch hole (%s)\n", strerror(errno)); | ||
51 | + trace_file_xfs_discard(strerror(errno)); | ||
52 | return -err; | ||
53 | } | ||
54 | |||
55 | @@ -XXX,XX +XXX,XX @@ static char *FindEjectableOpticalMedia(io_iterator_t *mediaIterator) | ||
56 | |||
57 | /* If a match was found, leave the loop */ | ||
58 | if (*mediaIterator != 0) { | ||
59 | - DPRINTF("Matching using %s\n", matching_array[index]); | ||
60 | + trace_file_FindEjectableOpticalMedia(matching_array[index]); | ||
61 | mediaType = g_strdup(matching_array[index]); | ||
62 | break; | ||
63 | } | ||
64 | @@ -XXX,XX +XXX,XX @@ static bool setup_cdrom(char *bsd_path, Error **errp) | ||
65 | if (partition_found == false) { | ||
66 | error_setg(errp, "Failed to find a working partition on disc"); | ||
67 | } else { | ||
68 | - DPRINTF("Using %s as optical disc\n", test_partition); | ||
69 | + trace_file_setup_cdrom(test_partition); | ||
70 | pstrcpy(bsd_path, MAXPATHLEN, test_partition); | ||
71 | } | ||
72 | return partition_found; | ||
73 | @@ -XXX,XX +XXX,XX @@ static bool hdev_is_sg(BlockDriverState *bs) | ||
74 | |||
75 | ret = ioctl(s->fd, SG_GET_SCSI_ID, &scsiid); | ||
76 | if (ret >= 0) { | ||
77 | - DPRINTF("SG device found: type=%d, version=%d\n", | ||
78 | - scsiid.scsi_type, sg_version); | ||
79 | + trace_file_hdev_is_sg(scsiid.scsi_type, sg_version); | ||
80 | return true; | ||
81 | } | ||
82 | |||
83 | diff --git a/block/trace-events b/block/trace-events | ||
84 | index XXXXXXX..XXXXXXX 100644 | ||
85 | --- a/block/trace-events | ||
86 | +++ b/block/trace-events | ||
87 | @@ -XXX,XX +XXX,XX @@ curl_open(const char *file) "opening %s" | ||
88 | curl_open_size(uint64_t size) "size = %" PRIu64 | ||
89 | curl_setup_preadv(uint64_t bytes, uint64_t start, const char *range) "reading %" PRIu64 " at %" PRIu64 " (%s)" | ||
90 | curl_close(void) "close" | ||
91 | + | ||
92 | +# block/file-posix.c | ||
93 | +file_xfs_write_zeroes(const char *error) "cannot write zero range (%s)" | ||
94 | +file_xfs_discard(const char *error) "cannot punch hole (%s)" | ||
95 | +file_FindEjectableOpticalMedia(const char *media) "Matching using %s" | ||
96 | +file_setup_cdrom(const char *partition) "Using %s as optical disc" | ||
97 | +file_hdev_is_sg(int type, int version) "SG device found: type=%d, version=%d" | ||
98 | -- | 26 | -- |
99 | 2.20.1 | 27 | 2.21.0 |
100 | 28 | ||
101 | 29 | diff view generated by jsdifflib |
1 | From: Laurent Vivier <lvivier@redhat.com> | 1 | From: Thomas Huth <thuth@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Laurent Vivier <lvivier@redhat.com> | 3 | It is possible to enable only a subset of the block drivers with the |
4 | Reviewed-by: Richard W.M. Jones <rjones@redhat.com> | 4 | "--block-drv-rw-whitelist" option of the "configure" script. All other |
5 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 5 | drivers are marked as unusable (or only included as read-only with the |
6 | Message-id: 20181213162727.17438-2-lvivier@redhat.com | 6 | "--block-drv-ro-whitelist" option). If an iotest is now using such a |
7 | [mreitz: Fixed type of ssh_{read,write}_return's parameter to be ssize_t | 7 | disabled block driver, it is failing - which is bad, since at least the |
8 | instead of size_t] | 8 | tests in the "auto" group should be able to deal with this situation. |
9 | Thus let's introduce a "_require_drivers" function that can be used by | ||
10 | the shell tests to check for the availability of certain drivers first, | ||
11 | and marks the test as "not run" if one of the drivers is missing. | ||
12 | |||
13 | This patch mainly targets the test in the "auto" group which should | ||
14 | never fail in such a case, but also improves some of the other tests | ||
15 | along the way. Note that we also assume that the "qcow2" and "file" | ||
16 | drivers are always available - otherwise it does not make sense to | ||
17 | run "make check-block" at all (which only tests with qcow2 by default). | ||
18 | |||
19 | Signed-off-by: Thomas Huth <thuth@redhat.com> | ||
20 | Message-id: 20190823133552.11680-1-thuth@redhat.com | ||
9 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 21 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
10 | --- | 22 | --- |
11 | block/ssh.c | 46 +++++++++++++++++----------------------------- | 23 | tests/qemu-iotests/071 | 1 + |
12 | block/trace-events | 17 +++++++++++++++++ | 24 | tests/qemu-iotests/081 | 4 +--- |
13 | 2 files changed, 34 insertions(+), 29 deletions(-) | 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(-) | ||
14 | 32 | ||
15 | diff --git a/block/ssh.c b/block/ssh.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 | ||
16 | index XXXXXXX..XXXXXXX 100644 | 131 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/block/ssh.c | 132 | --- a/tests/qemu-iotests/common.rc |
18 | +++ b/block/ssh.c | 133 | +++ b/tests/qemu-iotests/common.rc |
19 | @@ -XXX,XX +XXX,XX @@ | 134 | @@ -XXX,XX +XXX,XX @@ _require_command() |
20 | #include "qapi/qmp/qstring.h" | 135 | [ -x "$c" ] || _notrun "$1 utility required, skipped this test" |
21 | #include "qapi/qobject-input-visitor.h" | ||
22 | #include "qapi/qobject-output-visitor.h" | ||
23 | +#include "trace.h" | ||
24 | |||
25 | -/* DEBUG_SSH=1 enables the DPRINTF (debugging printf) statements in | ||
26 | - * this block driver code. | ||
27 | - * | ||
28 | +/* | ||
29 | * TRACE_LIBSSH2=<bitmask> enables tracing in libssh2 itself. Note | ||
30 | * that this requires that libssh2 was specially compiled with the | ||
31 | * `./configure --enable-debug' option, so most likely you will have | ||
32 | * to compile it yourself. The meaning of <bitmask> is described | ||
33 | * here: http://www.libssh2.org/libssh2_trace.html | ||
34 | */ | ||
35 | -#define DEBUG_SSH 0 | ||
36 | #define TRACE_LIBSSH2 0 /* or try: LIBSSH2_TRACE_SFTP */ | ||
37 | |||
38 | -#define DPRINTF(fmt, ...) \ | ||
39 | - do { \ | ||
40 | - if (DEBUG_SSH) { \ | ||
41 | - fprintf(stderr, "ssh: %-15s " fmt "\n", \ | ||
42 | - __func__, ##__VA_ARGS__); \ | ||
43 | - } \ | ||
44 | - } while (0) | ||
45 | - | ||
46 | typedef struct BDRVSSHState { | ||
47 | /* Coroutine. */ | ||
48 | CoMutex lock; | ||
49 | @@ -XXX,XX +XXX,XX @@ static int check_host_key_knownhosts(BDRVSSHState *s, | ||
50 | switch (r) { | ||
51 | case LIBSSH2_KNOWNHOST_CHECK_MATCH: | ||
52 | /* OK */ | ||
53 | - DPRINTF("host key OK: %s", found->key); | ||
54 | + trace_ssh_check_host_key_knownhosts(found->key); | ||
55 | break; | ||
56 | case LIBSSH2_KNOWNHOST_CHECK_MISMATCH: | ||
57 | ret = -EINVAL; | ||
58 | @@ -XXX,XX +XXX,XX @@ static int connect_to_ssh(BDRVSSHState *s, BlockdevOptionsSsh *opts, | ||
59 | } | ||
60 | |||
61 | /* Open the remote file. */ | ||
62 | - DPRINTF("opening file %s flags=0x%x creat_mode=0%o", | ||
63 | - opts->path, ssh_flags, creat_mode); | ||
64 | + trace_ssh_connect_to_ssh(opts->path, ssh_flags, creat_mode); | ||
65 | s->sftp_handle = libssh2_sftp_open(s->sftp, opts->path, ssh_flags, | ||
66 | creat_mode); | ||
67 | if (!s->sftp_handle) { | ||
68 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn ssh_co_create_opts(const char *filename, QemuOpts *opts, | ||
69 | /* Get desired file size. */ | ||
70 | ssh_opts->size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0), | ||
71 | BDRV_SECTOR_SIZE); | ||
72 | - DPRINTF("total_size=%" PRIi64, ssh_opts->size); | ||
73 | + trace_ssh_co_create_opts(ssh_opts->size); | ||
74 | |||
75 | uri_options = qdict_new(); | ||
76 | ret = parse_uri(filename, uri_options, errp); | ||
77 | @@ -XXX,XX +XXX,XX @@ static void restart_coroutine(void *opaque) | ||
78 | BDRVSSHState *s = bs->opaque; | ||
79 | AioContext *ctx = bdrv_get_aio_context(bs); | ||
80 | |||
81 | - DPRINTF("co=%p", restart->co); | ||
82 | + trace_ssh_restart_coroutine(restart->co); | ||
83 | aio_set_fd_handler(ctx, s->sock, false, NULL, NULL, NULL, NULL); | ||
84 | |||
85 | aio_co_wake(restart->co); | ||
86 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn void co_yield(BDRVSSHState *s, BlockDriverState *bs) | ||
87 | wr_handler = restart_coroutine; | ||
88 | } | ||
89 | |||
90 | - DPRINTF("s->sock=%d rd_handler=%p wr_handler=%p", s->sock, | ||
91 | - rd_handler, wr_handler); | ||
92 | + trace_ssh_co_yield(s->sock, rd_handler, wr_handler); | ||
93 | |||
94 | aio_set_fd_handler(bdrv_get_aio_context(bs), s->sock, | ||
95 | false, rd_handler, wr_handler, NULL, &restart); | ||
96 | qemu_coroutine_yield(); | ||
97 | - DPRINTF("s->sock=%d - back", s->sock); | ||
98 | + trace_ssh_co_yield_back(s->sock); | ||
99 | } | 136 | } |
100 | 137 | ||
101 | /* SFTP has a function `libssh2_sftp_seek64' which seeks to a position | 138 | +# Check that a set of drivers has been whitelisted in the QEMU binary |
102 | @@ -XXX,XX +XXX,XX @@ static void ssh_seek(BDRVSSHState *s, int64_t offset, int flags) | 139 | +# |
103 | bool force = (flags & SSH_SEEK_FORCE) != 0; | 140 | +_require_drivers() |
104 | 141 | +{ | |
105 | if (force || op_read != s->offset_op_read || offset != s->offset) { | 142 | + available=$($QEMU -drive format=help | \ |
106 | - DPRINTF("seeking to offset=%" PRIi64, offset); | 143 | + sed -e '/Supported formats:/!d' -e 's/Supported formats://') |
107 | + trace_ssh_seek(offset); | 144 | + for driver |
108 | libssh2_sftp_seek64(s->sftp_handle, offset); | 145 | + do |
109 | s->offset = offset; | 146 | + if ! echo "$available" | grep -q " $driver\( \|$\)"; then |
110 | s->offset_op_read = op_read; | 147 | + _notrun "$driver not available" |
111 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn int ssh_read(BDRVSSHState *s, BlockDriverState *bs, | 148 | + fi |
112 | char *buf, *end_of_vec; | 149 | + done |
113 | struct iovec *i; | 150 | +} |
114 | |||
115 | - DPRINTF("offset=%" PRIi64 " size=%zu", offset, size); | ||
116 | + trace_ssh_read(offset, size); | ||
117 | |||
118 | ssh_seek(s, offset, SSH_SEEK_READ); | ||
119 | |||
120 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn int ssh_read(BDRVSSHState *s, BlockDriverState *bs, | ||
121 | */ | ||
122 | for (got = 0; got < size; ) { | ||
123 | again: | ||
124 | - DPRINTF("sftp_read buf=%p size=%zu", buf, end_of_vec - buf); | ||
125 | + trace_ssh_read_buf(buf, end_of_vec - buf); | ||
126 | r = libssh2_sftp_read(s->sftp_handle, buf, end_of_vec - buf); | ||
127 | - DPRINTF("sftp_read returned %zd", r); | ||
128 | + trace_ssh_read_return(r); | ||
129 | |||
130 | if (r == LIBSSH2_ERROR_EAGAIN || r == LIBSSH2_ERROR_TIMEOUT) { | ||
131 | co_yield(s, bs); | ||
132 | @@ -XXX,XX +XXX,XX @@ static int ssh_write(BDRVSSHState *s, BlockDriverState *bs, | ||
133 | char *buf, *end_of_vec; | ||
134 | struct iovec *i; | ||
135 | |||
136 | - DPRINTF("offset=%" PRIi64 " size=%zu", offset, size); | ||
137 | + trace_ssh_write(offset, size); | ||
138 | |||
139 | ssh_seek(s, offset, SSH_SEEK_WRITE); | ||
140 | |||
141 | @@ -XXX,XX +XXX,XX @@ static int ssh_write(BDRVSSHState *s, BlockDriverState *bs, | ||
142 | |||
143 | for (written = 0; written < size; ) { | ||
144 | again: | ||
145 | - DPRINTF("sftp_write buf=%p size=%zu", buf, end_of_vec - buf); | ||
146 | + trace_ssh_write_buf(buf, end_of_vec - buf); | ||
147 | r = libssh2_sftp_write(s->sftp_handle, buf, end_of_vec - buf); | ||
148 | - DPRINTF("sftp_write returned %zd", r); | ||
149 | + trace_ssh_write_return(r); | ||
150 | |||
151 | if (r == LIBSSH2_ERROR_EAGAIN || r == LIBSSH2_ERROR_TIMEOUT) { | ||
152 | co_yield(s, bs); | ||
153 | @@ -XXX,XX +XXX,XX @@ static coroutine_fn int ssh_flush(BDRVSSHState *s, BlockDriverState *bs) | ||
154 | { | ||
155 | int r; | ||
156 | |||
157 | - DPRINTF("fsync"); | ||
158 | + trace_ssh_flush(); | ||
159 | again: | ||
160 | r = libssh2_sftp_fsync(s->sftp_handle); | ||
161 | if (r == LIBSSH2_ERROR_EAGAIN || r == LIBSSH2_ERROR_TIMEOUT) { | ||
162 | @@ -XXX,XX +XXX,XX @@ static int64_t ssh_getlength(BlockDriverState *bs) | ||
163 | |||
164 | /* Note we cannot make a libssh2 call here. */ | ||
165 | length = (int64_t) s->attrs.filesize; | ||
166 | - DPRINTF("length=%" PRIi64, length); | ||
167 | + trace_ssh_getlength(length); | ||
168 | |||
169 | return length; | ||
170 | } | ||
171 | diff --git a/block/trace-events b/block/trace-events | ||
172 | index XXXXXXX..XXXXXXX 100644 | ||
173 | --- a/block/trace-events | ||
174 | +++ b/block/trace-events | ||
175 | @@ -XXX,XX +XXX,XX @@ iscsi_xcopy(void *src_lun, uint64_t src_off, void *dst_lun, uint64_t dst_off, ui | ||
176 | # block/nbd-client.c | ||
177 | nbd_read_reply_entry_fail(int ret, const char *err) "ret = %d, err: %s" | ||
178 | nbd_co_request_fail(uint64_t from, uint32_t len, uint64_t handle, uint16_t flags, uint16_t type, const char *name, int ret, const char *err) "Request failed { .from = %" PRIu64", .len = %" PRIu32 ", .handle = %" PRIu64 ", .flags = 0x%" PRIx16 ", .type = %" PRIu16 " (%s) } ret = %d, err: %s" | ||
179 | + | 151 | + |
180 | +# block/ssh.c | 152 | # make sure this script returns success |
181 | +ssh_restart_coroutine(void *co) "co=%p" | 153 | true |
182 | +ssh_flush(void) "fsync" | ||
183 | +ssh_check_host_key_knownhosts(const char *key) "host key OK: %s" | ||
184 | +ssh_connect_to_ssh(char *path, int flags, int mode) "opening file %s flags=0x%x creat_mode=0%o" | ||
185 | +ssh_co_yield(int sock, void *rd_handler, void *wr_handler) "s->sock=%d rd_handler=%p wr_handler=%p" | ||
186 | +ssh_co_yield_back(int sock) "s->sock=%d - back" | ||
187 | +ssh_getlength(int64_t length) "length=%" PRIi64 | ||
188 | +ssh_co_create_opts(uint64_t size) "total_size=%" PRIu64 | ||
189 | +ssh_read(int64_t offset, size_t size) "offset=%" PRIi64 " size=%zu" | ||
190 | +ssh_read_buf(void *buf, size_t size) "sftp_read buf=%p size=%zu" | ||
191 | +ssh_read_return(ssize_t ret) "sftp_read returned %zd" | ||
192 | +ssh_write(int64_t offset, size_t size) "offset=%" PRIi64 " size=%zu" | ||
193 | +ssh_write_buf(void *buf, size_t size) "sftp_write buf=%p size=%zu" | ||
194 | +ssh_write_return(ssize_t ret) "sftp_write returned %zd" | ||
195 | +ssh_seek(int64_t offset) "seeking to offset=%" PRIi64 | ||
196 | -- | 154 | -- |
197 | 2.20.1 | 155 | 2.21.0 |
198 | 156 | ||
199 | 157 | diff view generated by jsdifflib |
1 | From: "Richard W.M. Jones" <rjones@redhat.com> | 1 | From: Thomas Huth <thuth@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | On FreeBSD 11.2: | 3 | The sanitizers (especially the address sanitizer from Clang) are |
4 | sometimes printing out warnings or false positives - this spoils | ||
5 | the output of the iotests, causing some of the tests to fail. | ||
6 | Thus let's skip the automatic iotests during "make check" when the | ||
7 | user configured QEMU with --enable-sanitizers. | ||
4 | 8 | ||
5 | $ nbdkit memory size=1M --run './qemu-io -f raw -c "aio_write 0 512" $nbd' | 9 | Signed-off-by: Thomas Huth <thuth@redhat.com> |
6 | Parsing error: non-numeric argument, or extraneous/unrecognized suffix -- aio_write | 10 | Message-id: 20190823084203.29734-1-thuth@redhat.com |
7 | |||
8 | After main option parsing, we reinitialize optind so we can parse each | ||
9 | command. However reinitializing optind to 0 does not work on FreeBSD. | ||
10 | What happens when you do this is optind remains 0 after the option | ||
11 | parsing loop, and the result is we try to parse argv[optind] == | ||
12 | argv[0] == "aio_write" as if it was the first parameter. | ||
13 | |||
14 | The FreeBSD manual page says: | ||
15 | |||
16 | In order to use getopt() to evaluate multiple sets of arguments, or to | ||
17 | evaluate a single set of arguments multiple times, the variable optreset | ||
18 | must be set to 1 before the second and each additional set of calls to | ||
19 | getopt(), and the variable optind must be reinitialized. | ||
20 | |||
21 | (From the rest of the man page it is clear that optind must be | ||
22 | reinitialized to 1). | ||
23 | |||
24 | The glibc man page says: | ||
25 | |||
26 | A program that scans multiple argument vectors, or rescans the same | ||
27 | vector more than once, and wants to make use of GNU extensions such as | ||
28 | '+' and '-' at the start of optstring, or changes the value of | ||
29 | POSIXLY_CORRECT between scans, must reinitialize getopt() by resetting | ||
30 | optind to 0, rather than the traditional value of 1. (Resetting to 0 | ||
31 | forces the invocation of an internal initialization routine that | ||
32 | rechecks POSIXLY_CORRECT and checks for GNU extensions in optstring.) | ||
33 | |||
34 | This commit introduces an OS-portability function called | ||
35 | qemu_reset_optind which provides a way of resetting optind that works | ||
36 | on FreeBSD and platforms that use optreset, while keeping it the same | ||
37 | as now on other platforms. | ||
38 | |||
39 | Note that the qemu codebase sets optind in many other places, but in | ||
40 | those other places it's setting a local variable and not using getopt. | ||
41 | This change is only needed in places where we are using getopt and the | ||
42 | associated global variable optind. | ||
43 | |||
44 | Signed-off-by: Richard W.M. Jones <rjones@redhat.com> | ||
45 | Message-id: 20190118101114.11759-2-rjones@redhat.com | ||
46 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | ||
47 | Reviewed-by: Eric Blake <eblake@redhat.com> | ||
48 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 11 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
49 | --- | 12 | --- |
50 | configure | 14 ++++++++++++++ | 13 | tests/check-block.sh | 5 +++++ |
51 | include/qemu/osdep.h | 16 ++++++++++++++++ | 14 | 1 file changed, 5 insertions(+) |
52 | qemu-img.c | 2 +- | ||
53 | qemu-io-cmds.c | 2 +- | ||
54 | 4 files changed, 32 insertions(+), 2 deletions(-) | ||
55 | 15 | ||
56 | diff --git a/configure b/configure | 16 | diff --git a/tests/check-block.sh b/tests/check-block.sh |
57 | index XXXXXXX..XXXXXXX 100755 | 17 | index XXXXXXX..XXXXXXX 100755 |
58 | --- a/configure | 18 | --- a/tests/check-block.sh |
59 | +++ b/configure | 19 | +++ b/tests/check-block.sh |
60 | @@ -XXX,XX +XXX,XX @@ if compile_prog "" "" ; then | 20 | @@ -XXX,XX +XXX,XX @@ if grep -q "TARGET_GPROF=y" *-softmmu/config-target.mak 2>/dev/null ; then |
61 | signalfd=yes | 21 | exit 0 |
62 | fi | 22 | fi |
63 | 23 | ||
64 | +# check if optreset global is declared by <getopt.h> | 24 | +if grep -q "CFLAGS.*-fsanitize" config-host.mak 2>/dev/null ; then |
65 | +optreset="no" | 25 | + echo "Sanitizers are enabled ==> Not running the qemu-iotests." |
66 | +cat > $TMPC << EOF | 26 | + exit 0 |
67 | +#include <getopt.h> | ||
68 | +int main(void) { return optreset; } | ||
69 | +EOF | ||
70 | + | ||
71 | +if compile_prog "" "" ; then | ||
72 | + optreset=yes | ||
73 | +fi | 27 | +fi |
74 | + | 28 | + |
75 | # check if eventfd is supported | 29 | if [ -z "$(find . -name 'qemu-system-*' -print)" ]; then |
76 | eventfd=no | 30 | echo "No qemu-system binary available ==> Not running the qemu-iotests." |
77 | cat > $TMPC << EOF | 31 | exit 0 |
78 | @@ -XXX,XX +XXX,XX @@ fi | ||
79 | if test "$signalfd" = "yes" ; then | ||
80 | echo "CONFIG_SIGNALFD=y" >> $config_host_mak | ||
81 | fi | ||
82 | +if test "$optreset" = "yes" ; then | ||
83 | + echo "HAVE_OPTRESET=y" >> $config_host_mak | ||
84 | +fi | ||
85 | if test "$tcg" = "yes"; then | ||
86 | echo "CONFIG_TCG=y" >> $config_host_mak | ||
87 | if test "$tcg_interpreter" = "yes" ; then | ||
88 | diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h | ||
89 | index XXXXXXX..XXXXXXX 100644 | ||
90 | --- a/include/qemu/osdep.h | ||
91 | +++ b/include/qemu/osdep.h | ||
92 | @@ -XXX,XX +XXX,XX @@ extern int daemon(int, int); | ||
93 | #include <ctype.h> | ||
94 | #include <errno.h> | ||
95 | #include <fcntl.h> | ||
96 | +#include <getopt.h> | ||
97 | #include <sys/stat.h> | ||
98 | #include <sys/time.h> | ||
99 | #include <assert.h> | ||
100 | @@ -XXX,XX +XXX,XX @@ extern int qemu_icache_linesize_log; | ||
101 | extern int qemu_dcache_linesize; | ||
102 | extern int qemu_dcache_linesize_log; | ||
103 | |||
104 | +/* | ||
105 | + * After using getopt or getopt_long, if you need to parse another set | ||
106 | + * of options, then you must reset optind. Unfortunately the way to | ||
107 | + * do this varies between implementations of getopt. | ||
108 | + */ | ||
109 | +static inline void qemu_reset_optind(void) | ||
110 | +{ | ||
111 | +#ifdef HAVE_OPTRESET | ||
112 | + optind = 1; | ||
113 | + optreset = 1; | ||
114 | +#else | ||
115 | + optind = 0; | ||
116 | +#endif | ||
117 | +} | ||
118 | + | ||
119 | #endif | ||
120 | diff --git a/qemu-img.c b/qemu-img.c | ||
121 | index XXXXXXX..XXXXXXX 100644 | ||
122 | --- a/qemu-img.c | ||
123 | +++ b/qemu-img.c | ||
124 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv) | ||
125 | return 0; | ||
126 | } | ||
127 | argv += optind; | ||
128 | - optind = 0; | ||
129 | + qemu_reset_optind(); | ||
130 | |||
131 | if (!trace_init_backends()) { | ||
132 | exit(1); | ||
133 | diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c | ||
134 | index XXXXXXX..XXXXXXX 100644 | ||
135 | --- a/qemu-io-cmds.c | ||
136 | +++ b/qemu-io-cmds.c | ||
137 | @@ -XXX,XX +XXX,XX @@ static int command(BlockBackend *blk, const cmdinfo_t *ct, int argc, | ||
138 | } | ||
139 | } | ||
140 | |||
141 | - optind = 0; | ||
142 | + qemu_reset_optind(); | ||
143 | return ct->cfunc(blk, argc, argv); | ||
144 | } | ||
145 | |||
146 | -- | 32 | -- |
147 | 2.20.1 | 33 | 2.21.0 |
148 | 34 | ||
149 | 35 | diff view generated by jsdifflib |
1 | From: Li Qiang <liq3ea@163.com> | 1 | From: Nir Soffer <nirsof@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | There is no need to make another reference. | 3 | Quoting cache mode is not needed, and most tests use unquoted values. |
4 | Unify all test to use the same style. | ||
4 | 5 | ||
5 | Signed-off-by: Li Qiang <liq3ea@163.com> | 6 | Message-id: 20190827173432.7656-1-nsoffer@redhat.com |
6 | Reviewed-by: Max Reitz <mreitz@redhat.com> | 7 | Signed-off-by: Nir Soffer <nsoffer@redhat.com> |
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Message-id: 20190120055558.32984-4-liq3ea@163.com | ||
9 | Signed-off-by: Max Reitz <mreitz@redhat.com> | 8 | Signed-off-by: Max Reitz <mreitz@redhat.com> |
10 | --- | 9 | --- |
11 | hw/block/nvme.c | 8 ++++---- | 10 | tests/qemu-iotests/026 | 4 ++-- |
12 | 1 file changed, 4 insertions(+), 4 deletions(-) | 11 | tests/qemu-iotests/039 | 4 ++-- |
12 | tests/qemu-iotests/052 | 2 +- | ||
13 | tests/qemu-iotests/091 | 4 ++-- | ||
14 | 4 files changed, 7 insertions(+), 7 deletions(-) | ||
13 | 15 | ||
14 | diff --git a/hw/block/nvme.c b/hw/block/nvme.c | 16 | diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026 |
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100755 |
16 | --- a/hw/block/nvme.c | 18 | --- a/tests/qemu-iotests/026 |
17 | +++ b/hw/block/nvme.c | 19 | +++ b/tests/qemu-iotests/026 |
18 | @@ -XXX,XX +XXX,XX @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp) | 20 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
19 | pci_conf[PCI_INTERRUPT_PIN] = 1; | 21 | # Currently only qcow2 supports rebasing |
20 | pci_config_set_prog_interface(pci_dev->config, 0x2); | 22 | _supported_fmt qcow2 |
21 | pci_config_set_class(pci_dev->config, PCI_CLASS_STORAGE_EXPRESS); | 23 | _supported_proto file |
22 | - pcie_endpoint_cap_init(&n->parent_obj, 0x80); | 24 | -_default_cache_mode "writethrough" |
23 | + pcie_endpoint_cap_init(pci_dev, 0x80); | 25 | -_supported_cache_modes "writethrough" "none" |
24 | 26 | +_default_cache_mode writethrough | |
25 | n->num_namespaces = 1; | 27 | +_supported_cache_modes writethrough none |
26 | n->reg_size = pow2ceil(0x1004 + 2 * (n->num_queues + 1) * 4); | 28 | # The refcount table tests expect a certain minimum width for refcount entries |
27 | @@ -XXX,XX +XXX,XX @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp) | 29 | # (so that the refcount table actually needs to grow); that minimum is 16 bits, |
28 | 30 | # being the default refcount entry width. | |
29 | memory_region_init_io(&n->iomem, OBJECT(n), &nvme_mmio_ops, n, | 31 | diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039 |
30 | "nvme", n->reg_size); | 32 | index XXXXXXX..XXXXXXX 100755 |
31 | - pci_register_bar(&n->parent_obj, 0, | 33 | --- a/tests/qemu-iotests/039 |
32 | + pci_register_bar(pci_dev, 0, | 34 | +++ b/tests/qemu-iotests/039 |
33 | PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64, | 35 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 |
34 | &n->iomem); | 36 | _supported_fmt qcow2 |
35 | - msix_init_exclusive_bar(&n->parent_obj, n->num_queues, 4, NULL); | 37 | _supported_proto file |
36 | + msix_init_exclusive_bar(pci_dev, n->num_queues, 4, NULL); | 38 | _supported_os Linux |
37 | 39 | -_default_cache_mode "writethrough" | |
38 | id->vid = cpu_to_le16(pci_get_word(pci_conf + PCI_VENDOR_ID)); | 40 | -_supported_cache_modes "writethrough" |
39 | id->ssvid = cpu_to_le16(pci_get_word(pci_conf + PCI_SUBSYSTEM_VENDOR_ID)); | 41 | +_default_cache_mode writethrough |
40 | @@ -XXX,XX +XXX,XX @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp) | 42 | +_supported_cache_modes writethrough |
41 | n->cmbuf = g_malloc0(NVME_CMBSZ_GETSIZE(n->bar.cmbsz)); | 43 | |
42 | memory_region_init_io(&n->ctrl_mem, OBJECT(n), &nvme_cmb_ops, n, | 44 | size=128M |
43 | "nvme-cmb", NVME_CMBSZ_GETSIZE(n->bar.cmbsz)); | 45 | |
44 | - pci_register_bar(&n->parent_obj, NVME_CMBLOC_BIR(n->bar.cmbloc), | 46 | diff --git a/tests/qemu-iotests/052 b/tests/qemu-iotests/052 |
45 | + pci_register_bar(pci_dev, NVME_CMBLOC_BIR(n->bar.cmbloc), | 47 | index XXXXXXX..XXXXXXX 100755 |
46 | PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64 | | 48 | --- a/tests/qemu-iotests/052 |
47 | PCI_BASE_ADDRESS_MEM_PREFETCH, &n->ctrl_mem); | 49 | +++ b/tests/qemu-iotests/052 |
50 | @@ -XXX,XX +XXX,XX @@ _supported_fmt generic | ||
51 | _supported_proto file | ||
52 | |||
53 | # Don't do O_DIRECT on tmpfs | ||
54 | -_supported_cache_modes "writeback" "writethrough" "unsafe" | ||
55 | +_supported_cache_modes writeback writethrough unsafe | ||
56 | |||
57 | size=128M | ||
58 | _make_test_img $size | ||
59 | diff --git a/tests/qemu-iotests/091 b/tests/qemu-iotests/091 | ||
60 | index XXXXXXX..XXXXXXX 100755 | ||
61 | --- a/tests/qemu-iotests/091 | ||
62 | +++ b/tests/qemu-iotests/091 | ||
63 | @@ -XXX,XX +XXX,XX @@ trap "_cleanup; exit \$status" 0 1 2 3 15 | ||
64 | _supported_fmt qcow2 | ||
65 | _supported_proto file | ||
66 | _supported_os Linux | ||
67 | -_default_cache_mode "none" | ||
68 | -_supported_cache_modes "writethrough" "none" "writeback" | ||
69 | +_default_cache_mode none | ||
70 | +_supported_cache_modes writethrough none writeback | ||
71 | |||
72 | size=1G | ||
48 | 73 | ||
49 | -- | 74 | -- |
50 | 2.20.1 | 75 | 2.21.0 |
51 | 76 | ||
52 | 77 | diff view generated by jsdifflib |