From patchwork Mon Oct 22 14:02:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 10652175 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 34E5814E2 for ; Mon, 22 Oct 2018 14:05:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BF0E28A32 for ; Mon, 22 Oct 2018 14:05:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D75B28A6B; Mon, 22 Oct 2018 14:05:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2A56A28A5A for ; Mon, 22 Oct 2018 14:05:36 +0000 (UTC) Received: from localhost ([::1]:35451 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEapq-0004L7-Is for patchwork-qemu-devel@patchwork.kernel.org; Mon, 22 Oct 2018 10:05:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42574) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEamp-0002BY-JU for qemu-devel@nongnu.org; Mon, 22 Oct 2018 10:02:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEamj-0003hW-7W for qemu-devel@nongnu.org; Mon, 22 Oct 2018 10:02:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38516) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gEamY-0003YE-Ki; Mon, 22 Oct 2018 10:02:10 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D44E13084028; Mon, 22 Oct 2018 14:02:09 +0000 (UTC) Received: from magic.redhat.com (unknown [10.40.205.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5ECEA74ABC; Mon, 22 Oct 2018 14:02:05 +0000 (UTC) From: Fam Zheng To: qemu-devel@nongnu.org Date: Mon, 22 Oct 2018 22:02:04 +0800 Message-Id: <20181022140204.15791-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Mon, 22 Oct 2018 14:02:09 +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] file-posix: Use error API properly 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 , armbru@redhat.com, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Use error_report for situations that affect user operation (i.e. we're actually returning error), and warn_report/warn_report_err when some less critical error happened but the user operation can still carry on. Suggested-by: Markus Armbruster Signed-off-by: Fam Zheng --- block/file-posix.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index 2da3a76355..2a46899313 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -214,8 +214,7 @@ static int raw_normalize_devicepath(const char **filename) fname = *filename; dp = strrchr(fname, '/'); if (lstat(fname, &sb) < 0) { - fprintf(stderr, "%s: stat failed: %s\n", - fname, strerror(errno)); + error_report("%s: stat failed: %s", fname, strerror(errno)); return -errno; } @@ -229,9 +228,8 @@ static int raw_normalize_devicepath(const char **filename) snprintf(namebuf, PATH_MAX, "%.*s/r%s", (int)(dp - fname), fname, dp + 1); } - fprintf(stderr, "%s is a block device", fname); *filename = namebuf; - fprintf(stderr, ", using %s\n", *filename); + warn_report("%s is a block device, using %s", fname, *filename); return 0; } @@ -492,11 +490,11 @@ static int raw_open_common(BlockDriverState *bs, QDict *options, case ON_OFF_AUTO_ON: s->use_lock = true; if (!qemu_has_ofd_lock()) { - fprintf(stderr, + warn_report( "File lock requested but OFD locking syscall is " - "unavailable, falling back to POSIX file locks.\n" + "unavailable, falling back to POSIX file locks. " "Due to the implementation, locks can be lost " - "unexpectedly.\n"); + "unexpectedly."); } break; case ON_OFF_AUTO_OFF: @@ -805,7 +803,7 @@ static int raw_handle_perm_lock(BlockDriverState *bs, /* Theoretically the above call only unlocks bytes and it cannot * fail. Something weird happened, report it. */ - error_report_err(local_err); + warn_report_err(local_err); } break; case RAW_PL_COMMIT: @@ -815,7 +813,7 @@ static int raw_handle_perm_lock(BlockDriverState *bs, /* Theoretically the above call only unlocks bytes and it cannot * fail. Something weird happened, report it. */ - error_report_err(local_err); + warn_report_err(local_err); } break; } @@ -1775,7 +1773,7 @@ static int aio_worker(void *arg) ret = handle_aiocb_truncate(aiocb); break; default: - fprintf(stderr, "invalid aio request (0x%x)\n", aiocb->aio_type); + error_report("invalid aio request (0x%x)", aiocb->aio_type); ret = -EINVAL; break; } @@ -2263,7 +2261,7 @@ out_unlock: * not mean the whole creation operation has failed. So * report it the user for their convenience, but do not report * it to the caller. */ - error_report_err(local_err); + warn_report_err(local_err); } out_close: