From nobody Sun May 5 04:44:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555528519; cv=none; d=zoho.com; s=zohoarc; b=bgrlvh3QMdjfkpr5X2FF5EhVEuG+m8u7wWtGwIf1PD1DH+ili9ykcuOjZX21Pi/6lB+7/WqpOq0m2jDaJPgX4Nhdt1kaKN4c6mrfHvipzQU7Rd7Yzrsx+FTDZtkYOBVUKDUns2bpwBCrpZ+jnUCLrYmLjshdrtge/f7vVFwq/c0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555528519; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=zx5w5GMJFmCpUif5WpKi9bxvAY6mOoXFzZaR+AaBLdI=; b=kRSEB8dGoVvclA/57GxpuX6lk7Ob1y+3yHKArR/UFEBqrmnk3yk/Th9prYxqno1M9f1jCdguR10VtNTJVBt4bllfIXk9wX84GZGLIM/X0u3xI80sQHl9Hi9xRwUz3yCs5ZrS0i2geNVtAh6oQsAlmLoIgrDmHBOemRH/cN8VwWw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555528519599992.7158222610387; Wed, 17 Apr 2019 12:15:19 -0700 (PDT) Received: from localhost ([127.0.0.1]:58226 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGq1b-0005eN-H0 for importer@patchew.org; Wed, 17 Apr 2019 15:15:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60294) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGptQ-0007eV-8u for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hGptP-0003aq-9v for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41158) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hGptN-0003Wq-3Q; Wed, 17 Apr 2019 15:06:45 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BA6A230ADBD3; Wed, 17 Apr 2019 19:06:43 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 82BE860148; Wed, 17 Apr 2019 19:06:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id CFF5A1132BB6; Wed, 17 Apr 2019 21:06:41 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Apr 2019 21:06:27 +0200 Message-Id: <20190417190641.26814-2-armbru@redhat.com> In-Reply-To: <20190417190641.26814-1-armbru@redhat.com> References: <20190417190641.26814-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Wed, 17 Apr 2019 19:06:43 +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 01/15] qemu-img: Use error_vreport() in error_exit() 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: Kevin Wolf , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" error_exit() uses low-level error_printf() to report errors. Modernize it to use error_vreport(). Cc: Kevin Wolf Cc: Max Reitz Cc: qemu-block@nongnu.org Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- qemu-img.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 8c7b2437f0..c376e91ca0 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -85,13 +85,11 @@ static void QEMU_NORETURN GCC_FMT_ATTR(1, 2) error_exit= (const char *fmt, ...) { va_list ap; =20 - error_printf("qemu-img: "); - va_start(ap, fmt); - error_vprintf(fmt, ap); + error_vreport(fmt, ap); va_end(ap); =20 - error_printf("\nTry 'qemu-img --help' for more information\n"); + error_printf("Try 'qemu-img --help' for more information\n"); exit(EXIT_FAILURE); } =20 --=20 2.17.2 From nobody Sun May 5 04:44:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555528919; cv=none; d=zoho.com; s=zohoarc; b=GqmXWi+u/MxEb7iS8vUi3zDuS2p/CsaXJXy49jnD2WrXLsFAyqi1QuLbl68lfm2hRG7VnHYjMQyPs0ZAInkpM6L7U9WGGsrlBBw+FqyTCI1EBQ4Zm5YrYo9kkgLLLlRNIsJakXdPUJPivcpP4FiUi0XjLKvKBaSDHCPkdutbua8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555528919; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=GQ5Gkj2PTA20Uv5iWQvfcYcrNfV4fZQqicGHf2fWDyo=; b=I41254Fbz+lWe48TgNrMVimDhOr0NqYb+3pQpQRR82buEp+GHhQA8dRii8lg6rQ1FoXZzCHlMYHhHkdowuE1aLw/bgqyCrUAAVqozScLhizEwwHy+tLCeia8xFLuCNs8qqHwxWtydVLURBi+JceN80+Y1QtAEZ5UtUErRYdXfRk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555528919715112.63762670750498; Wed, 17 Apr 2019 12:21:59 -0700 (PDT) Received: from localhost ([127.0.0.1]:58343 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGq81-0002Nv-Ia for importer@patchew.org; Wed, 17 Apr 2019 15:21:53 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60381) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGptR-0007gs-Rw for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hGptQ-0003d4-MO for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54754) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hGptN-0003Ws-3f; Wed, 17 Apr 2019 15:06:45 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E2C6981F18; Wed, 17 Apr 2019 19:06:43 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 82B535D707; Wed, 17 Apr 2019 19:06:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id D4C9C1132BD3; Wed, 17 Apr 2019 21:06:41 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Apr 2019 21:06:28 +0200 Message-Id: <20190417190641.26814-3-armbru@redhat.com> In-Reply-To: <20190417190641.26814-1-armbru@redhat.com> References: <20190417190641.26814-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 17 Apr 2019 19:06:43 +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 02/15] block/ssh: Do not report read/write/flush errors to the user 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: Kevin Wolf , "Richard W.M. Jones" , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Callbacks ssh_co_readv(), ssh_co_writev(), ssh_co_flush() report errors to the user with error_printf(). They shouldn't, it's their caller's job. Replace by a suitable trace point. While there, drop the unreachable !s->sftp case. Perhaps we should convert this part of the block driver interface to Error, so block drivers can pass more detail to their callers. Not today. Cc: "Richard W.M. Jones" Cc: Kevin Wolf Cc: Max Reitz Cc: qemu-block@nongnu.org Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- block/ssh.c | 38 +++++++++++++------------------------- block/trace-events | 3 +++ 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/block/ssh.c b/block/ssh.c index 190ef95300..859249113d 100644 --- a/block/ssh.c +++ b/block/ssh.c @@ -159,31 +159,19 @@ sftp_error_setg(Error **errp, BDRVSSHState *s, const = char *fs, ...) g_free(msg); } =20 -static void GCC_FMT_ATTR(2, 3) -sftp_error_report(BDRVSSHState *s, const char *fs, ...) +static void sftp_error_trace(BDRVSSHState *s, const char *op) { - va_list args; + char *ssh_err; + int ssh_err_code; + unsigned long sftp_err_code; =20 - va_start(args, fs); - error_vprintf(fs, args); + /* This is not an errno. See . */ + ssh_err_code =3D libssh2_session_last_error(s->session, + &ssh_err, NULL, 0); + /* See . */ + sftp_err_code =3D libssh2_sftp_last_error((s)->sftp); =20 - if ((s)->sftp) { - char *ssh_err; - int ssh_err_code; - unsigned long sftp_err_code; - - /* This is not an errno. See . */ - ssh_err_code =3D libssh2_session_last_error(s->session, - &ssh_err, NULL, 0); - /* See . */ - sftp_err_code =3D libssh2_sftp_last_error((s)->sftp); - - error_printf(": %s (libssh2 error code: %d, sftp error code: %lu)", - ssh_err, ssh_err_code, sftp_err_code); - } - - va_end(args); - error_printf("\n"); + trace_sftp_error(op, ssh_err, ssh_err_code, sftp_err_code); } =20 static int parse_uri(const char *filename, QDict *options, Error **errp) @@ -1035,7 +1023,7 @@ static coroutine_fn int ssh_read(BDRVSSHState *s, Blo= ckDriverState *bs, goto again; } if (r < 0) { - sftp_error_report(s, "read failed"); + sftp_error_trace(s, "read"); s->offset =3D -1; return -EIO; } @@ -1105,7 +1093,7 @@ static int ssh_write(BDRVSSHState *s, BlockDriverStat= e *bs, goto again; } if (r < 0) { - sftp_error_report(s, "write failed"); + sftp_error_trace(s, "write"); s->offset =3D -1; return -EIO; } @@ -1188,7 +1176,7 @@ static coroutine_fn int ssh_flush(BDRVSSHState *s, Bl= ockDriverState *bs) return 0; } if (r < 0) { - sftp_error_report(s, "fsync failed"); + sftp_error_trace(s, "fsync"); return -EIO; } =20 diff --git a/block/trace-events b/block/trace-events index 7335a42540..79ccd8d824 100644 --- a/block/trace-events +++ b/block/trace-events @@ -208,3 +208,6 @@ sheepdog_co_rw_vector_new(uint64_t oid) "new oid 0x%" P= RIx64 sheepdog_snapshot_create_info(const char *sn_name, const char *id, const c= har *name, int64_t size, int is_snapshot) "sn_info: name %s id_str %s s: na= me %s vm_state_size %" PRId64 " " "is_snapshot %d" sheepdog_snapshot_create(const char *sn_name, const char *id) "%s %s" sheepdog_snapshot_create_inode(const char *name, uint32_t snap, uint32_t v= di) "s->inode: name %s snap_id 0x%" PRIx32 " vdi 0x%" PRIx32 + +# ssh.c +sftp_error(const char *op, const char *ssh_err, int ssh_err_code, unsigned= long sftp_err_code) "%s failed: %s (libssh2 error code: %d, sftp error cod= e: %lu)" --=20 2.17.2 From nobody Sun May 5 04:44:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555528167; cv=none; d=zoho.com; s=zohoarc; b=OfljMqyN68YgT7tQLbYTSstHmTwHZ524EzFmryhdAA5kqjGN1q55sfGPHwGEh48m9Y0q6nQa+S+Wjmyw2egVzsef6BLXJtvaNp0P6v7PzYGGPkvlTu4EexNfrY9vNJL6aH2lUXwx8IXos5wRkNCu7YugxaWaXH6JijEg8cRaVVo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555528167; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=mWys47x15JAQDgyy8wAAYmxXGLkjmvv2S+T9EZYKhYc=; b=Kdb2NuWY3eEV3s6mB05WAHMJ7tYSPwMDIGBWQlnWAYCki8KLcCDIPQ0eMckT5uy7TvKQOhxovO7PBuq2IeO2W8AtUxYakKK3Nn+vJ17ohpVOemwUCab5q1CJVMZybG0W8wTb1ecIVYoTFkUww0Gf4cGy8OOHJ9kR8x8CSEcX2pY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555528167405699.7409009955896; Wed, 17 Apr 2019 12:09:27 -0700 (PDT) Received: from localhost ([127.0.0.1]:58140 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGpvp-0000fS-8w for importer@patchew.org; Wed, 17 Apr 2019 15:09:17 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60228) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGptO-0007dz-U7 for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hGptN-0003YJ-Fc for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53471) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hGptN-0003Wu-3D for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:45 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E3A11C050061; Wed, 17 Apr 2019 19:06:43 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 82B5119C58; Wed, 17 Apr 2019 19:06:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id D991E1132B6C; Wed, 17 Apr 2019 21:06:41 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Apr 2019 21:06:29 +0200 Message-Id: <20190417190641.26814-4-armbru@redhat.com> In-Reply-To: <20190417190641.26814-1-armbru@redhat.com> References: <20190417190641.26814-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 17 Apr 2019 19:06:43 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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 03/15] loader-fit: Wean off error_printf() 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: Aleksandar Rikalo , Paul Burton Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" load_fit() reports errors with error_printf() instead of error_report(). Worse, it even reports errors it actually recovers from, in fit_cfg_compatible() and fit_load_fdt(). Messed up in initial commit 51b58561c1d. Convert the helper functions for load_fit() to Error. Make sure each failure path sets an error. Fix fit_cfg_compatible() and fit_load_fdt() not to report errors they actually recover from. Convert load_fit() to error_report(). Cc: Paul Burton Cc: Aleksandar Rikalo Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/core/loader-fit.c | 62 +++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/hw/core/loader-fit.c b/hw/core/loader-fit.c index 447f60857d..f27b6af942 100644 --- a/hw/core/loader-fit.c +++ b/hw/core/loader-fit.c @@ -18,6 +18,7 @@ */ =20 #include "qemu/osdep.h" +#include "qapi/error.h" #include "qemu/units.h" #include "exec/memory.h" #include "hw/loader.h" @@ -33,7 +34,7 @@ #define FIT_LOADER_MAX_PATH (128) =20 static const void *fit_load_image_alloc(const void *itb, const char *name, - int *poff, size_t *psz) + int *poff, size_t *psz, Error **er= rp) { const void *data; const char *comp; @@ -46,6 +47,7 @@ static const void *fit_load_image_alloc(const void *itb, = const char *name, =20 off =3D fdt_path_offset(itb, path); if (off < 0) { + error_setg(errp, "can't find node %s", path); return NULL; } if (poff) { @@ -54,6 +56,7 @@ static const void *fit_load_image_alloc(const void *itb, = const char *name, =20 data =3D fdt_getprop(itb, off, "data", &sz); if (!data) { + error_setg(errp, "can't get %s/data", path); return NULL; } =20 @@ -73,7 +76,7 @@ static const void *fit_load_image_alloc(const void *itb, = const char *name, =20 uncomp_len =3D gunzip(uncomp_data, uncomp_len, (void *) data, sz); if (uncomp_len < 0) { - error_printf("unable to decompress %s image\n", name); + error_setg(errp, "unable to decompress %s image", name); g_free(uncomp_data); return NULL; } @@ -85,18 +88,19 @@ static const void *fit_load_image_alloc(const void *itb= , const char *name, return data; } =20 - error_printf("unknown compression '%s'\n", comp); + error_setg(errp, "unknown compression '%s'", comp); return NULL; } =20 static int fit_image_addr(const void *itb, int img, const char *name, - hwaddr *addr) + hwaddr *addr, Error **errp) { const void *prop; int len; =20 prop =3D fdt_getprop(itb, img, name, &len); if (!prop) { + error_setg(errp, "can't find %s address", name); return -ENOENT; } =20 @@ -108,13 +112,14 @@ static int fit_image_addr(const void *itb, int img, c= onst char *name, *addr =3D fdt64_to_cpu(*(fdt64_t *)prop); return 0; default: - error_printf("invalid %s address length %d\n", name, len); + error_setg(errp, "invalid %s address length %d", name, len); return -EINVAL; } } =20 static int fit_load_kernel(const struct fit_loader *ldr, const void *itb, - int cfg, void *opaque, hwaddr *pend) + int cfg, void *opaque, hwaddr *pend, + Error **errp) { const char *name; const void *data; @@ -126,26 +131,26 @@ static int fit_load_kernel(const struct fit_loader *l= dr, const void *itb, =20 name =3D fdt_getprop(itb, cfg, "kernel", NULL); if (!name) { - error_printf("no kernel specified by FIT configuration\n"); + error_setg(errp, "no kernel specified by FIT configuration"); return -EINVAL; } =20 - load_data =3D data =3D fit_load_image_alloc(itb, name, &img_off, &sz); + load_data =3D data =3D fit_load_image_alloc(itb, name, &img_off, &sz, = errp); if (!data) { - error_printf("unable to load kernel image from FIT\n"); + error_prepend(errp, "unable to load kernel image from FIT: "); return -EINVAL; } =20 - err =3D fit_image_addr(itb, img_off, "load", &load_addr); + err =3D fit_image_addr(itb, img_off, "load", &load_addr, errp); if (err) { - error_printf("unable to read kernel load address from FIT\n"); + error_prepend(errp, "unable to read kernel load address from FIT: = "); ret =3D err; goto out; } =20 - err =3D fit_image_addr(itb, img_off, "entry", &entry_addr); + err =3D fit_image_addr(itb, img_off, "entry", &entry_addr, errp); if (err) { - error_printf("unable to read kernel entry address from FIT\n"); + error_prepend(errp, "unable to read kernel entry address from FIT:= "); ret =3D err; goto out; } @@ -172,7 +177,7 @@ out: =20 static int fit_load_fdt(const struct fit_loader *ldr, const void *itb, int cfg, void *opaque, const void *match_data, - hwaddr kernel_end) + hwaddr kernel_end, Error **errp) { const char *name; const void *data; @@ -187,16 +192,18 @@ static int fit_load_fdt(const struct fit_loader *ldr,= const void *itb, return 0; } =20 - load_data =3D data =3D fit_load_image_alloc(itb, name, &img_off, &sz); + load_data =3D data =3D fit_load_image_alloc(itb, name, &img_off, &sz, = errp); if (!data) { - error_printf("unable to load FDT image from FIT\n"); + error_prepend(errp, "unable to load FDT image from FIT: "); return -EINVAL; } =20 - err =3D fit_image_addr(itb, img_off, "load", &load_addr); + err =3D fit_image_addr(itb, img_off, "load", &load_addr, errp); if (err =3D=3D -ENOENT) { load_addr =3D ROUND_UP(kernel_end, 64 * KiB) + (10 * MiB); + error_free(*errp); } else if (err) { + error_prepend(errp, "unable to read FDT load address from FIT: "); ret =3D err; goto out; } @@ -229,7 +236,7 @@ static bool fit_cfg_compatible(const void *itb, int cfg= , const char *compat) return false; } =20 - fdt =3D fit_load_image_alloc(itb, fdt_name, NULL, NULL); + fdt =3D fit_load_image_alloc(itb, fdt_name, NULL, NULL, NULL); if (!fdt) { return false; } @@ -252,11 +259,12 @@ out: =20 int load_fit(const struct fit_loader *ldr, const char *filename, void *opa= que) { + Error *err =3D NULL; const struct fit_loader_match *match; const void *itb, *match_data =3D NULL; const char *def_cfg_name; char path[FIT_LOADER_MAX_PATH]; - int itb_size, configs, cfg_off, off, err; + int itb_size, configs, cfg_off, off; hwaddr kernel_end; int ret; =20 @@ -267,6 +275,7 @@ int load_fit(const struct fit_loader *ldr, const char *= filename, void *opaque) =20 configs =3D fdt_path_offset(itb, "/configurations"); if (configs < 0) { + error_report("can't find node /configurations"); ret =3D configs; goto out; } @@ -301,20 +310,21 @@ int load_fit(const struct fit_loader *ldr, const char= *filename, void *opaque) } =20 if (cfg_off < 0) { - /* couldn't find a configuration to use */ + error_report("can't find configuration"); ret =3D cfg_off; goto out; } =20 - err =3D fit_load_kernel(ldr, itb, cfg_off, opaque, &kernel_end); - if (err) { - ret =3D err; + ret =3D fit_load_kernel(ldr, itb, cfg_off, opaque, &kernel_end, &err); + if (ret) { + error_report_err(err); goto out; } =20 - err =3D fit_load_fdt(ldr, itb, cfg_off, opaque, match_data, kernel_end= ); - if (err) { - ret =3D err; + ret =3D fit_load_fdt(ldr, itb, cfg_off, opaque, match_data, kernel_end, + &err); + if (ret) { + error_report_err(err); goto out; } =20 --=20 2.17.2 From nobody Sun May 5 04:44:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555528154; cv=none; d=zoho.com; s=zohoarc; b=ky7hR/rz9toVDAZw2N/fwMFllxKAS4Ejp4lpn/uFZ9QS8cOoP7iSXrNZZqCcSnL9rYbxnWOumyLdHkwHTUvR5TmUtwcYkpThT3kN9FMy3I1uZSkOcK4UJsj3Ix4D4Fk2HpLwL6M6rq/SDiXlrSbcA0g3l+iQRQTIyILJjniAcZQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555528154; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=bIVZVjVwMxYQaDisgyS+h1ypx/vh8NfxySNmCV0AYug=; b=bbHyDqn7QzKrFed3xmNA1k9rnpP0+f532kUlxMWVWh0dEYhKrncsgtdVaUO1Q0BCvFESGoXRPAt2OaipgnKQS/3ajd5tRu9HU8I3K2LK9C5ayGgENPsFHr6dM52qazkpMmLX/UDa7p5NjQ1bXnjzMW6pNEj5GO8i1YuF+hjUDXQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555528154545113.9023692319455; Wed, 17 Apr 2019 12:09:14 -0700 (PDT) Received: from localhost ([127.0.0.1]:58134 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGpvZ-0000S3-Vl for importer@patchew.org; Wed, 17 Apr 2019 15:09:02 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60195) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGptO-0007dw-8O for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hGptN-0003Xw-Cv for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47138) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hGptN-0003Wy-39 for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:45 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D2776307D9D1; Wed, 17 Apr 2019 19:06:43 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9875E5D9E1; Wed, 17 Apr 2019 19:06:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id DFFD21132B74; Wed, 17 Apr 2019 21:06:41 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Apr 2019 21:06:30 +0200 Message-Id: <20190417190641.26814-5-armbru@redhat.com> In-Reply-To: <20190417190641.26814-1-armbru@redhat.com> References: <20190417190641.26814-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Wed, 17 Apr 2019 19:06:43 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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 04/15] mips/boston: Report errors with error_report(), not error_printf() 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: Aleksandar Rikalo , Paul Burton Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Cc: Paul Burton Cc: Aleksandar Rikalo Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/mips/boston.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/mips/boston.c b/hw/mips/boston.c index e5bab3cadc..a8b29f62f5 100644 --- a/hw/mips/boston.c +++ b/hw/mips/boston.c @@ -528,21 +528,21 @@ static void boston_mach_init(MachineState *machine) fw_size =3D load_image_targphys(machine->firmware, 0x1fc00000, 4 * MiB); if (fw_size =3D=3D -1) { - error_printf("unable to load firmware image '%s'\n", + error_report("unable to load firmware image '%s'", machine->firmware); exit(1); } } else if (machine->kernel_filename) { fit_err =3D load_fit(&boston_fit_loader, machine->kernel_filename,= s); if (fit_err) { - error_printf("unable to load FIT image\n"); + error_report("unable to load FIT image"); exit(1); } =20 gen_firmware(memory_region_get_ram_ptr(flash) + 0x7c00000, s->kernel_entry, s->fdt_base, is_64b); } else if (!qtest_enabled()) { - error_printf("Please provide either a -kernel or -bios argument\n"= ); + error_report("Please provide either a -kernel or -bios argument"); exit(1); } } --=20 2.17.2 From nobody Sun May 5 04:44:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555528518; cv=none; d=zoho.com; s=zohoarc; b=OqFr0eO+wCKez56ncETRd3AMNdNmLmMVJi8TxrBqpOlV/fjPfoFP3roGUGLDCGB5AaSJEqjbfx0FtJNHCJhscoN239Fw30/e957NCdj6By2e+36aObzYd2FYdcPXMfUIeaE3QZTEqrdu7C+D8G7xXkVu+krx0oLg4U4zKmdW6jw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555528518; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=psSPJmdf72/LPLDTZzflC/820i7ASLPjQdn2RNzC+0s=; b=RvE4WjvztALl6BkKNAWTyynxGpdOfOR3dNa/bbQ3IWTFHOLufn1beVMu0Cc2B+IQDQaozE7xW2FYt+DQ/xs9aQtt5thgixVq8eXXwsIBQK7sMztqIpILNFsyzu33MbXzwHCp8dN7WtNNZyDMl7Cv6O2wTIf81IFqMxhOZ2CYIa8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555528518012909.6925174893287; Wed, 17 Apr 2019 12:15:18 -0700 (PDT) Received: from localhost ([127.0.0.1]:58220 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGq1O-0005Tu-5D for importer@patchew.org; Wed, 17 Apr 2019 15:15:02 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60345) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGptR-0007fr-8z for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hGptQ-0003cU-BD for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55480) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hGptQ-0003b6-1d for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:48 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 462E9C05FBAF; Wed, 17 Apr 2019 19:06:47 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1074D5D9D6; Wed, 17 Apr 2019 19:06:45 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E71001132B38; Wed, 17 Apr 2019 21:06:41 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Apr 2019 21:06:31 +0200 Message-Id: <20190417190641.26814-6-armbru@redhat.com> In-Reply-To: <20190417190641.26814-1-armbru@redhat.com> References: <20190417190641.26814-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 17 Apr 2019 19:06:47 +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 05/15] pci: Report fatal errors with error_report(), not error_printf() 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: "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Cc: "Michael S. Tsirkin" Cc: Marcel Apfelbaum Signed-off-by: Markus Armbruster Reviewed-by: Marcel Apfelbaum --- hw/pci/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 6d13ef877b..1808b242dd 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -951,7 +951,7 @@ static uint16_t pci_req_id_cache_extract(PCIReqIDCache = *cache) result =3D PCI_BUILD_BDF(bus_n, 0); break; default: - error_printf("Invalid PCI requester ID cache type: %d\n", + error_report("Invalid PCI requester ID cache type: %d", cache->type); exit(1); break; --=20 2.17.2 From nobody Sun May 5 04:44:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555528524; cv=none; d=zoho.com; s=zohoarc; b=Z2bU0it66ruyrhJPTlipmThW0fZEgoG7MYW5qq3EQWuoeHf7ZVgnckBHY8EmuRzkspBJfOpGMzCzktG+j2UYxB44NaOp5BIvTRR3Gl8on+Sx/bYjYP7U6VS4wvbNsDaKU0qWnJlmLKnbHHMuQgIczASZolw7rLqoAWV1d6YzRpo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555528524; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=QGo7i5ZhhvNT8id4hYgsc+Gpqp7OGwWFQzRPIxvSkic=; b=ehoVA85r4zrDIcgNd5D/SW5G5hCy2eODWnOQiq0ZHRsFYEkTZhX0Yet0+9DrIaC5IosXpi/0A9orADY4p6iyIwXVPiBctsHM5RNYf+soPAkyojmOq4bfWdZfeM3kRdEWl8NRh/x+mzRL7XVk/IefYQFjLNby3bkfbIAwy7SODa0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555528524258405.6895490629897; Wed, 17 Apr 2019 12:15:24 -0700 (PDT) Received: from localhost ([127.0.0.1]:58224 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGq1X-0005as-BO for importer@patchew.org; Wed, 17 Apr 2019 15:15:11 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60338) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGptR-0007fe-2O for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hGptQ-0003c9-77 for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39428) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hGptP-0003aw-Ul for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:48 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2C1542D7F8 for ; Wed, 17 Apr 2019 19:06:47 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 10C4060C61; Wed, 17 Apr 2019 19:06:45 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 012721132B3B; Wed, 17 Apr 2019 21:06:41 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Apr 2019 21:06:32 +0200 Message-Id: <20190417190641.26814-7-armbru@redhat.com> In-Reply-To: <20190417190641.26814-1-armbru@redhat.com> References: <20190417190641.26814-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 17 Apr 2019 19:06:47 +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 06/15] hpet: Report warnings with warn_report(), not error_printf() 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: Paolo Bonzini , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Cc: "Michael S. Tsirkin" Cc: Paolo Bonzini Signed-off-by: Markus Armbruster --- hw/timer/hpet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c index d97436bc7b..41024f39fb 100644 --- a/hw/timer/hpet.c +++ b/hw/timer/hpet.c @@ -744,7 +744,7 @@ static void hpet_realize(DeviceState *dev, Error **errp) HPETTimer *timer; =20 if (!s->intcap) { - error_printf("Hpet's intcap not initialized.\n"); + warn_report("Hpet's intcap not initialized"); } if (hpet_cfg.count =3D=3D UINT8_MAX) { /* first instance */ --=20 2.17.2 From nobody Sun May 5 04:44:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555528709; cv=none; d=zoho.com; s=zohoarc; b=c5gsbfDnWdx8K1PnpdG0qiMgEC59kXjy1Em8fZiOBNkTF9e7wb6s1Nv3QaOY9IGcvV12xBphAU2QlGZmKChXVUa4B5240afdZ7FCfa747gud7OUFuLpYCH7q4bta4WeciHMvd9GIDr+0jfoMeM4s8PMwNT6UPAaj+1DHk6NqvFc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555528709; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=hfN6utArzJ0Q+aTTpEj6bfs1Pgpc7oeBTQsthPA15pc=; b=VqgkQYwPMTdO3cHxyJ2l4rntqFuMS5ajUuN+mpJz2SUC7R26sW3oWrpFOXRfl1GBJU8VrxpfaTq8wuESjy/D8U81pwtnabctGrWUVydQOFWXd73Dz2baKeXJg136e1TkrCw4hnPIHwUMz1qQdX6/3zoTv2GhmuDyepf5wNz+zP8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555528709169841.4563433494236; Wed, 17 Apr 2019 12:18:29 -0700 (PDT) Received: from localhost ([127.0.0.1]:58278 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGq4g-0008AM-4W for importer@patchew.org; Wed, 17 Apr 2019 15:18:26 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60354) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGptR-0007g6-DS for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hGptQ-0003cJ-9T for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55476) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hGptP-0003au-U0 for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:48 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 26D2CC007344 for ; Wed, 17 Apr 2019 19:06:47 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 12054608C2; Wed, 17 Apr 2019 19:06:45 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 079AA1132A03; Wed, 17 Apr 2019 21:06:42 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Apr 2019 21:06:33 +0200 Message-Id: <20190417190641.26814-8-armbru@redhat.com> In-Reply-To: <20190417190641.26814-1-armbru@redhat.com> References: <20190417190641.26814-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 17 Apr 2019 19:06:47 +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 07/15] vfio: Report warnings with warn_report(), not error_printf() 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: Alex Williamson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Cc: Alex Williamson Signed-off-by: Markus Armbruster Acked-by: Alex Williamson --- hw/vfio/pci.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 504019c458..0142819ea6 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -947,8 +947,10 @@ static void vfio_pci_size_rom(VFIOPCIDevice *vdev) if (vdev->pdev.romfile || !vdev->pdev.rom_bar) { /* Since pci handles romfile, just print a message and return */ if (vfio_blacklist_opt_rom(vdev) && vdev->pdev.romfile) { - error_printf("Warning : Device at %s is known to cause system = instability issues during option rom execution. Proceeding anyway since use= r specified romfile\n", - vdev->vbasedev.name); + warn_report("Device at %s is known to cause system instability" + " issues during option rom execution", + vdev->vbasedev.name); + error_printf("Proceeding anyway since user specified romfile\n= "); } return; } @@ -973,11 +975,16 @@ static void vfio_pci_size_rom(VFIOPCIDevice *vdev) =20 if (vfio_blacklist_opt_rom(vdev)) { if (dev->opts && qemu_opt_get(dev->opts, "rombar")) { - error_printf("Warning : Device at %s is known to cause system = instability issues during option rom execution. Proceeding anyway since use= r specified non zero value for rombar\n", - vdev->vbasedev.name); + warn_report("Device at %s is known to cause system instability" + " issues during option rom execution", + vdev->vbasedev.name); + error_printf("Proceeding anyway since user specified" + " non zero value for rombar\n"); } else { - error_printf("Warning : Rom loading for device at %s has been = disabled due to system instability issues. Specify rombar=3D1 or romfile to= force\n", - vdev->vbasedev.name); + warn_report("Rom loading for device at %s has been disabled" + " due to system instability issues", + vdev->vbasedev.name); + error_printf("Specify rombar=3D1 or romfile to force\n"); return; } } --=20 2.17.2 From nobody Sun May 5 04:44:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555528340; cv=none; d=zoho.com; s=zohoarc; b=fdXNRQ+AwUXJixpT6L1IPWzF52N2I4Pf/kMalaKp6+SBXKGkrNjj2rVxtAZ3YXd2BQQyw3egvzANEQQVHsh06emHx1hllXTrXTT/3k6x0/TQHNXaskcK2kqM5t8qxqhOrELE02mAB/2NO4oXOe0iNjUE0qoVNNpfviviOkBfeWQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555528340; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=p9Ywb+zwF+s25tq8kzDGgK/h1bdp+iKU6DsDE/GJXwI=; b=cpJNwZizTMV20nhHC0Dic6wj9Bg75UH+CtRDR5pOJYxKXxTi152ryDT1T2/lJA2ZAU3b7Wm+amA2gvTMASkesXLyWLVuExrjnKoMb9r5m+GJkOopWmSCveDOMu+WEnbOHbsWO5t1rJqgB3fcRs+L52R5qxfNBOeMGmlsU0esFGI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555528340071335.02150852273485; Wed, 17 Apr 2019 12:12:20 -0700 (PDT) Received: from localhost ([127.0.0.1]:58195 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGpyj-0003Fp-3D for importer@patchew.org; Wed, 17 Apr 2019 15:12:17 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60257) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGptP-0007eE-Hb for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hGptO-0003Zc-E9 for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56634) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hGptO-0003YE-3C; Wed, 17 Apr 2019 15:06:46 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4963C30024DD; Wed, 17 Apr 2019 19:06:45 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 14D865D9E1; Wed, 17 Apr 2019 19:06:45 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 0F4CA11329CD; Wed, 17 Apr 2019 21:06:42 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Apr 2019 21:06:34 +0200 Message-Id: <20190417190641.26814-9-armbru@redhat.com> In-Reply-To: <20190417190641.26814-1-armbru@redhat.com> References: <20190417190641.26814-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Wed, 17 Apr 2019 19:06:45 +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 08/15] s390x/kvm: Report warnings with warn_report(), not error_printf() 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: Thomas Huth , qemu-s390x@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" kvm_s390_mem_op() can fail in two ways: when !cap_mem_op, it returns -ENOSYS, and when kvm_vcpu_ioctl() fails, it returns -errno set by ioctl(). Its caller s390_cpu_virt_mem_rw() recovers from both failures. kvm_s390_mem_op() prints "KVM_S390_MEM_OP failed" with error_printf() in the latter failure mode. Since this is obviously a warning, use warn_report(). Perhaps the reporting should be left to the caller. It could warn on failure other than -ENOSYS. Cc: Thomas Huth Cc: qemu-s390x@nongnu.org Signed-off-by: Markus Armbruster Reviewed-by: Thomas Huth Reviewed-by: Cornelia Huck --- target/s390x/kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 19530fb94e..2c6e35b5aa 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -782,7 +782,7 @@ int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, uint8_t a= r, void *hostbuf, =20 ret =3D kvm_vcpu_ioctl(CPU(cpu), KVM_S390_MEM_OP, &mem_op); if (ret < 0) { - error_printf("KVM_S390_MEM_OP failed: %s\n", strerror(-ret)); + warn_report("KVM_S390_MEM_OP failed: %s", strerror(-ret)); } return ret; } --=20 2.17.2 From nobody Sun May 5 04:44:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555528328; cv=none; d=zoho.com; s=zohoarc; b=lPNRw0KBlNnVUWkMTjfjiHWAebOaWSKzUbcPqIwDwnv+R8eGZf2sCoURtiweRpdAtNIggxeYMF9jaidmI+2vegagmIkhpL9JcyZTYzbhuugGcxRIGlQxwCCsa9338p5Fpp4KQqFvjGJarDPDzX6YQoqJudXU8nYM+Qb73tosrWw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555528328; h=Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=2w40EpcFtQMPljR9S9vwYSWeiGrB0g5b0MW0FziNCqY=; b=Hk0utQj/EYlvPy2PGnuB6f2yo4OVuN5bNuBbZ/+PK0NSJma9Lug7cl2KTAf09vi+maiWiyD0KIOyOVYkfn5ybsS26r2gU7PPhApjonN6O0bEs1vEVw74iRF3QMtg2eLcIb0X1gNPRzkrMFyVCTT4EEZJLm21fSs5oWxwcur8hhA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555528328003837.4806049514548; Wed, 17 Apr 2019 12:12:08 -0700 (PDT) Received: from localhost ([127.0.0.1]:58189 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGpyX-00034T-0c for importer@patchew.org; Wed, 17 Apr 2019 15:12:05 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60253) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGptP-0007eD-Bo for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hGptO-0003ZW-Dh for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56636) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hGptO-0003Ye-3W for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:46 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5BEC83002F52; Wed, 17 Apr 2019 19:06:45 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 278595D6A6; Wed, 17 Apr 2019 19:06:45 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 176D411329CF; Wed, 17 Apr 2019 21:06:42 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Apr 2019 21:06:35 +0200 Message-Id: <20190417190641.26814-10-armbru@redhat.com> In-Reply-To: <20190417190641.26814-1-armbru@redhat.com> References: <20190417190641.26814-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Wed, 17 Apr 2019 19:06:45 +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 09/15] vl: Make -machine $TYPE, help and -accel help print to stdout 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Command line help help explicitly requested by the user should be printed to stdout, not stderr. We do elsewhere. Adjust -machine $TYPE,help and -accel help to match: use printf() instead of error_printf(). Cc: Marcel Apfelbaum Signed-off-by: Markus Armbruster Reviewed-by: Marcel Apfelbaum --- vl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vl.c b/vl.c index 9877972d97..190c773176 100644 --- a/vl.c +++ b/vl.c @@ -1556,12 +1556,12 @@ static int machine_help_func(QemuOpts *opts, Machin= eState *machine) continue; } =20 - error_printf("%s.%s=3D%s", MACHINE_GET_CLASS(machine)->name, - prop->name, prop->type); + printf("%s.%s=3D%s", MACHINE_GET_CLASS(machine)->name, + prop->name, prop->type); if (prop->description) { - error_printf(" (%s)\n", prop->description); + printf(" (%s)\n", prop->description); } else { - error_printf("\n"); + printf("\n"); } } =20 @@ -3643,7 +3643,7 @@ int main(int argc, char **argv, char **envp) optarg, true); optarg =3D qemu_opt_get(accel_opts, "accel"); if (!optarg || is_help_option(optarg)) { - error_printf("Possible accelerators: kvm, xen, hax, tc= g\n"); + printf("Possible accelerators: kvm, xen, hax, tcg\n"); exit(0); } opts =3D qemu_opts_create(qemu_find_opts("machine"), NULL, --=20 2.17.2 From nobody Sun May 5 04:44:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555528716; cv=none; d=zoho.com; s=zohoarc; b=nmkR/x2QS4QjXVKudLYiIf4mA4o28apWPBnq0NSDNb1tv753Tk/zt73e0DYfmEVfv5e86j6w8RHAkwiEDIhonBk/7KyIxXmKtfaYnMK5xNzDlrPlgMCFHeJ1SJQWoMSqIz2FEZXubQW9Z6PrAbCUMqC1DhsXJfiiR+obo+O6jy4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555528716; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=i231vbDfF4cW6cyKRCvt937S6BOq7jK1cR5sDofvHjA=; b=SbRqD1LxS00EVDKQwGu+agMpj4Rg1qPUs3UX1bU9st9y7rbOOjgXs6frxs/VsAYGbY0PeW0R9GjLmy7qtig8Y/Rl46T/sUtyt2Vl57sZOTqCV+ViHBOtfeQec8LZsXH7AxVxIszpDoazptR/wmLvTSdD6L2plLbW/GyDF2Y/U0U= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 155552871669371.00708228456642; Wed, 17 Apr 2019 12:18:36 -0700 (PDT) Received: from localhost ([127.0.0.1]:58280 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGq4n-0008Di-HP for importer@patchew.org; Wed, 17 Apr 2019 15:18:33 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60307) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGptQ-0007el-FL for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hGptO-0003a6-Lw for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48472) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hGptO-0003Ym-BF for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:46 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8D610306C3F8 for ; Wed, 17 Apr 2019 19:06:45 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3069860148; Wed, 17 Apr 2019 19:06:45 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 236AA11329F5; Wed, 17 Apr 2019 21:06:42 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Apr 2019 21:06:36 +0200 Message-Id: <20190417190641.26814-11-armbru@redhat.com> In-Reply-To: <20190417190641.26814-1-armbru@redhat.com> References: <20190417190641.26814-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Wed, 17 Apr 2019 19:06:45 +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 10/15] monitor error: Make printf()-like functions return a value 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: "Dr . David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" printf() & friends return the number of characters written on success, negative value on error. monitor_printf(), monitor_vfprintf(), monitor_vprintf(), error_printf(), error_printf_unless_qmp(), error_vprintf(), and error_vprintf_unless_qmp() return void. Some of them carry a TODO comment asking for int instead. Improve them to return int like printf() does. This makes our use of monitor_printf() as fprintf_function slightly less dirty: the function cast no longer adds a return value that isn't there. It still changes a parameter's pointer type. That will be addressed in a future commit. monitor_vfprintf() always returns zero. Improve it to return the proper value. Cc: Dr. David Alan Gilbert Signed-off-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert --- include/monitor/monitor.h | 8 ++--- include/qemu/error-report.h | 8 ++--- monitor.c | 61 ++++++++++++++++++++----------------- stubs/error-printf.c | 13 +++++--- util/qemu-error.c | 12 +++++--- 5 files changed, 57 insertions(+), 45 deletions(-) diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h index c1b40a9cac..e4c3717454 100644 --- a/include/monitor/monitor.h +++ b/include/monitor/monitor.h @@ -28,9 +28,9 @@ void monitor_resume(Monitor *mon); int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp); int monitor_fd_param(Monitor *mon, const char *fdname, Error **errp); =20 -void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) +int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0); -void monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3); +int monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3); int monitor_fprintf(FILE *stream, const char *fmt, ...) GCC_FMT_ATTR(2, 3); void monitor_flush(Monitor *mon); int monitor_set_cpu(int cpu_index); @@ -48,7 +48,7 @@ int monitor_fdset_dup_fd_add(int64_t fdset_id, int dup_fd= ); void monitor_fdset_dup_fd_remove(int dup_fd); int monitor_fdset_dup_fd_find(int dup_fd); =20 -void monitor_vfprintf(FILE *stream, - const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0); +int monitor_vfprintf(FILE *stream, + const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0); =20 #endif /* MONITOR_H */ diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h index ce43c02314..00d069b20f 100644 --- a/include/qemu/error-report.h +++ b/include/qemu/error-report.h @@ -30,10 +30,10 @@ void loc_set_none(void); void loc_set_cmdline(char **argv, int idx, int cnt); void loc_set_file(const char *fname, int lno); =20 -void error_vprintf(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0); -void error_printf(const char *fmt, ...) GCC_FMT_ATTR(1, 2); -void error_vprintf_unless_qmp(const char *fmt, va_list ap) GCC_FMT_ATTR(1,= 0); -void error_printf_unless_qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2); +int error_vprintf(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0); +int error_printf(const char *fmt, ...) GCC_FMT_ATTR(1, 2); +int error_vprintf_unless_qmp(const char *fmt, va_list ap) GCC_FMT_ATTR(1, = 0); +int error_printf_unless_qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2); =20 void error_vreport(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0); void warn_vreport(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0); diff --git a/monitor.c b/monitor.c index 4807bbe811..7b4a78d798 100644 --- a/monitor.c +++ b/monitor.c @@ -430,15 +430,14 @@ void monitor_flush(Monitor *mon) } =20 /* flush at every end of line */ -static void monitor_puts(Monitor *mon, const char *str) +static int monitor_puts(Monitor *mon, const char *str) { + int i; char c; =20 qemu_mutex_lock(&mon->mon_lock); - for(;;) { - c =3D *str++; - if (c =3D=3D '\0') - break; + for (i =3D 0; str[i]; i++) { + c =3D str[i]; if (c =3D=3D '\n') { qstring_append_chr(mon->outbuf, '\r'); } @@ -448,39 +447,48 @@ static void monitor_puts(Monitor *mon, const char *st= r) } } qemu_mutex_unlock(&mon->mon_lock); + + return i; } =20 -void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) +int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) { char *buf; + int n; =20 if (!mon) - return; + return -1; =20 if (monitor_is_qmp(mon)) { - return; + return -1; } =20 buf =3D g_strdup_vprintf(fmt, ap); - monitor_puts(mon, buf); + n =3D monitor_puts(mon, buf); g_free(buf); + return n; } =20 -void monitor_printf(Monitor *mon, const char *fmt, ...) +int monitor_printf(Monitor *mon, const char *fmt, ...) { + int ret; + va_list ap; va_start(ap, fmt); - monitor_vprintf(mon, fmt, ap); + ret =3D monitor_vprintf(mon, fmt, ap); va_end(ap); + return ret; } =20 int monitor_fprintf(FILE *stream, const char *fmt, ...) { + int ret; + va_list ap; va_start(ap, fmt); - monitor_vprintf((Monitor *)stream, fmt, ap); + ret =3D monitor_vprintf((Monitor *)stream, fmt, ap); va_end(ap); - return 0; + return ret; } =20 static void qmp_send_response(Monitor *mon, const QDict *rsp) @@ -4535,35 +4543,32 @@ static void monitor_readline_flush(void *opaque) =20 /* * Print to current monitor if we have one, else to stream. - * TODO should return int, so callers can calculate width, but that - * requires surgery to monitor_vprintf(). Left for another day. */ -void monitor_vfprintf(FILE *stream, const char *fmt, va_list ap) +int monitor_vfprintf(FILE *stream, const char *fmt, va_list ap) { if (cur_mon && !monitor_cur_is_qmp()) { - monitor_vprintf(cur_mon, fmt, ap); - } else { - vfprintf(stream, fmt, ap); + return monitor_vprintf(cur_mon, fmt, ap); } + return vfprintf(stream, fmt, ap); } =20 /* * Print to current monitor if we have one, else to stderr. - * TODO should return int, so callers can calculate width, but that - * requires surgery to monitor_vprintf(). Left for another day. */ -void error_vprintf(const char *fmt, va_list ap) +int error_vprintf(const char *fmt, va_list ap) { - monitor_vfprintf(stderr, fmt, ap); + return monitor_vfprintf(stderr, fmt, ap); } =20 -void error_vprintf_unless_qmp(const char *fmt, va_list ap) +int error_vprintf_unless_qmp(const char *fmt, va_list ap) { - if (cur_mon && !monitor_cur_is_qmp()) { - monitor_vprintf(cur_mon, fmt, ap); - } else if (!cur_mon) { - vfprintf(stderr, fmt, ap); + if (!cur_mon) { + return vfprintf(stderr, fmt, ap); } + if (!monitor_cur_is_qmp()) { + return monitor_vprintf(cur_mon, fmt, ap); + } + return -1; } =20 static void monitor_list_append(Monitor *mon) diff --git a/stubs/error-printf.c b/stubs/error-printf.c index 99c6406668..1f9d3b3714 100644 --- a/stubs/error-printf.c +++ b/stubs/error-printf.c @@ -2,19 +2,22 @@ #include "qemu-common.h" #include "qemu/error-report.h" =20 -void error_vprintf(const char *fmt, va_list ap) +int error_vprintf(const char *fmt, va_list ap) { + int ret; + if (g_test_initialized() && !g_test_subprocess() && getenv("QTEST_SILENT_ERRORS")) { char *msg =3D g_strdup_vprintf(fmt, ap); g_test_message("%s", msg); + ret =3D strlen(msg); g_free(msg); - } else { - vfprintf(stderr, fmt, ap); + return ret; } + return vfprintf(stderr, fmt, ap); } =20 -void error_vprintf_unless_qmp(const char *fmt, va_list ap) +int error_vprintf_unless_qmp(const char *fmt, va_list ap) { - error_vprintf(fmt, ap); + return error_vprintf(fmt, ap); } diff --git a/util/qemu-error.c b/util/qemu-error.c index d08139d9ac..f373f3b3b0 100644 --- a/util/qemu-error.c +++ b/util/qemu-error.c @@ -24,22 +24,26 @@ typedef enum { REPORT_TYPE_INFO, } report_type; =20 -void error_printf(const char *fmt, ...) +int error_printf(const char *fmt, ...) { va_list ap; + int ret; =20 va_start(ap, fmt); - error_vprintf(fmt, ap); + ret =3D error_vprintf(fmt, ap); va_end(ap); + return ret; } =20 -void error_printf_unless_qmp(const char *fmt, ...) +int error_printf_unless_qmp(const char *fmt, ...) { va_list ap; + int ret; =20 va_start(ap, fmt); - error_vprintf_unless_qmp(fmt, ap); + ret =3D error_vprintf_unless_qmp(fmt, ap); va_end(ap); + return ret; } =20 static Location std_loc =3D { --=20 2.17.2 From nobody Sun May 5 04:44:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555528707; cv=none; d=zoho.com; s=zohoarc; b=BUuVFF8Cqoo3g2qaSyModWOIrdHfuVtr6arVhEAcK56L4/xGjjzSTSAVtprhDCLSszb5uHTi2uZ5m8YySrGEuNve65aOFV6C1MnzUeGT8GmvM12So7VeqAfkwyLpttT1RBmZNJAMJne1yD+9e+QgCkpRLxLxe4awBlfZtRYfxso= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555528707; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=C2+CMO0zP6I7wyAp8lVFOM7VNXWwdS2serYp8zZ+Edk=; b=k5cQIyKxKuAW/MiZIpKu8WbER26E3tKIO9TJLIYfD/BXW0ksLuxC83xbcxN34msHSeZ+Byz3UhIs3f6CoEFIxeqvUZ8/r8wcb+rhZ/o6CUqi6zE9WteBuG/EdLkysruojmLAsqTi1+VSyL2/OXuQ8UyZcglk4foK+11eT97aAFw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555528707981348.9877826227206; Wed, 17 Apr 2019 12:18:27 -0700 (PDT) Received: from localhost ([127.0.0.1]:58276 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGq4f-00088X-0L for importer@patchew.org; Wed, 17 Apr 2019 15:18:25 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60391) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGptS-0007h3-27 for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hGptQ-0003cp-He for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:4227) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hGptQ-0003b9-6I for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:48 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4C4103002725 for ; Wed, 17 Apr 2019 19:06:47 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 38B1E60C62; Wed, 17 Apr 2019 19:06:45 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2D1711132988; Wed, 17 Apr 2019 21:06:42 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Apr 2019 21:06:37 +0200 Message-Id: <20190417190641.26814-12-armbru@redhat.com> In-Reply-To: <20190417190641.26814-1-armbru@redhat.com> References: <20190417190641.26814-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Wed, 17 Apr 2019 19:06:47 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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 11/15] qemu-print: New qemu_printf(), qemu_vprintf() etc. 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: "Dr . David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We commonly want to print to the current monitor if we have one, else to stdout/stderr. For stderr, have error_printf(). For stdout, all we have is monitor_vfprintf(), which is rather unwieldy. We often print to stderr just because error_printf() is easier. New qemu_printf() and qemu_vprintf() do exactly what's needed. The next commits will put them to use. Cc: Dr. David Alan Gilbert Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Dr. David Alan Gilbert --- MAINTAINERS | 2 ++ include/qemu/qemu-print.h | 19 ++++++++++++++++++ stubs/monitor.c | 5 +++++ tests/test-util-sockets.c | 1 + util/Makefile.objs | 1 + util/qemu-print.c | 42 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 70 insertions(+) create mode 100644 include/qemu/qemu-print.h create mode 100644 util/qemu-print.c diff --git a/MAINTAINERS b/MAINTAINERS index 56139ac8ab..1aa19dc4ef 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1895,6 +1895,8 @@ F: hmp.[ch] F: hmp-commands*.hx F: include/monitor/hmp-target.h F: tests/test-hmp.c +F: include/qemu/qemu-print.h +F: util/qemu-print.c =20 Network device backends M: Jason Wang diff --git a/include/qemu/qemu-print.h b/include/qemu/qemu-print.h new file mode 100644 index 0000000000..8fed32bf42 --- /dev/null +++ b/include/qemu/qemu-print.h @@ -0,0 +1,19 @@ +/* + * Print to stream or current monitor + * + * Copyright (C) 2019 Red Hat Inc. + * + * Authors: + * Markus Armbruster , + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef QEMU_PRINT_H +#define QEMU_PRINT_H + +int qemu_vprintf(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0); +int qemu_printf(const char *fmt, ...) GCC_FMT_ATTR(1, 2); + +#endif diff --git a/stubs/monitor.c b/stubs/monitor.c index b57fe6c32f..b2ea975e40 100644 --- a/stubs/monitor.c +++ b/stubs/monitor.c @@ -6,6 +6,11 @@ =20 __thread Monitor *cur_mon; =20 +int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) +{ + abort(); +} + int monitor_get_fd(Monitor *mon, const char *name, Error **errp) { error_setg(errp, "only QEMU supports file descriptor passing"); diff --git a/tests/test-util-sockets.c b/tests/test-util-sockets.c index 6195a3ac36..fd1ced058c 100644 --- a/tests/test-util-sockets.c +++ b/tests/test-util-sockets.c @@ -70,6 +70,7 @@ int monitor_get_fd(Monitor *mon, const char *fdname, Erro= r **errp) * otherwise we get duplicate syms at link time. */ __thread Monitor *cur_mon; +int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) { abort(); } void monitor_init(Chardev *chr, int flags) {} =20 =20 diff --git a/util/Makefile.objs b/util/Makefile.objs index 835fcd69e2..9206878dec 100644 --- a/util/Makefile.objs +++ b/util/Makefile.objs @@ -23,6 +23,7 @@ util-obj-y +=3D bitmap.o bitops.o hbitmap.o util-obj-y +=3D fifo8.o util-obj-y +=3D cacheinfo.o util-obj-y +=3D error.o qemu-error.o +util-obj-y +=3D qemu-print.o util-obj-y +=3D id.o util-obj-y +=3D iov.o qemu-config.o qemu-sockets.o uri.o notify.o util-obj-y +=3D qemu-option.o qemu-progress.o diff --git a/util/qemu-print.c b/util/qemu-print.c new file mode 100644 index 0000000000..86f9417af8 --- /dev/null +++ b/util/qemu-print.c @@ -0,0 +1,42 @@ +/* + * Print to stream or current monitor + * + * Copyright (C) 2019 Red Hat Inc. + * + * Authors: + * Markus Armbruster , + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "monitor/monitor.h" +#include "qemu/qemu-print.h" + +/* + * Print like vprintf(). + * Print to current monitor if we have one, else to stdout. + */ +int qemu_vprintf(const char *fmt, va_list ap) +{ + if (cur_mon) { + return monitor_vprintf(cur_mon, fmt, ap); + } + return vprintf(fmt, ap); +} + +/* + * Print like printf(). + * Print to current monitor if we have one, else to stdout. + */ +int qemu_printf(const char *fmt, ...) +{ + va_list ap; + int ret; + + va_start(ap, fmt); + ret =3D qemu_vprintf(fmt, ap); + va_end(ap); + return ret; +} --=20 2.17.2 From nobody Sun May 5 04:44:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555528518; cv=none; d=zoho.com; s=zohoarc; b=RMyZvYQUvl7ERlhx9rPqUgk5B4Hl8sjMya+GNW9s2YLUymYlxcXIs1GMHm23ZamkojU9RWzso0uGyof92+5Oo/9rhu2IE2gykjb1jDdQyhNRsf/BwFX/WOwFPehNON10qwDfrnpWtOWCYYFT3r5JKD4/LKAeJbHgBL+4Hsm5jUU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555528518; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=BsJ1qV2Yjcj3QqoLXsxiT2nzRH91931cJZuWJsaglNA=; b=GXyNxBUzkcVNDJi8iNWiDQFsLLoTyyeIwMa7jLwiW6YimANe9UCQDEN27ftkiOvYubas7hvFbOoxqzz7RrEcijSz7IFjXI7T8Rzy/ZL51KCrEKIFKHgf7JoJQQ9KP8s7kzg2cFqzcGxiaEn5qt17ryRbmtcc2UC3Usb5lbadtG4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555528518424739.1684768393803; Wed, 17 Apr 2019 12:15:18 -0700 (PDT) Received: from localhost ([127.0.0.1]:58222 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGq1W-0005aX-5Z for importer@patchew.org; Wed, 17 Apr 2019 15:15:10 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60386) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGptR-0007gx-UO for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hGptQ-0003dO-Ur for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40274) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hGptO-0003Yi-8g; Wed, 17 Apr 2019 15:06:46 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6DA6AC04959B; Wed, 17 Apr 2019 19:06:45 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3AC0C19C58; Wed, 17 Apr 2019 19:06:45 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 35853113298A; Wed, 17 Apr 2019 21:06:42 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Apr 2019 21:06:38 +0200 Message-Id: <20190417190641.26814-13-armbru@redhat.com> In-Reply-To: <20190417190641.26814-1-armbru@redhat.com> References: <20190417190641.26814-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 17 Apr 2019 19:06:45 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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 12/15] blockdev: Make -drive format=help print to stdout 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: Kevin Wolf , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Command line help explicitly requested by the user should be printed to stdout, not stderr. We do elsewhere. Adjust -drive to match: use qemu_printf() instead of error_printf(). Plain printf() would be wrong because we need to print to the current monitor for "drive_add ... format=3Dhelp". Cc: Kevin Wolf Cc: Max Reitz Cc: qemu-block@nongnu.org Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- blockdev.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/blockdev.c b/blockdev.c index 4775a07d93..79fbac8450 100644 --- a/blockdev.c +++ b/blockdev.c @@ -40,6 +40,7 @@ #include "monitor/monitor.h" #include "qemu/error-report.h" #include "qemu/option.h" +#include "qemu/qemu-print.h" #include "qemu/config-file.h" #include "qapi/qapi-commands-block.h" #include "qapi/qapi-commands-transaction.h" @@ -301,7 +302,7 @@ DriveInfo *drive_get_next(BlockInterfaceType type) =20 static void bdrv_format_print(void *opaque, const char *name) { - error_printf(" %s", name); + qemu_printf(" %s", name); } =20 typedef struct { @@ -530,11 +531,11 @@ static BlockBackend *blockdev_init(const char *file, = QDict *bs_opts, =20 if ((buf =3D qemu_opt_get(opts, "format")) !=3D NULL) { if (is_help_option(buf)) { - error_printf("Supported formats:"); + qemu_printf("Supported formats:"); bdrv_iterate_format(bdrv_format_print, NULL, false); - error_printf("\nSupported formats (read-only):"); + qemu_printf("\nSupported formats (read-only):"); bdrv_iterate_format(bdrv_format_print, NULL, true); - error_printf("\n"); + qemu_printf("\n"); goto early_err; } =20 --=20 2.17.2 From nobody Sun May 5 04:44:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555528338; cv=none; d=zoho.com; s=zohoarc; b=hpGYMp39Hzc1vuFSdd2ONOmU6vVCWJmcJWKz5pnG5B50ddvl0rroo205GrQMBDDRdt4PBEEkqK7li6zRp70Lg3Wld3BftH0Y2jhQ9pSTvQ/KNRT0cQQcUZfvJFxUGe2mSQ6/35ACxCwKZA+bj4pLiJMQJDfQNZr4g5fAqAlOMO4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555528338; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=iPmM2Uwnu/93xgyaHKxCID/riue/9sRsZycOO+1BO4M=; b=SFwI+zeGzmGkmAMgyDbD65UkoEqTvuYTUg8I0ZUalFTB3EuZ2sNgIUN7H5sz8F0lxnmMTcjyr7lCgR2io4fX/55cF8I4Rj3XECfYSJ8PQSeQMbAokxPgqc2d+nL90CCIuKaUmmciPaB02PueWzWLKt0NFcx5F9DHNldM7HeDbd8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555528338354402.4347199846196; Wed, 17 Apr 2019 12:12:18 -0700 (PDT) Received: from localhost ([127.0.0.1]:58193 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGpyh-0003DL-AS for importer@patchew.org; Wed, 17 Apr 2019 15:12:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60358) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGptR-0007g9-FN for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hGptQ-0003cc-Dm for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56650) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hGptQ-0003bA-58 for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:48 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5052B3084212 for ; Wed, 17 Apr 2019 19:06:47 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3EEFC608C7; Wed, 17 Apr 2019 19:06:45 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 3ED04113292F; Wed, 17 Apr 2019 21:06:42 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Apr 2019 21:06:39 +0200 Message-Id: <20190417190641.26814-14-armbru@redhat.com> In-Reply-To: <20190417190641.26814-1-armbru@redhat.com> References: <20190417190641.26814-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Wed, 17 Apr 2019 19:06:47 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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 13/15] char: Make -chardev help print to stdout 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Command line help explicitly requested by the user should be printed to stdout, not stderr. We do elsewhere. Adjust -chardev to match: use qemu_printf() instead of error_printf(). Plain printf() would be wrong because we need to print to the current monitor for "chardev-add help". Cc: "Marc-Andr=C3=A9 Lureau" Cc: Paolo Bonzini Signed-off-by: Markus Armbruster Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- chardev/char.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chardev/char.c b/chardev/char.c index 514cd6b0c3..54724a56b1 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -28,6 +28,7 @@ #include "sysemu/sysemu.h" #include "qemu/config-file.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #include "chardev/char.h" #include "qapi/error.h" #include "qapi/qapi-commands-char.h" @@ -651,7 +652,7 @@ Chardev *qemu_chr_new_from_opts(QemuOpts *opts, GMainCo= ntext *context, =20 chardev_name_foreach(help_string_append, str); =20 - error_printf("Available chardev backend types: %s\n", str->str); + qemu_printf("Available chardev backend types: %s\n", str->str); g_string_free(str, true); return NULL; } --=20 2.17.2 From nobody Sun May 5 04:44:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555528154; cv=none; d=zoho.com; s=zohoarc; b=Gw1plMLGCYy3/aq185shH7sfJ3a1suzrldqnzj0D36ZoO+dBltPVRp6tMu0cQ3DmCXTHku3qpproytKTD/u7a0cLkP5FCFw00Lv/zOZ59jiWk59h+XFHfJCeYis7nzvUot5/bgvBYpqPQ0l4hQWP2mn+8xy5czs15zMXQpMLfkA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555528154; h=Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=7xx9/F0xM7VPX2izJng/3jBPSejbmWYtCb08Mlb4iP0=; b=VsDt4R9DmyiwI8uLZC4xMdrJdspzMJ3jZS+mYTnsAWslN2+bktYwKkp2+RYw3itZ9IbnOnJdmY39o8d+PE3H0LdJ+VNJhUpwCJAjERl8w1I4DW63uvuFbTnnS+awI3E6UcGYwYyo+5YoMhXXe1udMwD839rWO3Bv4HlRwV4pW6c= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555528154548189.60254143863324; Wed, 17 Apr 2019 12:09:14 -0700 (PDT) Received: from localhost ([127.0.0.1]:58136 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGpvb-0000Vi-T0 for importer@patchew.org; Wed, 17 Apr 2019 15:09:03 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60259) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGptP-0007eF-I2 for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hGptO-0003Zt-JN for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56640) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hGptO-0003Yk-9a for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:46 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 74DF930031AC for ; Wed, 17 Apr 2019 19:06:45 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 447FD60C64 for ; Wed, 17 Apr 2019 19:06:45 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4555911327DB; Wed, 17 Apr 2019 21:06:42 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Apr 2019 21:06:40 +0200 Message-Id: <20190417190641.26814-15-armbru@redhat.com> In-Reply-To: <20190417190641.26814-1-armbru@redhat.com> References: <20190417190641.26814-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Wed, 17 Apr 2019 19:06:45 +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 14/15] char-pty: Print "char device redirected" message to stdout 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" char_pty_open() prints a "char device redirected to PTY_NAME (label LABEL)" message to the current monitor or else to stderr. This is not an error, so it shouldn't go to stderr. Print it to stdout instead. Why is it even printed? No other ChardevClass::open() prints anything on success. It's because you need to know PTY_NAME to actually use this char device, e.g. like e.g. "socat STDIO,cfmakeraw FILE:PTY_NAME" to use the monitor's readline interface. You can get PTY_NAME with "info chardev" (a.k.a. query-chardev for QMP), but only if you already have a monitor. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- chardev/char-pty.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/chardev/char-pty.c b/chardev/char-pty.c index b034332edd..04759b0ef9 100644 --- a/chardev/char-pty.c +++ b/chardev/char-pty.c @@ -28,6 +28,7 @@ #include "io/channel-file.h" #include "qemu/sockets.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" =20 #include "chardev/char-io.h" =20 @@ -211,8 +212,8 @@ static void char_pty_open(Chardev *chr, qemu_set_nonblock(master_fd); =20 chr->filename =3D g_strdup_printf("pty:%s", pty_name); - error_printf("char device redirected to %s (label %s)\n", - pty_name, chr->label); + qemu_printf("char device redirected to %s (label %s)\n", + pty_name, chr->label); =20 s =3D PTY_CHARDEV(chr); s->ioc =3D QIO_CHANNEL(qio_channel_file_new_fd(master_fd)); --=20 2.17.2 From nobody Sun May 5 04:44:51 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555528164; cv=none; d=zoho.com; s=zohoarc; b=Ue6MIIjsmnxBP1/c0qvbed8RSqWz+pBhQISzAt3nyXqw9bChvAnldhxDNVspJT0Iu6qW1jok4uIlu1AI5SlXCt5SB1FQlCuyRW7q6pxawfKwT26/uoT29++66SXjBG0CFyvTl3GObIwJo18ynZW46C9VmRMFom+LIw3h2MUcjCI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555528164; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=IfY71svwZG4+WMFTFv/M1tZW78r+WU66WyCIv+838CQ=; b=J6t9AdeifXygB+4qPdwBMXvendr5JMl051fDHU4L9O2ZGz2j62YKVwszO+n3bDrR2erpH9XOz6YSZn1xTyUVQAqnB0tI/bMhlVnk/1D1CxLMWZHdPF4q2tbfuHC120H/xnfIes9Tnp3y0tbJwJWzt6HAUWkNh+eKdq1tN17xfdk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555528164087982.2088749040834; Wed, 17 Apr 2019 12:09:24 -0700 (PDT) Received: from localhost ([127.0.0.1]:58138 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGpvj-0000ct-W1 for importer@patchew.org; Wed, 17 Apr 2019 15:09:12 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60350) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGptR-0007g3-Cq for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hGptQ-0003bm-23 for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55474) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hGptP-0003ac-NK for qemu-devel@nongnu.org; Wed, 17 Apr 2019 15:06:47 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EDD0EC058CAF for ; Wed, 17 Apr 2019 19:06:46 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 917245D9E1; Wed, 17 Apr 2019 19:06:46 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4BE9C1132783; Wed, 17 Apr 2019 21:06:42 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 17 Apr 2019 21:06:41 +0200 Message-Id: <20190417190641.26814-16-armbru@redhat.com> In-Reply-To: <20190417190641.26814-1-armbru@redhat.com> References: <20190417190641.26814-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 17 Apr 2019 19:06:46 +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 15/15] monitor: Simplify how -device/device_add print help 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: "Dr . David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Commit a95db58f210 added monitor_vfprintf() as an error_printf() generalized from stderr to arbitrary streams, then used it wrapped in helper out_printf() to print -device/device_add help to stdout. Use qemu_printf() instead, and delete monitor_vfprintf() and out_printf(). Cc: Dr. David Alan Gilbert Signed-off-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert --- include/monitor/monitor.h | 3 --- monitor.c | 16 ++++------------ qdev-monitor.c | 36 ++++++++++++++---------------------- 3 files changed, 18 insertions(+), 37 deletions(-) diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h index e4c3717454..316a168c41 100644 --- a/include/monitor/monitor.h +++ b/include/monitor/monitor.h @@ -48,7 +48,4 @@ int monitor_fdset_dup_fd_add(int64_t fdset_id, int dup_fd= ); void monitor_fdset_dup_fd_remove(int dup_fd); int monitor_fdset_dup_fd_find(int dup_fd); =20 -int monitor_vfprintf(FILE *stream, - const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0); - #endif /* MONITOR_H */ diff --git a/monitor.c b/monitor.c index 7b4a78d798..10be8bdb86 100644 --- a/monitor.c +++ b/monitor.c @@ -4541,23 +4541,15 @@ static void monitor_readline_flush(void *opaque) monitor_flush(opaque); } =20 -/* - * Print to current monitor if we have one, else to stream. - */ -int monitor_vfprintf(FILE *stream, const char *fmt, va_list ap) -{ - if (cur_mon && !monitor_cur_is_qmp()) { - return monitor_vprintf(cur_mon, fmt, ap); - } - return vfprintf(stream, fmt, ap); -} - /* * Print to current monitor if we have one, else to stderr. */ int error_vprintf(const char *fmt, va_list ap) { - return monitor_vfprintf(stderr, fmt, ap); + if (cur_mon && !monitor_cur_is_qmp()) { + return monitor_vprintf(cur_mon, fmt, ap); + } + return vfprintf(stderr, fmt, ap); } =20 int error_vprintf_unless_qmp(const char *fmt, va_list ap) diff --git a/qdev-monitor.c b/qdev-monitor.c index d4320986a2..373b9ad445 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -31,6 +31,7 @@ #include "qemu/error-report.h" #include "qemu/help_option.h" #include "qemu/option.h" +#include "qemu/qemu-print.h" #include "sysemu/block-backend.h" #include "migration/misc.h" =20 @@ -104,31 +105,22 @@ static bool qdev_class_has_alias(DeviceClass *dc) return (qdev_class_get_alias(dc) !=3D NULL); } =20 -static void out_printf(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - monitor_vfprintf(stdout, fmt, ap); - va_end(ap); -} - static void qdev_print_devinfo(DeviceClass *dc) { - out_printf("name \"%s\"", object_class_get_name(OBJECT_CLASS(dc))); + qemu_printf("name \"%s\"", object_class_get_name(OBJECT_CLASS(dc))); if (dc->bus_type) { - out_printf(", bus %s", dc->bus_type); + qemu_printf(", bus %s", dc->bus_type); } if (qdev_class_has_alias(dc)) { - out_printf(", alias \"%s\"", qdev_class_get_alias(dc)); + qemu_printf(", alias \"%s\"", qdev_class_get_alias(dc)); } if (dc->desc) { - out_printf(", desc \"%s\"", dc->desc); + qemu_printf(", desc \"%s\"", dc->desc); } if (!dc->user_creatable) { - out_printf(", no-user"); + qemu_printf(", no-user"); } - out_printf("\n"); + qemu_printf("\n"); } =20 static void qdev_print_devinfos(bool show_no_user) @@ -164,7 +156,7 @@ static void qdev_print_devinfos(bool show_no_user) continue; } if (!cat_printed) { - out_printf("%s%s devices:\n", i ? "\n" : "", cat_name[i]); + qemu_printf("%s%s devices:\n", i ? "\n" : "", cat_name[i]); cat_printed =3D true; } qdev_print_devinfo(dc); @@ -286,20 +278,20 @@ int qdev_device_help(QemuOpts *opts) } =20 if (prop_list) { - out_printf("%s options:\n", driver); + qemu_printf("%s options:\n", driver); } else { - out_printf("There are no options for %s.\n", driver); + qemu_printf("There are no options for %s.\n", driver); } for (prop =3D prop_list; prop; prop =3D prop->next) { int len; - out_printf(" %s=3D<%s>%n", prop->value->name, prop->value->type, = &len); + qemu_printf(" %s=3D<%s>%n", prop->value->name, prop->value->type,= &len); if (prop->value->has_description) { if (len < 24) { - out_printf("%*s", 24 - len, ""); + qemu_printf("%*s", 24 - len, ""); } - out_printf(" - %s\n", prop->value->description); + qemu_printf(" - %s\n", prop->value->description); } else { - out_printf("\n"); + qemu_printf("\n"); } } =20 --=20 2.17.2