From patchwork Thu Aug 26 19:50:11 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: 12460641 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,URIBL_BLOCKED,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 57C13C432BE for ; Thu, 26 Aug 2021 19:58:05 +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 04FEA60F4C for ; Thu, 26 Aug 2021 19:58:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 04FEA60F4C 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]:43168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJLVk-0003FI-3d for qemu-devel@archiver.kernel.org; Thu, 26 Aug 2021 15:58:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49368) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJLOs-0005t2-MF for qemu-devel@nongnu.org; Thu, 26 Aug 2021 15:50:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:49494) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJLOp-0003GC-Uf for qemu-devel@nongnu.org; Thu, 26 Aug 2021 15:50:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630007454; 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=umqwksLtXVwt5Q4MQd+KtuQaKYoIZnas6CvSnWhM3q0=; b=LiqLerVisI7Ova4SUFOomNRG3E8G+Z8vW70ITiwtUR5A+V9mwNRpp9f2boAIDJXZJe+8ks ydrC2t+7pLnXoNxjTHMnBI+CnNoACOmjxiS0RLWCey0ve/p3qbgBAd6hx4oawoecQE9FNz PHUpMBYNNc8jNJRZk5N/E318tJP62wE= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-454-xYbmu-ifNMuG9DHjAbeuPw-1; Thu, 26 Aug 2021 15:50:53 -0400 X-MC-Unique: xYbmu-ifNMuG9DHjAbeuPw-1 Received: by mail-wr1-f72.google.com with SMTP id o9-20020a5d6849000000b001574518a85aso1201120wrw.11 for ; Thu, 26 Aug 2021 12:50:52 -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=umqwksLtXVwt5Q4MQd+KtuQaKYoIZnas6CvSnWhM3q0=; b=KRIOZZZGvQtnKyOcuHc0tgoQF+wEH6TvSkYJ2KJEFIU+KfqttqNPXcRHtIWeLVm/cQ yEUaGa5uSH6flVdS14r4J7vXPuYrtwJgTMx9IOlKJGiYya1cxI373fuurG9bQslAF8Rt UrcyqPuF/8HIL3VvziyOPjlkWmgC+6FppcUq8QEM0vRiY9VNIpms7faPRLGtpzf8+2G6 9HNqvtgb5tK0JDLcrH6SJaWsKzS8VA8cbx1n4q+zp8WYHMXnCn+mzKzOjz1mOOZfjLaS 53nBWRQP1pr5ToiaNW3HFAgIrbGXJERavo57xJRcBqu9+Qp6ZMNDRK988XhDWfIB6Se9 oM2w== X-Gm-Message-State: AOAM533kfqSUBODFMA1CYkI63HYnvRfIszkw9sMOd2/0chPWzOO5KohS pm7a4XV5zzRYdV5ZpWik1P3uLXVWk/UNtSZ6KIijXDpzgn+OEWTS45qkK1ckzhddkmv2qCTwcyO u+ZwEBKTMc5VVTIy4GLeoDJnMVwNeefkCbQ3JwoDo1LAWeYTA6KUWxgDX5ZxdARWd X-Received: by 2002:a05:600c:4152:: with SMTP id h18mr2321105wmm.55.1630007451493; Thu, 26 Aug 2021 12:50:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3kEbnE9dJSGbmrZEg2hRyrvfWdinwbSwV1YuV/Mm/kWH2Qef8qhRXNXF/jlgjLrNCsUKknw== X-Received: by 2002:a05:600c:4152:: with SMTP id h18mr2321087wmm.55.1630007451333; Thu, 26 Aug 2021 12:50:51 -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 f17sm4740622wrt.63.2021.08.26.12.50.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 12:50:51 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 08/11] util/vfio-helpers: Use error_setg in qemu_vfio_find_[fixed/temp]_iova Date: Thu, 26 Aug 2021 21:50:11 +0200 Message-Id: <20210826195014.2180369-9-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=170.10.133.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" Have qemu_vfio_find_fixed_iova() and qemu_vfio_find_temp_iova() propagate eventual errors to callers. Suggested-by: Klaus Jensen Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Klaus Jensen --- util/vfio-helpers.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index 306b5a83e48..7de5081dbd3 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -678,7 +678,8 @@ static bool qemu_vfio_verify_mappings(QEMUVFIOState *s) } static int -qemu_vfio_find_fixed_iova(QEMUVFIOState *s, size_t size, uint64_t *iova) +qemu_vfio_find_fixed_iova(QEMUVFIOState *s, size_t size, uint64_t *iova, + Error **errp) { int i; @@ -696,11 +697,14 @@ qemu_vfio_find_fixed_iova(QEMUVFIOState *s, size_t size, uint64_t *iova) return 0; } } + error_setg(errp, "fixed iova range not found"); + return -ENOMEM; } static int -qemu_vfio_find_temp_iova(QEMUVFIOState *s, size_t size, uint64_t *iova) +qemu_vfio_find_temp_iova(QEMUVFIOState *s, size_t size, uint64_t *iova, + Error **errp) { int i; @@ -718,6 +722,8 @@ qemu_vfio_find_temp_iova(QEMUVFIOState *s, size_t size, uint64_t *iova) return 0; } } + error_setg(errp, "temporary iova range not found"); + return -ENOMEM; } @@ -762,7 +768,7 @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, size_t size, goto out; } if (!temporary) { - if (qemu_vfio_find_fixed_iova(s, size, &iova0)) { + if (qemu_vfio_find_fixed_iova(s, size, &iova0, errp) < 0) { ret = -ENOMEM; goto out; } @@ -776,7 +782,7 @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, size_t size, } qemu_vfio_dump_mappings(s); } else { - if (qemu_vfio_find_temp_iova(s, size, &iova0)) { + if (qemu_vfio_find_temp_iova(s, size, &iova0, errp)) { ret = -ENOMEM; goto out; }