From patchwork Thu Oct 18 10:42:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhenwei pi X-Patchwork-Id: 10647297 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 1E203112B for ; Thu, 18 Oct 2018 14:29:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D75D28B24 for ; Thu, 18 Oct 2018 14:29:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01C9428B2A; Thu, 18 Oct 2018 14:29:27 +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 4096328B24 for ; Thu, 18 Oct 2018 14:29:27 +0000 (UTC) Received: from localhost ([::1]:42659 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD9Ik-0004HG-GW for patchwork-qemu-devel@patchwork.kernel.org; Thu, 18 Oct 2018 10:29:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58173) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD5kv-0005I1-Sa for qemu-devel@nongnu.org; Thu, 18 Oct 2018 06:42:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gD5ks-0001wT-Iy for qemu-devel@nongnu.org; Thu, 18 Oct 2018 06:42:17 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:39513) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gD5ks-0001ve-9C for qemu-devel@nongnu.org; Thu, 18 Oct 2018 06:42:14 -0400 Received: by mail-pl1-x641.google.com with SMTP id e67-v6so5165865plb.6 for ; Thu, 18 Oct 2018 03:42:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding:content-language; bh=m41Zw6QI3Bhrmhoen1ZwmX3HcwdCQMSSGVhEL0m6NJU=; b=DPpGw6r7Gy1uSF2nBpJ5bdCiQGv+wP6dQ3iN0rYRU8VY4uNie7+bSEr09AJ4IKrjy7 jiny6nypk7feoWB7zIJReQrmSlLJdWMU3a6+4+dwSst6/Ztlbhqbn4sOR3VwS4q+AlhE WeOShHJqHTbtGdJ/BCRMZpg3ACrn1YvDiEguMOOzbiBtvl6EKzVANgZ5zjF46shQE1fP 6TV+cA3S7OIVDR0Jn9ut4hMC8hZhfz2A5TSl3tJVROxwMVTB3ta2wYlxgBF7IGQHGLAb lbhaT1G7tVN+T/gCuyLOe1r71j1oqXqcSdSzkc8q5efBb4i2iBwmvQWlrnFnRBxcT17s dtKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding:content-language; bh=m41Zw6QI3Bhrmhoen1ZwmX3HcwdCQMSSGVhEL0m6NJU=; b=NL2GkDUw+IA/4Z5TEwJsXFsTO27Nxrsm7kw8HOpm7CoSHGMUTfK3we+RvbbuS/3TtV 1iX01G2cNb8I5StT1klRHGPxiBeevSMI5FPcVFm25Wh2mXsCllJdZC7lDgBMunSj5F1X tiiAR9gsFH2vzvXIULTuDM8+B29FrwIcop+Myal9QhxAp6iMIDbDWdhzki0vscC9jO8L 2YM2k9ypVWc3gS14JtVRak0sfC49Ia1lEa7HcPTlYASrt4fr4SB9R1dleS4WGL45Y70R vD4hafmUHXunjWwcOSvYMpZ5alWQ5iRffGNiKkp2CLUVttMCE7pjMU01Nje6NY7CAqVh 6huA== X-Gm-Message-State: ABuFfoj4zUiF5xE15evbbTPGzvsgHIKc7ZcQALOgaLxkm0a8ftxzbX0W MlyA/fg+VwxNxrB9e6m8M0SenA== X-Google-Smtp-Source: ACcGV63FKswQKStkZEDHUzdrKcf7tbCJUEPCAvbWDq2/vQoCzmjBwSPlAeTfnGrIyNSLzVL/HIWG/Q== X-Received: by 2002:a17:902:7897:: with SMTP id q23-v6mr29977421pll.54.1539859332781; Thu, 18 Oct 2018 03:42:12 -0700 (PDT) Received: from [10.2.9.206] ([203.12.205.220]) by smtp.gmail.com with ESMTPSA id g87-v6sm25604028pfj.34.2018.10.18.03.42.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Oct 2018 03:42:11 -0700 (PDT) To: kwolf@redhat.com, mreitz@redhat.com From: zhenwei pi Message-ID: Date: Thu, 18 Oct 2018 18:42:09 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 X-Mailman-Approved-At: Thu, 18 Oct 2018 10:27:29 -0400 Subject: [Qemu-devel] [PATCH] blockdev: report 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-devel@nongnu.org, qemu-block@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; + } } }