From patchwork Wed Feb 13 11:43:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 220123 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 87C012C0293 for ; Wed, 13 Feb 2013 22:43:23 +1100 (EST) Received: from localhost ([::1]:33022 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U5akD-0000dg-Gy for incoming@patchwork.ozlabs.org; Wed, 13 Feb 2013 06:43:21 -0500 Received: from eggs.gnu.org ([208.118.235.92]:57226) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U5ak5-0000dW-Fr for qemu-devel@nongnu.org; Wed, 13 Feb 2013 06:43:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U5ak4-0002k6-1L for qemu-devel@nongnu.org; Wed, 13 Feb 2013 06:43:13 -0500 Received: from goliath.siemens.de ([192.35.17.28]:19231) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U5ak3-0002k1-Mc for qemu-devel@nongnu.org; Wed, 13 Feb 2013 06:43:11 -0500 Received: from mail1.siemens.de (localhost [127.0.0.1]) by goliath.siemens.de (8.13.6/8.13.6) with ESMTP id r1DBhAVR025326; Wed, 13 Feb 2013 12:43:10 +0100 Received: from mchn199C.mchp.siemens.de ([139.25.109.49]) by mail1.siemens.de (8.13.6/8.13.6) with ESMTP id r1DBhAxH003353; Wed, 13 Feb 2013 12:43:10 +0100 Message-ID: <511B7C4E.8070403@siemens.com> Date: Wed, 13 Feb 2013 12:43:10 +0100 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: Marcelo Tosatti , Gleb Natapov X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 192.35.17.28 Cc: qemu-devel , kvm Subject: [Qemu-devel] [PATCH][QEMU] 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 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 --- scripts/kvm/vmxcap | 4 ++-- 1 files 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)