[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 5/9] vfio: Generalize vfio_listener_region_add failur
From: |
Alex Williamson |
Subject: |
[Qemu-devel] [PULL 5/9] vfio: Generalize vfio_listener_region_add failure path |
Date: |
Wed, 07 Oct 2015 09:43:21 -0600 |
User-agent: |
StGit/0.17.1-dirty |
From: David Gibson <address@hidden>
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 <address@hidden>
Reviewed-by: Thomas Huth <address@hidden>
Reviewed-by: Laurent Vivier <address@hidden>
Signed-off-by: Alex Williamson <address@hidden>
---
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");
}
}
- [Qemu-devel] [PULL 0/9] VFIO updates for 2015-10-07, Alex Williamson, 2015/10/08
- [Qemu-devel] [PULL 2/9] hw/vfio/platform: change interrupt/unmask fields into pointer, Alex Williamson, 2015/10/08
- [Qemu-devel] [PULL 6/9] vfio: Check guest IOVA ranges against host IOMMU capabilities, Alex Williamson, 2015/10/08
- [Qemu-devel] [PULL 4/9] vfio: Remove unneeded union from VFIOContainer, Alex Williamson, 2015/10/08
- [Qemu-devel] [PULL 9/9] vfio: Allow hotplug of containers onto existing guest IOMMU mappings, Alex Williamson, 2015/10/08
- [Qemu-devel] [PULL 5/9] vfio: Generalize vfio_listener_region_add failure path,
Alex Williamson <=
- [Qemu-devel] [PULL 7/9] vfio: Record host IOMMU's available IO page sizes, Alex Williamson, 2015/10/08
- [Qemu-devel] [PULL 8/9] memory: Allow replay of IOMMU mapping notifications, Alex Williamson, 2015/10/08
- [Qemu-devel] [PULL 1/9] hw/vfio/platform: irqfd setup sequence update, Alex Williamson, 2015/10/08
- [Qemu-devel] [PULL 3/9] hw/vfio/platform: do not set resamplefd for edge-sensitive IRQS, Alex Williamson, 2015/10/08
- Re: [Qemu-devel] [PULL 0/9] VFIO updates for 2015-10-07, Peter Maydell, 2015/10/09