mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
cpu-gather: Prepare gather_msr for reading multiple msr
Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
4b9720e89f
commit
942cf935d6
@ -58,24 +58,29 @@ def gather_cpuid_leaves(args):
|
|||||||
|
|
||||||
|
|
||||||
def gather_msr():
|
def gather_msr():
|
||||||
IA32_ARCH_CAPABILITIES_MSR = 0x10a
|
msrs = dict()
|
||||||
|
addresses = [
|
||||||
|
0x10a, # IA32_ARCH_CAPABILITIES_MSR
|
||||||
|
]
|
||||||
KVM_GET_MSRS = 0xc008ae88
|
KVM_GET_MSRS = 0xc008ae88
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open("/dev/cpu/0/msr", "rb") as f:
|
with open("/dev/cpu/0/msr", "rb") as f:
|
||||||
f.seek(IA32_ARCH_CAPABILITIES_MSR)
|
for addr in addresses:
|
||||||
|
f.seek(addr)
|
||||||
buf = f.read(8)
|
buf = f.read(8)
|
||||||
msr = struct.unpack("=Q", buf)[0]
|
msrs[addr] = struct.unpack("=Q", buf)[0]
|
||||||
return "", {IA32_ARCH_CAPABILITIES_MSR: msr}
|
return "", msrs
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print("Warning: {}".format(e), file=sys.stderr)
|
print("Warning: {}".format(e), file=sys.stderr)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
bufIn = struct.pack("=LLLLQ", 1, 0, IA32_ARCH_CAPABILITIES_MSR, 0, 0)
|
|
||||||
with open("/dev/kvm", "rb") as f:
|
with open("/dev/kvm", "rb") as f:
|
||||||
|
for addr in addresses:
|
||||||
|
bufIn = struct.pack("=LLLLQ", 1, 0, addr, 0, 0)
|
||||||
bufOut = fcntl.ioctl(f, KVM_GET_MSRS, bufIn)
|
bufOut = fcntl.ioctl(f, KVM_GET_MSRS, bufIn)
|
||||||
msr = struct.unpack("=LLLLQ", bufOut)[4]
|
msrs[addr] = struct.unpack("=LLLLQ", bufOut)[4]
|
||||||
return " via KVM", {IA32_ARCH_CAPABILITIES_MSR: msr}
|
return " via KVM", msrs
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
print("Warning: {}".format(e), file=sys.stderr)
|
print("Warning: {}".format(e), file=sys.stderr)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user