From patchwork Sun Sep 17 17:49:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Cline X-Patchwork-Id: 9954979 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7D0B860352 for ; Sun, 17 Sep 2017 17:50:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B96228B45 for ; Sun, 17 Sep 2017 17:50:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 607F528B79; Sun, 17 Sep 2017 17:50:17 +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.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 775EA28B36 for ; Sun, 17 Sep 2017 17:50:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751685AbdIQRtx (ORCPT ); Sun, 17 Sep 2017 13:49:53 -0400 Received: from a8-126.smtp-out.amazonses.com ([54.240.8.126]:45430 "EHLO a8-126.smtp-out.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751551AbdIQRtw (ORCPT ); Sun, 17 Sep 2017 13:49:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=rdybrs3533vx7mghocfwl3vdwgpl2v5u; d=jcline.org; t=1505670591; h=From:To:Cc:Subject:Date:Message-Id; bh=SobezS+UT/6avE8N0IAnhBhfHGgtAFqaTt/7Eep3MBE=; b=HDMbsdBSyFUKRseIxvml5YyjlQ0CAljz+JoFbWvl0DxzSNH5UPA+XkAh9PYi+gA+ janmwLugWCBPu81+uPAxWyCCvPasWjCrKBbhxuxQcaUq6FaJ5OEpIFZlz34BB83QjP4 vNMPL9JD5OfU981g0s59IoQuX12Krh5ZbaxxyY7Y= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=224i4yxa5dv7c2xz3womw6peuasteono; d=amazonses.com; t=1505670591; h=From:To:Cc:Subject:Date:Message-Id:Feedback-ID; bh=SobezS+UT/6avE8N0IAnhBhfHGgtAFqaTt/7Eep3MBE=; b=Z4XajbnYl5fOSNuC2NqB/TKA+vqSB/PpTXCpY4O4CNRUC9zI71u0KBYjxH46bVWR OSWU3304cufBtlpQBnCUt4O1+3gSndIEWd218IDP/gceIqxUJo9iupkkiOlrOACGjwk MyHSzbEMLqlJXtGQR1kqffH1uH4O4rUFSmlKFzvc= From: Jeremy Cline To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Jeremy Cline Subject: [PATCH] tools/kvm_stat: Add Python 3 support to kvm_stat Date: Sun, 17 Sep 2017 17:49:51 +0000 Message-ID: <0100015e90f5f216-374488c9-c5cb-43e9-825e-15f006b79825-000000@email.amazonses.com> X-Mailer: git-send-email 2.13.5 X-SES-Outgoing: 2017.09.17-54.240.8.126 Feedback-ID: 1.us-east-1.z18Isoc/FaoPOvCyJyi1mnTt8STwoRuibXVNoUcvG6g=:AmazonSES Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make kvm_stat support Python 3 by changing the use of "print" to a function rather than a statement and switching from "iteritems" (removed in Python 3) to "items". With this change, kvm_stat is usable with Python 2.6 and greater. Signed-off-by: Jeremy Cline Reviewed-by: Stefan Hajnoczi --- tools/kvm/kvm_stat/kvm_stat | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/kvm/kvm_stat/kvm_stat b/tools/kvm/kvm_stat/kvm_stat index 32283d88701a..1ed18b3e619c 100755 --- a/tools/kvm/kvm_stat/kvm_stat +++ b/tools/kvm/kvm_stat/kvm_stat @@ -19,6 +19,7 @@ Three different ways of output formatting are available: The data is sampled from the KVM's debugfs entries and its perf events. """ +from __future__ import print_function import curses import sys @@ -666,7 +667,7 @@ class TracepointProvider(Provider): """Returns 'event name: current value' for all enabled events.""" ret = defaultdict(int) for group in self.group_leaders: - for name, val in group.read().iteritems(): + for name, val in group.read().items(): if name in self._fields: ret[name] += val return ret @@ -1369,7 +1370,7 @@ def batch(stats): s = stats.get() for key in sorted(s.keys()): values = s[key] - print '%-42s%10d%10d' % (key, values[0], values[1]) + print('%-42s%10d%10d' % (key, values[0], values[1])) except KeyboardInterrupt: pass @@ -1380,14 +1381,14 @@ def log(stats): def banner(): for k in keys: - print '%s' % k, - print + print(k) + print() def statline(): s = stats.get() for k in keys: - print ' %9d' % s[k][1], - print + print(' %9d' % s[k][1]) + print() line = 0 banner_repeat = 20 while True: