From patchwork Thu Aug 18 05:28:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 660323 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sFF6M68ZGz9t1G for ; Thu, 18 Aug 2016 15:30:03 +1000 (AEST) Received: from localhost ([::1]:50836 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1baFtx-0003ya-Mm for incoming@patchwork.ozlabs.org; Thu, 18 Aug 2016 01:30:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40493) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1baFsU-0002sC-Lm for qemu-devel@nongnu.org; Thu, 18 Aug 2016 01:28:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1baFsO-0008Ls-BA for qemu-devel@nongnu.org; Thu, 18 Aug 2016 01:28:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45738) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1baFsO-0008Lo-5c for qemu-devel@nongnu.org; Thu, 18 Aug 2016 01:28:24 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C4BCE81127; Thu, 18 Aug 2016 05:28:23 +0000 (UTC) Received: from pxdev.xzpeter.org (vpn1-5-7.pek2.redhat.com [10.72.5.7]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u7I5SFpG004013; Thu, 18 Aug 2016 01:28:20 -0400 From: Peter Xu To: qemu-devel@nongnu.org Date: Thu, 18 Aug 2016 13:28:09 +0800 Message-Id: <1471498092-27135-2-git-send-email-peterx@redhat.com> In-Reply-To: <1471498092-27135-1-git-send-email-peterx@redhat.com> References: <1471498092-27135-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 18 Aug 2016 05:28:23 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 1/4] error-report: provide error_report_fatal() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, famz@redhat.com, armbru@redhat.com, peterx@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" There are many places in current QEMU codes that needs to print some error and then quit QEMU. Provide a new function for it. Signed-off-by: Peter Xu --- include/qemu/error-report.h | 1 + util/qemu-error.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h index 499ec8b..eb8260e 100644 --- a/include/qemu/error-report.h +++ b/include/qemu/error-report.h @@ -36,6 +36,7 @@ void error_printf_unless_qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2); void error_set_progname(const char *argv0); void error_vreport(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0); void error_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2); +void error_report_fatal(const char *fmt, ...) GCC_FMT_ATTR(1, 2); const char *error_get_progname(void); extern bool enable_timestamp_msg; diff --git a/util/qemu-error.c b/util/qemu-error.c index 1ef3566..81379e1 100644 --- a/util/qemu-error.c +++ b/util/qemu-error.c @@ -10,6 +10,7 @@ * See the COPYING file in the top-level directory. */ +#include #include "qemu/osdep.h" #include "monitor/monitor.h" #include "qemu/error-report.h" @@ -237,3 +238,14 @@ void error_report(const char *fmt, ...) error_vreport(fmt, ap); va_end(ap); } + +void error_report_fatal(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + error_vreport(fmt, ap); + va_end(ap); + + exit(1); +}