From nobody Wed May 1 15:04:29 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=1630566035; cv=none; d=zohomail.com; s=zohoarc; b=Y6+clyOGIkcmR2DDVCFcsv54+gqDZFuWIvHLgOFaJZ5Pkhz1AVA9OehqADr7thM0ssTJLbImXYegYv26h0AXXzUnDWIsmC6ZPMwY/EbG7BZ03ZyaOEYTP9zj3UGrLyBahD4vzOhobrfsrJXUYfKgAXZwWudNibRPvo1nKrkxH5w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630566035; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=DPW4a8fAJ5aQIhBkKgFcCQAwlhPjH6NHU1IvtDHYfFc=; b=dYsRdi3TjsQfOPwIDSDec2KVbKIXCDg667nRUEoXzywZvgqgoHD7FCWeJLi2V/4pg/rVPj8I5kQb8H3t+tyP81L9BItF9rYeeHlW8I/Z2Jq7xrrAty2E20WCpIr0CL7a9fS4PhbCz/hbK+8iXlyy1FggkNoWYgsjCM7daZsHY3w= 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 1630566035193628.3705374209812; Thu, 2 Sep 2021 00:00:35 -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-300-kJ8w6qJWNl-os_J_jt0etQ-1; Thu, 02 Sep 2021 03:00:33 -0400 Received: by mail-wm1-f70.google.com with SMTP id k5-20020a7bc3050000b02901e081f69d80so322382wmj.8 for ; Thu, 02 Sep 2021 00:00:33 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id v5sm933269wru.37.2021.09.02.00.00.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 00:00:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630566034; 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=b36AWFyjT64saCO5RG3ie7WacO1W9Id08koJVV2rMwHy9jZMGxRr1GY1JDNiPm1BcHKbKR LuIv//tg6Xy8bFfokJOktM85NzzGVM5INTt5Wb1c0CVN1Qtp4dVX0vlZzeWGoplnjVC4mw qrnNd1wsEVlGmqLrIZqZQnutWNTmV4Y= X-MC-Unique: kJ8w6qJWNl-os_J_jt0etQ-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=MsfYwte5N0EdID1EdAUfu4OW9y8VLXNI3GssBl4/HAiNB3O3zj6gOY1eUxitvKIAP5 ipQN7S+Et6J6o7hsGVnmCb9a2L54ByynaVjQqp8fK5XgJZhxXaLIpBsxhcPQavwuYOSN 9Aua6N1TNGyyp9KjgQB1l2lzDqFORNOr9MkTzGLybx1kDs8qisHD02NTq7oVKdgKSVa5 6n9h3E8RvG0Ix5DQDZxdJn0nGM+MyaG1xmYTiH9+DWvVPpawIvAi8R224G0VBj3PsFwf pTAYE9sw73Ez+PbLSrz8BiQ0mbtlwr5JpasJXVzXJd3bNAYWjZ9zsd3Mumy46L4zkYzx uDGA== X-Gm-Message-State: AOAM531mvIJPVu5ZoLGG0GKLhEPVRooNaWSWmHmD11B3vdCJXNujWVBZ i1MCUAjx0pzTkW96XytLhdJbjwdzz0djBa0pOcIRuqMmRvG2YdXa2PtZzewhQvHNnXJqyWctcmN f/yTbEK303yQIbw== X-Received: by 2002:a1c:80c3:: with SMTP id b186mr1459253wmd.105.1630566032193; Thu, 02 Sep 2021 00:00:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSuTMeUBYjmMj9GWscYxb35xMvhBOgt2AD3bmDvuZlwWwJvRxCponAJZjr4WVkSloZcaVXBg== X-Received: by 2002:a1c:80c3:: with SMTP id b186mr1459238wmd.105.1630566031984; Thu, 02 Sep 2021 00:00:31 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Kevin Wolf , Fam Zheng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Klaus Jensen , Hanna Reitz , Auger Eric , qemu-block@nongnu.org, Stefan Hajnoczi Subject: [PATCH v3 01/11] block/nvme: Use safer trace format string Date: Thu, 2 Sep 2021 09:00:15 +0200 Message-Id: <20210902070025.197072-2-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210902070025.197072-1-philmd@redhat.com> References: <20210902070025.197072-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: 1630566035539100001 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 Wed May 1 15:04:29 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=1630566040; cv=none; d=zohomail.com; s=zohoarc; b=afifpPUiUs6e/riq/7Aw0cKo4pRRg0EU6+mK7DDbgT8bupTCl0gP2WMxTrjRU3wiEPdwyrqz9/WyQsf6W28BQT5/sA2g+dr4CvPXCu8lBEpGCcPT8xNVeBGfdO6+H5vL0HgX4Dqx95rZ97C4j31yQo6hfQDs4hkLcwNkNFHFq1o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630566040; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=bBtss4QrAZvCKlRzk4+0XN0kMEBQG8X7JlDa7aeGGM4=; b=BNL+WiVp4kV2RFyXYLMfBmV9Cha7H+CILJNQwsnq6/AyEDY2aiQZtJR0jWbFwRrKVQUTY/oju3XdyRfa37mmmSsxMx0VJV20Es2QQJLGGmsuhyclB3bLJ+LzZqscmx/uKTwz1jtMhPBcUZkzMREKXAhR47kB0gVWgPtQub8Zw+A= 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 1630566040030356.3274099479022; Thu, 2 Sep 2021 00:00:40 -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-514-83OVy9KQOf-wpy5Ha3RxDw-1; Thu, 02 Sep 2021 03:00:38 -0400 Received: by mail-wm1-f69.google.com with SMTP id j145-20020a1c2397000000b002ea321114f7so324285wmj.7 for ; Thu, 02 Sep 2021 00:00:37 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id t7sm1012543wrq.90.2021.09.02.00.00.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 00:00:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630566039; 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=bBtss4QrAZvCKlRzk4+0XN0kMEBQG8X7JlDa7aeGGM4=; b=PcwSbdDJg+CxCRHyyjz0/9VjlFVf9jS84uWoBU5fcl59NHZ4c683Y5MrasNpeKbq4xeFc+ kAkP8hZdJ4yX4DEukGnbDlwJ5cVqdiSIE3tOnBP4lxZTU9jw7mjUNEViXnYsyYUCwlrBhX SxV9ZAKSQrFrAt5I6VbNq4xCclgjj/s= X-MC-Unique: 83OVy9KQOf-wpy5Ha3RxDw-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=bBtss4QrAZvCKlRzk4+0XN0kMEBQG8X7JlDa7aeGGM4=; b=AEFTbFrmhofW9k/zDkMSxvMrMGbstEIYN8QYdHUeMkM6MmpfcJqthcFcysdth1mgEG t8nfvfwIWHEj94PyaJbNH50EzfobWHcmtn06/fQGp/b6c1SkeBGKs7NuH4Mih7IodLw7 lAq3j9MHPnwgxVxdj8MGQCzgpTr2rqJMh2u/DzNgYcUUCInT9LdlqSRGMPo8Q2GXXauo dGkgtQJdQkn3xOHugbaPpaxiU9KrhV9BPnhUnSHJ765Lg6N8ArVQHFiNObkhAa1Z95LL sptvbRlFq6HOzZCT23Oe3XkV85YaPFTQ9lloHwW5A0wn/YqPhjzMvMZLiIHRXKtwOfag yP1g== X-Gm-Message-State: AOAM533tqtVHISC9tUsEEtIYQAnouXjDXK0ZjNJWYSSHB52ysQsUojfT 52KZ5ogrn4C61/lQ3Y6D22jJx3ii32cPQnmx2+YqxxQFsah0NfeLJ0xF3STL0YiviZdfq4NxWCg kitU9h0aa6FiFlQ== X-Received: by 2002:a7b:c441:: with SMTP id l1mr1511144wmi.69.1630566036719; Thu, 02 Sep 2021 00:00:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqzlcRd6hLENRtIYmXuNe2XYP5FMGyq04M4x0uGtqjDbinDjdqTxZZXnD6HnxGookx9mDnpg== X-Received: by 2002:a7b:c441:: with SMTP id l1mr1511125wmi.69.1630566036532; Thu, 02 Sep 2021 00:00:36 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Kevin Wolf , Fam Zheng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Klaus Jensen , Hanna Reitz , Auger Eric , qemu-block@nongnu.org, Stefan Hajnoczi Subject: [PATCH v3 02/11] util/vfio-helpers: Let qemu_vfio_verify_mappings() use error_report() Date: Thu, 2 Sep 2021 09:00:16 +0200 Message-Id: <20210902070025.197072-3-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210902070025.197072-1-philmd@redhat.com> References: <20210902070025.197072-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: 1630566042167100001 Instead of displaying the error on stderr, use error_report() which also report to the monitor. Reviewed-by: Fam Zheng Reviewed-by: Stefan Hajnoczi Reviewed-by: Klaus Jensen Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- 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 Wed May 1 15:04:29 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=1630566044; cv=none; d=zohomail.com; s=zohoarc; b=ZlQESgDdwA1/G+XA0tnFz9qY3UgDvKG4937FPttMvKVSaP4RZX0GLjRp2/jyn8gRaBWjoweZs6uHqWtG22zvttTGiU7RHj5RZ3n1cOZhTEbfBeQnOcfLd2rYDpGv7d42G4pVynDkyJkRuWwrJY04dz3qYf6ULKzWNOySRE/h8kM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630566044; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=2lm4MltjciLe1FvPMjz8J1KaGtyzlphex4Ajbbc6qJo=; b=PRk9hq4YYCHwYOeq1/gk6vXaUjKRR/znzmXZWr7watUoGDjf9ZrAsiBuOEJgQXP2xs8fez3gZTSP7Lc8+p3zMk/zXXPff0LWZmztjx7poOc385PffE9d8UKCbvY7X7lDFDCAJZ6v/8MCLBj2cYabqMFe4hYrUaOWSOx94G6GZCA= 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 1630566044522989.1485798773921; Thu, 2 Sep 2021 00:00:44 -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-313-UKuU1N3-M-mr0erjUDo0Wg-1; Thu, 02 Sep 2021 03:00:42 -0400 Received: by mail-wr1-f69.google.com with SMTP id v18-20020adfe2920000b029013bbfb19640so208541wri.17 for ; Thu, 02 Sep 2021 00:00:42 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id r10sm932883wrc.85.2021.09.02.00.00.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 00:00:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630566043; 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=SZHsT8bjzscam71LE8G4RXCK+ybUkvjHxFNnXSIdPcmB7r2VinrSYoF21X5gU+t+rji1Jp qfTgvtZTXEVpbG0Aw3cAnH2R8ym/ClW+oW8VIqFSo97up2s2wbrA6YjZZiCnyoM+rNB7q1 FJqoR69pVMOcNxVsIz5ShWmPdXhOx9g= X-MC-Unique: UKuU1N3-M-mr0erjUDo0Wg-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=NrstceqjqsaunMCvVtk1Ue7koKzy3G9Zbuugqzdw8iKWJbWi06HSKgoB+8oDUvsMRc WgCCmu6QyISnt6jsJoCEbO55mD9P+WwgmIbJLxvdERiDpfaqDJO2IKWkZubSbSSDDTcS 3bIro3H9uOUpXK/413dXeNSP3AlnyNLiNOF1ujlO3aBZPH7x067RltUNSboi9iSzPSSe mpoUc40+Q9AVuofGhznYaQ0Uyp4Jh31vDCbvcCH5uE925NPAe6KSvU/uROTjAIBSp5VU tEC5aha21AnkeafSN9IPvB0/3zfCm406vJXdwG51hB7oYWqm5UjtvvDp13Ujb4ELmYR7 rO8Q== X-Gm-Message-State: AOAM5328rwjDcmro+GG8n8SunwagEVMPLaGZFka+1+m+day4Gr1m09tD gLDKlvykBdZ5NLSec30Rm37K3EAzIVhk8lECvZ06xw8bFc28/TMxF8XnESrX0gbMJ3QVdi909gf kfcz0ic4ygi/I5w== X-Received: by 2002:a1c:20d7:: with SMTP id g206mr1612453wmg.153.1630566041126; Thu, 02 Sep 2021 00:00:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrJvsaNZnkBJWlG0OQYz1GUol6cYXAcSs8Fw2UXZXajEbYv+fWiTNPrnI6L8LhiEwKU5B70w== X-Received: by 2002:a1c:20d7:: with SMTP id g206mr1612426wmg.153.1630566040915; Thu, 02 Sep 2021 00:00:40 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Kevin Wolf , Fam Zheng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Klaus Jensen , Hanna Reitz , Auger Eric , qemu-block@nongnu.org, Stefan Hajnoczi Subject: [PATCH v3 03/11] util/vfio-helpers: Replace qemu_mutex_lock() calls with QEMU_LOCK_GUARD Date: Thu, 2 Sep 2021 09:00:17 +0200 Message-Id: <20210902070025.197072-4-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210902070025.197072-1-philmd@redhat.com> References: <20210902070025.197072-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: 1630566046600100001 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 Wed May 1 15:04:29 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=1630566050; cv=none; d=zohomail.com; s=zohoarc; b=gpC3P3gZdCYvwhnbKxjtbGLqvkFxfoqrHWTSWd+xCsiW0w4O3hMfLkVa6624UoRTwJfdeDtn+yd81x9h8DpVbMLaPZMgnmjsYBWB8hAtc0sMP/rG8ox6Zn7e2dst6wWHXo0EoQ663RN/E/6e5DNrD56J5wJdFRG5PqK7oSXcVAI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630566050; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=CPZfczG2XQrRC55s69h86ljHzGci8wjhwO3c1XD3j8g=; b=KTR4zaYdMGq59P61HSiosqWepgqoX+prc1usnmSUCnsyRQvgkR9SOcBii7wFtQE0MFBPPZBGFC5cmGmbMxuUNTB+msfyXY5CrYO7/1Hr+EPPbGh5sY9nYnxSNSRCn1H8LYnzGqOFjxOyv/Z2LhoesPjmP8NpW6qWWgT4Y7I7GNQ= 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 1630566050974872.5372059477386; Thu, 2 Sep 2021 00:00:50 -0700 (PDT) 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-375-OajSDg4GNHOC0qJfPEWVLg-1; Thu, 02 Sep 2021 03:00:46 -0400 Received: by mail-wm1-f72.google.com with SMTP id u14-20020a7bcb0e0000b0290248831d46e4so340580wmj.6 for ; Thu, 02 Sep 2021 00:00:46 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id k37sm718914wms.18.2021.09.02.00.00.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 00:00:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630566050; 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=The9/zCn1Upk1hTRgAZiThcbxjfKABYC7rFywZlozmdA1lODw+FXB+FkMqJXgrryZIdzWG wc0p81fjscPJLkoDXlX5M3AQXpuVbSUqw/kkEAnfc4jxAZySGDzXYhEGiTPL+lOEs1N2rg bMQWUsy3Su2+GtX4GNGqbUHBX+qbUis= X-MC-Unique: OajSDg4GNHOC0qJfPEWVLg-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=XgzIK8BBgUIDkshbnYpmZPoVsVddNpXoTt1LBGLC6Uw4xbMPufSmO/fxew1+LIzOgA I1YTTbfjIkTmAA66/7WUk/Zr5ukv0Cx7MNXVIB0pxdMsPNelP2F4Z/chTHdhvPDVIFm7 EuEpYebV779b4y2zx3Qbnecy8Hnd+B++KlHXcJOztEHxuUZ9l9ZGeBpnTaIgi2DV7PoL UiEUzCfTSZN/Dro0EIky07fT9ztW/nqeFhMjc0vDvAc96VV1tt5IRyW9wBhO9nDmJPMc giV7kNWz7Y2L+EDcgL2HtHn7ChBXC40IhNt5/6MSju3lpF7FUFQfr5KDewxmDvoTOW8G wWzA== X-Gm-Message-State: AOAM530RcBxJmVrusacSQoD6ZIYQNOdTGFqzwJgfqS0hqmzYemMxY1p6 jmWqKQP7qfjOxOI6k+J6yU3WbiOl/A6XWyZJ+T7C9hV9I4mcLPz8b0qgcX6WxMbt3T39ybNEf6V PViHpaL17b6/mow== X-Received: by 2002:a1c:f60c:: with SMTP id w12mr1576150wmc.3.1630566045567; Thu, 02 Sep 2021 00:00:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPjBmCiebh+oOlEjgSurjZRRPjR7r/gETyismGSZ6AEUj0xE3V3XA0dCOd/gHkvZcxL9Rqbw== X-Received: by 2002:a1c:f60c:: with SMTP id w12mr1576141wmc.3.1630566045429; Thu, 02 Sep 2021 00:00:45 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Kevin Wolf , Fam Zheng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Klaus Jensen , Hanna Reitz , Auger Eric , qemu-block@nongnu.org, Stefan Hajnoczi Subject: [PATCH v3 04/11] util/vfio-helpers: Remove unreachable code in qemu_vfio_dma_map() Date: Thu, 2 Sep 2021 09:00:18 +0200 Message-Id: <20210902070025.197072-5-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210902070025.197072-1-philmd@redhat.com> References: <20210902070025.197072-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: 1630566051234100001 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 Wed May 1 15:04:29 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=1630566053; cv=none; d=zohomail.com; s=zohoarc; b=muMefQgnIpR5ZFQc8AfA9jeaySC755EQI+krTN5jwKXXIqo/46fNReOIsvqb0zdHNh6SJpxO4/U3LUhXsQsxpLGVhOG/3fvoyO/x4h4IPJhggmiuXrqd59S4ByTDRE72ma/AS6tT7pfP5dDqlNKhIPPeq6+qskbsplC4uNjD9wA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630566053; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=fxOMagDiCYXI3yAqJDznAMmBXuTNis02iI0rK5zMlsE=; b=ZF0LNHVfVoAGzHUZ6UNg0u0gboWLOR2oyTeQpp/2SI5C2m9aHxCmjnyzFNCm3YabfBQXNoSAn2MZZrPI1xS/VAoP+0s/FkvTrtM4mFKXCCLnpEloW/7LEaNbUbGJ6fSbluim+n26I88ZaTF2x/yUIbVyVM4YFxs3+5pLKqUHPFY= 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 1630566053291608.8165855234943; Thu, 2 Sep 2021 00:00:53 -0700 (PDT) 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-284-U9fKr6d_O7W3HHjgrUb2Kg-1; Thu, 02 Sep 2021 03:00:51 -0400 Received: by mail-wm1-f72.google.com with SMTP id r4-20020a1c4404000000b002e728beb9fbso561019wma.9 for ; Thu, 02 Sep 2021 00:00:50 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id c24sm921515wrb.57.2021.09.02.00.00.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 00:00:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630566052; 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=fxOMagDiCYXI3yAqJDznAMmBXuTNis02iI0rK5zMlsE=; b=c3+6lBeZk5ICr+PxeQLk9kQIE63XFymF2TGyqbzgpoxHqWld7wDp6ckxNooKfBmNcabJE1 5Lqj2frximDXpR57Oc2jKEC0opYtG4gLHYMYC0/UUPzz/caI/qaoW/ftH88H3m3Jm7SzCi 0SYnoZ1jt5mMVlJXnEHTifK4N+SuTNE= X-MC-Unique: U9fKr6d_O7W3HHjgrUb2Kg-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=fxOMagDiCYXI3yAqJDznAMmBXuTNis02iI0rK5zMlsE=; b=Hi57Mgpn8IAig3ClovHxR9aFrqC85JRP8tk/L/XXBHSAHxrRNJ9LrdVNqloHg1JfLE 8TcW+FztvqoA314tVjkfavf6h58VTSunVVTNwP1sb6T7XD/7LvIJ0RY9BZ/uXW9RjcDZ HfSseOKmwzTlgxoxIRYaEsPGz173OkUFQGcVkEgCug96X/iUGabvVRNKOZxOag+44MMF 0emuI2YQPIpRJMzOpGfYQAsuBYhH0MzoA0dTgUTJMAAthy9fbiYW36zPZUf5AExsA9OV Wge8DCGSHgPgYwUdieUZkFPWGiVutLbPeAXGZM/uU/0jGJnRpKJTNfA6uOCr09pNkP07 YiDQ== X-Gm-Message-State: AOAM531apoQYh8nm/cdOcLdfmOwE+LKFdxfC4Kby/+jXCqcZragrxaBp o9hLxlqnEnhQGnXo57OTO4Vq6OIE/UIbyve88MP+2aQgfNg9v9UqsKrD/fros6MqCjsYpAHBdwc aYegUUJimn56o5A== X-Received: by 2002:a1c:f019:: with SMTP id a25mr1600343wmb.96.1630566049991; Thu, 02 Sep 2021 00:00:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyj9XGwda9JFPCgQuPtB8iH/uqvLuI3dO5xcorOcnyXJ4D2BnKJrwgcJHBik02aPE9HityRnQ== X-Received: by 2002:a1c:f019:: with SMTP id a25mr1600324wmb.96.1630566049793; Thu, 02 Sep 2021 00:00:49 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Kevin Wolf , Fam Zheng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Klaus Jensen , Hanna Reitz , Auger Eric , qemu-block@nongnu.org, Stefan Hajnoczi Subject: [PATCH v3 05/11] block/nvme: Have nvme_create_queue_pair() report errors consistently Date: Thu, 2 Sep 2021 09:00:19 +0200 Message-Id: <20210902070025.197072-6-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210902070025.197072-1-philmd@redhat.com> References: <20210902070025.197072-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: 1630566053754100001 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 Reviewed-by: Klaus Jensen 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 Wed May 1 15:04:29 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=1630566057; cv=none; d=zohomail.com; s=zohoarc; b=POkcATVEE6xkoaIX6W1OND8pbMMsDJsAoL3xXk1RgOyZIOcqFqYIdexEqWSRhXikQ5AHqYDVhrKrgFcCkjGJ3bJphCE5cUB3KhyP5XV84pFO9ACMqm1ho2u74obw5iJDeJkiNB+sO3mp3bCDCcxnXWd9UdHZ/dhgQvKD9XLq30k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630566057; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=c0du9Xr//PiqvpruelRCxIATbcKBoWU0kKahzJtsSiw=; b=oFpLuPEs2sd2tmBS5CpRC+AU8soDVJjrkDFGgkQ3X0TO5POmEIpPwC/8i/js9m59A1JEtq00NTQXPbB3gSGBbo2qvKC1p2vbMjNJm9q0UdBbO4mo5U4S239zpH2t7sRrxKPyHCk1WXuSpo6xq4n+Pe4DwgTuL8SQXh02b1Q0xo8= 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 1630566057609586.165623507269; Thu, 2 Sep 2021 00:00:57 -0700 (PDT) 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-419-CFRf__ULMnavflGppoTSVA-1; Thu, 02 Sep 2021 03:00:55 -0400 Received: by mail-wr1-f72.google.com with SMTP id p10-20020a5d68ca000000b001552bf8b9daso206916wrw.22 for ; Thu, 02 Sep 2021 00:00:55 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id u25sm787473wmj.10.2021.09.02.00.00.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 00:00:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630566056; 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=c0du9Xr//PiqvpruelRCxIATbcKBoWU0kKahzJtsSiw=; b=IdiBH6PeBFK+UtnoLpNkW+ubAV4mNI9MzXRdUrcvTAiy0uNPXJhVYsU4FdVAraibxRq7Df ECaHUeyIVtWVnDqmdeBx8reeJw8cP2SS1B5wjRvDlXKfkhxzKy2zGcZqTcVBsJBRyOMZ/E Z7qyv9dfw9sOOApDUhW9JljTgKBrtYE= X-MC-Unique: CFRf__ULMnavflGppoTSVA-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=c0du9Xr//PiqvpruelRCxIATbcKBoWU0kKahzJtsSiw=; b=WgUTJIFv8nbn0DzGbVv9qeO005hnLkjzzhI42a7uY8Ojra5gpBQfmb74i6Aj8gdsNz qLZl7swKx8nSU1g/2QzZu4wnnCufpddmZGYiMw8yFaegn5GJ/S1car3UdIthcXHdLKHN oMggaws7cQu+c/hTvDRY5fnkeEIHK8QZNJ3FwI4k5j7wp5tvOwfBCPaVvTAdWjzplDJ6 tiVQaUPyss1WPlE3dNKr+5KH4R5xHvuvIuxova39E5c+RtY/erxJFsC42uFZCQ/ZmTKT akiPh1/YPt5YFN1ZGCp/g+YEfU+UU8SkPFHEselGBNCjO6zTg0IkfNysvfEibA6MGOxi NkVg== X-Gm-Message-State: AOAM533y+Nsa/bXuiQEI66b3IwDOfv0SvW5Iqgu9GYeGjsTrx7NfPS0x 9PwyzJbl/yF9n+8xB8g47ajLJS2OLNEsuIiXqUmiTxn8iL91mErXRrDnwx6wrLIUJ1SwQK0pzyc dgraHCzQlBLlZ1g== X-Received: by 2002:a05:600c:221a:: with SMTP id z26mr1527093wml.142.1630566054456; Thu, 02 Sep 2021 00:00:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylnNN/kJdKCFAkAkGLauU+WQ+QrSGYfCJTQNHnYqVmFdVDVivjhcWGpNRzX1TYhGLlyxxjaA== X-Received: by 2002:a05:600c:221a:: with SMTP id z26mr1527073wml.142.1630566054301; Thu, 02 Sep 2021 00:00:54 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Kevin Wolf , Fam Zheng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Klaus Jensen , Hanna Reitz , Auger Eric , qemu-block@nongnu.org, Stefan Hajnoczi Subject: [PATCH v3 06/11] util/vfio-helpers: Pass Error handle to qemu_vfio_dma_map() Date: Thu, 2 Sep 2021 09:00:20 +0200 Message-Id: <20210902070025.197072-7-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210902070025.197072-1-philmd@redhat.com> References: <20210902070025.197072-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: 1630566058180100001 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 Reviewed-by: Klaus Jensen Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- 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 Wed May 1 15:04:29 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=1630566062; cv=none; d=zohomail.com; s=zohoarc; b=hbR2zYu708s/hUT6ZtE9KaKF+27scjGHIM2BiEj26/FYmJ/XUmT/5MyjxZ05sXtIW7Kup8R1I/zCJP775coSF8Q6f6H77kblbrN8VSd8e5NQUf5Bo1at8TXQhjreU5Z36L0/xngfK1lv5l1DpFLCnI/W9AJrCJCZig0Bd8Hge/Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630566062; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=arguNxflA2S+jzgAEya6eTJ5GHl9dYzb/Yt+fBA14Bw=; b=eGeCPw9BccJpxsMYLdBDodnrhoihXGjJHqF9IyVfP+fyihQ7Osv3E6SUyQo6PjNSJR+UvjgHu0PWo40G5wHbMg79ytXmtNzxpY8FG4yK595iz5QQ21dYReJXk0Sd69BUHQqDVoumg2T6PptXqkClhMYXWOQb33MNWFZ+K4yvofI= 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 1630566062261120.8960605145279; Thu, 2 Sep 2021 00:01:02 -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-34-8in48CUXPY2SgyatCrj3lg-1; Thu, 02 Sep 2021 03:01:00 -0400 Received: by mail-wr1-f70.google.com with SMTP id 102-20020adf82ef000000b001576e345169so212977wrc.7 for ; Thu, 02 Sep 2021 00:00:59 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id j20sm820512wrb.5.2021.09.02.00.00.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 00:00:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630566061; 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=arguNxflA2S+jzgAEya6eTJ5GHl9dYzb/Yt+fBA14Bw=; b=Tv/9TN9NJGLh480VUVDtWMA2+8hGYhQXl2D38u0Ugr289XCd53FSq3R6Rdfg4vz0Y1nRSy q1yh9X82a09GvoN9ei9JTzXmgju+0wrVwpEWZNqnMSc5PWNfE1lCHPpFF40MfX1fvTN3qS wR8udDMouyLLYv33WaFuDRgP8eUu00E= X-MC-Unique: 8in48CUXPY2SgyatCrj3lg-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=arguNxflA2S+jzgAEya6eTJ5GHl9dYzb/Yt+fBA14Bw=; b=CzvRHWu5ARwEEIYQb0hFtTtaf2oRLsrSwyjwlOjIQOosqEXe+No3OnSM8SzndwjWwJ hCEYNnee8Nuuh2g5emGEksD/z6i3w3tgyfkdxaT2uRIFf2f7o61ddo97lMXGD+wGFZUl 4IrqqZH4C3d123RJTEDA+0ThFs9KBoXFRMSeHvgGXR35Z5Wz0zGfy8pSxbwTINUbFBVG NX7KwCQS8Xe4+HcIf9tHvC1tNtUz+uMLOeo6jXJ0hg2lHXfSLXCYtAlsqMANKJRM8rW0 DxpDvAeFgxfPtxbyPy8CCRJZ4gxZaizmCqzrlxj4iFrZljHd5TjQHXWwV+m31dJDWwnl myog== X-Gm-Message-State: AOAM531K5pOKBEg4NwVLIh3Vmy5I15oWPayua0/Gd7v8Tn04mTAJVqxY Gk4PutLvPEJ8U5iUz4GA6cMPEmDxo7VWGPXYVtW18X4z2fee2SXE97KYchxFCoIy7l8b+jIm83H XjJlerNPe7yrWIQ== X-Received: by 2002:adf:d1a4:: with SMTP id w4mr1776954wrc.233.1630566058894; Thu, 02 Sep 2021 00:00:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwce3M7LpyeIDl7aBBNIHUUHA094XTA5fvajruqoP7By1cxn/DNw3jIgN5FiCaS/c9LeIrCjg== X-Received: by 2002:adf:d1a4:: with SMTP id w4mr1776935wrc.233.1630566058742; Thu, 02 Sep 2021 00:00:58 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Kevin Wolf , Fam Zheng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Klaus Jensen , Hanna Reitz , Auger Eric , qemu-block@nongnu.org, Stefan Hajnoczi Subject: [PATCH v3 07/11] util/vfio-helpers: Extract qemu_vfio_water_mark_reached() Date: Thu, 2 Sep 2021 09:00:21 +0200 Message-Id: <20210902070025.197072-8-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210902070025.197072-1-philmd@redhat.com> References: <20210902070025.197072-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: 1630566064161100001 Extract qemu_vfio_water_mark_reached() for readability, and have it provide an error hint it its Error* handle. Suggested-by: Klaus Jensen Reviewed-by: Klaus Jensen Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- 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 Wed May 1 15:04:29 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=1630566069; cv=none; d=zohomail.com; s=zohoarc; b=oG1FfHT3ra1ATXj3j9MHEgoaZUUtSLs/SAhHKoUF2kQCV099Q9Z6tKAroQmOvdhyURGWNzqX71n0H5KzY1HZ/0VjKI9k420yXjFFAXNHer8L1U/DRTGbk7BZLrB63m5tAcrkoxn/nGCmazsWHuMui36nyzG2PlZoI7NIc4GHzgM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630566069; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=0uOWhp+saqCNjYYeu2/7aRiyZ5BV70RG+ybspQ5dAak=; b=BoNisHTYQ3259KsPGr6VM25p++pB3iE5dquNftPwgugfw4ttpUWzTdVlO0dXmtPvIsH3kSeKzrZ9V8ZDg9WJGMA/g0avwCaj5lUxmvF/KGNEVG4CunRI8BcD4q9gSeGyLZehUtKHwIPkV1yQJko/nZA2OIZyx3u4+19hB3BL/Qw= 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 1630566069092119.7568950775941; Thu, 2 Sep 2021 00:01:09 -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-465-Tush8DbEMMetgarvDd8x1g-1; Thu, 02 Sep 2021 03:01:05 -0400 Received: by mail-wm1-f70.google.com with SMTP id p11-20020a05600c204b00b002f05aff1663so349867wmg.2 for ; Thu, 02 Sep 2021 00:01:04 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id w9sm748568wmc.19.2021.09.02.00.01.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 00:01:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630566068; 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=0uOWhp+saqCNjYYeu2/7aRiyZ5BV70RG+ybspQ5dAak=; b=JPAUbQhch2EKJOPR9sx0lTCjUEOcEpYwLS7PT4GKWnsEOw+UNzS+NdbQUaj7KnirjmZ3ra 4WZHABj3Sp+sl3hpPrNAqgd1nuSOxTvxgBRxu3agbu43QQS4VxoeTZzHWSFCitpa75s+V3 8c1jQtZC3Up5nrVVMSJrXGAEPWP/nqY= X-MC-Unique: Tush8DbEMMetgarvDd8x1g-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=0uOWhp+saqCNjYYeu2/7aRiyZ5BV70RG+ybspQ5dAak=; b=JTelwrMlE1Cjk1Y+r8WfSpVmIQcdEXAdJ9ctqGjdj9upaGIee1Py4M/EQyjQBYdotL gBcb0/x1qUd3shUORyVuDIo1Mb98WrSUWza3T+EaLQTv2CwTsOu6ONhYrrpwgVovWjoI RzbKCZGRBUrn1wQvHYrHqnelDq2EthHJqe04MhQLRPatRxWpWhS7rCsN6zKnrWsI1ceQ wKY5zOap3rNOLWKyaOvnXIf+PjoGv66MSaGpedPyzSIrymr70q7NshOIxz3T8ShlTGHQ vdVXXTN1UGnB6GX+9UxdXAJfumR1FPm3iuK17s/X/E7n3Mnc/NWEDsxu1T1FUllF8DHH SM8w== X-Gm-Message-State: AOAM531tablTIGBn1TnQymB+C4X7PFtV5FBCqt5Yf3C3bUIPYr48Y0kk wUZmWo54FTWkyjDeFn7XLj0YWyhy/duy2RSRUyNbhJJhIUb1jmMN6z3i6vSLEouylr6v+8LaWs5 y2PBGqxqc4cgw7Q== X-Received: by 2002:a1c:4686:: with SMTP id t128mr1478488wma.183.1630566063699; Thu, 02 Sep 2021 00:01:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7uRnvl5NMiCgo8fd31zdmpgDUNAKhX/1UQ81e7SxZUCKxXZXSyeA8FZuRhep03yUFE+Oi4g== X-Received: by 2002:a1c:4686:: with SMTP id t128mr1478470wma.183.1630566063545; Thu, 02 Sep 2021 00:01:03 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Kevin Wolf , Fam Zheng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Klaus Jensen , Hanna Reitz , Auger Eric , qemu-block@nongnu.org, Stefan Hajnoczi Subject: [PATCH v3 08/11] util/vfio-helpers: Use error_setg in qemu_vfio_find_[fixed/temp]_iova Date: Thu, 2 Sep 2021 09:00:22 +0200 Message-Id: <20210902070025.197072-9-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210902070025.197072-1-philmd@redhat.com> References: <20210902070025.197072-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: 1630566071109100001 Both qemu_vfio_find_fixed_iova() and qemu_vfio_find_temp_iova() return an errno which is unused (or overwritten). Have them propagate eventual errors to callers, returning a boolean (which is what the Error API recommends, see commit e3fe3988d78 "error: Document Error API usage rules" for rationale). Suggested-by: Klaus Jensen Reviewed-by: Klaus Jensen Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- util/vfio-helpers.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index 306b5a83e48..b93a3d35787 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -677,8 +677,8 @@ static bool qemu_vfio_verify_mappings(QEMUVFIOState *s) return true; } =20 -static int -qemu_vfio_find_fixed_iova(QEMUVFIOState *s, size_t size, uint64_t *iova) +static bool qemu_vfio_find_fixed_iova(QEMUVFIOState *s, size_t size, + uint64_t *iova, Error **errp) { int i; =20 @@ -693,14 +693,16 @@ qemu_vfio_find_fixed_iova(QEMUVFIOState *s, size_t si= ze, uint64_t *iova) s->usable_iova_ranges[i].end - s->low_water_mark + 1 =3D=3D 0)= { *iova =3D s->low_water_mark; s->low_water_mark +=3D size; - return 0; + return true; } } - return -ENOMEM; + error_setg(errp, "fixed iova range not found"); + + return false; } =20 -static int -qemu_vfio_find_temp_iova(QEMUVFIOState *s, size_t size, uint64_t *iova) +static bool qemu_vfio_find_temp_iova(QEMUVFIOState *s, size_t size, + uint64_t *iova, Error **errp) { int i; =20 @@ -715,10 +717,12 @@ qemu_vfio_find_temp_iova(QEMUVFIOState *s, size_t siz= e, uint64_t *iova) s->high_water_mark - s->usable_iova_ranges[i].start + 1 =3D=3D= 0) { *iova =3D s->high_water_mark - size; s->high_water_mark =3D *iova; - return 0; + return true; } } - return -ENOMEM; + error_setg(errp, "temporary iova range not found"); + + return false; } =20 /** @@ -762,7 +766,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)) { ret =3D -ENOMEM; goto out; } @@ -776,7 +780,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 Wed May 1 15:04:29 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=1630566071; cv=none; d=zohomail.com; s=zohoarc; b=kEWYmaxFVcl3zWE4F6tSzY4GrSxT5PgN3wRemVDyTskXvXowtCc9/ZOdvflrnir9GJlnl0p7SIpsnIbJOz+8p1WbCAD38k9HFZ6jg8VOvQuhvPeuZiR01UdbTPtgkKBkOaYEXtwD8WONHLnKyj52X8nkl0kELUXmHCvdxkMnkiw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630566071; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=V1OPgrDUvQgAnd9+SePpUbnTbT2KxXBfqSZ8bPzA2WI=; b=T74qERi6h3eafdozSF1/z8r1iN6qXJb2jTNF7WTj7FSkecpb7wupa+W1UhWFRXQRvhEF5oalJ6VUBvKaFVoZkY1xC3A4mnWe/sDTnZFqUgONQlCr62o2ksqJsiXCbjMdeHlvtyyzl9kZxxib7KEspgcOLq3IlwFBB93U5KGXtMc= 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 1630566071318574.0755240331274; Thu, 2 Sep 2021 00:01:11 -0700 (PDT) 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-24-0ySIiM_LMUqTG9cXy6X9Hw-1; Thu, 02 Sep 2021 03:01:09 -0400 Received: by mail-wm1-f72.google.com with SMTP id z18-20020a1c7e120000b02902e69f6fa2e0so323251wmc.9 for ; Thu, 02 Sep 2021 00:01:09 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id a6sm917585wrh.97.2021.09.02.00.01.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 00:01:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630566070; 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=V1OPgrDUvQgAnd9+SePpUbnTbT2KxXBfqSZ8bPzA2WI=; b=e9LMjlmNb+yU6iYuQt9hJNgD1Ml3iTvAE+MXFjP+oovNI1Ja9j4R1QZXr8Pk3jaFLkcAQW Q1GGuj7/GrrmQMCWDg14vHDphktwg/+KnOo0b/1M29Ks8vte7X0UMfMsaYEmEdJgDtCvQ2 8UirQ49+OOTwFAl9lw09EU5fxIpK6P4= X-MC-Unique: 0ySIiM_LMUqTG9cXy6X9Hw-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=V1OPgrDUvQgAnd9+SePpUbnTbT2KxXBfqSZ8bPzA2WI=; b=YML46AYbMPYZoaPpR/+YKL1rAYOBvCwj3aU52l+thoJor1+joLQWThtMkeNNN9HaBy wIb20bHuPWLUk+SZFCRVj19FhJUjV8HBkUElwQc4rSDcNMB+3zcN69SFdEJyu1DhyPoZ JFUNOD7J6W5Yw+aWUV/e0cNZvpJGUAL198aBpjyImFyTo3IX1DFiW7h9YqnTJ/odFSFg TgyKthfXKLU5Qc9rJkDexZrAQfEuuIXbNpPTDIuKjrMXPKXCUAMHX61edgGm8Apsk9wq vLamb4QG8emZCX0oKPX3a29qFMebqF+c+FPmwF6rsF13r4jDvbKNtPYUX7B//Gr3oDU7 PNHQ== X-Gm-Message-State: AOAM530v00YuL1D38UtvF2I0zkoZ748rTPJ1B1S1uNCSyjLP3D43ROIW +tiKV27aZ7O4tVnZYMIi4yb0yP5ehsnpU11hBR1DBCj8kKX13FFZzAZxbO2F+kVnaZfjdipThHn wrPJjnN+zfuNgSw== X-Received: by 2002:a05:600c:1990:: with SMTP id t16mr1549664wmq.45.1630566068089; Thu, 02 Sep 2021 00:01:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBnaLQDBmhgZ52vkNdpL6UJBhePOKuAx2drr4XNe1mHiArDuZ0H19Lhu0W8yeNO3ZfeW7bLQ== X-Received: by 2002:a05:600c:1990:: with SMTP id t16mr1549640wmq.45.1630566067939; Thu, 02 Sep 2021 00:01:07 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Kevin Wolf , Fam Zheng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Klaus Jensen , Hanna Reitz , Auger Eric , qemu-block@nongnu.org, Stefan Hajnoczi Subject: [PATCH v3 09/11] util/vfio-helpers: Simplify qemu_vfio_dma_map() returning directly Date: Thu, 2 Sep 2021 09:00:23 +0200 Message-Id: <20210902070025.197072-10-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210902070025.197072-1-philmd@redhat.com> References: <20210902070025.197072-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: 1630566072755100003 To simplify qemu_vfio_dma_map(): - reduce 'ret' (returned value) scope by returning errno directly, - remove the goto 'out' label. Reviewed-by: Klaus Jensen 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 b93a3d35787..66148bd381c 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -748,7 +748,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; @@ -761,32 +760,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)) { - 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; } } } @@ -794,8 +792,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 Wed May 1 15:04:29 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=1630566075; cv=none; d=zohomail.com; s=zohoarc; b=TGzTCpPh+DMmca9cTHWbJtnbRqgluJXfH0UhLbe81Wt34kY5O42oHc46y56QPeRNZDrgD7vAvlrHUWIAz+UtJjgg1lW5sYxxFvlNAQJqEOmTxBxxgkPGmnZ3bZ1tkNa9i2TktSqtzQrFkHzf0hRY7vD4exxX3g9ea4AibFEHEqA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630566075; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=CveArVIYmhyoj6c5Fi4UZZ4/p/tOfu6mARhUZq6eESQ=; b=SswZWppRg2Ul3lFX37Reqmt+LkDjnEn1R8ofPtVSn5Eb1FvW8EOijpL4mgc8RKUelsJmPCnbIRuip93BXrQhI27Bn1AlFhVLk1/HOZhtsh5QnEEqHZvN7Kr9PI96qnENUf+jOY0cLOZkdi3u3/Nta24GYMpZhV7Q7JLSuWs/IDY= 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 1630566075979362.26768452181545; Thu, 2 Sep 2021 00:01:15 -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-303-qgQPJ4cHMPWc3whlSBuxLQ-1; Thu, 02 Sep 2021 03:01:13 -0400 Received: by mail-wr1-f71.google.com with SMTP id p18-20020a5d4e12000000b0015940dc586aso213846wrt.6 for ; Thu, 02 Sep 2021 00:01:13 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id u23sm778635wmc.24.2021.09.02.00.01.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 00:01:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630566074; 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=CveArVIYmhyoj6c5Fi4UZZ4/p/tOfu6mARhUZq6eESQ=; b=TvdvEbKGR5neCYZ1td5WpHJBMMLEKNqLPFLIoMMOXpKz9JA3eKRmMseIAxXho2tW+SdP/z gsyponFJbm5p+5bKqyqk9MCY3PHmLzZ8GMP5wyeTi5hQgyp51TumMedlu3bDyV9N/GGjwW r4aKqiPy65hfx6G//jdpT4W4Aw+SJno= X-MC-Unique: qgQPJ4cHMPWc3whlSBuxLQ-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=CveArVIYmhyoj6c5Fi4UZZ4/p/tOfu6mARhUZq6eESQ=; b=RIeiJL82Jfzy/4trkq9/is8y7q0UjKEUxPhbrPIbyN5sCSMT4bKJInfQl9mVnHkLpB p57lIPjqQqcvz8+w9/vYzu/uEeuvu1a9QKtSZNOCGMEbsDqkZjm+Dj0HpLC4MRcGZBB9 YXMAIouiPLrVFcD0JoJIvZcXHZFkwohzURC/4Xax4FzNV86kLF4QOsJv9CYD0rsv3t7E FxbrMyWCLsOG9F5NiN7fhBWD7GQ37Wj+BSlgEdJlcYPu2mfXTyNX2EHbsno973AQxvgs 43pBI8rl9PHnDFx2WMGHZ8LcwMxdQe2rnDHcLIOtT+FS007WWUkivY8wveajx0IIVe/Z 49yg== X-Gm-Message-State: AOAM532Ehk9vGmuWGKP71QGXP6c6zV+qftuOaH3TqbWiG8+tDa+6TDe+ 7nWHcCbLuEN07Q+TA/o3ACq3PFhaOjph7BgU09EsnoyYX+wuaKIicBhgpFbj4EeHmGWMuKqPkpm EAAh4yqCdSBzOMg== X-Received: by 2002:adf:80eb:: with SMTP id 98mr1809805wrl.370.1630566072530; Thu, 02 Sep 2021 00:01:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4cCgFXqYbqpIcYIDGgAkPdhj+JBLV5vosy8EkcujXb1DylNVuH1toQDPYsHXqMoUFzUH9OA== X-Received: by 2002:adf:80eb:: with SMTP id 98mr1809790wrl.370.1630566072379; Thu, 02 Sep 2021 00:01:12 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Kevin Wolf , Fam Zheng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Klaus Jensen , Hanna Reitz , Auger Eric , qemu-block@nongnu.org, Stefan Hajnoczi Subject: [PATCH v3 10/11] util/vfio-helpers: Let qemu_vfio_do_mapping() propagate Error Date: Thu, 2 Sep 2021 09:00:24 +0200 Message-Id: <20210902070025.197072-11-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210902070025.197072-1-philmd@redhat.com> References: <20210902070025.197072-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: 1630566076598100001 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 Reviewed-by: Klaus Jensen 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 66148bd381c..00a80431a09 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; @@ -772,7 +772,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; @@ -782,7 +782,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 Wed May 1 15:04:29 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=1630566085; cv=none; d=zohomail.com; s=zohoarc; b=aYxsDYU9PYw0XBJoeeowWCRZCwd0AfowuQOWAi9Hovhd5ewhWGzNMEAFLdtOLyJMbEzIzdd9WfoLARZgVvlPqbl/rCZnzf+aV8PEXXKRUQgphqX3xgMtYPR//1LGXSfTHsLfRbGYEcR+xPEnFKvIgnCl8NBsuiLGcplPyUM3Kq8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630566085; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=ojj+ZaFHzvapR5Yklu/beV4VWQwhlVBhI7TMjzFMewk=; b=XekjlVyrxuQCio4Y8MK78aH5kVYnMCwmpT/5aV0WBg/UCdVxp19Qhbay5NFS6kkpo9/Pc5Zp6ih2XFh98/V6PTCegGIRnCfP6o7mLOLj2pUBy7GpX7WfH7YpL8SRWHDZRy3Y9X/774+/2P9p0XfmnPt5mrHtZvooKDf+Wgym12s= 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 1630566085246892.2950513516448; Thu, 2 Sep 2021 00:01:25 -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-357-1XvQpjEfOICo18Ewxs2gkA-1; Thu, 02 Sep 2021 03:01:23 -0400 Received: by mail-wr1-f71.google.com with SMTP id r17-20020adfda510000b02901526f76d738so223340wrl.0 for ; Thu, 02 Sep 2021 00:01:23 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id x9sm730430wmi.30.2021.09.02.00.01.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 00:01:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630566084; 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=UQsHQemR7unS/BVaaoV7K9RhUVg/+RIlJHkKLCoe7ribMidrqn3AME0enlrFyTcyOF0iID yLaKgdzfUgCQIJ74Ozrg7hIQOmfBI/G6aa1pZ8/YH5ReSFinly+zecdzBm/3C1wdSjPHhR Lj9KYnjX4pi4I8CGMpLakv3sMoibDWQ= X-MC-Unique: 1XvQpjEfOICo18Ewxs2gkA-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=HgWHwaTBg6nsLD7YoRdFrfFF+a0EXjcvGz7NlxART6OxUNHfdcuL2/ZvOt6CaRyC2z glgs4LRcwhku5Ty46+e4DXjbhhCNOOWRp3So1q5Ch5xSs6R/kbxK86sZiYQoyKYKEa5z zG0jgGCD76i1fBY/h2cNJjDhv5jISh/2YbWUcCwlxX/kCTNUvoI3Aa2A6Xt4Nl6rCqkZ YRScITcr+kzTUbGscGzjxtSJbg6jv9C8UZRSDnCbGUFz7zwx8C0jz89L0dYC74iL2//3 9cpRMSgu1Li98Hf2XCRzI3HC1d0UbkfJEtkrYZHEgyiXYNuLbGbTQWmB1kbyESeivW/e 5tyw== X-Gm-Message-State: AOAM530UH7+Jy1zVBQXeewY47/8GgIQhL9mwPc42KDGyy8Cw5CUCEyXu 9tyjLrbv3Lr6BupFFeFpnCoKljb3easGFE/qMC7Bfc7szL681Dwb4/XlL8ewPM4nvsIsdU1cnnZ RJxHwZJVIqOGNyQ== X-Received: by 2002:a1c:2bc6:: with SMTP id r189mr1552956wmr.183.1630566077257; Thu, 02 Sep 2021 00:01:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjPO9+j1p/lKqPtGN0rof7wAaE3gOLxBrOL6tvfx4iDsgGjr5PR5vnT1yie2pRi8nThH0dNQ== X-Received: by 2002:a1c:2bc6:: with SMTP id r189mr1552943wmr.183.1630566077058; Thu, 02 Sep 2021 00:01:17 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Kevin Wolf , Fam Zheng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Klaus Jensen , Hanna Reitz , Auger Eric , qemu-block@nongnu.org, Stefan Hajnoczi , Tingting Mao Subject: [PATCH v3 11/11] block/nvme: Only report VFIO error on failed retry Date: Thu, 2 Sep 2021 09:00:25 +0200 Message-Id: <20210902070025.197072-12-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210902070025.197072-1-philmd@redhat.com> References: <20210902070025.197072-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: 1630566086091100001 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