mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
cpu-parse: Move xml output to new script
Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
43d3703d3a
commit
58a1ad721f
@ -207,10 +207,50 @@ def parse_filename(data):
|
||||
return "x86_64-cpuid-{}".format(filename)
|
||||
|
||||
|
||||
def output_xml(data, filename):
|
||||
leave_pattern = re.compile(
|
||||
"^\\s*"
|
||||
"(0x[0-9a-f]+)\\s*"
|
||||
"(0x[0-9a-f]+):\\s*"
|
||||
"eax=(0x[0-9a-f]+)\\s*"
|
||||
"ebx=(0x[0-9a-f]+)\\s*"
|
||||
"ecx=(0x[0-9a-f]+)\\s*"
|
||||
"edx=(0x[0-9a-f]+)\\s*$")
|
||||
|
||||
leave_template = \
|
||||
" <cpuid" \
|
||||
" eax_in='{}'" \
|
||||
" ecx_in='{}'" \
|
||||
" eax='{}'" \
|
||||
" ebx='{}'" \
|
||||
" ecx='{}'" \
|
||||
" edx='{}'" \
|
||||
"/>\n"
|
||||
|
||||
msr_template = " <msr index='0x{:x}' edx='0x{:08x}' eax='0x{:08x}'/>\n"
|
||||
|
||||
print(filename)
|
||||
with open(filename, "wt") as f:
|
||||
f.write("<!-- {} -->\n".format(data["name"]))
|
||||
f.write("<cpudata arch='x86'>\n")
|
||||
for line in data["leaves"]:
|
||||
match = leave_pattern.match(line)
|
||||
f.write(leave_template.format(*match.groups()))
|
||||
for key, value in sorted(data["msr"].items()):
|
||||
f.write(msr_template.format(
|
||||
int(key),
|
||||
0xffffffff & (value >> 32),
|
||||
0xffffffff & (value >> 0)))
|
||||
f.write("</cpudata>\n")
|
||||
|
||||
|
||||
def parse(args):
|
||||
data = json.load(sys.stdin)
|
||||
|
||||
filename = parse_filename(data)
|
||||
filename_xml = "{}.xml".format(filename)
|
||||
|
||||
output_xml(data, filename_xml)
|
||||
|
||||
os.environ["CPU_GATHER_PY"] = "true"
|
||||
os.environ["model"] = data["name"]
|
||||
|
@ -7,21 +7,6 @@ fi
|
||||
|
||||
data=`cat`
|
||||
|
||||
xml()
|
||||
{
|
||||
hex='\(0x[0-9a-f]\+\)'
|
||||
matchCPUID="$hex $hex: eax=$hex ebx=$hex ecx=$hex edx=$hex"
|
||||
substCPUID="<cpuid eax_in='\\1' ecx_in='\\2' eax='\\3' ebx='\\4' ecx='\\5' edx='\\6'\\/>"
|
||||
|
||||
matchMSR="$hex: $hex\(.......[0-9a-f]\)"
|
||||
substMSR="<msr index='\\1' edx='\\2' eax='0x\\3'\\/>"
|
||||
|
||||
echo "<!-- $model -->"
|
||||
echo "<cpudata arch='x86'>"
|
||||
sed -ne "s/^ *$matchCPUID$/ $substCPUID/p; s/^ *$matchMSR$/ $substMSR/p"
|
||||
echo "</cpudata>"
|
||||
}
|
||||
|
||||
json()
|
||||
{
|
||||
first=true
|
||||
@ -36,9 +21,6 @@ json()
|
||||
done
|
||||
}
|
||||
|
||||
xml <<<"$data" >$fname.xml
|
||||
echo $fname.xml
|
||||
|
||||
json <<<"$data" >$fname.json
|
||||
if [[ -s $fname.json ]]; then
|
||||
echo $fname.json
|
||||
|
Loading…
Reference in New Issue
Block a user