From nobody Thu May 2 02:43:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1630007426; cv=none; d=zohomail.com; s=zohoarc; b=aI7tJvDvlf/7hhCAHtsk9utZLvcExJpguqv4Ylv0oUbebg23ny71Ac6ZW9xH0fVfquXj4R6MJHtb/SL+atZkjQxHHpwQhptOfG/UBqj6WKjaK+aPdqoyy9TBsWEwYYAix+n530AKjcUpH/ZBKBcYWZQaiIZOFE7hUOtV+3h+KRs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630007426; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=DPW4a8fAJ5aQIhBkKgFcCQAwlhPjH6NHU1IvtDHYfFc=; b=GOibKgTMgz8ZPi6QGQcGEAe7UiJ6aOZDvc9nf+0nzZ9u+t08zvuXLwMUGMCSmnNKOlTsX1tKc1zC0vtppRTuLABm07xmQevwXwF9FekGnWo0TR6eH0+Xpl6yIGJFpqQcaPyLaW+xGFQE1n3xMGdJF6kwjBxAhiUPTAn6i1gWBuo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1630007426163612.6480484426962; Thu, 26 Aug 2021 12:50:26 -0700 (PDT) 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-535-UEilR8-WNLyTNLNm2C3y4w-1; Thu, 26 Aug 2021 15:50:22 -0400 Received: by mail-wm1-f69.google.com with SMTP id x125-20020a1c3183000000b002e73f079eefso3458618wmx.0 for ; Thu, 26 Aug 2021 12:50:21 -0700 (PDT) Return-Path: Return-Path: 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630007425; 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=iBe0lMwRsJ2IJBY1kinXlmNruC0GFjPqe0nslp+78HEs5wMIHrJ3bBrWnqGUYLgRPaF5LI sj1wSijG6pTm8dBBkZ5EeZo8kdswqkSV39Tdt45+oQIb7SVIYUgU/dXyQcGxDIMB0w+Kpz 9tHNXD9/WsW56rrjnW3CgVzHTk8M4mA= X-MC-Unique: UEilR8-WNLyTNLNm2C3y4w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DPW4a8fAJ5aQIhBkKgFcCQAwlhPjH6NHU1IvtDHYfFc=; b=GIuNcG0PlSUE2GRJlHTixBImltswPWXZ3tfez9SAZ/V5dfnO7c4B1pKPi7ZtqZzbYN SnJ8a8Sg5cU3/vwfZJ1SMEKCSnMldVmMaG3KD8ycV+P52tGvVVoAjwGLfT1jcHxvSaA5 k7Lq3xKNv6pLsStaHWOfTNi7BLoALznr7hbk2RO3y1yoCIyeHGbs/7+IM69bpFMjsXKw 1PWQltj8VnbrmySIKfkAZ5zYEEYq6YKXUO+UxG13z/px3C1ROoROqBeSnLJewRdjFN9+ KwW2kupYJAHu/MOMwiHAdzU7ACualdbtExcYCwMPFLmKk8QE2xxhlGO3Cf8gesxVBagB e6Jg== X-Gm-Message-State: AOAM530ymDhPf3uSpHU/+sviksNnGYl8IB4nLrSk0pF3OFTontLcU70r MfstCtElblggnFwnmdJQROZZlaiiEanZDHtVrlrl0YBNC/vU5YUe9ummf3CanZBcZiYsDqJ3bsV PyhEjhUy52Q75Pg== X-Received: by 2002:adf:fcc5:: with SMTP id f5mr6147560wrs.114.1630007420842; 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Hanna Reitz , Klaus Jensen , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi , Auger Eric 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1630007427586100001 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=C3=A9 --- 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 off= set 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_c= ontext, 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 --=20 2.31.1 From nobody Thu May 2 02:43:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1630007428; cv=none; d=zohomail.com; s=zohoarc; b=AVrkg1NrGC5ANv44SAfABjfHKrIju6YHReP/VfWFdLVNUbsOVRjV8uzBYYnCx5kJJQiO8ZdD0/q3DsvlHgTSaiF4Y8UPsJ3IxWXNq14EXnKm+BFtShNSRkwYJwCbEDeTfaTSD4SCBm+t8qkp1gs63CjdLLOfx8mLC7rzB6Gs1r4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630007428; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=rai7h32TrTkDK/wiLtMpSewodwbvjWhnx25D5kPSBpM=; b=QPWW+pcb9x73eg8nJVrWKWcFbw61U1hZIwscrx1gX3rEN1/WfkoNnZR4cdUpirnIiLmTaYNLd6UUXJtZAA5NTZKcSYvWKgTCE77zcTwnXtPVDuEUjMG6NP6/6EDlKYQFj105dBdL9K0carKE4TKw42rONkSoc3yhA9AzG1WregQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1630007428567583.4424689799523; Thu, 26 Aug 2021 12:50:28 -0700 (PDT) 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-247-Ht7Y7qVPNWq-BMpzNabNBw-1; Thu, 26 Aug 2021 15:50:26 -0400 Received: by mail-wm1-f70.google.com with SMTP id k5-20020a7bc3050000b02901e081f69d80so1272298wmj.8 for ; Thu, 26 Aug 2021 12:50:26 -0700 (PDT) Return-Path: Return-Path: 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) 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= X-MC-Unique: Ht7Y7qVPNWq-BMpzNabNBw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rai7h32TrTkDK/wiLtMpSewodwbvjWhnx25D5kPSBpM=; b=Gq8VxWOgu9yEASKKAVx8JBgV2qzhmI8AFWDvGPdXEoM9E0fJoMQm8HXVClFt+j6SZS AReT8fwITYk9+TWY631s2MFI6VjVxz4ON0j/1yF8vsegca2A8J8o4/jWfrkFc08lvk9Y QYQlnj3cYKUOfvWRSXUiqZqRnWkPs7zaHzVN/hj7ANca4+KCmi4fdyJMpbf7Mo3MZVGA GoY+ajCBXIx6oAqNyWXQUe1tzGU49dIP1EY73u0gNRfBdyvAFtPL6D8xe/q6/Lc/5wco ZfHKrmlBDprwaUi+/PAtkHSgTY2Btpr84wO6qiY4oFmuYn2UwkzZU3btKFWJvsj/hQrW trYg== X-Gm-Message-State: AOAM532DdRMRZZTRn35SxTFwpgBMOvssosFYmPk5M8T66GotzCRJcrfq rlEPiVovFwkmAuGUv5rMRPxgt19/tNSTSPSUWC1eZkWXGXeKM9b3KONUmzELg2ti85DJRuHsXJi /0UcqfodFtEXioQ== X-Received: by 2002:a1c:210a:: with SMTP id h10mr7971659wmh.117.1630007425249; 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Hanna Reitz , Klaus Jensen , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi , Auger Eric 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1630007429855100001 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=C3=A9 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 =3D 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 <=3D 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; } --=20 2.31.1 From nobody Thu May 2 02:43:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1630007435; cv=none; d=zohomail.com; s=zohoarc; b=HYuMqqlc32kCFSTJfrDRsvm7ST8jxn8UlMIppbq0K9FdOsdcRPev+X1/2L4ExOBucz1I2F2VbHZSeKG2T4DqX2X6DePtDqoP60kGu1842ZHiENLkmyPFDeTp0udgFxMRyGK7QuOCaOshIX/nopFuDW0YPXDvlgeOoaDxIPHXwcA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630007435; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=2lm4MltjciLe1FvPMjz8J1KaGtyzlphex4Ajbbc6qJo=; b=BLUXN20BzQb65Tw0XnXxFwIHnX33CB3JX+3UEsxfFO14gVQ/8vbaJCEDTur9i0d1fHkquOMTpPmmaI2cjitKMUP5upWnBN5HCTKfuH6kGhr3Q5wXUJARsuOpkFJ89hv1nBHCH1J3ABMetaxnioNKKWihR0jcc0mZiCx+XRRKnVs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 16300074352964.888137769732907; Thu, 26 Aug 2021 12:50:35 -0700 (PDT) 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-334-GS6mS5L5O_a1F9fS6xXHaw-1; Thu, 26 Aug 2021 15:50:30 -0400 Received: by mail-wr1-f70.google.com with SMTP id b7-20020a5d4d87000000b001575d1053d2so1187771wru.23 for ; Thu, 26 Aug 2021 12:50:30 -0700 (PDT) Return-Path: Return-Path: 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630007434; 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=JeTZiWZfHl1rROcUHR3xwAzHbe/kB6t0gHaqBOFdu8GB0DbZo+m1yHKv/xu7/Ti9abLkLF j4ONI3oQdIWQdH42lqwPFEUFeO9mYJfsQrQ+zjEiad7RloOwkStGBWaCeaDUQ6CEVcuJn/ fwQAwSf0X/x7Mq/nrX7Od7prVimdMWo= X-MC-Unique: GS6mS5L5O_a1F9fS6xXHaw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2lm4MltjciLe1FvPMjz8J1KaGtyzlphex4Ajbbc6qJo=; b=TqQ2ttyFCqU/UzMkq4He9Fo+hR48veUd+M41ZGuFd9ORD8VEy6ykQhMLiAZe7ggWh8 +h85Kzopp2KhOQ6bCPQ+yyBytrZrqsLutoICklTHAbYDjkcHctlCSd02wp6VQ3OMs8LK 6k2ggIyiHVstaTtkMTEzQZbLqp/+BCj6S0w2GVWWdGaZWrsSkv/Gi9XJV0hFR98kCCOI 7PrB0+sXjWaX14O7hVtAkZJTP63GeLROwhDEhCrowyJj3tAosKdt7VZnhMYbgQsDL789 3uoMF8emM17JkJpDCziZpWEVj00ZbxbV8SF7O7bQ4xuXTSeBQCIwqk9E0mUAl4O0iKNa +3oA== X-Gm-Message-State: AOAM5306O+rbM6vc0/i9jrjwSugd/tCb6WJ970QSofFzijWuQIbAag5k Lf3PvLC8y1L1MtkGGZ/NP22R8TvX32b5GaSsaoUDevZ0bDP7bN09WkVZtWx1uD1/Lc3+l7UEnCr bl2h0KPws9NgVJQ== X-Received: by 2002:a1c:29c3:: with SMTP id p186mr5259850wmp.22.1630007429678; 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Hanna Reitz , Klaus Jensen , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi , Auger Eric 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1630007436443100001 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=C3=A9 --- 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, siz= e_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 =3D qemu_vfio_find_mapping(s, host, &index); if (mapping) { iova0 =3D mapping->iova + ((uint8_t *)host - (uint8_t *)mapping->h= ost); @@ -778,7 +778,6 @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, siz= e_t size, *iova =3D iova0; } out: - qemu_mutex_unlock(&s->lock); return ret; } =20 @@ -813,14 +812,12 @@ void qemu_vfio_dma_unmap(QEMUVFIOState *s, void *host) } =20 trace_qemu_vfio_dma_unmap(s, host); - qemu_mutex_lock(&s->lock); + QEMU_LOCK_GUARD(&s->lock); m =3D 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); } =20 static void qemu_vfio_reset(QEMUVFIOState *s) --=20 2.31.1 From nobody Thu May 2 02:43:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1630007437; cv=none; d=zohomail.com; s=zohoarc; b=TdVh7VwB7UGLwAWF1JmOa5QoaLkb33Hu9EyeIpn5v+QhEmYXokBjaJTYWVL3aaYQuyedzRPGYp421XbiEuEw3PXXVmOf+4Oo5EykosoWceYM5nf+M0qvwTj8EZSobcL+wgI/04NW9GUeNznnd/1m5jTfHL0XGDhA/k+Tp1ipr8U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630007437; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=CPZfczG2XQrRC55s69h86ljHzGci8wjhwO3c1XD3j8g=; b=ZWi54odOCCHTFMgx2WTTi1wPAIBIkPykcm7R9w+sad33Ot4POXMtp2G/j0H6KmAdwU/cJbea68/EIudi8yT2gPV2J9x8UaJqrRvD4M3f4mB2Eo0Pyz+I0NjBQDvTag7rvo/wlSMTSWmIysd/Bs9r8DaiENekEMjwu056Au+HuV0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1630007437519846.7524105756981; Thu, 26 Aug 2021 12:50:37 -0700 (PDT) Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-401-dU2sNudcMhq3_IuojlNMzA-1; Thu, 26 Aug 2021 15:50:35 -0400 Received: by mail-wm1-f71.google.com with SMTP id p5-20020a7bcc85000000b002e7563efc4cso1133643wma.4 for ; Thu, 26 Aug 2021 12:50:35 -0700 (PDT) Return-Path: Return-Path: 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630007436; 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=ep4GcBIbHbypnP1/7OG2YW3sS8ewRRhyfMpLWpfG6wl2F//NLg0urvfofPlt3SAGW8roj1 vkaaqhshyy+UX2tCBP8pv7QL/XJcbCT/qXtK+P/4blLI5wylMwMGPCjdnRUJeMA0p/Uxlc ohoOWE8Qpu7L9x6f42rt07iTc/9ZMVk= X-MC-Unique: dU2sNudcMhq3_IuojlNMzA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CPZfczG2XQrRC55s69h86ljHzGci8wjhwO3c1XD3j8g=; b=r5b6Hi8IVNu9Y35Vu++9M62mzw3pNOCKpWX+tK9m7IIhX9I/aHWE5DCbFFCJzwv3HR cj7XVmGFVjPQFmTcPwF9wZ+gkaKlwWtxFIEXxXHBDlpU4A80n2AQ0I4YfoavqTP9OuYe QeXNRjQwGgQf6y/gFCGPMF84Md0QAqZUCAAwGw6OcA691xePvyjos3eGdRdVOPf1JAPq HNaDK3tfa1oUHeaKjMxYiSVt6k+bC5n57HuxkbiAH2RpHaohAKRIEOkhbNvTsrAwgn8u 8fjp0zFPNbZOKlmUvAfSFhFZEiq7V7JqPMs4lPYxvRIZCXTPKswqkIL5CtIoTT/mMlLQ 7iCg== X-Gm-Message-State: AOAM530jJTt3N+vQdMY88gWAA/j7at0sZUhfcppBYDPJ+vl0nZoq0ZA4 DxKnHB99QoBFueC5KMawHqhRvk0fzEtgYdUbuE8N0SpwDvPC78oOwzbuOiX/YDaE6PMC5hgklcw ntz5DGPBrbO5PZg== X-Received: by 2002:adf:edcf:: with SMTP id v15mr6037107wro.61.1630007434077; 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Hanna Reitz , Klaus Jensen , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi , Auger Eric 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1630007438992100001 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=C3=A9 --- 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, si= ze_t size, } =20 mapping =3D qemu_vfio_add_mapping(s, host, size, index + 1, io= va0); - if (!mapping) { - ret =3D -ENOMEM; - goto out; - } assert(qemu_vfio_verify_mappings(s)); ret =3D qemu_vfio_do_mapping(s, host, size, iova0); if (ret) { --=20 2.31.1 From nobody Thu May 2 02:43:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1630007442; cv=none; d=zohomail.com; s=zohoarc; b=grF+D4mx1uU9SQlWxKanpBAK2HBouWJMzpGSe+gy74K4IaEmLIbXzkJJW5pfUjduyuV4XdaJQxgR1M9uM5/KS75IQZjOiFE+iLuuwptZVqfOzLzGfZK1b7NSkeZLzqbqC0Isz3UDmMt/iaWSXo2Io2tzi4cg3YNzMFduBNpirp0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630007442; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=5UH5gTXKqeTJNaOUfTO6KDAq9dp4eTnytqWl3CBLEdg=; b=bFt+6oWlQ/AFxXO/DDwfj3le4CbIqY5N4MqNl4HgIj5XBHSGR+UH8QjZ28WF2PdAZIPMsmGfzb/4adSyi+bUKV9lT4fqaPfC/48dVcE5Ra6s04MJ+9RScqkd8VuSszmogZoXkKnr6XDLK3+9nvtyZ6oVA+NktN0S+cBwBEAA720= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1630007442182292.435742052704; Thu, 26 Aug 2021 12:50:42 -0700 (PDT) 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-212-M5h9E3WvPN2Vv3Ol9hDnKA-1; Thu, 26 Aug 2021 15:50:39 -0400 Received: by mail-wm1-f69.google.com with SMTP id g3-20020a1c2003000000b002e751c4f439so4766074wmg.7 for ; Thu, 26 Aug 2021 12:50:39 -0700 (PDT) Return-Path: Return-Path: 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630007440; 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=QVIIlE/3c9tH/Ffa4YlIVJTCvPW+V3S/njuOwZVLOwFcuZivTUU4oGfFEJ7WfYEjxUBEnZ IEwhqoV2vFhyEu0cIrDXC04h1HeVBJ8oIPMwzzL/6uHpCcgATka8uPLV9A2k4ZPj8xZGol gwUEIV9NeQnI2UMbg4k3S0ahjegu7Vo= X-MC-Unique: M5h9E3WvPN2Vv3Ol9hDnKA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5UH5gTXKqeTJNaOUfTO6KDAq9dp4eTnytqWl3CBLEdg=; b=ZZRcF6rMkXtElL8E9aLjd1VKbB4SFiGzo/MH7xRxmsMkz2dWYec+X2vTVrttSKzXg5 RBLBxwaRv1LnDJb8J0BIXVuIKj+nnuCuzhh7/dwUxhI0Zpu4kjDgNJl65y488aj15wY3 A2BBHtxh8ImLA4vExhp4yPCU6I+RBa/luPiXsVxvRTa05goOQOHUptsiAVGQG9aHsCgF lUP08jtkQGtsMxRPAIdlRhugUF5IMjlPxbJvB7iR8C7RvUbuhT535dwZ1VSFwiQfuqh/ PpODnreomdppHFYc7ppbtMkDz2ew2ofp5LeeAlg4xQlcZ0yTMnvw+uRhwRrS0Qs7ar/O bvrw== X-Gm-Message-State: AOAM532r9/BXCOfCShhGDTE5NS9n+PBUizyHDmzGBhCkWeLfMS8PLPvr PIXxXkGtuKzQ7w4+0DF2GlXTDpYxmAbLNi8DvB4Q0RYcX5K7CJCvfiBbecp7fTv317sgFxdGeKF qIDETVBFDxF3YQw== X-Received: by 2002:a1c:a78a:: with SMTP id q132mr5286213wme.91.1630007438274; 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Hanna Reitz , Klaus Jensen , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi , Auger Eric 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1630007443441100001 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=C3=A9 --- 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(BDRVNVMeSt= ate *s, =20 q =3D 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(BDRVNVMeSt= ate *s, qemu_real_host_page_size); q->prp_list_pages =3D qemu_try_memalign(qemu_real_host_page_size, byte= s); 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(BDRVNVMeSt= ate *s, r =3D 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 =3D -1; --=20 2.31.1 From nobody Thu May 2 02:43:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1630007446; cv=none; d=zohomail.com; s=zohoarc; b=ekzHGG3f+EFLl+/xQXTQrjnrQymV9p4fJsPUC2pAWVe7v+GpdZF5gZhB+ABInNODO3WUoE9lPE0fTp3KM0GA7ShjMQR8DHt3VNzePPVgmByvztshR2uv70hsQaSMgo2OwSvNazZvBUB0HMk4PmWmQo2k7Wa2Jphq4v+5xTv+MMs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630007446; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=wNKmqePd9nD6kB4TAflUms7TAcM03nxgZUc5G0laZ78=; b=gESOaMjVJ9L7lWOLi6F2RVvpaau+QuJye1gU9uy+Z5mqK/4UCUPT+iURCLLh0Awfql1mjlgme4OnL27PQ4luzKPzPFuRxp9PxPy8NHD7p/m8k6eBj4ENLRmQQMCEenV7aU6SNZfiOnThtNhNUorGw5EpDxdglahQp1SuRacvw7o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1630007446378794.0496817301978; Thu, 26 Aug 2021 12:50:46 -0700 (PDT) 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-427-dt7SYH1JPs6iUjE0STIRJQ-1; Thu, 26 Aug 2021 15:50:44 -0400 Received: by mail-wr1-f69.google.com with SMTP id b8-20020a5d5508000000b001574e8e9237so1203731wrv.16 for ; Thu, 26 Aug 2021 12:50:43 -0700 (PDT) Return-Path: Return-Path: 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) 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= X-MC-Unique: dt7SYH1JPs6iUjE0STIRJQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wNKmqePd9nD6kB4TAflUms7TAcM03nxgZUc5G0laZ78=; b=oCYPr3pV4srHQ/JsrPVodZCSRxFyqIDMMkm6nNi3XaCc4mC0A3VggyarqEJCS+hcEf SflBTF7HPONnkeuZcr8npCagC0V2Csyi3cGO5egGIMsK3m+2CB/orQ9hexk5Lq18lnrw q2MIsPGl7psF4cTX+qBKbZ/gGhmuDXCfSlo5nPPzGSwzQ8aIK7Nmpxi0uBHIP2lsVZGc WDRAsnHYzCOUYJERciN/3HodRK9209BaNYxzFlp1MKCaIIpCcjJNJ7WWqh9rKTku48Qp xpQzLGq3LuJAapehYaaHEHQVE7X6Ur9GaTfK8/wnS1/uXMopdPSBHTSERwH6w11aylz8 wAvw== X-Gm-Message-State: AOAM532SMMoTqOdUGWBba6LEmhKY8zky4VzGSMHeVpyrbczzDvdUAqGI BrXbYM9sDjt+jYz7iOUSpeHrnnawajt7C4EdtdkLYaL95LJZfeuwsU0MCN2kHvbP79fa1VJU7CZ ULUvjbjyJa+sFHg== X-Received: by 2002:a1c:20d7:: with SMTP id g206mr16487946wmg.153.1630007442851; 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Hanna Reitz , Klaus Jensen , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi , Auger Eric 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1630007447545100001 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=C3=A9 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, NVMeQue= ue *q, return false; } memset(q->queue, 0, bytes); - r =3D qemu_vfio_dma_map(s->vfio, q->queue, bytes, false, &q->iova); + r =3D qemu_vfio_dma_map(s->vfio, q->queue, bytes, false, &q->iova, err= p); if (r) { - error_setg(errp, "Cannot map queue"); - return false; + error_prepend(errp, "Cannot map queue: "); } - return true; + return r =3D=3D 0; } =20 static void nvme_free_queue_pair(NVMeQueuePair *q) @@ -239,9 +238,9 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeSt= ate *s, qemu_co_queue_init(&q->free_req_queue); q->completion_bh =3D aio_bh_new(aio_context, nvme_process_completion_b= h, q); r =3D 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 =3D -1; @@ -534,9 +533,9 @@ static bool nvme_identify(BlockDriverState *bs, int nam= espace, Error **errp) error_setg(errp, "Cannot allocate buffer for identify response"); goto out; } - r =3D qemu_vfio_dma_map(s->vfio, id, id_size, true, &iova); + r =3D 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; } =20 @@ -1032,7 +1031,7 @@ static coroutine_fn int nvme_cmd_map_qiov(BlockDriver= State *bs, NvmeCmd *cmd, try_map: r =3D qemu_vfio_dma_map(s->vfio, qiov->iov[i].iov_base, - len, true, &iova); + len, true, &iova, NULL); if (r =3D=3D -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 siz= e) { int ret; + Error *local_err =3D NULL; BDRVNVMeState *s =3D bs->opaque; =20 - ret =3D qemu_vfio_dma_map(s->vfio, host, size, false, NULL); + ret =3D 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_un= map * 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: "); } } =20 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(RAMBlockNotifie= r *n, void *host, size_t size, size_t max_size) { QEMUVFIOState *s =3D container_of(n, QEMUVFIOState, ram_notifier); + Error *local_err =3D NULL; int ret; =20 trace_qemu_vfio_ram_block_added(s, host, max_size); - ret =3D qemu_vfio_dma_map(s, host, max_size, false, NULL); + ret =3D 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_si= ze, - strerror(-ret)); + error_reportf_err(local_err, + "qemu_vfio_dma_map(%p, %zu) failed: ", + host, max_size); } } =20 @@ -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 =3D 0; int index; --=20 2.31.1 From nobody Thu May 2 02:43:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1630007450; cv=none; d=zohomail.com; s=zohoarc; b=bBAisQJL93s0D7Sv6MosUy52mT1rU+cpE6HeF6r1rG+o0iScnIFz0/2nGAmV0arZ+v3DEsG37oi5ekgTzMM4ZhUthb/M/Fneg1z8tAQAyy8yXX+BqVUXfCxwTi97FtXm1sc5H8PVkjJ07YBfBY4ZwwAWSpAEQrGnj3HtqbYQyDs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630007450; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=yPAeN1ELfe7bdUEPxcVE2xQF9fAx3P6/HJ2p3gjANPc=; b=KnZG3FglFv+iqqLYmKMNgjbYqw3MypUKSzp8xfkZsZiJiQabagJsuNxAqmXaJWpfMroO7m8ZBviKtRfAJSDkjkJrLD+EFMzl7Hgl2bTF39NUDEwhYGkOXZnEztcHhu1Cc4Wxvo4oTEje2Z2F+RbQFQl0vTQN/4Kg4rnAcEWrpNo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1630007450691183.4502313704221; Thu, 26 Aug 2021 12:50:50 -0700 (PDT) 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-14--rTt13XFPIKfiDjzjz2ykQ-1; Thu, 26 Aug 2021 15:50:48 -0400 Received: by mail-wr1-f69.google.com with SMTP id r17-20020adfda510000b02901526f76d738so1230361wrl.0 for ; Thu, 26 Aug 2021 12:50:48 -0700 (PDT) Return-Path: Return-Path: 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) 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= X-MC-Unique: -rTt13XFPIKfiDjzjz2ykQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yPAeN1ELfe7bdUEPxcVE2xQF9fAx3P6/HJ2p3gjANPc=; b=g6dSW7B2Vd8y2XlbaA8qkKwJIfz3et/uPCMcElcXofidArYMNPSPo4SRBhIojK/M5z RLu8dpr5x75F9/fahZxE9eRXicrxchYe86EaQ9JekadzlU2zRunawEjsGZZ8ViM+2UuO m4/XtUNdyx4eLSbXeElOhMYmIFxg94kWAG5BWqtI9WpZ1+qsDOlbJ+6rD4KD0bRfGRPt wzTKSnqi0VnSY3vFefIUL6QD3K1R+HkozxUfrInDRT8YFdycE3hDfJ3ZuKkxE9aq9HPL 2vkeIJKjiwSdIkZ9Sc6lq7u8IqMz+l9SINCG1GsDUs/dU8pKudA8OFaXAN6ISUx93GjH KRGA== X-Gm-Message-State: AOAM5308ddF4w6be4ynMEIrLy8dQVIgYdiuiJgksBAVYBRqyQ1q6bzik qYj0HoQaT5vh/aiK644IIapHVNhsXT2nXdC8ml1gh2yqq5voApPyPmO86r0rtJd41ZCUBZHzEwt YfbeR2oU0SiT8Ww== X-Received: by 2002:a1c:2209:: with SMTP id i9mr5245157wmi.92.1630007447168; 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Hanna Reitz , Klaus Jensen , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi , Auger Eric 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1630007451873100001 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=C3=A9 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; } =20 +/** + * 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, siz= e_t size, if (mapping) { iova0 =3D mapping->iova + ((uint8_t *)host - (uint8_t *)mapping->h= ost); } else { - if (s->high_water_mark - s->low_water_mark + 1 < size) { + if (qemu_vfio_water_mark_reached(s, size, errp)) { ret =3D -ENOMEM; goto out; } --=20 2.31.1 From nobody Thu May 2 02:43:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1630007454; cv=none; d=zohomail.com; s=zohoarc; b=UBr+VFNaEyh2R7XQ3+HMb+KKFgqD3u4KSZStxW7dzsMo0WN5Zrj4fHtUaqVCo7iJxlMLU5Ywq6eDlLGce2EFq0yjlfY7hPwZBZjbncFGlOysFPrJK7xOQDIVcIS9IaA0MfZzjcifcLcUpyp9VTFnO3eH1JTecesGcbWnmpMS9U8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630007454; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=umqwksLtXVwt5Q4MQd+KtuQaKYoIZnas6CvSnWhM3q0=; b=CcmmLtGe1JsryeKUVwDSibt4KJVUIeVlTRejV4OkrnPI5Y/kke3KXbXGVrZ2g0kf3KRid2oUbnxiL6xTpwQ02FEg5ALSV84UxmASa1I1KbFulpNscZ/3hN4fLk5r2a7oHKvXQ9IVLvBeqvSnfh5s8by09rRM1wNXD07voFJuDig= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1630007454890526.720479011657; Thu, 26 Aug 2021 12:50:54 -0700 (PDT) Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-29-1tAxzvm0NNyrVRkVhYhsUw-1; Thu, 26 Aug 2021 15:50:52 -0400 Received: by mail-wm1-f71.google.com with SMTP id j135-20020a1c238d000000b002e87aa95b5aso3965703wmj.4 for ; Thu, 26 Aug 2021 12:50:52 -0700 (PDT) Return-Path: Return-Path: 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630007453; 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=f/q4bqLC8nveVhjgcrZ/ffE2rgtGeEa86trzV5OFiNxGDzsMqTS4IpuwGtZ+KsGUU3EZKg 3uoxTC/qt8bocV+98BDy/4oMOsnoulDFU2nhMdMN6+RgrwX0JDHMbXjVSe35/f5DkAGO4U KPDEU1jDTaER/73QN7V0WTCH7Il9zog= X-MC-Unique: 1tAxzvm0NNyrVRkVhYhsUw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=umqwksLtXVwt5Q4MQd+KtuQaKYoIZnas6CvSnWhM3q0=; b=fuugCa9ooJCGpmKgPn5OaqBFr5N179tq4Z2OWVpYRNMgGWBSagqkq17OpbvR2Tdft2 y4p0csYPCZOgkzW5meDBkgWlDakRT/SmvcecSw0Y7/nXACWKjHwrONLtOSn9Wg/bqLR2 f3JFwgZAEyXXSPMDyh3uH5bm7fPRo7k3hGWyAq6sUQxf0FNM8tylUOWpF5gY8PGMSa00 RuWUBmCWlA7QlBGuAcm7QDvNrP3IwPNmRNdOybHCKErujzlTxgnVjDWJ/h4N1zE8fICV MY1OnJHEvS+1U64IJXogqQSNxQj4uAqs2+JA6o6rIy2LPxINCtP83altmRtY77EuqqfR tEUg== X-Gm-Message-State: AOAM5324w+OtKXoh7MDXhj6VTs9A3dGnNp5crL9UcRhoSPvf/O0cn31v RhutYwuA1NVwFyMXfY5uWOsC63kkNFtN3KzE4eXP2BHYnqGMcY++Kw3geu7w2Z98ocdNfxw3FOB cbN5LiPlDcJeOBg== X-Received: by 2002:a05:600c:4152:: with SMTP id h18mr2321100wmm.55.1630007451467; 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Hanna Reitz , Klaus Jensen , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi , Auger Eric 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1630007456349100001 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=C3=A9 --- 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) } =20 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; =20 @@ -696,11 +697,14 @@ qemu_vfio_find_fixed_iova(QEMUVFIOState *s, size_t si= ze, uint64_t *iova) return 0; } } + error_setg(errp, "fixed iova range not found"); + return -ENOMEM; } =20 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; =20 @@ -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; } =20 @@ -762,7 +768,7 @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, siz= e_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 =3D -ENOMEM; goto out; } @@ -776,7 +782,7 @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, siz= e_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 =3D -ENOMEM; goto out; } --=20 2.31.1 From nobody Thu May 2 02:43:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1630007459; cv=none; d=zohomail.com; s=zohoarc; b=SCtPsTuRNgu/QcAzGRGSt7T8Le4bXZVzhJapilIuZ/rVnwpxf/rRAY/B74Dv+A7jGVXUfZHx41pRNMMlQGWNBn37DSH1EPu0RFaGEUVyOAOQV2BYQYscxna39FEVwwcKyDWXNU6ItNqm+8uhbfltfRWuTPMS1sD+GezqKAwc4gw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630007459; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=BVQGD97lOuv5jkp0wr3tMIUyo/OkErXO+YtZC52NVRU=; b=CTQBBhe2Cd98ta2102pUHVaw2Ssk4IRTJedG7QTMaZ9LIgBjkTqy9chQVe/FHWUBs2Anw2wjUXAmQPom5yEoRmAdf2rFUA6risW9WP2xspOc+qJIJCGOZgzRnY/awaWEj+El2dnEF8rgTSjlLtzbzdIBsCCPI6yhSBuh8JdDr5U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1630007459369938.986650236746; Thu, 26 Aug 2021 12:50:59 -0700 (PDT) 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-411-MKaKh3E0MpGtbobJxlewOw-1; Thu, 26 Aug 2021 15:50:56 -0400 Received: by mail-wm1-f70.google.com with SMTP id z18-20020a1c7e120000b02902e69f6fa2e0so1267255wmc.9 for ; Thu, 26 Aug 2021 12:50:56 -0700 (PDT) Return-Path: Return-Path: 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630007458; 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=VJa4V/+iIhKQXigwKRaQNMljaj7GoEd02sf99TSUBYeI3/XPU96CofuyurdZzR4/l3LlWa 86Rtnf+4DChi4ucOUKmuAMfH0C9T2nMlf0WGIM6KL+dblOMYTSHJMFhV0Gg7K30w2SusQq cnM+Fi3EE7ugtRFLUdDih5cuZJYI8os= X-MC-Unique: MKaKh3E0MpGtbobJxlewOw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BVQGD97lOuv5jkp0wr3tMIUyo/OkErXO+YtZC52NVRU=; b=XcYQGYJeDG8ntHuLlZR/7Z0/03Isesypbuo6VVaDZDStmp0w5mGxlMvIvvOcgOeN+2 bfiLGkIoywW7Fr3NFYGSMZxHZDY2gEo0GTcrcbT0XaDkzic+HD7JhF3iDH2QZl7d2ZZY irJUg8h/gbSW0JlesF23rVrQlk1uzK6VTcTplG4QZjs0v0u3UaMG8hlIkYaJm5outLdF aYqa53k8Mi/9vEFyvDmAwvQpoU/0xmeh4D+drUlFGGr105N2U5ehCY22/F2Sx5Hw6ZuV 6aamIGHHgWNqhwEkQWfIBaJm9vtK4cPe/bJqu5IZgDnIkZ/GcG7NOpCTbNDl7MJ5NmcW FURg== X-Gm-Message-State: AOAM5300/RMmV8nnncBc4FHKBRUI6zB1pCUVTbDDk8CiVbvI4J83h1ce qcTPxnpMvLMAbfo0y3mF6mEigxMgwrG+/Pm19m/ppltTGcIUY/Biv50deikKwyrMqor4jOamR3e SpBlCY+sjt7u4Cw== X-Received: by 2002:a5d:69c8:: with SMTP id s8mr5807469wrw.324.1630007455740; 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Hanna Reitz , Klaus Jensen , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi , Auger Eric 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1630007460547100001 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=C3=A9 --- 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 =3D 0; int index; IOVAMapping *mapping; uint64_t iova0; @@ -763,32 +762,31 @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, s= ize_t size, if (mapping) { iova0 =3D mapping->iova + ((uint8_t *)host - (uint8_t *)mapping->h= ost); } else { + int ret; + if (qemu_vfio_water_mark_reached(s, size, errp)) { - ret =3D -ENOMEM; - goto out; + return -ENOMEM; } if (!temporary) { if (qemu_vfio_find_fixed_iova(s, size, &iova0, errp) < 0) { - ret =3D -ENOMEM; - goto out; + return -ENOMEM; } =20 mapping =3D qemu_vfio_add_mapping(s, host, size, index + 1, io= va0); assert(qemu_vfio_verify_mappings(s)); ret =3D 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 =3D -ENOMEM; - goto out; + return -ENOMEM; } ret =3D 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, siz= e_t size, if (iova) { *iova =3D iova0; } -out: - return ret; + return 0; } =20 /* Reset the high watermark and free all "temporary" mappings. */ --=20 2.31.1 From nobody Thu May 2 02:43:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1630007466; cv=none; d=zohomail.com; s=zohoarc; b=QnuuLIriMISBHA7JasVVjZ5rMvC9OEs175tkGe/r3mfxEUtNxKCaIChX9q0RFy81Jx6+oQ9ChzILE1Dotz2KMDjFoxkJ8ovXTDxqsvkOWgC/RIDmIYcoy0IJ49ulsgnrV5UYm3YTEHVGNYHlxq1cZVwkd/YMVfbcOMVPMoXlCg0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630007466; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=bIzUg2n6cWwWuyxJa1hqTDlzAZlGw1TJMvDOruqrhIU=; b=FDz+CfdojwhVUVgQ+j/s/uXrTFhPrkhaEgvaHAbXXmDbZaWWBlms0dK96BMgkVor3n2cifAdNZrdToS5zD/LiStR2hJR/ktMA/1Jk+HT3znUq2x0ywryZV6uS/esG+yL4kJ1VurWwdbDHpM5ECl9TbrXnLmcCkF7/LAprXJwcGI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1630007466142763.6032354557956; Thu, 26 Aug 2021 12:51:06 -0700 (PDT) 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-412-S4OZkNjcNbW-BQy48V7jsw-1; Thu, 26 Aug 2021 15:51:01 -0400 Received: by mail-wr1-f71.google.com with SMTP id a13-20020adfed0d000000b00156fd70137aso1210157wro.8 for ; Thu, 26 Aug 2021 12:51:01 -0700 (PDT) Return-Path: Return-Path: 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) 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= X-MC-Unique: S4OZkNjcNbW-BQy48V7jsw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bIzUg2n6cWwWuyxJa1hqTDlzAZlGw1TJMvDOruqrhIU=; b=EPD92AxMkIJvSxwqOxaKJjxYb5Eudof1j/URxk2iDqSMZzSQVX6VLh1rDQM/waloiz oojNOAVjAfr/Os85iC0jLyZzwsFendhMZuhWSWMESYv6hV6wmWQf97301NKcFgXzoxwm T3yjcEIGp42gtKuL6eZg5kuLh9hV1fDbn0zVvtMtm39lqEpWz+27nADxD7VrUr4A6qGQ 9AmZUgq9uYVfUmMJGGWynNNKF9UHmyGhOeaFC0cgHvNdW8mHI96cEs5eeBnUJKVLLsXE Is8D6fjLS72PBrsdsnqWJs0nPhGQuaRUe+8KLprqdW07C2XUgshVY5sf/a6dT61YDSzR gQ1Q== X-Gm-Message-State: AOAM532KNyDAN5DhIZkkAzc1K86JcS1xVkyJq+LLPN1Xhde70tJ8d6Vl cAJ5+FbtvXbNwGqAif5Yys22tyN7qtjZ5AjxDyvbvL+i2bA0HhIrbeIdQZvkLbm832KS5KfACWO 0CRIJ4sO5Dz9+tg== X-Received: by 2002:adf:e449:: with SMTP id t9mr5856707wrm.135.1630007460193; 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Hanna Reitz , Klaus Jensen , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi , Auger Eric 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1630007467302100001 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=C3=A9 --- 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, =20 /* 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 =3D { .argsz =3D 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); =20 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, siz= e_t size, =20 mapping =3D qemu_vfio_add_mapping(s, host, size, index + 1, io= va0); assert(qemu_vfio_verify_mappings(s)); - ret =3D qemu_vfio_do_mapping(s, host, size, iova0); + ret =3D 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, siz= e_t size, if (qemu_vfio_find_temp_iova(s, size, &iova0, errp)) { return -ENOMEM; } - ret =3D qemu_vfio_do_mapping(s, host, size, iova0); + ret =3D qemu_vfio_do_mapping(s, host, size, iova0, errp); if (ret < 0) { return ret; } --=20 2.31.1 From nobody Thu May 2 02:43:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1630007470; cv=none; d=zohomail.com; s=zohoarc; b=W1qKFUd8zNR0F8C58QdI7E1HHQXcC//ZT5NMueKD4Q23HBRrCVIhDgcc/ABhUfQyZ9Dv7JjByhDJaviXx+PYClP73zgeIK5HQbeWZ7B+E0TJTcl3v48P8YvCxrkTVOTFsOsrTW+fnF7E1CVT4U+74UawMpyzD06TzCuZRSSWbIU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630007470; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=ojj+ZaFHzvapR5Yklu/beV4VWQwhlVBhI7TMjzFMewk=; b=jlMKtAIlfmxHws6ecRkBISpouy/4xIWRsmuIngTLKSNd9P1SohPq0z7p0KS4iAf0fTx5YwkwHI4ApClQnEiwmTTEIkRuYVm3vLsEZu3KkuamyiHiEUB0W6mCqtfFQeKuUI76xqZdl35KuK7UIzM32aLt8CCM5XDH9eTBkmKPkJI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1630007470539152.0695375306334; Thu, 26 Aug 2021 12:51:10 -0700 (PDT) Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-99-71ImaxVtMJ6RV4CXkPUOCQ-1; Thu, 26 Aug 2021 15:51:05 -0400 Received: by mail-wm1-f71.google.com with SMTP id j135-20020a1c238d000000b002e87aa95b5aso3965943wmj.4 for ; Thu, 26 Aug 2021 12:51:05 -0700 (PDT) Return-Path: Return-Path: 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) 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= X-MC-Unique: 71ImaxVtMJ6RV4CXkPUOCQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ojj+ZaFHzvapR5Yklu/beV4VWQwhlVBhI7TMjzFMewk=; b=uE+Jrf7XsmP6BjGnTLyaTIK96aWYe9POSe/Hv9GIferMznJJURFkAb5Y16kYztM2CI 7Ufk8v1hMtAmFMvIiFGXgIfjUcIj4lOXD+fFVHWHFPPcDhnC8fsylNeKDknUIlz59b8S 9SBe238fVEmOU4a8QR3Sxa39rxgHJ2Xm3kEn3f8mqPks/NpKIM8bMQUOt+ZA7mUPqJKY YH7jVyAv0/HmC+ZGsGTeWC8XT7GRd0ER7vACK8Ho1DRFxQpjOiIiG19sr6KV77fk1R45 FebgydiitRJR353No1yYbtPIhEeCp69xkSZCLq9+Pdq5b9v56w1G8kgXwfQ5OOpL6go3 fQ3g== X-Gm-Message-State: AOAM532KvU5Dry/nLy11hTjoP1pQiZvMybheLDB4kygxin1aQSBl3a4M Hafebs0821fGU80di2PfqnTaAXote30nmDs0wRxsbkWNlMoUfsKmtCsswmzfpf1ULIfx97yfXl6 mr3QM+KDhs2vLCw== X-Received: by 2002:adf:cd10:: with SMTP id w16mr6241779wrm.404.1630007464822; 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Hanna Reitz , Klaus Jensen , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi , Auger Eric , Tingting Mao 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1630007472043100005 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=C3=A9 --- 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(BlockDriver= State *bs, NvmeCmd *cmd, uint64_t *pagelist =3D req->prp_list_page; int i, j, r; int entries =3D 0; + Error *local_err =3D NULL, **errp =3D NULL; =20 assert(qiov->size); assert(QEMU_IS_ALIGNED(qiov->size, s->page_size)); @@ -1031,7 +1032,7 @@ static coroutine_fn int nvme_cmd_map_qiov(BlockDriver= State *bs, NvmeCmd *cmd, try_map: r =3D qemu_vfio_dma_map(s->vfio, qiov->iov[i].iov_base, - len, true, &iova, NULL); + len, true, &iova, errp); if (r =3D=3D -ENOSPC) { /* * In addition to the -ENOMEM error, the VFIO_IOMMU_MAP_DMA @@ -1066,6 +1067,8 @@ try_map: goto fail; } } + errp =3D &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; } =20 --=20 2.31.1