1 | The following changes since commit 61c265f0660ee476985808c8aa7915617c44fd53: | 1 | The following changes since commit 7208429223963c405c62fa2611398f1aa8033593: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20200313a' into staging (2020-03-13 10:33:04 +0000) | 3 | Merge tag 'mem-2022-10-28' of https://github.com/davidhildenbrand/qemu into staging (2022-10-30 18:31:59 -0400) |
4 | 4 | ||
5 | are available in the Git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | https://github.com/stefanha/qemu.git tags/block-pull-request | 7 | https://gitlab.com/stefanha/qemu.git tags/block-pull-request |
8 | 8 | ||
9 | for you to fetch changes up to 4ab78b19189a81038e744728ed949d09aa477550: | 9 | for you to fetch changes up to 6c32fc0df9cd901add75618c831fb26a9eb742cb: |
10 | 10 | ||
11 | block/io: fix bdrv_co_do_copy_on_readv (2020-03-16 11:46:11 +0000) | 11 | block/blkio: Make driver nvme-io_uring take a "path" instead of a "filename" (2022-10-31 14:35:14 -0400) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Pull request | 14 | Pull request |
15 | 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 | |||
16 | ---------------------------------------------------------------- | 20 | ---------------------------------------------------------------- |
17 | 21 | ||
18 | Vladimir Sementsov-Ogievskiy (1): | 22 | Alberto Faria (3): |
19 | block/io: fix bdrv_co_do_copy_on_readv | 23 | block/blkio: Add virtio-blk-vfio-pci BlockDriver |
24 | block/blkio: Tolerate device size changes | ||
25 | block/blkio: Make driver nvme-io_uring take a "path" instead of a | ||
26 | "filename" | ||
20 | 27 | ||
21 | block/io.c | 2 +- | 28 | qapi/block-core.json | 22 +++++++++++++++++++-- |
22 | 1 file changed, 1 insertion(+), 1 deletion(-) | 29 | block/blkio.c | 47 ++++++++++++++++++++++++++++++++++++++++---- |
30 | 2 files changed, 63 insertions(+), 6 deletions(-) | ||
23 | 31 | ||
24 | -- | 32 | -- |
25 | 2.24.1 | 33 | 2.38.1 |
26 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Alberto Faria <afaria@redhat.com> | ||
1 | 2 | ||
3 | libblkio 1.1.0 [1] introduces a virtio-blk-vfio-pci driver, which | ||
4 | accesses a virtio-blk PCI device using VFIO. Add a corresponding | ||
5 | BlockDriver. | ||
6 | |||
7 | [1] https://gitlab.com/libblkio/libblkio/-/tree/v1.1.0 | ||
8 | |||
9 | Signed-off-by: Alberto Faria <afaria@redhat.com> | ||
10 | Message-id: 20221028131635.710267-1-afaria@redhat.com | ||
11 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
12 | --- | ||
13 | qapi/block-core.json | 18 ++++++++++++++++++ | ||
14 | block/blkio.c | 8 ++++++++ | ||
15 | 2 files changed, 26 insertions(+) | ||
16 | |||
17 | diff --git a/qapi/block-core.json b/qapi/block-core.json | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/qapi/block-core.json | ||
20 | +++ b/qapi/block-core.json | ||
21 | @@ -XXX,XX +XXX,XX @@ | ||
22 | 'raw', 'rbd', | ||
23 | { 'name': 'replication', 'if': 'CONFIG_REPLICATION' }, | ||
24 | 'ssh', 'throttle', 'vdi', 'vhdx', | ||
25 | + { 'name': 'virtio-blk-vfio-pci', 'if': 'CONFIG_BLKIO' }, | ||
26 | { 'name': 'virtio-blk-vhost-user', 'if': 'CONFIG_BLKIO' }, | ||
27 | { 'name': 'virtio-blk-vhost-vdpa', 'if': 'CONFIG_BLKIO' }, | ||
28 | 'vmdk', 'vpc', 'vvfat' ] } | ||
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 | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/block/blkio.c | ||
63 | +++ b/block/blkio.c | ||
64 | @@ -XXX,XX +XXX,XX @@ | ||
65 | */ | ||
66 | #define DRIVER_IO_URING "io_uring" | ||
67 | #define DRIVER_NVME_IO_URING "nvme-io_uring" | ||
68 | +#define DRIVER_VIRTIO_BLK_VFIO_PCI "virtio-blk-vfio-pci" | ||
69 | #define DRIVER_VIRTIO_BLK_VHOST_USER "virtio-blk-vhost-user" | ||
70 | #define DRIVER_VIRTIO_BLK_VHOST_VDPA "virtio-blk-vhost-vdpa" | ||
71 | |||
72 | @@ -XXX,XX +XXX,XX @@ static int blkio_file_open(BlockDriverState *bs, QDict *options, int flags, | ||
73 | ret = blkio_io_uring_open(bs, options, flags, errp); | ||
74 | } else if (strcmp(blkio_driver, DRIVER_NVME_IO_URING) == 0) { | ||
75 | ret = blkio_nvme_io_uring(bs, options, flags, errp); | ||
76 | + } else if (strcmp(blkio_driver, DRIVER_VIRTIO_BLK_VFIO_PCI) == 0) { | ||
77 | + ret = blkio_virtio_blk_common_open(bs, options, flags, errp); | ||
78 | } else if (strcmp(blkio_driver, DRIVER_VIRTIO_BLK_VHOST_USER) == 0) { | ||
79 | ret = blkio_virtio_blk_common_open(bs, options, flags, errp); | ||
80 | } else if (strcmp(blkio_driver, DRIVER_VIRTIO_BLK_VHOST_VDPA) == 0) { | ||
81 | @@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_nvme_io_uring = BLKIO_DRIVER( | ||
82 | .bdrv_needs_filename = true, | ||
83 | ); | ||
84 | |||
85 | +static BlockDriver bdrv_virtio_blk_vfio_pci = BLKIO_DRIVER( | ||
86 | + DRIVER_VIRTIO_BLK_VFIO_PCI | ||
87 | +); | ||
88 | + | ||
89 | static BlockDriver bdrv_virtio_blk_vhost_user = BLKIO_DRIVER( | ||
90 | DRIVER_VIRTIO_BLK_VHOST_USER | ||
91 | ); | ||
92 | @@ -XXX,XX +XXX,XX @@ static void bdrv_blkio_init(void) | ||
93 | { | ||
94 | bdrv_register(&bdrv_io_uring); | ||
95 | bdrv_register(&bdrv_nvme_io_uring); | ||
96 | + bdrv_register(&bdrv_virtio_blk_vfio_pci); | ||
97 | bdrv_register(&bdrv_virtio_blk_vhost_user); | ||
98 | bdrv_register(&bdrv_virtio_blk_vhost_vdpa); | ||
99 | } | ||
100 | -- | ||
101 | 2.38.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Alberto Faria <afaria@redhat.com> | ||
1 | 2 | ||
3 | Some libblkio drivers may be able to work with regular files (e.g., | ||
4 | io_uring) or otherwise resizable devices. Conservatively set | ||
5 | BlockDriver::has_variable_length to true to ensure bdrv_nb_sectors() | ||
6 | always gives up-to-date results. | ||
7 | |||
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. | ||
11 | |||
12 | Signed-off-by: Alberto Faria <afaria@redhat.com> | ||
13 | Message-id: 20221029122031.975273-1-afaria@redhat.com | ||
14 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
15 | --- | ||
16 | block/blkio.c | 27 +++++++++++++++++++++++++++ | ||
17 | 1 file changed, 27 insertions(+) | ||
18 | |||
19 | diff --git a/block/blkio.c b/block/blkio.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/block/blkio.c | ||
22 | +++ b/block/blkio.c | ||
23 | @@ -XXX,XX +XXX,XX @@ static int64_t blkio_getlength(BlockDriverState *bs) | ||
24 | return capacity; | ||
25 | } | ||
26 | |||
27 | +static int coroutine_fn blkio_truncate(BlockDriverState *bs, int64_t offset, | ||
28 | + bool exact, PreallocMode prealloc, | ||
29 | + BdrvRequestFlags flags, Error **errp) | ||
30 | +{ | ||
31 | + int64_t current_length; | ||
32 | + | ||
33 | + if (prealloc != PREALLOC_MODE_OFF) { | ||
34 | + error_setg(errp, "Unsupported preallocation mode '%s'", | ||
35 | + PreallocMode_str(prealloc)); | ||
36 | + return -ENOTSUP; | ||
37 | + } | ||
38 | + | ||
39 | + current_length = blkio_getlength(bs); | ||
40 | + | ||
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; | ||
50 | +} | ||
51 | + | ||
52 | static int blkio_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) | ||
53 | { | ||
54 | return 0; | ||
55 | @@ -XXX,XX +XXX,XX @@ static void blkio_refresh_limits(BlockDriverState *bs, Error **errp) | ||
56 | { \ | ||
57 | .format_name = name, \ | ||
58 | .protocol_name = name, \ | ||
59 | + .has_variable_length = true, \ | ||
60 | .instance_size = sizeof(BDRVBlkioState), \ | ||
61 | .bdrv_file_open = blkio_file_open, \ | ||
62 | .bdrv_close = blkio_close, \ | ||
63 | .bdrv_getlength = blkio_getlength, \ | ||
64 | + .bdrv_co_truncate = blkio_truncate, \ | ||
65 | .bdrv_get_info = blkio_get_info, \ | ||
66 | .bdrv_attach_aio_context = blkio_attach_aio_context, \ | ||
67 | .bdrv_detach_aio_context = blkio_detach_aio_context, \ | ||
68 | -- | ||
69 | 2.38.1 | diff view generated by jsdifflib |
1 | From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 1 | From: Alberto Faria <afaria@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Prior to 1143ec5ebf4 it was OK to qemu_iovec_from_buf() from aligned-up | 3 | The nvme-io_uring driver expects a character special file such as |
4 | buffer to original qiov, as qemu_iovec_from_buf() will stop at qiov end | 4 | /dev/ng0n1. Follow the convention of having a "filename" option when a |
5 | anyway. | 5 | regular file is expected, and a "path" option otherwise. |
6 | 6 | ||
7 | But after 1143ec5ebf4 we assume that bdrv_co_do_copy_on_readv works on | 7 | This makes io_uring the only libblkio-based driver with a "filename" |
8 | part of original qiov, defined by qiov_offset and bytes. So we must not | 8 | option, as it accepts a regular file (even though it can also take a |
9 | touch qiov behind qiov_offset+bytes bound. Fix it. | 9 | block special file). |
10 | 10 | ||
11 | Cc: qemu-stable@nongnu.org # v4.2 | 11 | Signed-off-by: Alberto Faria <afaria@redhat.com> |
12 | Fixes: 1143ec5ebf4 | 12 | Message-id: 20221028233854.839933-1-afaria@redhat.com |
13 | Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | ||
14 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
15 | Message-id: 20200312081949.5350-1-vsementsov@virtuozzo.com | ||
16 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 13 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
17 | --- | 14 | --- |
18 | block/io.c | 2 +- | 15 | qapi/block-core.json | 4 ++-- |
19 | 1 file changed, 1 insertion(+), 1 deletion(-) | 16 | block/blkio.c | 12 ++++++++---- |
17 | 2 files changed, 10 insertions(+), 6 deletions(-) | ||
20 | 18 | ||
21 | diff --git a/block/io.c b/block/io.c | 19 | diff --git a/qapi/block-core.json b/qapi/block-core.json |
22 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/block/io.c | 21 | --- a/qapi/block-core.json |
24 | +++ b/block/io.c | 22 | +++ b/qapi/block-core.json |
25 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child, | 23 | @@ -XXX,XX +XXX,XX @@ |
26 | if (!(flags & BDRV_REQ_PREFETCH)) { | 24 | # |
27 | qemu_iovec_from_buf(qiov, qiov_offset + progress, | 25 | # Driver specific block device options for the nvme-io_uring backend. |
28 | bounce_buffer + skip_bytes, | 26 | # |
29 | - pnum - skip_bytes); | 27 | -# @filename: path to the image file |
30 | + MIN(pnum - skip_bytes, bytes - progress)); | 28 | +# @path: path to the image file |
31 | } | 29 | # |
32 | } else if (!(flags & BDRV_REQ_PREFETCH)) { | 30 | # Since: 7.2 |
33 | /* Read directly into the destination */ | 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) | ||
45 | { | ||
46 | - const char *filename = qdict_get_str(options, "filename"); | ||
47 | + const char *path = qdict_get_try_str(options, "path"); | ||
48 | BDRVBlkioState *s = bs->opaque; | ||
49 | int ret; | ||
50 | |||
51 | - ret = blkio_set_str(s->blkio, "path", filename); | ||
52 | - qdict_del(options, "filename"); | ||
53 | + if (!path) { | ||
54 | + error_setg(errp, "missing 'path' option"); | ||
55 | + return -EINVAL; | ||
56 | + } | ||
57 | + | ||
58 | + ret = blkio_set_str(s->blkio, "path", path); | ||
59 | + qdict_del(options, "path"); | ||
60 | if (ret < 0) { | ||
61 | error_setg_errno(errp, -ret, "failed to set path: %s", | ||
62 | blkio_get_error_msg()); | ||
63 | @@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_io_uring = BLKIO_DRIVER( | ||
64 | |||
65 | static BlockDriver bdrv_nvme_io_uring = BLKIO_DRIVER( | ||
66 | DRIVER_NVME_IO_URING, | ||
67 | - .bdrv_needs_filename = true, | ||
68 | ); | ||
69 | |||
70 | static BlockDriver bdrv_virtio_blk_vfio_pci = BLKIO_DRIVER( | ||
34 | -- | 71 | -- |
35 | 2.24.1 | 72 | 2.38.1 |
36 | diff view generated by jsdifflib |