1 | The following changes since commit 64175afc695c0672876fbbfc31b299c86d562cb4: | 1 | The following changes since commit 66234fee9c2d37bfbc523aa8d0ae5300a14cc10e: |
---|---|---|---|
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/alistair/tags/pull-riscv-to-apply-202= |
4 | 00603' into staging (2020-06-04 11:38:48 +0100) | ||
4 | 5 | ||
5 | are available in the git repository at: | 6 | are available in the Git repository at: |
6 | 7 | ||
7 | git://github.com/codyprime/qemu-kvm-jtc.git tags/block-pull-request | 8 | https://github.com/stefanha/qemu.git tags/block-pull-request |
8 | 9 | ||
9 | for you to fetch changes up to 56faeb9bb6872b3f926b3b3e0452a70beea10af2: | 10 | for you to fetch changes up to 7d2410cea154bf915fb30179ebda3b17ac36e70e: |
10 | 11 | ||
11 | block/gluster.c: Handle qdict_array_entries() failure (2017-06-09 08:41:29 -0400) | 12 | block: Factor out bdrv_run_co() (2020-06-05 09:54:48 +0100) |
12 | 13 | ||
13 | ---------------------------------------------------------------- | 14 | ---------------------------------------------------------------- |
14 | Gluster patch | 15 | Pull request |
16 | |||
15 | ---------------------------------------------------------------- | 17 | ---------------------------------------------------------------- |
16 | 18 | ||
17 | Peter Maydell (1): | 19 | Alexander Bulekov (4): |
18 | block/gluster.c: Handle qdict_array_entries() failure | 20 | fuzz: add datadir for oss-fuzz compatability |
21 | fuzz: fix typo in i440fx-qtest-reboot arguments | ||
22 | fuzz: add mangled object name to linker script | ||
23 | fuzz: run the main-loop in fork-server process | ||
19 | 24 | ||
20 | block/gluster.c | 3 +-- | 25 | Philippe Mathieu-Daud=C3=A9 (4): |
21 | 1 file changed, 1 insertion(+), 2 deletions(-) | 26 | memory: Rename memory_region_do_writeback -> memory_region_writeback |
27 | memory: Extract memory_region_msync() from memory_region_writeback() | ||
28 | hw/block: Let the NVMe emulated device be target-agnostic | ||
29 | exec: Rename qemu_ram_writeback() as qemu_ram_msync() | ||
22 | 30 | ||
23 | -- | 31 | Stefano Garzarella (2): |
24 | 2.9.3 | 32 | io_uring: retry io_uring_submit() if it fails with errno=3DEINTR |
33 | io_uring: use io_uring_cq_ready() to check for ready cqes | ||
25 | 34 | ||
35 | Vladimir Sementsov-Ogievskiy (1): | ||
36 | block: Factor out bdrv_run_co() | ||
26 | 37 | ||
38 | hw/block/Makefile.objs | 2 +- | ||
39 | include/exec/memory.h | 15 ++- | ||
40 | include/exec/ram_addr.h | 4 +- | ||
41 | include/sysemu/sysemu.h | 2 + | ||
42 | block/io.c | 193 +++++++++++----------------- | ||
43 | block/io_uring.c | 11 +- | ||
44 | exec.c | 2 +- | ||
45 | hw/block/nvme.c | 6 +- | ||
46 | memory.c | 12 +- | ||
47 | softmmu/vl.c | 2 +- | ||
48 | target/arm/helper.c | 2 +- | ||
49 | tests/qtest/fuzz/fuzz.c | 15 +++ | ||
50 | tests/qtest/fuzz/i440fx_fuzz.c | 3 +- | ||
51 | tests/qtest/fuzz/virtio_net_fuzz.c | 2 + | ||
52 | tests/qtest/fuzz/virtio_scsi_fuzz.c | 2 + | ||
53 | tests/qtest/fuzz/fork_fuzz.ld | 5 + | ||
54 | 16 files changed, 134 insertions(+), 144 deletions(-) | ||
55 | |||
56 | --=20 | ||
57 | 2.25.4 | ||
58 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Stefano Garzarella <sgarzare@redhat.com> | ||
1 | 2 | ||
3 | As recently documented [1], io_uring_enter(2) syscall can return an | ||
4 | error (errno=EINTR) if the operation was interrupted by a delivery | ||
5 | of a signal before it could complete. | ||
6 | |||
7 | This should happen when IORING_ENTER_GETEVENTS flag is used, for | ||
8 | example during io_uring_submit_and_wait() or during io_uring_submit() | ||
9 | when IORING_SETUP_IOPOLL is enabled. | ||
10 | |||
11 | We shouldn't have this problem for now, but it's better to prevent it. | ||
12 | |||
13 | [1] https://github.com/axboe/liburing/commit/344355ec6619de8f4e64584c9736530b5346e4f4 | ||
14 | |||
15 | Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> | ||
16 | Message-id: 20200519133041.112138-1-sgarzare@redhat.com | ||
17 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
18 | --- | ||
19 | block/io_uring.c | 2 +- | ||
20 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
21 | |||
22 | diff --git a/block/io_uring.c b/block/io_uring.c | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/block/io_uring.c | ||
25 | +++ b/block/io_uring.c | ||
26 | @@ -XXX,XX +XXX,XX @@ static int ioq_submit(LuringState *s) | ||
27 | trace_luring_io_uring_submit(s, ret); | ||
28 | /* Prevent infinite loop if submission is refused */ | ||
29 | if (ret <= 0) { | ||
30 | - if (ret == -EAGAIN) { | ||
31 | + if (ret == -EAGAIN || ret == -EINTR) { | ||
32 | continue; | ||
33 | } | ||
34 | break; | ||
35 | -- | ||
36 | 2.25.4 | ||
37 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Stefano Garzarella <sgarzare@redhat.com> | ||
1 | 2 | ||
3 | In qemu_luring_poll_cb() we are not using the cqe peeked from the | ||
4 | CQ ring. We are using io_uring_peek_cqe() only to see if there | ||
5 | are cqes ready, so we can replace it with io_uring_cq_ready(). | ||
6 | |||
7 | Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> | ||
8 | Message-id: 20200519134942.118178-1-sgarzare@redhat.com | ||
9 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
10 | --- | ||
11 | block/io_uring.c | 9 +++------ | ||
12 | 1 file changed, 3 insertions(+), 6 deletions(-) | ||
13 | |||
14 | diff --git a/block/io_uring.c b/block/io_uring.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/block/io_uring.c | ||
17 | +++ b/block/io_uring.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static void qemu_luring_completion_cb(void *opaque) | ||
19 | static bool qemu_luring_poll_cb(void *opaque) | ||
20 | { | ||
21 | LuringState *s = opaque; | ||
22 | - struct io_uring_cqe *cqes; | ||
23 | |||
24 | - if (io_uring_peek_cqe(&s->ring, &cqes) == 0) { | ||
25 | - if (cqes) { | ||
26 | - luring_process_completions_and_submit(s); | ||
27 | - return true; | ||
28 | - } | ||
29 | + if (io_uring_cq_ready(&s->ring)) { | ||
30 | + luring_process_completions_and_submit(s); | ||
31 | + return true; | ||
32 | } | ||
33 | |||
34 | return false; | ||
35 | -- | ||
36 | 2.25.4 | ||
37 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Alexander Bulekov <alxndr@bu.edu> | ||
1 | 2 | ||
3 | This allows us to keep pc-bios in executable_dir/pc-bios, rather than | ||
4 | executable_dir/../pc-bios, which is incompatible with oss-fuzz' file | ||
5 | structure. | ||
6 | |||
7 | Signed-off-by: Alexander Bulekov <alxndr@bu.edu> | ||
8 | Reviewed-by: Darren Kenny <darren.kenny@oracle.com> | ||
9 | Message-id: 20200512030133.29896-2-alxndr@bu.edu | ||
10 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
11 | --- | ||
12 | include/sysemu/sysemu.h | 2 ++ | ||
13 | softmmu/vl.c | 2 +- | ||
14 | tests/qtest/fuzz/fuzz.c | 15 +++++++++++++++ | ||
15 | 3 files changed, 18 insertions(+), 1 deletion(-) | ||
16 | |||
17 | diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/include/sysemu/sysemu.h | ||
20 | +++ b/include/sysemu/sysemu.h | ||
21 | @@ -XXX,XX +XXX,XX @@ extern const char *qemu_name; | ||
22 | extern QemuUUID qemu_uuid; | ||
23 | extern bool qemu_uuid_set; | ||
24 | |||
25 | +void qemu_add_data_dir(const char *path); | ||
26 | + | ||
27 | void qemu_add_exit_notifier(Notifier *notify); | ||
28 | void qemu_remove_exit_notifier(Notifier *notify); | ||
29 | |||
30 | diff --git a/softmmu/vl.c b/softmmu/vl.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/softmmu/vl.c | ||
33 | +++ b/softmmu/vl.c | ||
34 | @@ -XXX,XX +XXX,XX @@ char *qemu_find_file(int type, const char *name) | ||
35 | return NULL; | ||
36 | } | ||
37 | |||
38 | -static void qemu_add_data_dir(const char *path) | ||
39 | +void qemu_add_data_dir(const char *path) | ||
40 | { | ||
41 | int i; | ||
42 | |||
43 | diff --git a/tests/qtest/fuzz/fuzz.c b/tests/qtest/fuzz/fuzz.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/tests/qtest/fuzz/fuzz.c | ||
46 | +++ b/tests/qtest/fuzz/fuzz.c | ||
47 | @@ -XXX,XX +XXX,XX @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp) | ||
48 | { | ||
49 | |||
50 | char *target_name; | ||
51 | + char *dir; | ||
52 | |||
53 | /* Initialize qgraph and modules */ | ||
54 | qos_graph_init(); | ||
55 | @@ -XXX,XX +XXX,XX @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp) | ||
56 | target_name = strstr(**argv, "-target-"); | ||
57 | if (target_name) { /* The binary name specifies the target */ | ||
58 | target_name += strlen("-target-"); | ||
59 | + /* | ||
60 | + * With oss-fuzz, the executable is kept in the root of a directory (we | ||
61 | + * cannot assume the path). All data (including bios binaries) must be | ||
62 | + * in the same dir, or a subdir. Thus, we cannot place the pc-bios so | ||
63 | + * that it would be in exec_dir/../pc-bios. | ||
64 | + * As a workaround, oss-fuzz allows us to use argv[0] to get the | ||
65 | + * location of the executable. Using this we add exec_dir/pc-bios to | ||
66 | + * the datadirs. | ||
67 | + */ | ||
68 | + dir = g_build_filename(g_path_get_dirname(**argv), "pc-bios", NULL); | ||
69 | + if (g_file_test(dir, G_FILE_TEST_IS_DIR)) { | ||
70 | + qemu_add_data_dir(dir); | ||
71 | + } | ||
72 | + g_free(dir); | ||
73 | } else if (*argc > 1) { /* The target is specified as an argument */ | ||
74 | target_name = (*argv)[1]; | ||
75 | if (!strstr(target_name, "--fuzz-target=")) { | ||
76 | -- | ||
77 | 2.25.4 | ||
78 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Alexander Bulekov <alxndr@bu.edu> | ||
1 | 2 | ||
3 | Signed-off-by: Alexander Bulekov <alxndr@bu.edu> | ||
4 | Reviewed-by: Darren Kenny <darren.kenny@oracle.com> | ||
5 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
6 | Message-id: 20200512030133.29896-3-alxndr@bu.edu | ||
7 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
8 | --- | ||
9 | tests/qtest/fuzz/i440fx_fuzz.c | 2 +- | ||
10 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
11 | |||
12 | diff --git a/tests/qtest/fuzz/i440fx_fuzz.c b/tests/qtest/fuzz/i440fx_fuzz.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/tests/qtest/fuzz/i440fx_fuzz.c | ||
15 | +++ b/tests/qtest/fuzz/i440fx_fuzz.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static void i440fx_fuzz_qos_fork(QTestState *s, | ||
17 | } | ||
18 | |||
19 | static const char *i440fx_qtest_argv = TARGET_NAME " -machine accel=qtest" | ||
20 | - "-m 0 -display none"; | ||
21 | + " -m 0 -display none"; | ||
22 | static const char *i440fx_argv(FuzzTarget *t) | ||
23 | { | ||
24 | return i440fx_qtest_argv; | ||
25 | -- | ||
26 | 2.25.4 | ||
27 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Alexander Bulekov <alxndr@bu.edu> | ||
1 | 2 | ||
3 | Previously, we relied on "FuzzerTracePC*(.bss*)" to place libfuzzer's | ||
4 | fuzzer::TPC object into our contiguous shared-memory region. This does | ||
5 | not work for some libfuzzer builds, so this addition identifies the | ||
6 | region by its mangled name: *(.bss._ZN6fuzzer3TPCE); | ||
7 | |||
8 | Signed-off-by: Alexander Bulekov <alxndr@bu.edu> | ||
9 | Reviewed-by: Darren Kenny <darren.kenny@oracle.com> | ||
10 | Message-id: 20200512030133.29896-4-alxndr@bu.edu | ||
11 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
12 | --- | ||
13 | tests/qtest/fuzz/fork_fuzz.ld | 5 +++++ | ||
14 | 1 file changed, 5 insertions(+) | ||
15 | |||
16 | diff --git a/tests/qtest/fuzz/fork_fuzz.ld b/tests/qtest/fuzz/fork_fuzz.ld | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/tests/qtest/fuzz/fork_fuzz.ld | ||
19 | +++ b/tests/qtest/fuzz/fork_fuzz.ld | ||
20 | @@ -XXX,XX +XXX,XX @@ SECTIONS | ||
21 | |||
22 | /* Internal Libfuzzer TracePC object which contains the ValueProfileMap */ | ||
23 | FuzzerTracePC*(.bss*); | ||
24 | + /* | ||
25 | + * In case the above line fails, explicitly specify the (mangled) name of | ||
26 | + * the object we care about | ||
27 | + */ | ||
28 | + *(.bss._ZN6fuzzer3TPCE); | ||
29 | } | ||
30 | .data.fuzz_end : ALIGN(4K) | ||
31 | { | ||
32 | -- | ||
33 | 2.25.4 | ||
34 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Alexander Bulekov <alxndr@bu.edu> | ||
1 | 2 | ||
3 | Without this, the time since the last main-loop keeps increasing, as the | ||
4 | fuzzer runs. The forked children need to handle all the "past-due" | ||
5 | timers, slowing them down, over time. With this change, the | ||
6 | parent/fork-server process runs the main-loop, while waiting on the | ||
7 | child, ensuring that the timer events do not pile up, over time. | ||
8 | |||
9 | Signed-off-by: Alexander Bulekov <alxndr@bu.edu> | ||
10 | Reviewed-by: Darren Kenny <darren.kenny@oracle.com> | ||
11 | Message-id: 20200512030133.29896-5-alxndr@bu.edu | ||
12 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
13 | --- | ||
14 | tests/qtest/fuzz/i440fx_fuzz.c | 1 + | ||
15 | tests/qtest/fuzz/virtio_net_fuzz.c | 2 ++ | ||
16 | tests/qtest/fuzz/virtio_scsi_fuzz.c | 2 ++ | ||
17 | 3 files changed, 5 insertions(+) | ||
18 | |||
19 | diff --git a/tests/qtest/fuzz/i440fx_fuzz.c b/tests/qtest/fuzz/i440fx_fuzz.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/tests/qtest/fuzz/i440fx_fuzz.c | ||
22 | +++ b/tests/qtest/fuzz/i440fx_fuzz.c | ||
23 | @@ -XXX,XX +XXX,XX @@ static void i440fx_fuzz_qos_fork(QTestState *s, | ||
24 | i440fx_fuzz_qos(s, Data, Size); | ||
25 | _Exit(0); | ||
26 | } else { | ||
27 | + flush_events(s); | ||
28 | wait(NULL); | ||
29 | } | ||
30 | } | ||
31 | diff --git a/tests/qtest/fuzz/virtio_net_fuzz.c b/tests/qtest/fuzz/virtio_net_fuzz.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/tests/qtest/fuzz/virtio_net_fuzz.c | ||
34 | +++ b/tests/qtest/fuzz/virtio_net_fuzz.c | ||
35 | @@ -XXX,XX +XXX,XX @@ static void virtio_net_fork_fuzz(QTestState *s, | ||
36 | flush_events(s); | ||
37 | _Exit(0); | ||
38 | } else { | ||
39 | + flush_events(s); | ||
40 | wait(NULL); | ||
41 | } | ||
42 | } | ||
43 | @@ -XXX,XX +XXX,XX @@ static void virtio_net_fork_fuzz_check_used(QTestState *s, | ||
44 | flush_events(s); | ||
45 | _Exit(0); | ||
46 | } else { | ||
47 | + flush_events(s); | ||
48 | wait(NULL); | ||
49 | } | ||
50 | } | ||
51 | diff --git a/tests/qtest/fuzz/virtio_scsi_fuzz.c b/tests/qtest/fuzz/virtio_scsi_fuzz.c | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/tests/qtest/fuzz/virtio_scsi_fuzz.c | ||
54 | +++ b/tests/qtest/fuzz/virtio_scsi_fuzz.c | ||
55 | @@ -XXX,XX +XXX,XX @@ static void virtio_scsi_fork_fuzz(QTestState *s, | ||
56 | flush_events(s); | ||
57 | _Exit(0); | ||
58 | } else { | ||
59 | + flush_events(s); | ||
60 | wait(NULL); | ||
61 | } | ||
62 | } | ||
63 | @@ -XXX,XX +XXX,XX @@ static void virtio_scsi_with_flag_fuzz(QTestState *s, | ||
64 | } | ||
65 | _Exit(0); | ||
66 | } else { | ||
67 | + flush_events(s); | ||
68 | wait(NULL); | ||
69 | } | ||
70 | } | ||
71 | -- | ||
72 | 2.25.4 | ||
73 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
1 | 2 | ||
3 | We usually use '_do_' for internal functions. Rename | ||
4 | memory_region_do_writeback() as memory_region_writeback(). | ||
5 | |||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
7 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Acked-by: Paolo Bonzini <pbonzini@redhat.com> | ||
10 | Message-id: 20200508062456.23344-2-philmd@redhat.com | ||
11 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
12 | --- | ||
13 | include/exec/memory.h | 4 ++-- | ||
14 | memory.c | 2 +- | ||
15 | target/arm/helper.c | 2 +- | ||
16 | 3 files changed, 4 insertions(+), 4 deletions(-) | ||
17 | |||
18 | diff --git a/include/exec/memory.h b/include/exec/memory.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/include/exec/memory.h | ||
21 | +++ b/include/exec/memory.h | ||
22 | @@ -XXX,XX +XXX,XX @@ void *memory_region_get_ram_ptr(MemoryRegion *mr); | ||
23 | void memory_region_ram_resize(MemoryRegion *mr, ram_addr_t newsize, | ||
24 | Error **errp); | ||
25 | /** | ||
26 | - * memory_region_do_writeback: Trigger cache writeback or msync for | ||
27 | + * memory_region_writeback: Trigger cache writeback or msync for | ||
28 | * selected address range | ||
29 | * | ||
30 | * @mr: the memory region to be updated | ||
31 | * @addr: the initial address of the range to be written back | ||
32 | * @size: the size of the range to be written back | ||
33 | */ | ||
34 | -void memory_region_do_writeback(MemoryRegion *mr, hwaddr addr, hwaddr size); | ||
35 | +void memory_region_writeback(MemoryRegion *mr, hwaddr addr, hwaddr size); | ||
36 | |||
37 | /** | ||
38 | * memory_region_set_log: Turn dirty logging on or off for a region. | ||
39 | diff --git a/memory.c b/memory.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/memory.c | ||
42 | +++ b/memory.c | ||
43 | @@ -XXX,XX +XXX,XX @@ void memory_region_ram_resize(MemoryRegion *mr, ram_addr_t newsize, Error **errp | ||
44 | } | ||
45 | |||
46 | |||
47 | -void memory_region_do_writeback(MemoryRegion *mr, hwaddr addr, hwaddr size) | ||
48 | +void memory_region_writeback(MemoryRegion *mr, hwaddr addr, hwaddr size) | ||
49 | { | ||
50 | /* | ||
51 | * Might be extended case needed to cover | ||
52 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/target/arm/helper.c | ||
55 | +++ b/target/arm/helper.c | ||
56 | @@ -XXX,XX +XXX,XX @@ static void dccvap_writefn(CPUARMState *env, const ARMCPRegInfo *opaque, | ||
57 | mr = memory_region_from_host(haddr, &offset); | ||
58 | |||
59 | if (mr) { | ||
60 | - memory_region_do_writeback(mr, offset, dline_size); | ||
61 | + memory_region_writeback(mr, offset, dline_size); | ||
62 | } | ||
63 | } | ||
64 | } | ||
65 | -- | ||
66 | 2.25.4 | ||
67 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
1 | 2 | ||
3 | Suggested-by: Paolo Bonzini <pbonzini@redhat.com> | ||
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
5 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Acked-by: Paolo Bonzini <pbonzini@redhat.com> | ||
8 | Message-id: 20200508062456.23344-3-philmd@redhat.com | ||
9 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
10 | --- | ||
11 | include/exec/memory.h | 13 ++++++++++++- | ||
12 | memory.c | 10 ++++++++-- | ||
13 | 2 files changed, 20 insertions(+), 3 deletions(-) | ||
14 | |||
15 | diff --git a/include/exec/memory.h b/include/exec/memory.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/include/exec/memory.h | ||
18 | +++ b/include/exec/memory.h | ||
19 | @@ -XXX,XX +XXX,XX @@ void *memory_region_get_ram_ptr(MemoryRegion *mr); | ||
20 | */ | ||
21 | void memory_region_ram_resize(MemoryRegion *mr, ram_addr_t newsize, | ||
22 | Error **errp); | ||
23 | + | ||
24 | /** | ||
25 | - * memory_region_writeback: Trigger cache writeback or msync for | ||
26 | + * memory_region_msync: Synchronize selected address range of | ||
27 | + * a memory mapped region | ||
28 | + * | ||
29 | + * @mr: the memory region to be msync | ||
30 | + * @addr: the initial address of the range to be sync | ||
31 | + * @size: the size of the range to be sync | ||
32 | + */ | ||
33 | +void memory_region_msync(MemoryRegion *mr, hwaddr addr, hwaddr size); | ||
34 | + | ||
35 | +/** | ||
36 | + * memory_region_writeback: Trigger cache writeback for | ||
37 | * selected address range | ||
38 | * | ||
39 | * @mr: the memory region to be updated | ||
40 | diff --git a/memory.c b/memory.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/memory.c | ||
43 | +++ b/memory.c | ||
44 | @@ -XXX,XX +XXX,XX @@ void memory_region_ram_resize(MemoryRegion *mr, ram_addr_t newsize, Error **errp | ||
45 | qemu_ram_resize(mr->ram_block, newsize, errp); | ||
46 | } | ||
47 | |||
48 | +void memory_region_msync(MemoryRegion *mr, hwaddr addr, hwaddr size) | ||
49 | +{ | ||
50 | + if (mr->ram_block) { | ||
51 | + qemu_ram_writeback(mr->ram_block, addr, size); | ||
52 | + } | ||
53 | +} | ||
54 | |||
55 | void memory_region_writeback(MemoryRegion *mr, hwaddr addr, hwaddr size) | ||
56 | { | ||
57 | @@ -XXX,XX +XXX,XX @@ void memory_region_writeback(MemoryRegion *mr, hwaddr addr, hwaddr size) | ||
58 | * Might be extended case needed to cover | ||
59 | * different types of memory regions | ||
60 | */ | ||
61 | - if (mr->ram_block && mr->dirty_log_mask) { | ||
62 | - qemu_ram_writeback(mr->ram_block, addr, size); | ||
63 | + if (mr->dirty_log_mask) { | ||
64 | + memory_region_msync(mr, addr, size); | ||
65 | } | ||
66 | } | ||
67 | |||
68 | -- | ||
69 | 2.25.4 | ||
70 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
1 | 2 | ||
3 | Now than the non-target specific memory_region_msync() function | ||
4 | is available, use it to make this device target-agnostic. | ||
5 | |||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
7 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Acked-by: Paolo Bonzini <pbonzini@redhat.com> | ||
10 | Message-id: 20200508062456.23344-4-philmd@redhat.com | ||
11 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
12 | --- | ||
13 | hw/block/Makefile.objs | 2 +- | ||
14 | hw/block/nvme.c | 6 ++---- | ||
15 | 2 files changed, 3 insertions(+), 5 deletions(-) | ||
16 | |||
17 | diff --git a/hw/block/Makefile.objs b/hw/block/Makefile.objs | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/hw/block/Makefile.objs | ||
20 | +++ b/hw/block/Makefile.objs | ||
21 | @@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_SH4) += tc58128.o | ||
22 | |||
23 | obj-$(CONFIG_VIRTIO_BLK) += virtio-blk.o | ||
24 | obj-$(CONFIG_VHOST_USER_BLK) += vhost-user-blk.o | ||
25 | -obj-$(CONFIG_NVME_PCI) += nvme.o | ||
26 | +common-obj-$(CONFIG_NVME_PCI) += nvme.o | ||
27 | |||
28 | obj-y += dataplane/ | ||
29 | diff --git a/hw/block/nvme.c b/hw/block/nvme.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/hw/block/nvme.c | ||
32 | +++ b/hw/block/nvme.c | ||
33 | @@ -XXX,XX +XXX,XX @@ | ||
34 | #include "qapi/visitor.h" | ||
35 | #include "sysemu/hostmem.h" | ||
36 | #include "sysemu/block-backend.h" | ||
37 | -#include "exec/ram_addr.h" | ||
38 | - | ||
39 | +#include "exec/memory.h" | ||
40 | #include "qemu/log.h" | ||
41 | #include "qemu/module.h" | ||
42 | #include "qemu/cutils.h" | ||
43 | @@ -XXX,XX +XXX,XX @@ static uint64_t nvme_mmio_read(void *opaque, hwaddr addr, unsigned size) | ||
44 | */ | ||
45 | if (addr == 0xE08 && | ||
46 | (NVME_PMRCAP_PMRWBM(n->bar.pmrcap) & 0x02)) { | ||
47 | - qemu_ram_writeback(n->pmrdev->mr.ram_block, | ||
48 | - 0, n->pmrdev->size); | ||
49 | + memory_region_msync(&n->pmrdev->mr, 0, n->pmrdev->size); | ||
50 | } | ||
51 | memcpy(&val, ptr + addr, size); | ||
52 | } else { | ||
53 | -- | ||
54 | 2.25.4 | ||
55 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
1 | 2 | ||
3 | Rename qemu_ram_writeback() as qemu_ram_msync() to better | ||
4 | match what it does. | ||
5 | |||
6 | Suggested-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Acked-by: Paolo Bonzini <pbonzini@redhat.com> | ||
11 | Message-id: 20200508062456.23344-5-philmd@redhat.com | ||
12 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
13 | --- | ||
14 | include/exec/ram_addr.h | 4 ++-- | ||
15 | exec.c | 2 +- | ||
16 | memory.c | 2 +- | ||
17 | 3 files changed, 4 insertions(+), 4 deletions(-) | ||
18 | |||
19 | diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/include/exec/ram_addr.h | ||
22 | +++ b/include/exec/ram_addr.h | ||
23 | @@ -XXX,XX +XXX,XX @@ void qemu_ram_free(RAMBlock *block); | ||
24 | |||
25 | int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp); | ||
26 | |||
27 | -void qemu_ram_writeback(RAMBlock *block, ram_addr_t start, ram_addr_t length); | ||
28 | +void qemu_ram_msync(RAMBlock *block, ram_addr_t start, ram_addr_t length); | ||
29 | |||
30 | /* Clear whole block of mem */ | ||
31 | static inline void qemu_ram_block_writeback(RAMBlock *block) | ||
32 | { | ||
33 | - qemu_ram_writeback(block, 0, block->used_length); | ||
34 | + qemu_ram_msync(block, 0, block->used_length); | ||
35 | } | ||
36 | |||
37 | #define DIRTY_CLIENTS_ALL ((1 << DIRTY_MEMORY_NUM) - 1) | ||
38 | diff --git a/exec.c b/exec.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/exec.c | ||
41 | +++ b/exec.c | ||
42 | @@ -XXX,XX +XXX,XX @@ int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp) | ||
43 | * Otherwise no-op. | ||
44 | * @Note: this is supposed to be a synchronous op. | ||
45 | */ | ||
46 | -void qemu_ram_writeback(RAMBlock *block, ram_addr_t start, ram_addr_t length) | ||
47 | +void qemu_ram_msync(RAMBlock *block, ram_addr_t start, ram_addr_t length) | ||
48 | { | ||
49 | /* The requested range should fit in within the block range */ | ||
50 | g_assert((start + length) <= block->used_length); | ||
51 | diff --git a/memory.c b/memory.c | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/memory.c | ||
54 | +++ b/memory.c | ||
55 | @@ -XXX,XX +XXX,XX @@ void memory_region_ram_resize(MemoryRegion *mr, ram_addr_t newsize, Error **errp | ||
56 | void memory_region_msync(MemoryRegion *mr, hwaddr addr, hwaddr size) | ||
57 | { | ||
58 | if (mr->ram_block) { | ||
59 | - qemu_ram_writeback(mr->ram_block, addr, size); | ||
60 | + qemu_ram_msync(mr->ram_block, addr, size); | ||
61 | } | ||
62 | } | ||
63 | |||
64 | -- | ||
65 | 2.25.4 | ||
66 | diff view generated by jsdifflib |
1 | From: Peter Maydell <peter.maydell@linaro.org> | 1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> |
---|---|---|---|
2 | 2 | ||
3 | In qemu_gluster_parse_json(), the call to qdict_array_entries() | 3 | We have a few bdrv_*() functions that can either spawn a new coroutine |
4 | could return a negative error code, which we were ignoring | 4 | and wait for it with BDRV_POLL_WHILE() or use a fastpath if they are |
5 | because we assigned the result to an unsigned variable. | 5 | alreeady running in a coroutine. All of them duplicate basically the |
6 | Fix this by using the 'int' type instead, which matches the | 6 | same code. |
7 | return type of qdict_array_entries() and also the type | 7 | |
8 | we use for the loop enumeration variable 'i'. | 8 | Factor the common code into a new function bdrv_run_co(). |
9 | 9 | ||
10 | (Spotted by Coverity, CID 1360960.) | 10 | Signed-off-by: Kevin Wolf <kwolf@redhat.com> |
11 | 11 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | |
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Message-id: 20200520144901.16589-1-vsementsov@virtuozzo.com |
13 | Reviewed-by: Eric Blake <eblake@redhat.com> | 13 | [Factor out bdrv_run_co_entry too] |
14 | Reviewed-by: Jeff Cody <jcody@redhat.com> | 14 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
15 | Message-id: 1496682098-1540-1-git-send-email-peter.maydell@linaro.org | ||
16 | Signed-off-by: Jeff Cody <jcody@redhat.com> | ||
17 | --- | 15 | --- |
18 | block/gluster.c | 3 +-- | 16 | block/io.c | 193 ++++++++++++++++++++--------------------------------- |
19 | 1 file changed, 1 insertion(+), 2 deletions(-) | 17 | 1 file changed, 72 insertions(+), 121 deletions(-) |
20 | 18 | ||
21 | diff --git a/block/gluster.c b/block/gluster.c | 19 | diff --git a/block/io.c b/block/io.c |
22 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/block/gluster.c | 21 | --- a/block/io.c |
24 | +++ b/block/gluster.c | 22 | +++ b/block/io.c |
25 | @@ -XXX,XX +XXX,XX @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf, | 23 | @@ -XXX,XX +XXX,XX @@ |
26 | Error *local_err = NULL; | 24 | #include "qemu/main-loop.h" |
27 | char *str = NULL; | 25 | #include "sysemu/replay.h" |
28 | const char *ptr; | 26 | |
29 | - size_t num_servers; | 27 | -#define NOT_DONE 0x7fffffff /* used while emulated sync operation in progress */ |
30 | - int i, type; | 28 | - |
31 | + int i, type, num_servers; | 29 | /* Maximum bounce buffer for copy-on-read and write zeroes, in bytes */ |
32 | 30 | #define MAX_BOUNCE_BUFFER (32768 << BDRV_SECTOR_BITS) | |
33 | /* create opts info from runtime_json_opts list */ | 31 | |
34 | opts = qemu_opts_create(&runtime_json_opts, NULL, 0, &error_abort); | 32 | @@ -XXX,XX +XXX,XX @@ static int bdrv_check_byte_request(BlockDriverState *bs, int64_t offset, |
33 | return 0; | ||
34 | } | ||
35 | |||
36 | +typedef int coroutine_fn BdrvRequestEntry(void *opaque); | ||
37 | +typedef struct BdrvRunCo { | ||
38 | + BdrvRequestEntry *entry; | ||
39 | + void *opaque; | ||
40 | + int ret; | ||
41 | + bool done; | ||
42 | + Coroutine *co; /* Coroutine, running bdrv_run_co_entry, for debugging */ | ||
43 | +} BdrvRunCo; | ||
44 | + | ||
45 | +static void coroutine_fn bdrv_run_co_entry(void *opaque) | ||
46 | +{ | ||
47 | + BdrvRunCo *arg = opaque; | ||
48 | + | ||
49 | + arg->ret = arg->entry(arg->opaque); | ||
50 | + arg->done = true; | ||
51 | + aio_wait_kick(); | ||
52 | +} | ||
53 | + | ||
54 | +static int bdrv_run_co(BlockDriverState *bs, BdrvRequestEntry *entry, | ||
55 | + void *opaque) | ||
56 | +{ | ||
57 | + if (qemu_in_coroutine()) { | ||
58 | + /* Fast-path if already in coroutine context */ | ||
59 | + return entry(opaque); | ||
60 | + } else { | ||
61 | + BdrvRunCo s = { .entry = entry, .opaque = opaque }; | ||
62 | + | ||
63 | + s.co = qemu_coroutine_create(bdrv_run_co_entry, &s); | ||
64 | + bdrv_coroutine_enter(bs, s.co); | ||
65 | + | ||
66 | + BDRV_POLL_WHILE(bs, !s.done); | ||
67 | + | ||
68 | + return s.ret; | ||
69 | + } | ||
70 | +} | ||
71 | + | ||
72 | typedef struct RwCo { | ||
73 | BdrvChild *child; | ||
74 | int64_t offset; | ||
75 | QEMUIOVector *qiov; | ||
76 | bool is_write; | ||
77 | - int ret; | ||
78 | BdrvRequestFlags flags; | ||
79 | } RwCo; | ||
80 | |||
81 | -static void coroutine_fn bdrv_rw_co_entry(void *opaque) | ||
82 | +static int coroutine_fn bdrv_rw_co_entry(void *opaque) | ||
83 | { | ||
84 | RwCo *rwco = opaque; | ||
85 | |||
86 | if (!rwco->is_write) { | ||
87 | - rwco->ret = bdrv_co_preadv(rwco->child, rwco->offset, | ||
88 | - rwco->qiov->size, rwco->qiov, | ||
89 | - rwco->flags); | ||
90 | + return bdrv_co_preadv(rwco->child, rwco->offset, | ||
91 | + rwco->qiov->size, rwco->qiov, | ||
92 | + rwco->flags); | ||
93 | } else { | ||
94 | - rwco->ret = bdrv_co_pwritev(rwco->child, rwco->offset, | ||
95 | - rwco->qiov->size, rwco->qiov, | ||
96 | - rwco->flags); | ||
97 | + return bdrv_co_pwritev(rwco->child, rwco->offset, | ||
98 | + rwco->qiov->size, rwco->qiov, | ||
99 | + rwco->flags); | ||
100 | } | ||
101 | - aio_wait_kick(); | ||
102 | } | ||
103 | |||
104 | /* | ||
105 | @@ -XXX,XX +XXX,XX @@ static int bdrv_prwv_co(BdrvChild *child, int64_t offset, | ||
106 | QEMUIOVector *qiov, bool is_write, | ||
107 | BdrvRequestFlags flags) | ||
108 | { | ||
109 | - Coroutine *co; | ||
110 | RwCo rwco = { | ||
111 | .child = child, | ||
112 | .offset = offset, | ||
113 | .qiov = qiov, | ||
114 | .is_write = is_write, | ||
115 | - .ret = NOT_DONE, | ||
116 | .flags = flags, | ||
117 | }; | ||
118 | |||
119 | - if (qemu_in_coroutine()) { | ||
120 | - /* Fast-path if already in coroutine context */ | ||
121 | - bdrv_rw_co_entry(&rwco); | ||
122 | - } else { | ||
123 | - co = qemu_coroutine_create(bdrv_rw_co_entry, &rwco); | ||
124 | - bdrv_coroutine_enter(child->bs, co); | ||
125 | - BDRV_POLL_WHILE(child->bs, rwco.ret == NOT_DONE); | ||
126 | - } | ||
127 | - return rwco.ret; | ||
128 | + return bdrv_run_co(child->bs, bdrv_rw_co_entry, &rwco); | ||
129 | } | ||
130 | |||
131 | int bdrv_pwrite_zeroes(BdrvChild *child, int64_t offset, | ||
132 | @@ -XXX,XX +XXX,XX @@ typedef struct BdrvCoBlockStatusData { | ||
133 | int64_t *pnum; | ||
134 | int64_t *map; | ||
135 | BlockDriverState **file; | ||
136 | - int ret; | ||
137 | - bool done; | ||
138 | } BdrvCoBlockStatusData; | ||
139 | |||
140 | int coroutine_fn bdrv_co_block_status_from_file(BlockDriverState *bs, | ||
141 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_block_status_above(BlockDriverState *bs, | ||
142 | } | ||
143 | |||
144 | /* Coroutine wrapper for bdrv_block_status_above() */ | ||
145 | -static void coroutine_fn bdrv_block_status_above_co_entry(void *opaque) | ||
146 | +static int coroutine_fn bdrv_block_status_above_co_entry(void *opaque) | ||
147 | { | ||
148 | BdrvCoBlockStatusData *data = opaque; | ||
149 | |||
150 | - data->ret = bdrv_co_block_status_above(data->bs, data->base, | ||
151 | - data->want_zero, | ||
152 | - data->offset, data->bytes, | ||
153 | - data->pnum, data->map, data->file); | ||
154 | - data->done = true; | ||
155 | - aio_wait_kick(); | ||
156 | + return bdrv_co_block_status_above(data->bs, data->base, | ||
157 | + data->want_zero, | ||
158 | + data->offset, data->bytes, | ||
159 | + data->pnum, data->map, data->file); | ||
160 | } | ||
161 | |||
162 | /* | ||
163 | @@ -XXX,XX +XXX,XX @@ static int bdrv_common_block_status_above(BlockDriverState *bs, | ||
164 | int64_t *map, | ||
165 | BlockDriverState **file) | ||
166 | { | ||
167 | - Coroutine *co; | ||
168 | BdrvCoBlockStatusData data = { | ||
169 | .bs = bs, | ||
170 | .base = base, | ||
171 | @@ -XXX,XX +XXX,XX @@ static int bdrv_common_block_status_above(BlockDriverState *bs, | ||
172 | .pnum = pnum, | ||
173 | .map = map, | ||
174 | .file = file, | ||
175 | - .done = false, | ||
176 | }; | ||
177 | |||
178 | - if (qemu_in_coroutine()) { | ||
179 | - /* Fast-path if already in coroutine context */ | ||
180 | - bdrv_block_status_above_co_entry(&data); | ||
181 | - } else { | ||
182 | - co = qemu_coroutine_create(bdrv_block_status_above_co_entry, &data); | ||
183 | - bdrv_coroutine_enter(bs, co); | ||
184 | - BDRV_POLL_WHILE(bs, !data.done); | ||
185 | - } | ||
186 | - return data.ret; | ||
187 | + return bdrv_run_co(bs, bdrv_block_status_above_co_entry, &data); | ||
188 | } | ||
189 | |||
190 | int bdrv_block_status_above(BlockDriverState *bs, BlockDriverState *base, | ||
191 | @@ -XXX,XX +XXX,XX @@ typedef struct BdrvVmstateCo { | ||
192 | QEMUIOVector *qiov; | ||
193 | int64_t pos; | ||
194 | bool is_read; | ||
195 | - int ret; | ||
196 | } BdrvVmstateCo; | ||
197 | |||
198 | static int coroutine_fn | ||
199 | @@ -XXX,XX +XXX,XX @@ bdrv_co_rw_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos, | ||
200 | return ret; | ||
201 | } | ||
202 | |||
203 | -static void coroutine_fn bdrv_co_rw_vmstate_entry(void *opaque) | ||
204 | +static int coroutine_fn bdrv_co_rw_vmstate_entry(void *opaque) | ||
205 | { | ||
206 | BdrvVmstateCo *co = opaque; | ||
207 | - co->ret = bdrv_co_rw_vmstate(co->bs, co->qiov, co->pos, co->is_read); | ||
208 | - aio_wait_kick(); | ||
209 | + | ||
210 | + return bdrv_co_rw_vmstate(co->bs, co->qiov, co->pos, co->is_read); | ||
211 | } | ||
212 | |||
213 | static inline int | ||
214 | bdrv_rw_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos, | ||
215 | bool is_read) | ||
216 | { | ||
217 | - if (qemu_in_coroutine()) { | ||
218 | - return bdrv_co_rw_vmstate(bs, qiov, pos, is_read); | ||
219 | - } else { | ||
220 | - BdrvVmstateCo data = { | ||
221 | - .bs = bs, | ||
222 | - .qiov = qiov, | ||
223 | - .pos = pos, | ||
224 | - .is_read = is_read, | ||
225 | - .ret = -EINPROGRESS, | ||
226 | - }; | ||
227 | - Coroutine *co = qemu_coroutine_create(bdrv_co_rw_vmstate_entry, &data); | ||
228 | + BdrvVmstateCo data = { | ||
229 | + .bs = bs, | ||
230 | + .qiov = qiov, | ||
231 | + .pos = pos, | ||
232 | + .is_read = is_read, | ||
233 | + }; | ||
234 | |||
235 | - bdrv_coroutine_enter(bs, co); | ||
236 | - BDRV_POLL_WHILE(bs, data.ret == -EINPROGRESS); | ||
237 | - return data.ret; | ||
238 | - } | ||
239 | + return bdrv_run_co(bs, bdrv_co_rw_vmstate_entry, &data); | ||
240 | } | ||
241 | |||
242 | int bdrv_save_vmstate(BlockDriverState *bs, const uint8_t *buf, | ||
243 | @@ -XXX,XX +XXX,XX @@ void bdrv_aio_cancel_async(BlockAIOCB *acb) | ||
244 | /**************************************************************/ | ||
245 | /* Coroutine block device emulation */ | ||
246 | |||
247 | -typedef struct FlushCo { | ||
248 | - BlockDriverState *bs; | ||
249 | - int ret; | ||
250 | -} FlushCo; | ||
251 | - | ||
252 | - | ||
253 | -static void coroutine_fn bdrv_flush_co_entry(void *opaque) | ||
254 | +static int coroutine_fn bdrv_flush_co_entry(void *opaque) | ||
255 | { | ||
256 | - FlushCo *rwco = opaque; | ||
257 | - | ||
258 | - rwco->ret = bdrv_co_flush(rwco->bs); | ||
259 | - aio_wait_kick(); | ||
260 | + return bdrv_co_flush(opaque); | ||
261 | } | ||
262 | |||
263 | int coroutine_fn bdrv_co_flush(BlockDriverState *bs) | ||
264 | @@ -XXX,XX +XXX,XX @@ early_exit: | ||
265 | |||
266 | int bdrv_flush(BlockDriverState *bs) | ||
267 | { | ||
268 | - Coroutine *co; | ||
269 | - FlushCo flush_co = { | ||
270 | - .bs = bs, | ||
271 | - .ret = NOT_DONE, | ||
272 | - }; | ||
273 | - | ||
274 | - if (qemu_in_coroutine()) { | ||
275 | - /* Fast-path if already in coroutine context */ | ||
276 | - bdrv_flush_co_entry(&flush_co); | ||
277 | - } else { | ||
278 | - co = qemu_coroutine_create(bdrv_flush_co_entry, &flush_co); | ||
279 | - bdrv_coroutine_enter(bs, co); | ||
280 | - BDRV_POLL_WHILE(bs, flush_co.ret == NOT_DONE); | ||
281 | - } | ||
282 | - | ||
283 | - return flush_co.ret; | ||
284 | + return bdrv_run_co(bs, bdrv_flush_co_entry, bs); | ||
285 | } | ||
286 | |||
287 | typedef struct DiscardCo { | ||
288 | BdrvChild *child; | ||
289 | int64_t offset; | ||
290 | int64_t bytes; | ||
291 | - int ret; | ||
292 | } DiscardCo; | ||
293 | -static void coroutine_fn bdrv_pdiscard_co_entry(void *opaque) | ||
294 | + | ||
295 | +static int coroutine_fn bdrv_pdiscard_co_entry(void *opaque) | ||
296 | { | ||
297 | DiscardCo *rwco = opaque; | ||
298 | |||
299 | - rwco->ret = bdrv_co_pdiscard(rwco->child, rwco->offset, rwco->bytes); | ||
300 | - aio_wait_kick(); | ||
301 | + return bdrv_co_pdiscard(rwco->child, rwco->offset, rwco->bytes); | ||
302 | } | ||
303 | |||
304 | int coroutine_fn bdrv_co_pdiscard(BdrvChild *child, int64_t offset, | ||
305 | @@ -XXX,XX +XXX,XX @@ out: | ||
306 | |||
307 | int bdrv_pdiscard(BdrvChild *child, int64_t offset, int64_t bytes) | ||
308 | { | ||
309 | - Coroutine *co; | ||
310 | DiscardCo rwco = { | ||
311 | .child = child, | ||
312 | .offset = offset, | ||
313 | .bytes = bytes, | ||
314 | - .ret = NOT_DONE, | ||
315 | }; | ||
316 | |||
317 | - if (qemu_in_coroutine()) { | ||
318 | - /* Fast-path if already in coroutine context */ | ||
319 | - bdrv_pdiscard_co_entry(&rwco); | ||
320 | - } else { | ||
321 | - co = qemu_coroutine_create(bdrv_pdiscard_co_entry, &rwco); | ||
322 | - bdrv_coroutine_enter(child->bs, co); | ||
323 | - BDRV_POLL_WHILE(child->bs, rwco.ret == NOT_DONE); | ||
324 | - } | ||
325 | - | ||
326 | - return rwco.ret; | ||
327 | + return bdrv_run_co(child->bs, bdrv_pdiscard_co_entry, &rwco); | ||
328 | } | ||
329 | |||
330 | int bdrv_co_ioctl(BlockDriverState *bs, int req, void *buf) | ||
331 | @@ -XXX,XX +XXX,XX @@ typedef struct TruncateCo { | ||
332 | PreallocMode prealloc; | ||
333 | BdrvRequestFlags flags; | ||
334 | Error **errp; | ||
335 | - int ret; | ||
336 | } TruncateCo; | ||
337 | |||
338 | -static void coroutine_fn bdrv_truncate_co_entry(void *opaque) | ||
339 | +static int coroutine_fn bdrv_truncate_co_entry(void *opaque) | ||
340 | { | ||
341 | TruncateCo *tco = opaque; | ||
342 | - tco->ret = bdrv_co_truncate(tco->child, tco->offset, tco->exact, | ||
343 | - tco->prealloc, tco->flags, tco->errp); | ||
344 | - aio_wait_kick(); | ||
345 | + | ||
346 | + return bdrv_co_truncate(tco->child, tco->offset, tco->exact, | ||
347 | + tco->prealloc, tco->flags, tco->errp); | ||
348 | } | ||
349 | |||
350 | int bdrv_truncate(BdrvChild *child, int64_t offset, bool exact, | ||
351 | PreallocMode prealloc, BdrvRequestFlags flags, Error **errp) | ||
352 | { | ||
353 | - Coroutine *co; | ||
354 | TruncateCo tco = { | ||
355 | .child = child, | ||
356 | .offset = offset, | ||
357 | @@ -XXX,XX +XXX,XX @@ int bdrv_truncate(BdrvChild *child, int64_t offset, bool exact, | ||
358 | .prealloc = prealloc, | ||
359 | .flags = flags, | ||
360 | .errp = errp, | ||
361 | - .ret = NOT_DONE, | ||
362 | }; | ||
363 | |||
364 | - if (qemu_in_coroutine()) { | ||
365 | - /* Fast-path if already in coroutine context */ | ||
366 | - bdrv_truncate_co_entry(&tco); | ||
367 | - } else { | ||
368 | - co = qemu_coroutine_create(bdrv_truncate_co_entry, &tco); | ||
369 | - bdrv_coroutine_enter(child->bs, co); | ||
370 | - BDRV_POLL_WHILE(child->bs, tco.ret == NOT_DONE); | ||
371 | - } | ||
372 | - | ||
373 | - return tco.ret; | ||
374 | + return bdrv_run_co(child->bs, bdrv_truncate_co_entry, &tco); | ||
375 | } | ||
35 | -- | 376 | -- |
36 | 2.9.3 | 377 | 2.25.4 |
37 | 378 | ||
38 | diff view generated by jsdifflib |