From patchwork Thu May 8 18:52:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 347238 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C62151400A3 for ; Fri, 9 May 2014 06:52:11 +1000 (EST) Received: from localhost ([::1]:48922 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WiTYN-0008RC-O4 for incoming@patchwork.ozlabs.org; Thu, 08 May 2014 15:00:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54302) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WiTRo-0008Gq-VN for qemu-devel@nongnu.org; Thu, 08 May 2014 14:53:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WiTRg-0008Rx-O3 for qemu-devel@nongnu.org; Thu, 08 May 2014 14:53:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:62185) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WiTRg-0008Rh-F6 for qemu-devel@nongnu.org; Thu, 08 May 2014 14:53:28 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s48IrOSD006852 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 8 May 2014 14:53:25 -0400 Received: from localhost (ovpn-113-20.phx2.redhat.com [10.3.113.20]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s48IrOwf007407; Thu, 8 May 2014 14:53:24 -0400 From: Luiz Capitulino To: peter.maydell@linaro.org Date: Thu, 8 May 2014 14:52:45 -0400 Message-Id: <1399575182-9768-22-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1399575182-9768-1-git-send-email-lcapitulino@redhat.com> References: <1399575182-9768-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org, anthony@codemonkey.ws Subject: [Qemu-devel] [PULL 21/38] pci-assign: assigned_initfn(): set monitor error in common error handler X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Laszlo Ersek Signed-off-by: Laszlo Ersek Reviewed-by: Eric Blake Signed-off-by: Luiz Capitulino --- hw/i386/kvm/pci-assign.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/hw/i386/kvm/pci-assign.c b/hw/i386/kvm/pci-assign.c index 6891729..e55421a 100644 --- a/hw/i386/kvm/pci-assign.c +++ b/hw/i386/kvm/pci-assign.c @@ -1756,14 +1756,14 @@ static int assigned_initfn(struct PCIDevice *pci_dev) Error *local_err = NULL; if (!kvm_enabled()) { - error_report("pci-assign: error: requires KVM support"); - return -1; + error_setg(&local_err, "pci-assign requires KVM support"); + goto exit_with_error; } if (!dev->host.domain && !dev->host.bus && !dev->host.slot && !dev->host.function) { - error_report("pci-assign: error: no host device specified"); - return -1; + error_setg(&local_err, "no host device specified"); + goto exit_with_error; } /* @@ -1788,14 +1788,10 @@ static int assigned_initfn(struct PCIDevice *pci_dev) get_real_device(dev, &local_err); if (local_err) { - qerror_report_err(local_err); - error_free(local_err); goto out; } if (assigned_device_pci_cap_init(pci_dev, &local_err) < 0) { - qerror_report_err(local_err); - error_free(local_err); goto out; } @@ -1803,8 +1799,6 @@ static int assigned_initfn(struct PCIDevice *pci_dev) if (dev->cap.available & ASSIGNED_DEVICE_CAP_MSIX) { assigned_dev_register_msix_mmio(dev, &local_err); if (local_err) { - qerror_report_err(local_err); - error_free(local_err); goto out; } } @@ -1814,8 +1808,6 @@ static int assigned_initfn(struct PCIDevice *pci_dev) dev->real_device.region_number, dev, &local_err); if (local_err) { - qerror_report_err(local_err); - error_free(local_err); goto out; } @@ -1828,16 +1820,12 @@ static int assigned_initfn(struct PCIDevice *pci_dev) /* assign device to guest */ assign_device(dev, &local_err); if (local_err) { - qerror_report_err(local_err); - error_free(local_err); goto out; } /* assign legacy INTx to the device */ r = assign_intx(dev, &local_err); if (r < 0) { - qerror_report_err(local_err); - error_free(local_err); goto assigned_out; } @@ -1849,8 +1837,14 @@ static int assigned_initfn(struct PCIDevice *pci_dev) assigned_out: deassign_device(dev); + out: free_assigned_device(dev); + +exit_with_error: + assert(local_err); + qerror_report_err(local_err); + error_free(local_err); return -1; }