mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
cpu-gather: Merge model gathering logic
Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
b1773967c5
commit
d828870d2d
@ -96,7 +96,7 @@ def call_qemu(qemu, qmp_cmds):
|
|||||||
yield json.loads(line)
|
yield json.loads(line)
|
||||||
|
|
||||||
|
|
||||||
def gather_static_model(args):
|
def gather_model(args):
|
||||||
output = call_qemu(args.path_to_qemu, [
|
output = call_qemu(args.path_to_qemu, [
|
||||||
{
|
{
|
||||||
"execute": "query-cpu-model-expansion",
|
"execute": "query-cpu-model-expansion",
|
||||||
@ -108,14 +108,11 @@ def gather_static_model(args):
|
|||||||
"id": "model-expansion"
|
"id": "model-expansion"
|
||||||
}])
|
}])
|
||||||
|
|
||||||
|
static_model = None
|
||||||
for o in output:
|
for o in output:
|
||||||
if o.get("id") == "model-expansion":
|
if o.get("id") == "model-expansion":
|
||||||
return o["return"]["model"]
|
static_model = o["return"]["model"]
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def gather_full_model(args, static_model):
|
|
||||||
if static_model:
|
if static_model:
|
||||||
return call_qemu(args.path_to_qemu, [
|
return call_qemu(args.path_to_qemu, [
|
||||||
{
|
{
|
||||||
@ -231,15 +228,13 @@ def main():
|
|||||||
for key, value in sorted(msr.items()):
|
for key, value in sorted(msr.items()):
|
||||||
print(" 0x{:x}: 0x{:016x}\n".format(int(key), value))
|
print(" 0x{:x}: 0x{:016x}\n".format(int(key), value))
|
||||||
|
|
||||||
static_model = gather_static_model(args)
|
model = gather_model(args)
|
||||||
model = gather_full_model(args, static_model)
|
|
||||||
for o in model:
|
for o in model:
|
||||||
print(json.dumps(o))
|
print(json.dumps(o))
|
||||||
|
|
||||||
print(end="", flush=True)
|
print(end="", flush=True)
|
||||||
os.environ["CPU_GATHER_PY"] = "true"
|
os.environ["CPU_GATHER_PY"] = "true"
|
||||||
os.environ["qemu"] = args.path_to_qemu
|
os.environ["qemu"] = args.path_to_qemu
|
||||||
os.environ["model"] = json.dumps(static_model) if static_model else ""
|
|
||||||
subprocess.check_call("./cpu-gather.sh")
|
subprocess.check_call("./cpu-gather.sh")
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user