From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Fam Zheng" <fam@euphon.net>, "Kevin Wolf" <kwolf@redhat.com>,
qemu-block@nongnu.org, "Max Reitz" <mreitz@redhat.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: [PATCH 07/15] block/nvme: Make nvme_init_queue() return boolean indicating error
Date: Wed, 14 Oct 2020 17:58:02 +0200 [thread overview]
Message-ID: <20201014155810.102841-8-philmd@redhat.com> (raw)
In-Reply-To: <20201014155810.102841-1-philmd@redhat.com>
Just for consistency, following the example documented since
commit e3fe3988d7 ("error: Document Error API usage rules"),
return a boolean value indicating an error is set or not.
This simplifies a bit nvme_create_queue_pair().
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
block/nvme.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/block/nvme.c b/block/nvme.c
index 95f8f8b360b..523814a1243 100644
--- a/block/nvme.c
+++ b/block/nvme.c
@@ -153,7 +153,8 @@ static QemuOptsList runtime_opts = {
},
};
-static void nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q,
+/* Returns true on success, false on failure. */
+static bool nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q,
unsigned nentries, size_t entry_bytes, Error **errp)
{
size_t bytes;
@@ -164,13 +165,14 @@ static void nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q,
q->queue = qemu_try_memalign(s->page_size, bytes);
if (!q->queue) {
error_setg(errp, "Cannot allocate queue");
- return;
+ return false;
}
memset(q->queue, 0, bytes);
r = qemu_vfio_dma_map(s->vfio, q->queue, bytes, false, &q->iova, errp);
if (r) {
error_prepend(errp, "Cannot map queue: ");
}
+ return r == 0;
}
static void nvme_free_queue_pair(NVMeQueuePair *q)
@@ -203,7 +205,6 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s,
Error **errp)
{
int i, r;
- Error *local_err = NULL;
NVMeQueuePair *q;
uint64_t prp_list_iova;
@@ -240,16 +241,12 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s,
req->prp_list_iova = prp_list_iova + i * s->page_size;
}
- nvme_init_queue(s, &q->sq, size, NVME_SQ_ENTRY_BYTES, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!nvme_init_queue(s, &q->sq, size, NVME_SQ_ENTRY_BYTES, errp)) {
goto fail;
}
q->sq.doorbell = &s->doorbells[idx * s->doorbell_scale].sq_tail;
- nvme_init_queue(s, &q->cq, size, NVME_CQ_ENTRY_BYTES, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!nvme_init_queue(s, &q->cq, size, NVME_CQ_ENTRY_BYTES, errp)) {
goto fail;
}
q->cq.doorbell = &s->doorbells[idx * s->doorbell_scale].cq_head;
--
2.26.2
next prev parent reply other threads:[~2020-10-14 16:07 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-14 15:57 [PATCH 00/15] block/nvme: Improve debugging experience and minor fixes Philippe Mathieu-Daudé
2020-10-14 15:57 ` [PATCH 01/15] block/nvme: Move nvme_poll_cb() earlier Philippe Mathieu-Daudé
2020-10-14 15:57 ` [PATCH 02/15] block/nvme: Trace nvme_poll_queue() per queue Philippe Mathieu-Daudé
2020-10-14 15:57 ` [PATCH 03/15] block/nvme: Use unsigned integer for queue counter/size Philippe Mathieu-Daudé
2020-10-14 15:57 ` [PATCH 04/15] block/nvme: Improve nvme_free_req_queue_wait() trace information Philippe Mathieu-Daudé
2020-10-14 15:58 ` [PATCH 05/15] block/nvme: Trace queue pair creation/deletion Philippe Mathieu-Daudé
2020-10-14 15:58 ` [PATCH 06/15] block/nvme: Make nvme_identify() return boolean indicating error Philippe Mathieu-Daudé
2020-10-14 15:58 ` Philippe Mathieu-Daudé [this message]
2020-10-14 15:58 ` [PATCH 08/15] block/nvme: Pass AioContext argument to nvme_add_io_queue() Philippe Mathieu-Daudé
2020-10-14 15:58 ` [PATCH 09/15] block/nvme: Introduce Completion Queue definitions Philippe Mathieu-Daudé
2020-10-14 15:58 ` [PATCH 10/15] block/nvme: Use definitions instead of magic values in add_io_queue() Philippe Mathieu-Daudé
2020-10-15 10:57 ` Philippe Mathieu-Daudé
2020-10-14 15:58 ` [PATCH 11/15] block/nvme: Trace controller capabilities Philippe Mathieu-Daudé
2020-10-14 15:58 ` [PATCH 12/15] block/nvme: Simplify device reset Philippe Mathieu-Daudé
2020-10-14 15:58 ` [PATCH 13/15] block/nvme: Simplify ADMIN queue access Philippe Mathieu-Daudé
2020-10-14 15:58 ` [PATCH 14/15] block/nvme: Report warning with warn_report() Philippe Mathieu-Daudé
2020-10-14 15:58 ` [PATCH 15/15] block/nvme: Set request_alignment at initialization Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201014155810.102841-8-philmd@redhat.com \
--to=philmd@redhat.com \
--cc=fam@euphon.net \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).