From nobody Mon Nov 17 11:49:41 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603807018; cv=none; d=zohomail.com; s=zohoarc; b=n9YrRREi81Iw9xChx1GVKU67IptuNvE1uGgUK8AERsOKm/EoCxXzgEZkmpXhrRVgzrzR1hQdY7NGXb09KIrPDHXWP5Pm9DWSZUJhzEEtezih7Rn7/WazjnbZ+ihKLkoepvGyCtCT3Uc7RA0R/VPGGxEKYPZiuS7f1RdaWdutqvY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603807018; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=5UNrRYGfWn9M8qfpcFzDzOyggHy+DoEp25W1xSNXQns=; b=LX4bVO3xj3v0lMqsJttVK0XcoVlpOyB3zOtGnlJLVaeg1/xNmy9jAnIGKpyNFFMUT8ePb6vYZEi2J4vtLvDb/xOols4Qk3Gtbdisw/oGD/pyHWiU4TFoQkdifQgU91QtOa8W/bVo9ZXuH03eUgSOesGPxBNPLTZG0fKlaGLeY98= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1603807018285538.0540478667713; Tue, 27 Oct 2020 06:56:58 -0700 (PDT) Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-162-OsaQJGrWNsSFl-MRzuuzGg-1; Tue, 27 Oct 2020 09:56:55 -0400 Received: by mail-ej1-f71.google.com with SMTP id t1so870595ejb.21 for ; Tue, 27 Oct 2020 06:56:55 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id b15sm945058edz.97.2020.10.27.06.56.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Oct 2020 06:56:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603807017; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5UNrRYGfWn9M8qfpcFzDzOyggHy+DoEp25W1xSNXQns=; b=Z0Yqr9he0hGartmW0UQiTM59H3oJahK10kw01rQ9ilL/qKVtR8sl5kPErOmEti99R3/NuK GLg6+lWq43byGVZpdSu1oTRY3chUetJXViYryFnZT9g8QjtaVxGxeAU4RQ/5fJVIqhdzTV XUTlK42iETBGiKGbUbdTWKG0ghANLiE= X-MC-Unique: OsaQJGrWNsSFl-MRzuuzGg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5UNrRYGfWn9M8qfpcFzDzOyggHy+DoEp25W1xSNXQns=; b=QRbBMEYLE3d5+tD9HLqO7cPRJo0HOPS70FohFWIy94/luq1ioaRkdGwPNo4se0W8/3 ji54LOFGm3Mi3teXnwUyQoOPcsBLZO7hfnHiODQxy4p02Dp9PJprqX4TNBD5alXBmvoY Zv/AW33wtNAjIpZqDfiT3AbcSM+WciSRzZuTTwcij2+HNZ/4IFhCUIRdlBzw7on8LoxS MnjMnI35DqbzlyfuyiVPiUylpjtaVviSGzOXiyS2TaeZhjJ8V3a1gjYPLXHbUWOA9f+/ i+97ep3JS2yD0rT06KGovFaKq2gaxss8G5O05lptFhKh8p6LWydAukPEEyRozyiFT7QU 9/Bw== X-Gm-Message-State: AOAM530S4PRfbkweOgiAOeeoDdL/2inwxjYq/EdM1Rg1bI/UKKngkUB4 VVW7GZ9bIyjnAj0nVAArDUr36I3qjxcLoUMlOuI4STD8YPgq3faRjlqPY94uqzmgdL0wlixZ6go idB+7+loLMxyZHA== X-Received: by 2002:a17:906:1cca:: with SMTP id i10mr2568909ejh.487.1603807014416; Tue, 27 Oct 2020 06:56:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfu8uTTNbTc5SUgHNwN75/s0cC36p9ImYoAKcTKZOBsnKGav5H8mbnFW+m90c+b40ULMAJrQ== X-Received: by 2002:a17:906:1cca:: with SMTP id i10mr2568885ejh.487.1603807014202; Tue, 27 Oct 2020 06:56:54 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Klaus Jensen , qemu-block@nongnu.org, Fam Zheng , Keith Busch , Eric Auger , Stefan Hajnoczi , Kevin Wolf , Max Reitz , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 12/25] block/nvme: Make nvme_init_queue() return boolean indicating error Date: Tue, 27 Oct 2020 14:55:34 +0100 Message-Id: <20201027135547.374946-13-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201027135547.374946-1-philmd@redhat.com> References: <20201027135547.374946-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @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=C3=A9 Reviewed-by: Stefan Hajnoczi --- block/nvme.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 74994c442e5..9324f0bfdc4 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -160,7 +160,8 @@ static QemuOptsList runtime_opts =3D { }, }; =20 -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; @@ -171,13 +172,14 @@ static void nvme_init_queue(BDRVNVMeState *s, NVMeQue= ue *q, q->queue =3D 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 =3D qemu_vfio_dma_map(s->vfio, q->queue, bytes, false, &q->iova); if (r) { error_setg(errp, "Cannot map queue"); } + return r =3D=3D 0; } =20 static void nvme_free_queue_pair(NVMeQueuePair *q) @@ -210,7 +212,6 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeSt= ate *s, Error **errp) { int i, r; - Error *local_err =3D NULL; NVMeQueuePair *q; uint64_t prp_list_iova; =20 @@ -247,16 +248,12 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMe= State *s, req->prp_list_iova =3D prp_list_iova + i * s->page_size; } =20 - 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 =3D &s->doorbells[idx * s->doorbell_scale].sq_tail; =20 - 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 =3D &s->doorbells[idx * s->doorbell_scale].cq_head; --=20 2.26.2