Skip to content

Commit

Permalink
set vhost on when vhost-net module is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
LiliDeng committed Feb 13, 2025
1 parent 3e5cc4c commit 66a1fe9
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lisa/tools/qemu.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from lisa.executable import Tool
from lisa.operating_system import Fedora, Posix, Redhat
from lisa.tools import Ip, Kill, Lscpu, Lsmod, Pgrep
from lisa.tools import Ip, KernelConfig, Kill, Lscpu, Lsmod, Pgrep
from lisa.tools.lscpu import CpuType
from lisa.util import LisaException, SkippedException, get_matched_str

Expand Down Expand Up @@ -104,9 +104,16 @@ def create_vm(
f"-device {nic_model},netdev=nettap{self.interface_count},"
f"mac={random_mac_address} "
)
cmd += (
f"-netdev tap,id=nettap{self.interface_count},vhost=on,script=no "
)

base_cmd = f"-netdev tap,id=nettap{self.interface_count},script=no"

# vhost-net is a kernel module that accelerates virtio-net performance
# by offloading packet processing from QEMU's user space to the host
# kernel reducing latency and CPU overhead
if self.node.tools[KernelConfig].is_enabled("CONFIG_VHOST_NET"):
base_cmd += ",vhost=on"

cmd += base_cmd + " "
added_taps.append(f"tap{self.interface_count}")
self.interface_count += 1

Expand Down

0 comments on commit 66a1fe9

Please sign in to comment.