1 | The following changes since commit 577caa2672ccde7352fda3ef17e44993de862f0e: | 1 | The following changes since commit 20d6c7312f1b812bb9c750f4087f69ac8485cc90: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/edgar/tags/edgar/mmio-exec-v2.for-upstream' into staging (2017-06-27 16:56:55 +0100) | 3 | Merge remote-tracking branch 'remotes/palmer/tags/riscv-for-master-3.2-part1' into staging (2019-01-03 13:26:30 +0000) |
4 | 4 | ||
5 | are available in the git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | git://github.com/stefanha/qemu.git tags/block-pull-request | 7 | git://github.com/stefanha/qemu.git tags/block-pull-request |
8 | 8 | ||
9 | for you to fetch changes up to 439778e6b4a20c8fe6a6a92a17013b09c4ae55d0: | 9 | for you to fetch changes up to 39a0408e768cd00142f5b57d27ab234282bf4df5: |
10 | 10 | ||
11 | virtio-pci: use ioeventfd even when KVM is disabled (2017-06-28 13:18:53 +0100) | 11 | dmg: don't skip zero chunk (2019-01-04 11:15:09 +0000) |
12 | |||
13 | ---------------------------------------------------------------- | ||
14 | Pull request | ||
15 | |||
16 | Bug fixes for the .dmg image file format. | ||
12 | 17 | ||
13 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
14 | 19 | ||
15 | ---------------------------------------------------------------- | 20 | Julio Faracco (1): |
21 | dmg: Fixing wrong dmg block type value for block terminator. | ||
16 | 22 | ||
17 | Stefan Hajnoczi (2): | 23 | yuchenlin (3): |
18 | virtio-blk: trace vdev so devices can be distinguished | 24 | dmg: fix binary search |
19 | virtio-pci: use ioeventfd even when KVM is disabled | 25 | dmg: use enumeration type instead of hard coding number |
26 | dmg: don't skip zero chunk | ||
20 | 27 | ||
21 | hw/block/virtio-blk.c | 12 +++++++----- | 28 | block/dmg.c | 31 ++++++++++++++++++++----------- |
22 | hw/virtio/virtio-pci.c | 2 +- | 29 | 1 file changed, 20 insertions(+), 11 deletions(-) |
23 | hw/block/trace-events | 10 +++++----- | ||
24 | 3 files changed, 13 insertions(+), 11 deletions(-) | ||
25 | 30 | ||
26 | -- | 31 | -- |
27 | 2.9.4 | 32 | 2.20.1 |
28 | 33 | ||
29 | 34 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Julio Faracco <jcfaracco@gmail.com> | ||
1 | 2 | ||
3 | This is a trivial patch to fix a wrong value for block terminator. | ||
4 | The old value was 0x7fffffff which is wrong. It was not affecting the | ||
5 | code because QEMU dmg block is not handling block terminator right now. | ||
6 | Neverthless, it should be fixed. | ||
7 | |||
8 | Signed-off-by: Julio Faracco <jcfaracco@gmail.com> | ||
9 | Reviewed-by: yuchenlin <yuchenlin@synology.com> | ||
10 | Message-id: 20181228145055.18039-1-jcfaracco@gmail.com | ||
11 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
12 | --- | ||
13 | block/dmg.c | 2 +- | ||
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
15 | |||
16 | diff --git a/block/dmg.c b/block/dmg.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/block/dmg.c | ||
19 | +++ b/block/dmg.c | ||
20 | @@ -XXX,XX +XXX,XX @@ enum { | ||
21 | UDBZ, | ||
22 | ULFO, | ||
23 | UDCM = 0x7ffffffe, /* Comments */ | ||
24 | - UDLE /* Last Entry */ | ||
25 | + UDLE = 0xffffffff /* Last Entry */ | ||
26 | }; | ||
27 | |||
28 | static int dmg_probe(const uint8_t *buf, int buf_size, const char *filename) | ||
29 | -- | ||
30 | 2.20.1 | ||
31 | |||
32 | diff view generated by jsdifflib |
1 | Old kvm.ko versions only supported a tiny number of ioeventfds so | 1 | From: yuchenlin <npes87184@gmail.com> |
---|---|---|---|
2 | virtio-pci avoids ioeventfds when kvm_has_many_ioeventfds() returns 0. | ||
3 | 2 | ||
4 | Do not check kvm_has_many_ioeventfds() when KVM is disabled since it | 3 | There is a possible hang in original binary search implementation. That is |
5 | always returns 0. Since commit 8c56c1a592b5092d91da8d8943c17777d6462a6f | 4 | if chunk1 = 4, chunk2 = 5, chunk3 = 4, and we go else case. |
6 | ("memory: emulate ioeventfd") it has been possible to use ioeventfds in | ||
7 | qtest or TCG mode. | ||
8 | 5 | ||
9 | This patch makes -device virtio-blk-pci,iothread=iothread0 work even | 6 | The chunk1 will be still 4, and so on. |
10 | when KVM is disabled. | ||
11 | 7 | ||
12 | I have tested that virtio-blk-pci works under TCG both with and without | 8 | Signed-off-by: yuchenlin <npes87184@gmail.com> |
13 | iothread. | 9 | Message-id: 20190103114700.9686-2-npes87184@gmail.com |
14 | |||
15 | This patch fixes qemu-iotests 068, which was accidentally merged early | ||
16 | despite the dependency on ioeventfd. | ||
17 | |||
18 | Cc: Michael S. Tsirkin <mst@redhat.com> | ||
19 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
20 | Reviewed-by: Michael S. Tsirkin <mst@redhat.com> | ||
21 | Message-id: 20170615163813.7255-2-stefanha@redhat.com | ||
22 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 10 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
23 | --- | 11 | --- |
24 | hw/virtio/virtio-pci.c | 2 +- | 12 | block/dmg.c | 10 +++++++--- |
25 | 1 file changed, 1 insertion(+), 1 deletion(-) | 13 | 1 file changed, 7 insertions(+), 3 deletions(-) |
26 | 14 | ||
27 | diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c | 15 | diff --git a/block/dmg.c b/block/dmg.c |
28 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/hw/virtio/virtio-pci.c | 17 | --- a/block/dmg.c |
30 | +++ b/hw/virtio/virtio-pci.c | 18 | +++ b/block/dmg.c |
31 | @@ -XXX,XX +XXX,XX @@ static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp) | 19 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t search_chunk(BDRVDMGState *s, uint64_t sector_num) |
32 | bool pcie_port = pci_bus_is_express(pci_dev->bus) && | 20 | { |
33 | !pci_bus_is_root(pci_dev->bus); | 21 | /* binary search */ |
34 | 22 | uint32_t chunk1 = 0, chunk2 = s->n_chunks, chunk3; | |
35 | - if (!kvm_has_many_ioeventfds()) { | 23 | - while (chunk1 != chunk2) { |
36 | + if (kvm_enabled() && !kvm_has_many_ioeventfds()) { | 24 | + while (chunk1 <= chunk2) { |
37 | proxy->flags &= ~VIRTIO_PCI_FLAG_USE_IOEVENTFD; | 25 | chunk3 = (chunk1 + chunk2) / 2; |
26 | if (s->sectors[chunk3] > sector_num) { | ||
27 | - chunk2 = chunk3; | ||
28 | + if (chunk3 == 0) { | ||
29 | + goto err; | ||
30 | + } | ||
31 | + chunk2 = chunk3 - 1; | ||
32 | } else if (s->sectors[chunk3] + s->sectorcounts[chunk3] > sector_num) { | ||
33 | return chunk3; | ||
34 | } else { | ||
35 | - chunk1 = chunk3; | ||
36 | + chunk1 = chunk3 + 1; | ||
37 | } | ||
38 | } | 38 | } |
39 | +err: | ||
40 | return s->n_chunks; /* error */ | ||
41 | } | ||
39 | 42 | ||
40 | -- | 43 | -- |
41 | 2.9.4 | 44 | 2.20.1 |
42 | 45 | ||
43 | 46 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: yuchenlin <npes87184@gmail.com> | ||
1 | 2 | ||
3 | Signed-off-by: yuchenlin <npes87184@gmail.com> | ||
4 | Reviewed-by: Julio Faracco <jcfaracco@gmail.com> | ||
5 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
6 | Message-id: 20190103114700.9686-3-npes87184@gmail.com | ||
7 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
8 | --- | ||
9 | block/dmg.c | 4 ++-- | ||
10 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
11 | |||
12 | diff --git a/block/dmg.c b/block/dmg.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/block/dmg.c | ||
15 | +++ b/block/dmg.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static int dmg_read_mish_block(BDRVDMGState *s, DmgHeaderState *ds, | ||
17 | |||
18 | /* all-zeroes sector (type 2) does not need to be "uncompressed" and can | ||
19 | * therefore be unbounded. */ | ||
20 | - if (s->types[i] != 2 && s->sectorcounts[i] > DMG_SECTORCOUNTS_MAX) { | ||
21 | + if (s->types[i] != UDIG && s->sectorcounts[i] > DMG_SECTORCOUNTS_MAX) { | ||
22 | error_report("sector count %" PRIu64 " for chunk %" PRIu32 | ||
23 | " is larger than max (%u)", | ||
24 | s->sectorcounts[i], i, DMG_SECTORCOUNTS_MAX); | ||
25 | @@ -XXX,XX +XXX,XX @@ dmg_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, | ||
26 | /* Special case: current chunk is all zeroes. Do not perform a memcpy as | ||
27 | * s->uncompressed_chunk may be too small to cover the large all-zeroes | ||
28 | * section. dmg_read_chunk is called to find s->current_chunk */ | ||
29 | - if (s->types[s->current_chunk] == 2) { /* all zeroes block entry */ | ||
30 | + if (s->types[s->current_chunk] == UDIG) { /* all zeroes block entry */ | ||
31 | qemu_iovec_memset(qiov, i * 512, 0, 512); | ||
32 | continue; | ||
33 | } | ||
34 | -- | ||
35 | 2.20.1 | ||
36 | |||
37 | diff view generated by jsdifflib |
1 | It is hard to analyze trace logs with multiple virtio-blk devices | 1 | From: yuchenlin <npes87184@gmail.com> |
---|---|---|---|
2 | because none of the trace events include the VirtIODevice *vdev. | ||
3 | 2 | ||
4 | This patch adds vdev so it's clear which device a request is associated | 3 | The dmg file has many tables which describe: "start from sector XXX to |
5 | with. | 4 | sector XXX, the compression method is XXX and where the compressed data |
5 | resides on". | ||
6 | 6 | ||
7 | I considered using VirtIOBlock *s instead but VirtIODevice *vdev is more | 7 | Each sector in the expanded file should be covered by a table. The table |
8 | general and may be correlated with generic virtio trace events like | 8 | will describe the offset of compressed data (or raw depends on the type) |
9 | virtio_set_status. | 9 | in the dmg. |
10 | 10 | ||
11 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 11 | For example: |
12 | Reviewed-by: Fam Zheng <famz@redhat.com> | 12 | |
13 | Message-id: 20170614092930.11234-1-stefanha@redhat.com | 13 | [-----------The expanded file------------] |
14 | [---bzip table ---]/* zeros */[---zlib---] | ||
15 | ^ | ||
16 | | if we want to read this sector. | ||
17 | |||
18 | we will find bzip table which contains this sector, and get the | ||
19 | compressed data offset, read it from dmg, uncompress it, finally write to | ||
20 | expanded file. | ||
21 | |||
22 | If we skip zero chunk (table), some sector cannot find the table which | ||
23 | will cause search_chunk() return s->n_chunks, dmg_read_chunk() return -1 | ||
24 | and finally causing dmg_co_preadv() return EIO. | ||
25 | |||
26 | See: | ||
27 | |||
28 | [-----------The expanded file------------] | ||
29 | [---bzip table ---]/* zeros */[---zlib---] | ||
30 | ^ | ||
31 | | if we want to read this sector. | ||
32 | |||
33 | Oops, we cannot find the table contains it... | ||
34 | |||
35 | In the original implementation, we don't have zero table. When we try to | ||
36 | read sector inside the zero chunk. We will get EIO, and skip reading. | ||
37 | |||
38 | After this patch, we treat zero chunk the same as ignore chunk, it will | ||
39 | directly write zero and avoid some sector may not find the table. | ||
40 | |||
41 | After this patch: | ||
42 | |||
43 | [-----------The expanded file------------] | ||
44 | [---bzip table ---][--zeros--][---zlib---] | ||
45 | |||
46 | Signed-off-by: yuchenlin <npes87184@gmail.com> | ||
47 | Reviewed-by: Julio Faracco <jcfaracco@gmail.com> | ||
48 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
49 | Message-id: 20190103114700.9686-4-npes87184@gmail.com | ||
14 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 50 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
15 | --- | 51 | --- |
16 | hw/block/virtio-blk.c | 12 +++++++----- | 52 | block/dmg.c | 19 ++++++++++++------- |
17 | hw/block/trace-events | 10 +++++----- | 53 | 1 file changed, 12 insertions(+), 7 deletions(-) |
18 | 2 files changed, 12 insertions(+), 10 deletions(-) | ||
19 | 54 | ||
20 | diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c | 55 | diff --git a/block/dmg.c b/block/dmg.c |
21 | index XXXXXXX..XXXXXXX 100644 | 56 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/block/virtio-blk.c | 57 | --- a/block/dmg.c |
23 | +++ b/hw/block/virtio-blk.c | 58 | +++ b/block/dmg.c |
24 | @@ -XXX,XX +XXX,XX @@ static void virtio_blk_req_complete(VirtIOBlockReq *req, unsigned char status) | 59 | @@ -XXX,XX +XXX,XX @@ static void update_max_chunk_size(BDRVDMGState *s, uint32_t chunk, |
25 | VirtIOBlock *s = req->dev; | 60 | case UDRW: /* copy */ |
26 | VirtIODevice *vdev = VIRTIO_DEVICE(s); | 61 | uncompressed_sectors = DIV_ROUND_UP(s->lengths[chunk], 512); |
27 | 62 | break; | |
28 | - trace_virtio_blk_req_complete(req, status); | 63 | - case UDIG: /* zero */ |
29 | + trace_virtio_blk_req_complete(vdev, req, status); | 64 | + case UDZE: /* zero */ |
30 | 65 | + case UDIG: /* ignore */ | |
31 | stb_p(&req->in->status, status); | 66 | /* as the all-zeroes block may be large, it is treated specially: the |
32 | virtqueue_push(req->vq, &req->elem, req->in_len); | 67 | * sector is not copied from a large buffer, a simple memset is used |
33 | @@ -XXX,XX +XXX,XX @@ static void virtio_blk_rw_complete(void *opaque, int ret) | 68 | * instead. Therefore uncompressed_sectors does not need to be set. */ |
69 | @@ -XXX,XX +XXX,XX @@ typedef struct DmgHeaderState { | ||
70 | static bool dmg_is_known_block_type(uint32_t entry_type) | ||
34 | { | 71 | { |
35 | VirtIOBlockReq *next = opaque; | 72 | switch (entry_type) { |
36 | VirtIOBlock *s = next->dev; | 73 | + case UDZE: /* zeros */ |
37 | + VirtIODevice *vdev = VIRTIO_DEVICE(s); | 74 | case UDRW: /* uncompressed */ |
38 | 75 | - case UDIG: /* zeroes */ | |
39 | aio_context_acquire(blk_get_aio_context(s->conf.conf.blk)); | 76 | + case UDIG: /* ignore */ |
40 | while (next) { | 77 | case UDZO: /* zlib */ |
41 | VirtIOBlockReq *req = next; | 78 | return true; |
42 | next = req->mr_next; | 79 | case UDBZ: /* bzip2 */ |
43 | - trace_virtio_blk_rw_complete(req, ret); | 80 | @@ -XXX,XX +XXX,XX @@ static int dmg_read_mish_block(BDRVDMGState *s, DmgHeaderState *ds, |
44 | + trace_virtio_blk_rw_complete(vdev, req, ret); | 81 | /* sector count */ |
45 | 82 | s->sectorcounts[i] = buff_read_uint64(buffer, offset + 0x10); | |
46 | if (req->qiov.nalloc != -1) { | 83 | |
47 | /* If nalloc is != 1 req->qiov is a local copy of the original | 84 | - /* all-zeroes sector (type 2) does not need to be "uncompressed" and can |
48 | @@ -XXX,XX +XXX,XX @@ static inline void submit_requests(BlockBackend *blk, MultiReqBuffer *mrb, | 85 | - * therefore be unbounded. */ |
49 | mrb->reqs[i - 1]->mr_next = mrb->reqs[i]; | 86 | - if (s->types[i] != UDIG && s->sectorcounts[i] > DMG_SECTORCOUNTS_MAX) { |
87 | + /* all-zeroes sector (type UDZE and UDIG) does not need to be | ||
88 | + * "uncompressed" and can therefore be unbounded. */ | ||
89 | + if (s->types[i] != UDZE && s->types[i] != UDIG | ||
90 | + && s->sectorcounts[i] > DMG_SECTORCOUNTS_MAX) { | ||
91 | error_report("sector count %" PRIu64 " for chunk %" PRIu32 | ||
92 | " is larger than max (%u)", | ||
93 | s->sectorcounts[i], i, DMG_SECTORCOUNTS_MAX); | ||
94 | @@ -XXX,XX +XXX,XX @@ static inline int dmg_read_chunk(BlockDriverState *bs, uint64_t sector_num) | ||
95 | return -1; | ||
96 | } | ||
97 | break; | ||
98 | - case UDIG: /* zero */ | ||
99 | + case UDZE: /* zeros */ | ||
100 | + case UDIG: /* ignore */ | ||
101 | /* see dmg_read, it is treated specially. No buffer needs to be | ||
102 | * pre-filled, the zeroes can be set directly. */ | ||
103 | break; | ||
104 | @@ -XXX,XX +XXX,XX @@ dmg_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, | ||
105 | /* Special case: current chunk is all zeroes. Do not perform a memcpy as | ||
106 | * s->uncompressed_chunk may be too small to cover the large all-zeroes | ||
107 | * section. dmg_read_chunk is called to find s->current_chunk */ | ||
108 | - if (s->types[s->current_chunk] == UDIG) { /* all zeroes block entry */ | ||
109 | + if (s->types[s->current_chunk] == UDZE | ||
110 | + || s->types[s->current_chunk] == UDIG) { /* all zeroes block entry */ | ||
111 | qemu_iovec_memset(qiov, i * 512, 0, 512); | ||
112 | continue; | ||
50 | } | 113 | } |
51 | |||
52 | - trace_virtio_blk_submit_multireq(mrb, start, num_reqs, | ||
53 | + trace_virtio_blk_submit_multireq(VIRTIO_DEVICE(mrb->reqs[start]->dev), | ||
54 | + mrb, start, num_reqs, | ||
55 | sector_num << BDRV_SECTOR_BITS, | ||
56 | qiov->size, is_write); | ||
57 | block_acct_merge_done(blk_get_stats(blk), | ||
58 | @@ -XXX,XX +XXX,XX @@ static int virtio_blk_handle_request(VirtIOBlockReq *req, MultiReqBuffer *mrb) | ||
59 | |||
60 | if (is_write) { | ||
61 | qemu_iovec_init_external(&req->qiov, iov, out_num); | ||
62 | - trace_virtio_blk_handle_write(req, req->sector_num, | ||
63 | + trace_virtio_blk_handle_write(vdev, req, req->sector_num, | ||
64 | req->qiov.size / BDRV_SECTOR_SIZE); | ||
65 | } else { | ||
66 | qemu_iovec_init_external(&req->qiov, in_iov, in_num); | ||
67 | - trace_virtio_blk_handle_read(req, req->sector_num, | ||
68 | + trace_virtio_blk_handle_read(vdev, req, req->sector_num, | ||
69 | req->qiov.size / BDRV_SECTOR_SIZE); | ||
70 | } | ||
71 | |||
72 | diff --git a/hw/block/trace-events b/hw/block/trace-events | ||
73 | index XXXXXXX..XXXXXXX 100644 | ||
74 | --- a/hw/block/trace-events | ||
75 | +++ b/hw/block/trace-events | ||
76 | @@ -XXX,XX +XXX,XX @@ | ||
77 | # See docs/tracing.txt for syntax documentation. | ||
78 | |||
79 | # hw/block/virtio-blk.c | ||
80 | -virtio_blk_req_complete(void *req, int status) "req %p status %d" | ||
81 | -virtio_blk_rw_complete(void *req, int ret) "req %p ret %d" | ||
82 | -virtio_blk_handle_write(void *req, uint64_t sector, size_t nsectors) "req %p sector %"PRIu64" nsectors %zu" | ||
83 | -virtio_blk_handle_read(void *req, uint64_t sector, size_t nsectors) "req %p sector %"PRIu64" nsectors %zu" | ||
84 | -virtio_blk_submit_multireq(void *mrb, int start, int num_reqs, uint64_t offset, size_t size, bool is_write) "mrb %p start %d num_reqs %d offset %"PRIu64" size %zu is_write %d" | ||
85 | +virtio_blk_req_complete(void *vdev, void *req, int status) "vdev %p req %p status %d" | ||
86 | +virtio_blk_rw_complete(void *vdev, void *req, int ret) "vdev %p req %p ret %d" | ||
87 | +virtio_blk_handle_write(void *vdev, void *req, uint64_t sector, size_t nsectors) "vdev %p req %p sector %"PRIu64" nsectors %zu" | ||
88 | +virtio_blk_handle_read(void *vdev, void *req, uint64_t sector, size_t nsectors) "vdev %p req %p sector %"PRIu64" nsectors %zu" | ||
89 | +virtio_blk_submit_multireq(void *vdev, void *mrb, int start, int num_reqs, uint64_t offset, size_t size, bool is_write) "vdev %p mrb %p start %d num_reqs %d offset %"PRIu64" size %zu is_write %d" | ||
90 | |||
91 | # hw/block/hd-geometry.c | ||
92 | hd_geometry_lchs_guess(void *blk, int cyls, int heads, int secs) "blk %p LCHS %d %d %d" | ||
93 | -- | 114 | -- |
94 | 2.9.4 | 115 | 2.20.1 |
95 | 116 | ||
96 | 117 | diff view generated by jsdifflib |