From 581dd57e65e1803042f7ffb3ef43ecf3e2fef619 Mon Sep 17 00:00:00 2001 From: Kostiantyn Kostiuk Date: Tue, 20 Feb 2024 14:32:57 +0200 Subject: [PATCH] Add VirtIO Viomem Driver support Signed-off-by: Kostiantyn Kostiuk --- lib/engines/hcktest/drivers/viomem.json | 11 +++++++++++ lib/models/driver.rb | 1 + .../qemuhck/devices/virtio-mem-pci.json | 8 ++++++++ lib/setupmanagers/qemuhck/qemu_machine.rb | 18 ++++++++++++++++-- lib/setupmanagers/qemuhck/qemuhck.rb | 3 ++- 5 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 lib/engines/hcktest/drivers/viomem.json create mode 100644 lib/setupmanagers/qemuhck/devices/virtio-mem-pci.json diff --git a/lib/engines/hcktest/drivers/viomem.json b/lib/engines/hcktest/drivers/viomem.json new file mode 100644 index 00000000..77c11416 --- /dev/null +++ b/lib/engines/hcktest/drivers/viomem.json @@ -0,0 +1,11 @@ +{ + "name": "VirtIO Viomem Driver", + "device": "virtio-mem-pci", + "inf": "viomem.inf", + "install_method": "PNP", + "type": 0, + "support": false, + "reject_test_names": [ + "Hardware-enforced Stack Protection Compatibility Test" + ] +} diff --git a/lib/models/driver.rb b/lib/models/driver.rb index b507466e..a27524a8 100644 --- a/lib/models/driver.rb +++ b/lib/models/driver.rb @@ -31,6 +31,7 @@ class Driver < T::Struct const :s3_state, T.nilable(T::Boolean) const :s4_state, T.nilable(T::Boolean) const :enlightenments_state, T.nilable(T::Boolean) + const :pluggable_memory_gb, T.nilable(Integer) const :pretestcommands, T.nilable(T::Array[CommandInfo]) const :extra_software, T.nilable(T::Array[String]) diff --git a/lib/setupmanagers/qemuhck/devices/virtio-mem-pci.json b/lib/setupmanagers/qemuhck/devices/virtio-mem-pci.json new file mode 100644 index 00000000..dec2c1c3 --- /dev/null +++ b/lib/setupmanagers/qemuhck/devices/virtio-mem-pci.json @@ -0,0 +1,8 @@ +{ + "name": "virtio-mem-pci", + "pluggable_memory_gb": 2, + "command_line": [ + "-object memory-backend-ram,id=mem_backend,size=@pluggable_memory@", + "-device virtio-mem-pci@device_extra_param@,memdev=mem_backend,requested-size=1G,bus=@bus_name@.0" + ] +} diff --git a/lib/setupmanagers/qemuhck/qemu_machine.rb b/lib/setupmanagers/qemuhck/qemu_machine.rb index 710e6cb4..faae1986 100644 --- a/lib/setupmanagers/qemuhck/qemu_machine.rb +++ b/lib/setupmanagers/qemuhck/qemu_machine.rb @@ -224,6 +224,7 @@ def define_local_variables @drive_cache_options = [] @define_variables = {} @run_opts = {} + @pluggable_memory_gb = 0 @configured = false end @@ -341,6 +342,16 @@ def machine_replacement_list } end + def memory_replacement_list + memory_gb = option_config('memory_gb') + + { + '@memory@' => "#{memory_gb}G", + '@pluggable_memory@' => "#{@pluggable_memory_gb}G", + '@max_memory@' => "#{memory_gb + @pluggable_memory_gb}G" + } + end + def options_replacement_list { '@machine_extra_param@' => @machine_extra_param.join, @@ -358,7 +369,6 @@ def full_replacement_list '@run_id_second@' => @id_second, '@client_id@' => @client_id, '@workspace@' => @workspace_path, - '@memory@' => "#{option_config('memory_gb')}G", '@cpu@' => option_config('cpu'), '@cpu_count@' => option_config('cpu_count'), '@cpu_model@' => option_config('cpu_model'), @@ -367,6 +377,7 @@ def full_replacement_list '@qemu_monitor_port@' => @monitor_port }.merge(config_replacement_list) .merge(machine_replacement_list) + .merge(memory_replacement_list) .merge(options_replacement_list) .merge(@define_variables) end @@ -402,6 +413,8 @@ def load_device_info(device_info) var_value.merge! value when Array var_value << value + when Integer, String + instance_variable_set var, value else raise(QemuHCKError, "Variable #{var} has unsupported type") end @@ -486,7 +499,7 @@ def process_devices def base_cmd [ '@qemu_bin@ -enable-kvm -machine @machine_name@@machine_extra_param@ ', - '-m @memory@ -smp @cpu_count@,cores=@cpu_count@ ', + '-m @memory@,maxmem=@max_memory@ -smp @cpu_count@,cores=@cpu_count@ ', '-cpu @cpu_options@ -boot order=cd,menu=on ', '-nodefaults -no-user-config -usb -device usb-tablet -vnc :@vnc_id@ ', '-global kvm-pit.lost_tick_policy=discard -rtc base=localtime,clock=host,driftfix=slew ', @@ -537,6 +550,7 @@ def dump_config ' VM VCPU .................... @cpu@', ' VM VCPUs ................... @cpu_count@', ' VM Memory .................. @memory@', + ' VM pluggable memory ........ @pluggable_memory@', ' VM display port ............ Vnc @vnc_id@/@vnc_port@', ' VM monitor port ............ Telnet @qemu_monitor_port@' ] diff --git a/lib/setupmanagers/qemuhck/qemuhck.rb b/lib/setupmanagers/qemuhck/qemuhck.rb index d540b223..e3410251 100644 --- a/lib/setupmanagers/qemuhck/qemuhck.rb +++ b/lib/setupmanagers/qemuhck/qemuhck.rb @@ -14,7 +14,8 @@ class QemuHCK attr_reader :kit, :project - OPT_NAMES = %w[viommu_state s3_state s4_state enlightenments_state vhost_state machine_type fw_type cpu].freeze + OPT_NAMES = %w[viommu_state s3_state s4_state enlightenments_state vhost_state machine_type fw_type cpu + pluggable_memory_gb].freeze def initialize(project) initialize_project project