Skip to content

Commit 893b03d

Browse files
committed
Add the ability to specify the network device under test speed
Works for virtio-net-pci only. Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
1 parent 3219e3f commit 893b03d

File tree

5 files changed

+21
-6
lines changed

5 files changed

+21
-6
lines changed

lib/cli.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class TestOptions
9696
:commit, :svvp, :dump, :gthb_context_prefix, :gthb_context_suffix, :playlist,
9797
:select_test_names, :reject_test_names, :reject_report_sections, :boot_device,
9898
:allow_test_duplication, :manual, :package_with_playlist, :enable_vbs, :tag_suffix,
99-
:fs_test_image_format, :extensions
99+
:fs_test_image_format, :extensions, :net_test_speed
100100

101101
def create_parser
102102
OptionParser.new do |parser|
@@ -218,6 +218,11 @@ def define_options(parser)
218218
parser.on('--extensions <extensions_list>', Array,
219219
'List of extensions for run test',
220220
&method(:extensions=))
221+
222+
parser.on('--net-test-speed <net_test_speed>', Integer,
223+
'Network test speed (in Mbps). Default is 10000.',
224+
'Has effect only when testing virtio-net-pci network device.',
225+
&method(:net_test_speed=))
221226
end
222227
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
223228
end

lib/setupmanagers/qemuhck/devices/virtio-net-pci.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"need_pci_bus": true,
55
"command_line": [
66
"-netdev @network_backend@,id=@net_if_name@@netdev_options@",
7-
"-device virtio-net-pci@device_extra_param@@iommu_device_param@,netdev=@net_if_name@,mac=@net_if_mac@@net_addr@,bus=@bus_name@.0,id=@net_if_name@"
7+
"-device virtio-net-pci@device_extra_param@@iommu_device_param@,netdev=@net_if_name@,mac=@net_if_mac@@net_addr@,speed=@speed@,bus=@bus_name@.0,id=@net_if_name@"
88
]
99
}

lib/setupmanagers/qemuhck/network_manager.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,17 @@ class NetworkManager
99
include Helper
1010

1111
CONFIG_JSON = 'lib/setupmanagers/qemuhck/network_manager.json'
12+
DEFAULT_NET_SPEED = 10_000 # 10G
1213

13-
def initialize(id, client_id, machine, logger)
14+
def initialize(id, client_id, machine, qemu_options, logger)
1415
@id = id
1516
@client_id = client_id
1617
@machine = machine
1718
@logger = logger
1819
@dev_id = 0
1920

21+
@net_test_speed = qemu_options['net_test_speed'] || DEFAULT_NET_SPEED
22+
2023
@config = Json.read_json(CONFIG_JSON, @logger)
2124
end
2225

@@ -67,6 +70,11 @@ def device_command_info(type, device, command_options, dev_pci, qemu_replacement
6770
@dev_id += 1
6871

6972
type_config = @config['devices'][type]
73+
command_options['@speed@'] = if type == 'test'
74+
@net_test_speed
75+
else
76+
DEFAULT_NET_SPEED
77+
end
7078

7179
replacement_map = device_replacement_map(type, device, type_config, dev_pci, qemu_replacement_map)
7280
replacement_map.merge! command_options

lib/setupmanagers/qemuhck/qemu_machine.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def initialize(options)
173173
init_ports
174174

175175
@pcim = PciManager.new(@logger)
176-
@nm = NetworkManager.new(@id, @client_id, @machine, @logger)
176+
@nm = NetworkManager.new(@id, @client_id, @machine, @options, @logger)
177177
@sm = StorageManager.new(@id, @client_id, @config, @options, @logger)
178178

179179
@devices_list.flatten!

lib/setupmanagers/qemuhck/qemuhck.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ def platform_client_options
8787

8888
def client_vm_common_options
8989
common = @project.options.common
90+
test_opt = @project.options.test
9091
{
9192
'id' => @id.to_i,
9293
'workspace_path' => @workspace_path,
@@ -96,8 +97,9 @@ def client_vm_common_options
9697
'client_world_net' => common.client_world_net,
9798
'attach_debug_net' => common.attach_debug_net,
9899
'share_on_host_path' => common.share_on_host_path,
99-
'boot_device' => @project.options.test.boot_device,
100-
'fs_test_image_format' => @project.options.test.fs_test_image_format,
100+
'boot_device' => test_opt.boot_device,
101+
'fs_test_image_format' => test_opt.fs_test_image_format,
102+
'net_test_speed' => test_opt.net_test_speed,
101103
'ctrl_net_device' => common.client_ctrl_net_dev
102104
}.compact
103105
end

0 commit comments

Comments
 (0)