vmxcap: Open MSR file in unbuffered mode

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 <jan.kiszka@siemens.com>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
This commit is contained in:
Jan Kiszka 2013-02-13 12:43:10 +01:00 committed by Marcelo Tosatti
parent 1773d9ee6e
commit f505a4d74a
1 changed files with 2 additions and 2 deletions

View File

@ -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)