[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v6 5/9] block/nvme: Implement .bdrv_(un)register_buf
From: |
Fam Zheng |
Subject: |
[Qemu-devel] [PATCH v6 5/9] block/nvme: Implement .bdrv_(un)register_buf |
Date: |
Tue, 16 Jan 2018 14:08:57 +0800 |
Forward these two calls to the IOVA manager.
Signed-off-by: Fam Zheng <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
---
block/nvme.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/block/nvme.c b/block/nvme.c
index 99cc7702ad..30616f50c7 100644
--- a/block/nvme.c
+++ b/block/nvme.c
@@ -1145,6 +1145,27 @@ static void nvme_aio_unplug(BlockDriverState *bs)
}
}
+static void nvme_register_buf(BlockDriverState *bs, void *host, size_t size)
+{
+ int ret;
+ BDRVNVMeState *s = bs->opaque;
+
+ ret = qemu_vfio_dma_map(s->vfio, host, size, false, NULL);
+ if (ret) {
+ /* FIXME: we may run out of IOVA addresses after repeated
+ * bdrv_register_buf/bdrv_unregister_buf, because nvme_vfio_dma_unmap
+ * doesn't reclaim addresses for fixed mappings. */
+ error_report("nvme_register_buf failed: %s", strerror(-ret));
+ }
+}
+
+static void nvme_unregister_buf(BlockDriverState *bs, void *host)
+{
+ BDRVNVMeState *s = bs->opaque;
+
+ qemu_vfio_dma_unmap(s->vfio, host);
+}
+
static BlockDriver bdrv_nvme = {
.format_name = "nvme",
.protocol_name = "nvme",
@@ -1170,6 +1191,9 @@ static BlockDriver bdrv_nvme = {
.bdrv_io_plug = nvme_aio_plug,
.bdrv_io_unplug = nvme_aio_unplug,
+
+ .bdrv_register_buf = nvme_register_buf,
+ .bdrv_unregister_buf = nvme_unregister_buf,
};
static void bdrv_nvme_init(void)
--
2.14.3
- [Qemu-devel] [PATCH v6 0/9] block: Add VFIO based driver for NVMe device, Fam Zheng, 2018/01/16
- [Qemu-devel] [PATCH v6 1/9] stubs: Add stubs for ram block API, Fam Zheng, 2018/01/16
- [Qemu-devel] [PATCH v6 2/9] util: Introduce vfio helpers, Fam Zheng, 2018/01/16
- [Qemu-devel] [PATCH v6 4/9] block: Introduce buf register API, Fam Zheng, 2018/01/16
- [Qemu-devel] [PATCH v6 3/9] block: Add VFIO based NVMe driver, Fam Zheng, 2018/01/16
- [Qemu-devel] [PATCH v6 5/9] block/nvme: Implement .bdrv_(un)register_buf,
Fam Zheng <=
- [Qemu-devel] [PATCH v6 6/9] qemu-img: Map bench buffer, Fam Zheng, 2018/01/16
- [Qemu-devel] [PATCH v6 7/9] block: Move NVMe constants to a separate header, Fam Zheng, 2018/01/16
- [Qemu-devel] [PATCH v6 8/9] docs: Add section for NVMe VFIO driver, Fam Zheng, 2018/01/16
- [Qemu-devel] [PATCH v6 9/9] qapi: Add NVMe driver options to the schema, Fam Zheng, 2018/01/16
- Re: [Qemu-devel] [PATCH v6 0/9] block: Add VFIO based driver for NVMe device, Stefan Hajnoczi, 2018/01/22