From patchwork Tue Jul 24 11:03:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 172877 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 792B12C0090 for ; Tue, 24 Jul 2012 22:45:45 +1000 (EST) Received: from localhost ([::1]:40462 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StcwA-0007eY-PW for incoming@patchwork.ozlabs.org; Tue, 24 Jul 2012 07:05:58 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56738) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Stcvw-0007GO-Er for qemu-devel@nongnu.org; Tue, 24 Jul 2012 07:05:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Stcvo-0005eN-UT for qemu-devel@nongnu.org; Tue, 24 Jul 2012 07:05:44 -0400 Received: from mail-gh0-f173.google.com ([209.85.160.173]:59147) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Stcvo-0005Rh-QD for qemu-devel@nongnu.org; Tue, 24 Jul 2012 07:05:36 -0400 Received: by mail-gh0-f173.google.com with SMTP id r14so6581704ghr.4 for ; Tue, 24 Jul 2012 04:05:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=ZgYENyGpe0rxhL2g3NxpKHIObH9a0cCxJIgK+AxEBNk=; b=d1FgAZHBR74ebyTbKakonpY7EvgnD0yRLKJefW1E2chemimXsTEnUhcydnr9OFOjqV BRxwhLMlTihovsZu9NxeVrvvUwvZhk1BKHwYeXBzKOSBQaX4q4uylXcBX08RNrKv1WY8 /78j+tbXYBIkjJlhkNvn/sSGFz8dLn8bc/0KXZXI/ACV4ZEryyjE7VreUlBGJil+isEn pCa4NViQr/84iL6Yn6urG1CQ52H9zFwR9mBAz3dsdO12DNbsES5EjSYoZH31W7hXfQNI 7wo5KC4yaOYmWExpiIDS+yWU96GuQEJeegJDBkuxhTqXyOrZaTOYwhdks0rS0f5Ppt9L NHEA== Received: by 10.43.92.71 with SMTP id bp7mr14560970icc.52.1343127936485; Tue, 24 Jul 2012 04:05:36 -0700 (PDT) Received: from yakj.usersys.redhat.com (93-34-189-113.ip51.fastwebnet.it. [93.34.189.113]) by mx.google.com with ESMTPS id if4sm1752561igc.10.2012.07.24.04.05.33 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 24 Jul 2012 04:05:35 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 24 Jul 2012 13:03:58 +0200 Message-Id: <1343127865-16608-21-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1343127865-16608-1-git-send-email-pbonzini@redhat.com> References: <1343127865-16608-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.173 Cc: kwolf@redhat.com, jcody@redhat.com, eblake@redhat.com, stefanha@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH 20/47] block: add bdrv_query_stats 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 Extract it out of the implementation of "info blockstats". Signed-off-by: Paolo Bonzini --- block.c | 17 ++++++----------- block.h | 1 + 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/block.c b/block.c index 591e027..19da114 100644 --- a/block.c +++ b/block.c @@ -2467,7 +2467,7 @@ BlockInfoList *qmp_query_block(Error **errp) } /* Consider exposing this as a full fledged QMP command */ -static BlockStats *qmp_query_blockstat(const BlockDriverState *bs, Error **errp) +BlockStats *bdrv_query_stats(const BlockDriverState *bs) { BlockStats *s; @@ -2491,7 +2491,7 @@ static BlockStats *qmp_query_blockstat(const BlockDriverState *bs, Error **errp) if (bs->file) { s->has_parent = true; - s->parent = qmp_query_blockstat(bs->file, NULL); + s->parent = bdrv_query_stats(bs->file); } return s; @@ -2547,20 +2547,15 @@ BlockInfo *bdrv_query_info(BlockDriverState *bs) BlockStatsList *qmp_query_blockstats(Error **errp) { - BlockStatsList *head = NULL, *cur_item = NULL; + BlockStatsList *head = NULL, **p_next = &head; BlockDriverState *bs; QTAILQ_FOREACH(bs, &bdrv_states, list) { BlockStatsList *info = g_malloc0(sizeof(*info)); - info->value = qmp_query_blockstat(bs, NULL); + info->value = bdrv_query_stats(bs); - /* XXX: waiting for the qapi to support GSList */ - if (!cur_item) { - head = cur_item = info; - } else { - cur_item->next = info; - cur_item = info; - } + *p_next = info; + p_next = &info->next; } return head; diff --git a/block.h b/block.h index ba99585..9bff842 100644 --- a/block.h +++ b/block.h @@ -289,6 +289,7 @@ void bdrv_get_backing_filename(BlockDriverState *bs, void bdrv_get_full_backing_filename(BlockDriverState *bs, char *dest, size_t sz); BlockInfo *bdrv_query_info(BlockDriverState *s); +BlockStats *bdrv_query_stats(const BlockDriverState *bs); int bdrv_can_snapshot(BlockDriverState *bs); int bdrv_is_snapshot(BlockDriverState *bs); BlockDriverState *bdrv_snapshots(void);