From patchwork Thu Aug 26 19:50:04 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: 1521320 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=G50sgsfH; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4GwYPn28GLz9sVw for ; Fri, 27 Aug 2021 05:51:25 +1000 (AEST) Received: from localhost ([::1]:49438 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJLPH-00055C-2e for incoming@patchwork.ozlabs.org; Thu, 26 Aug 2021 15:51:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49108) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJLON-0004rd-Bs for qemu-devel@nongnu.org; Thu, 26 Aug 2021 15:50:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31441) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJLOK-0002kj-LR for qemu-devel@nongnu.org; Thu, 26 Aug 2021 15:50:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630007423; 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=DPW4a8fAJ5aQIhBkKgFcCQAwlhPjH6NHU1IvtDHYfFc=; b=G50sgsfH31pWoeXgLLRtOKlGvBfS0xjFMEGoNxBjSn9QfSbeGL/9mh9yTB7t5WRwo20mWw AeFU1EjvAZG+jlEVYVDMg/FPUimUqp/QPEIfumirOr+Vq3fz+lov3xbhdFuANWKJCYJHiS M0rNNxwYM2Z3ZS6jWKeuxImne5zga/8= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-551-PbnQHP7TM9Ok6ASZH6rKbQ-1; Thu, 26 Aug 2021 15:50:22 -0400 X-MC-Unique: PbnQHP7TM9Ok6ASZH6rKbQ-1 Received: by mail-wr1-f69.google.com with SMTP id l1-20020adff481000000b00156e670a09dso1220900wro.1 for ; Thu, 26 Aug 2021 12:50:22 -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=DPW4a8fAJ5aQIhBkKgFcCQAwlhPjH6NHU1IvtDHYfFc=; b=khfd7rjvUHpwT5/UTqICmS1LEMn4Sv6prWxNIYg4ed5nFSv7afdBOcJAn3OmF0IYcP o6wNOuuyIAceC7p+I3SD3KOnhid/JYBIjYLym1sajMfK3M4VfgiMj7uHF7lGjBHyW/sc Tjy7kGDO4eOyKzPvk2LhbtbhnsZlZM6xLZWzn3gZ1AzzZ5pPao1tizlG//Kw0bLMcUIk AMYQ9oeQZdchwDz3Chk+UzwKM+C4NMR3uKOsbw1bDGfkh4SMqAQBXQ+QbTp9NE6EmrLH fL0dCzcZ/FRbUEV4wgQ1AgrhHwbDTx+98MYLRoc2mlLyAkNiHW3eSV9yP1u7cz9vRmz7 4B+g== X-Gm-Message-State: AOAM531jDIDPCyFGMjywCYNz1FZaJX/8vSAmtaG3d4b5x4jSzgC9SvDB p+fGIqbHxYxxSuDca4+JCj4xvjhyU6bzixj81UMJW9aj9yReK4sc1eQWKgrTm60z1TXMQXh8JwM 7rpHHqPUM79ZhJ0KuOEFzV6lwrJbjohnc3Mo55o3fbilBqSERRH+xOvCPxacC94h2 X-Received: by 2002:adf:fcc5:: with SMTP id f5mr6147570wrs.114.1630007420963; Thu, 26 Aug 2021 12:50:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRI0s+iQs7V4r++edyJffi8HHplgzEnD3/oANNrp3ZWOtGA3u2MsUT7LDyLQ4pQ6/+PmgATg== X-Received: by 2002:adf:fcc5:: with SMTP id f5mr6147548wrs.114.1630007420667; Thu, 26 Aug 2021 12:50:20 -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 n15sm4106961wrv.48.2021.08.26.12.50.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 12:50:20 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 01/11] block/nvme: Use safer trace format string Date: Thu, 26 Aug 2021 21:50:04 +0200 Message-Id: <20210826195014.2180369-2-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=unavailable 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Fix when building with -Wshorten-64-to-32: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32] Reviewed-by: Klaus Jensen Signed-off-by: Philippe Mathieu-Daudé --- block/trace-events | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/trace-events b/block/trace-events index b3d2b1e62cb..f4f1267c8c0 100644 --- a/block/trace-events +++ b/block/trace-events @@ -156,7 +156,7 @@ nvme_dsm(void *s, uint64_t offset, uint64_t bytes) "s %p offset 0x%"PRIx64" byte nvme_dsm_done(void *s, uint64_t offset, uint64_t bytes, int ret) "s %p offset 0x%"PRIx64" bytes %"PRId64" ret %d" nvme_dma_map_flush(void *s) "s %p" nvme_free_req_queue_wait(void *s, unsigned q_index) "s %p q #%u" -nvme_create_queue_pair(unsigned q_index, void *q, unsigned size, void *aio_context, int fd) "index %u q %p size %u aioctx %p fd %d" +nvme_create_queue_pair(unsigned q_index, void *q, size_t size, void *aio_context, int fd) "index %u q %p size %zu aioctx %p fd %d" nvme_free_queue_pair(unsigned q_index, void *q) "index %u q %p" nvme_cmd_map_qiov(void *s, void *cmd, void *req, void *qiov, int entries) "s %p cmd %p req %p qiov %p entries %d" nvme_cmd_map_qiov_pages(void *s, int i, uint64_t page) "s %p page[%d] 0x%"PRIx64 From patchwork Thu Aug 26 19:50:05 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: 1521323 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Vape+nU5; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4GwYT81Y6wz9sW4 for ; Fri, 27 Aug 2021 05:54:20 +1000 (AEST) Received: from localhost ([::1]:58502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJLS5-0002qO-VY for incoming@patchwork.ozlabs.org; Thu, 26 Aug 2021 15:54:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49136) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJLOQ-0004yf-3t for qemu-devel@nongnu.org; Thu, 26 Aug 2021 15:50:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53003) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJLOO-0002pU-JY for qemu-devel@nongnu.org; Thu, 26 Aug 2021 15:50:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630007427; 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=rai7h32TrTkDK/wiLtMpSewodwbvjWhnx25D5kPSBpM=; b=Vape+nU5EIRmNzpGxCEn6wjDu5auxD268RGcs6c768mSQVJzO4fVU2oD+nVJKuSEFiDdyH f5trtSl8sLkq+gpoygPqx5U4SniUbToS6HPSSz+lCzpguRlN8fiR0UASKcy4cxw3u5OeW9 V/LgB633LFGrZ9kS+q9JL8ohb8CzAP4= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-402-b0nJgZRJPryr4XoMIeuSKg-1; Thu, 26 Aug 2021 15:50:26 -0400 X-MC-Unique: b0nJgZRJPryr4XoMIeuSKg-1 Received: by mail-wm1-f69.google.com with SMTP id 201-20020a1c01d2000000b002e72ba822dcso4772431wmb.6 for ; Thu, 26 Aug 2021 12:50:26 -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=rai7h32TrTkDK/wiLtMpSewodwbvjWhnx25D5kPSBpM=; b=Zqtqj7etiYa1LMCzXWc9BdZ2gjnkcwkyoYf8/fv8tpQK1kdXim/uXQC222oBXcJq1g pJacoQjX7XptmsbdSHH56GbwNy8KDNcfPxfcfd7z88bOLzCletC/UeHQJ5034Ioj1TBO eWy/dhbxD/tMUxg/lpHQ1HCwpGYViXXqVNQF1gCnqt/mwEQVj5NhVrbpdYrd2ngsX/Yj u8rhyLbwzqgNJt1oQ/LmvNOlaE8Xa+wmkq7vPLtcwEInEnK00wsG3do4T/F0RzlX6ovz RYt5/SU1jssZ7/XO+Ceyifto8TEEPu3iTkiP4beKSKUBGCipSxU+q9jeJZYkqMNuBiZX uTMQ== X-Gm-Message-State: AOAM532nVIrkj95nXXgIn11TrmxQkYbR2yXOSR+zfid4vjj1jrG1xXM0 qgGRLtMnjBS/PXcRlZVgDckDAP30j6y6LJ5KUxShXlHb8+ByTLLiSu4S5oYmI9mFzKoYOVdJ8Mu adjiVQAc9fg7ZSMgllVkcW/hWDK/sjvh/2cNLc3RmtPO+gD06DRlxtGfnuCJIHnVk X-Received: by 2002:a1c:210a:: with SMTP id h10mr7971664wmh.117.1630007425279; Thu, 26 Aug 2021 12:50:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDRJMm/10Yb6eJeXOOXHlAhtXlhDCxZAVFiUBI3triim5kJuM2Pq0s4mOxybiUpx/CAYgyqQ== X-Received: by 2002:a1c:210a:: with SMTP id h10mr7971645wmh.117.1630007425097; Thu, 26 Aug 2021 12:50:25 -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 a10sm8817058wmj.44.2021.08.26.12.50.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 12:50:24 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 02/11] util/vfio-helpers: Let qemu_vfio_verify_mappings() use error_report() Date: Thu, 26 Aug 2021 21:50:05 +0200 Message-Id: <20210826195014.2180369-3-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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Instead of displaying the error on stderr, use error_report() which also report to the monitor. Reviewed-by: Fam Zheng Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Klaus Jensen --- util/vfio-helpers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index 911115b86e6..1d149136299 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -660,13 +660,13 @@ static bool qemu_vfio_verify_mappings(QEMUVFIOState *s) if (QEMU_VFIO_DEBUG) { for (i = 0; i < s->nr_mappings - 1; ++i) { if (!(s->mappings[i].host < s->mappings[i + 1].host)) { - fprintf(stderr, "item %d not sorted!\n", i); + error_report("item %d not sorted!", i); qemu_vfio_dump_mappings(s); return false; } if (!(s->mappings[i].host + s->mappings[i].size <= s->mappings[i + 1].host)) { - fprintf(stderr, "item %d overlap with next!\n", i); + error_report("item %d overlap with next!", i); qemu_vfio_dump_mappings(s); return false; } From patchwork Thu Aug 26 19:50:06 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: 1521326 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=P4FgOn88; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4GwYXF3lHFz9sVw for ; Fri, 27 Aug 2021 05:56:59 +1000 (AEST) Received: from localhost ([::1]:38754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJLUe-0000KC-Dj for incoming@patchwork.ozlabs.org; Thu, 26 Aug 2021 15:56:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49170) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJLOU-00059m-MF for qemu-devel@nongnu.org; Thu, 26 Aug 2021 15:50:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:53555) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJLOT-0002z2-4A for qemu-devel@nongnu.org; Thu, 26 Aug 2021 15:50:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630007432; 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=2lm4MltjciLe1FvPMjz8J1KaGtyzlphex4Ajbbc6qJo=; b=P4FgOn88ze7wrshXMRNUbqUWscc0JNbHcJ+pfb1+urtVztTNiTzuOCpj9A5ECQ/1qaQn+d BTabsQ328TjtomUL+vzcOswe2FAAlKgk/Ylp0Ku7Rd0xYuDUwZLm6K540wxExucsMir1Da WfBAi/SUeVzPVXFf22fxDPPpHjyRtb4= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-293-5y7amJanMmanGlzlhCZ-Ng-1; Thu, 26 Aug 2021 15:50:31 -0400 X-MC-Unique: 5y7amJanMmanGlzlhCZ-Ng-1 Received: by mail-wr1-f69.google.com with SMTP id q11-20020a5d61cb0000b02901550c3fccb5so1200826wrv.14 for ; Thu, 26 Aug 2021 12:50:30 -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=2lm4MltjciLe1FvPMjz8J1KaGtyzlphex4Ajbbc6qJo=; b=oPzXhCPrRcyzgK2jkhFYRHOeG6yLsP9DYsCJ5QyikusFD3YVCXZ3YaT9kdehxLZ9Bq YmVsAOxz9KfhzaL6tZJfmlBKo722RPOf8cm3X+RZmw8mTNoaVpSO3haU4qAK1S39yJW2 ScXsTe/EyJ6q+GM5WqeTZ8RWWmEg5+TIoCbm9+UtYXIv4ui/mKrxNX9DT4z0yeL2Y0MA iJZEuUSQpF1KOE2/5U25LbxrgpbzYIDYcm4SQmdVfhhoszap+bmA7oRmGJGfplmuoXLr 3n0nCosv1TTp2NqBRyHUXvQathOPbaotF98Ht3z1Syp7Kgi5iPVzjafqK2pANAMhypYu CT1Q== X-Gm-Message-State: AOAM533He/h6ZAQ+XkgJNOWg6p7tSefHSOmPrDNWsT9i8m+i/X00PDRX hTIwv1QMGqsdMaEZrLl5bDHh7tI48rWEIKNXQaIyKy3wDBjD/xrHZtK256I3+nf4yRUBfEDCNeU LhXEK6nrt/jrPkd2NHr5vtKj8xMsbL2zXobezpBZaHohraFXBarWjNi5wSyMklld7 X-Received: by 2002:a1c:29c3:: with SMTP id p186mr5259861wmp.22.1630007429784; Thu, 26 Aug 2021 12:50:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhY56nY8acJv336t+w5OxTG8jgsWTSeozY/XtH4noR1liRtVoYV69/WBsw2kOvcNGHblDT6Q== X-Received: by 2002:a1c:29c3:: with SMTP id p186mr5259838wmp.22.1630007429532; Thu, 26 Aug 2021 12:50:29 -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 q11sm9152016wmc.41.2021.08.26.12.50.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 12:50:29 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 03/11] util/vfio-helpers: Replace qemu_mutex_lock() calls with QEMU_LOCK_GUARD Date: Thu, 26 Aug 2021 21:50:06 +0200 Message-Id: <20210826195014.2180369-4-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=unavailable 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Simplify qemu_vfio_dma_[un]map() handlers by replacing a pair of qemu_mutex_lock/qemu_mutex_unlock calls by the WITH_QEMU_LOCK_GUARD macro. Reviewed-by: Klaus Jensen Signed-off-by: Philippe Mathieu-Daudé --- util/vfio-helpers.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index 1d149136299..d956866b4e9 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -735,7 +735,7 @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, size_t size, assert(QEMU_PTR_IS_ALIGNED(host, qemu_real_host_page_size)); assert(QEMU_IS_ALIGNED(size, qemu_real_host_page_size)); trace_qemu_vfio_dma_map(s, host, size, temporary, iova); - qemu_mutex_lock(&s->lock); + QEMU_LOCK_GUARD(&s->lock); mapping = qemu_vfio_find_mapping(s, host, &index); if (mapping) { iova0 = mapping->iova + ((uint8_t *)host - (uint8_t *)mapping->host); @@ -778,7 +778,6 @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, size_t size, *iova = iova0; } out: - qemu_mutex_unlock(&s->lock); return ret; } @@ -813,14 +812,12 @@ void qemu_vfio_dma_unmap(QEMUVFIOState *s, void *host) } trace_qemu_vfio_dma_unmap(s, host); - qemu_mutex_lock(&s->lock); + QEMU_LOCK_GUARD(&s->lock); m = qemu_vfio_find_mapping(s, host, &index); if (!m) { - goto out; + return; } qemu_vfio_undo_mapping(s, m, NULL); -out: - qemu_mutex_unlock(&s->lock); } static void qemu_vfio_reset(QEMUVFIOState *s) From patchwork Thu Aug 26 19:50:07 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: 1521329 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GvK9hLvl; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4GwYZM2qD9z9sVw for ; Fri, 27 Aug 2021 05:58:51 +1000 (AEST) Received: from localhost ([::1]:45148 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJLWT-0004Zn-5s for incoming@patchwork.ozlabs.org; Thu, 26 Aug 2021 15:58:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49224) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJLOb-0005K5-Uw for qemu-devel@nongnu.org; Thu, 26 Aug 2021 15:50:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23297) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJLOZ-00035H-KB for qemu-devel@nongnu.org; Thu, 26 Aug 2021 15:50:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630007438; 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=CPZfczG2XQrRC55s69h86ljHzGci8wjhwO3c1XD3j8g=; b=GvK9hLvlvCwfFG+v5riWOLsSPLU048yducizMLYKbnDGu5CIherS9cvXRTqybQyOJLwtIz bbxNRwvENe91Pd3gHnhw/lIjrYQHLB/pZmri2Dy4nVRQRAGBg/QAextRa7XDarLw+1mbMm a0gftFCIUZaRwkl7D3mCATEm/C+E1Ko= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-31-7Lbqu5ZGOAyWhv2G0osWyQ-1; Thu, 26 Aug 2021 15:50:35 -0400 X-MC-Unique: 7Lbqu5ZGOAyWhv2G0osWyQ-1 Received: by mail-wr1-f70.google.com with SMTP id l1-20020adff481000000b00156e670a09dso1221058wro.1 for ; Thu, 26 Aug 2021 12:50:35 -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=CPZfczG2XQrRC55s69h86ljHzGci8wjhwO3c1XD3j8g=; b=SapqYbIlxMGrYAcpZ+WSPMgBjIwxcQPic+UN9nLImDQKfdxCnp/Sy+PjQs1lBm1qzz TFPiVkYvNJa7DXh+GvULv3odisrHSub9X5yJUJxbStmdFvWnr8jMV9HKuYlKsQmaIwkF UATiirBUHbEAS3+NG+6mlGE0gGgsLvgFmgXWi4DV6F5x77SqheY2TIu5rVB5UtSMbbFS aurRcot/xnyNJr4NWeSHVudu1bgot+If6FD8aO4WezheX0+c7ASbSDK4r4f40KlGQVnV gOMxeFeebppPJG+tl1J79//GCP6S0zENU0QDipLC1pMAJFfTaIRyCO3bRhJdoQNYJBf5 ZDUg== X-Gm-Message-State: AOAM531Oft2ZmKuSKPjUsrEYgSRvRUg0kaEXrT3X/mf/AkIPKIEtwQrR qogP7LAK63v731XWN405P3pFfuMNIORDOSWXIQSCyMN9/eF1YnOLbJDQHjCvEf8h46pUuyEjGgH qNKQB0l13HDT/CdQ9Ts9iK3BsKZIK0Y3thjsxgSrJIqaYGxdPY+vbx1BNjnWxbNKD X-Received: by 2002:adf:edcf:: with SMTP id v15mr6037122wro.61.1630007434120; Thu, 26 Aug 2021 12:50:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxpPp74nFUTEVaLdtiLUSM5iwa51BcR3IivZ17saErSXnDIEFKbQUjijSVSLzvrnHoZPy7trQ== X-Received: by 2002:adf:edcf:: with SMTP id v15mr6037090wro.61.1630007433858; Thu, 26 Aug 2021 12:50:33 -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 o5sm4003844wrw.17.2021.08.26.12.50.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 12:50:33 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 04/11] util/vfio-helpers: Remove unreachable code in qemu_vfio_dma_map() Date: Thu, 26 Aug 2021 21:50:07 +0200 Message-Id: <20210826195014.2180369-5-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: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" qemu_vfio_add_mapping() returns a pointer to an indexed entry in pre-allocated QEMUVFIOState::mappings[], thus can not be NULL. Remove the pointless check. Reviewed-by: Klaus Jensen Signed-off-by: Philippe Mathieu-Daudé --- util/vfio-helpers.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index d956866b4e9..e7909222cfd 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -751,10 +751,6 @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, size_t size, } mapping = qemu_vfio_add_mapping(s, host, size, index + 1, iova0); - if (!mapping) { - ret = -ENOMEM; - goto out; - } assert(qemu_vfio_verify_mappings(s)); ret = qemu_vfio_do_mapping(s, host, size, iova0); if (ret) { 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: 1521321 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=eAzV5sUx; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4GwYQS0KGvz9sVw for ; Fri, 27 Aug 2021 05:51:59 +1000 (AEST) Received: from localhost ([::1]:51034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJLPp-0006JR-Fn for incoming@patchwork.ozlabs.org; Thu, 26 Aug 2021 15:51:57 -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+incoming=patchwork.ozlabs.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; From patchwork Thu Aug 26 19:50:09 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: 1521322 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Xj1nNq3z; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4GwYT71l6xz9sVw for ; Fri, 27 Aug 2021 05:54:19 +1000 (AEST) Received: from localhost ([::1]:58296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJLS4-0002ih-VC for incoming@patchwork.ozlabs.org; Thu, 26 Aug 2021 15:54:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49294) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJLOj-0005i2-U4 for qemu-devel@nongnu.org; Thu, 26 Aug 2021 15:50:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:34299) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJLOg-0003Ah-Fm for qemu-devel@nongnu.org; Thu, 26 Aug 2021 15:50:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630007445; 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=wNKmqePd9nD6kB4TAflUms7TAcM03nxgZUc5G0laZ78=; b=Xj1nNq3zoitcmiGPs0aYRUPBEN5t9MQGj+DZ1Owv/QdNluhNtbcoQn3fm+P+EFvlvt0jt4 XTIrLoKCJzn5+17Gm1l0kzrL4cA/2Bo4lw9RVpV0CMlJ+fq2uRuDMPMCCuow44gsBBnq2P 9xVyvQZ+JkJ4J75hAe9DWgYAhBTD7Wc= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-548-hm7fiXMXMEGgWnVH8_XkfA-1; Thu, 26 Aug 2021 15:50:44 -0400 X-MC-Unique: hm7fiXMXMEGgWnVH8_XkfA-1 Received: by mail-wr1-f71.google.com with SMTP id a13-20020adfed0d000000b00156fd70137aso1209984wro.8 for ; Thu, 26 Aug 2021 12:50:44 -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=wNKmqePd9nD6kB4TAflUms7TAcM03nxgZUc5G0laZ78=; b=f4h2zcsXPPsfUaJb15Gycyi/Eb7hoQ/a5s+qhzW4xGjagGud1uXXO/8E6le9MSLkrD pPoNOHaYYSNyYq1Gvn8DjE9tCX7e3CypjY3ALL8Yv4yg6fYl8L6aEF5ZobJDgW6LIqrl TL4h9e000bduEeypD3DBBDu+W2rFMOhx9Ssg5PyYxhXY+4ZSSEgci7SUvQ5E9sqxzv9H oaq8PIDciVdb0w3gayWKPLA2p6Bl/C3BnW3opPohPc0DPzTtWrY617HRpGzLIRrxA+Wz CoVhhga6d1cZ62FF8VfmFrHJ3KrBJsj7s6tXWRrpPPZIwvUD/0cC5iHXoHhRHnqJIh0p Ei2w== X-Gm-Message-State: AOAM530xT2YvUC2oxIzLexkFOLGRfTKot1aNEc5WEcSe4X1CWw7JpLrQ 40806d/ztvdfmrsY8SYfRE05/Lh5gl9L6/KER3kDNnN0Ws9inY17RktBGy0FpQtq3y0K3Wno1ns XBcxx0N3f2NlObSfLVI7SevI++Tjiu3RNekLb1OEVqJq5hjWluq+bHcZailU1P0UA X-Received: by 2002:a1c:20d7:: with SMTP id g206mr16487950wmg.153.1630007442903; Thu, 26 Aug 2021 12:50:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4ikk6NdIGdn/N8EhcUbRj/Guyxy9oh+MatSjdS8sHMUKZllpGQe5cK/7HvtJCbRZ8YDmYMA== X-Received: by 2002:a1c:20d7:: with SMTP id g206mr16487927wmg.153.1630007442694; Thu, 26 Aug 2021 12:50:42 -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 m4sm9324912wml.28.2021.08.26.12.50.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 12:50:42 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 06/11] util/vfio-helpers: Pass Error handle to qemu_vfio_dma_map() Date: Thu, 26 Aug 2021 21:50:09 +0200 Message-Id: <20210826195014.2180369-7-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=unavailable 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Currently qemu_vfio_dma_map() displays errors on stderr. When using management interface, this information is simply lost. Pass qemu_vfio_dma_map() an Error** handle so it can propagate the error to callers. Reviewed-by: Fam Zheng Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Klaus Jensen --- include/qemu/vfio-helpers.h | 2 +- block/nvme.c | 22 +++++++++++----------- util/vfio-helpers.c | 10 ++++++---- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/include/qemu/vfio-helpers.h b/include/qemu/vfio-helpers.h index 4491c8e1a6e..bde9495b254 100644 --- a/include/qemu/vfio-helpers.h +++ b/include/qemu/vfio-helpers.h @@ -18,7 +18,7 @@ typedef struct QEMUVFIOState QEMUVFIOState; QEMUVFIOState *qemu_vfio_open_pci(const char *device, Error **errp); void qemu_vfio_close(QEMUVFIOState *s); int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, size_t size, - bool temporary, uint64_t *iova_list); + bool temporary, uint64_t *iova_list, Error **errp); int qemu_vfio_dma_reset_temporary(QEMUVFIOState *s); void qemu_vfio_dma_unmap(QEMUVFIOState *s, void *host); void *qemu_vfio_pci_map_bar(QEMUVFIOState *s, int index, diff --git a/block/nvme.c b/block/nvme.c index 0786c501e46..80546b0babd 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -176,12 +176,11 @@ static bool nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q, return false; } memset(q->queue, 0, bytes); - r = qemu_vfio_dma_map(s->vfio, q->queue, bytes, false, &q->iova); + r = qemu_vfio_dma_map(s->vfio, q->queue, bytes, false, &q->iova, errp); if (r) { - error_setg(errp, "Cannot map queue"); - return false; + error_prepend(errp, "Cannot map queue: "); } - return true; + return r == 0; } static void nvme_free_queue_pair(NVMeQueuePair *q) @@ -239,9 +238,9 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s, qemu_co_queue_init(&q->free_req_queue); q->completion_bh = aio_bh_new(aio_context, nvme_process_completion_bh, q); r = qemu_vfio_dma_map(s->vfio, q->prp_list_pages, bytes, - false, &prp_list_iova); + false, &prp_list_iova, errp); if (r) { - error_setg_errno(errp, -r, "Cannot map buffer for DMA"); + error_prepend(errp, "Cannot map buffer for DMA: "); goto fail; } q->free_req_head = -1; @@ -534,9 +533,9 @@ static bool nvme_identify(BlockDriverState *bs, int namespace, Error **errp) error_setg(errp, "Cannot allocate buffer for identify response"); goto out; } - r = qemu_vfio_dma_map(s->vfio, id, id_size, true, &iova); + r = qemu_vfio_dma_map(s->vfio, id, id_size, true, &iova, errp); if (r) { - error_setg(errp, "Cannot map buffer for DMA"); + error_prepend(errp, "Cannot map buffer for DMA: "); goto out; } @@ -1032,7 +1031,7 @@ static coroutine_fn int nvme_cmd_map_qiov(BlockDriverState *bs, NvmeCmd *cmd, try_map: r = qemu_vfio_dma_map(s->vfio, qiov->iov[i].iov_base, - len, true, &iova); + len, true, &iova, NULL); if (r == -ENOSPC) { /* * In addition to the -ENOMEM error, the VFIO_IOMMU_MAP_DMA @@ -1524,14 +1523,15 @@ static void nvme_aio_unplug(BlockDriverState *bs) static void nvme_register_buf(BlockDriverState *bs, void *host, size_t size) { int ret; + Error *local_err = NULL; BDRVNVMeState *s = bs->opaque; - ret = qemu_vfio_dma_map(s->vfio, host, size, false, NULL); + ret = qemu_vfio_dma_map(s->vfio, host, size, false, NULL, &local_err); if (ret) { /* FIXME: we may run out of IOVA addresses after repeated * bdrv_register_buf/bdrv_unregister_buf, because nvme_vfio_dma_unmap * doesn't reclaim addresses for fixed mappings. */ - error_report("nvme_register_buf failed: %s", strerror(-ret)); + error_reportf_err(local_err, "nvme_register_buf failed: "); } } diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index e7909222cfd..77cdec845d9 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -463,13 +463,15 @@ static void qemu_vfio_ram_block_added(RAMBlockNotifier *n, void *host, size_t size, size_t max_size) { QEMUVFIOState *s = container_of(n, QEMUVFIOState, ram_notifier); + Error *local_err = NULL; int ret; trace_qemu_vfio_ram_block_added(s, host, max_size); - ret = qemu_vfio_dma_map(s, host, max_size, false, NULL); + ret = qemu_vfio_dma_map(s, host, max_size, false, NULL, &local_err); if (ret) { - error_report("qemu_vfio_dma_map(%p, %zu) failed: %s", host, max_size, - strerror(-ret)); + error_reportf_err(local_err, + "qemu_vfio_dma_map(%p, %zu) failed: ", + host, max_size); } } @@ -725,7 +727,7 @@ qemu_vfio_find_temp_iova(QEMUVFIOState *s, size_t size, uint64_t *iova) * mapping status within this area is not allowed). */ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, size_t size, - bool temporary, uint64_t *iova) + bool temporary, uint64_t *iova, Error **errp) { int ret = 0; int index; From patchwork Thu Aug 26 19:50:10 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: 1521324 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZuOz7KVi; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4GwYTj6pwJz9sVw for ; Fri, 27 Aug 2021 05:54:49 +1000 (AEST) Received: from localhost ([::1]:60404 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJLSZ-00046f-Jw for incoming@patchwork.ozlabs.org; Thu, 26 Aug 2021 15:54:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49326) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJLOn-0005no-Dw for qemu-devel@nongnu.org; Thu, 26 Aug 2021 15:50:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:26473) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJLOk-0003Cq-Oc for qemu-devel@nongnu.org; Thu, 26 Aug 2021 15:50:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630007449; 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=yPAeN1ELfe7bdUEPxcVE2xQF9fAx3P6/HJ2p3gjANPc=; b=ZuOz7KVif5nkt449h2mQ/YaVYx1mRE1a2euaXKDNzvAW70chFU9iMEWzJlLugg0w7ZHBQJ OofAaPrhFFKO9eznjf4kofTFVu3jvmEuHxASCETrqP+BLW14jkoBc7e5H1KH6fuMDGWSWd fHECCQenahQQ66QopxprdVFXp6BIlwM= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-280-y76H7EQ3MQ2xpapEH-K2hA-1; Thu, 26 Aug 2021 15:50:48 -0400 X-MC-Unique: y76H7EQ3MQ2xpapEH-K2hA-1 Received: by mail-wm1-f69.google.com with SMTP id x125-20020a1c3183000000b002e73f079eefso3459009wmx.0 for ; Thu, 26 Aug 2021 12:50:48 -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=yPAeN1ELfe7bdUEPxcVE2xQF9fAx3P6/HJ2p3gjANPc=; b=YhJwuivAOjeo3K+ADJgdegqdQyfOFDAMoGJRWmHY6sZjMf7stzAkdpO62hALRyVydY VkNJ1tnq3AzvjSq1OG26CALFm4jv0x2y/Si+RLNKSSWOqqg6wiaaMvvu8zKMeOibQLCo PlvWFRQtlDhKGu+kymOUkjUkr8Bwnu7yHigdmqXzm0iElcP2EA0Otxe/CxcMyGt8sdBJ jAT/sI5IDdz7wXD4PQnHI71Uqg6r05AZYjILUNKFFoB+Ouf05akc2CisOAzQ53PBuxl0 Ds66bt+NVerrA5Aw0B/BdB5ewuyI2mmqRmpAOUtfVFLScmR1QgITuZip/e28cLmBcjG/ INJg== X-Gm-Message-State: AOAM533h+i0te/uZRcY80WANXIibV/p0ChTr9nc2Aq9kva6ZvTCgcrbE uOSShmCRy96Nq6Rc86ftOsUyGpQvCJlVyFOI7fm55VzWKFXsrgsHvbEukGOd+WRnHc7ms2kUkAp NxdhpzJTIrL48/dkQrKG0GXfcBVB9p3sreKnyunni7LB4nt6XgwiDfLY/8xwRfIKn X-Received: by 2002:a1c:2209:: with SMTP id i9mr5245168wmi.92.1630007447217; Thu, 26 Aug 2021 12:50:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvwCtxIeyv/Wa8uD6Rfs62sxbIWRS5/+E5nqnpvvnuaWK1lYYpSxcT7NwU5XrhcIvrR8GOWw== X-Received: by 2002:a1c:2209:: with SMTP id i9mr5245143wmi.92.1630007447016; Thu, 26 Aug 2021 12:50:47 -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 z137sm9522151wmc.14.2021.08.26.12.50.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 12:50:46 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 07/11] util/vfio-helpers: Extract qemu_vfio_water_mark_reached() Date: Thu, 26 Aug 2021 21:50:10 +0200 Message-Id: <20210826195014.2180369-8-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=unavailable 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Extract qemu_vfio_water_mark_reached() for readability, and have it provide an error hint it its Error* handle. Suggested-by: Klaus Jensen Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Klaus Jensen --- util/vfio-helpers.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index 77cdec845d9..306b5a83e48 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -721,6 +721,21 @@ qemu_vfio_find_temp_iova(QEMUVFIOState *s, size_t size, uint64_t *iova) return -ENOMEM; } +/** + * qemu_vfio_water_mark_reached: + * + * Returns %true if high watermark has been reached, %false otherwise. + */ +static bool qemu_vfio_water_mark_reached(QEMUVFIOState *s, size_t size, + Error **errp) +{ + if (s->high_water_mark - s->low_water_mark + 1 < size) { + error_setg(errp, "iova exhausted (water mark reached)"); + return true; + } + return false; +} + /* Map [host, host + size) area into a contiguous IOVA address space, and store * the result in @iova if not NULL. The caller need to make sure the area is * aligned to page size, and mustn't overlap with existing mapping areas (split @@ -742,7 +757,7 @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, size_t size, if (mapping) { iova0 = mapping->iova + ((uint8_t *)host - (uint8_t *)mapping->host); } else { - if (s->high_water_mark - s->low_water_mark + 1 < size) { + if (qemu_vfio_water_mark_reached(s, size, errp)) { ret = -ENOMEM; goto out; } 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: 1521328 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=LiqLerVi; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4GwYXh6K5vz9sVw for ; Fri, 27 Aug 2021 05:57:24 +1000 (AEST) Received: from localhost ([::1]:40124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJLV4-0001En-Mm for incoming@patchwork.ozlabs.org; Thu, 26 Aug 2021 15:57:22 -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+incoming=patchwork.ozlabs.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; } From patchwork Thu Aug 26 19:50:12 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: 1521331 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Uy0NY50p; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4GwYfL2nrmz9sVw for ; Fri, 27 Aug 2021 06:02:16 +1000 (AEST) Received: from localhost ([::1]:50084 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJLZl-0007yy-Ey for incoming@patchwork.ozlabs.org; Thu, 26 Aug 2021 16:02:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49408) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJLOx-0005wS-TX for qemu-devel@nongnu.org; Thu, 26 Aug 2021 15:51:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:37740) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJLOu-0003KN-SK for qemu-devel@nongnu.org; Thu, 26 Aug 2021 15:51:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630007460; 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=BVQGD97lOuv5jkp0wr3tMIUyo/OkErXO+YtZC52NVRU=; b=Uy0NY50poAFow6D3HVzpTC5wIeVUYCya6e8tGKKTYaTfO8YI7Bsnj+tFhRS3ML2GfyukgA Y844gE000VLVz4xC9KTuXTTvaQkwTnBPfkxvKafBlbxUQ9AhnYZLf/EKJBPI2KSgFPm/lI nqNbUZa5KTovZEhE8YDaL6Doc3vqZA0= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-15-fO6dYsVVPgildWldEnD3lw-1; Thu, 26 Aug 2021 15:50:57 -0400 X-MC-Unique: fO6dYsVVPgildWldEnD3lw-1 Received: by mail-wr1-f71.google.com with SMTP id l1-20020adff481000000b00156e670a09dso1221258wro.1 for ; Thu, 26 Aug 2021 12:50:57 -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=BVQGD97lOuv5jkp0wr3tMIUyo/OkErXO+YtZC52NVRU=; b=A02Y44fgiCKYKPkSRj3o8wq+N++Ll/NIZmrTyK91efxUe93wq9J1iRDy+MAdF4/PAI /cllSSSMdzr/yy1QrRWOZZZ3sCm1erKzcTjfv3pXKEv3CT96r3R5rGGKLIVWy2T8DR+J F6HMauPPNid0OTcd5ykCShdU22CxseC/G0hwFtlJ7sTLIfCdczgD1xf2ec8WXb+GKk0g XiGW/v92e+PHrEChElCVZ45iuf/lBnlfTkVu6KUFEMuSXjZ3IuaWPtPH1yF7P9jMMm8h Oc9YtzIY5BpIFWRmIuL8DSQ+gIG+d9U+j4mczsPej/gFjda1RTj0uka5N0YJR+zf3uGj 4pFw== X-Gm-Message-State: AOAM531ezlnxAZGlxP6HZsoc8t0MOly0Oa/q4bowE9xqMEm997+NBxbw I+Sp44HqLWYrarcNPeUBot/XPWsjqL+rkT2RSGkB7b3BMJ6b1EjCpGD1s5aZHDHWEYcmv2swaDS RIBzc67b9oyXLUQgbRtVDLfHeRUOeB0JJZJ06LOiEGYT79hYdmX8r1FdO9wEFG+mo X-Received: by 2002:a5d:69c8:: with SMTP id s8mr5807478wrw.324.1630007455773; Thu, 26 Aug 2021 12:50:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNNJ19Av96aSZJp6jKLp1FNdmSOMavSlUl7pm1Ya1l6fqMWpOuwriSGHgY8vutcJfFdjYZtQ== X-Received: by 2002:a5d:69c8:: with SMTP id s8mr5807456wrw.324.1630007455608; Thu, 26 Aug 2021 12:50:55 -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 b15sm4637345wru.1.2021.08.26.12.50.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 12:50:55 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 09/11] util/vfio-helpers: Simplify qemu_vfio_dma_map() returning directly Date: Thu, 26 Aug 2021 21:50:12 +0200 Message-Id: <20210826195014.2180369-10-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.129.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" To simplify qemu_vfio_dma_map(): - reduce 'ret' (returned value) scope by returning errno directly, - remove the goto 'out' label. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Klaus Jensen --- util/vfio-helpers.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index 7de5081dbd3..48b4384e8c8 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -750,7 +750,6 @@ static bool qemu_vfio_water_mark_reached(QEMUVFIOState *s, size_t size, int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, size_t size, bool temporary, uint64_t *iova, Error **errp) { - int ret = 0; int index; IOVAMapping *mapping; uint64_t iova0; @@ -763,32 +762,31 @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, size_t size, if (mapping) { iova0 = mapping->iova + ((uint8_t *)host - (uint8_t *)mapping->host); } else { + int ret; + if (qemu_vfio_water_mark_reached(s, size, errp)) { - ret = -ENOMEM; - goto out; + return -ENOMEM; } if (!temporary) { if (qemu_vfio_find_fixed_iova(s, size, &iova0, errp) < 0) { - ret = -ENOMEM; - goto out; + return -ENOMEM; } mapping = qemu_vfio_add_mapping(s, host, size, index + 1, iova0); assert(qemu_vfio_verify_mappings(s)); ret = qemu_vfio_do_mapping(s, host, size, iova0); - if (ret) { + if (ret < 0) { qemu_vfio_undo_mapping(s, mapping, NULL); - goto out; + return ret; } qemu_vfio_dump_mappings(s); } else { if (qemu_vfio_find_temp_iova(s, size, &iova0, errp)) { - ret = -ENOMEM; - goto out; + return -ENOMEM; } ret = qemu_vfio_do_mapping(s, host, size, iova0); - if (ret) { - goto out; + if (ret < 0) { + return ret; } } } @@ -796,8 +794,7 @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, size_t size, if (iova) { *iova = iova0; } -out: - return ret; + return 0; } /* Reset the high watermark and free all "temporary" mappings. */ From patchwork Thu Aug 26 19:50:13 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: 1521330 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=gMRidvcn; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4GwYZs4028z9sW4 for ; Fri, 27 Aug 2021 05:59:17 +1000 (AEST) Received: from localhost ([::1]:46278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJLWt-0005Jm-BN for incoming@patchwork.ozlabs.org; Thu, 26 Aug 2021 15:59:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49458) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJLP4-000648-KU for qemu-devel@nongnu.org; Thu, 26 Aug 2021 15:51:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44000) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJLP2-0003Mj-5S for qemu-devel@nongnu.org; Thu, 26 Aug 2021 15:51:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630007465; 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=bIzUg2n6cWwWuyxJa1hqTDlzAZlGw1TJMvDOruqrhIU=; b=gMRidvcnLTNxILEOGBIwcnFV4+cfOI/QMus2jRP5njxl1o1x3UfCY6GFCdiDqEXLhCB/aM vy1rUBNK/OGT6umR+zsBiENfEgmFiyJJ7Rt8IaDEPjbE6Hsx9cZNtfADuLh8rh3vejcF8h 4hj5QY02HqlWqeDCRewqZjVF0T8DJDQ= 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-374-5r6s8bnkNfCRPnNtDJSdkg-1; Thu, 26 Aug 2021 15:51:04 -0400 X-MC-Unique: 5r6s8bnkNfCRPnNtDJSdkg-1 Received: by mail-wr1-f72.google.com with SMTP id p1-20020adfcc81000000b001576cccf12cso1214877wrj.6 for ; Thu, 26 Aug 2021 12:51:01 -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=bIzUg2n6cWwWuyxJa1hqTDlzAZlGw1TJMvDOruqrhIU=; b=APIhWluheJC0gzUC6kYAlYli/FJ1riiqGMmrw2LjLV9+c0bEoXHHaFOWcpq20PP+DV bDD6Yb0rbsSdZ2xXLQA/L1mlahCvfRmPW3RWib/4Uvu6qCfvomF8ykr4S06KiDLiO4KS eews2Ir5eoIfEof2gKpKBPbqdbOjg7DKrO/NpnoAg/TRgSc7CJ2XcBZkFjnbvbIUvePc MLKsT/ObNn5vWwmcrbR2ITVbrTgYHq/ERo8TA7jvJTG59VCe/r8mPmMFnvdlxZ534+Is Mjz36J3PzhKAolLpM6fJAq3NmuuT43eXnflZtD9J2W3/M4OscrUt/Cqh7kxTjfQ3pMoZ dQ7Q== X-Gm-Message-State: AOAM530sEw+cvH/bFRf6lDYTsCiI2a09w17+AP5SfsQz6E++k18P/W3w mmK1vxd1N+nTzcBxwl4J4LSzNJX5o8J82ibasSghat4eoknirL5ct2C/MGYktplb8bzqQDR2jYg cpDOd1B5dyGwKVO6qm/P9cc5LJaEHPf7GM66UQjI2a1Nved9GY7HkASRytCY7d6da X-Received: by 2002:adf:e449:: with SMTP id t9mr5856714wrm.135.1630007460281; Thu, 26 Aug 2021 12:51:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypfB0khH35T8LBtMh71Lwudql1ndIwhOb+rF6A0wR8+745Q2L5H/jEZtVH9bG+6Nl4wPnv/Q== X-Received: by 2002:adf:e449:: with SMTP id t9mr5856688wrm.135.1630007460069; Thu, 26 Aug 2021 12:51:00 -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 p13sm4146951wro.8.2021.08.26.12.50.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 12:50:59 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 10/11] util/vfio-helpers: Let qemu_vfio_do_mapping() propagate Error Date: Thu, 26 Aug 2021 21:50:13 +0200 Message-Id: <20210826195014.2180369-11-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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Pass qemu_vfio_do_mapping() an Error* argument so it can propagate any error to callers. Replace error_report() which only report to the monitor by the more generic error_setg_errno(). Reviewed-by: Fam Zheng Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Klaus Jensen --- util/vfio-helpers.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index 48b4384e8c8..0c011b3dbc8 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -610,7 +610,7 @@ static IOVAMapping *qemu_vfio_add_mapping(QEMUVFIOState *s, /* Do the DMA mapping with VFIO. */ static int qemu_vfio_do_mapping(QEMUVFIOState *s, void *host, size_t size, - uint64_t iova) + uint64_t iova, Error **errp) { struct vfio_iommu_type1_dma_map dma_map = { .argsz = sizeof(dma_map), @@ -622,7 +622,7 @@ static int qemu_vfio_do_mapping(QEMUVFIOState *s, void *host, size_t size, trace_qemu_vfio_do_mapping(s, host, iova, size); if (ioctl(s->container, VFIO_IOMMU_MAP_DMA, &dma_map)) { - error_report("VFIO_MAP_DMA failed: %s", strerror(errno)); + error_setg_errno(errp, errno, "VFIO_MAP_DMA failed"); return -errno; } return 0; @@ -774,7 +774,7 @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, size_t size, mapping = qemu_vfio_add_mapping(s, host, size, index + 1, iova0); assert(qemu_vfio_verify_mappings(s)); - ret = qemu_vfio_do_mapping(s, host, size, iova0); + ret = qemu_vfio_do_mapping(s, host, size, iova0, errp); if (ret < 0) { qemu_vfio_undo_mapping(s, mapping, NULL); return ret; @@ -784,7 +784,7 @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, size_t size, if (qemu_vfio_find_temp_iova(s, size, &iova0, errp)) { return -ENOMEM; } - ret = qemu_vfio_do_mapping(s, host, size, iova0); + ret = qemu_vfio_do_mapping(s, host, size, iova0, errp); if (ret < 0) { return ret; } From patchwork Thu Aug 26 19:50:14 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: 1521327 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=KO1r4c0L; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4GwYXV1Wrmz9sVw for ; Fri, 27 Aug 2021 05:57:14 +1000 (AEST) Received: from localhost ([::1]:39262 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJLUt-0000fp-Vk for incoming@patchwork.ozlabs.org; Thu, 26 Aug 2021 15:57:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49470) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJLP5-00066e-Q1 for qemu-devel@nongnu.org; Thu, 26 Aug 2021 15:51:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:47513) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJLP4-0003Qn-48 for qemu-devel@nongnu.org; Thu, 26 Aug 2021 15:51:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630007469; 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=ojj+ZaFHzvapR5Yklu/beV4VWQwhlVBhI7TMjzFMewk=; b=KO1r4c0L61+A6h1y63AbLja0lFoTOzGONYVi3D0GFmxqcGVUvg/Cye6ZH5VQIBR1Irs8LW jFs9TVKDwkaAxKBKLLSqi6OihTZo832bOVJBzzrpfB3mAgp61hU+C5XwTit/CDJqTUcNm5 h85vu8rOP6A3jeQSFx+QDaEIG2h/X1Y= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-133-7u7YnMPVPlSSxsbTNVlDuA-1; Thu, 26 Aug 2021 15:51:06 -0400 X-MC-Unique: 7u7YnMPVPlSSxsbTNVlDuA-1 Received: by mail-wm1-f70.google.com with SMTP id c4-20020a1c9a04000000b002e864b7edd1so1272581wme.6 for ; Thu, 26 Aug 2021 12:51:06 -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=ojj+ZaFHzvapR5Yklu/beV4VWQwhlVBhI7TMjzFMewk=; b=MMT7YHp8lpqhFwqPlL9IenVDtry1HZ+d5BLTugjQ9opky9NBcoj2TtlzJvfAgR+LbT sE8UrnMLS9V148rVKxiJfUzfCrKmI+5+k12KSiWpawZpqwRVJra3oXsdkHJOoOjPUiKJ Bwv2DoJgYZeT6Hpfjv6mHirGo8+OHfSnK7hRSttfvbYeCrDK618qQk2Xr/ntF9y7mUPd O92cSwOkcyzP93qUkBD2Ysbs55t1ZQQDF9x2P+1xc1zce6z5hl+iRkoRkFuno3IIz7ER 91Wg96azoNgHQUDItuD+zh2IoGmuTAfsIhWixvf6y/z8F02HUoBdHDVUKYXbv4zcDr7/ bchQ== X-Gm-Message-State: AOAM531qF9CxnYCl/SbiTA0Pc62A+xVnjKjnRkBhzBOtWRleNtVkA5ej 8rxIdsax+0yslemq+XeZtUKeFrt6za+xvqIOAOir10snAnsP+DiaHMpq0mv+FH1PxmYZYt9l+eM OHvBlZ5T6u4mXu85Z2K5kLRFIXb+F0k4fWDinEL90e+hWUORkhwxYGdkwWt8NrFPK X-Received: by 2002:adf:cd10:: with SMTP id w16mr6241784wrm.404.1630007464861; Thu, 26 Aug 2021 12:51:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjO3MWn5XqzJXC8a9xrkH5+1XNA08ELP3LEdYLLAhn9/odMsvXYAepVGX+0yMy92TKIe9uig== X-Received: by 2002:adf:cd10:: with SMTP id w16mr6241756wrm.404.1630007464640; Thu, 26 Aug 2021 12:51:04 -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 l26sm80749wmi.13.2021.08.26.12.51.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 12:51:04 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 11/11] block/nvme: Only report VFIO error on failed retry Date: Thu, 26 Aug 2021 21:50:14 +0200 Message-Id: <20210826195014.2180369-12-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=unavailable 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, Tingting Mao , Klaus Jensen , Auger Eric , Hanna Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" We expect the first qemu_vfio_dma_map() to fail (indicating DMA mappings exhaustion, see commit 15a730e7a3a). Do not report the first failure as error, since we are going to flush the mappings and retry. This removes spurious error message displayed on the monitor: (qemu) c (qemu) qemu-kvm: VFIO_MAP_DMA failed: No space left on device (qemu) info status VM status: running Reported-by: Tingting Mao Reviewed-by: Klaus Jensen Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/block/nvme.c b/block/nvme.c index 80546b0babd..abfe305baf2 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -1019,6 +1019,7 @@ static coroutine_fn int nvme_cmd_map_qiov(BlockDriverState *bs, NvmeCmd *cmd, uint64_t *pagelist = req->prp_list_page; int i, j, r; int entries = 0; + Error *local_err = NULL, **errp = NULL; assert(qiov->size); assert(QEMU_IS_ALIGNED(qiov->size, s->page_size)); @@ -1031,7 +1032,7 @@ static coroutine_fn int nvme_cmd_map_qiov(BlockDriverState *bs, NvmeCmd *cmd, try_map: r = qemu_vfio_dma_map(s->vfio, qiov->iov[i].iov_base, - len, true, &iova, NULL); + len, true, &iova, errp); if (r == -ENOSPC) { /* * In addition to the -ENOMEM error, the VFIO_IOMMU_MAP_DMA @@ -1066,6 +1067,8 @@ try_map: goto fail; } } + errp = &local_err; + goto try_map; } if (r) { @@ -1109,6 +1112,9 @@ fail: * because they are already mapped before calling this function; for * temporary mappings, a later nvme_cmd_(un)map_qiov will reclaim by * calling qemu_vfio_dma_reset_temporary when necessary. */ + if (local_err) { + error_reportf_err(local_err, "Cannot map buffer for DMA: "); + } return r; }