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: 2135411 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 60F3A3FCA4 for ; Wed, 13 Feb 2013 11:43:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933900Ab3BMLnQ (ORCPT ); Wed, 13 Feb 2013 06:43:16 -0500 Received: from goliath.siemens.de ([192.35.17.28]:26334 "EHLO goliath.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933891Ab3BMLnP (ORCPT ); Wed, 13 Feb 2013 06:43:15 -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 CC: kvm , qemu-devel Subject: [PATCH][QEMU] vmxcap: Open MSR file in unbuffered mode Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.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)