Received: from eggs.gnu.org ([208.118.235.92]:51560) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1KXQ-0005jT-C1 for qemu-devel@nongnu.org; Fri, 01 Feb 2013 12:36:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U1KXM-0006H7-IM for qemu-devel@nongnu.org; Fri, 01 Feb 2013 12:36:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57144) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1KXM-0006Gv-Al for qemu-devel@nongnu.org; Fri, 01 Feb 2013 12:36:28 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r11HaRD6027520 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 1 Feb 2013 12:36:27 -0500 From: Laszlo Ersek Date: Fri, 1 Feb 2013 18:38:18 +0100 Message-Id: <1359740299-27968-7-git-send-email-lersek@redhat.com> In-Reply-To: <1359740299-27968-1-git-send-email-lersek@redhat.com> References: <1359740299-27968-1-git-send-email-lersek@redhat.com> Subject: [Qemu-devel] [PATCH 6/7] qbus_find(): report errors via Error List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: lcapitulino@redhat.com, qemu-devel@nongnu.org Signed-off-by: Laszlo Ersek --- hw/qdev-monitor.c | 29 +++++++++++++++-------------- 1 files changed, 15 insertions(+), 14 deletions(-) diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c index 83540fc..0c01b04 100644 --- a/hw/qdev-monitor.c +++ b/hw/qdev-monitor.c @@ -324,7 +324,7 @@ static BusState *qbus_find_recursive(BusState *bus, const char *name, return NULL; } -static BusState *qbus_find(const char *path) +static BusState *qbus_find(const char *path, Error **errp) { DeviceState *dev; BusState *bus; @@ -336,20 +336,19 @@ static BusState *qbus_find(const char *path) bus = sysbus_get_default(); pos = 0; } else { - Error *err = NULL; + Error *find_err = NULL; if (sscanf(path, "%127[^/]%n", elem, &len) != 1) { assert(!path[0]); elem[0] = len = 0; } - bus = qbus_find_recursive(sysbus_get_default(), elem, NULL, &err); + bus = qbus_find_recursive(sysbus_get_default(), elem, NULL, &find_err); if (!bus) { - if (error_is_set(&err)) { - qerror_report_err(err); - error_free(err); - } else { - qerror_report(QERR_BUS_NOT_FOUND, elem); - } + Error *not_found; + + error_set(¬_found, QERR_BUS_NOT_FOUND, elem); + error_propagate(errp, find_err); + error_propagate(errp, not_found); return NULL; } pos = len; @@ -372,7 +371,7 @@ static BusState *qbus_find(const char *path) pos += len; dev = qbus_find_dev(bus, elem); if (!dev) { - qerror_report(QERR_DEVICE_NOT_FOUND, elem); + error_set(errp, QERR_DEVICE_NOT_FOUND, elem); if (!monitor_cur_is_qmp()) { qbus_list_dev(bus); } @@ -388,12 +387,12 @@ static BusState *qbus_find(const char *path) * one child bus accept it nevertheless */ switch (dev->num_child_bus) { case 0: - qerror_report(QERR_DEVICE_NO_BUS, elem); + error_set(errp, QERR_DEVICE_NO_BUS, elem); return NULL; case 1: return QLIST_FIRST(&dev->child_bus); default: - qerror_report(QERR_DEVICE_MULTIPLE_BUSSES, elem); + error_set(errp, QERR_DEVICE_MULTIPLE_BUSSES, elem); if (!monitor_cur_is_qmp()) { qbus_list_bus(dev); } @@ -409,7 +408,7 @@ static BusState *qbus_find(const char *path) pos += len; bus = qbus_find_bus(dev, elem); if (!bus) { - qerror_report(QERR_BUS_NOT_FOUND, elem); + error_set(errp, QERR_BUS_NOT_FOUND, elem); if (!monitor_cur_is_qmp()) { qbus_list_bus(dev); } @@ -454,8 +453,10 @@ DeviceState *qdev_device_add(QemuOpts *opts) /* find bus */ path = qemu_opt_get(opts, "bus"); if (path != NULL) { - bus = qbus_find(path); + bus = qbus_find(path, &local_err); if (!bus) { + qerror_report_err(local_err); + error_free(local_err); return NULL; } if (!object_dynamic_cast(OBJECT(bus), k->bus_type)) { -- 1.7.1