From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 457F91382C5 for ; Sat, 5 Jun 2021 12:51:33 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 3A04BE091B; Sat, 5 Jun 2021 12:51:27 +0000 (UTC) Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A9B07E0908 for ; Sat, 5 Jun 2021 12:51:25 +0000 (UTC) Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 339812400FC for ; Sat, 5 Jun 2021 14:51:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1622897483; bh=EyKRyyOpd3ZBZua70pvF33E1EZGPZGBRupGIpcV2uyM=; h=Date:From:To:Subject:Autocrypt:OpenPGP:From; b=gNo7ginqIA3J+B9zW3m4toQEoAyJh3EbQ4aq0K6+Wpf9EG9zc94xa0VD3l1UJehAj 2Rxz4GpvnnqJu09hbPpfRIIucL2HqBBoC82hJ8J9PDdWW5PY5ydWv68sGiXOE6+z6v QfIeohY8iDESVU3uX0Lw8n4kvW8Mroh55mezY9sTYw00HmAgcNjS4tlU8jAYF0F1fn TVXHUulMrvkgIWuO+1KASCmPI0wJy6gojUSn4LoEQK+L7mf4+9TvtrzQjplF8ArrTP CvRg6SqpERJ3/Fy4WJBSrl4boFk/CGtM0+1GrPfYN5jVo+yDQttQBi65bRhS4os3Tv sCpqzEphvhyBA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Fxzyy3jNHz6tmJ for ; Sat, 5 Jun 2021 14:51:22 +0200 (CEST) Date: Sat, 5 Jun 2021 12:51:21 +0000 From: Nils Freydank To: gentoo-user@lists.gentoo.org Subject: Re: [gentoo-user] QEMU -nographic Option with OVMF Message-ID: <20210605125121.77exflu4jb7j6w44@pygoscelis.ansernet> Mail-Followup-To: gentoo-user@lists.gentoo.org References: <20210524010115.dnp6lolmpfp55fzh@ad-gentoo-main> <7916209.T7Z3S40VBb@lenovo.localdomain> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@lists.gentoo.org Reply-to: gentoo-user@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nfeytkr63htypicl" Content-Disposition: inline In-Reply-To: <7916209.T7Z3S40VBb@lenovo.localdomain> Autocrypt: addr=nils.freydank@posteo.de; keydata=xsFNBFi67twBEADsz2MWzPBlXOI+Dp1hYJPERwcB7bV0vW5vjr8GZujQ/vz4Ab68KRLvmBoe5k67Uhz9pN40uRNY19h2dSxomH9jea8EH7asMR9KV0R2CXn9lIrmiu8PRm10UMI1BlUDh5897FPRwat52dKBTok6POj64A82jsvvrhfTImf9IzFVHt9iygFPAeMvgJqDN4eoSyAg0lO5hs66lbrcRnOxzRUPzOMFFdQMuWO3jY0WMqCsBjhwE73s32dzCNXZw6f9J0c3axEPRCRnU2o/BEbZHf/ZtFfU6+9ii6IY/pvwkHvLGp1JNpeGPgfSEV8JFBd3tGDKQZe6O3WyBawdiHkZ8RQkkPUuTjbuBPIUmR5ksA7qRg/Frl6bon1T3fDhUouZsg5eusdXemfsfkp9U0kakaotkLDblpkCXBYeGRXEyBhZHT//eEUIwhOz5BVKAPGk8T5zcoh5PuzVZ8Bx/oMJJd9rGIm38a3cnk4KPbF9sjRo/VYmhK1MTM24a6rHyOMR138KD11b1f8z7AbdG2/l2ojYDqT2+7R/gucY+awm0M5oxQ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qiulC2A2Hmm7ZkdZhKsaEJEojDQ+pyZt6H5k6hnpACYtOuViQ/NmtsmyahLoJQypGANy6VwXDXIfGRyRJFXgWPT+ZpBdKW4pc43+835P//kSHZ8gtpC9aZukqROEUxyG2FhRxhgUdDHTCG3tGyPh5ITGmOiJq/s6JqbmSgqacoTAh4wv5JvgXwyLGCp1h6+O2nmXMTMiBdo98yEe7U6wN3WQ yG/SVdBC8no5jUgVJd/tEbP2U8FswFV8Ocv3Wd/dEIrT1k3xsT0n+DvRNCOB4rj6j+g== OpenPGP: url=https://posteo.de/keys/nils.freydank@posteo.de.asc X-Archives-Salt: 9a19f1c9-5f71-499b-aa2e-c7430021dc18 X-Archives-Hash: 5f961a5fa5cdae8626cb74c8b81526d8 --nfeytkr63htypicl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Am Montag, den 24.05.2021 um 11:52:22 Uhr +0100 schrieb Michael : > On Monday, 24 May 2021 02:01:15 BST Oliver Dixon wrote: > > Hi, > > > > I decided to bite the bullet yesterday and switch from clunky, and generally > > untoward, VirtualBox to QEMU/KVM for developing kernel modules. I have a > > working Gentoo VM with all the bells and whistles I need/want (UEFI > > booting, NIC passthrough, SSH forwarding, NFSv4 support, etc.), but it's > > running in an SDL window, which means the guest TTY will become confused > > and pretty much unusable whenever I change the window size. (Which is > > rather often since I use a tiling window manager.) > > Have you tried '-display sdl,gl=on -vga virtio' and then use Ctrl+Alt+f to > maximise it early in the boot process? It seems to work OK here, without > distorting the contents of the VM window. Why don't you (Oliver) just use ssh to log in? That way you wouldn't have to work around TTY resizing problems. If you don't see a prompt over the serial connection, than maybe there is no getty/agetty instance listening there. Unfortunately I can't help further in that direction. As a different approach you could also put the qemu output into a VNC socket with '-vnc unix:/path/to/socket'. With '-vga virtio' and '-vga std' I had at least a reproducible screen resolution at startup. Inspired by app-emulation/nemu I wrote a short shell script which does this and works for me. I'll attach it here - feel free to take useful parts out of it, e.g. the daemon mode of qemu could be interesting for you aswell. --nfeytkr63htypicl Content-Type: application/x-sh Content-Disposition: attachment; filename="control-vm.sh" Content-Transfer-Encoding: quoted-printable #!/bin/bash=0A# Virtual machine control script for QEMU/KVM VMs.=0A# Tested= on Gentoo (~amd64/hardened) with qemu-6.0.=0A#=0A# Version: 2021-06-05=0A#= Author: Nils Freydank =0A# License: MIT=0A=0A# TODO= (not in specific order):=0A# 1. Support qemu-img commit=0A# 2. clipboard s= upport via spice=0A# 3. Support ISO-only boots/live media like tails.=0A# 4= =2E Support boot from CD for first installations.=0A=0A# =3D=3D=3D Usage of= this script =3D=3D=3D=0A# Create a directory to contain your VM images and= metadata.=0A# Let it be readable and writeable for the user who executes Q= EMU.=0A# For each Guest do the following:=0A# Create a directory named ex= actly as the guest=0A# Create an qcow2 image named virtual-machine.img in= side the newly created=0A# directory.=0A# Create a configuration file n= amed exactly as the guest plus a suffix '.sh'.=0A# Fill in the data from = the example below into the configuration file.=0A# Control the vm by call= ing: ./ ,=0A# e.g. ./control-v= m Gentoo-guest start=0A# or ./control-vm Gentoo-guest shudown=0A# or = ./control-vm Gentoo-guest save=0A=0A# =3D=3D=3D Configuration the guest. = =3D=3D=3D=0A# Create a file with the guest's parameters and name it same as= the "GUEST_NAME"=0A# plus a "sh" suffix, so we can easily assume the name = later.=0A#=0A# cat << _EOF > "${GUEST_NAME}.sh"=0A# CPU_CORES=3D"8"=0A# CPU= _SOCKETS=3D""=0A# CPU_=0A# GUEST_NAME=3D"Guest-OS"=0A# MEMORY=3D"16384"=0A#= NET=3D"True"=0A# SOUND=3D"True"=0A# SSH_PORT=3D""=0A# UI=3D"True"=0A# _EOF= =0A=0A# =3D=3D=3D Define defaults. =3D=3D=3D=0A[[ -z "${1}" ]] && echo "Ple= ase provide a guest name!" && exit 1=0ACPUS=3D"${CPUS:-16}"=0ACPU_CORES=3D"= ${CPU_CORES:-1}"=0AEFI_MACHINE=3D"${EFI_MACHINE:-pc-q35-6.0}" # Needs >=3Dq= emu-6.0 ;-)=0AEXTRA_BOOT_PARAMS=3D"${EXTRA_BOOT_PARAMS:-}"=0AGUEST_NAME=3D"= $1"=0AMEMORY=3D"${MEMORY:-16384}"=0ANET=3D"${NET:-}"=0ANETDEV_NAME=3D"vmnic= -${GUEST_NAME}"=0ALIVE_ONLY=3D"${LIVE_ONLY:-}"=0ASOUND=3D"${SOUND:-}"=0ASSH= _PORT=3D"${SSH_PORT:-}"=0AUI=3D"${UI:-}"=0A# Define global paths.=0ABASE_PA= TH=3D"${BASE_PATH:-${HOME}/vm/${GUEST_NAME}}"=0AIMAGE_PATH=3D"${IMAGE_PATH:= -${BASE_PATH}/virtual-machine.img}"=0AISO_PATH=3D"${ISO_PATH:-}"=0AMONITOR_= SOCKET=3D"${MONITOR_SOCKET:-${BASE_PATH}/monitor.socket}"=0APID_FILE=3D"${P= ID_FILE:-${BASE_PATH}/qemu.pid}"=0ASNAPSHOT_INFO_FILE=3D"${SNAPSHOT_INFO_FI= LE:-${BASE_PATH}/last-snapshot-info}"=0AVNC_SOCKET=3D"${VNC_SOCKET:-${BASE_= PATH}/vnc.socket}"=0AGUEST_CONFIG_FILE=3D"${HOME}/vm/${GUEST_NAME}.sh"=0A= =0A=0A# =3D=3D=3D Source the guest configuration to overwrite defaults if n= ecessary. =3D=3D=3D=0Aif [[ -f "${GUEST_CONFIG_FILE}" ]]=0Athen=0A source = "${GUEST_CONFIG_FILE}"=0Aelse=0A echo "No configuration found. Aborting."= =0A exit 2=0Afi=0A=0A# =3D=3D=3D Define a base and glue everything togethe= r. =3D=3D=3D=0AQEMU_COMMON_ARGS=3D(=0A # Provide a pretty name for the gue= st.=0A -name "${GUEST_NAME}"=0A # Configure some seccomp mode 2 filters.= =0A -sandbox on,obsolete=3Ddeny,elevateprivileges=3Dallow,spawn=3Dallow,re= sourcecontrol=3Dallow=0A # Enable KVM and hardware acceleration.=0A -enab= le-kvm=0A # Use the same CPU as the host has for maximum performoance and = configure=0A # the amount of memory and CPU cores as configured per-host.= =0A -cpu host=0A -smp cpus=3D"${CPUS}",maxcpus=3D"${CPUS}",cores=3D"${CPU= _CORES}"=0A -m "${MEMORY}"=0A # Detach from the current shell and monitor= by pid file and a unix socket.=0A -daemonize=0A -pidfile "${PID_FILE}"= =0A -monitor unix:"${MONITOR_SOCKET}",server,nowait=0A)=0AQEMU_DISK_ARGS= =3D(=0A -drive id=3Dhd0,media=3Ddisk,if=3Dvirtio,file=3D"${IMAGE_PATH}",di= scard=3Don,aio=3Dio_uring,cache=3Dnone=0A)=0AQEMU_DISPLAY_NONE_ARGS=3D( -vg= a none -display none )=0AQEMU_DISPLAY_STDVGA_ARGS=3D(=0A -vga virtio=0A -= vnc unix:"${VNC_SOCKET}"=0A)=0AQEMU_EFI_ARGS=3D(=0A -M "${EFI_MACHINE}"=0A= -drive file=3D/usr/share/edk2-ovmf/OVMF_CODE.fd,if=3Dpflash,format=3Draw,= unit=3D0,readonly=3Don=0A)=0AQEMU_ISO_ARGS=3D( -cdrom "${ISO_PATH}" )=0AQEM= U_NET_ARGS=3D(=0A -device virtio-net,netdev=3D"${NETDEV_NAME}"=0A -netdev= user,id=3D"${NETDEV_NAME}"=0A)=0AQEMU_SOUND_ARGS=3D( -device ich9-intel-hd= a -device hda-duplex )=0AQEMU_SSH_ARGS=3D(=0A -device virtio-net,netdev=3D= "${NETDEV_NAME}"=0A -netdev user,id=3D"${NETDEV_NAME}",hostfwd=3Dtcp:127.0= =2E0.1:"${SSH_PORT}"-:22=0A)=0A=0A# =3D=3D=3D Start the final QEMU paramete= r array. =3D=3D=3D=0AQEMU_ARGS=3D(=0A "${QEMU_COMMON_ARGS[@]}"=0A "${QEMU= _EFI_ARGS[@]}"=0A)=0A[[ -z "${LIVE_ONLY}" ]] && QEMU_ARGS+=3D( "${QEMU_DISK= _ARGS[@]}" -boot d )=0A[[ ! -z "${NET}" && -z "${SSH_PORT}" ]] && QEMU_ARGS= +=3D( "${QEMU_NET_ARGS[@]}" )=0A[[ ! -z "${SOUND}" ]] && QEMU_ARGS+=3D( "${= QEMU_SOUND_ARGS[@]}" )=0A[[ ! -z "${SSH_PORT}" ]] && QEMU_ARGS+=3D( "${QEMU= _SSH_ARGS[@]}" )=0A[[ ! -z "${ISO_PATH}" ]] && QEMU_ARGS+=3D( "${QEMU_ISO_A= RGS[@]}" )=0Aif [[ ! -z "${UI}" ]]=0Athen=0A QEMU_ARGS+=3D( "${QEMU_DISPLA= Y_STDVGA_ARGS[@]}" )=0Aelse=0A QEMU_ARGS+=3D( "${QEMU_DISPLAY_NONE_ARGS[@]= }" )=0Afi=0A=0A# =3D=3D=3D Define functions for the actual QEMU controlling= =2E =3D=3D=3D=0Astart_qemu(){=0A [[ ! -f "${PID_FILE}" ]] && /usr/bin/qemu= -system-x86_64 "${QEMU_ARGS[@]}"=0A}=0Ashutdown_qemu(){=0A if [[ -f "${PID= _FILE}" ]]=0A then=0A echo "system_powerdown" | socat - unix-connect:= "${MONITOR_SOCKET}"=0A fi=0A}=0Astop_qemu(){=0A if [[ -f "${PID_FILE}" ]]= =0A then=0A echo "quit" | socat - unix-connect:"${MONITOR_SOCKET}"=0A= fi=0A}=0Asave_qemu(){=0A if [[ -f "${PID_FILE}" ]]=0A then=0A SNAP= SHOT_NAME=3D"snap$(date --utc +%s)"=0A echo "savevm ${SNAPSHOT_NAME}" = | socat - unix-connect:"${MONITOR_SOCKET}"=0A echo "${SNAPSHOT_NAME}" = > "${SNAPSHOT_INFO_FILE}"=0A fi=0A}=0Apause_qemu(){=0A if [[ -f "${PID_FI= LE}" ]]=0A then=0A echo "stop" | socat - unix-connect:"${MONITOR_SOCK= ET}"=0A fi=0A}=0Arestore_qemu(){=0A if [[ -f "${PID_FILE}" ]]=0A then=0A= SNAPSHOT_NAME=3D"$(cat ${SNAPSHOT_INFO_FILE})"=0A echo "loadvm $= {SNAPSHOT_NAME}" | socat - unix-connect:"${MONITOR_SOCKET}"=0A fi=0A}=0Are= sume_qemu(){=0A if [[ -f "${PID_FILE}" ]]=0A then=0A echo "cont" | s= ocat - unix-connect:"${MONITOR_SOCKET}"=0A fi=0A}=0A=0A# =3D=3D=3D Parse t= he user input. =3D=3D=3D=0A# "$1 !=3D nothing" is already checked earlier.= =0Acase "${2}" in=0A start) echo "Starting VM ${GUEST_NAME}." && start_qem= u;;=0A shutdown) echo "Requesting shutdown for VM ${GUEST_NAME}." && shutd= own_qemu;;=0A stop) echo "Forcing shutdown of VM ${GUEST_NAME}." && stop_q= emu;;=0A connect) echo "Opening VNC session for ${GUEST_NAME}." \=0A = && ( vncviewer "${VNC_SOCKET}" &> /dev/null )& ;;=0A save) echo "Saving st= ate of VM ${GUEST_NAME}." && save_qemu;;=0A restore) echo "Restore state o= f VM ${GUEST_NAME}." && restore_qemu;;=0A pause) echo "Pausing the VM ${GU= EST_NAME}." && pause_qemu;;=0A resume) echo "Resuming the VM ${GUEST_NAME}= =2E" && resume_qemu;;=0A *) echo "Unknown Operation!"=0A echo "Use one= of: start | shutdown | stop | connect | save | restore | pause | resume"= =0A echo "Note that stop means a forced stop.";;=0Aesac=0A# vim:fileenc= oding=3Dutf-8:ts=3D2:syntax=3Dbash:expandtab:colorcolumn=3D81=0A --nfeytkr63htypicl--