From nobody Tue Nov 4 15:00:49 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15301450401865.641174452154701; Wed, 27 Jun 2018 17:17:20 -0700 (PDT) Received: from localhost ([::1]:33806 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYKcf-00030t-82 for importer@patchew.org; Wed, 27 Jun 2018 20:17:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58235) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYKUO-00056p-7N for qemu-devel@nongnu.org; Wed, 27 Jun 2018 20:08:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYKUN-00053A-2j for qemu-devel@nongnu.org; Wed, 27 Jun 2018 20:08:44 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:41474 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fYKUJ-0004vQ-8d; Wed, 27 Jun 2018 20:08:39 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E640681A4EA9; Thu, 28 Jun 2018 00:08:38 +0000 (UTC) Received: from localhost (unknown [10.40.205.153]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 942C62026D5B; Thu, 28 Jun 2018 00:08:38 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Thu, 28 Jun 2018 02:07:40 +0200 Message-Id: <20180628000745.4477-27-mreitz@redhat.com> In-Reply-To: <20180628000745.4477-1-mreitz@redhat.com> References: <20180628000745.4477-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 28 Jun 2018 00:08:38 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 28 Jun 2018 00:08:38 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mreitz@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v9 26/31] block/nvme: Fix bdrv_refresh_filename() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- 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 { =20 /* Total size of mapped qiov, accessed under dma_map_lock */ int dma_map_count; + + /* PCI address (required for nvme_refresh_filename()) */ + char *device; } BDRVNVMeState; =20 #define NVME_BLOCK_OPT_DEVICE "device" @@ -558,6 +561,7 @@ static int nvme_init(BlockDriverState *bs, const char *= device, int namespace, =20 qemu_co_mutex_init(&s->dma_map_lock); qemu_co_queue_init(&s->dma_flush_queue); + s->device =3D g_strdup(device); s->nsid =3D namespace; s->aio_context =3D bdrv_get_aio_context(bs); ret =3D 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); } =20 static int nvme_file_open(BlockDriverState *bs, QDict *options, int flags, @@ -1073,21 +1079,10 @@ static int nvme_reopen_prepare(BDRVReopenState *reo= pen_state, =20 static void nvme_refresh_filename(BlockDriverState *bs) { - const QDictEntry *e; - - for (e =3D qdict_first(bs->full_open_options); e; - e =3D 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 =3D bs->opaque; =20 - 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); } =20 static void nvme_refresh_limits(BlockDriverState *bs, Error **errp) --=20 2.17.1