initial commit
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Disposable local Ubuntu validation VM helper; no host package installation."""
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess,json,socket
|
||||
r=Path(os.environ.get('DOCVIEW_VM_WORK', 'build-ubuntu-vm')).resolve()
|
||||
with socket.socket() as port_probe:
|
||||
port_probe.bind(('127.0.0.1',22224))
|
||||
cmd=['qemu-system-x86_64','-name','docview-ubuntu2404-validation',
|
||||
'-machine','q35,accel=kvm','-cpu','host','-smp','4','-m','8192',
|
||||
'-display','none','-monitor','none','-serial','file:'+str(r/'private/serial.log'),
|
||||
'-pidfile',str(r/'qemu.pid'),'-qmp','unix:'+str(r/'qmp.sock')+',server=on,wait=off',
|
||||
'-drive','if=pflash,format=raw,readonly=on,file=/usr/share/edk2-ovmf/x64/OVMF_CODE.4m.fd',
|
||||
'-drive','if=pflash,format=raw,file='+str(r/'OVMF_VARS.4m.fd'),
|
||||
'-drive','if=virtio,format=qcow2,file='+str(r/'guest.qcow2'),
|
||||
'-drive','if=virtio,format=raw,readonly=on,file='+str(r/'private/seed.iso'),
|
||||
'-netdev','user,id=net0,hostfwd=tcp:127.0.0.1:22224-:22',
|
||||
'-device','virtio-net-pci,netdev=net0','-device','virtio-rng-pci',
|
||||
'-sandbox','on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny']
|
||||
(r/'metadata/qemu-active-command.json').write_text(json.dumps(cmd,indent=2)+'\n')
|
||||
print('Running dedicated Ubuntu guest; 4 vCPU / 8 GiB / 24 GiB / SSH 127.0.0.1:22224',flush=True)
|
||||
with (r/'logs/qemu-runtime.txt').open('ab') as log:
|
||||
p=subprocess.run(cmd,stdout=log,stderr=subprocess.STDOUT)
|
||||
print('QEMU exit',p.returncode,flush=True)
|
||||
raise SystemExit(p.returncode)
|
||||
Reference in New Issue
Block a user