From patchwork Thu Aug 26 19:50:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12460627 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6ECCAC432BE for ; Thu, 26 Aug 2021 19:53:21 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1E9C260F11 for ; Thu, 26 Aug 2021 19:53:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1E9C260F11 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:55006 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJLRA-0000Wy-8e for qemu-devel@archiver.kernel.org; Thu, 26 Aug 2021 15:53:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJLOf-0005VY-Ct for qemu-devel@nongnu.org; Thu, 26 Aug 2021 15:50:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:26060) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJLOd-00039K-OR for qemu-devel@nongnu.org; Thu, 26 Aug 2021 15:50:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630007443; 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=5UH5gTXKqeTJNaOUfTO6KDAq9dp4eTnytqWl3CBLEdg=; b=eAzV5sUxnnHxNIxQjP979kX0VUfYqp9N0u1wngSOfYBU4NRRF0u9M6WFDXOyiapbI50vUo ccm/BBaGu0zEwQ7pqOi2Ee3OScbkHXW5WLIo4LyLXNQ8g37CSz4exkWv/GFkaOelUlHPjd Zy+r+iE0I5hkrZrDZKIxmZ8I/vyOOf0= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-465-gmi5yzPmPdu-qN0h7CYuyA-1; Thu, 26 Aug 2021 15:50:39 -0400 X-MC-Unique: gmi5yzPmPdu-qN0h7CYuyA-1 Received: by mail-wm1-f72.google.com with SMTP id m22-20020a7bca56000000b002e7508f3faeso1280539wml.2 for ; Thu, 26 Aug 2021 12:50:39 -0700 (PDT) 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=5UH5gTXKqeTJNaOUfTO6KDAq9dp4eTnytqWl3CBLEdg=; b=Tp5N+ax3f29SxlGDKRWwOy1zhs6svpuiLsnuQebUOU6A/E+/rhLAUXlvzJ0PTT6zeo 6r3iu/y+55r9eEGfQ06ijfbOCsm4KMhLKdqUsixwagLM/WSbjQ2VAUFaZr/cQcSucp/L I6Yqj7PM8t+xKYDZIfE0Fs+GD3hWpPXJvP585HEjRVR/Df+5ssrjukeQGc+91qmAvFyC b3+SBjGLozGf7LKR8MFb/TOuakkG5xPLrwIxwpgrZ8xw/ox4zmHWalbWwSeViqsYkzXJ r/gmHxrK1QNIaWY5g3ukMU4gI5LBpKCWzU2vCz7rKgjDYF4nrxu1t3kjCyCw33CqY6Z0 l+bQ== X-Gm-Message-State: AOAM531p61E+g+QbR4AmEqyfDQu7AWj4JDJHG3nVLsXm2Nc9PXf1y8++ X523D7G5OEmxz+68724N4vVzaeuWlcB+aZgq+OZuFTWFAkB+v95RJH7BeAieh/VXKa6lSUaNb1k xTVnSknxWc8XRxWuCWl7qS/Xl1xlRBZRbQ3p9coHdfRuf/ewsh/9A43ZzqyXvbpJ5 X-Received: by 2002:a1c:a78a:: with SMTP id q132mr5286218wme.91.1630007438315; Thu, 26 Aug 2021 12:50:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzonunia3BcQMWDDq13LsVtb9ObTCUsM75OJ/BHlnjwD0+Af0ay6Lz2YeQ4v6ltjDugUGcXzA== X-Received: by 2002:a1c:a78a:: with SMTP id q132mr5286198wme.91.1630007438147; Thu, 26 Aug 2021 12:50:38 -0700 (PDT) Received: from x1w.. (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id f17sm4740029wrt.63.2021.08.26.12.50.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 12:50:37 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 05/11] block/nvme: Have nvme_create_queue_pair() report errors consistently Date: Thu, 26 Aug 2021 21:50:08 +0200 Message-Id: <20210826195014.2180369-6-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210826195014.2180369-1-philmd@redhat.com> References: <20210826195014.2180369-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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.742, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Klaus Jensen , Auger Eric , Hanna Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" nvme_create_queue_pair() does not return a boolean value (indicating eventual error) but a pointer, and is inconsistent in how it fills the error handler. To fulfill callers expectations, always set an error message on failure. Reported-by: Auger Eric Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Klaus Jensen --- block/nvme.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/nvme.c b/block/nvme.c index e8dbbc23177..0786c501e46 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -220,6 +220,7 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s, q = g_try_new0(NVMeQueuePair, 1); if (!q) { + error_setg(errp, "Cannot allocate queue pair"); return NULL; } trace_nvme_create_queue_pair(idx, q, size, aio_context, @@ -228,6 +229,7 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s, qemu_real_host_page_size); q->prp_list_pages = qemu_try_memalign(qemu_real_host_page_size, bytes); if (!q->prp_list_pages) { + error_setg(errp, "Cannot allocate PRP page list"); goto fail; } memset(q->prp_list_pages, 0, bytes); @@ -239,6 +241,7 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s, r = qemu_vfio_dma_map(s->vfio, q->prp_list_pages, bytes, false, &prp_list_iova); if (r) { + error_setg_errno(errp, -r, "Cannot map buffer for DMA"); goto fail; } q->free_req_head = -1;