From patchwork Fri Nov 27 00:58:57 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 39598 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C62C61007D1 for ; Fri, 27 Nov 2009 12:11:42 +1100 (EST) Received: from localhost ([127.0.0.1]:44874 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NDpN3-0007gp-Or for incoming@patchwork.ozlabs.org; Thu, 26 Nov 2009 20:11:37 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NDpBW-0001fe-BD for qemu-devel@nongnu.org; Thu, 26 Nov 2009 19:59:42 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NDpBR-0001cx-73 for qemu-devel@nongnu.org; Thu, 26 Nov 2009 19:59:41 -0500 Received: from [199.232.76.173] (port=48293 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NDpBQ-0001cs-PS for qemu-devel@nongnu.org; Thu, 26 Nov 2009 19:59:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:2348) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NDpBQ-0004Q9-6K for qemu-devel@nongnu.org; Thu, 26 Nov 2009 19:59:36 -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.13.8/8.13.8) with ESMTP id nAR0xZRr020812 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 26 Nov 2009 19:59:35 -0500 Received: from localhost (vpn-10-232.rdu.redhat.com [10.11.10.232]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nAR0xX3Y006937; Thu, 26 Nov 2009 19:59:34 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Thu, 26 Nov 2009 22:58:57 -0200 Message-Id: <1259283550-3597-8-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1259283550-3597-1-git-send-email-lcapitulino@redhat.com> References: <1259283550-3597-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: aliguori@us.ibm.com, avi@redhat.com, armbru@redhat.com Subject: [Qemu-devel] [PATCH 07/20] QError: Add errors needed by QMP X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Only QERR_QMP_BAD_INPUT_OBJECT is QMP specific, the others can be used in different contexts by other subsystems. Please, note that QERR_JSON_PARSING signals any parsing error from the json parser. We will need it until the parser gets updated to use QError. Signed-off-by: Luiz Capitulino --- qerror.c | 24 ++++++++++++++++++++++++ qerror.h | 18 ++++++++++++++++++ 2 files changed, 42 insertions(+), 0 deletions(-) diff --git a/qerror.c b/qerror.c index d8b125e..6560996 100644 --- a/qerror.c +++ b/qerror.c @@ -41,6 +41,10 @@ static const QType qerror_type = { */ const QErrorStringTable qerror_table[] = { { + .error_fmt = QERR_COMMAND_NOT_FOUND, + .desc = "The command %(name) has not been found", + }, + { .error_fmt = QERR_DEVICE_NOT_FOUND, .desc = "The %(device) device has not been found", }, @@ -49,9 +53,29 @@ const QErrorStringTable qerror_table[] = { .desc = "The %(device) device has not been activated by the guest", }, { + .error_fmt = QERR_INVALID_PARAMETER_TYPE, + .desc = "Invalid parameter type, expected: %(expected)", + }, + { .error_fmt = QERR_KVM_MISSING_CAP, .desc = "Using KVM without %(capability), %(feature) unavailable", }, + { + .error_fmt = QERR_MISSING_PARAMETER, + .desc = "Parameter %(name) is missing", + }, + { + .error_fmt = QERR_QMP_BAD_INPUT_OBJECT, + .desc = "Bad QMP input object", + }, + { + .error_fmt = QERR_JSON_PARSING, + .desc = "Invalid JSON synaxt", + }, + { + .error_fmt = QERR_UNDEFINED_ERROR, + .desc = "An undefined error has ocurred", + }, {} }; diff --git a/qerror.h b/qerror.h index 6c100af..5fd9931 100644 --- a/qerror.h +++ b/qerror.h @@ -38,13 +38,31 @@ QError *qobject_to_qerror(const QObject *obj); /* * QError class list */ +#define QERR_COMMAND_NOT_FOUND \ + "{ 'class': 'CommandNotFound', 'data': { 'name': %s } }" + #define QERR_DEVICE_NOT_FOUND \ "{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }" #define QERR_DEVICE_NOT_ACTIVE \ "{ 'class': 'DeviceNotActive', 'data': { 'device': %s } }" +#define QERR_INVALID_PARAMETER_TYPE \ + "{ 'class': 'InvalidParameterType', 'data': { 'name': %s,'expected': %s } }" + #define QERR_KVM_MISSING_CAP \ "{ 'class': 'KVMMissingCap', 'data': { 'capability': %s, 'feature': %s } }" +#define QERR_MISSING_PARAMETER \ + "{ 'class': 'MissingParameter', 'data': { 'name': %s } }" + +#define QERR_QMP_BAD_INPUT_OBJECT \ + "{ 'class': 'QMPBadInputObject', 'data': { 'expected': %s } }" + +#define QERR_JSON_PARSING \ + "{ 'class': 'JSONParsing', 'data': {} }" + +#define QERR_UNDEFINED_ERROR \ + "{ 'class': 'UndefinedError', 'data': {} }" + #endif /* QERROR_H */