Skip to content

Commit

Permalink
set a higher memory value to avoid ntttcp error
Browse files Browse the repository at this point in the history
  • Loading branch information
LiliDeng committed Feb 13, 2025
1 parent 4c73e45 commit a77a178
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions lisa/tools/qemu.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def create_vm(
port: int,
guest_image_path: str,
cores: int = 2,
memory: int = 4096,
memory_in_gb: int = 4,
nic_model: str = "e1000",
taps: int = 0,
bridge: Optional[str] = None,
Expand All @@ -52,7 +52,7 @@ def create_vm(
port: port of the host vm mapped to the guest's ssh port
guest_image_path: path of the guest image
cores: number of cores of the vm. Defaults to 2
memory: memory of the vm in MB. Defaults to 2048MB
memory_in_gb: memory of the vm in GB. Defaults to 4G
nics: number of qemu managed nics of the vm. Defaults to 1
nic_model: model of the nics. Can be `e1000` or `virtio-net-pci`.
Defaults to `e1000` as it works with most x86 machines
Expand Down Expand Up @@ -86,7 +86,7 @@ def create_vm(
)
if not get_matched_str(try_pcid_flag.stdout, self.NO_PCID_PATTERN):
cmd += ",pcid=no"
cmd += f" -smp {cores} -m {memory} -hda {guest_image_path} "
cmd += f" -smp {cores} -m {memory_in_gb} -hda {guest_image_path} "

# Add qemu managed nic device
# This will be used to communicate with ssh to the guest
Expand Down Expand Up @@ -163,13 +163,7 @@ def create_vm(
self.node.tools[Ip].up(tap)
self.node.tools[Ip].set_master(tap, bridge)

# update firewall rules
# https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/configuring_and_managing_networking/using-and-configuring-firewalld_configuring-and-managing-networking # noqa E501
if isinstance(self.node.os, Fedora):
self.node.execute(
f"firewall-cmd --permanent --add-port={port}/tcp", sudo=True
)
self.node.execute("firewall-cmd --reload", sudo=True)
self._configure_firewall_for_fedora(port)

def delete_vm(self, timeout: int = 300) -> None:
# stop vm
Expand Down Expand Up @@ -235,3 +229,12 @@ def _configure_qemu_command_for_cpu(self, cmd: str) -> str:
if get_matched_str(result.stdout, self.ERROR_WHEN_USE_HOST_CPU):
cmd = cmd.replace("-cpu host", "-cpu EPYC")
return cmd

def _configure_firewall_for_fedora(self, port: int) -> bool:
# update firewall rules
# https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/configuring_and_managing_networking/using-and-configuring-firewalld_configuring-and-managing-networking # noqa E501
if isinstance(self.node.os, Fedora):
self.node.execute(
f"firewall-cmd --permanent --add-port={port}/tcp", sudo=True
)
self.node.execute("firewall-cmd --reload", sudo=True)

0 comments on commit a77a178

Please sign in to comment.