1 | The following changes since commit 00928a421d47f49691cace1207481b7aad31b1f1: | 1 | The following changes since commit 346ed3151f1c43e72c40cb55b392a1d4cface62c: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20180626' into staging (2018-06-26 18:23:49 +0100) | 3 | Merge remote-tracking branch 'remotes/awilliam/tags/vfio-update-20200206.0' into staging (2020-02-07 11:52:15 +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 | https://github.com/stefanha/qemu.git tags/block-pull-request |
8 | 8 | ||
9 | for you to fetch changes up to ed6e2161715c527330f936d44af4c547f25f687e: | 9 | for you to fetch changes up to 11a18c84db4a71497d3d40769688a01b6f64b2ad: |
10 | 10 | ||
11 | linux-aio: properly bubble up errors from initialization (2018-06-27 13:06:34 +0100) | 11 | hw/core: Allow setting 'virtio-blk-device.scsi' property on OSX host (2020-02-07 16:49:39 +0000) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Pull request | 14 | Pull request |
15 | 15 | ||
16 | * Gracefully handle Linux AIO init failure | ||
17 | |||
18 | ---------------------------------------------------------------- | 16 | ---------------------------------------------------------------- |
19 | 17 | ||
20 | Nishanth Aravamudan (1): | 18 | Philippe Mathieu-Daudé (1): |
21 | linux-aio: properly bubble up errors from initialization | 19 | hw/core: Allow setting 'virtio-blk-device.scsi' property on OSX host |
22 | 20 | ||
23 | Stefan Hajnoczi (1): | 21 | Vladimir Sementsov-Ogievskiy (1): |
24 | compiler: add a sizeof_field() macro | 22 | block: fix crash on zero-length unaligned write and read |
25 | 23 | ||
26 | include/block/aio.h | 3 +++ | 24 | block/io.c | 28 +++++++++++++++++++++++++++- |
27 | include/block/raw-aio.h | 2 +- | 25 | hw/core/machine.c | 3 ++- |
28 | include/hw/xen/io/ring.h | 2 +- | 26 | 2 files changed, 29 insertions(+), 2 deletions(-) |
29 | include/qemu/compiler.h | 2 ++ | ||
30 | accel/tcg/translate-all.c | 2 +- | ||
31 | block/file-posix.c | 33 ++++++++++++++++++++++++++++----- | ||
32 | block/linux-aio.c | 12 +++++++++--- | ||
33 | hw/display/xenfb.c | 4 ++-- | ||
34 | hw/net/rocker/rocker_of_dpa.c | 2 +- | ||
35 | hw/net/virtio-net.c | 2 +- | ||
36 | stubs/linux-aio.c | 2 +- | ||
37 | target/i386/kvm.c | 2 +- | ||
38 | target/ppc/arch_dump.c | 10 +++++----- | ||
39 | target/s390x/arch_dump.c | 20 ++++++++++---------- | ||
40 | util/async.c | 14 +++++++++++--- | ||
41 | 15 files changed, 77 insertions(+), 35 deletions(-) | ||
42 | 27 | ||
43 | -- | 28 | -- |
44 | 2.17.1 | 29 | 2.24.1 |
45 | 30 | ||
46 | 31 | diff view generated by jsdifflib |
1 | From: Nishanth Aravamudan <naravamudan@digitalocean.com> | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | laio_init() can fail for a couple of reasons, which will lead to a NULL | 3 | Commit 7a3f542fbd "block/io: refactor padding" occasionally dropped |
4 | pointer dereference in laio_attach_aio_context(). | 4 | aligning for zero-length request: bdrv_init_padding() blindly return |
5 | false if bytes == 0, like there is nothing to align. | ||
5 | 6 | ||
6 | To solve this, add a aio_setup_linux_aio() function which is called | 7 | This leads the following command to crash: |
7 | early in raw_open_common. If this fails, propagate the error up. The | ||
8 | signature of aio_get_linux_aio() was not modified, because it seems | ||
9 | preferable to return the actual errno from the possible failing | ||
10 | initialization calls. | ||
11 | 8 | ||
12 | Additionally, when the AioContext changes, we need to associate a | 9 | ./qemu-io --image-opts -c 'write 1 0' \ |
13 | LinuxAioState with the new AioContext. Use the bdrv_attach_aio_context | 10 | driver=blkdebug,align=512,image.driver=null-co,image.size=512 |
14 | callback and call the new aio_setup_linux_aio(), which will allocate a | ||
15 | new AioContext if needed, and return errors on failures. If it fails for | ||
16 | any reason, fallback to threaded AIO with an error message, as the | ||
17 | device is already in-use by the guest. | ||
18 | 11 | ||
19 | Add an assert that aio_get_linux_aio() cannot return NULL. | 12 | >> qemu-io: block/io.c:1955: bdrv_aligned_pwritev: Assertion |
13 | `(offset & (align - 1)) == 0' failed. | ||
14 | >> Aborted (core dumped) | ||
20 | 15 | ||
21 | Signed-off-by: Nishanth Aravamudan <naravamudan@digitalocean.com> | 16 | Prior to 7a3f542fbd we does aligning of such zero requests. Instead of |
22 | Message-id: 20180622193700.6523-1-naravamudan@digitalocean.com | 17 | recovering this behavior let's just do nothing on such requests as it |
18 | is useless. | ||
19 | |||
20 | Note that driver may have special meaning of zero-length reqeusts, like | ||
21 | qcow2_co_pwritev_compressed_part, so we can't skip any zero-length | ||
22 | operation. But for unaligned ones, we can't pass it to driver anyway. | ||
23 | |||
24 | This commit also fixes crash in iotest 80 running with -nocache: | ||
25 | |||
26 | ./check -nocache -qcow2 80 | ||
27 | |||
28 | which crashes on same assertion due to trying to read empty extra data | ||
29 | in qcow2_do_read_snapshots(). | ||
30 | |||
31 | Cc: qemu-stable@nongnu.org # v4.2 | ||
32 | Fixes: 7a3f542fbd | ||
33 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
34 | Reviewed-by: Max Reitz <mreitz@redhat.com> | ||
35 | Message-id: 20200206164245.17781-1-vsementsov@virtuozzo.com | ||
23 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 36 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
24 | --- | 37 | --- |
25 | include/block/aio.h | 3 +++ | 38 | block/io.c | 28 +++++++++++++++++++++++++++- |
26 | include/block/raw-aio.h | 2 +- | 39 | 1 file changed, 27 insertions(+), 1 deletion(-) |
27 | block/file-posix.c | 33 ++++++++++++++++++++++++++++----- | ||
28 | block/linux-aio.c | 12 +++++++++--- | ||
29 | stubs/linux-aio.c | 2 +- | ||
30 | util/async.c | 14 +++++++++++--- | ||
31 | 6 files changed, 53 insertions(+), 13 deletions(-) | ||
32 | 40 | ||
33 | diff --git a/include/block/aio.h b/include/block/aio.h | 41 | diff --git a/block/io.c b/block/io.c |
34 | index XXXXXXX..XXXXXXX 100644 | 42 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/include/block/aio.h | 43 | --- a/block/io.c |
36 | +++ b/include/block/aio.h | 44 | +++ b/block/io.c |
37 | @@ -XXX,XX +XXX,XX @@ GSource *aio_get_g_source(AioContext *ctx); | 45 | @@ -XXX,XX +XXX,XX @@ static bool bdrv_init_padding(BlockDriverState *bs, |
38 | /* Return the ThreadPool bound to this AioContext */ | 46 | pad->tail = align - pad->tail; |
39 | struct ThreadPool *aio_get_thread_pool(AioContext *ctx); | 47 | } |
40 | 48 | ||
41 | +/* Setup the LinuxAioState bound to this AioContext */ | 49 | - if ((!pad->head && !pad->tail) || !bytes) { |
42 | +struct LinuxAioState *aio_setup_linux_aio(AioContext *ctx, Error **errp); | 50 | + if (!pad->head && !pad->tail) { |
51 | return false; | ||
52 | } | ||
53 | |||
54 | + assert(bytes); /* Nothing good in aligning zero-length requests */ | ||
43 | + | 55 | + |
44 | /* Return the LinuxAioState bound to this AioContext */ | 56 | sum = pad->head + bytes + pad->tail; |
45 | struct LinuxAioState *aio_get_linux_aio(AioContext *ctx); | 57 | pad->buf_len = (sum > align && pad->head && pad->tail) ? 2 * align : align; |
46 | 58 | pad->buf = qemu_blockalign(bs, pad->buf_len); | |
47 | diff --git a/include/block/raw-aio.h b/include/block/raw-aio.h | 59 | @@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_preadv_part(BdrvChild *child, |
48 | index XXXXXXX..XXXXXXX 100644 | 60 | return ret; |
49 | --- a/include/block/raw-aio.h | ||
50 | +++ b/include/block/raw-aio.h | ||
51 | @@ -XXX,XX +XXX,XX @@ | ||
52 | /* linux-aio.c - Linux native implementation */ | ||
53 | #ifdef CONFIG_LINUX_AIO | ||
54 | typedef struct LinuxAioState LinuxAioState; | ||
55 | -LinuxAioState *laio_init(void); | ||
56 | +LinuxAioState *laio_init(Error **errp); | ||
57 | void laio_cleanup(LinuxAioState *s); | ||
58 | int coroutine_fn laio_co_submit(BlockDriverState *bs, LinuxAioState *s, int fd, | ||
59 | uint64_t offset, QEMUIOVector *qiov, int type); | ||
60 | diff --git a/block/file-posix.c b/block/file-posix.c | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/block/file-posix.c | ||
63 | +++ b/block/file-posix.c | ||
64 | @@ -XXX,XX +XXX,XX @@ static int raw_open_common(BlockDriverState *bs, QDict *options, | ||
65 | |||
66 | #ifdef CONFIG_LINUX_AIO | ||
67 | /* Currently Linux does AIO only for files opened with O_DIRECT */ | ||
68 | - if (s->use_linux_aio && !(s->open_flags & O_DIRECT)) { | ||
69 | - error_setg(errp, "aio=native was specified, but it requires " | ||
70 | - "cache.direct=on, which was not specified."); | ||
71 | - ret = -EINVAL; | ||
72 | - goto fail; | ||
73 | + if (s->use_linux_aio) { | ||
74 | + if (!(s->open_flags & O_DIRECT)) { | ||
75 | + error_setg(errp, "aio=native was specified, but it requires " | ||
76 | + "cache.direct=on, which was not specified."); | ||
77 | + ret = -EINVAL; | ||
78 | + goto fail; | ||
79 | + } | ||
80 | + if (!aio_setup_linux_aio(bdrv_get_aio_context(bs), errp)) { | ||
81 | + error_prepend(errp, "Unable to use native AIO: "); | ||
82 | + goto fail; | ||
83 | + } | ||
84 | } | 61 | } |
85 | #else | 62 | |
86 | if (s->use_linux_aio) { | 63 | + if (bytes == 0 && !QEMU_IS_ALIGNED(offset, bs->bl.request_alignment)) { |
87 | @@ -XXX,XX +XXX,XX @@ static BlockAIOCB *raw_aio_flush(BlockDriverState *bs, | 64 | + /* |
88 | return paio_submit(bs, s->fd, 0, NULL, 0, cb, opaque, QEMU_AIO_FLUSH); | 65 | + * Aligning zero request is nonsense. Even if driver has special meaning |
89 | } | 66 | + * of zero-length (like qcow2_co_pwritev_compressed_part), we can't pass |
90 | 67 | + * it to driver due to request_alignment. | |
91 | +static void raw_aio_attach_aio_context(BlockDriverState *bs, | 68 | + * |
92 | + AioContext *new_context) | 69 | + * Still, no reason to return an error if someone do unaligned |
93 | +{ | 70 | + * zero-length read occasionally. |
94 | +#ifdef CONFIG_LINUX_AIO | 71 | + */ |
95 | + BDRVRawState *s = bs->opaque; | 72 | + return 0; |
96 | + if (s->use_linux_aio) { | ||
97 | + Error *local_err; | ||
98 | + if (!aio_setup_linux_aio(new_context, &local_err)) { | ||
99 | + error_reportf_err(local_err, "Unable to use native AIO, " | ||
100 | + "falling back to thread pool: "); | ||
101 | + s->use_linux_aio = false; | ||
102 | + } | ||
103 | + } | 73 | + } |
104 | +#endif | ||
105 | +} | ||
106 | + | 74 | + |
107 | static void raw_close(BlockDriverState *bs) | 75 | bdrv_inc_in_flight(bs); |
108 | { | 76 | |
109 | BDRVRawState *s = bs->opaque; | 77 | /* Don't do copy-on-read if we read data before write operation */ |
110 | @@ -XXX,XX +XXX,XX @@ BlockDriver bdrv_file = { | 78 | @@ -XXX,XX +XXX,XX @@ int coroutine_fn bdrv_co_pwritev_part(BdrvChild *child, |
111 | .bdrv_refresh_limits = raw_refresh_limits, | 79 | return -ENOTSUP; |
112 | .bdrv_io_plug = raw_aio_plug, | ||
113 | .bdrv_io_unplug = raw_aio_unplug, | ||
114 | + .bdrv_attach_aio_context = raw_aio_attach_aio_context, | ||
115 | |||
116 | .bdrv_truncate = raw_truncate, | ||
117 | .bdrv_getlength = raw_getlength, | ||
118 | diff --git a/block/linux-aio.c b/block/linux-aio.c | ||
119 | index XXXXXXX..XXXXXXX 100644 | ||
120 | --- a/block/linux-aio.c | ||
121 | +++ b/block/linux-aio.c | ||
122 | @@ -XXX,XX +XXX,XX @@ | ||
123 | #include "block/raw-aio.h" | ||
124 | #include "qemu/event_notifier.h" | ||
125 | #include "qemu/coroutine.h" | ||
126 | +#include "qapi/error.h" | ||
127 | |||
128 | #include <libaio.h> | ||
129 | |||
130 | @@ -XXX,XX +XXX,XX @@ void laio_attach_aio_context(LinuxAioState *s, AioContext *new_context) | ||
131 | qemu_laio_poll_cb); | ||
132 | } | ||
133 | |||
134 | -LinuxAioState *laio_init(void) | ||
135 | +LinuxAioState *laio_init(Error **errp) | ||
136 | { | ||
137 | + int rc; | ||
138 | LinuxAioState *s; | ||
139 | |||
140 | s = g_malloc0(sizeof(*s)); | ||
141 | - if (event_notifier_init(&s->e, false) < 0) { | ||
142 | + rc = event_notifier_init(&s->e, false); | ||
143 | + if (rc < 0) { | ||
144 | + error_setg_errno(errp, -rc, "failed to to initialize event notifier"); | ||
145 | goto out_free_state; | ||
146 | } | 80 | } |
147 | 81 | ||
148 | - if (io_setup(MAX_EVENTS, &s->ctx) != 0) { | 82 | + if (bytes == 0 && !QEMU_IS_ALIGNED(offset, bs->bl.request_alignment)) { |
149 | + rc = io_setup(MAX_EVENTS, &s->ctx); | 83 | + /* |
150 | + if (rc < 0) { | 84 | + * Aligning zero request is nonsense. Even if driver has special meaning |
151 | + error_setg_errno(errp, -rc, "failed to create linux AIO context"); | 85 | + * of zero-length (like qcow2_co_pwritev_compressed_part), we can't pass |
152 | goto out_close_efd; | 86 | + * it to driver due to request_alignment. |
153 | } | 87 | + * |
154 | 88 | + * Still, no reason to return an error if someone do unaligned | |
155 | diff --git a/stubs/linux-aio.c b/stubs/linux-aio.c | 89 | + * zero-length write occasionally. |
156 | index XXXXXXX..XXXXXXX 100644 | 90 | + */ |
157 | --- a/stubs/linux-aio.c | 91 | + return 0; |
158 | +++ b/stubs/linux-aio.c | 92 | + } |
159 | @@ -XXX,XX +XXX,XX @@ void laio_attach_aio_context(LinuxAioState *s, AioContext *new_context) | ||
160 | abort(); | ||
161 | } | ||
162 | |||
163 | -LinuxAioState *laio_init(void) | ||
164 | +LinuxAioState *laio_init(Error **errp) | ||
165 | { | ||
166 | abort(); | ||
167 | } | ||
168 | diff --git a/util/async.c b/util/async.c | ||
169 | index XXXXXXX..XXXXXXX 100644 | ||
170 | --- a/util/async.c | ||
171 | +++ b/util/async.c | ||
172 | @@ -XXX,XX +XXX,XX @@ ThreadPool *aio_get_thread_pool(AioContext *ctx) | ||
173 | } | ||
174 | |||
175 | #ifdef CONFIG_LINUX_AIO | ||
176 | -LinuxAioState *aio_get_linux_aio(AioContext *ctx) | ||
177 | +LinuxAioState *aio_setup_linux_aio(AioContext *ctx, Error **errp) | ||
178 | { | ||
179 | if (!ctx->linux_aio) { | ||
180 | - ctx->linux_aio = laio_init(); | ||
181 | - laio_attach_aio_context(ctx->linux_aio, ctx); | ||
182 | + ctx->linux_aio = laio_init(errp); | ||
183 | + if (ctx->linux_aio) { | ||
184 | + laio_attach_aio_context(ctx->linux_aio, ctx); | ||
185 | + } | ||
186 | } | ||
187 | return ctx->linux_aio; | ||
188 | } | ||
189 | + | 93 | + |
190 | +LinuxAioState *aio_get_linux_aio(AioContext *ctx) | 94 | bdrv_inc_in_flight(bs); |
191 | +{ | 95 | /* |
192 | + assert(ctx->linux_aio); | 96 | * Align write if necessary by performing a read-modify-write cycle. |
193 | + return ctx->linux_aio; | ||
194 | +} | ||
195 | #endif | ||
196 | |||
197 | void aio_notify(AioContext *ctx) | ||
198 | -- | 97 | -- |
199 | 2.17.1 | 98 | 2.24.1 |
200 | 99 | ||
201 | 100 | diff view generated by jsdifflib |
1 | Determining the size of a field is useful when you don't have a struct | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | variable handy. Open-coding this is ugly. | ||
3 | 2 | ||
4 | This patch adds the sizeof_field() macro, which is similar to | 3 | Commit ed65fd1a2750 ("virtio-blk: switch off scsi-passthrough by |
5 | typeof_field(). Existing instances are updated to use the macro. | 4 | default") changed the default value of the 'scsi' property of |
5 | virtio-blk, which is only available on Linux hosts. It also added | ||
6 | an unconditional compat entry for 2.4 or earlier machines. | ||
6 | 7 | ||
7 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 8 | Trying to set this property on a pre-2.5 machine on OSX, we get: |
8 | Reviewed-by: John Snow <jsnow@redhat.com> | 9 | |
9 | Message-id: 20180614164431.29305-1-stefanha@redhat.com | 10 | Unexpected error in object_property_find() at qom/object.c:1201: |
11 | qemu-system-x86_64: -device virtio-blk-pci,id=scsi0,drive=drive0: can't apply global virtio-blk-device.scsi=true: Property '.scsi' not found | ||
12 | |||
13 | Fix this error by marking the property optional. | ||
14 | |||
15 | Fixes: ed65fd1a27 ("virtio-blk: switch off scsi-passthrough by default") | ||
16 | Suggested-by: Cornelia Huck <cohuck@redhat.com> | ||
17 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> | ||
18 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
19 | Reviewed-by: Michael S. Tsirkin <mst@redhat.com> | ||
20 | Message-id: 20200207001404.1739-1-philmd@redhat.com | ||
10 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 21 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
11 | --- | 22 | --- |
12 | include/hw/xen/io/ring.h | 2 +- | 23 | hw/core/machine.c | 3 ++- |
13 | include/qemu/compiler.h | 2 ++ | 24 | 1 file changed, 2 insertions(+), 1 deletion(-) |
14 | accel/tcg/translate-all.c | 2 +- | ||
15 | hw/display/xenfb.c | 4 ++-- | ||
16 | hw/net/rocker/rocker_of_dpa.c | 2 +- | ||
17 | hw/net/virtio-net.c | 2 +- | ||
18 | target/i386/kvm.c | 2 +- | ||
19 | target/ppc/arch_dump.c | 10 +++++----- | ||
20 | target/s390x/arch_dump.c | 20 ++++++++++---------- | ||
21 | 9 files changed, 24 insertions(+), 22 deletions(-) | ||
22 | 25 | ||
23 | diff --git a/include/hw/xen/io/ring.h b/include/hw/xen/io/ring.h | 26 | diff --git a/hw/core/machine.c b/hw/core/machine.c |
24 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/include/hw/xen/io/ring.h | 28 | --- a/hw/core/machine.c |
26 | +++ b/include/hw/xen/io/ring.h | 29 | +++ b/hw/core/machine.c |
27 | @@ -XXX,XX +XXX,XX @@ typedef unsigned int RING_IDX; | 30 | @@ -XXX,XX +XXX,XX @@ GlobalProperty hw_compat_2_5[] = { |
28 | */ | 31 | const size_t hw_compat_2_5_len = G_N_ELEMENTS(hw_compat_2_5); |
29 | #define __CONST_RING_SIZE(_s, _sz) \ | 32 | |
30 | (__RD32(((_sz) - offsetof(struct _s##_sring, ring)) / \ | 33 | GlobalProperty hw_compat_2_4[] = { |
31 | - sizeof(((struct _s##_sring *)0)->ring[0]))) | 34 | - { "virtio-blk-device", "scsi", "true" }, |
32 | + sizeof_field(struct _s##_sring, ring[0]))) | 35 | + /* Optional because the 'scsi' property is Linux-only */ |
33 | /* | 36 | + { "virtio-blk-device", "scsi", "true", .optional = true }, |
34 | * The same for passing in an actual pointer instead of a name tag. | 37 | { "e1000", "extra_mac_registers", "off" }, |
35 | */ | 38 | { "virtio-pci", "x-disable-pcie", "on" }, |
36 | diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h | 39 | { "virtio-pci", "migrate-extra", "off" }, |
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/include/qemu/compiler.h | ||
39 | +++ b/include/qemu/compiler.h | ||
40 | @@ -XXX,XX +XXX,XX @@ | ||
41 | (type *) ((char *) __mptr - offsetof(type, member));}) | ||
42 | #endif | ||
43 | |||
44 | +#define sizeof_field(type, field) sizeof(((type *)0)->field) | ||
45 | + | ||
46 | /* Convert from a base type to a parent type, with compile time checking. */ | ||
47 | #ifdef __GNUC__ | ||
48 | #define DO_UPCAST(type, field, dev) ( __extension__ ( { \ | ||
49 | diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/accel/tcg/translate-all.c | ||
52 | +++ b/accel/tcg/translate-all.c | ||
53 | @@ -XXX,XX +XXX,XX @@ struct page_collection { | ||
54 | |||
55 | /* Make sure all possible CPU event bits fit in tb->trace_vcpu_dstate */ | ||
56 | QEMU_BUILD_BUG_ON(CPU_TRACE_DSTATE_MAX_EVENTS > | ||
57 | - sizeof(((TranslationBlock *)0)->trace_vcpu_dstate) | ||
58 | + sizeof_field(TranslationBlock, trace_vcpu_dstate) | ||
59 | * BITS_PER_BYTE); | ||
60 | |||
61 | /* | ||
62 | diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c | ||
63 | index XXXXXXX..XXXXXXX 100644 | ||
64 | --- a/hw/display/xenfb.c | ||
65 | +++ b/hw/display/xenfb.c | ||
66 | @@ -XXX,XX +XXX,XX @@ static int xenfb_configure_fb(struct XenFB *xenfb, size_t fb_len_lim, | ||
67 | int width, int height, int depth, | ||
68 | size_t fb_len, int offset, int row_stride) | ||
69 | { | ||
70 | - size_t mfn_sz = sizeof(*((struct xenfb_page *)0)->pd); | ||
71 | - size_t pd_len = sizeof(((struct xenfb_page *)0)->pd) / mfn_sz; | ||
72 | + size_t mfn_sz = sizeof_field(struct xenfb_page, pd[0]); | ||
73 | + size_t pd_len = sizeof_field(struct xenfb_page, pd) / mfn_sz; | ||
74 | size_t fb_pages = pd_len * XC_PAGE_SIZE / mfn_sz; | ||
75 | size_t fb_len_max = fb_pages * XC_PAGE_SIZE; | ||
76 | int max_width, max_height; | ||
77 | diff --git a/hw/net/rocker/rocker_of_dpa.c b/hw/net/rocker/rocker_of_dpa.c | ||
78 | index XXXXXXX..XXXXXXX 100644 | ||
79 | --- a/hw/net/rocker/rocker_of_dpa.c | ||
80 | +++ b/hw/net/rocker/rocker_of_dpa.c | ||
81 | @@ -XXX,XX +XXX,XX @@ typedef struct of_dpa_flow_key { | ||
82 | |||
83 | /* Width of key which includes field 'f' in u64s, rounded up */ | ||
84 | #define FLOW_KEY_WIDTH(f) \ | ||
85 | - DIV_ROUND_UP(offsetof(OfDpaFlowKey, f) + sizeof(((OfDpaFlowKey *)0)->f), \ | ||
86 | + DIV_ROUND_UP(offsetof(OfDpaFlowKey, f) + sizeof_field(OfDpaFlowKey, f), \ | ||
87 | sizeof(uint64_t)) | ||
88 | |||
89 | typedef struct of_dpa_flow_action { | ||
90 | diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c | ||
91 | index XXXXXXX..XXXXXXX 100644 | ||
92 | --- a/hw/net/virtio-net.c | ||
93 | +++ b/hw/net/virtio-net.c | ||
94 | @@ -XXX,XX +XXX,XX @@ | ||
95 | * 'container'. | ||
96 | */ | ||
97 | #define endof(container, field) \ | ||
98 | - (offsetof(container, field) + sizeof(((container *)0)->field)) | ||
99 | + (offsetof(container, field) + sizeof_field(container, field)) | ||
100 | |||
101 | typedef struct VirtIOFeature { | ||
102 | uint64_t flags; | ||
103 | diff --git a/target/i386/kvm.c b/target/i386/kvm.c | ||
104 | index XXXXXXX..XXXXXXX 100644 | ||
105 | --- a/target/i386/kvm.c | ||
106 | +++ b/target/i386/kvm.c | ||
107 | @@ -XXX,XX +XXX,XX @@ static int kvm_put_fpu(X86CPU *cpu) | ||
108 | #define XSAVE_PKRU 672 | ||
109 | |||
110 | #define XSAVE_BYTE_OFFSET(word_offset) \ | ||
111 | - ((word_offset) * sizeof(((struct kvm_xsave *)0)->region[0])) | ||
112 | + ((word_offset) * sizeof_field(struct kvm_xsave, region[0])) | ||
113 | |||
114 | #define ASSERT_OFFSET(word_offset, field) \ | ||
115 | QEMU_BUILD_BUG_ON(XSAVE_BYTE_OFFSET(word_offset) != \ | ||
116 | diff --git a/target/ppc/arch_dump.c b/target/ppc/arch_dump.c | ||
117 | index XXXXXXX..XXXXXXX 100644 | ||
118 | --- a/target/ppc/arch_dump.c | ||
119 | +++ b/target/ppc/arch_dump.c | ||
120 | @@ -XXX,XX +XXX,XX @@ static const struct NoteFuncDescStruct { | ||
121 | int contents_size; | ||
122 | void (*note_contents_func)(NoteFuncArg *arg, PowerPCCPU *cpu); | ||
123 | } note_func[] = { | ||
124 | - {sizeof(((Note *)0)->contents.prstatus), ppc_write_elf_prstatus}, | ||
125 | - {sizeof(((Note *)0)->contents.fpregset), ppc_write_elf_fpregset}, | ||
126 | - {sizeof(((Note *)0)->contents.vmxregset), ppc_write_elf_vmxregset}, | ||
127 | - {sizeof(((Note *)0)->contents.vsxregset), ppc_write_elf_vsxregset}, | ||
128 | - {sizeof(((Note *)0)->contents.speregset), ppc_write_elf_speregset}, | ||
129 | + {sizeof_field(Note, contents.prstatus), ppc_write_elf_prstatus}, | ||
130 | + {sizeof_field(Note, contents.fpregset), ppc_write_elf_fpregset}, | ||
131 | + {sizeof_field(Note, contents.vmxregset), ppc_write_elf_vmxregset}, | ||
132 | + {sizeof_field(Note, contents.vsxregset), ppc_write_elf_vsxregset}, | ||
133 | + {sizeof_field(Note, contents.speregset), ppc_write_elf_speregset}, | ||
134 | { 0, NULL} | ||
135 | }; | ||
136 | |||
137 | diff --git a/target/s390x/arch_dump.c b/target/s390x/arch_dump.c | ||
138 | index XXXXXXX..XXXXXXX 100644 | ||
139 | --- a/target/s390x/arch_dump.c | ||
140 | +++ b/target/s390x/arch_dump.c | ||
141 | @@ -XXX,XX +XXX,XX @@ typedef struct NoteFuncDescStruct { | ||
142 | } NoteFuncDesc; | ||
143 | |||
144 | static const NoteFuncDesc note_core[] = { | ||
145 | - {sizeof(((Note *)0)->contents.prstatus), s390x_write_elf64_prstatus}, | ||
146 | - {sizeof(((Note *)0)->contents.fpregset), s390x_write_elf64_fpregset}, | ||
147 | + {sizeof_field(Note, contents.prstatus), s390x_write_elf64_prstatus}, | ||
148 | + {sizeof_field(Note, contents.fpregset), s390x_write_elf64_fpregset}, | ||
149 | { 0, NULL} | ||
150 | }; | ||
151 | |||
152 | static const NoteFuncDesc note_linux[] = { | ||
153 | - {sizeof(((Note *)0)->contents.prefix), s390x_write_elf64_prefix}, | ||
154 | - {sizeof(((Note *)0)->contents.ctrs), s390x_write_elf64_ctrs}, | ||
155 | - {sizeof(((Note *)0)->contents.timer), s390x_write_elf64_timer}, | ||
156 | - {sizeof(((Note *)0)->contents.todcmp), s390x_write_elf64_todcmp}, | ||
157 | - {sizeof(((Note *)0)->contents.todpreg), s390x_write_elf64_todpreg}, | ||
158 | - {sizeof(((Note *)0)->contents.vregslo), s390x_write_elf64_vregslo}, | ||
159 | - {sizeof(((Note *)0)->contents.vregshi), s390x_write_elf64_vregshi}, | ||
160 | - {sizeof(((Note *)0)->contents.gscb), s390x_write_elf64_gscb}, | ||
161 | + {sizeof_field(Note, contents.prefix), s390x_write_elf64_prefix}, | ||
162 | + {sizeof_field(Note, contents.ctrs), s390x_write_elf64_ctrs}, | ||
163 | + {sizeof_field(Note, contents.timer), s390x_write_elf64_timer}, | ||
164 | + {sizeof_field(Note, contents.todcmp), s390x_write_elf64_todcmp}, | ||
165 | + {sizeof_field(Note, contents.todpreg), s390x_write_elf64_todpreg}, | ||
166 | + {sizeof_field(Note, contents.vregslo), s390x_write_elf64_vregslo}, | ||
167 | + {sizeof_field(Note, contents.vregshi), s390x_write_elf64_vregshi}, | ||
168 | + {sizeof_field(Note, contents.gscb), s390x_write_elf64_gscb}, | ||
169 | { 0, NULL} | ||
170 | }; | ||
171 | |||
172 | -- | 40 | -- |
173 | 2.17.1 | 41 | 2.24.1 |
174 | 42 | ||
175 | 43 | diff view generated by jsdifflib |