From patchwork Wed Oct 28 15:33:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 537451 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A03101402B2 for ; Thu, 29 Oct 2015 02:49:20 +1100 (AEDT) Received: from localhost ([::1]:38978 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrSyU-00086C-Lz for incoming@patchwork.ozlabs.org; Wed, 28 Oct 2015 11:49:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47262) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrSjl-00014b-5o for qemu-devel@nongnu.org; Wed, 28 Oct 2015 11:34:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZrSjj-00048U-Fo for qemu-devel@nongnu.org; Wed, 28 Oct 2015 11:34:05 -0400 Received: from smtp3.mundo-r.com ([212.51.32.191]:34358 helo=smtp4.mundo-r.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZrSjj-00047x-9I; Wed, 28 Oct 2015 11:34:03 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2BADgBI6jBW/5tjdVteGQEBAg4BAQGDCIFDqhIBAQEBAQEFAYENAY9ChgmGGwKBOzsRAQEBAQEBAYEKQRMBg2EBAQR5EDgHEjwbGYg0AcYDAQEBByOGMIpVBwqEJAWHQoVZgTCHco0kgVmHY5J4NyyCRIFCcIIRg2wBAQE X-IPAS-Result: A2BADgBI6jBW/5tjdVteGQEBAg4BAQGDCIFDqhIBAQEBAQEFAYENAY9ChgmGGwKBOzsRAQEBAQEBAYEKQRMBg2EBAQR5EDgHEjwbGYg0AcYDAQEBByOGMIpVBwqEJAWHQoVZgTCHco0kgVmHY5J4NyyCRIFCcIIRg2wBAQE X-IronPort-AV: E=Sophos;i="5.20,210,1444687200"; d="scan'208";a="39053382" Received: from fanzine.igalia.com ([91.117.99.155]) by smtp4.mundo-r.com with ESMTP; 28 Oct 2015 16:33:57 +0100 Received: from 85-76-137-228-nat.elisa-mobile.fi ([85.76.137.228] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim) id 1ZrSjc-0001Md-Py; Wed, 28 Oct 2015 16:33:57 +0100 Received: from berto by perseus.local with local (Exim 4.86) (envelope-from ) id 1ZrSj2-0006Wk-Da; Wed, 28 Oct 2015 17:33:20 +0200 From: Alberto Garcia To: qemu-devel@nongnu.org Date: Wed, 28 Oct 2015 17:33:07 +0200 Message-Id: <41cbcd334a61c6157f0f495cdfd21eff6c156f2a.1446044837.git.berto@igalia.com> X-Mailer: git-send-email 2.6.1 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.51.32.191 Cc: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Markus Armbruster , Max Reitz , Stefan Hajnoczi Subject: [Qemu-devel] [PATCH v4 10/21] block: New option to define the intervals for collecting I/O statistics X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The BlockAcctStats structure contains a list of BlockAcctTimedStats. Each one of these collects statistics about the minimum, maximum and average latencies of all I/O operations in a certain interval of time. This patch adds a new "stats-intervals" option that allows defining these intervals. Signed-off-by: Alberto Garcia --- blockdev.c | 37 +++++++++++++++++++++++++++++++++++++ qapi/block-core.json | 4 ++++ 2 files changed, 41 insertions(+) diff --git a/blockdev.c b/blockdev.c index 82cd6a0..b060385 100644 --- a/blockdev.c +++ b/blockdev.c @@ -468,6 +468,7 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts, int bdrv_flags = 0; int on_read_error, on_write_error; bool account_invalid, account_failed; + const char *stats_intervals; BlockBackend *blk; BlockDriverState *bs; ThrottleConfig cfg; @@ -507,6 +508,8 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts, account_invalid = qemu_opt_get_bool(opts, "stats-account-invalid", true); account_failed = qemu_opt_get_bool(opts, "stats-account-failed", true); + stats_intervals = qemu_opt_get(opts, "stats-intervals"); + extract_common_blockdev_options(opts, &bdrv_flags, &throttling_group, &cfg, &detect_zeroes, &error); if (error) { @@ -605,6 +608,35 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts, } block_acct_init(blk_get_stats(blk), account_invalid, account_failed); + + if (stats_intervals) { + char **intervals = g_strsplit(stats_intervals, ":", 0); + unsigned i; + + if (*stats_intervals == '\0') { + error_setg(&error, "stats-intervals can't have an empty value"); + } + + for (i = 0; !error && intervals[i] != NULL; i++) { + unsigned long long val; + if (parse_uint_full(intervals[i], &val, 10) == 0 && + val > 0 && val <= UINT_MAX) { + block_acct_add_interval(blk_get_stats(blk), val); + } else { + error_setg(&error, "Invalid interval length: '%s'", + intervals[i]); + } + } + + g_strfreev(intervals); + + if (error) { + error_propagate(errp, error); + blk_unref(blk); + blk = NULL; + goto err_no_bs_opts; + } + } } blk_set_on_error(blk, on_read_error, on_write_error); @@ -3420,6 +3452,11 @@ QemuOptsList qemu_common_drive_opts = { .type = QEMU_OPT_BOOL, .help = "whether to account for failed I/O operations " "in the statistics", + },{ + .name = "stats-intervals", + .type = QEMU_OPT_STRING, + .help = "colon-separated list of intervals " + "for collecting I/O statistics, in seconds", }, { /* end of list */ } }, diff --git a/qapi/block-core.json b/qapi/block-core.json index 0742794..273d073 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1503,6 +1503,9 @@ # @stats-account-failed: #optional whether to include failed # operations when computing latency and last # access statistics (default: true) (Since 2.5) +# @stats-intervals: #optional colon-separated list of intervals for +# collecting I/O statistics, in seconds (default: none) +# (Since 2.5) # @detect-zeroes: #optional detect and optimize zero writes (Since 2.1) # (default: off) # @@ -1520,6 +1523,7 @@ '*read-only': 'bool', '*stats-account-invalid': 'bool', '*stats-account-failed': 'bool', + '*stats-intervals': 'str', '*detect-zeroes': 'BlockdevDetectZeroesOptions' } } ##