|
#!/usr/bin/env ruby |
|
|
|
ENV["PYTHONUNBUFFERED"] = "1" |
|
|
|
Vagrant.configure("2") do |config| |
|
|
|
# Better defaults |
|
config.vm.provider :libvirt do |libvirt| |
|
libvirt.qemu_use_session = false |
|
libvirt.cpu_mode = 'host-passthrough' # Prefer performance to reproducibility here |
|
libvirt.machine_type = 'q35' # better support device passthrough since ICH9 uses a PCI-E bus |
|
# whereas the I440FX only supports a PCI bus |
|
|
|
# Avoid unpredictable memory latencies for better reproducibility |
|
libvirt.memorybacking :hugepages |
|
libvirt.memorybacking :nosharepages |
|
libvirt.memorybacking :locked # Forbids swapping |
|
libvirt.memorybacking :source, :type => 'file' |
|
libvirt.memorybacking :allocation, :mode => 'immediate' |
|
end |
|
|
|
config.vm.define :traffgen do |node| |
|
node.vm.box = "centos/8" |
|
node.vm.hostname = "traffgen" |
|
node.vm.synced_folder './shared', '/vagrant', type: 'rsync' |
|
|
|
node.vm.provider :libvirt do |qemu| |
|
qemu.graphics_type = 'none' # use serial |
|
qemu.cpus = 3 # Recommended value from TRex FAQ |
|
qemu.cputopology :sockets => 1, :cores => 3, :threads => 1 |
|
qemu.memory = 1024 # Reduced value for debugging |
|
#qemu.memory = 4096 # Recommended value from TRex FAQ |
|
|
|
# HostNIC-1/p0 (PCI 01:00.0) <-cable-> HostNIC-2/p0 (enp3s0f0) |
|
qemu.pci :bus => '01', :slot => '00', :function => '0' |
|
# HostNIC-1/p1 (PCI 01:00.1) <-cable-> HostNIC-2/p2 (enp3s0f2) |
|
qemu.pci :bus => '01', :slot => '00', :function => '1' |
|
end |
|
|
|
node.vm.provision :ansible do |ansible| |
|
ansible.playbook = "./traffgen.yml" |
|
ansible.become = true |
|
ansible.compatibility_mode = "2.0" |
|
ansible.verbose = "vv" |
|
end |
|
end |
|
|
|
######################################################################## |
|
# System-under-test |
|
# |
|
# Should be connected using physical cable to traffic generator VM. |
|
# We use macvtap because currently KOS dosn't handle passed-through NICs |
|
# properly (bug #3980834). |
|
######################################################################## |
|
config.vm.define :sut do |node| |
|
node.vm.provider :libvirt do |qemu| |
|
qemu.graphics_type = 'none' # use serial |
|
qemu.kernel = "#{__dir__}/kernel" |
|
qemu.machine_type = 'pc' |
|
qemu.cpus = 1 |
|
qemu.memory = 1024 |
|
qemu.mgmt_attach = false # useless on KOS |
|
|
|
# Use OVMF UEFI instead of SeaBIOS |
|
#qemu.loader = "/usr/share/OVMF/OVMF_CODE.fd" |
|
#qemu.storage :file, :device => :cdrom, :bus => "sata", :path => "#{__dir__}/uboot-efi.img" |
|
|
|
# IOMMU |
|
# qemu.features = ['acpi', 'apic', 'pae', 'ioapic'] # 3 vagrant default + ioapic |
|
# qemu.qemuargs :value => "-device" |
|
# qemu.qemuargs :value => "intel-iommu" |
|
end |
|
|
|
node.vm.network :public_network, |
|
:dev => "enp3s0f0", |
|
:mode => "private", |
|
:model_type => "e1000", |
|
:trust_guest_rx_filters => true |
|
|
|
node.vm.network :public_network, |
|
:dev => "enp3s0f2", |
|
:mode => "private", |
|
:model_type => "e1000", |
|
:trust_guest_rx_filters => true |
|
end |
|
|
|
######################################################################## |
|
# NetBSD reference system |
|
######################################################################## |
|
config.vm.define :netbsd do |node| |
|
node.vm.box = "generic/netbsd8" |
|
|
|
node.vm.provider :libvirt do |qemu| |
|
# qemu.graphics_type should be non-none or netbsd won't boot |
|
qemu.cpus = 1 |
|
qemu.memory = 1024 |
|
qemu.machine_type = 'pc' |
|
end |
|
|
|
node.vm.network :public_network, |
|
:dev => "enp3s0f0", |
|
:mode => "private", |
|
:model_type => "rtl8139", |
|
:trust_guest_rx_filters => true |
|
|
|
node.vm.network :public_network, |
|
:dev => "enp3s0f2", |
|
:mode => "private", |
|
:model_type => "rtl8139", |
|
:trust_guest_rx_filters => true |
|
end |
|
|
|
end |