Skip to content

Commit

Permalink
Add VirtIO Viomem Driver support
Browse files Browse the repository at this point in the history
Signed-off-by: Kostiantyn Kostiuk <[email protected]>
  • Loading branch information
kostyanf14 committed Mar 25, 2024
1 parent bf594f3 commit 4f630dc
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 3 deletions.
11 changes: 11 additions & 0 deletions lib/engines/hcktest/drivers/viomem.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
1 change: 1 addition & 0 deletions lib/models/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
8 changes: 8 additions & 0 deletions lib/setupmanagers/qemuhck/devices/virtio-mem-pci.json
Original file line number Diff line number Diff line change
@@ -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=@[email protected]"
]
}
18 changes: 16 additions & 2 deletions lib/setupmanagers/qemuhck/qemu_machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ def define_local_variables
@drive_cache_options = []
@define_variables = {}
@run_opts = {}
@pluggable_memory_gb = 0
@configured = false
end

Expand Down Expand Up @@ -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,
Expand All @@ -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'),
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ',
Expand Down Expand Up @@ -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@'
]
Expand Down
3 changes: 2 additions & 1 deletion lib/setupmanagers/qemuhck/qemuhck.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4f630dc

Please sign in to comment.