From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZhCdB-0003TP-6t for qemu-devel@nongnu.org; Wed, 30 Sep 2015 04:20:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZhCd7-0001yQ-V6 for qemu-devel@nongnu.org; Wed, 30 Sep 2015 04:20:53 -0400 References: <1443579237-9636-1-git-send-email-david@gibson.dropbear.id.au> <1443579237-9636-3-git-send-email-david@gibson.dropbear.id.au> From: Laurent Vivier Message-ID: <560B9B5D.7010509@redhat.com> Date: Wed, 30 Sep 2015 10:20:45 +0200 MIME-Version: 1.0 In-Reply-To: <1443579237-9636-3-git-send-email-david@gibson.dropbear.id.au> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCHv3 2/7] vfio: Generalize vfio_listener_region_add failure path List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson , alex.williamson@redhat.com, pbonzini@redhat.com Cc: thuth@redhat.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, aik@ozlabs.ru, abologna@redhat.com, gwshan@linux.vnet.ibm.com, qemu-ppc@nongnu.org On 30/09/2015 04:13, David Gibson wrote: > 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 > Reviewed-by: Thomas Huth > Reviewed-by: Laurent Vivier > --- > 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"); > } > } > > Reviewed-by: Laurent Vivier