mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
cpu-gather: Allow overwriting cpuid binary location
This is useful if cpuid was compiled from source in a non-standard location. Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
7721aae31b
commit
7f59cbcc16
@ -18,10 +18,11 @@ def gather_name(args):
|
|||||||
"Use '--model' to set a model name.")
|
"Use '--model' to set a model name.")
|
||||||
|
|
||||||
|
|
||||||
def gather_cpuid_leaves():
|
def gather_cpuid_leaves(args):
|
||||||
|
cpuid = args.path_to_cpuid or "cpuid"
|
||||||
try:
|
try:
|
||||||
output = subprocess.check_output(
|
output = subprocess.check_output(
|
||||||
["cpuid", "-1r"],
|
[cpuid, "-1r"],
|
||||||
universal_newlines=True)
|
universal_newlines=True)
|
||||||
except FileNotFoundError as e:
|
except FileNotFoundError as e:
|
||||||
exit("Error: '{}' not found.\n'cpuid' can be usually found in a "
|
exit("Error: '{}' not found.\n'cpuid' can be usually found in a "
|
||||||
@ -43,13 +44,18 @@ def main():
|
|||||||
"--name",
|
"--name",
|
||||||
help="CPU model name. "
|
help="CPU model name. "
|
||||||
"If unset, model name is read from '/proc/cpuinfo'.")
|
"If unset, model name is read from '/proc/cpuinfo'.")
|
||||||
|
parser.add_argument(
|
||||||
|
"--path-to-cpuid",
|
||||||
|
metavar="PATH",
|
||||||
|
help="Path to 'cpuid' utility. "
|
||||||
|
"If unset, the first executable 'cpuid' in $PATH is used.")
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
name = gather_name(args)
|
name = gather_name(args)
|
||||||
print("model name\t: {}".format(name))
|
print("model name\t: {}".format(name))
|
||||||
|
|
||||||
leaves = gather_cpuid_leaves()
|
leaves = gather_cpuid_leaves(args)
|
||||||
print("CPU:")
|
print("CPU:")
|
||||||
for leave in leaves:
|
for leave in leaves:
|
||||||
print(" {}".format(leave))
|
print(" {}".format(leave))
|
||||||
|
Loading…
Reference in New Issue
Block a user