From patchwork Mon Nov 5 03:04:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhenwei pi X-Patchwork-Id: 10667371 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 B8DB113A4 for ; Mon, 5 Nov 2018 03:06:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92A0C294DB for ; Mon, 5 Nov 2018 03:06:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E8E029666; Mon, 5 Nov 2018 03:06:07 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 7BA18294DB for ; Mon, 5 Nov 2018 03:06:06 +0000 (UTC) Received: from localhost ([::1]:32943 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJVDJ-0003GK-Bi for patchwork-qemu-devel@patchwork.kernel.org; Sun, 04 Nov 2018 22:06:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39624) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJVCX-0002om-Uc for qemu-devel@nongnu.org; Sun, 04 Nov 2018 22:05:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gJVCU-0007iZ-2r for qemu-devel@nongnu.org; Sun, 04 Nov 2018 22:05:17 -0500 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:44685) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gJVCT-0007hp-QE for qemu-devel@nongnu.org; Sun, 04 Nov 2018 22:05:13 -0500 Received: by mail-pl1-x642.google.com with SMTP id s5-v6so3687159plq.11 for ; Sun, 04 Nov 2018 19:05:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=m41Zw6QI3Bhrmhoen1ZwmX3HcwdCQMSSGVhEL0m6NJU=; b=ACOqxC+xjMw/Ww6Q3x2MIw15XCwWIS/v8LLdcSc6jDh7dEOPRpTj+MbeUEm18oGHd8 1O6fYQus7B6ZrLObJXfRh9cHCBg1J0r1HGXOff6ZgjiBz9xxdKSXgp+36G0LiwVU3LAo vT52ILKsudLJXmJ2vpJ+yI9zDbTMuRZ41QQGWp3CCWHqzioP/uQ5ZuRwsfrA7Jd5OjmV HOsQHM1NjhYX/R/5Jgeui2WHsrhp359xU2OUBlGFbT0z69gT2DK1w5ikfNZi8R0y1yZ9 bHymmFShm8v6yJvtoL6pLx698kFjYVS3GsB1eNmhOxpU77/EIujxGDfX0mmoAQT3yWrG 95og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=m41Zw6QI3Bhrmhoen1ZwmX3HcwdCQMSSGVhEL0m6NJU=; b=ttfxZJNREtDVvZYvOfvd7vpuD85ssnAHO+YQbn5gVM83F+DzYyATLvwo+HpB5W6NOu cb82GtYs5BB8qJqDm2cDihDiIXAdYgsnwZqmzcEH2h7F74Pjn3zFPq4bqiN8ziHq7HTp 9CPEcWGtub89rGERR9dzomEzkn6weBEzVlH2qDGbT1TWg8wdm+NBMgAFi2C7F84orCqR jpXj7mCr6lxonf/s/l6I9AsYA0pG6Dmvogd9W1OTn1UUCtjtDsXkqf59G67Dg7lhy164 v5eJ8uAibppQqIcXgbuz1KZvAoEXiKl0x3E3DmlcROo58xla5K+Fw2BWF+yudq68U8Ze 3QUg== X-Gm-Message-State: AGRZ1gKqyLOvaOQyH2iGXbDl7+FXOmoo6OSZHpKeWDMCyUigzV9L034C UFRZkg1P3PbLjvF1nGx1viLc4w== X-Google-Smtp-Source: AJdET5e74B3XDWEI9QX4iUNPQbrSDuFOcg51YUAJOOASm7CwX6x7BUH0R0/oMna1NYI69poEo9fVUg== X-Received: by 2002:a17:902:7845:: with SMTP id e5-v6mr9828636pln.104.1541387111986; Sun, 04 Nov 2018 19:05:11 -0800 (PST) Received: from always-ThinkPad-T480.bytedance.net ([203.12.205.220]) by smtp.gmail.com with ESMTPSA id b11-v6sm30657143pgi.10.2018.11.04.19.05.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 04 Nov 2018 19:05:11 -0800 (PST) From: zhenwei pi To: kwolf@redhat.com, armbru@redhat.com, mreitz@redhat.com Date: Mon, 5 Nov 2018 11:04:56 +0800 Message-Id: <1541387096-19513-1-git-send-email-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.7.4 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::642 Subject: [Qemu-devel] [PATCH] blockdev: handle error on block latency histogram set error 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: vsementsov@virtuozzo.com, qemu-block@nongnu.org, pizhenwei@bytedance.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Function block_latency_histogram_set may return error, but qapi ignore this. This can be reproduced easily by qmp command: virsh qemu-monitor-command INSTANCE '{"execute":"x-block-latency-histogram-set", "arguments":{"device":"drive-virtio-disk1","boundaries":[10,200,40]}}' In fact this command does not work, but we still get success result. qmp_x_block_latency_histogram_set is a batch setting API, report error ASAP. Signed-off-by: zhenwei pi --- blockdev.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/blockdev.c b/blockdev.c index a8755bd..03b1aa3 100644 --- a/blockdev.c +++ b/blockdev.c @@ -4377,6 +4377,7 @@ void qmp_x_block_latency_histogram_set( { BlockBackend *blk = blk_by_name(device); BlockAcctStats *stats; + int ret; if (!blk) { error_setg(errp, "Device '%s' not found", device); @@ -4392,21 +4393,33 @@ void qmp_x_block_latency_histogram_set( } if (has_boundaries || has_boundaries_read) { - block_latency_histogram_set( + ret = block_latency_histogram_set( stats, BLOCK_ACCT_READ, has_boundaries_read ? boundaries_read : boundaries); + if (ret) { + error_setg(errp, "Device '%s' set read boundaries fail", device); + return; + } } if (has_boundaries || has_boundaries_write) { - block_latency_histogram_set( + ret = block_latency_histogram_set( stats, BLOCK_ACCT_WRITE, has_boundaries_write ? boundaries_write : boundaries); + if (ret) { + error_setg(errp, "Device '%s' set write boundaries fail", device); + return; + } } if (has_boundaries || has_boundaries_flush) { - block_latency_histogram_set( + ret = block_latency_histogram_set( stats, BLOCK_ACCT_FLUSH, has_boundaries_flush ? boundaries_flush : boundaries); + if (ret) { + error_setg(errp, "Device '%s' set flush boundaries fail", device); + return; + } } }