diff --git a/lib/cli.rb b/lib/cli.rb index 8a5fd837..93dbb829 100644 --- a/lib/cli.rb +++ b/lib/cli.rb @@ -96,7 +96,7 @@ class TestOptions :commit, :svvp, :dump, :gthb_context_prefix, :gthb_context_suffix, :playlist, :select_test_names, :reject_test_names, :reject_report_sections, :boot_device, :allow_test_duplication, :manual, :package_with_playlist, :enable_vbs, :tag_suffix, - :fs_test_image_format, :extensions + :fs_test_image_format, :extensions, :net_test_speed def create_parser OptionParser.new do |parser| @@ -218,6 +218,11 @@ def define_options(parser) parser.on('--extensions ', Array, 'List of extensions for run test', &method(:extensions=)) + + parser.on('--net-test-speed ', Integer, + 'Network test speed (in Mbps). Default is 10000.', + 'Has effect only when testing virtio-net-pci network device.', + &method(:net_test_speed=)) end # rubocop:enable Metrics/AbcSize, Metrics/MethodLength end diff --git a/lib/setupmanagers/qemuhck/devices/virtio-net-pci.json b/lib/setupmanagers/qemuhck/devices/virtio-net-pci.json index fa667cb7..692f2b89 100644 --- a/lib/setupmanagers/qemuhck/devices/virtio-net-pci.json +++ b/lib/setupmanagers/qemuhck/devices/virtio-net-pci.json @@ -4,6 +4,6 @@ "need_pci_bus": true, "command_line": [ "-netdev @network_backend@,id=@net_if_name@@netdev_options@", - "-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@" + "-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@" ] } diff --git a/lib/setupmanagers/qemuhck/network_manager.rb b/lib/setupmanagers/qemuhck/network_manager.rb index da400515..c9aa6a34 100644 --- a/lib/setupmanagers/qemuhck/network_manager.rb +++ b/lib/setupmanagers/qemuhck/network_manager.rb @@ -9,14 +9,17 @@ class NetworkManager include Helper CONFIG_JSON = 'lib/setupmanagers/qemuhck/network_manager.json' + DEFAULT_NET_SPEED = 10_000 # 10G - def initialize(id, client_id, machine, logger) + def initialize(id, client_id, machine, qemu_options, logger) @id = id @client_id = client_id @machine = machine @logger = logger @dev_id = 0 + @net_test_speed = qemu_options['net_test_speed'] || DEFAULT_NET_SPEED + @config = Json.read_json(CONFIG_JSON, @logger) end @@ -67,6 +70,11 @@ def device_command_info(type, device, command_options, dev_pci, qemu_replacement @dev_id += 1 type_config = @config['devices'][type] + command_options['@speed@'] = if type == 'test' + @net_test_speed + else + DEFAULT_NET_SPEED + end replacement_map = device_replacement_map(type, device, type_config, dev_pci, qemu_replacement_map) replacement_map.merge! command_options diff --git a/lib/setupmanagers/qemuhck/qemu_machine.rb b/lib/setupmanagers/qemuhck/qemu_machine.rb index 94cfe88b..15dbc0db 100644 --- a/lib/setupmanagers/qemuhck/qemu_machine.rb +++ b/lib/setupmanagers/qemuhck/qemu_machine.rb @@ -173,7 +173,7 @@ def initialize(options) init_ports @pcim = PciManager.new(@logger) - @nm = NetworkManager.new(@id, @client_id, @machine, @logger) + @nm = NetworkManager.new(@id, @client_id, @machine, @options, @logger) @sm = StorageManager.new(@id, @client_id, @config, @options, @logger) @devices_list.flatten! diff --git a/lib/setupmanagers/qemuhck/qemuhck.rb b/lib/setupmanagers/qemuhck/qemuhck.rb index 63c58a42..f1a4f3fb 100644 --- a/lib/setupmanagers/qemuhck/qemuhck.rb +++ b/lib/setupmanagers/qemuhck/qemuhck.rb @@ -87,6 +87,7 @@ def platform_client_options def client_vm_common_options common = @project.options.common + test_opt = @project.options.test { 'id' => @id.to_i, 'workspace_path' => @workspace_path, @@ -96,8 +97,9 @@ def client_vm_common_options 'client_world_net' => common.client_world_net, 'attach_debug_net' => common.attach_debug_net, 'share_on_host_path' => common.share_on_host_path, - 'boot_device' => @project.options.test.boot_device, - 'fs_test_image_format' => @project.options.test.fs_test_image_format, + 'boot_device' => test_opt.boot_device, + 'fs_test_image_format' => test_opt.fs_test_image_format, + 'net_test_speed' => test_opt.net_test_speed, 'ctrl_net_device' => common.client_ctrl_net_dev }.compact end