From: Alex Williamson <alex.williamson@redhat.com>
To: qemu-devel@nongnu.org
Cc: Laurent Vivier <lvivier@redhat.com>,
Thomas Huth <thuth@redhat.com>,
David Gibson <david@gibson.dropbear.id.au>
Subject: [Qemu-devel] [PULL 5/9] vfio: Generalize vfio_listener_region_add failure path
Date: Wed, 07 Oct 2015 09:43:21 -0600 [thread overview]
Message-ID: <20151007154321.22135.51315.stgit@gimli.home> (raw)
In-Reply-To: <20151007153840.22135.78451.stgit@gimli.home>
From: David Gibson <david@gibson.dropbear.id.au>
If a DMA mapping operation fails in vfio_listener_region_add() it
checks to see if we've already completed initial setup of the
container. If so it reports an error so the setup code can fail
gracefully, otherwise throws a hw_error().
There are other potential failure cases in vfio_listener_region_add()
which could benefit from the same logic, so move it to its own
fail: block. Later patches can use this to extend other failure cases
to fail as gracefully as possible under the circumstances.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
hw/vfio/common.c | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 1545f62..95a4850 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -399,19 +399,23 @@ static void vfio_listener_region_add(MemoryListener *listener,
error_report("vfio_dma_map(%p, 0x%"HWADDR_PRIx", "
"0x%"HWADDR_PRIx", %p) = %d (%m)",
container, iova, end - iova, vaddr, ret);
+ goto fail;
+ }
- /*
- * On the initfn path, store the first error in the container so we
- * can gracefully fail. Runtime, there's not much we can do other
- * than throw a hardware error.
- */
- if (!container->initialized) {
- if (!container->error) {
- container->error = ret;
- }
- } else {
- hw_error("vfio: DMA mapping failed, unable to continue");
+ return;
+
+fail:
+ /*
+ * On the initfn path, store the first error in the container so we
+ * can gracefully fail. Runtime, there's not much we can do other
+ * than throw a hardware error.
+ */
+ if (!container->initialized) {
+ if (!container->error) {
+ container->error = ret;
}
+ } else {
+ hw_error("vfio: DMA mapping failed, unable to continue");
}
}
next prev parent reply other threads:[~2015-10-07 15:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-07 15:42 [Qemu-devel] [PULL 0/9] VFIO updates for 2015-10-07 Alex Williamson
2015-10-07 15:42 ` [Qemu-devel] [PULL 1/9] hw/vfio/platform: irqfd setup sequence update Alex Williamson
2015-10-07 15:43 ` [Qemu-devel] [PULL 2/9] hw/vfio/platform: change interrupt/unmask fields into pointer Alex Williamson
2015-10-07 15:43 ` [Qemu-devel] [PULL 3/9] hw/vfio/platform: do not set resamplefd for edge-sensitive IRQS Alex Williamson
2015-10-07 15:43 ` [Qemu-devel] [PULL 4/9] vfio: Remove unneeded union from VFIOContainer Alex Williamson
2015-10-07 15:43 ` Alex Williamson [this message]
2015-10-07 15:43 ` [Qemu-devel] [PULL 6/9] vfio: Check guest IOVA ranges against host IOMMU capabilities Alex Williamson
2015-10-07 15:43 ` [Qemu-devel] [PULL 7/9] vfio: Record host IOMMU's available IO page sizes Alex Williamson
2015-10-07 15:43 ` [Qemu-devel] [PULL 8/9] memory: Allow replay of IOMMU mapping notifications Alex Williamson
2015-10-07 15:43 ` [Qemu-devel] [PULL 9/9] vfio: Allow hotplug of containers onto existing guest IOMMU mappings Alex Williamson
2015-10-08 17:00 ` [Qemu-devel] [PULL 0/9] VFIO updates for 2015-10-07 Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151007154321.22135.51315.stgit@gimli.home \
--to=alex.williamson@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=lvivier@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).