1 | The following changes since commit 64175afc695c0672876fbbfc31b299c86d562cb4: | 1 | The following changes since commit 20d6c7312f1b812bb9c750f4087f69ac8485cc90: |
---|---|---|---|
2 | 2 | ||
3 | arm_gicv3: Fix ICC_BPR1 reset value when EL3 not implemented (2017-06-07 17:21:44 +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/codyprime/qemu-kvm-jtc.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 56faeb9bb6872b3f926b3b3e0452a70beea10af2: | 9 | for you to fetch changes up to 39a0408e768cd00142f5b57d27ab234282bf4df5: |
10 | 10 | ||
11 | block/gluster.c: Handle qdict_array_entries() failure (2017-06-09 08:41:29 -0400) | 11 | dmg: don't skip zero chunk (2019-01-04 11:15:09 +0000) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Gluster patch | 14 | Pull request |
15 | |||
16 | Bug fixes for the .dmg image file format. | ||
17 | |||
15 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
16 | 19 | ||
17 | Peter Maydell (1): | 20 | Julio Faracco (1): |
18 | block/gluster.c: Handle qdict_array_entries() failure | 21 | dmg: Fixing wrong dmg block type value for block terminator. |
19 | 22 | ||
20 | block/gluster.c | 3 +-- | 23 | yuchenlin (3): |
21 | 1 file changed, 1 insertion(+), 2 deletions(-) | 24 | dmg: fix binary search |
25 | dmg: use enumeration type instead of hard coding number | ||
26 | dmg: don't skip zero chunk | ||
27 | |||
28 | block/dmg.c | 31 ++++++++++++++++++++----------- | ||
29 | 1 file changed, 20 insertions(+), 11 deletions(-) | ||
22 | 30 | ||
23 | -- | 31 | -- |
24 | 2.9.3 | 32 | 2.20.1 |
25 | 33 | ||
26 | 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 |
New patch | |||
---|---|---|---|
1 | From: yuchenlin <npes87184@gmail.com> | ||
1 | 2 | ||
3 | There is a possible hang in original binary search implementation. That is | ||
4 | if chunk1 = 4, chunk2 = 5, chunk3 = 4, and we go else case. | ||
5 | |||
6 | The chunk1 will be still 4, and so on. | ||
7 | |||
8 | Signed-off-by: yuchenlin <npes87184@gmail.com> | ||
9 | Message-id: 20190103114700.9686-2-npes87184@gmail.com | ||
10 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
11 | --- | ||
12 | block/dmg.c | 10 +++++++--- | ||
13 | 1 file changed, 7 insertions(+), 3 deletions(-) | ||
14 | |||
15 | diff --git a/block/dmg.c b/block/dmg.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/block/dmg.c | ||
18 | +++ b/block/dmg.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t search_chunk(BDRVDMGState *s, uint64_t sector_num) | ||
20 | { | ||
21 | /* binary search */ | ||
22 | uint32_t chunk1 = 0, chunk2 = s->n_chunks, chunk3; | ||
23 | - while (chunk1 != chunk2) { | ||
24 | + while (chunk1 <= chunk2) { | ||
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 | } | ||
39 | +err: | ||
40 | return s->n_chunks; /* error */ | ||
41 | } | ||
42 | |||
43 | -- | ||
44 | 2.20.1 | ||
45 | |||
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 | From: Peter Maydell <peter.maydell@linaro.org> | 1 | From: yuchenlin <npes87184@gmail.com> |
---|---|---|---|
2 | 2 | ||
3 | In qemu_gluster_parse_json(), the call to qdict_array_entries() | 3 | The dmg file has many tables which describe: "start from sector XXX to |
4 | could return a negative error code, which we were ignoring | 4 | sector XXX, the compression method is XXX and where the compressed data |
5 | because we assigned the result to an unsigned variable. | 5 | resides on". |
6 | Fix this by using the 'int' type instead, which matches the | ||
7 | return type of qdict_array_entries() and also the type | ||
8 | we use for the loop enumeration variable 'i'. | ||
9 | 6 | ||
10 | (Spotted by Coverity, CID 1360960.) | 7 | Each sector in the expanded file should be covered by a table. The table |
8 | will describe the offset of compressed data (or raw depends on the type) | ||
9 | in the dmg. | ||
11 | 10 | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | For example: |
13 | Reviewed-by: Eric Blake <eblake@redhat.com> | 12 | |
14 | Reviewed-by: Jeff Cody <jcody@redhat.com> | 13 | [-----------The expanded file------------] |
15 | Message-id: 1496682098-1540-1-git-send-email-peter.maydell@linaro.org | 14 | [---bzip table ---]/* zeros */[---zlib---] |
16 | Signed-off-by: Jeff Cody <jcody@redhat.com> | 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 | ||
50 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
17 | --- | 51 | --- |
18 | block/gluster.c | 3 +-- | 52 | block/dmg.c | 19 ++++++++++++------- |
19 | 1 file changed, 1 insertion(+), 2 deletions(-) | 53 | 1 file changed, 12 insertions(+), 7 deletions(-) |
20 | 54 | ||
21 | diff --git a/block/gluster.c b/block/gluster.c | 55 | diff --git a/block/dmg.c b/block/dmg.c |
22 | index XXXXXXX..XXXXXXX 100644 | 56 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/block/gluster.c | 57 | --- a/block/dmg.c |
24 | +++ b/block/gluster.c | 58 | +++ b/block/dmg.c |
25 | @@ -XXX,XX +XXX,XX @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf, | 59 | @@ -XXX,XX +XXX,XX @@ static void update_max_chunk_size(BDRVDMGState *s, uint32_t chunk, |
26 | Error *local_err = NULL; | 60 | case UDRW: /* copy */ |
27 | char *str = NULL; | 61 | uncompressed_sectors = DIV_ROUND_UP(s->lengths[chunk], 512); |
28 | const char *ptr; | 62 | break; |
29 | - size_t num_servers; | 63 | - case UDIG: /* zero */ |
30 | - int i, type; | 64 | + case UDZE: /* zero */ |
31 | + int i, type, num_servers; | 65 | + case UDIG: /* ignore */ |
32 | 66 | /* as the all-zeroes block may be large, it is treated specially: the | |
33 | /* create opts info from runtime_json_opts list */ | 67 | * sector is not copied from a large buffer, a simple memset is used |
34 | opts = qemu_opts_create(&runtime_json_opts, NULL, 0, &error_abort); | 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) | ||
71 | { | ||
72 | switch (entry_type) { | ||
73 | + case UDZE: /* zeros */ | ||
74 | case UDRW: /* uncompressed */ | ||
75 | - case UDIG: /* zeroes */ | ||
76 | + case UDIG: /* ignore */ | ||
77 | case UDZO: /* zlib */ | ||
78 | return true; | ||
79 | case UDBZ: /* bzip2 */ | ||
80 | @@ -XXX,XX +XXX,XX @@ static int dmg_read_mish_block(BDRVDMGState *s, DmgHeaderState *ds, | ||
81 | /* sector count */ | ||
82 | s->sectorcounts[i] = buff_read_uint64(buffer, offset + 0x10); | ||
83 | |||
84 | - /* all-zeroes sector (type 2) does not need to be "uncompressed" and can | ||
85 | - * therefore be unbounded. */ | ||
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; | ||
113 | } | ||
35 | -- | 114 | -- |
36 | 2.9.3 | 115 | 2.20.1 |
37 | 116 | ||
38 | 117 | diff view generated by jsdifflib |