block/nvme: Implement .bdrv_(un)register_buf
Forward these two calls to the IOVA manager. Signed-off-by: Fam Zheng <famz@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20180116060901.17413-6-famz@redhat.com> Signed-off-by: Fam Zheng <famz@redhat.com>
This commit is contained in:
parent
23d0ba9319
commit
9ed616129e
24
block/nvme.c
24
block/nvme.c
@ -1147,6 +1147,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",
|
||||
@ -1172,6 +1193,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)
|
||||
|
Loading…
Reference in New Issue
Block a user