[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v9 26/31] block/nvme: Fix bdrv_refresh_filename()
From: |
Max Reitz |
Subject: |
[Qemu-block] [PATCH v9 26/31] block/nvme: Fix bdrv_refresh_filename() |
Date: |
Thu, 28 Jun 2018 02:07:40 +0200 |
Currently, nvme's bdrv_refresh_filename() is an exact copy of null's
implementation. However, for null, "null-co://" and "null-aio://" are
indeed valid filenames -- for nvme, they are not, as a device address is
still required.
The correct implementation should generate a filename of the form
"nvme://[PCI address]/[namespace]" (as the comment above
nvme_parse_filename() describes).
Signed-off-by: Max Reitz <address@hidden>
---
block/nvme.c | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/block/nvme.c b/block/nvme.c
index 9e893ab5fa..d8c55faff3 100644
--- a/block/nvme.c
+++ b/block/nvme.c
@@ -111,6 +111,9 @@ typedef struct {
/* Total size of mapped qiov, accessed under dma_map_lock */
int dma_map_count;
+
+ /* PCI address (required for nvme_refresh_filename()) */
+ char *device;
} BDRVNVMeState;
#define NVME_BLOCK_OPT_DEVICE "device"
@@ -558,6 +561,7 @@ static int nvme_init(BlockDriverState *bs, const char
*device, int namespace,
qemu_co_mutex_init(&s->dma_map_lock);
qemu_co_queue_init(&s->dma_flush_queue);
+ s->device = g_strdup(device);
s->nsid = namespace;
s->aio_context = bdrv_get_aio_context(bs);
ret = event_notifier_init(&s->irq_notifier, 0);
@@ -743,6 +747,8 @@ static void nvme_close(BlockDriverState *bs)
false, NULL, NULL);
qemu_vfio_pci_unmap_bar(s->vfio, 0, (void *)s->regs, 0, NVME_BAR_SIZE);
qemu_vfio_close(s->vfio);
+
+ g_free(s->device);
}
static int nvme_file_open(BlockDriverState *bs, QDict *options, int flags,
@@ -1073,21 +1079,10 @@ static int nvme_reopen_prepare(BDRVReopenState
*reopen_state,
static void nvme_refresh_filename(BlockDriverState *bs)
{
- const QDictEntry *e;
-
- for (e = qdict_first(bs->full_open_options); e;
- e = qdict_next(bs->full_open_options, e))
- {
- /* These options can be ignored */
- if (strcmp(qdict_entry_key(e), "filename") &&
- strcmp(qdict_entry_key(e), "driver"))
- {
- return;
- }
- }
+ BDRVNVMeState *s = bs->opaque;
- snprintf(bs->exact_filename, sizeof(bs->exact_filename), "%s://",
- bs->drv->format_name);
+ snprintf(bs->exact_filename, sizeof(bs->exact_filename), "nvme://%s/%i",
+ s->device, s->nsid);
}
static void nvme_refresh_limits(BlockDriverState *bs, Error **errp)
--
2.17.1
- [Qemu-block] [PATCH v9 14/31] block: Add bdrv_dirname(), (continued)
- [Qemu-block] [PATCH v9 14/31] block: Add bdrv_dirname(), Max Reitz, 2018/06/27
- [Qemu-block] [PATCH v9 16/31] quorum: Make bdrv_dirname() return NULL, Max Reitz, 2018/06/27
- [Qemu-block] [PATCH v9 15/31] blkverify: Make bdrv_dirname() return NULL, Max Reitz, 2018/06/27
- [Qemu-block] [PATCH v9 17/31] block/nbd: Make bdrv_dirname() return NULL, Max Reitz, 2018/06/27
- [Qemu-block] [PATCH v9 18/31] block/nfs: Implement bdrv_dirname(), Max Reitz, 2018/06/27
- [Qemu-block] [PATCH v9 19/31] block: Use bdrv_dirname() for relative filenames, Max Reitz, 2018/06/27
- [Qemu-block] [PATCH v9 20/31] iotests: Add quorum case to test 110, Max Reitz, 2018/06/27
- [Qemu-block] [PATCH v9 21/31] block: Add strong_runtime_opts to BlockDriver, Max Reitz, 2018/06/27
- [Qemu-block] [PATCH v9 23/31] block: Generically refresh runtime options, Max Reitz, 2018/06/27
- [Qemu-block] [PATCH v9 22/31] block: Add BlockDriver.bdrv_gather_child_options, Max Reitz, 2018/06/27
- [Qemu-block] [PATCH v9 26/31] block/nvme: Fix bdrv_refresh_filename(),
Max Reitz <=
- [Qemu-block] [PATCH v9 24/31] block: Purify .bdrv_refresh_filename(), Max Reitz, 2018/06/27
- [Qemu-block] [PATCH v9 27/31] block/curl: Harmonize option defaults, Max Reitz, 2018/06/27
- [Qemu-block] [PATCH v9 25/31] block: Do not copy exact_filename from format file, Max Reitz, 2018/06/27
- [Qemu-block] [PATCH v9 28/31] block/curl: Implement bdrv_refresh_filename(), Max Reitz, 2018/06/27
- [Qemu-block] [PATCH v9 29/31] block/null: Generate filename even with latency-ns, Max Reitz, 2018/06/27
- [Qemu-block] [PATCH v9 31/31] iotests: Test json:{} filenames of internal BDSs, Max Reitz, 2018/06/27
- [Qemu-block] [PATCH v9 30/31] block: BDS options may lack the "driver" option, Max Reitz, 2018/06/27