From 4e46e9a0295f8155ddcdd7615886653bf53dc32b Mon Sep 17 00:00:00 2001 From: Kostiantyn Kostiuk Date: Mon, 25 Jul 2022 15:07:23 +0000 Subject: [PATCH] Add VirtIO Viomem Driver support Signed-off-by: Kostiantyn Kostiuk --- drivers.json | 11 +++++++++++ .../qemuhck/devices/virtio-mem-pci.json | 7 +++++++ lib/setupmanagers/qemuhck/qemu_machine.rb | 13 ++++++++++++- 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 lib/setupmanagers/qemuhck/devices/virtio-mem-pci.json diff --git a/drivers.json b/drivers.json index 23158327..4355b8ea 100644 --- a/drivers.json +++ b/drivers.json @@ -206,6 +206,17 @@ "Hardware-enforced Stack Protection Compatibility Test" ] }, + "viomem": { + "name": "VirtIO Viomem Driver", + "device": "virtio-mem-pci", + "inf": "viomem.inf", + "install_method": "PNP", + "type": 0, + "support": false, + "blacklist": [ + "Hardware-enforced Stack Protection Compatibility Test" + ] + }, "openvpn": { "name": "TAP-Windows Adapter V9", "device": "e1000e", 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..176c3fc3 --- /dev/null +++ b/lib/setupmanagers/qemuhck/devices/virtio-mem-pci.json @@ -0,0 +1,7 @@ +{ + "name": "virtio-mem-pci", + "command_line": [ + "-object memory-backend-ram,id=mem_backend,size=1G", + "-device virtio-mem-pci@device_extra_param@,memdev=mem_backend,requested-size=300M,bus=@bus_name@.0" + ] +} diff --git a/lib/setupmanagers/qemuhck/qemu_machine.rb b/lib/setupmanagers/qemuhck/qemu_machine.rb index 94a9a328..34aeea2d 100644 --- a/lib/setupmanagers/qemuhck/qemu_machine.rb +++ b/lib/setupmanagers/qemuhck/qemu_machine.rb @@ -193,6 +193,16 @@ def options_replacement_list } end + def double_memory + memory = option_config('memory') + memory2 = (memory.to_i * 2).to_s + if memory.to_i.to_s == memory + memory2 + else + memory2 + memory[-1..] + end + end + def full_replacement_list { '@run_id@' => @id, @@ -201,6 +211,7 @@ def full_replacement_list '@client_id@' => @client_id, '@workspace@' => @workspace_path, '@memory@' => option_config('memory'), + '@double_memory@' => double_memory, '@cpu_count@' => option_config('cpu_count'), '@cpu_model@' => option_config('cpu_model'), '@vnc_id@' => @vnc_id, @@ -351,7 +362,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=@double_memory@ -smp @cpu_count@,cores=@cpu_count@ ', '-cpu qemu64,+x2apic,+fsgsbase@cpu_options@,model=@cpu_model@ -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 ',