From patchwork Thu Jan 28 21:41:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Llu=C3=ADs_Vilanova?= X-Patchwork-Id: 8154271 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7920D9F9A0 for ; Thu, 28 Jan 2016 21:43:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6ECCA20211 for ; Thu, 28 Jan 2016 21:43:35 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id B56AB2020F for ; Thu, 28 Jan 2016 21:43:34 +0000 (UTC) Received: from localhost ([::1]:58677 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOuLm-0006kU-5O for patchwork-qemu-devel@patchwork.kernel.org; Thu, 28 Jan 2016 16:43:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45974) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOuK3-0003Jc-4G for qemu-devel@nongnu.org; Thu, 28 Jan 2016 16:41:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aOuK1-0001Oi-41 for qemu-devel@nongnu.org; Thu, 28 Jan 2016 16:41:47 -0500 Received: from roura.ac.upc.es ([147.83.33.10]:37173) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOuK0-0001OU-OD for qemu-devel@nongnu.org; Thu, 28 Jan 2016 16:41:45 -0500 Received: from gw-2.ac.upc.es (gw-2.ac.upc.es [147.83.30.8]) by roura.ac.upc.es (8.13.8/8.13.8) with ESMTP id u0SLfhfS020247; Thu, 28 Jan 2016 22:41:43 +0100 Received: from localhost (unknown [84.88.51.85]) by gw-2.ac.upc.es (Postfix) with ESMTPSA id 6805FA6; Thu, 28 Jan 2016 22:41:43 +0100 (CET) From: =?utf-8?b?TGx1w61z?= Vilanova To: qemu-devel@nongnu.org Date: Thu, 28 Jan 2016 22:41:43 +0100 Message-Id: <145401730295.31479.7043845714018218355.stgit@localhost> X-Mailer: git-send-email 2.7.0.rc3 In-Reply-To: <145401727502.31479.11571397180565966513.stgit@localhost> References: <145401727502.31479.11571397180565966513.stgit@localhost> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-MIME-Autoconverted: from 8bit to quoted-printable by roura.ac.upc.es id u0SLfhfS020247 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 147.83.33.10 Cc: Stefan Hajnoczi , Thomas Huth , "Dr . David Alan Gilbert" , Markus Armbruster Subject: [Qemu-devel] [PATCH v4 5/5] doc: Introduce coding style for errors 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Gives some general guidelines for reporting errors in QEMU. Signed-off-by: LluĂ­s Vilanova --- HACKING | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/HACKING b/HACKING index 12fbc8a..f5783d4 100644 --- a/HACKING +++ b/HACKING @@ -157,3 +157,36 @@ painful. These are: * you may assume that integers are 2s complement representation * you may assume that right shift of a signed integer duplicates the sign bit (ie it is an arithmetic shift, not a logical shift) + +7. Error reporting + +QEMU provides various mechanisms for reporting errors using a uniform format, +ensuring the user will receive them (e.g., shown in QMP when necessary). You +should use one of these mechanisms instead of manually reporting them (i.e., do +not use 'printf()', 'exit()' or 'abort()'). + +7.1. Simple error messages + +The 'error_report*()' functions in "include/qemu/error-report.h" will +immediately report error messages to the user. + +WARNING: Do *not* use 'error_report_fatal()' or 'error_report_abort()' for +errors that are (or can be) triggered by guest code (e.g., some unimplimented +corner case in guest code translation or device code). Otherwise that can be +abused by guest code to terminate QEMU. Instead, you should use +'error_report()'. + +7.2. Errors in user inputs + +The 'loc_*()' functions in "include/qemu/error-report.h" will extend the +messages from 'error_report*()' with references to locations in inputs provided +by the user (e.g., command line arguments or configuration files). + +7.3. More complex error management + +The functions in "include/qapi/error.h" can be used to accumulate error messages +in an 'Error' object, which can be propagated up the call chain where it is +finally reported. + +WARNING: The special 'error_fatal' and 'error_abort' objects follow the same +constrains as the 'error_report_fatal' and 'error_report_abort' functions.