Commit ac6dc389 authored by David Gibson's avatar David Gibson Committed by Alex Williamson
Browse files

vfio: Generalize vfio_listener_region_add failure path



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: default avatarDavid Gibson <david@gibson.dropbear.id.au>
Reviewed-by: default avatarThomas Huth <thuth@redhat.com>
Reviewed-by: default avatarLaurent Vivier <lvivier@redhat.com>
Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
parent ee0bf0e5
Loading
Loading
Loading
Loading
+15 −11
Original line number Diff line number Diff line
@@ -399,7 +399,12 @@ 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;
    }

    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
@@ -413,7 +418,6 @@ static void vfio_listener_region_add(MemoryListener *listener,
        hw_error("vfio: DMA mapping failed, unable to continue");
    }
}
}

static void vfio_listener_region_del(MemoryListener *listener,
                                     MemoryRegionSection *section)