Skip to content

Commit e920b5f

Browse files
[QEMU] move machine info to config parsing script
to not duplicate hmat info parsing - extra parsing was done in start_qemu.sh. If "hmat" not found in libvirt args, assume hmat=off.
1 parent 7fbb857 commit e920b5f

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

scripts/qemu/parse_config.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@ def parse_topology_xml(tpg_file_name: str) -> TopologyCfg:
5656
if verbose_mode != False:
5757
print(f"\nFull libvirt_args: {libvirt_args}\n")
5858

59+
hmat_search = re.search(r"hmat=(\w+)", libvirt_args)
5960
tpg_cfg = {
6061
"name": re.search(r"guest=(\w+)", libvirt_args).group(1),
61-
"hmat": "hmat=on" in libvirt_args,
62+
"hmat": hmat_search.group(0) if hmat_search else "hmat=off",
6263
"cpu_model": re.search(r"cpu (\S+)", libvirt_args).group(1),
6364
"cpu_options": re.search("(?=-smp)(.*)threads=[0-9]+", libvirt_args).group(
6465
0
@@ -89,7 +90,8 @@ def get_qemu_args(tpg_file_name: str) -> str:
8990
Get QEMU arguments from topology xml file
9091
"""
9192
tpg = parse_topology_xml(tpg_file_name)
92-
qemu_args = f"-name {tpg.name} {calculate_memory(tpg)} -cpu {tpg.cpu_model} {tpg.cpu_options} {tpg.mem_options}"
93+
qemu_args = f"-machine q35,usb=off,{tpg.hmat} -name {tpg.name} " \
94+
f"{calculate_memory(tpg)} -cpu {tpg.cpu_model} {tpg.cpu_options} {tpg.mem_options}"
9395
return qemu_args
9496

9597

scripts/qemu/start_qemu.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,9 @@ config_file=$1
1010
# Parse the config file to get topology info and fix escaped single quotes
1111
parsed_config=$(python3 scripts/qemu/parse_config.py ${config_file} | sed s/''\''/'/g)
1212

13-
if grep -q '<interconnects>' "$config_file"; then
14-
hmat="on"
15-
else
16-
hmat="off"
17-
fi
18-
1913
sudo qemu-system-x86_64 \
2014
-drive file=./ubuntu-23.04-server-cloudimg-amd64.img,format=qcow2,index=0,media=disk,id=hd \
2115
-cdrom ./ubuntu-cloud-init.iso \
22-
-machine q35,usb=off,hmat=${hmat} \
2316
-enable-kvm \
2417
-net nic -net user,hostfwd=tcp::2222-:22 \
2518
${parsed_config} \

0 commit comments

Comments
 (0)