From patchwork Thu Apr 18 02:48:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 237422 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 4459B2C0199 for ; Thu, 18 Apr 2013 12:49:40 +1000 (EST) Received: from localhost ([::1]:48636 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USeuo-0000XY-Hc for incoming@patchwork.ozlabs.org; Wed, 17 Apr 2013 22:49:38 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53652) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USetv-0008Af-BI for qemu-devel@nongnu.org; Wed, 17 Apr 2013 22:48:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1USett-0001Zk-Cx for qemu-devel@nongnu.org; Wed, 17 Apr 2013 22:48:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:29029) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USett-0001Yu-2S for qemu-devel@nongnu.org; Wed, 17 Apr 2013 22:48:41 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3I2mdbn029041 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 17 Apr 2013 22:48:39 -0400 Received: from amt.cnet (vpn1-7-116.gru2.redhat.com [10.97.7.116]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r3I2mc6j021958; Wed, 17 Apr 2013 22:48:38 -0400 Received: from amt.cnet (localhost [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 21BE11040F9; Wed, 17 Apr 2013 23:48:33 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.6/8.14.6/Submit) id r3I2mWnc014890; Wed, 17 Apr 2013 23:48:32 -0300 From: Marcelo Tosatti To: Anthony Liguori Date: Wed, 17 Apr 2013 23:48:22 -0300 Message-Id: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Jan Kiszka , Gleb Natapov , qemu-devel@nongnu.org, kvm@vger.kernel.org Subject: [Qemu-devel] [PATCH 1/5] vmxcap: Open MSR file in unbuffered mode 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 From: Jan Kiszka Python may otherwise decide to to read larger chunks, applying the seek only on the software buffer. This will return results from the wrong MSRs. Signed-off-by: Jan Kiszka Signed-off-by: Gleb Natapov --- scripts/kvm/vmxcap | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/kvm/vmxcap b/scripts/kvm/vmxcap index 0b23f77..6363e73 100755 --- a/scripts/kvm/vmxcap +++ b/scripts/kvm/vmxcap @@ -27,9 +27,9 @@ MSR_IA32_VMX_VMFUNC = 0x491 class msr(object): def __init__(self): try: - self.f = file('/dev/cpu/0/msr') + self.f = open('/dev/cpu/0/msr', 'r', 0) except: - self.f = file('/dev/msr0') + self.f = open('/dev/msr0', 'r', 0) def read(self, index, default = None): import struct self.f.seek(index)