From a77a1782d558f532aa8099286ad62fc4e08a6b1b Mon Sep 17 00:00:00 2001 From: Lili Deng Date: Thu, 13 Feb 2025 21:25:03 +0800 Subject: [PATCH] set a higher memory value to avoid ntttcp error --- lisa/tools/qemu.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/lisa/tools/qemu.py b/lisa/tools/qemu.py index 1cc24db823..78da4b4e9c 100644 --- a/lisa/tools/qemu.py +++ b/lisa/tools/qemu.py @@ -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, @@ -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 @@ -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 @@ -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 @@ -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)