// QEMU definitions. These define the base QEMU command lines, // which are standardized across all crusttest slots. // (This file has been bastardized for socket2) import { QemuVmDefinition } from '@socketcomputer/qemu'; const kQemuPath = '/srv/collabvm/qemu/bin/qemu-system-x86_64'; // the aio model qemu will use. if possible, leave this at 'io_uring'. const kQemuAio = 'io_uring'; /// Creates a base definition for a VM with PC chipset. export function Slot_PCDef( // RAM ramSize: string, // Network netdevOption: string = '-netdev user,id=vm.wan', netAdapterModel: string = 'rtl8139', netMac: string = 'c7:4e:c0:5f:2c:7c', // HDA hdaIsSsd: boolean = true, hdImagePath: string, hdImageFormat: string ): QemuVmDefinition { let qCommand = [kQemuPath]; let pushOption = (opt: string) => { qCommand.push(opt.substring(0, opt.indexOf(' '))); qCommand.push(opt.substring(opt.indexOf(' ') + 1)); }; // boilerplate/chipset qCommand.push('-nodefaults'); pushOption('-machine pc-i440fx-2.10,accel=kvm,kernel_irqchip=on,hpet=off,acpi=on,usb=on'); pushOption('-rtc base=localtime,clock=vm'); // CPU/RAM pushOption(`-cpu pentium3`); pushOption(`-m ${ramSize}`); // unlike LVM we don't really want to prealloc per se.. pushOption(`${netdevOption}`); pushOption(`-device ${netAdapterModel},id=vm.netadp,netdev=vm.wan,mac=${netMac}`); pushOption( `-drive if=none,file=${hdImagePath},cache=writeback,discard=unmap,format=${hdImageFormat},aio=${kQemuAio},id=vm.hda_drive,bps=65000000,bps_max=65000000,iops=1500,iops_max=2000` ); // prettier-ignore if (hdaIsSsd) pushOption(`-device ide-hd,id=vm.hda,rotation_rate=1,drive=vm.hda_drive`); else pushOption(`-device ide-hd,id=vm.hda,drive=vm.hda_drive`); // CD drive pushOption(`-drive if=none,media=cdrom,aio=${kQemuAio},id=vm.cd`); pushOption(`-device ide-cd,drive=vm.cd,id=vm.cd_drive`); pushOption('-audio driver=none,model=ac97'); // VGA + usb tablet pushOption('-device VGA,id=vm.vga'); pushOption('-device usb-tablet'); return { id: "socketvm2-test", command: qCommand }; }