* [PULL 0/3] Block patches
@ 2022-10-31 18:51 Stefan Hajnoczi
2022-10-31 18:51 ` [PULL 1/3] block/blkio: Add virtio-blk-vfio-pci BlockDriver Stefan Hajnoczi
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2022-10-31 18:51 UTC (permalink / raw)
To: qemu-devel
Cc: Eric Blake, Hanna Reitz, Stefan Hajnoczi, Markus Armbruster,
qemu-block, Kevin Wolf
The following changes since commit 7208429223963c405c62fa2611398f1aa8033593:
Merge tag 'mem-2022-10-28' of https://github.com/davidhildenbrand/qemu into staging (2022-10-30 18:31:59 -0400)
are available in the Git repository at:
https://gitlab.com/stefanha/qemu.git tags/block-pull-request
for you to fetch changes up to 6c32fc0df9cd901add75618c831fb26a9eb742cb:
block/blkio: Make driver nvme-io_uring take a "path" instead of a "filename" (2022-10-31 14:35:14 -0400)
----------------------------------------------------------------
Pull request
Note that we're still discussing "block/blkio: Make driver nvme-io_uring take a
"path" instead of a "filename"". I have sent the pull request now so everything
is ready for the soft freeze tomorrow if we decide to go ahead with the patch.
----------------------------------------------------------------
Alberto Faria (3):
block/blkio: Add virtio-blk-vfio-pci BlockDriver
block/blkio: Tolerate device size changes
block/blkio: Make driver nvme-io_uring take a "path" instead of a
"filename"
qapi/block-core.json | 22 +++++++++++++++++++--
block/blkio.c | 47 ++++++++++++++++++++++++++++++++++++++++----
2 files changed, 63 insertions(+), 6 deletions(-)
--
2.38.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PULL 1/3] block/blkio: Add virtio-blk-vfio-pci BlockDriver
2022-10-31 18:51 [PULL 0/3] Block patches Stefan Hajnoczi
@ 2022-10-31 18:51 ` Stefan Hajnoczi
2022-10-31 18:51 ` [PULL 2/3] block/blkio: Tolerate device size changes Stefan Hajnoczi
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2022-10-31 18:51 UTC (permalink / raw)
To: qemu-devel
Cc: Eric Blake, Hanna Reitz, Stefan Hajnoczi, Markus Armbruster,
qemu-block, Kevin Wolf, Alberto Faria
From: Alberto Faria <afaria@redhat.com>
libblkio 1.1.0 [1] introduces a virtio-blk-vfio-pci driver, which
accesses a virtio-blk PCI device using VFIO. Add a corresponding
BlockDriver.
[1] https://gitlab.com/libblkio/libblkio/-/tree/v1.1.0
Signed-off-by: Alberto Faria <afaria@redhat.com>
Message-id: 20221028131635.710267-1-afaria@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
qapi/block-core.json | 18 ++++++++++++++++++
block/blkio.c | 8 ++++++++
2 files changed, 26 insertions(+)
diff --git a/qapi/block-core.json b/qapi/block-core.json
index cb5079e645..81bbb0b893 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -2960,6 +2960,7 @@
'raw', 'rbd',
{ 'name': 'replication', 'if': 'CONFIG_REPLICATION' },
'ssh', 'throttle', 'vdi', 'vhdx',
+ { 'name': 'virtio-blk-vfio-pci', 'if': 'CONFIG_BLKIO' },
{ 'name': 'virtio-blk-vhost-user', 'if': 'CONFIG_BLKIO' },
{ 'name': 'virtio-blk-vhost-vdpa', 'if': 'CONFIG_BLKIO' },
'vmdk', 'vpc', 'vvfat' ] }
@@ -3711,6 +3712,20 @@
'data': { 'filename': 'str' },
'if': 'CONFIG_BLKIO' }
+##
+# @BlockdevOptionsVirtioBlkVfioPci:
+#
+# Driver specific block device options for the virtio-blk-vfio-pci backend.
+#
+# @path: path to the PCI device's sysfs directory (e.g.
+# /sys/bus/pci/devices/0000:00:01.0).
+#
+# Since: 7.2
+##
+{ 'struct': 'BlockdevOptionsVirtioBlkVfioPci',
+ 'data': { 'path': 'str' },
+ 'if': 'CONFIG_BLKIO' }
+
##
# @BlockdevOptionsVirtioBlkVhostUser:
#
@@ -4390,6 +4405,9 @@
'throttle': 'BlockdevOptionsThrottle',
'vdi': 'BlockdevOptionsGenericFormat',
'vhdx': 'BlockdevOptionsGenericFormat',
+ 'virtio-blk-vfio-pci':
+ { 'type': 'BlockdevOptionsVirtioBlkVfioPci',
+ 'if': 'CONFIG_BLKIO' },
'virtio-blk-vhost-user':
{ 'type': 'BlockdevOptionsVirtioBlkVhostUser',
'if': 'CONFIG_BLKIO' },
diff --git a/block/blkio.c b/block/blkio.c
index 82f26eedd2..f55eb774b4 100644
--- a/block/blkio.c
+++ b/block/blkio.c
@@ -25,6 +25,7 @@
*/
#define DRIVER_IO_URING "io_uring"
#define DRIVER_NVME_IO_URING "nvme-io_uring"
+#define DRIVER_VIRTIO_BLK_VFIO_PCI "virtio-blk-vfio-pci"
#define DRIVER_VIRTIO_BLK_VHOST_USER "virtio-blk-vhost-user"
#define DRIVER_VIRTIO_BLK_VHOST_VDPA "virtio-blk-vhost-vdpa"
@@ -704,6 +705,8 @@ static int blkio_file_open(BlockDriverState *bs, QDict *options, int flags,
ret = blkio_io_uring_open(bs, options, flags, errp);
} else if (strcmp(blkio_driver, DRIVER_NVME_IO_URING) == 0) {
ret = blkio_nvme_io_uring(bs, options, flags, errp);
+ } else if (strcmp(blkio_driver, DRIVER_VIRTIO_BLK_VFIO_PCI) == 0) {
+ ret = blkio_virtio_blk_common_open(bs, options, flags, errp);
} else if (strcmp(blkio_driver, DRIVER_VIRTIO_BLK_VHOST_USER) == 0) {
ret = blkio_virtio_blk_common_open(bs, options, flags, errp);
} else if (strcmp(blkio_driver, DRIVER_VIRTIO_BLK_VHOST_VDPA) == 0) {
@@ -989,6 +992,10 @@ static BlockDriver bdrv_nvme_io_uring = BLKIO_DRIVER(
.bdrv_needs_filename = true,
);
+static BlockDriver bdrv_virtio_blk_vfio_pci = BLKIO_DRIVER(
+ DRIVER_VIRTIO_BLK_VFIO_PCI
+);
+
static BlockDriver bdrv_virtio_blk_vhost_user = BLKIO_DRIVER(
DRIVER_VIRTIO_BLK_VHOST_USER
);
@@ -1001,6 +1008,7 @@ static void bdrv_blkio_init(void)
{
bdrv_register(&bdrv_io_uring);
bdrv_register(&bdrv_nvme_io_uring);
+ bdrv_register(&bdrv_virtio_blk_vfio_pci);
bdrv_register(&bdrv_virtio_blk_vhost_user);
bdrv_register(&bdrv_virtio_blk_vhost_vdpa);
}
--
2.38.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PULL 2/3] block/blkio: Tolerate device size changes
2022-10-31 18:51 [PULL 0/3] Block patches Stefan Hajnoczi
2022-10-31 18:51 ` [PULL 1/3] block/blkio: Add virtio-blk-vfio-pci BlockDriver Stefan Hajnoczi
@ 2022-10-31 18:51 ` Stefan Hajnoczi
2022-10-31 18:51 ` [PULL 3/3] block/blkio: Make driver nvme-io_uring take a "path" instead of a "filename" Stefan Hajnoczi
2022-11-01 20:04 ` [PULL 0/3] Block patches Stefan Hajnoczi
3 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2022-10-31 18:51 UTC (permalink / raw)
To: qemu-devel
Cc: Eric Blake, Hanna Reitz, Stefan Hajnoczi, Markus Armbruster,
qemu-block, Kevin Wolf, Alberto Faria
From: Alberto Faria <afaria@redhat.com>
Some libblkio drivers may be able to work with regular files (e.g.,
io_uring) or otherwise resizable devices. Conservatively set
BlockDriver::has_variable_length to true to ensure bdrv_nb_sectors()
always gives up-to-date results.
Also implement BlockDriver::bdrv_co_truncate for the case where no
preallocation is needed and the device already has a size compatible
with what was requested.
Signed-off-by: Alberto Faria <afaria@redhat.com>
Message-id: 20221029122031.975273-1-afaria@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
block/blkio.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/block/blkio.c b/block/blkio.c
index f55eb774b4..d850506acd 100644
--- a/block/blkio.c
+++ b/block/blkio.c
@@ -848,6 +848,31 @@ static int64_t blkio_getlength(BlockDriverState *bs)
return capacity;
}
+static int coroutine_fn blkio_truncate(BlockDriverState *bs, int64_t offset,
+ bool exact, PreallocMode prealloc,
+ BdrvRequestFlags flags, Error **errp)
+{
+ int64_t current_length;
+
+ if (prealloc != PREALLOC_MODE_OFF) {
+ error_setg(errp, "Unsupported preallocation mode '%s'",
+ PreallocMode_str(prealloc));
+ return -ENOTSUP;
+ }
+
+ current_length = blkio_getlength(bs);
+
+ if (offset > current_length) {
+ error_setg(errp, "Cannot grow device");
+ return -EINVAL;
+ } else if (exact && offset != current_length) {
+ error_setg(errp, "Cannot resize device");
+ return -ENOTSUP;
+ }
+
+ return 0;
+}
+
static int blkio_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
{
return 0;
@@ -963,10 +988,12 @@ static void blkio_refresh_limits(BlockDriverState *bs, Error **errp)
{ \
.format_name = name, \
.protocol_name = name, \
+ .has_variable_length = true, \
.instance_size = sizeof(BDRVBlkioState), \
.bdrv_file_open = blkio_file_open, \
.bdrv_close = blkio_close, \
.bdrv_getlength = blkio_getlength, \
+ .bdrv_co_truncate = blkio_truncate, \
.bdrv_get_info = blkio_get_info, \
.bdrv_attach_aio_context = blkio_attach_aio_context, \
.bdrv_detach_aio_context = blkio_detach_aio_context, \
--
2.38.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PULL 3/3] block/blkio: Make driver nvme-io_uring take a "path" instead of a "filename"
2022-10-31 18:51 [PULL 0/3] Block patches Stefan Hajnoczi
2022-10-31 18:51 ` [PULL 1/3] block/blkio: Add virtio-blk-vfio-pci BlockDriver Stefan Hajnoczi
2022-10-31 18:51 ` [PULL 2/3] block/blkio: Tolerate device size changes Stefan Hajnoczi
@ 2022-10-31 18:51 ` Stefan Hajnoczi
2022-11-01 20:04 ` [PULL 0/3] Block patches Stefan Hajnoczi
3 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2022-10-31 18:51 UTC (permalink / raw)
To: qemu-devel
Cc: Eric Blake, Hanna Reitz, Stefan Hajnoczi, Markus Armbruster,
qemu-block, Kevin Wolf, Alberto Faria
From: Alberto Faria <afaria@redhat.com>
The nvme-io_uring driver expects a character special file such as
/dev/ng0n1. Follow the convention of having a "filename" option when a
regular file is expected, and a "path" option otherwise.
This makes io_uring the only libblkio-based driver with a "filename"
option, as it accepts a regular file (even though it can also take a
block special file).
Signed-off-by: Alberto Faria <afaria@redhat.com>
Message-id: 20221028233854.839933-1-afaria@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
qapi/block-core.json | 4 ++--
block/blkio.c | 12 ++++++++----
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 81bbb0b893..6d904004f8 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -3704,12 +3704,12 @@
#
# Driver specific block device options for the nvme-io_uring backend.
#
-# @filename: path to the image file
+# @path: path to the image file
#
# Since: 7.2
##
{ 'struct': 'BlockdevOptionsNvmeIoUring',
- 'data': { 'filename': 'str' },
+ 'data': { 'path': 'str' },
'if': 'CONFIG_BLKIO' }
##
diff --git a/block/blkio.c b/block/blkio.c
index d850506acd..620fab28a7 100644
--- a/block/blkio.c
+++ b/block/blkio.c
@@ -640,12 +640,17 @@ static int blkio_io_uring_open(BlockDriverState *bs, QDict *options, int flags,
static int blkio_nvme_io_uring(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
- const char *filename = qdict_get_str(options, "filename");
+ const char *path = qdict_get_try_str(options, "path");
BDRVBlkioState *s = bs->opaque;
int ret;
- ret = blkio_set_str(s->blkio, "path", filename);
- qdict_del(options, "filename");
+ if (!path) {
+ error_setg(errp, "missing 'path' option");
+ return -EINVAL;
+ }
+
+ ret = blkio_set_str(s->blkio, "path", path);
+ qdict_del(options, "path");
if (ret < 0) {
error_setg_errno(errp, -ret, "failed to set path: %s",
blkio_get_error_msg());
@@ -1016,7 +1021,6 @@ static BlockDriver bdrv_io_uring = BLKIO_DRIVER(
static BlockDriver bdrv_nvme_io_uring = BLKIO_DRIVER(
DRIVER_NVME_IO_URING,
- .bdrv_needs_filename = true,
);
static BlockDriver bdrv_virtio_blk_vfio_pci = BLKIO_DRIVER(
--
2.38.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PULL 0/3] Block patches
2022-10-31 18:51 [PULL 0/3] Block patches Stefan Hajnoczi
` (2 preceding siblings ...)
2022-10-31 18:51 ` [PULL 3/3] block/blkio: Make driver nvme-io_uring take a "path" instead of a "filename" Stefan Hajnoczi
@ 2022-11-01 20:04 ` Stefan Hajnoczi
3 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2022-11-01 20:04 UTC (permalink / raw)
To: Stefan Hajnoczi
Cc: qemu-devel, Eric Blake, Hanna Reitz, Stefan Hajnoczi,
Markus Armbruster, qemu-block, Kevin Wolf
[-- Attachment #1: Type: text/plain, Size: 115 bytes --]
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/7.2 for any user-visible changes.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-11-01 20:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-31 18:51 [PULL 0/3] Block patches Stefan Hajnoczi
2022-10-31 18:51 ` [PULL 1/3] block/blkio: Add virtio-blk-vfio-pci BlockDriver Stefan Hajnoczi
2022-10-31 18:51 ` [PULL 2/3] block/blkio: Tolerate device size changes Stefan Hajnoczi
2022-10-31 18:51 ` [PULL 3/3] block/blkio: Make driver nvme-io_uring take a "path" instead of a "filename" Stefan Hajnoczi
2022-11-01 20:04 ` [PULL 0/3] Block patches Stefan Hajnoczi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).