From patchwork Thu May 8 18:52:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 347179 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 CF73F1400DF for ; Fri, 9 May 2014 04:57:33 +1000 (EST) Received: from localhost ([::1]:48890 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WiTVb-0004iF-NX for incoming@patchwork.ozlabs.org; Thu, 08 May 2014 14:57:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54194) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WiTRi-00084y-TH for qemu-devel@nongnu.org; Thu, 08 May 2014 14:53:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WiTRc-0008Pt-K2 for qemu-devel@nongnu.org; Thu, 08 May 2014 14:53:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14579) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WiTRc-0008Pb-Cq for qemu-devel@nongnu.org; Thu, 08 May 2014 14:53:24 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s48IrKki026813 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 8 May 2014 14:53:20 -0400 Received: from localhost (ovpn-113-20.phx2.redhat.com [10.3.113.20]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s48IrKgf001856; Thu, 8 May 2014 14:53:20 -0400 From: Luiz Capitulino To: peter.maydell@linaro.org Date: Thu, 8 May 2014 14:52:39 -0400 Message-Id: <1399575182-9768-16-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.24 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 15/38] pci-assign: propagate errors from get_real_device() 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 | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/hw/i386/kvm/pci-assign.c b/hw/i386/kvm/pci-assign.c index e89bb6a..c6d1094 100644 --- a/hw/i386/kvm/pci-assign.c +++ b/hw/i386/kvm/pci-assign.c @@ -532,7 +532,7 @@ static void get_real_device_id(const char *devpath, uint16_t *val, get_real_id(devpath, "device", val, errp); } -static int get_real_device(AssignedDevice *pci_dev) +static void get_real_device(AssignedDevice *pci_dev, Error **errp) { char dir[128], name[128]; int fd, r = 0; @@ -556,16 +556,15 @@ static int get_real_device(AssignedDevice *pci_dev) pci_dev->configfd_name, &local_err); if (local_err) { - qerror_report_err(local_err); - error_free(local_err); - return 1; + error_propagate(errp, local_err); + return; } } else { dev->config_fd = open(name, O_RDWR); if (dev->config_fd == -1) { - error_report("%s: %s: %m", __func__, name); - return 1; + error_setg_file_open(errp, errno, name); + return; } } again: @@ -575,8 +574,10 @@ again: if (errno == EINTR || errno == EAGAIN) { goto again; } - error_report("%s: read failed, errno = %d", __func__, errno); - return 1; + error_setg_errno(errp, errno, "read(\"%s\")", + (pci_dev->configfd_name && *pci_dev->configfd_name) ? + pci_dev->configfd_name : name); + return; } /* Restore or clear multifunction, this is always controlled by qemu */ @@ -596,8 +597,8 @@ again: f = fopen(name, "r"); if (f == NULL) { - error_report("%s: %s: %m", __func__, name); - return 1; + error_setg_file_open(errp, errno, name); + return; } for (r = 0; r < PCI_ROM_SLOT; r++) { @@ -642,9 +643,8 @@ again: /* read and fill vendor ID */ get_real_vendor_id(dir, &id, &local_err); if (local_err) { - error_report("%s", error_get_pretty(local_err)); - error_free(local_err); - return 1; + error_propagate(errp, local_err); + return; } pci_dev->dev.config[0] = id & 0xff; pci_dev->dev.config[1] = (id & 0xff00) >> 8; @@ -652,9 +652,8 @@ again: /* read and fill device ID */ get_real_device_id(dir, &id, &local_err); if (local_err) { - error_report("%s", error_get_pretty(local_err)); - error_free(local_err); - return 1; + error_propagate(errp, local_err); + return; } pci_dev->dev.config[2] = id & 0xff; pci_dev->dev.config[3] = (id & 0xff00) >> 8; @@ -663,7 +662,6 @@ again: PCI_COMMAND_MASTER | PCI_COMMAND_INTX_DISABLE); dev->region_number = r; - return 0; } static void free_msi_virqs(AssignedDevice *dev) @@ -1751,6 +1749,7 @@ static int assigned_initfn(struct PCIDevice *pci_dev) AssignedDevice *dev = DO_UPCAST(AssignedDevice, dev, pci_dev); uint8_t e_intx; int r; + Error *local_err = NULL; if (!kvm_enabled()) { error_report("pci-assign: error: requires KVM support"); @@ -1783,9 +1782,10 @@ static int assigned_initfn(struct PCIDevice *pci_dev) memcpy(dev->emulate_config_write, dev->emulate_config_read, sizeof(dev->emulate_config_read)); - if (get_real_device(dev)) { - error_report("pci-assign: Error: Couldn't get real device (%s)!", - dev->dev.qdev.id); + get_real_device(dev, &local_err); + if (local_err) { + qerror_report_err(local_err); + error_free(local_err); goto out; }