From 3fe4845098ca3478fc2d83e6fc943fec4c0459d6 Mon Sep 17 00:00:00 2001 From: Shokara Kou Date: Sat, 30 Dec 2023 15:50:12 -0500 Subject: import qemu from openbsd 7.3 ports --- emulators/qemu/CVS/Entries | 5 + emulators/qemu/CVS/Repository | 1 + emulators/qemu/CVS/Root | 1 + emulators/qemu/CVS/Tag | 1 + emulators/qemu/Makefile | 139 +++++ emulators/qemu/distinfo | 2 + emulators/qemu/files/CVS/Entries | 4 + emulators/qemu/files/CVS/Repository | 1 + emulators/qemu/files/CVS/Root | 1 + emulators/qemu/files/CVS/Tag | 1 + emulators/qemu/files/qemu-ga.conf | 3 + emulators/qemu/files/qemu-ifdown | 14 + emulators/qemu/files/qemu-ifup | 40 ++ emulators/qemu/patches/CVS/Entries | 10 + emulators/qemu/patches/CVS/Repository | 1 + emulators/qemu/patches/CVS/Root | 1 + emulators/qemu/patches/CVS/Tag | 1 + emulators/qemu/patches/patch-audio_audio_c | 13 + .../qemu/patches/patch-audio_audio_template_h | 14 + emulators/qemu/patches/patch-audio_meson_build | 13 + emulators/qemu/patches/patch-audio_sndioaudio_c | 572 ++++++++++++++++++++ emulators/qemu/patches/patch-configure | 97 ++++ emulators/qemu/patches/patch-meson_build | 56 ++ .../patch-meson_mesonbuild_compilers_cpp_py | 21 + emulators/qemu/patches/patch-meson_options_txt | 23 + emulators/qemu/patches/patch-plugins_meson_build | 26 + emulators/qemu/patches/patch-qapi_audio_json | 50 ++ emulators/qemu/patches/patch-qemu-options_hx | 35 ++ emulators/qemu/patches/patch-qga_commands-bsd_c | 16 + emulators/qemu/patches/patch-qga_commands-posix_c | 576 +++++++++++++++++++++ emulators/qemu/patches/patch-qga_main_c | 37 ++ emulators/qemu/patches/patch-util_cacheflush_c | 19 + .../qemu/patches/patch-util_qemu-thread-posix_c | 35 ++ emulators/qemu/pkg/CVS/Entries | 9 + emulators/qemu/pkg/CVS/Repository | 1 + emulators/qemu/pkg/CVS/Root | 1 + emulators/qemu/pkg/CVS/Tag | 1 + emulators/qemu/pkg/DESCR-ga | 3 + emulators/qemu/pkg/DESCR-main | 4 + emulators/qemu/pkg/PFRAG.plugins-main | 1 + emulators/qemu/pkg/PLIST-ga | 14 + emulators/qemu/pkg/PLIST-main | 465 +++++++++++++++++ emulators/qemu/pkg/README-ga | 25 + emulators/qemu/pkg/README-main | 266 ++++++++++ emulators/qemu/pkg/qemu_ga.rc | 14 + 45 files changed, 2633 insertions(+) create mode 100644 emulators/qemu/CVS/Entries create mode 100644 emulators/qemu/CVS/Repository create mode 100644 emulators/qemu/CVS/Root create mode 100644 emulators/qemu/CVS/Tag create mode 100644 emulators/qemu/Makefile create mode 100644 emulators/qemu/distinfo create mode 100644 emulators/qemu/files/CVS/Entries create mode 100644 emulators/qemu/files/CVS/Repository create mode 100644 emulators/qemu/files/CVS/Root create mode 100644 emulators/qemu/files/CVS/Tag create mode 100644 emulators/qemu/files/qemu-ga.conf create mode 100644 emulators/qemu/files/qemu-ifdown create mode 100644 emulators/qemu/files/qemu-ifup create mode 100644 emulators/qemu/patches/CVS/Entries create mode 100644 emulators/qemu/patches/CVS/Repository create mode 100644 emulators/qemu/patches/CVS/Root create mode 100644 emulators/qemu/patches/CVS/Tag create mode 100644 emulators/qemu/patches/patch-audio_audio_c create mode 100644 emulators/qemu/patches/patch-audio_audio_template_h create mode 100644 emulators/qemu/patches/patch-audio_meson_build create mode 100644 emulators/qemu/patches/patch-audio_sndioaudio_c create mode 100644 emulators/qemu/patches/patch-configure create mode 100644 emulators/qemu/patches/patch-meson_build create mode 100644 emulators/qemu/patches/patch-meson_mesonbuild_compilers_cpp_py create mode 100644 emulators/qemu/patches/patch-meson_options_txt create mode 100644 emulators/qemu/patches/patch-plugins_meson_build create mode 100644 emulators/qemu/patches/patch-qapi_audio_json create mode 100644 emulators/qemu/patches/patch-qemu-options_hx create mode 100644 emulators/qemu/patches/patch-qga_commands-bsd_c create mode 100644 emulators/qemu/patches/patch-qga_commands-posix_c create mode 100644 emulators/qemu/patches/patch-qga_main_c create mode 100644 emulators/qemu/patches/patch-util_cacheflush_c create mode 100644 emulators/qemu/patches/patch-util_qemu-thread-posix_c create mode 100644 emulators/qemu/pkg/CVS/Entries create mode 100644 emulators/qemu/pkg/CVS/Repository create mode 100644 emulators/qemu/pkg/CVS/Root create mode 100644 emulators/qemu/pkg/CVS/Tag create mode 100644 emulators/qemu/pkg/DESCR-ga create mode 100644 emulators/qemu/pkg/DESCR-main create mode 100644 emulators/qemu/pkg/PFRAG.plugins-main create mode 100644 emulators/qemu/pkg/PLIST-ga create mode 100644 emulators/qemu/pkg/PLIST-main create mode 100644 emulators/qemu/pkg/README-ga create mode 100644 emulators/qemu/pkg/README-main create mode 100644 emulators/qemu/pkg/qemu_ga.rc diff --git a/emulators/qemu/CVS/Entries b/emulators/qemu/CVS/Entries new file mode 100644 index 0000000..e40f1c4 --- /dev/null +++ b/emulators/qemu/CVS/Entries @@ -0,0 +1,5 @@ +D/files//// +D/patches//// +D/pkg//// +/Makefile/1.230/Tue Feb 21 23:06:55 2023//TOPENBSD_7_3 +/distinfo/1.68/Wed Jan 4 21:33:42 2023//TOPENBSD_7_3 diff --git a/emulators/qemu/CVS/Repository b/emulators/qemu/CVS/Repository new file mode 100644 index 0000000..452518b --- /dev/null +++ b/emulators/qemu/CVS/Repository @@ -0,0 +1 @@ +ports/emulators/qemu diff --git a/emulators/qemu/CVS/Root b/emulators/qemu/CVS/Root new file mode 100644 index 0000000..3811072 --- /dev/null +++ b/emulators/qemu/CVS/Root @@ -0,0 +1 @@ +/cvs diff --git a/emulators/qemu/CVS/Tag b/emulators/qemu/CVS/Tag new file mode 100644 index 0000000..b1c2a73 --- /dev/null +++ b/emulators/qemu/CVS/Tag @@ -0,0 +1 @@ +TOPENBSD_7_3 diff --git a/emulators/qemu/Makefile b/emulators/qemu/Makefile new file mode 100644 index 0000000..3775eb6 --- /dev/null +++ b/emulators/qemu/Makefile @@ -0,0 +1,139 @@ +ONLY_FOR_ARCHS= aarch64 amd64 arm i386 powerpc powerpc64 riscv64 sparc64 +DPB_PROPERTIES= parallel + +COMMENT-main= multi system emulator +COMMENT-ga= QEMU guest agent + +VERSION= 7.2.0 +DISTNAME= qemu-${VERSION} +REVISION-ga= 0 +REVISION-main= 1 +CATEGORIES= emulators +MASTER_SITES= https://download.qemu.org/ +EXTRACT_SUFX= .tar.xz + +HOMEPAGE= https://www.qemu.org/ + +MAINTAINER= Brad Smith + +# GPLv2, LGPLv2 and BSD +PERMIT_PACKAGE= Yes + +WANTLIB= c glib-2.0 pthread +WANTLIB-main= ${COMPILER_LIBCXX} ${WANTLIB} SDL2 X11 bz2 cairo capstone curl \ + curses epoxy fdt gbm gdk-3 gdk_pixbuf-2.0 gio-2.0 gnutls \ + gobject-2.0 gtk-3 iconv intl iscsi jpeg lzo2 m nfs pixman-1 \ + png slirp sndio ssh usb-1.0 util vte-2.91 xkbcommon z zstd +WANTLIB-ga= ${WANTLIB} + +MULTI_PACKAGES= -main -ga +DEBUG_PACKAGES= ${BUILD_PACKAGES} + +# Using TLS emulation layer +COMPILER= base-clang ports-gcc + +MODULES= lang/python +MODPY_RUNDEP= No + +BUILD_DEPENDS= devel/gettext,-tools \ + devel/ninja \ + shells/bash \ + textproc/py-sphinx${MODPY_FLAVOR}>=4.0.2 \ + textproc/py-sphinx_rtd_theme${MODPY_FLAVOR} + +RUN_DEPENDS-main= ${BUILD_PKGPATH}-ga +LIB_DEPENDS= devel/glib2 +LIB_DEPENDS-main= ${LIB_DEPENDS} \ + archivers/bzip2 \ + archivers/lzo2 \ + archivers/zstd \ + converters/libiconv \ + devel/capstone/main \ + devel/dtc \ + devel/gettext,-runtime \ + devel/libiscsi \ + devel/libnfs \ + devel/libusb1 \ + devel/sdl2 \ + devel/vte3 \ + graphics/jpeg \ + graphics/png \ + net/curl \ + net/libslirp \ + security/gnutls \ + security/libssh \ + x11/gtk+3 \ + x11/xkbcommon +LIB_DEPENDS-ga= ${LIB_DEPENDS} + +MAKE_ENV= V=1 +FAKE_FLAGS= qemu_confdir=${PREFIX}/share/examples/qemu + +CFLAGS+= -I${LOCALBASE}/include -I${X11BASE}/include +LDFLAGS+= -L${LOCALBASE}/lib -L${X11BASE}/lib + +# until the system headers are fixed properly. +CFLAGS+= -Wno-redundant-decls + +SEPARATE_BUILD= Yes +USE_GMAKE= Yes +CONFIGURE_STYLE=simple +CONFIGURE_ENV+= LDFLAGS="${LDFLAGS}" +CONFIGURE_ARGS= --localstatedir=${LOCALSTATEDIR} \ + --prefix=${PREFIX} \ + --sysconfdir=${SYSCONFDIR} \ + --mandir=${PREFIX}/man \ + --python=${MODPY_BIN} \ + --smbd=${LOCALBASE}/sbin/smbd \ + --cc="${CC}" \ + --cxx="${CXX}" \ + --host-cc="${CC}" \ + --enable-capstone \ + --disable-auth-pam \ + --disable-bsd-user \ + --disable-jack \ + --disable-sdl-image \ + --disable-smartcard \ + --disable-snappy \ + --disable-spice \ + --disable-usb-redir \ + --disable-vnc-sasl + +FLAVORS= debug +FLAVOR?= + +.if ${FLAVOR:Mdebug} +CFLAGS+= -O0 +CONFIGURE_ARGS+=--enable-debug +INSTALL_STRIP= +.else +CONFIGURE_ARGS+=--disable-debug-info +.endif + +TEST_TARGET= check + +# XXX Optimizer bug, using -O2 causes segfaults, -O1 linking errors +.if ${MACHINE_ARCH:Mpowerpc} +CFLAGS+= -O0 +.endif + +.include + +# Only lld has --dynamic-list +.if ${PROPERTIES:Mlld} +WANTLIB-main+= gmodule-2.0 +PKG_ARGS+= -Dplugins=1 +.else +PKG_ARGS+= -Dplugins=0 +.endif + +post-install: + ${INSTALL_DATA_DIR} ${PREFIX}/share/examples/qemu + ${INSTALL_SCRIPT} ${FILESDIR}/qemu-ifup \ + ${PREFIX}/share/examples/qemu + ${INSTALL_SCRIPT} ${FILESDIR}/qemu-ifdown \ + ${PREFIX}/share/examples/qemu + ${INSTALL_SCRIPT} ${FILESDIR}/qemu-ga.conf \ + ${PREFIX}/share/examples/qemu + +.include diff --git a/emulators/qemu/distinfo b/emulators/qemu/distinfo new file mode 100644 index 0000000..2af259a --- /dev/null +++ b/emulators/qemu/distinfo @@ -0,0 +1,2 @@ +SHA256 (qemu-7.2.0.tar.xz) = W0nOJod0Ta1JSukKiYxSIEo0BuhNBySCoeG+hU7rIVc= +SIZE (qemu-7.2.0.tar.xz) = 122408576 diff --git a/emulators/qemu/files/CVS/Entries b/emulators/qemu/files/CVS/Entries new file mode 100644 index 0000000..8a3bf7a --- /dev/null +++ b/emulators/qemu/files/CVS/Entries @@ -0,0 +1,4 @@ +/qemu-ga.conf/1.1/Tue Mar 29 10:04:28 2022//TOPENBSD_7_3 +/qemu-ifdown/1.5/Wed Oct 28 09:17:31 2015//TOPENBSD_7_3 +/qemu-ifup/1.10/Wed Oct 28 09:17:31 2015//TOPENBSD_7_3 +D diff --git a/emulators/qemu/files/CVS/Repository b/emulators/qemu/files/CVS/Repository new file mode 100644 index 0000000..a9a1732 --- /dev/null +++ b/emulators/qemu/files/CVS/Repository @@ -0,0 +1 @@ +ports/emulators/qemu/files diff --git a/emulators/qemu/files/CVS/Root b/emulators/qemu/files/CVS/Root new file mode 100644 index 0000000..3811072 --- /dev/null +++ b/emulators/qemu/files/CVS/Root @@ -0,0 +1 @@ +/cvs diff --git a/emulators/qemu/files/CVS/Tag b/emulators/qemu/files/CVS/Tag new file mode 100644 index 0000000..b1c2a73 --- /dev/null +++ b/emulators/qemu/files/CVS/Tag @@ -0,0 +1 @@ +TOPENBSD_7_3 diff --git a/emulators/qemu/files/qemu-ga.conf b/emulators/qemu/files/qemu-ga.conf new file mode 100644 index 0000000..184885a --- /dev/null +++ b/emulators/qemu/files/qemu-ga.conf @@ -0,0 +1,3 @@ +[general] +method=isa-serial +path=/dev/cua01 diff --git a/emulators/qemu/files/qemu-ifdown b/emulators/qemu/files/qemu-ifdown new file mode 100644 index 0000000..fbd5789 --- /dev/null +++ b/emulators/qemu/files/qemu-ifdown @@ -0,0 +1,14 @@ +#! /bin/sh + +_ETHER=trunk0 +_BRIDGE=bridge0 + +# Let the environment over-ride this +[ "$BRIDGE" ] || BRIDGE=${_BRIDGE} +[ "$ETHER" ] || ETHER=${_ETHER} + +if test `id -u` -ne 0; then + DOAS=doas +fi + +$DOAS ifconfig $BRIDGE del $1 > /dev/null 2>&1 diff --git a/emulators/qemu/files/qemu-ifup b/emulators/qemu/files/qemu-ifup new file mode 100644 index 0000000..1207696 --- /dev/null +++ b/emulators/qemu/files/qemu-ifup @@ -0,0 +1,40 @@ +#! /bin/sh + +_ETHER=`route -n get default 2>/dev/null |awk '/interface:/ {print $2}'` +_ETHER=${_ETHER:=trunk0} +_BRIDGE=bridge0 + +# Let the environment over-ride this +[ "$BRIDGE" ] || BRIDGE=${_BRIDGE} +[ "$ETHER" ] || ETHER=${_ETHER} + +if test `id -u` -ne 0; then + DOAS=doas +fi + +echo -n " {$1 ($BRIDGE <-> $ETHER)" + +# Set up our bridge +$DOAS ifconfig $1 group tap > /dev/null 2>&1 +$DOAS ifconfig $BRIDGE create > /dev/null 2>&1 && { + # Only add rules if the bridge creation succeeds; otherwise + # duplicate rules get loaded each time qemu starts + # The following two block carp packets from wasting cpu cycles inside the + # qemu sessions, remove if testing carp inside qemu + $DOAS ifconfig $BRIDGE rule block in on $ETHER dst 33:33:0:0:0:12 + $DOAS ifconfig $BRIDGE rule block in on $ETHER dst 01:00:5e:00:00:12 +} +# Since we can specify ETHER and BRIDGE above, its possible that +# this tap interface or this physical interface was setup as part of +# a different bridge earlier, and that is never cleaned up, so we have +# to cleanup here first before we set it up; a physical interface cannot +# be member to more than one bridge, thankfully, or I never would have +# caught this +ifconfig bridge | sed -n '/^bridge[0-9]*/{s/:.*$//;p;}' | while read brif +do + $DOAS ifconfig $brif del $ETHER > /dev/null 2>&1 + $DOAS ifconfig $brif del $1 > /dev/null 2>&1 +done +$DOAS ifconfig $BRIDGE add $ETHER up +$DOAS ifconfig $BRIDGE add $1 up || true +echo "}" diff --git a/emulators/qemu/patches/CVS/Entries b/emulators/qemu/patches/CVS/Entries new file mode 100644 index 0000000..f5fb771 --- /dev/null +++ b/emulators/qemu/patches/CVS/Entries @@ -0,0 +1,10 @@ +/patch-configure/1.75/Wed Jan 4 21:33:42 2023//TOPENBSD_7_3 +/patch-meson_build/1.9/Mon Jan 9 14:26:00 2023//TOPENBSD_7_3 +/patch-meson_mesonbuild_compilers_cpp_py/1.4/Wed Jan 4 21:33:42 2023//TOPENBSD_7_3 +/patch-plugins_meson_build/1.3/Wed Jan 4 21:33:42 2023//TOPENBSD_7_3 +/patch-qga_commands-bsd_c/1.1/Wed Jan 4 21:33:42 2023//TOPENBSD_7_3 +/patch-qga_commands-posix_c/1.7/Wed Jan 4 21:33:42 2023//TOPENBSD_7_3 +/patch-qga_main_c/1.6/Wed Jan 4 21:33:42 2023//TOPENBSD_7_3 +/patch-util_cacheflush_c/1.1/Tue Sep 13 20:11:35 2022//TOPENBSD_7_3 +/patch-util_qemu-thread-posix_c/1.1/Mon Jan 9 14:26:00 2023//TOPENBSD_7_3 +D diff --git a/emulators/qemu/patches/CVS/Repository b/emulators/qemu/patches/CVS/Repository new file mode 100644 index 0000000..ddd2435 --- /dev/null +++ b/emulators/qemu/patches/CVS/Repository @@ -0,0 +1 @@ +ports/emulators/qemu/patches diff --git a/emulators/qemu/patches/CVS/Root b/emulators/qemu/patches/CVS/Root new file mode 100644 index 0000000..3811072 --- /dev/null +++ b/emulators/qemu/patches/CVS/Root @@ -0,0 +1 @@ +/cvs diff --git a/emulators/qemu/patches/CVS/Tag b/emulators/qemu/patches/CVS/Tag new file mode 100644 index 0000000..b1c2a73 --- /dev/null +++ b/emulators/qemu/patches/CVS/Tag @@ -0,0 +1 @@ +TOPENBSD_7_3 diff --git a/emulators/qemu/patches/patch-audio_audio_c b/emulators/qemu/patches/patch-audio_audio_c new file mode 100644 index 0000000..9d89265 --- /dev/null +++ b/emulators/qemu/patches/patch-audio_audio_c @@ -0,0 +1,13 @@ +sndio module + +Index: audio/audio.c +--- audio/audio.c.orig ++++ audio/audio.c +@@ -2025,6 +2025,7 @@ void audio_create_pdos(Audiodev *dev) + CASE(OSS, oss, Oss); + CASE(PA, pa, Pa); + CASE(SDL, sdl, Sdl); ++ CASE(SNDIO, sndio, ); + CASE(SPICE, spice, ); + CASE(WAV, wav, ); + diff --git a/emulators/qemu/patches/patch-audio_audio_template_h b/emulators/qemu/patches/patch-audio_audio_template_h new file mode 100644 index 0000000..97fd008 --- /dev/null +++ b/emulators/qemu/patches/patch-audio_audio_template_h @@ -0,0 +1,14 @@ +sndio module + +Index: audio/audio_template.h +--- audio/audio_template.h.orig ++++ audio/audio_template.h +@@ -336,6 +336,8 @@ AudiodevPerDirectionOptions *glue(audio_get_pdo_, TYPE + return qapi_AudiodevPaPerDirectionOptions_base(dev->u.pa.TYPE); + case AUDIODEV_DRIVER_SDL: + return qapi_AudiodevSdlPerDirectionOptions_base(dev->u.sdl.TYPE); ++ case AUDIODEV_DRIVER_SNDIO: ++ return dev->u.sndio.TYPE; + case AUDIODEV_DRIVER_SPICE: + return dev->u.spice.TYPE; + case AUDIODEV_DRIVER_WAV: diff --git a/emulators/qemu/patches/patch-audio_meson_build b/emulators/qemu/patches/patch-audio_meson_build new file mode 100644 index 0000000..842fcf8 --- /dev/null +++ b/emulators/qemu/patches/patch-audio_meson_build @@ -0,0 +1,13 @@ +sndio module + +Index: audio/meson.build +--- audio/meson.build.orig ++++ audio/meson.build +@@ -17,6 +17,7 @@ foreach m : [ + ['pa', pulse, files('paaudio.c')], + ['sdl', sdl, files('sdlaudio.c')], + ['jack', jack, files('jackaudio.c')], ++ ['sndio', sndio, files('sndioaudio.c')], + ['spice', spice, files('spiceaudio.c')] + ] + if m[1].found() diff --git a/emulators/qemu/patches/patch-audio_sndioaudio_c b/emulators/qemu/patches/patch-audio_sndioaudio_c new file mode 100644 index 0000000..68b4c2e --- /dev/null +++ b/emulators/qemu/patches/patch-audio_sndioaudio_c @@ -0,0 +1,572 @@ +sndio module + +Index: audio/sndioaudio.c +--- audio/sndioaudio.c.orig ++++ audio/sndioaudio.c +@@ -0,0 +1,566 @@ ++/* ++ * SPDX-License-Identifier: ISC ++ * ++ * Copyright (c) 2019 Alexandre Ratchov ++ */ ++ ++/* ++ * TODO : ++ * ++ * Use a single device and open it in full-duplex rather than ++ * opening it twice (once for playback once for recording). ++ * ++ * This is the only way to ensure that playback doesn't drift with respect ++ * to recording, which is what guest systems expect. ++ */ ++ ++#include ++#include ++#include "qemu/osdep.h" ++#include "qemu/help-texts.h" ++#include "qemu/main-loop.h" ++#include "audio.h" ++#include "trace.h" ++ ++#define AUDIO_CAP "sndio" ++#include "audio_int.h" ++ ++/* default latency in microseconds if no option is set */ ++#define SNDIO_LATENCY_US 50000 ++ ++typedef struct SndioVoice { ++ union { ++ HWVoiceOut out; ++ HWVoiceIn in; ++ } hw; ++ struct sio_par par; ++ struct sio_hdl *hdl; ++ struct pollfd *pfds; ++ struct pollindex { ++ struct SndioVoice *self; ++ int index; ++ } *pindexes; ++ unsigned char *buf; ++ size_t buf_size; ++ size_t sndio_pos; ++ size_t qemu_pos; ++ unsigned int mode; ++ unsigned int nfds; ++ bool enabled; ++} SndioVoice; ++ ++typedef struct SndioConf { ++ const char *devname; ++ unsigned int latency; ++} SndioConf; ++ ++/* needed for forward reference */ ++static void sndio_poll_in(void *arg); ++static void sndio_poll_out(void *arg); ++ ++/* ++ * stop polling descriptors ++ */ ++static void sndio_poll_clear(SndioVoice *self) ++{ ++ struct pollfd *pfd; ++ int i; ++ ++ for (i = 0; i < self->nfds; i++) { ++ pfd = &self->pfds[i]; ++ qemu_set_fd_handler(pfd->fd, NULL, NULL, NULL); ++ } ++ ++ self->nfds = 0; ++} ++ ++/* ++ * write data to the device until it blocks or ++ * all of our buffered data is written ++ */ ++static void sndio_write(SndioVoice *self) ++{ ++ size_t todo, n; ++ ++ todo = self->qemu_pos - self->sndio_pos; ++ ++ /* ++ * transfer data to device, until it blocks ++ */ ++ while (todo > 0) { ++ n = sio_write(self->hdl, self->buf + self->sndio_pos, todo); ++ if (n == 0) { ++ break; ++ } ++ self->sndio_pos += n; ++ todo -= n; ++ } ++ ++ if (self->sndio_pos == self->buf_size) { ++ /* ++ * we complete the block ++ */ ++ self->sndio_pos = 0; ++ self->qemu_pos = 0; ++ } ++} ++ ++/* ++ * read data from the device until it blocks or ++ * there no room any longer ++ */ ++static void sndio_read(SndioVoice *self) ++{ ++ size_t todo, n; ++ ++ todo = self->buf_size - self->sndio_pos; ++ ++ /* ++ * transfer data from the device, until it blocks ++ */ ++ while (todo > 0) { ++ n = sio_read(self->hdl, self->buf + self->sndio_pos, todo); ++ if (n == 0) { ++ break; ++ } ++ self->sndio_pos += n; ++ todo -= n; ++ } ++} ++ ++/* ++ * Set handlers for all descriptors libsndio needs to ++ * poll ++ */ ++static void sndio_poll_wait(SndioVoice *self) ++{ ++ struct pollfd *pfd; ++ int events, i; ++ ++ events = 0; ++ if (self->mode == SIO_PLAY) { ++ if (self->sndio_pos < self->qemu_pos) { ++ events |= POLLOUT; ++ } ++ } else { ++ if (self->sndio_pos < self->buf_size) { ++ events |= POLLIN; ++ } ++ } ++ ++ /* ++ * fill the given array of descriptors with the events sndio ++ * wants, they are different from our 'event' variable because ++ * sndio may use descriptors internally. ++ */ ++ self->nfds = sio_pollfd(self->hdl, self->pfds, events); ++ ++ for (i = 0; i < self->nfds; i++) { ++ pfd = &self->pfds[i]; ++ if (pfd->fd < 0) { ++ continue; ++ } ++ qemu_set_fd_handler(pfd->fd, ++ (pfd->events & POLLIN) ? sndio_poll_in : NULL, ++ (pfd->events & POLLOUT) ? sndio_poll_out : NULL, ++ &self->pindexes[i]); ++ pfd->revents = 0; ++ } ++} ++ ++/* ++ * call-back called when one of the descriptors ++ * became readable or writable ++ */ ++static void sndio_poll_event(SndioVoice *self, int index, int event) ++{ ++ int revents; ++ ++ /* ++ * ensure we're not called twice this cycle ++ */ ++ sndio_poll_clear(self); ++ ++ /* ++ * make self->pfds[] look as we're returning from poll syscal, ++ * this is how sio_revents expects events to be. ++ */ ++ self->pfds[index].revents = event; ++ ++ /* ++ * tell sndio to handle events and return whether we can read or ++ * write without blocking. ++ */ ++ revents = sio_revents(self->hdl, self->pfds); ++ if (self->mode == SIO_PLAY) { ++ if (revents & POLLOUT) { ++ sndio_write(self); ++ } ++ ++ if (self->qemu_pos < self->buf_size) { ++ audio_run(self->hw.out.s, "sndio_out"); ++ } ++ } else { ++ if (revents & POLLIN) { ++ sndio_read(self); ++ } ++ ++ if (self->qemu_pos < self->sndio_pos) { ++ audio_run(self->hw.in.s, "sndio_in"); ++ } ++ } ++ ++ /* ++ * audio_run() may have changed state ++ */ ++ if (self->enabled) { ++ sndio_poll_wait(self); ++ } ++} ++ ++/* ++ * return the upper limit of the amount of free play buffer space ++ */ ++static size_t sndio_buffer_get_free(HWVoiceOut *hw) ++{ ++ SndioVoice *self = (SndioVoice *) hw; ++ ++ return self->buf_size - self->qemu_pos; ++} ++ ++/* ++ * return a buffer where data to play can be stored, ++ * its size is stored in the location pointed by the size argument. ++ */ ++static void *sndio_get_buffer_out(HWVoiceOut *hw, size_t *size) ++{ ++ SndioVoice *self = (SndioVoice *) hw; ++ ++ *size = self->buf_size - self->qemu_pos; ++ return self->buf + self->qemu_pos; ++} ++ ++/* ++ * return a buffer where data to play can be stored ++ */ ++static size_t sndio_put_buffer_out(HWVoiceOut *hw, void *buf, size_t size) ++{ ++ SndioVoice *self = (SndioVoice *) hw; ++ ++ self->qemu_pos += size; ++ sndio_poll_wait(self); ++ return size; ++} ++ ++/* ++ * return a buffer from where recorded data is available, ++ * its size is stored in the location pointed by the size argument. ++ * it may not exceed the initial value of "*size". ++ */ ++static void *sndio_get_buffer_in(HWVoiceIn *hw, size_t *size) ++{ ++ SndioVoice *self = (SndioVoice *) hw; ++ size_t todo, max_todo; ++ ++ /* ++ * unlike the get_buffer_out() method, get_buffer_in() ++ * must return a buffer of at most the given size, see audio.c ++ */ ++ max_todo = *size; ++ ++ todo = self->sndio_pos - self->qemu_pos; ++ if (todo > max_todo) { ++ todo = max_todo; ++ } ++ ++ *size = todo; ++ return self->buf + self->qemu_pos; ++} ++ ++/* ++ * discard the given amount of recorded data ++ */ ++static void sndio_put_buffer_in(HWVoiceIn *hw, void *buf, size_t size) ++{ ++ SndioVoice *self = (SndioVoice *) hw; ++ ++ self->qemu_pos += size; ++ if (self->qemu_pos == self->buf_size) { ++ self->qemu_pos = 0; ++ self->sndio_pos = 0; ++ } ++ sndio_poll_wait(self); ++} ++ ++/* ++ * call-back called when one of our descriptors becomes writable ++ */ ++static void sndio_poll_out(void *arg) ++{ ++ struct pollindex *pindex = (struct pollindex *) arg; ++ ++ sndio_poll_event(pindex->self, pindex->index, POLLOUT); ++} ++ ++/* ++ * call-back called when one of our descriptors becomes readable ++ */ ++static void sndio_poll_in(void *arg) ++{ ++ struct pollindex *pindex = (struct pollindex *) arg; ++ ++ sndio_poll_event(pindex->self, pindex->index, POLLIN); ++} ++ ++static void sndio_fini(SndioVoice *self) ++{ ++ if (self->hdl) { ++ sio_close(self->hdl); ++ self->hdl = NULL; ++ } ++ ++ g_free(self->pfds); ++ g_free(self->pindexes); ++ g_free(self->buf); ++} ++ ++static int sndio_init(SndioVoice *self, ++ struct audsettings *as, int mode, Audiodev *dev) ++{ ++ AudiodevSndioOptions *opts = &dev->u.sndio; ++ unsigned long long latency; ++ const char *dev_name; ++ struct sio_par req; ++ unsigned int nch; ++ int i, nfds; ++ ++ dev_name = opts->has_dev ? opts->dev : SIO_DEVANY; ++ latency = opts->has_latency ? opts->latency : SNDIO_LATENCY_US; ++ ++ /* open the device in non-blocking mode */ ++ self->hdl = sio_open(dev_name, mode, 1); ++ if (self->hdl == NULL) { ++ dolog("failed to open device\n"); ++ return -1; ++ } ++ ++ self->mode = mode; ++ ++ sio_initpar(&req); ++ ++ switch (as->fmt) { ++ case AUDIO_FORMAT_S8: ++ req.bits = 8; ++ req.sig = 1; ++ break; ++ case AUDIO_FORMAT_U8: ++ req.bits = 8; ++ req.sig = 0; ++ break; ++ case AUDIO_FORMAT_S16: ++ req.bits = 16; ++ req.sig = 1; ++ break; ++ case AUDIO_FORMAT_U16: ++ req.bits = 16; ++ req.sig = 0; ++ break; ++ case AUDIO_FORMAT_S32: ++ req.bits = 32; ++ req.sig = 1; ++ break; ++ case AUDIO_FORMAT_U32: ++ req.bits = 32; ++ req.sig = 0; ++ break; ++ default: ++ dolog("unknown audio sample format\n"); ++ return -1; ++ } ++ ++ if (req.bits > 8) { ++ req.le = as->endianness ? 0 : 1; ++ } ++ ++ req.rate = as->freq; ++ if (mode == SIO_PLAY) { ++ req.pchan = as->nchannels; ++ } else { ++ req.rchan = as->nchannels; ++ } ++ ++ /* set on-device buffer size */ ++ req.appbufsz = req.rate * latency / 1000000; ++ ++ if (!sio_setpar(self->hdl, &req)) { ++ dolog("failed set audio params\n"); ++ goto fail; ++ } ++ ++ if (!sio_getpar(self->hdl, &self->par)) { ++ dolog("failed get audio params\n"); ++ goto fail; ++ } ++ ++ nch = (mode == SIO_PLAY) ? self->par.pchan : self->par.rchan; ++ ++ /* ++ * With the default setup, sndio supports any combination of parameters ++ * so these checks are mostly to catch configuration errors. ++ */ ++ if (self->par.bits != req.bits || self->par.bps != req.bits / 8 || ++ self->par.sig != req.sig || (req.bits > 8 && self->par.le != req.le) || ++ self->par.rate != as->freq || nch != as->nchannels) { ++ dolog("unsupported audio params\n"); ++ goto fail; ++ } ++ ++ /* ++ * we use one block as buffer size; this is how ++ * transfers get well aligned ++ */ ++ self->buf_size = self->par.round * self->par.bps * nch; ++ ++ self->buf = g_malloc(self->buf_size); ++ if (self->buf == NULL) { ++ dolog("failed to allocate audio buffer\n"); ++ goto fail; ++ } ++ ++ nfds = sio_nfds(self->hdl); ++ ++ self->pfds = g_malloc_n(nfds, sizeof(struct pollfd)); ++ if (self->pfds == NULL) { ++ dolog("failed to allocate pollfd structures\n"); ++ goto fail; ++ } ++ ++ self->pindexes = g_malloc_n(nfds, sizeof(struct pollindex)); ++ if (self->pindexes == NULL) { ++ dolog("failed to allocate pollindex structures\n"); ++ goto fail; ++ } ++ ++ for (i = 0; i < nfds; i++) { ++ self->pindexes[i].self = self; ++ self->pindexes[i].index = i; ++ } ++ ++ return 0; ++fail: ++ sndio_fini(self); ++ return -1; ++} ++ ++static void sndio_enable(SndioVoice *self, bool enable) ++{ ++ if (enable) { ++ sio_start(self->hdl); ++ self->enabled = true; ++ sndio_poll_wait(self); ++ } else { ++ self->enabled = false; ++ sndio_poll_clear(self); ++ sio_stop(self->hdl); ++ } ++} ++ ++static void sndio_enable_out(HWVoiceOut *hw, bool enable) ++{ ++ SndioVoice *self = (SndioVoice *) hw; ++ ++ sndio_enable(self, enable); ++} ++ ++static void sndio_enable_in(HWVoiceIn *hw, bool enable) ++{ ++ SndioVoice *self = (SndioVoice *) hw; ++ ++ sndio_enable(self, enable); ++} ++ ++static int sndio_init_out(HWVoiceOut *hw, struct audsettings *as, void *opaque) ++{ ++ SndioVoice *self = (SndioVoice *) hw; ++ ++ if (sndio_init(self, as, SIO_PLAY, opaque) == -1) { ++ return -1; ++ } ++ ++ audio_pcm_init_info(&hw->info, as); ++ hw->samples = self->par.round; ++ return 0; ++} ++ ++static int sndio_init_in(HWVoiceIn *hw, struct audsettings *as, void *opaque) ++{ ++ SndioVoice *self = (SndioVoice *) hw; ++ ++ if (sndio_init(self, as, SIO_REC, opaque) == -1) { ++ return -1; ++ } ++ ++ audio_pcm_init_info(&hw->info, as); ++ hw->samples = self->par.round; ++ return 0; ++} ++ ++static void sndio_fini_out(HWVoiceOut *hw) ++{ ++ SndioVoice *self = (SndioVoice *) hw; ++ ++ sndio_fini(self); ++} ++ ++static void sndio_fini_in(HWVoiceIn *hw) ++{ ++ SndioVoice *self = (SndioVoice *) hw; ++ ++ sndio_fini(self); ++} ++ ++static void *sndio_audio_init(Audiodev *dev) ++{ ++ assert(dev->driver == AUDIODEV_DRIVER_SNDIO); ++ return dev; ++} ++ ++static void sndio_audio_fini(void *opaque) ++{ ++} ++ ++static struct audio_pcm_ops sndio_pcm_ops = { ++ .init_out = sndio_init_out, ++ .fini_out = sndio_fini_out, ++ .enable_out = sndio_enable_out, ++ .write = audio_generic_write, ++ .buffer_get_free = sndio_buffer_get_free, ++ .get_buffer_out = sndio_get_buffer_out, ++ .put_buffer_out = sndio_put_buffer_out, ++ .init_in = sndio_init_in, ++ .fini_in = sndio_fini_in, ++ .read = audio_generic_read, ++ .enable_in = sndio_enable_in, ++ .get_buffer_in = sndio_get_buffer_in, ++ .put_buffer_in = sndio_put_buffer_in, ++}; ++ ++static struct audio_driver sndio_audio_driver = { ++ .name = "sndio", ++ .descr = "sndio https://sndio.org", ++ .init = sndio_audio_init, ++ .fini = sndio_audio_fini, ++ .pcm_ops = &sndio_pcm_ops, ++ .can_be_default = 1, ++ .max_voices_out = INT_MAX, ++ .max_voices_in = INT_MAX, ++ .voice_size_out = sizeof(SndioVoice), ++ .voice_size_in = sizeof(SndioVoice) ++}; ++ ++static void register_audio_sndio(void) ++{ ++ audio_driver_register(&sndio_audio_driver); ++} ++ ++type_init(register_audio_sndio); diff --git a/emulators/qemu/patches/patch-configure b/emulators/qemu/patches/patch-configure new file mode 100644 index 0000000..d0e635c --- /dev/null +++ b/emulators/qemu/patches/patch-configure @@ -0,0 +1,97 @@ +Revert.. + +[PATCH] configure: simplify creation of plugin symbol list +37650689473c4cdb5838f90cbc1aefbcd9332fb0 + +Index: configure +--- configure.orig ++++ configure +@@ -77,6 +77,7 @@ TMPC="${TMPDIR1}/${TMPB}.c" + TMPO="${TMPDIR1}/${TMPB}.o" + TMPM="${TMPDIR1}/${TMPB}.m" + TMPE="${TMPDIR1}/${TMPB}.exe" ++TMPTXT="${TMPDIR1}/${TMPB}.txt" + + rm -f config.log + +@@ -1314,7 +1315,6 @@ if test "$static" = "yes" ; then + plugins="no" + fi + fi +-test "$plugins" = "" && plugins=yes + + cat > $TMPC << EOF + +@@ -1459,6 +1459,56 @@ if ! has "$pkg_config_exe"; then + fi + + ########################################## ++# plugin linker support probe ++ ++if test "$plugins" != "no"; then ++ ++ ######################################### ++ # See if --dynamic-list is supported by the linker ++ ++ ld_dynamic_list="no" ++ cat > $TMPTXT < $TMPC < ++void foo(void); ++ ++void foo(void) ++{ ++ printf("foo\n"); ++} ++ ++int main(void) ++{ ++ foo(); ++ return 0; ++} ++EOF ++ ++ if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then ++ ld_dynamic_list="yes" ++ fi ++ ++ if test "$ld_dynamic_list" = "no" ; then ++ if test "$plugins" = "yes"; then ++ error_exit \ ++ "Plugin support requires dynamic linking and specifying a set of symbols " \ ++ "that are exported to plugins. Unfortunately your linker doesn't " \ ++ "support the flag (--dynamic-list) used " \ ++ "for this purpose." ++ else ++ plugins="no" ++ fi ++ else ++ plugins="yes" ++ fi ++fi ++ ++########################################## + # glib support probe + + # When bumping glib_req_ver, please check also whether we should increase +@@ -2390,6 +2440,15 @@ fi + + if test "$plugins" = "yes" ; then + echo "CONFIG_PLUGIN=y" >> $config_host_mak ++ # Copy the export object list to the build dir ++ if test "$ld_dynamic_list" = "yes" ; then ++ echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak ++ ld_symbols=qemu-plugins-ld.symbols ++ cp "$source_path/plugins/qemu-plugins.symbols" $ld_symbols ++ else ++ error_exit \ ++ "If \$plugins=yes, \$ld_dynamic_list should have been set to 'yes'." ++ fi + fi + + if test -n "$gdb_bin"; then diff --git a/emulators/qemu/patches/patch-meson_build b/emulators/qemu/patches/patch-meson_build new file mode 100644 index 0000000..6109662 --- /dev/null +++ b/emulators/qemu/patches/patch-meson_build @@ -0,0 +1,56 @@ +- localstatedir does not belong under prefix +- Remove hardcoding of optimization +- thread-posix: add support for setting threads name on OpenBSD + +Index: meson.build +--- meson.build.orig ++++ meson.build +@@ -75,7 +75,7 @@ have_tools = get_option('tools') \ + .allowed() + have_ga = get_option('guest_agent') \ + .disable_auto_if(not have_system and not have_tools) \ +- .require(targetos in ['sunos', 'linux', 'windows', 'freebsd'], ++ .require(targetos in ['sunos', 'linux', 'windows', 'freebsd', 'openbsd'], + error_message: 'unsupported OS for QEMU guest agent') \ + .allowed() + have_block = have_system or have_tools +@@ -1790,7 +1790,7 @@ config_host_data.set('CONFIG_QEMU_FIRMWAREPATH', qemu_ + config_host_data.set_quoted('CONFIG_QEMU_HELPERDIR', get_option('prefix') / get_option('libexecdir')) + config_host_data.set_quoted('CONFIG_QEMU_ICONDIR', get_option('prefix') / qemu_icondir) + config_host_data.set_quoted('CONFIG_QEMU_LOCALEDIR', get_option('prefix') / get_option('localedir')) +-config_host_data.set_quoted('CONFIG_QEMU_LOCALSTATEDIR', get_option('prefix') / get_option('localstatedir')) ++config_host_data.set_quoted('CONFIG_QEMU_LOCALSTATEDIR', get_option('localstatedir')) + config_host_data.set_quoted('CONFIG_QEMU_MODDIR', get_option('prefix') / qemu_moddir) + config_host_data.set_quoted('CONFIG_SYSCONFDIR', get_option('prefix') / get_option('sysconfdir')) + +@@ -2123,6 +2123,18 @@ config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_WO_TID + pthread_create(&thread, 0, f, 0); + return 0; + }''', dependencies: threads)) ++config_host_data.set('CONFIG_PTHREAD_SET_NAME_NP', cc.links(gnu_source_prefix + ''' ++ #include ++ #include ++ ++ static void *f(void *p) { return NULL; } ++ int main(void) ++ { ++ pthread_t thread; ++ pthread_create(&thread, 0, f, 0); ++ pthread_set_name_np(thread, "QEMU"); ++ return 0; ++ }''', dependencies: threads)) + config_host_data.set('CONFIG_PTHREAD_CONDATTR_SETCLOCK', cc.links(gnu_source_prefix + ''' + #include + #include +@@ -3756,11 +3768,9 @@ if targetos == 'darwin' + summary_info += {'Objective-C compiler': ' '.join(meson.get_compiler('objc').cmd_array())} + endif + summary_info += {'CFLAGS': ' '.join(get_option('c_args') +- + ['-O' + get_option('optimization')] + + (get_option('debug') ? ['-g'] : []))} + if link_language == 'cpp' + summary_info += {'CXXFLAGS': ' '.join(get_option('cpp_args') +- + ['-O' + get_option('optimization')] + + (get_option('debug') ? ['-g'] : []))} + endif + if targetos == 'darwin' diff --git a/emulators/qemu/patches/patch-meson_mesonbuild_compilers_cpp_py b/emulators/qemu/patches/patch-meson_mesonbuild_compilers_cpp_py new file mode 100644 index 0000000..2ce3ee1 --- /dev/null +++ b/emulators/qemu/patches/patch-meson_mesonbuild_compilers_cpp_py @@ -0,0 +1,21 @@ +Index: meson/mesonbuild/compilers/cpp.py +--- meson/mesonbuild/compilers/cpp.py.orig ++++ meson/mesonbuild/compilers/cpp.py +@@ -254,7 +254,7 @@ class ClangCPPCompiler(ClangCompiler, CPPCompiler): + search_dirs: T.List[str] = [] + for d in self.get_compiler_dirs(env, 'libraries'): + search_dirs.append(f'-L{d}') +- return search_dirs + ['-lstdc++'] ++ return search_dirs + ['-lc++'] + + + class AppleClangCPPCompiler(ClangCPPCompiler): +@@ -418,7 +418,7 @@ class GnuCPPCompiler(GnuCompiler, CPPCompiler): + search_dirs: T.List[str] = [] + for d in self.get_compiler_dirs(env, 'libraries'): + search_dirs.append(f'-L{d}') +- return ['-lstdc++'] ++ return ['-lestdc++'] + + + class PGICPPCompiler(PGICompiler, CPPCompiler): diff --git a/emulators/qemu/patches/patch-meson_options_txt b/emulators/qemu/patches/patch-meson_options_txt new file mode 100644 index 0000000..fa5ded5 --- /dev/null +++ b/emulators/qemu/patches/patch-meson_options_txt @@ -0,0 +1,23 @@ +sndio module + +Index: meson_options.txt +--- meson_options.txt.orig ++++ meson_options.txt +@@ -21,7 +21,7 @@ option('tls_priority', type : 'string', value : 'NORMA + option('default_devices', type : 'boolean', value : true, + description: 'Include a default selection of devices in emulators') + option('audio_drv_list', type: 'array', value: ['default'], +- choices: ['alsa', 'coreaudio', 'default', 'dsound', 'jack', 'oss', 'pa', 'sdl'], ++ choices: ['alsa', 'coreaudio', 'default', 'dsound', 'jack', 'oss', 'pa', 'sdl', 'sndio'], + description: 'Set audio driver list') + option('block_drv_rw_whitelist', type : 'string', value : '', + description: 'set block driver read-write whitelist (by default affects only QEMU, not tools like qemu-img)') +@@ -240,6 +240,8 @@ option('oss', type: 'feature', value: 'auto', + description: 'OSS sound support') + option('pa', type: 'feature', value: 'auto', + description: 'PulseAudio sound support') ++option('sndio', type: 'feature', value: 'auto', ++ description: 'sndio sound support') + + option('vhost_kernel', type: 'feature', value: 'auto', + description: 'vhost kernel backend support') diff --git a/emulators/qemu/patches/patch-plugins_meson_build b/emulators/qemu/patches/patch-plugins_meson_build new file mode 100644 index 0000000..67d53f3 --- /dev/null +++ b/emulators/qemu/patches/patch-plugins_meson_build @@ -0,0 +1,26 @@ +Revert.. + +[PATCH] configure: simplify creation of plugin symbol list +37650689473c4cdb5838f90cbc1aefbcd9332fb0 + +Index: plugins/meson.build +--- plugins/meson.build.orig ++++ plugins/meson.build +@@ -1,15 +1,8 @@ + plugin_ldflags = [] + # Modules need more symbols than just those in plugins/qemu-plugins.symbols + if not enable_modules +- if targetos == 'darwin' +- configure_file( +- input: files('qemu-plugins.symbols'), +- output: 'qemu-plugins-ld64.symbols', +- capture: true, +- command: ['sed', '-ne', 's/^[[:space:]]*\\(qemu_.*\\);/_\\1/p', '@INPUT@']) +- plugin_ldflags = ['-Wl,-exported_symbols_list,plugins/qemu-plugins-ld64.symbols'] +- else +- plugin_ldflags = ['-Xlinker', '--dynamic-list=' + (meson.project_source_root() / 'plugins/qemu-plugins.symbols')] ++ if 'CONFIG_HAS_LD_DYNAMIC_LIST' in config_host ++ plugin_ldflags = ['-Wl,--dynamic-list=qemu-plugins-ld.symbols'] + endif + endif + diff --git a/emulators/qemu/patches/patch-qapi_audio_json b/emulators/qemu/patches/patch-qapi_audio_json new file mode 100644 index 0000000..cccb078 --- /dev/null +++ b/emulators/qemu/patches/patch-qapi_audio_json @@ -0,0 +1,50 @@ +sndio module + +Index: qapi/audio.json +--- qapi/audio.json.orig ++++ qapi/audio.json +@@ -107,6 +107,28 @@ + '*threshold': 'uint32' } } + + ## ++# @AudiodevSndioOptions: ++# ++# Options of the sndio audio backend. ++# ++# @in: options of the capture stream ++# ++# @out: options of the playback stream ++# ++# @dev: the name of the sndio device to use (default 'default') ++# ++# @latency: play buffer size (in microseconds) ++# ++# Since: 7.2 ++## ++{ 'struct': 'AudiodevSndioOptions', ++ 'data': { ++ '*in': 'AudiodevPerDirectionOptions', ++ '*out': 'AudiodevPerDirectionOptions', ++ '*dev': 'str', ++ '*latency': 'uint32'} } ++ ++## + # @AudiodevCoreaudioPerDirectionOptions: + # + # Options of the Core Audio backend that are used for both playback and +@@ -387,7 +409,7 @@ + ## + { 'enum': 'AudiodevDriver', + 'data': [ 'none', 'alsa', 'coreaudio', 'dbus', 'dsound', 'jack', 'oss', 'pa', +- 'sdl', 'spice', 'wav' ] } ++ 'sdl', 'sndio', 'spice', 'wav' ] } + + ## + # @Audiodev: +@@ -418,5 +440,6 @@ + 'oss': 'AudiodevOssOptions', + 'pa': 'AudiodevPaOptions', + 'sdl': 'AudiodevSdlOptions', ++ 'sndio': 'AudiodevSndioOptions', + 'spice': 'AudiodevGenericOptions', + 'wav': 'AudiodevWavOptions' } } diff --git a/emulators/qemu/patches/patch-qemu-options_hx b/emulators/qemu/patches/patch-qemu-options_hx new file mode 100644 index 0000000..f357ad9 --- /dev/null +++ b/emulators/qemu/patches/patch-qemu-options_hx @@ -0,0 +1,35 @@ +sndio module + +Index: qemu-options.hx +--- qemu-options.hx.orig ++++ qemu-options.hx +@@ -767,6 +767,9 @@ DEF("audiodev", HAS_ARG, QEMU_OPTION_audiodev, + "-audiodev sdl,id=id[,prop[=value][,...]]\n" + " in|out.buffer-count= number of buffers\n" + #endif ++#ifdef CONFIG_AUDIO_SNDIO ++ "-audiodev sndio,id=id[,prop[=value][,...]]\n" ++#endif + #ifdef CONFIG_SPICE + "-audiodev spice,id=id[,prop[=value][,...]]\n" + #endif +@@ -932,6 +935,19 @@ SRST + + ``in|out.buffer-count=count`` + Sets the count of the buffers. ++ ++``-audiodev sndio,id=id[,prop[=value][,...]]`` ++ Creates a backend using SNDIO. This backend is available on ++ OpenBSD and most other Unix-like systems. ++ ++ Sndio specific options are: ++ ++ ``in|out.dev=device`` ++ Specify the sndio device to use for input and/or output. Default ++ is ``default``. ++ ++ ``in|out.latency=usecs`` ++ Sets the desired period length in microseconds. + + ``-audiodev spice,id=id[,prop[=value][,...]]`` + Creates a backend that sends audio through SPICE. This backend diff --git a/emulators/qemu/patches/patch-qga_commands-bsd_c b/emulators/qemu/patches/patch-qga_commands-bsd_c new file mode 100644 index 0000000..81b330d --- /dev/null +++ b/emulators/qemu/patches/patch-qga_commands-bsd_c @@ -0,0 +1,16 @@ +Index: qga/commands-bsd.c +--- qga/commands-bsd.c.orig ++++ qga/commands-bsd.c +@@ -21,7 +21,12 @@ + #include + #include + #include ++#ifdef __OpenBSD__ ++#include ++#include ++#else + #include ++#endif + #include + + #if defined(CONFIG_FSFREEZE) || defined(CONFIG_FSTRIM) diff --git a/emulators/qemu/patches/patch-qga_commands-posix_c b/emulators/qemu/patches/patch-qga_commands-posix_c new file mode 100644 index 0000000..d5d0c16 --- /dev/null +++ b/emulators/qemu/patches/patch-qga_commands-posix_c @@ -0,0 +1,576 @@ +Adapted from https://github.com/aborche/qemu-guest-agent + +Adds support for +"guest-get-fsinfo" +"guest-get-vcpus" +"guest-network-get-interfaces" +and guest shutdown from host. + +Setting user password is not supported on OpenBSD. + +Index: qga/commands-posix.c +--- qga/commands-posix.c.orig ++++ qga/commands-posix.c +@@ -45,13 +45,23 @@ + #include + #include + #include ++#ifdef __OpenBSD__ ++#include ++#include ++#else + #include ++#endif + #include + #ifdef CONFIG_SOLARIS + #include + #endif + #endif + ++#ifdef __OpenBSD__ ++#include ++#include ++#endif ++ + static void ga_wait_child(pid_t pid, int *status, Error **errp) + { + pid_t rpid; +@@ -2232,12 +2242,118 @@ out: + close(datafd[1]); + } + } +-#else /* __linux__ || __FreeBSD__ */ ++#elif defined(__OpenBSD__) /* __linux__ || __FreeBSD__ */ + void qmp_guest_set_user_password(const char *username, + const char *password, + bool crypted, + Error **errp) + { ++ Error *local_err = NULL; ++ char *pw_path = NULL; ++ pid_t pid; ++ int status; ++ int datafd[2] = { -1, -1 }; ++ char *rawpasswddata = NULL; ++ size_t rawpasswdlen; ++ char *chpasswddata = NULL; ++ size_t chpasswdlen; ++ ++ rawpasswddata = (char *)qbase64_decode(password, -1, &rawpasswdlen, errp); ++ if (!rawpasswddata) { ++ return; ++ } ++ ++ rawpasswddata = g_renew(char, rawpasswddata, rawpasswdlen + 1); ++ rawpasswddata[rawpasswdlen] = '\0'; ++ ++ if (strchr(rawpasswddata, '\n')) { ++ error_setg(errp, "forbidden characters in raw password"); ++ goto out; ++ } ++ ++ if (strchr(username, '\n') || ++ strchr(username, ':')) { ++ error_setg(errp, "forbidden characters in username"); ++ goto out; ++ } ++ ++ chpasswddata = g_strdup_printf("%s", rawpasswddata); ++ chpasswdlen = strlen(chpasswddata); ++ ++ pw_path = g_find_program_in_path("pw"); ++ ++ if (!pw_path) { ++ error_setg(errp, "cannot find 'pw' program in PATH"); ++ goto out; ++ } ++ ++ if (pipe(datafd) < 0) { ++ error_setg(errp, "cannot create pipe FDs"); ++ goto out; ++ } ++ ++ pid = fork(); ++ if (pid == 0) { ++ close(datafd[1]); ++ /* child */ ++ setsid(); ++ dup2(datafd[0], 0); ++ reopen_fd_to_null(1); ++ reopen_fd_to_null(2); ++ ++ if (crypted) { ++ execl(pw_path, "pw", "usermod", username, "-H", "0", (char*)NULL); ++ } else { ++ execl(pw_path, "pw", "usermod", username, "-h", "0", (char*)NULL); ++ } ++ _exit(EXIT_FAILURE); ++ } else if (pid < 0) { ++ error_setg_errno(errp, errno, "failed to create child process"); ++ goto out; ++ } ++ close(datafd[0]); ++ datafd[0] = -1; ++ ++ if (qemu_write_full(datafd[1], chpasswddata, chpasswdlen) != chpasswdlen) { ++ error_setg_errno(errp, errno, "cannot write new account password"); ++ goto out; ++ } ++ close(datafd[1]); ++ datafd[1] = -1; ++ ++ ga_wait_child(pid, &status, &local_err); ++ if (local_err) { ++ error_propagate(errp, local_err); ++ goto out; ++ } ++ ++ if (!WIFEXITED(status)) { ++ error_setg(errp, "child process has terminated abnormally"); ++ goto out; ++ } ++ ++ if (WEXITSTATUS(status)) { ++ error_setg(errp, "child process has failed to set user password"); ++ goto out; ++ } ++ ++out: ++ g_free(chpasswddata); ++ g_free(rawpasswddata); ++ g_free(pw_path); ++ if (datafd[0] != -1) { ++ close(datafd[0]); ++ } ++ if (datafd[1] != -1) { ++ close(datafd[1]); ++ } ++} ++#else /* __OpenBSD__ */ ++void qmp_guest_set_user_password(const char *username, ++ const char *password, ++ bool crypted, ++ Error **errp) ++{ + error_setg(errp, QERR_UNSUPPORTED); + } + #endif /* __linux__ || __FreeBSD__ */ +@@ -2750,7 +2866,7 @@ GuestCpuStatsList *qmp_guest_get_cpustats(Error **errp + return head; + } + +-#else /* defined(__linux__) */ ++#elif defined(CONFIG_BSD) + + void qmp_guest_suspend_disk(Error **errp) + { +@@ -2769,10 +2885,103 @@ void qmp_guest_suspend_hybrid(Error **errp) + + GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp) + { ++ int64_t current; ++ GuestLogicalProcessorList *head, **link; ++ long sc_max; ++ Error *local_err = NULL; ++ int Query[2]; ++ int NumCpu = 0; ++ size_t Length = sizeof(NumCpu); ++ ++ Query[0] = CTL_HW; ++#ifdef HW_NCPUONLINE ++ Query[1] = HW_NCPUONLINE; ++#else ++ Query[1] = HW_NCPU; ++#endif ++ ++ current = 0; ++ head = NULL; ++ link = &head; ++ if (sysctl(Query, 2, &NumCpu, &Length, NULL, 0) == -1) { ++ error_setg(errp, "sysctl get CTL_HW.HW_NCPU failed"); ++ } ++ sc_max = NumCpu; ++ ++ while (local_err == NULL && current < sc_max) { ++ GuestLogicalProcessor *vcpu; ++ GuestLogicalProcessorList *entry; ++ int64_t id = current++; ++ vcpu = g_malloc0(sizeof *vcpu); ++ vcpu->logical_id = id; ++ vcpu->has_can_offline = false; /* lolspeak ftw */ ++ vcpu->online = true; ++ vcpu->can_offline = false; ++ entry = g_malloc0(sizeof *entry); ++ entry->value = vcpu; ++ *link = entry; ++ link = &entry->next; ++ } ++ ++ if (local_err == NULL) { ++ /* there's no guest with zero VCPUs */ ++ g_assert(head != NULL); ++ return head; ++ } ++ ++ qapi_free_GuestLogicalProcessorList(head); ++ error_propagate(errp, local_err); ++ return NULL; ++} ++ ++int64_t qmp_guest_set_vcpus(GuestLogicalProcessorList *vcpus, Error **errp) ++{ + error_setg(errp, QERR_UNSUPPORTED); ++ return -1; ++} ++ ++GuestMemoryBlockList *qmp_guest_get_memory_blocks(Error **errp) ++{ ++ error_setg(errp, QERR_UNSUPPORTED); + return NULL; + } + ++GuestMemoryBlockResponseList * ++qmp_guest_set_memory_blocks(GuestMemoryBlockList *mem_blks, Error **errp) ++{ ++ error_setg(errp, QERR_UNSUPPORTED); ++ return NULL; ++} ++ ++GuestMemoryBlockInfo *qmp_guest_get_memory_block_info(Error **errp) ++{ ++ error_setg(errp, QERR_UNSUPPORTED); ++ return NULL; ++} ++ ++#else /* defined(CONFIG_BSD) */ ++ ++void qmp_guest_suspend_disk(Error **errp) ++{ ++ error_setg(errp, QERR_UNSUPPORTED); ++} ++ ++void qmp_guest_suspend_ram(Error **errp) ++{ ++ error_setg(errp, QERR_UNSUPPORTED); ++} ++ ++void qmp_guest_suspend_hybrid(Error **errp) ++{ ++ error_setg(errp, QERR_UNSUPPORTED); ++} ++ ++GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp) ++{ ++ error_setg(errp, QERR_UNSUPPORTED); ++ return NULL; ++} ++ + int64_t qmp_guest_set_vcpus(GuestLogicalProcessorList *vcpus, Error **errp) + { + error_setg(errp, QERR_UNSUPPORTED); +@@ -2881,7 +3090,7 @@ static int guest_get_network_stats(const char *name, + return -1; + } + +-#ifndef __FreeBSD__ ++#ifndef CONFIG_BSD + /* + * Fill "buf" with MAC address by ifaddrs. Pointer buf must point to a + * buffer with ETHER_ADDR_LEN length at least. +@@ -2930,7 +3139,7 @@ bool guest_get_hw_addr(struct ifaddrs *ifa, unsigned c + close(sock); + return true; + } +-#endif /* __FreeBSD__ */ ++#endif /* CONFIG_BSD */ + + /* + * Build information about guest interfaces +@@ -3070,11 +3279,245 @@ GuestNetworkInterfaceList *qmp_guest_network_get_inter + + #if !defined(CONFIG_FSFREEZE) + ++#ifdef CONFIG_BSD ++typedef struct FsMount { ++ char *dirname; ++ char *devtype; ++ char *size; ++ char *used; ++ char *free; ++ char *load; ++ char *mntpoint; ++ unsigned int devmajor, devminor; ++ QTAILQ_ENTRY(FsMount) next; ++} FsMount; ++ ++typedef QTAILQ_HEAD(FsMountList, FsMount) FsMountList; ++ ++static void free_fs_mount_list(FsMountList *mounts) ++{ ++ FsMount *mount, *temp; ++ ++ if (!mounts) { ++ return; ++ } ++ ++ QTAILQ_FOREACH_SAFE(mount, mounts, next, temp) { ++ QTAILQ_REMOVE(mounts, mount, next); ++ g_free(mount->dirname); ++ g_free(mount->devtype); ++ g_free(mount->size); ++ g_free(mount->used); ++ g_free(mount->free); ++ g_free(mount->load); ++ g_free(mount->mntpoint); ++ g_free(mount); ++ } ++} ++ ++static void build_fs_mount_list(FsMountList *mounts, Error **errp) ++{ ++ FsMount *mount; ++#ifdef __OpenBSD__ ++ char const *dfcmd = "/bin/df"; ++#else // defined(__OpenBSD__) ++ char const *dfcmd = "/bin/df -hT"; ++#endif // defined(__OpenBSD__) ++ ++ FILE *fp; ++ char *line = NULL; ++ size_t n; ++ int ret; ++ char dev_name[128], size[12], used[12], free[12], load[10], mounted[128]; ++#ifndef __OpenBSD__ ++ char fstype[12] = ""; ++#endif // !defined(__OpenBSD__) ++ ++ if ((fp = popen(dfcmd, "r")) == NULL) { ++ g_debug("Cannot open '%s'!!\n", dfcmd); ++ error_setg_errno(errp, errno, ++ "failed to create child process for command: %s", ++ dfcmd); ++ return; ++ } ++ ++ while (getline(&line, &n, fp) != -1) { ++ //g_debug("line '%s'", line); ++#ifdef __OpenBSD__ ++ ret = sscanf(line, "%127s%11s%11s%11s%9s%127s", ++ dev_name, size, used, free, load, mounted); ++#else // defined(__OpenBSD__) ++ ret = sscanf(line, "%127s%11s%11s%11s%11s%9s%127s", ++ dev_name, fstype, size, used, free, load, mounted); ++ //g_debug("ret %d, dev_name '%s', fstype '%s', size '%s', used '%s', free '%s', load '%s', mounted '%s'", ++ // ret, dev_name, fstype, size, used, free, load, mounted); ++#endif // defined(__OpenBSD__) ++ if (g_str_equal(dev_name, "Filesystem") ++#ifndef __OpenBSD__ ++ ||g_str_equal(fstype,"devfs") ++ ||g_str_equal(fstype,"procfs") ++ ||g_str_equal(fstype,"fdescfs") ++#endif // !defined(__OpenBSD__) ++ ) { ++ continue; ++ } ++ ++#ifdef __OpenBSD__ ++ if (ret < 6) { ++#else // defined(__OpenBSD__) ++ if (ret < 7) { ++#endif // defined(__OpenBSD__) ++ continue; ++ } ++ ++ mount = g_new0(FsMount, 1); ++ mount->dirname = g_strdup(dev_name); ++#ifndef __OpenBSD__ ++ mount->devtype = g_strdup(fstype); ++#endif // defined(__OpenBSD__) ++ mount->free = g_strdup(free); ++ mount->load = g_strdup(load); ++ mount->size = g_strdup(size); ++ mount->used = g_strdup(used); ++ mount->mntpoint = g_strdup(mounted); ++ mount->devmajor = 0; ++ mount->devminor = 0; ++ ++ QTAILQ_INSERT_TAIL(mounts, mount, next); ++ } ++ g_free(line); ++ ++ fclose(fp); ++} ++ ++#ifdef __OpenBSD__ ++ ++static void add_type_fs_mount_list(FsMountList *mounts, Error **errp) ++{ ++ FILE *fp; ++ char const *mountcmd = "/sbin/mount"; ++ char *line = NULL; ++ size_t n; ++ int ret; ++ char mnt_fsname[128], mnt_dir[128], mnt_type[32], mnt_opts[128]; ++ struct FsMount *mount; ++ ++ // get mounts from mount command ++ if ((fp = popen(mountcmd, "r")) == NULL) { ++ g_debug("Cannot open '%s'!!\n", mountcmd); ++ error_setg_errno(errp, errno, "failed to create child process for command: %s", mountcmd); ++ return; ++ } ++ ++ // loop through mounts from mount command ++ while (getline(&line, &n, fp) != -1) { ++ //g_debug("line '%s'", line); ++ ++ ret = sscanf(line, "%127s on %127s type %31s (%127s)", ++ mnt_fsname, mnt_dir, mnt_type, mnt_opts); ++ //g_debug("ret %d, fsname '%s', dir '%s', type '%s', opts '%s'", ++ // ret, mnt_fsname, mnt_dir, mnt_type, mnt_opts); ++ ++ if (4 != ret || ++ '/' != mnt_fsname[0] || ++ '/' != mnt_dir[0] || ++ g_str_equal("smbfs", mnt_type) || ++ g_str_equal("cifs", mnt_type)) { ++ continue; ++ } ++ ++ // find mount in supplied mounts list and update device type ++ QTAILQ_FOREACH(mount, mounts, next) { ++ if (NULL == mount->devtype && g_str_equal(mount->dirname, mnt_fsname)) { ++ mount->devtype = g_strdup(mnt_type); ++ break; ++ } ++ } ++ } ++ g_free(line); ++ ++ fclose(fp); ++} ++ ++#endif // defined(__OpenBSD__) ++ ++/* Return a list of the disk device(s)' info which @mount lies on */ ++static GuestFilesystemInfo *build_guest_fsinfo(struct FsMount *mount, ++ Error **errp) ++{ ++ GuestFilesystemInfo *fs = g_malloc0(sizeof(*fs)); ++ struct statvfs buf; ++ unsigned long used, nonroot_total, fr_size; ++ ++ fs->name = g_strdup(mount->dirname); ++ fs->mountpoint = g_strdup(mount->mntpoint); ++ fs->type = g_strdup(mount->devtype); ++ ++ if (statvfs(fs->mountpoint, &buf) == 0) { ++ fr_size = buf.f_frsize; ++ used = buf.f_blocks - buf.f_bfree; ++ nonroot_total = used + buf.f_bavail; ++ fs->used_bytes = used * fr_size; ++ fs->total_bytes = nonroot_total * fr_size; ++ ++ fs->has_total_bytes = true; ++ fs->has_used_bytes = true; ++ } ++ ++ //g_free(devpath); ++ ++ return fs; ++} ++ + GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp) + { ++ FsMountList mounts; ++ struct FsMount *mount; ++ GuestFilesystemInfoList *new, *ret = NULL; ++ Error *local_err = NULL; ++ ++ QTAILQ_INIT(&mounts); ++ ++ g_debug("Entering to guest_get_fsinfo"); ++ build_fs_mount_list(&mounts, &local_err); ++ if (local_err) { ++ error_propagate(errp, local_err); ++ return NULL; ++ } ++ ++#ifdef __OpenBSD__ ++ add_type_fs_mount_list(&mounts, &local_err); ++ if (local_err) { ++ error_propagate(errp, local_err); ++ return NULL; ++ } ++#endif // defined(__OpenBSD__) ++ ++ QTAILQ_FOREACH(mount, &mounts, next) { ++ //g_debug("Building guest fsinfo for '%s'", mount->dirname); ++ //g_debug("Devtype '%s'", mount->devtype); ++ new = g_malloc0(sizeof(*ret)); ++ new->value = build_guest_fsinfo(mount, &local_err); ++ new->next = ret; ++ ret = new; ++ if (local_err) { ++ error_propagate(errp, local_err); ++ qapi_free_GuestFilesystemInfoList(ret); ++ ret = NULL; ++ break; ++ } ++ } ++ ++ free_fs_mount_list(&mounts); ++ return ret; ++} ++#else ++GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp) ++{ + error_setg(errp, QERR_UNSUPPORTED); + return NULL; + } ++#endif /* CONFIG_BSD */ + + GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **errp) + { +@@ -3140,12 +3583,21 @@ GList *ga_command_init_blockedrpcs(GList *blockedrpcs) + { + #if !defined(__linux__) + { ++#ifdef CONFIG_BSD + const char *list[] = { + "guest-suspend-disk", "guest-suspend-ram", ++ "guest-suspend-hybrid", "guest-set-vcpus", ++ "guest-get-memory-blocks", "guest-set-memory-blocks", ++ "guest-get-memory-block-size", "guest-get-memory-block-info", ++ NULL}; ++#else ++ const char *list[] = { ++ "guest-suspend-disk", "guest-suspend-ram", + "guest-suspend-hybrid", "guest-get-vcpus", "guest-set-vcpus", + "guest-get-memory-blocks", "guest-set-memory-blocks", + "guest-get-memory-block-size", "guest-get-memory-block-info", + NULL}; ++#endif /* CONFIG_BSD */ + char **p = (char **)list; + + while (*p) { +@@ -3161,11 +3613,19 @@ GList *ga_command_init_blockedrpcs(GList *blockedrpcs) + + #if !defined(CONFIG_FSFREEZE) + { ++#ifdef CONFIG_BSD + const char *list[] = { ++ "guest-fsfreeze-status", ++ "guest-fsfreeze-freeze", "guest-fsfreeze-freeze-list", ++ "guest-fsfreeze-thaw", ++ "guest-get-disks", NULL}; ++#else ++ const char *list[] = { + "guest-get-fsinfo", "guest-fsfreeze-status", + "guest-fsfreeze-freeze", "guest-fsfreeze-freeze-list", + "guest-fsfreeze-thaw", "guest-get-fsinfo", + "guest-get-disks", NULL}; ++#endif /* CONFIG_BSD */ + char **p = (char **)list; + + while (*p) { diff --git a/emulators/qemu/patches/patch-qga_main_c b/emulators/qemu/patches/patch-qga_main_c new file mode 100644 index 0000000..4dc551d --- /dev/null +++ b/emulators/qemu/patches/patch-qga_main_c @@ -0,0 +1,37 @@ +Adapted from https://github.com/aborche/qemu-guest-agent + +Index: qga/main.c +--- qga/main.c.orig ++++ qga/main.c +@@ -40,12 +40,16 @@ + #include "commands-common.h" + + #ifndef _WIN32 +-#ifdef __FreeBSD__ ++#ifdef CONFIG_BSD + #define QGA_VIRTIO_PATH_DEFAULT "/dev/vtcon/org.qemu.guest_agent.0" +-#else /* __FreeBSD__ */ ++#else /* CONFIG_BSD */ + #define QGA_VIRTIO_PATH_DEFAULT "/dev/virtio-ports/org.qemu.guest_agent.0" +-#endif /* __FreeBSD__ */ ++#endif /* CONFIG_BSD */ ++#ifdef __OpenBSD__ ++#define QGA_SERIAL_PATH_DEFAULT "/dev/cua01" ++#else + #define QGA_SERIAL_PATH_DEFAULT "/dev/ttyS0" ++#endif + #define QGA_STATE_RELATIVE_DIR "run" + #else + #define QGA_VIRTIO_PATH_DEFAULT "\\\\.\\Global\\org.qemu.guest_agent.0" +@@ -1483,7 +1487,11 @@ int main(int argc, char **argv) + } + + if (config->method == NULL) { ++#ifdef CONFIG_BSD ++ config->method = g_strdup("isa-serial"); ++#else + config->method = g_strdup("virtio-serial"); ++#endif + } + + socket_activation = check_socket_activation(); diff --git a/emulators/qemu/patches/patch-util_cacheflush_c b/emulators/qemu/patches/patch-util_cacheflush_c new file mode 100644 index 0000000..2d1d5d8 --- /dev/null +++ b/emulators/qemu/patches/patch-util_cacheflush_c @@ -0,0 +1,19 @@ +Set OpenBSD/powerpc cache sizes. + +Index: util/cacheflush.c +--- util/cacheflush.c.orig ++++ util/cacheflush.c +@@ -163,6 +163,13 @@ static void arch_cache_info(int *isize, int *dsize) + have_coherent_icache = qemu_getauxval(AT_HWCAP) & PPC_FEATURE_ICACHE_SNOOP; + } + ++#elif defined(_ARCH_PPC) && defined (__OpenBSD__) ++static void arch_cache_info(int *isize, int *dsize) ++{ ++ *isize = 32; ++ *dsize = 32; ++} ++ + #else + static void arch_cache_info(int *isize, int *dsize) { } + #endif /* arch_cache_info */ diff --git a/emulators/qemu/patches/patch-util_qemu-thread-posix_c b/emulators/qemu/patches/patch-util_qemu-thread-posix_c new file mode 100644 index 0000000..112abb5 --- /dev/null +++ b/emulators/qemu/patches/patch-util_qemu-thread-posix_c @@ -0,0 +1,35 @@ +thread-posix: add support for setting threads name on OpenBSD + +Index: util/qemu-thread-posix.c +--- util/qemu-thread-posix.c.orig ++++ util/qemu-thread-posix.c +@@ -18,6 +18,10 @@ + #include "qemu/tsan.h" + #include "qemu/bitmap.h" + ++#ifdef CONFIG_PTHREAD_SET_NAME_NP ++#include ++#endif ++ + static bool name_threads; + + void qemu_thread_naming(bool enable) +@@ -25,7 +29,8 @@ void qemu_thread_naming(bool enable) + name_threads = enable; + + #if !defined CONFIG_PTHREAD_SETNAME_NP_W_TID && \ +- !defined CONFIG_PTHREAD_SETNAME_NP_WO_TID ++ !defined CONFIG_PTHREAD_SETNAME_NP_WO_TID && \ ++ !defined CONFIG_PTHREAD_SET_NAME_NP + /* This is a debugging option, not fatal */ + if (enable) { + fprintf(stderr, "qemu: thread naming not supported on this host\n"); +@@ -480,6 +485,8 @@ static void *qemu_thread_start(void *args) + pthread_setname_np(pthread_self(), qemu_thread_args->name); + # elif defined(CONFIG_PTHREAD_SETNAME_NP_WO_TID) + pthread_setname_np(qemu_thread_args->name); ++# elif defined(CONFIG_PTHREAD_SET_NAME_NP) ++ pthread_set_name_np(pthread_self(), qemu_thread_args->name); + # endif + } + QEMU_TSAN_ANNOTATE_THREAD_NAME(qemu_thread_args->name); diff --git a/emulators/qemu/pkg/CVS/Entries b/emulators/qemu/pkg/CVS/Entries new file mode 100644 index 0000000..d41c45d --- /dev/null +++ b/emulators/qemu/pkg/CVS/Entries @@ -0,0 +1,9 @@ +/DESCR-ga/1.1/Sun Feb 28 18:38:41 2021//TOPENBSD_7_3 +/DESCR-main/1.1/Sun Feb 28 18:38:41 2021//TOPENBSD_7_3 +/PFRAG.plugins-main/1.2/Fri Mar 11 18:59:40 2022//TOPENBSD_7_3 +/PLIST-ga/1.5/Sat Apr 23 10:30:24 2022//TOPENBSD_7_3 +/PLIST-main/1.13/Tue Feb 21 23:06:55 2023//TOPENBSD_7_3 +/README-ga/1.1/Tue Mar 29 10:04:28 2022//TOPENBSD_7_3 +/README-main/1.3/Fri Mar 11 18:59:40 2022//TOPENBSD_7_3 +/qemu_ga.rc/1.1/Tue Mar 29 10:04:28 2022//TOPENBSD_7_3 +D diff --git a/emulators/qemu/pkg/CVS/Repository b/emulators/qemu/pkg/CVS/Repository new file mode 100644 index 0000000..64f210f --- /dev/null +++ b/emulators/qemu/pkg/CVS/Repository @@ -0,0 +1 @@ +ports/emulators/qemu/pkg diff --git a/emulators/qemu/pkg/CVS/Root b/emulators/qemu/pkg/CVS/Root new file mode 100644 index 0000000..3811072 --- /dev/null +++ b/emulators/qemu/pkg/CVS/Root @@ -0,0 +1 @@ +/cvs diff --git a/emulators/qemu/pkg/CVS/Tag b/emulators/qemu/pkg/CVS/Tag new file mode 100644 index 0000000..b1c2a73 --- /dev/null +++ b/emulators/qemu/pkg/CVS/Tag @@ -0,0 +1 @@ +TOPENBSD_7_3 diff --git a/emulators/qemu/pkg/DESCR-ga b/emulators/qemu/pkg/DESCR-ga new file mode 100644 index 0000000..0402160 --- /dev/null +++ b/emulators/qemu/pkg/DESCR-ga @@ -0,0 +1,3 @@ +The QEMU guest agent provides a daemon to run inside QEMU guests. It +communicates with the host system and allows to perform various tasks in +the guest from the host system. diff --git a/emulators/qemu/pkg/DESCR-main b/emulators/qemu/pkg/DESCR-main new file mode 100644 index 0000000..73ae431 --- /dev/null +++ b/emulators/qemu/pkg/DESCR-main @@ -0,0 +1,4 @@ +QEMU is an open source machine emulator. It can run OSes and programs +made for one machine (e.g. an ARM board) on a different machine (e.g. +your own PC). By using dynamic translation, it achieves very good +performance. diff --git a/emulators/qemu/pkg/PFRAG.plugins-main b/emulators/qemu/pkg/PFRAG.plugins-main new file mode 100644 index 0000000..59fe1cc --- /dev/null +++ b/emulators/qemu/pkg/PFRAG.plugins-main @@ -0,0 +1 @@ +include/qemu-plugin.h diff --git a/emulators/qemu/pkg/PLIST-ga b/emulators/qemu/pkg/PLIST-ga new file mode 100644 index 0000000..536bb06 --- /dev/null +++ b/emulators/qemu/pkg/PLIST-ga @@ -0,0 +1,14 @@ +@conflict qemu-<=5.1.0p2 +@rcscript ${RCDIR}/qemu_ga +@bin bin/qemu-ga +@man man/man7/qemu-ga-ref.7 +@man man/man8/qemu-ga.8 +share/doc/pkg-readmes/${PKGSTEM} +share/doc/qemu/ +share/doc/qemu/interop/ +share/doc/qemu/interop/qemu-ga-ref.html +share/doc/qemu/interop/qemu-ga.html +share/examples/qemu/ +@sample ${SYSCONFDIR}/qemu/ +share/examples/qemu/qemu-ga.conf +@sample ${SYSCONFDIR}/qemu/qemu-ga.conf diff --git a/emulators/qemu/pkg/PLIST-main b/emulators/qemu/pkg/PLIST-main new file mode 100644 index 0000000..6a3f4d0 --- /dev/null +++ b/emulators/qemu/pkg/PLIST-main @@ -0,0 +1,465 @@ +@pkgpath emulators/qemu +@bin bin/elf2dmp +@bin bin/qemu-edid +@bin bin/qemu-img +@bin bin/qemu-io +@bin bin/qemu-keymap +@bin bin/qemu-nbd +@bin bin/qemu-storage-daemon +@bin bin/qemu-system-aarch64 +@bin bin/qemu-system-alpha +@bin bin/qemu-system-arm +@bin bin/qemu-system-avr +@bin bin/qemu-system-cris +@bin bin/qemu-system-hppa +@bin bin/qemu-system-i386 +@bin bin/qemu-system-loongarch64 +@bin bin/qemu-system-m68k +@bin bin/qemu-system-microblaze +@bin bin/qemu-system-microblazeel +@bin bin/qemu-system-mips +@bin bin/qemu-system-mips64 +@bin bin/qemu-system-mips64el +@bin bin/qemu-system-mipsel +@bin bin/qemu-system-nios2 +@bin bin/qemu-system-or1k +@bin bin/qemu-system-ppc +@bin bin/qemu-system-ppc64 +@bin bin/qemu-system-riscv32 +@bin bin/qemu-system-riscv64 +@bin bin/qemu-system-rx +@bin bin/qemu-system-s390x +@bin bin/qemu-system-sh4 +@bin bin/qemu-system-sh4eb +@bin bin/qemu-system-sparc +@bin bin/qemu-system-sparc64 +@bin bin/qemu-system-tricore +@bin bin/qemu-system-x86_64 +@bin bin/qemu-system-xtensa +@bin bin/qemu-system-xtensaeb +%%plugins%% +@man man/man1/qemu-img.1 +@man man/man1/qemu-storage-daemon.1 +@man man/man1/qemu.1 +@man man/man7/qemu-block-drivers.7 +@man man/man7/qemu-cpu-models.7 +@man man/man7/qemu-qmp-ref.7 +@man man/man7/qemu-storage-daemon-qmp-ref.7 +@man man/man8/qemu-nbd.8 +@man man/man8/qemu-pr-helper.8 +share/applications/qemu.desktop +share/doc/pkg-readmes/${PKGSTEM} +share/doc/qemu/.buildinfo +share/doc/qemu/_static/ +share/doc/qemu/_static/basic.css +share/doc/qemu/_static/css/ +share/doc/qemu/_static/css/badge_only.css +share/doc/qemu/_static/css/fonts/ +share/doc/qemu/_static/css/fonts/Roboto-Slab-Bold.woff +share/doc/qemu/_static/css/fonts/Roboto-Slab-Bold.woff2 +share/doc/qemu/_static/css/fonts/Roboto-Slab-Regular.woff +share/doc/qemu/_static/css/fonts/Roboto-Slab-Regular.woff2 +share/doc/qemu/_static/css/fonts/fontawesome-webfont.eot +share/doc/qemu/_static/css/fonts/fontawesome-webfont.svg +share/doc/qemu/_static/css/fonts/fontawesome-webfont.ttf +share/doc/qemu/_static/css/fonts/fontawesome-webfont.woff +share/doc/qemu/_static/css/fonts/fontawesome-webfont.woff2 +share/doc/qemu/_static/css/fonts/lato-bold-italic.woff +share/doc/qemu/_static/css/fonts/lato-bold-italic.woff2 +share/doc/qemu/_static/css/fonts/lato-bold.woff +share/doc/qemu/_static/css/fonts/lato-bold.woff2 +share/doc/qemu/_static/css/fonts/lato-normal-italic.woff +share/doc/qemu/_static/css/fonts/lato-normal-italic.woff2 +share/doc/qemu/_static/css/fonts/lato-normal.woff +share/doc/qemu/_static/css/fonts/lato-normal.woff2 +share/doc/qemu/_static/css/theme.css +share/doc/qemu/_static/custom.js +share/doc/qemu/_static/doctools.js +share/doc/qemu/_static/documentation_options.js +share/doc/qemu/_static/file.png +share/doc/qemu/_static/js/ +share/doc/qemu/_static/js/badge_only.js +share/doc/qemu/_static/js/theme.js +share/doc/qemu/_static/language_data.js +share/doc/qemu/_static/minus.png +share/doc/qemu/_static/plus.png +share/doc/qemu/_static/pygments.css +share/doc/qemu/_static/qemu_128x128.png +share/doc/qemu/_static/qemu_32x32.png +share/doc/qemu/_static/searchtools.js +share/doc/qemu/_static/sphinx_highlight.js +share/doc/qemu/_static/theme_overrides.css +share/doc/qemu/about/ +share/doc/qemu/about/build-platforms.html +share/doc/qemu/about/deprecated.html +share/doc/qemu/about/index.html +share/doc/qemu/about/license.html +share/doc/qemu/about/removed-features.html +share/doc/qemu/dbus-dbusindex.html +share/doc/qemu/devel/ +share/doc/qemu/devel/acpi-bits.html +share/doc/qemu/devel/atomics.html +share/doc/qemu/devel/bitops.html +share/doc/qemu/devel/block-coroutine-wrapper.html +share/doc/qemu/devel/build-system.html +share/doc/qemu/devel/ci.html +share/doc/qemu/devel/clocks.html +share/doc/qemu/devel/code-of-conduct.html +share/doc/qemu/devel/conflict-resolution.html +share/doc/qemu/devel/control-flow-integrity.html +share/doc/qemu/devel/decodetree.html +share/doc/qemu/devel/ebpf_rss.html +share/doc/qemu/devel/fuzzing.html +share/doc/qemu/devel/index-api.html +share/doc/qemu/devel/index-build.html +share/doc/qemu/devel/index-internals.html +share/doc/qemu/devel/index-process.html +share/doc/qemu/devel/index-tcg.html +share/doc/qemu/devel/index.html +share/doc/qemu/devel/kconfig.html +share/doc/qemu/devel/loads-stores.html +share/doc/qemu/devel/maintainers.html +share/doc/qemu/devel/memory.html +share/doc/qemu/devel/migration.html +share/doc/qemu/devel/modules.html +share/doc/qemu/devel/multi-process.html +share/doc/qemu/devel/multi-thread-tcg.html +share/doc/qemu/devel/qapi-code-gen.html +share/doc/qemu/devel/qgraph.html +share/doc/qemu/devel/qom.html +share/doc/qemu/devel/qtest.html +share/doc/qemu/devel/replay.html +share/doc/qemu/devel/reset.html +share/doc/qemu/devel/s390-dasd-ipl.html +share/doc/qemu/devel/secure-coding-practices.html +share/doc/qemu/devel/stable-process.html +share/doc/qemu/devel/style.html +share/doc/qemu/devel/submitting-a-patch.html +share/doc/qemu/devel/submitting-a-pull-request.html +share/doc/qemu/devel/tcg-icount.html +share/doc/qemu/devel/tcg-plugins.html +share/doc/qemu/devel/tcg.html +share/doc/qemu/devel/testing.html +share/doc/qemu/devel/tracing.html +share/doc/qemu/devel/trivial-patches.html +share/doc/qemu/devel/ui.html +share/doc/qemu/devel/vfio-migration.html +share/doc/qemu/devel/virtio-backends.html +share/doc/qemu/devel/writing-monitor-commands.html +share/doc/qemu/genindex.html +share/doc/qemu/index.html +share/doc/qemu/interop/barrier.html +share/doc/qemu/interop/bitmaps.html +share/doc/qemu/interop/dbus-display.html +share/doc/qemu/interop/dbus-vmstate.html +share/doc/qemu/interop/dbus.html +share/doc/qemu/interop/index.html +share/doc/qemu/interop/live-block-operations.html +share/doc/qemu/interop/pr-helper.html +share/doc/qemu/interop/qemu-qmp-ref.html +share/doc/qemu/interop/qemu-storage-daemon-qmp-ref.html +share/doc/qemu/interop/vhost-user-gpu.html +share/doc/qemu/interop/vhost-user.html +share/doc/qemu/interop/vhost-vdpa.html +share/doc/qemu/interop/virtio-balloon-stats.html +share/doc/qemu/objects.inv +share/doc/qemu/search.html +share/doc/qemu/searchindex.js +share/doc/qemu/specs/ +share/doc/qemu/specs/acpi_cpu_hotplug.html +share/doc/qemu/specs/acpi_erst.html +share/doc/qemu/specs/acpi_hest_ghes.html +share/doc/qemu/specs/acpi_hw_reduced_hotplug.html +share/doc/qemu/specs/acpi_mem_hotplug.html +share/doc/qemu/specs/acpi_nvdimm.html +share/doc/qemu/specs/acpi_pci_hotplug.html +share/doc/qemu/specs/fw_cfg.html +share/doc/qemu/specs/index.html +share/doc/qemu/specs/ppc-spapr-hcalls.html +share/doc/qemu/specs/ppc-spapr-hotplug.html +share/doc/qemu/specs/ppc-spapr-numa.html +share/doc/qemu/specs/ppc-spapr-uv-hcalls.html +share/doc/qemu/specs/ppc-spapr-xive.html +share/doc/qemu/specs/ppc-xive.html +share/doc/qemu/specs/sev-guest-firmware.html +share/doc/qemu/specs/tpm.html +share/doc/qemu/system/ +share/doc/qemu/system/arm/ +share/doc/qemu/system/arm/aspeed.html +share/doc/qemu/system/arm/collie.html +share/doc/qemu/system/arm/cpu-features.html +share/doc/qemu/system/arm/cubieboard.html +share/doc/qemu/system/arm/digic.html +share/doc/qemu/system/arm/emcraft-sf2.html +share/doc/qemu/system/arm/emulation.html +share/doc/qemu/system/arm/gumstix.html +share/doc/qemu/system/arm/highbank.html +share/doc/qemu/system/arm/imx25-pdk.html +share/doc/qemu/system/arm/integratorcp.html +share/doc/qemu/system/arm/kzm.html +share/doc/qemu/system/arm/mainstone.html +share/doc/qemu/system/arm/mps2.html +share/doc/qemu/system/arm/musca.html +share/doc/qemu/system/arm/musicpal.html +share/doc/qemu/system/arm/nrf.html +share/doc/qemu/system/arm/nseries.html +share/doc/qemu/system/arm/nuvoton.html +share/doc/qemu/system/arm/orangepi.html +share/doc/qemu/system/arm/palm.html +share/doc/qemu/system/arm/raspi.html +share/doc/qemu/system/arm/realview.html +share/doc/qemu/system/arm/sabrelite.html +share/doc/qemu/system/arm/sbsa.html +share/doc/qemu/system/arm/stellaris.html +share/doc/qemu/system/arm/stm32.html +share/doc/qemu/system/arm/sx1.html +share/doc/qemu/system/arm/versatile.html +share/doc/qemu/system/arm/vexpress.html +share/doc/qemu/system/arm/virt.html +share/doc/qemu/system/arm/xlnx-versal-virt.html +share/doc/qemu/system/arm/xscale.html +share/doc/qemu/system/authz.html +share/doc/qemu/system/barrier.html +share/doc/qemu/system/bootindex.html +share/doc/qemu/system/confidential-guest-support.html +share/doc/qemu/system/cpu-hotplug.html +share/doc/qemu/system/device-emulation.html +share/doc/qemu/system/devices/ +share/doc/qemu/system/devices/can.html +share/doc/qemu/system/devices/canokey.html +share/doc/qemu/system/devices/ccid.html +share/doc/qemu/system/devices/cxl.html +share/doc/qemu/system/devices/ivshmem.html +share/doc/qemu/system/devices/net.html +share/doc/qemu/system/devices/nvme.html +share/doc/qemu/system/devices/usb.html +share/doc/qemu/system/devices/vhost-user-rng.html +share/doc/qemu/system/devices/vhost-user.html +share/doc/qemu/system/devices/virtio-pmem.html +share/doc/qemu/system/gdb.html +share/doc/qemu/system/generic-loader.html +share/doc/qemu/system/guest-loader.html +share/doc/qemu/system/i386/ +share/doc/qemu/system/i386/amd-memory-encryption.html +share/doc/qemu/system/i386/cpu.html +share/doc/qemu/system/i386/hyperv.html +share/doc/qemu/system/i386/kvm-pv.html +share/doc/qemu/system/i386/microvm.html +share/doc/qemu/system/i386/pc.html +share/doc/qemu/system/i386/sgx.html +share/doc/qemu/system/images.html +share/doc/qemu/system/index.html +share/doc/qemu/system/invocation.html +share/doc/qemu/system/keys.html +share/doc/qemu/system/linuxboot.html +share/doc/qemu/system/loongarch/ +share/doc/qemu/system/loongarch/loongson3.html +share/doc/qemu/system/managed-startup.html +share/doc/qemu/system/monitor.html +share/doc/qemu/system/multi-process.html +share/doc/qemu/system/mux-chardev.html +share/doc/qemu/system/openrisc/ +share/doc/qemu/system/openrisc/cpu-features.html +share/doc/qemu/system/openrisc/emulation.html +share/doc/qemu/system/openrisc/or1k-sim.html +share/doc/qemu/system/openrisc/virt.html +share/doc/qemu/system/ppc/ +share/doc/qemu/system/ppc/embedded.html +share/doc/qemu/system/ppc/powermac.html +share/doc/qemu/system/ppc/powernv.html +share/doc/qemu/system/ppc/ppce500.html +share/doc/qemu/system/ppc/prep.html +share/doc/qemu/system/ppc/pseries.html +share/doc/qemu/system/pr-manager.html +share/doc/qemu/system/qemu-block-drivers.html +share/doc/qemu/system/qemu-cpu-models.html +share/doc/qemu/system/qemu-manpage.html +share/doc/qemu/system/quickstart.html +share/doc/qemu/system/replay.html +share/doc/qemu/system/riscv/ +share/doc/qemu/system/riscv/microchip-icicle-kit.html +share/doc/qemu/system/riscv/shakti-c.html +share/doc/qemu/system/riscv/sifive_u.html +share/doc/qemu/system/riscv/virt.html +share/doc/qemu/system/s390x/ +share/doc/qemu/system/s390x/3270.html +share/doc/qemu/system/s390x/bootdevices.html +share/doc/qemu/system/s390x/css.html +share/doc/qemu/system/s390x/protvirt.html +share/doc/qemu/system/s390x/vfio-ap.html +share/doc/qemu/system/s390x/vfio-ccw.html +share/doc/qemu/system/secrets.html +share/doc/qemu/system/security.html +share/doc/qemu/system/target-arm.html +share/doc/qemu/system/target-avr.html +share/doc/qemu/system/target-i386.html +share/doc/qemu/system/target-m68k.html +share/doc/qemu/system/target-mips.html +share/doc/qemu/system/target-openrisc.html +share/doc/qemu/system/target-ppc.html +share/doc/qemu/system/target-riscv.html +share/doc/qemu/system/target-rx.html +share/doc/qemu/system/target-s390x.html +share/doc/qemu/system/target-sparc.html +share/doc/qemu/system/target-sparc64.html +share/doc/qemu/system/target-xtensa.html +share/doc/qemu/system/targets.html +share/doc/qemu/system/tls.html +share/doc/qemu/system/virtio-net-failover.html +share/doc/qemu/system/vnc-security.html +share/doc/qemu/tools/ +share/doc/qemu/tools/index.html +share/doc/qemu/tools/qemu-img.html +share/doc/qemu/tools/qemu-nbd.html +share/doc/qemu/tools/qemu-pr-helper.html +share/doc/qemu/tools/qemu-storage-daemon.html +share/doc/qemu/tools/qemu-trace-stap.html +share/doc/qemu/tools/virtfs-proxy-helper.html +share/doc/qemu/tools/virtiofsd.html +share/doc/qemu/user/ +share/doc/qemu/user/index.html +share/doc/qemu/user/main.html +share/examples/qemu/qemu-ifdown +@mode 755 +@sample ${SYSCONFDIR}/qemu-ifdown +@mode +share/examples/qemu/qemu-ifup +@mode 755 +@sample ${SYSCONFDIR}/qemu-ifup +@mode +share/icons/hicolor/128x128/apps/qemu.png +share/icons/hicolor/16x16/apps/qemu.png +share/icons/hicolor/24x24/apps/qemu.png +share/icons/hicolor/256x256/apps/qemu.png +share/icons/hicolor/32x32/apps/qemu.bmp +share/icons/hicolor/32x32/apps/qemu.png +share/icons/hicolor/48x48/apps/qemu.png +share/icons/hicolor/512x512/apps/qemu.png +share/icons/hicolor/64x64/apps/qemu.png +share/icons/hicolor/scalable/apps/qemu.svg +share/locale/bg/LC_MESSAGES/qemu.mo +share/locale/de_DE/ +share/locale/de_DE/LC_MESSAGES/ +share/locale/de_DE/LC_MESSAGES/qemu.mo +share/locale/fr_FR/ +share/locale/fr_FR/LC_MESSAGES/ +share/locale/fr_FR/LC_MESSAGES/qemu.mo +share/locale/hu/LC_MESSAGES/qemu.mo +share/locale/it/LC_MESSAGES/qemu.mo +share/locale/sv/LC_MESSAGES/qemu.mo +share/locale/tr/LC_MESSAGES/qemu.mo +share/locale/uk/LC_MESSAGES/qemu.mo +share/locale/zh_CN/LC_MESSAGES/qemu.mo +share/qemu/ +share/qemu/QEMU,cgthree.bin +share/qemu/QEMU,tcx.bin +share/qemu/bamboo.dtb +share/qemu/bios-256k.bin +share/qemu/bios-microvm.bin +share/qemu/bios.bin +share/qemu/canyonlands.dtb +share/qemu/edk2-aarch64-code.fd +share/qemu/edk2-arm-code.fd +share/qemu/edk2-arm-vars.fd +share/qemu/edk2-i386-code.fd +share/qemu/edk2-i386-secure-code.fd +share/qemu/edk2-i386-vars.fd +share/qemu/edk2-licenses.txt +share/qemu/edk2-x86_64-code.fd +share/qemu/edk2-x86_64-secure-code.fd +share/qemu/efi-e1000.rom +share/qemu/efi-e1000e.rom +share/qemu/efi-eepro100.rom +share/qemu/efi-ne2k_pci.rom +share/qemu/efi-pcnet.rom +share/qemu/efi-rtl8139.rom +share/qemu/efi-virtio.rom +share/qemu/efi-vmxnet3.rom +share/qemu/firmware/ +share/qemu/firmware/50-edk2-i386-secure.json +share/qemu/firmware/50-edk2-x86_64-secure.json +share/qemu/firmware/60-edk2-aarch64.json +share/qemu/firmware/60-edk2-arm.json +share/qemu/firmware/60-edk2-i386.json +share/qemu/firmware/60-edk2-x86_64.json +share/qemu/hppa-firmware.img +share/qemu/keymaps/ +share/qemu/keymaps/ar +share/qemu/keymaps/bepo +share/qemu/keymaps/cz +share/qemu/keymaps/da +share/qemu/keymaps/de +share/qemu/keymaps/de-ch +share/qemu/keymaps/en-gb +share/qemu/keymaps/en-us +share/qemu/keymaps/es +share/qemu/keymaps/et +share/qemu/keymaps/fi +share/qemu/keymaps/fo +share/qemu/keymaps/fr +share/qemu/keymaps/fr-be +share/qemu/keymaps/fr-ca +share/qemu/keymaps/fr-ch +share/qemu/keymaps/hr +share/qemu/keymaps/hu +share/qemu/keymaps/is +share/qemu/keymaps/it +share/qemu/keymaps/ja +share/qemu/keymaps/lt +share/qemu/keymaps/lv +share/qemu/keymaps/mk +share/qemu/keymaps/nl +share/qemu/keymaps/no +share/qemu/keymaps/pl +share/qemu/keymaps/pt +share/qemu/keymaps/pt-br +share/qemu/keymaps/ru +share/qemu/keymaps/sl +share/qemu/keymaps/sv +share/qemu/keymaps/th +share/qemu/keymaps/tr +share/qemu/kvmvapic.bin +share/qemu/linuxboot.bin +share/qemu/linuxboot_dma.bin +share/qemu/multiboot.bin +share/qemu/multiboot_dma.bin +share/qemu/npcm7xx_bootrom.bin +share/qemu/openbios-ppc +share/qemu/openbios-sparc32 +share/qemu/openbios-sparc64 +share/qemu/opensbi-riscv32-generic-fw_dynamic.bin +share/qemu/opensbi-riscv64-generic-fw_dynamic.bin +share/qemu/palcode-clipper +share/qemu/petalogix-ml605.dtb +share/qemu/petalogix-s3adsp1800.dtb +share/qemu/pvh.bin +share/qemu/pxe-e1000.rom +share/qemu/pxe-eepro100.rom +share/qemu/pxe-ne2k_pci.rom +share/qemu/pxe-pcnet.rom +share/qemu/pxe-rtl8139.rom +share/qemu/pxe-virtio.rom +share/qemu/qboot.rom +share/qemu/qemu-nsis.bmp +share/qemu/qemu_vga.ndrv +share/qemu/s390-ccw.img +share/qemu/s390-netboot.img +share/qemu/sgabios.bin +share/qemu/skiboot.lid +share/qemu/slof.bin +share/qemu/trace-events-all +share/qemu/u-boot-sam460-20100605.bin +share/qemu/u-boot.e500 +share/qemu/vgabios-ati.bin +share/qemu/vgabios-bochs-display.bin +share/qemu/vgabios-cirrus.bin +share/qemu/vgabios-qxl.bin +share/qemu/vgabios-ramfb.bin +share/qemu/vgabios-stdvga.bin +share/qemu/vgabios-virtio.bin +share/qemu/vgabios-vmware.bin +share/qemu/vgabios.bin +share/qemu/vof-nvram.bin +share/qemu/vof.bin +@tag update-desktop-database +@tag gtk-update-icon-cache %D/share/icons/hicolor diff --git a/emulators/qemu/pkg/README-ga b/emulators/qemu/pkg/README-ga new file mode 100644 index 0000000..963a88e --- /dev/null +++ b/emulators/qemu/pkg/README-ga @@ -0,0 +1,25 @@ ++----------------------------------------------------------------------- +| Running ${PKGSTEM} on OpenBSD ++----------------------------------------------------------------------- + +To use qemu-ga, configure QEMU to present the guest agent interface as +an isa-serial port. + +If you use Proxmox Virtual Environment, you can do this in the "Options" +section; edit "QEMU Guest Agent", enable it, tick the box to show advanced +settings, and set "Type" to ISA. + +An rc.d(8) script is provided; as usual you can enable it to start at +boot with: + +# rcctl enable qemu_ga + +By default the script uses /dev/cua01 for the connection as would be +the case where you have also enabled a serial console device. If you have +not done this and the Guest Agent interface is on a different port, set +that with e.g. + +# rcctl set qemu_ga flags -t /var/run/qemu-ga \ + -f /var/run/qemu-ga/qemu-ga.pid -m isa-serial -p /dev/cua00 + +Currently only a basic set of commands are available via this interface. diff --git a/emulators/qemu/pkg/README-main b/emulators/qemu/pkg/README-main new file mode 100644 index 0000000..09221d2 --- /dev/null +++ b/emulators/qemu/pkg/README-main @@ -0,0 +1,266 @@ ++----------------------------------------------------------------------- +| Running ${PKGSTEM} on OpenBSD ++----------------------------------------------------------------------- + +==> Quick Start + +1. Get a bootable CDROM image: + + $ ftp https://cdn.openbsd.org/pub/OpenBSD/snapshots/i386/cd70.iso + + or to use a 64-bit client OS or SPARC, respectively: + + $ ftp https://cdn.openbsd.org/pub/OpenBSD/snapshots/amd64/cd70.iso + + $ ftp https://cdn.openbsd.org/pub/OpenBSD/snapshots/sparc/cd70.iso + +2. Create a virtual disk image: + + $ qemu-img create -f qcow2 virtual.img 10G + +3. Install the OS: + + $ qemu-system-i386 -m 32 -monitor stdio -no-fd-bootchk \ + -hda virtual.img -cdrom cd70.iso -boot d + + or: + + $ qemu-system-x86_64 -m 32 -monitor stdio -no-fd-bootchk \ + -hda virtual.img -cdrom cd70.iso -boot d + + $ qemu-system-sparc -m 32 -monitor stdio \ + -hda virtual.img -cdrom cd70.iso -boot d + + NOTE: start this inside an xterm or equivalent. + NOTE: be sure to choose serial console during install. + NOTE: -no-fd-bootchk permits booting faster when no floppy is + in use, but is not supported for qemu-system-sparc. + NOTE: qemu-system-ppc* and qemu-system-sparc* currently fail with + J or S malloc flags + +4. Compress the virtual disk: + + $ qemu-img convert -c -O qcow2 virtual.img v.tmp && \ + mv v.tmp virtual.img + + NOTE: do not do this while QEMU is running / using this virtual + disk. + +5. Boot normally from the virtual disk: + + $ qemu-system-i386 -m 32 -nographic -no-fd-bootchk -hda virtual.img + + or: + + $ qemu-system-x86_64 -m 32 -nographic -no-fd-bootchk -hda virtual.img + + $ qemu-system-sparc -m 32 -nographic -hda virtual.img + +==> Networking + +1. Default Settings + + By default, QEMU sets up the equivalent of the following networking: + + -net nic,vlan=0,model=e1000,macaddr=52:54:00:12:34:56 + -net user,vlan=0 + + Also, inside this virtual usermode network, it uses the 10.0.2.0/24 + and serves DHCP from inside this virtual network. Static address + can be used if one cannot or does not want to do DHCP in the + guest OS: + + Guest OS IP : 10.0.2.15 + Default Gateway : 10.0.2.2 + Nameserver : 10.0.2.3 + + It is sufficient for most operations, QEMU itself performs NAT + and then makes userland network calls for TCP/UDP operations. + ICMP and other things are not possible in this mode. + + NOTE: If you use one '-net' cmdline argument, QEMU assumes you + know what you want and clears defaults for the rest of the + -net defaults. + + NOTE: The guest mode networking does not currently support IPv6, + and QEMU will complain that it cannot find a DNS server + if /etc/resolv.conf contains only IPv6 DNS servers. + +2. tap mode + + Sometimes it is desirable to configure QEMU to access a network + via layer2 directly. One way of doing this without having to run + QEMU as root is to let root open /dev/tapN and pass the file + descriptor to QEMU. The tap(4) interface should preferrably be + configured before starting QEMU: + + $ doas ifconfig tap0 192.168.0.254 + + The interface can also be configured as part of a bridge(4), in + which case the ip address can be omitted: + + $ doas ifconfig bridge0 add tap0 add em0 up + + The tunnel and bridge interfaces can also be configured at system + startup by editing /etc/hostname.tapN and /etc/hostname.bridgeN, + respectively (see hostname.if(5)). + + After configuring the virtual network we can use doas to let + root open the tunnel device and then use doas again to drop + privileges and start QEMU: + + $ doas sh -c "doas -u $USER qemu-system-i386 -nographic -net nic \ + -net tap,fd=3 -no-fd-bootchk -hda virtual.img 3<>/dev/tap0" + + NOTE: if you use sudo instead of doas, remember that sudo calls + closefrom(2). In order to have more than one fd passed tap + interface, a line to sudoers akin to: + + Defaults closefrom_override + + then calling sudo via 'sudo -C 5 -u $USER qemu-system-i386 ..' + is required. See sudoers(5) and sudo(8) for details. + + An alternative to the procedure described above is to have QEMU + set up the network via ${SYSCONFDIR}/qemu-ifup. This is not + recommended however, since you would have to run QEMU as root, + and there is no way to drop from root privileges at this point. + + ${SYSCONFDIR}/qemu-ifup contains some default settings that + permit one to do the following: + + # qemu-system-i386 -net nic -net tap -no-fd-bootchk -hda virtual.img + + It presumes you wish the tap(4) interface to talk to the interface + holding the default IPv4 route (falling back to trunk0 if no + route is found), and that you want 'bridge0' to be used to bridge + the two. + + Setting the environment variables ETHER and BRIDGE will override + these settings, respectively. + + When starting QEMU, the script attempts to output useful + information, but there are also error messages that occur as + well. On my laptop, I want to route / nat natively using PF and + also have layer2 access to the QEMU networks. I thus have this + as /etc/hostname.trunk101: + + inet6 fe80::1c 64 lladdr 00:03:25:0d:7a:2c + inet 10.7.255.1 255.255.255.0 + inet6 alias 2001:240:58a:45::1c + + I have dhcpd configured to run on trunk101, and also run rad. + For QEMU, the startup looks like this: + + # export ETHER=trunk101 + # export BRIDGE=bridge101 + # qemu-system-i386 -net nic,vlan=0,macaddr=52:54:00:12:35:00 \ + -net tap,vlan=0 -vnc :0 -localtime -usb -usbdevice tablet \ + -m 256 -no-fd-bootchk -hda virtual.img -monitor stdio + {tap0 (bridge101 <-> trunk101)ifconfig: bridge101: No such process + ifconfig: bridge101: No such process + } + (qemu) + + The errors are normal and should be ignored. One can verify the + networking is properly configured by verifying the bridge + interface: + + $ ifconfig bridge101 + bridge101: flags=41 + groups: bridge + priority 32768 hellotime 2 fwddelay 15 maxage 20 holdcnt 6 proto rstp + designated: id 00:00:00:00:00:00 priority 0 + tap0 flags=3 + port 16 ifpriority 0 ifcost 0 + trunk101 flags=3 + port 6 ifpriority 0 ifcost 0 + Addresses (max cache: 100, timeout: 240): + + NOTE: When running multiple QEMU sessions simultaneously on the + same bridge, care must be taken because the network MAC + address defaults to 52:54:00:12:34:56 for every QEMU + instance. To change this, observe the macaddr= syntax in + the above example and choose a unique lladdr per QEMU nic. + +==> Mice + + NOTE: Certain OS's work much better with the USB tablet device + than the normal PS/2 mouse handling. See the above example + for usage. + +==> Serial Console + + Installing OpenBSD via serial console is sometimes desirable. + X may not be available, and so on. There are two ways to + accomplish this, both in effect the same solution: + + a. qemu-system-i386 -vnc :0 -serial stdio .. virtual.img \ + -cdrom install52.iso -boot d + + - this option permits you to use VNC from some system to + connect to the QEMU instance and 'set tty com0' at the + 'boot>' prompt. + - you may then disconnect VNC and use the terminal from + which you started QEMU to do the install. + + b. qemu-system-i386 -nographic .. virtual.img -fda floppy52.fs -boot a + + - this maps both the serial port and the (qemu) monitor + prompt to the terminal QEMU was started on. + - to flip between them, Ctrl-a c; see the QEMU man page for + other commands that work in -nographic mode. + - preparation of the floppy image to force serial console + mode is straightforward: + + vnconfig vnd0 floppy52.fs + mount /dev/vnd0c /mnt + mkdir /mnt/etc + echo set tty com0 > /mnt/etc/boot.conf + umount /mnt + vnconfig -u vnd0 + + .. be sure to choose 'yes' for setting com0 to be the serial + console. + + NOTE: OpenBSD poweroff does work with QEMU, which actually causes + QEMU itself to exit. This is a good thing, as it is + currently not possible to set what block device is booted + from at runtime from QEMU. So if you start an installation + booting from a CD-ROM, you will always boot off a CD-ROM + every time you reboot that QEMU session until you exit and + start QEMU again booting off the virtual hard drive. + +==> daemonized QEMU + + Sometimes you want QEMU to start as part of a system script. + + Adding to some of the above, the -daemonize option comes in + handy, as well as the telnet: designator for -serial and monitor. + This is a complete example that may be cut-and-pasted into + rc.local: + + hddir=/var/vm + USER=qemu + if [ -x ${TRUEPREFIX}/bin/qemu ]; then + echo -n 'Qemu: vmi386' + ( + ifconfig bridge101 add trunk101 add tap0 up + + sh -c "doas -u $USER \ + ${TRUEPREFIX}/bin/qemu-system-i386 \ + -daemonize \ + -nographic \ + -net nic,vlan=0,macaddr=52:54:00:4e:62:8f \ + -net tap,vlan=0,fd=3 \ + -m 128 \ + -hda $hddir/virtual.img \ + -serial telnet:127.0.0.1:1080,server,nowait \ + -monitor telnet:127.0.0.1:1081,server,nowait \ + -no-fd-bootchk 3<>/dev/tap0" + ) + echo "." + fi + + NOTE: this presumes the user `qemu' exists, create it or set + USER= to an existing user to use this example. diff --git a/emulators/qemu/pkg/qemu_ga.rc b/emulators/qemu/pkg/qemu_ga.rc new file mode 100644 index 0000000..d2d3f50 --- /dev/null +++ b/emulators/qemu/pkg/qemu_ga.rc @@ -0,0 +1,14 @@ +#!/bin/ksh + +daemon="${TRUEPREFIX}/bin/qemu-ga -d" +daemon_flags="-t /var/run/qemu-ga -f /var/run/qemu-ga/qemu-ga.pid" + +. /etc/rc.d/rc.subr + +rc_reload=NO + +rc_pre() { + install -d -o ${daemon_user} /var/run/qemu-ga +} + +rc_cmd $1 -- cgit v1.2.3