1
The following changes since commit 66234fee9c2d37bfbc523aa8d0ae5300a14cc10e:
1
The following changes since commit 7208429223963c405c62fa2611398f1aa8033593:
2
2
3
Merge remote-tracking branch 'remotes/alistair/tags/pull-riscv-to-apply-202=
3
Merge tag 'mem-2022-10-28' of https://github.com/davidhildenbrand/qemu into staging (2022-10-30 18:31:59 -0400)
4
00603' into staging (2020-06-04 11:38:48 +0100)
5
4
6
are available in the Git repository at:
5
are available in the Git repository at:
7
6
8
https://github.com/stefanha/qemu.git tags/block-pull-request
7
https://gitlab.com/stefanha/qemu.git tags/block-pull-request
9
8
10
for you to fetch changes up to 7d2410cea154bf915fb30179ebda3b17ac36e70e:
9
for you to fetch changes up to 6c32fc0df9cd901add75618c831fb26a9eb742cb:
11
10
12
block: Factor out bdrv_run_co() (2020-06-05 09:54:48 +0100)
11
block/blkio: Make driver nvme-io_uring take a "path" instead of a "filename" (2022-10-31 14:35:14 -0400)
13
12
14
----------------------------------------------------------------
13
----------------------------------------------------------------
15
Pull request
14
Pull request
16
15
16
Note that we're still discussing "block/blkio: Make driver nvme-io_uring take a
17
"path" instead of a "filename"". I have sent the pull request now so everything
18
is ready for the soft freeze tomorrow if we decide to go ahead with the patch.
19
17
----------------------------------------------------------------
20
----------------------------------------------------------------
18
21
19
Alexander Bulekov (4):
22
Alberto Faria (3):
20
fuzz: add datadir for oss-fuzz compatability
23
block/blkio: Add virtio-blk-vfio-pci BlockDriver
21
fuzz: fix typo in i440fx-qtest-reboot arguments
24
block/blkio: Tolerate device size changes
22
fuzz: add mangled object name to linker script
25
block/blkio: Make driver nvme-io_uring take a "path" instead of a
23
fuzz: run the main-loop in fork-server process
26
"filename"
24
27
25
Philippe Mathieu-Daud=C3=A9 (4):
28
qapi/block-core.json | 22 +++++++++++++++++++--
26
memory: Rename memory_region_do_writeback -> memory_region_writeback
29
block/blkio.c | 47 ++++++++++++++++++++++++++++++++++++++++----
27
memory: Extract memory_region_msync() from memory_region_writeback()
30
2 files changed, 63 insertions(+), 6 deletions(-)
28
hw/block: Let the NVMe emulated device be target-agnostic
29
exec: Rename qemu_ram_writeback() as qemu_ram_msync()
30
31
31
Stefano Garzarella (2):
32
--
32
io_uring: retry io_uring_submit() if it fails with errno=3DEINTR
33
2.38.1
33
io_uring: use io_uring_cq_ready() to check for ready cqes
34
35
Vladimir Sementsov-Ogievskiy (1):
36
block: Factor out bdrv_run_co()
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
Deleted patch
1
From: Stefano Garzarella <sgarzare@redhat.com>
2
1
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
Deleted patch
1
From: Stefano Garzarella <sgarzare@redhat.com>
2
1
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
Deleted patch
1
From: Alexander Bulekov <alxndr@bu.edu>
2
1
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
Deleted patch
1
From: Alexander Bulekov <alxndr@bu.edu>
2
1
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
Deleted patch
1
From: Alexander Bulekov <alxndr@bu.edu>
2
1
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
1
From: Alexander Bulekov <alxndr@bu.edu>
1
From: Alberto Faria <afaria@redhat.com>
2
2
3
Without this, the time since the last main-loop keeps increasing, as the
3
libblkio 1.1.0 [1] introduces a virtio-blk-vfio-pci driver, which
4
fuzzer runs. The forked children need to handle all the "past-due"
4
accesses a virtio-blk PCI device using VFIO. Add a corresponding
5
timers, slowing them down, over time. With this change, the
5
BlockDriver.
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
6
9
Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
7
[1] https://gitlab.com/libblkio/libblkio/-/tree/v1.1.0
10
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
8
11
Message-id: 20200512030133.29896-5-alxndr@bu.edu
9
Signed-off-by: Alberto Faria <afaria@redhat.com>
10
Message-id: 20221028131635.710267-1-afaria@redhat.com
12
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
13
---
12
---
14
tests/qtest/fuzz/i440fx_fuzz.c | 1 +
13
qapi/block-core.json | 18 ++++++++++++++++++
15
tests/qtest/fuzz/virtio_net_fuzz.c | 2 ++
14
block/blkio.c | 8 ++++++++
16
tests/qtest/fuzz/virtio_scsi_fuzz.c | 2 ++
15
2 files changed, 26 insertions(+)
17
3 files changed, 5 insertions(+)
18
16
19
diff --git a/tests/qtest/fuzz/i440fx_fuzz.c b/tests/qtest/fuzz/i440fx_fuzz.c
17
diff --git a/qapi/block-core.json b/qapi/block-core.json
20
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
21
--- a/tests/qtest/fuzz/i440fx_fuzz.c
19
--- a/qapi/block-core.json
22
+++ b/tests/qtest/fuzz/i440fx_fuzz.c
20
+++ b/qapi/block-core.json
23
@@ -XXX,XX +XXX,XX @@ static void i440fx_fuzz_qos_fork(QTestState *s,
21
@@ -XXX,XX +XXX,XX @@
24
i440fx_fuzz_qos(s, Data, Size);
22
'raw', 'rbd',
25
_Exit(0);
23
{ 'name': 'replication', 'if': 'CONFIG_REPLICATION' },
26
} else {
24
'ssh', 'throttle', 'vdi', 'vhdx',
27
+ flush_events(s);
25
+ { 'name': 'virtio-blk-vfio-pci', 'if': 'CONFIG_BLKIO' },
28
wait(NULL);
26
{ 'name': 'virtio-blk-vhost-user', 'if': 'CONFIG_BLKIO' },
29
}
27
{ 'name': 'virtio-blk-vhost-vdpa', 'if': 'CONFIG_BLKIO' },
30
}
28
'vmdk', 'vpc', 'vvfat' ] }
31
diff --git a/tests/qtest/fuzz/virtio_net_fuzz.c b/tests/qtest/fuzz/virtio_net_fuzz.c
29
@@ -XXX,XX +XXX,XX @@
30
'data': { 'filename': 'str' },
31
'if': 'CONFIG_BLKIO' }
32
33
+##
34
+# @BlockdevOptionsVirtioBlkVfioPci:
35
+#
36
+# Driver specific block device options for the virtio-blk-vfio-pci backend.
37
+#
38
+# @path: path to the PCI device's sysfs directory (e.g.
39
+# /sys/bus/pci/devices/0000:00:01.0).
40
+#
41
+# Since: 7.2
42
+##
43
+{ 'struct': 'BlockdevOptionsVirtioBlkVfioPci',
44
+ 'data': { 'path': 'str' },
45
+ 'if': 'CONFIG_BLKIO' }
46
+
47
##
48
# @BlockdevOptionsVirtioBlkVhostUser:
49
#
50
@@ -XXX,XX +XXX,XX @@
51
'throttle': 'BlockdevOptionsThrottle',
52
'vdi': 'BlockdevOptionsGenericFormat',
53
'vhdx': 'BlockdevOptionsGenericFormat',
54
+ 'virtio-blk-vfio-pci':
55
+ { 'type': 'BlockdevOptionsVirtioBlkVfioPci',
56
+ 'if': 'CONFIG_BLKIO' },
57
'virtio-blk-vhost-user':
58
{ 'type': 'BlockdevOptionsVirtioBlkVhostUser',
59
'if': 'CONFIG_BLKIO' },
60
diff --git a/block/blkio.c b/block/blkio.c
32
index XXXXXXX..XXXXXXX 100644
61
index XXXXXXX..XXXXXXX 100644
33
--- a/tests/qtest/fuzz/virtio_net_fuzz.c
62
--- a/block/blkio.c
34
+++ b/tests/qtest/fuzz/virtio_net_fuzz.c
63
+++ b/block/blkio.c
35
@@ -XXX,XX +XXX,XX @@ static void virtio_net_fork_fuzz(QTestState *s,
64
@@ -XXX,XX +XXX,XX @@
36
flush_events(s);
65
*/
37
_Exit(0);
66
#define DRIVER_IO_URING "io_uring"
38
} else {
67
#define DRIVER_NVME_IO_URING "nvme-io_uring"
39
+ flush_events(s);
68
+#define DRIVER_VIRTIO_BLK_VFIO_PCI "virtio-blk-vfio-pci"
40
wait(NULL);
69
#define DRIVER_VIRTIO_BLK_VHOST_USER "virtio-blk-vhost-user"
41
}
70
#define DRIVER_VIRTIO_BLK_VHOST_VDPA "virtio-blk-vhost-vdpa"
42
}
71
43
@@ -XXX,XX +XXX,XX @@ static void virtio_net_fork_fuzz_check_used(QTestState *s,
72
@@ -XXX,XX +XXX,XX @@ static int blkio_file_open(BlockDriverState *bs, QDict *options, int flags,
44
flush_events(s);
73
ret = blkio_io_uring_open(bs, options, flags, errp);
45
_Exit(0);
74
} else if (strcmp(blkio_driver, DRIVER_NVME_IO_URING) == 0) {
46
} else {
75
ret = blkio_nvme_io_uring(bs, options, flags, errp);
47
+ flush_events(s);
76
+ } else if (strcmp(blkio_driver, DRIVER_VIRTIO_BLK_VFIO_PCI) == 0) {
48
wait(NULL);
77
+ ret = blkio_virtio_blk_common_open(bs, options, flags, errp);
49
}
78
} else if (strcmp(blkio_driver, DRIVER_VIRTIO_BLK_VHOST_USER) == 0) {
50
}
79
ret = blkio_virtio_blk_common_open(bs, options, flags, errp);
51
diff --git a/tests/qtest/fuzz/virtio_scsi_fuzz.c b/tests/qtest/fuzz/virtio_scsi_fuzz.c
80
} else if (strcmp(blkio_driver, DRIVER_VIRTIO_BLK_VHOST_VDPA) == 0) {
52
index XXXXXXX..XXXXXXX 100644
81
@@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_nvme_io_uring = BLKIO_DRIVER(
53
--- a/tests/qtest/fuzz/virtio_scsi_fuzz.c
82
.bdrv_needs_filename = true,
54
+++ b/tests/qtest/fuzz/virtio_scsi_fuzz.c
83
);
55
@@ -XXX,XX +XXX,XX @@ static void virtio_scsi_fork_fuzz(QTestState *s,
84
56
flush_events(s);
85
+static BlockDriver bdrv_virtio_blk_vfio_pci = BLKIO_DRIVER(
57
_Exit(0);
86
+ DRIVER_VIRTIO_BLK_VFIO_PCI
58
} else {
87
+);
59
+ flush_events(s);
88
+
60
wait(NULL);
89
static BlockDriver bdrv_virtio_blk_vhost_user = BLKIO_DRIVER(
61
}
90
DRIVER_VIRTIO_BLK_VHOST_USER
62
}
91
);
63
@@ -XXX,XX +XXX,XX @@ static void virtio_scsi_with_flag_fuzz(QTestState *s,
92
@@ -XXX,XX +XXX,XX @@ static void bdrv_blkio_init(void)
64
}
93
{
65
_Exit(0);
94
bdrv_register(&bdrv_io_uring);
66
} else {
95
bdrv_register(&bdrv_nvme_io_uring);
67
+ flush_events(s);
96
+ bdrv_register(&bdrv_virtio_blk_vfio_pci);
68
wait(NULL);
97
bdrv_register(&bdrv_virtio_blk_vhost_user);
69
}
98
bdrv_register(&bdrv_virtio_blk_vhost_vdpa);
70
}
99
}
71
--
100
--
72
2.25.4
101
2.38.1
73
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
1
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
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
1
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
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
1
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
1
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
1
From: Alberto Faria <afaria@redhat.com>
2
2
3
We have a few bdrv_*() functions that can either spawn a new coroutine
3
Some libblkio drivers may be able to work with regular files (e.g.,
4
and wait for it with BDRV_POLL_WHILE() or use a fastpath if they are
4
io_uring) or otherwise resizable devices. Conservatively set
5
alreeady running in a coroutine. All of them duplicate basically the
5
BlockDriver::has_variable_length to true to ensure bdrv_nb_sectors()
6
same code.
6
always gives up-to-date results.
7
7
8
Factor the common code into a new function bdrv_run_co().
8
Also implement BlockDriver::bdrv_co_truncate for the case where no
9
preallocation is needed and the device already has a size compatible
10
with what was requested.
9
11
10
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
12
Signed-off-by: Alberto Faria <afaria@redhat.com>
11
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
13
Message-id: 20221029122031.975273-1-afaria@redhat.com
12
Message-id: 20200520144901.16589-1-vsementsov@virtuozzo.com
13
[Factor out bdrv_run_co_entry too]
14
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
14
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
15
---
15
---
16
block/io.c | 193 ++++++++++++++++++++---------------------------------
16
block/blkio.c | 27 +++++++++++++++++++++++++++
17
1 file changed, 72 insertions(+), 121 deletions(-)
17
1 file changed, 27 insertions(+)
18
18
19
diff --git a/block/io.c b/block/io.c
19
diff --git a/block/blkio.c b/block/blkio.c
20
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
21
--- a/block/io.c
21
--- a/block/blkio.c
22
+++ b/block/io.c
22
+++ b/block/blkio.c
23
@@ -XXX,XX +XXX,XX @@
23
@@ -XXX,XX +XXX,XX @@ static int64_t blkio_getlength(BlockDriverState *bs)
24
#include "qemu/main-loop.h"
24
return capacity;
25
#include "sysemu/replay.h"
26
27
-#define NOT_DONE 0x7fffffff /* used while emulated sync operation in progress */
28
-
29
/* Maximum bounce buffer for copy-on-read and write zeroes, in bytes */
30
#define MAX_BOUNCE_BUFFER (32768 << BDRV_SECTOR_BITS)
31
32
@@ -XXX,XX +XXX,XX @@ static int bdrv_check_byte_request(BlockDriverState *bs, int64_t offset,
33
return 0;
34
}
25
}
35
26
36
+typedef int coroutine_fn BdrvRequestEntry(void *opaque);
27
+static int coroutine_fn blkio_truncate(BlockDriverState *bs, int64_t offset,
37
+typedef struct BdrvRunCo {
28
+ bool exact, PreallocMode prealloc,
38
+ BdrvRequestEntry *entry;
29
+ BdrvRequestFlags flags, Error **errp)
39
+ void *opaque;
30
+{
40
+ int ret;
31
+ int64_t current_length;
41
+ bool done;
42
+ Coroutine *co; /* Coroutine, running bdrv_run_co_entry, for debugging */
43
+} BdrvRunCo;
44
+
32
+
45
+static void coroutine_fn bdrv_run_co_entry(void *opaque)
33
+ if (prealloc != PREALLOC_MODE_OFF) {
46
+{
34
+ error_setg(errp, "Unsupported preallocation mode '%s'",
47
+ BdrvRunCo *arg = opaque;
35
+ PreallocMode_str(prealloc));
36
+ return -ENOTSUP;
37
+ }
48
+
38
+
49
+ arg->ret = arg->entry(arg->opaque);
39
+ current_length = blkio_getlength(bs);
50
+ arg->done = true;
40
+
51
+ aio_wait_kick();
41
+ if (offset > current_length) {
42
+ error_setg(errp, "Cannot grow device");
43
+ return -EINVAL;
44
+ } else if (exact && offset != current_length) {
45
+ error_setg(errp, "Cannot resize device");
46
+ return -ENOTSUP;
47
+ }
48
+
49
+ return 0;
52
+}
50
+}
53
+
51
+
54
+static int bdrv_run_co(BlockDriverState *bs, BdrvRequestEntry *entry,
52
static int blkio_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
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
{
53
{
84
RwCo *rwco = opaque;
54
return 0;
85
55
@@ -XXX,XX +XXX,XX @@ static void blkio_refresh_limits(BlockDriverState *bs, Error **errp)
86
if (!rwco->is_write) {
56
{ \
87
- rwco->ret = bdrv_co_preadv(rwco->child, rwco->offset,
57
.format_name = name, \
88
- rwco->qiov->size, rwco->qiov,
58
.protocol_name = name, \
89
- rwco->flags);
59
+ .has_variable_length = true, \
90
+ return bdrv_co_preadv(rwco->child, rwco->offset,
60
.instance_size = sizeof(BDRVBlkioState), \
91
+ rwco->qiov->size, rwco->qiov,
61
.bdrv_file_open = blkio_file_open, \
92
+ rwco->flags);
62
.bdrv_close = blkio_close, \
93
} else {
63
.bdrv_getlength = blkio_getlength, \
94
- rwco->ret = bdrv_co_pwritev(rwco->child, rwco->offset,
64
+ .bdrv_co_truncate = blkio_truncate, \
95
- rwco->qiov->size, rwco->qiov,
65
.bdrv_get_info = blkio_get_info, \
96
- rwco->flags);
66
.bdrv_attach_aio_context = blkio_attach_aio_context, \
97
+ return bdrv_co_pwritev(rwco->child, rwco->offset,
67
.bdrv_detach_aio_context = blkio_detach_aio_context, \
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
}
376
--
68
--
377
2.25.4
69
2.38.1
378
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Alberto Faria <afaria@redhat.com>
2
2
3
Rename qemu_ram_writeback() as qemu_ram_msync() to better
3
The nvme-io_uring driver expects a character special file such as
4
match what it does.
4
/dev/ng0n1. Follow the convention of having a "filename" option when a
5
regular file is expected, and a "path" option otherwise.
5
6
6
Suggested-by: Stefan Hajnoczi <stefanha@redhat.com>
7
This makes io_uring the only libblkio-based driver with a "filename"
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
option, as it accepts a regular file (even though it can also take a
8
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
9
block special file).
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
10
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
11
Signed-off-by: Alberto Faria <afaria@redhat.com>
11
Message-id: 20200508062456.23344-5-philmd@redhat.com
12
Message-id: 20221028233854.839933-1-afaria@redhat.com
12
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
13
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
13
---
14
---
14
include/exec/ram_addr.h | 4 ++--
15
qapi/block-core.json | 4 ++--
15
exec.c | 2 +-
16
block/blkio.c | 12 ++++++++----
16
memory.c | 2 +-
17
2 files changed, 10 insertions(+), 6 deletions(-)
17
3 files changed, 4 insertions(+), 4 deletions(-)
18
18
19
diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h
19
diff --git a/qapi/block-core.json b/qapi/block-core.json
20
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
21
--- a/include/exec/ram_addr.h
21
--- a/qapi/block-core.json
22
+++ b/include/exec/ram_addr.h
22
+++ b/qapi/block-core.json
23
@@ -XXX,XX +XXX,XX @@ void qemu_ram_free(RAMBlock *block);
23
@@ -XXX,XX +XXX,XX @@
24
24
#
25
int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp);
25
# Driver specific block device options for the nvme-io_uring backend.
26
26
#
27
-void qemu_ram_writeback(RAMBlock *block, ram_addr_t start, ram_addr_t length);
27
-# @filename: path to the image file
28
+void qemu_ram_msync(RAMBlock *block, ram_addr_t start, ram_addr_t length);
28
+# @path: path to the image file
29
29
#
30
/* Clear whole block of mem */
30
# Since: 7.2
31
static inline void qemu_ram_block_writeback(RAMBlock *block)
31
##
32
{ 'struct': 'BlockdevOptionsNvmeIoUring',
33
- 'data': { 'filename': 'str' },
34
+ 'data': { 'path': 'str' },
35
'if': 'CONFIG_BLKIO' }
36
37
##
38
diff --git a/block/blkio.c b/block/blkio.c
39
index XXXXXXX..XXXXXXX 100644
40
--- a/block/blkio.c
41
+++ b/block/blkio.c
42
@@ -XXX,XX +XXX,XX @@ static int blkio_io_uring_open(BlockDriverState *bs, QDict *options, int flags,
43
static int blkio_nvme_io_uring(BlockDriverState *bs, QDict *options, int flags,
44
Error **errp)
32
{
45
{
33
- qemu_ram_writeback(block, 0, block->used_length);
46
- const char *filename = qdict_get_str(options, "filename");
34
+ qemu_ram_msync(block, 0, block->used_length);
47
+ const char *path = qdict_get_try_str(options, "path");
35
}
48
BDRVBlkioState *s = bs->opaque;
36
49
int ret;
37
#define DIRTY_CLIENTS_ALL ((1 << DIRTY_MEMORY_NUM) - 1)
50
38
diff --git a/exec.c b/exec.c
51
- ret = blkio_set_str(s->blkio, "path", filename);
39
index XXXXXXX..XXXXXXX 100644
52
- qdict_del(options, "filename");
40
--- a/exec.c
53
+ if (!path) {
41
+++ b/exec.c
54
+ error_setg(errp, "missing 'path' option");
42
@@ -XXX,XX +XXX,XX @@ int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp)
55
+ return -EINVAL;
43
* Otherwise no-op.
56
+ }
44
* @Note: this is supposed to be a synchronous op.
57
+
45
*/
58
+ ret = blkio_set_str(s->blkio, "path", path);
46
-void qemu_ram_writeback(RAMBlock *block, ram_addr_t start, ram_addr_t length)
59
+ qdict_del(options, "path");
47
+void qemu_ram_msync(RAMBlock *block, ram_addr_t start, ram_addr_t length)
60
if (ret < 0) {
48
{
61
error_setg_errno(errp, -ret, "failed to set path: %s",
49
/* The requested range should fit in within the block range */
62
blkio_get_error_msg());
50
g_assert((start + length) <= block->used_length);
63
@@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_io_uring = BLKIO_DRIVER(
51
diff --git a/memory.c b/memory.c
64
52
index XXXXXXX..XXXXXXX 100644
65
static BlockDriver bdrv_nvme_io_uring = BLKIO_DRIVER(
53
--- a/memory.c
66
DRIVER_NVME_IO_URING,
54
+++ b/memory.c
67
- .bdrv_needs_filename = true,
55
@@ -XXX,XX +XXX,XX @@ void memory_region_ram_resize(MemoryRegion *mr, ram_addr_t newsize, Error **errp
68
);
56
void memory_region_msync(MemoryRegion *mr, hwaddr addr, hwaddr size)
69
57
{
70
static BlockDriver bdrv_virtio_blk_vfio_pci = BLKIO_DRIVER(
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
--
71
--
65
2.25.4
72
2.38.1
66
diff view generated by jsdifflib