summaryrefslogtreecommitdiff
path: root/emulators
diff options
context:
space:
mode:
Diffstat (limited to 'emulators')
-rw-r--r--emulators/qemu/CVS/Entries5
-rw-r--r--emulators/qemu/CVS/Repository1
-rw-r--r--emulators/qemu/CVS/Root1
-rw-r--r--emulators/qemu/CVS/Tag1
-rw-r--r--emulators/qemu/Makefile139
-rw-r--r--emulators/qemu/distinfo2
-rw-r--r--emulators/qemu/files/CVS/Entries4
-rw-r--r--emulators/qemu/files/CVS/Repository1
-rw-r--r--emulators/qemu/files/CVS/Root1
-rw-r--r--emulators/qemu/files/CVS/Tag1
-rw-r--r--emulators/qemu/files/qemu-ga.conf3
-rw-r--r--emulators/qemu/files/qemu-ifdown14
-rw-r--r--emulators/qemu/files/qemu-ifup40
-rw-r--r--emulators/qemu/patches/CVS/Entries10
-rw-r--r--emulators/qemu/patches/CVS/Repository1
-rw-r--r--emulators/qemu/patches/CVS/Root1
-rw-r--r--emulators/qemu/patches/CVS/Tag1
-rw-r--r--emulators/qemu/patches/patch-audio_audio_c13
-rw-r--r--emulators/qemu/patches/patch-audio_audio_template_h14
-rw-r--r--emulators/qemu/patches/patch-audio_meson_build13
-rw-r--r--emulators/qemu/patches/patch-audio_sndioaudio_c572
-rw-r--r--emulators/qemu/patches/patch-configure97
-rw-r--r--emulators/qemu/patches/patch-meson_build56
-rw-r--r--emulators/qemu/patches/patch-meson_mesonbuild_compilers_cpp_py21
-rw-r--r--emulators/qemu/patches/patch-meson_options_txt23
-rw-r--r--emulators/qemu/patches/patch-plugins_meson_build26
-rw-r--r--emulators/qemu/patches/patch-qapi_audio_json50
-rw-r--r--emulators/qemu/patches/patch-qemu-options_hx35
-rw-r--r--emulators/qemu/patches/patch-qga_commands-bsd_c16
-rw-r--r--emulators/qemu/patches/patch-qga_commands-posix_c576
-rw-r--r--emulators/qemu/patches/patch-qga_main_c37
-rw-r--r--emulators/qemu/patches/patch-util_cacheflush_c19
-rw-r--r--emulators/qemu/patches/patch-util_qemu-thread-posix_c35
-rw-r--r--emulators/qemu/pkg/CVS/Entries9
-rw-r--r--emulators/qemu/pkg/CVS/Repository1
-rw-r--r--emulators/qemu/pkg/CVS/Root1
-rw-r--r--emulators/qemu/pkg/CVS/Tag1
-rw-r--r--emulators/qemu/pkg/DESCR-ga3
-rw-r--r--emulators/qemu/pkg/DESCR-main4
-rw-r--r--emulators/qemu/pkg/PFRAG.plugins-main1
-rw-r--r--emulators/qemu/pkg/PLIST-ga14
-rw-r--r--emulators/qemu/pkg/PLIST-main465
-rw-r--r--emulators/qemu/pkg/README-ga25
-rw-r--r--emulators/qemu/pkg/README-main266
-rw-r--r--emulators/qemu/pkg/qemu_ga.rc14
45 files changed, 2633 insertions, 0 deletions
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 @@
1D/files////
2D/patches////
3D/pkg////
4/Makefile/1.230/Tue Feb 21 23:06:55 2023//TOPENBSD_7_3
5/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 @@
1ONLY_FOR_ARCHS= aarch64 amd64 arm i386 powerpc powerpc64 riscv64 sparc64
2DPB_PROPERTIES= parallel
3
4COMMENT-main= multi system emulator
5COMMENT-ga= QEMU guest agent
6
7VERSION= 7.2.0
8DISTNAME= qemu-${VERSION}
9REVISION-ga= 0
10REVISION-main= 1
11CATEGORIES= emulators
12MASTER_SITES= https://download.qemu.org/
13EXTRACT_SUFX= .tar.xz
14
15HOMEPAGE= https://www.qemu.org/
16
17MAINTAINER= Brad Smith <brad@comstyle.com>
18
19# GPLv2, LGPLv2 and BSD
20PERMIT_PACKAGE= Yes
21
22WANTLIB= c glib-2.0 pthread
23WANTLIB-main= ${COMPILER_LIBCXX} ${WANTLIB} SDL2 X11 bz2 cairo capstone curl \
24 curses epoxy fdt gbm gdk-3 gdk_pixbuf-2.0 gio-2.0 gnutls \
25 gobject-2.0 gtk-3 iconv intl iscsi jpeg lzo2 m nfs pixman-1 \
26 png slirp sndio ssh usb-1.0 util vte-2.91 xkbcommon z zstd
27WANTLIB-ga= ${WANTLIB}
28
29MULTI_PACKAGES= -main -ga
30DEBUG_PACKAGES= ${BUILD_PACKAGES}
31
32# Using TLS emulation layer
33COMPILER= base-clang ports-gcc
34
35MODULES= lang/python
36MODPY_RUNDEP= No
37
38BUILD_DEPENDS= devel/gettext,-tools \
39 devel/ninja \
40 shells/bash \
41 textproc/py-sphinx${MODPY_FLAVOR}>=4.0.2 \
42 textproc/py-sphinx_rtd_theme${MODPY_FLAVOR}
43
44RUN_DEPENDS-main= ${BUILD_PKGPATH}-ga
45LIB_DEPENDS= devel/glib2
46LIB_DEPENDS-main= ${LIB_DEPENDS} \
47 archivers/bzip2 \
48 archivers/lzo2 \
49 archivers/zstd \
50 converters/libiconv \
51 devel/capstone/main \
52 devel/dtc \
53 devel/gettext,-runtime \
54 devel/libiscsi \
55 devel/libnfs \
56 devel/libusb1 \
57 devel/sdl2 \
58 devel/vte3 \
59 graphics/jpeg \
60 graphics/png \
61 net/curl \
62 net/libslirp \
63 security/gnutls \
64 security/libssh \
65 x11/gtk+3 \
66 x11/xkbcommon
67LIB_DEPENDS-ga= ${LIB_DEPENDS}
68
69MAKE_ENV= V=1
70FAKE_FLAGS= qemu_confdir=${PREFIX}/share/examples/qemu
71
72CFLAGS+= -I${LOCALBASE}/include -I${X11BASE}/include
73LDFLAGS+= -L${LOCALBASE}/lib -L${X11BASE}/lib
74
75# until the system headers are fixed properly.
76CFLAGS+= -Wno-redundant-decls
77
78SEPARATE_BUILD= Yes
79USE_GMAKE= Yes
80CONFIGURE_STYLE=simple
81CONFIGURE_ENV+= LDFLAGS="${LDFLAGS}"
82CONFIGURE_ARGS= --localstatedir=${LOCALSTATEDIR} \
83 --prefix=${PREFIX} \
84 --sysconfdir=${SYSCONFDIR} \
85 --mandir=${PREFIX}/man \
86 --python=${MODPY_BIN} \
87 --smbd=${LOCALBASE}/sbin/smbd \
88 --cc="${CC}" \
89 --cxx="${CXX}" \
90 --host-cc="${CC}" \
91 --enable-capstone \
92 --disable-auth-pam \
93 --disable-bsd-user \
94 --disable-jack \
95 --disable-sdl-image \
96 --disable-smartcard \
97 --disable-snappy \
98 --disable-spice \
99 --disable-usb-redir \
100 --disable-vnc-sasl
101
102FLAVORS= debug
103FLAVOR?=
104
105.if ${FLAVOR:Mdebug}
106CFLAGS+= -O0
107CONFIGURE_ARGS+=--enable-debug
108INSTALL_STRIP=
109.else
110CONFIGURE_ARGS+=--disable-debug-info
111.endif
112
113TEST_TARGET= check
114
115# XXX Optimizer bug, using -O2 causes segfaults, -O1 linking errors
116.if ${MACHINE_ARCH:Mpowerpc}
117CFLAGS+= -O0
118.endif
119
120.include <bsd.port.arch.mk>
121
122# Only lld has --dynamic-list
123.if ${PROPERTIES:Mlld}
124WANTLIB-main+= gmodule-2.0
125PKG_ARGS+= -Dplugins=1
126.else
127PKG_ARGS+= -Dplugins=0
128.endif
129
130post-install:
131 ${INSTALL_DATA_DIR} ${PREFIX}/share/examples/qemu
132 ${INSTALL_SCRIPT} ${FILESDIR}/qemu-ifup \
133 ${PREFIX}/share/examples/qemu
134 ${INSTALL_SCRIPT} ${FILESDIR}/qemu-ifdown \
135 ${PREFIX}/share/examples/qemu
136 ${INSTALL_SCRIPT} ${FILESDIR}/qemu-ga.conf \
137 ${PREFIX}/share/examples/qemu
138
139.include <bsd.port.mk>
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 @@
1SHA256 (qemu-7.2.0.tar.xz) = W0nOJod0Ta1JSukKiYxSIEo0BuhNBySCoeG+hU7rIVc=
2SIZE (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 @@
1/qemu-ga.conf/1.1/Tue Mar 29 10:04:28 2022//TOPENBSD_7_3
2/qemu-ifdown/1.5/Wed Oct 28 09:17:31 2015//TOPENBSD_7_3
3/qemu-ifup/1.10/Wed Oct 28 09:17:31 2015//TOPENBSD_7_3
4D
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 @@
1[general]
2method=isa-serial
3path=/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 @@
1#! /bin/sh
2
3_ETHER=trunk0
4_BRIDGE=bridge0
5
6# Let the environment over-ride this
7[ "$BRIDGE" ] || BRIDGE=${_BRIDGE}
8[ "$ETHER" ] || ETHER=${_ETHER}
9
10if test `id -u` -ne 0; then
11 DOAS=doas
12fi
13
14$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 @@
1#! /bin/sh
2
3_ETHER=`route -n get default 2>/dev/null |awk '/interface:/ {print $2}'`
4_ETHER=${_ETHER:=trunk0}
5_BRIDGE=bridge0
6
7# Let the environment over-ride this
8[ "$BRIDGE" ] || BRIDGE=${_BRIDGE}
9[ "$ETHER" ] || ETHER=${_ETHER}
10
11if test `id -u` -ne 0; then
12 DOAS=doas
13fi
14
15echo -n " {$1 ($BRIDGE <-> $ETHER)"
16
17# Set up our bridge
18$DOAS ifconfig $1 group tap > /dev/null 2>&1
19$DOAS ifconfig $BRIDGE create > /dev/null 2>&1 && {
20 # Only add rules if the bridge creation succeeds; otherwise
21 # duplicate rules get loaded each time qemu starts
22 # The following two block carp packets from wasting cpu cycles inside the
23 # qemu sessions, remove if testing carp inside qemu
24 $DOAS ifconfig $BRIDGE rule block in on $ETHER dst 33:33:0:0:0:12
25 $DOAS ifconfig $BRIDGE rule block in on $ETHER dst 01:00:5e:00:00:12
26}
27# Since we can specify ETHER and BRIDGE above, its possible that
28# this tap interface or this physical interface was setup as part of
29# a different bridge earlier, and that is never cleaned up, so we have
30# to cleanup here first before we set it up; a physical interface cannot
31# be member to more than one bridge, thankfully, or I never would have
32# caught this
33ifconfig bridge | sed -n '/^bridge[0-9]*/{s/:.*$//;p;}' | while read brif
34do
35 $DOAS ifconfig $brif del $ETHER > /dev/null 2>&1
36 $DOAS ifconfig $brif del $1 > /dev/null 2>&1
37done
38$DOAS ifconfig $BRIDGE add $ETHER up
39$DOAS ifconfig $BRIDGE add $1 up || true
40echo "}"
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 @@
1/patch-configure/1.75/Wed Jan 4 21:33:42 2023//TOPENBSD_7_3
2/patch-meson_build/1.9/Mon Jan 9 14:26:00 2023//TOPENBSD_7_3
3/patch-meson_mesonbuild_compilers_cpp_py/1.4/Wed Jan 4 21:33:42 2023//TOPENBSD_7_3
4/patch-plugins_meson_build/1.3/Wed Jan 4 21:33:42 2023//TOPENBSD_7_3
5/patch-qga_commands-bsd_c/1.1/Wed Jan 4 21:33:42 2023//TOPENBSD_7_3
6/patch-qga_commands-posix_c/1.7/Wed Jan 4 21:33:42 2023//TOPENBSD_7_3
7/patch-qga_main_c/1.6/Wed Jan 4 21:33:42 2023//TOPENBSD_7_3
8/patch-util_cacheflush_c/1.1/Tue Sep 13 20:11:35 2022//TOPENBSD_7_3
9/patch-util_qemu-thread-posix_c/1.1/Mon Jan 9 14:26:00 2023//TOPENBSD_7_3
10D
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 @@
1sndio module
2
3Index: audio/audio.c
4--- audio/audio.c.orig
5+++ audio/audio.c
6@@ -2025,6 +2025,7 @@ void audio_create_pdos(Audiodev *dev)
7 CASE(OSS, oss, Oss);
8 CASE(PA, pa, Pa);
9 CASE(SDL, sdl, Sdl);
10+ CASE(SNDIO, sndio, );
11 CASE(SPICE, spice, );
12 CASE(WAV, wav, );
13
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 @@
1sndio module
2
3Index: audio/audio_template.h
4--- audio/audio_template.h.orig
5+++ audio/audio_template.h
6@@ -336,6 +336,8 @@ AudiodevPerDirectionOptions *glue(audio_get_pdo_, TYPE
7 return qapi_AudiodevPaPerDirectionOptions_base(dev->u.pa.TYPE);
8 case AUDIODEV_DRIVER_SDL:
9 return qapi_AudiodevSdlPerDirectionOptions_base(dev->u.sdl.TYPE);
10+ case AUDIODEV_DRIVER_SNDIO:
11+ return dev->u.sndio.TYPE;
12 case AUDIODEV_DRIVER_SPICE:
13 return dev->u.spice.TYPE;
14 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 @@
1sndio module
2
3Index: audio/meson.build
4--- audio/meson.build.orig
5+++ audio/meson.build
6@@ -17,6 +17,7 @@ foreach m : [
7 ['pa', pulse, files('paaudio.c')],
8 ['sdl', sdl, files('sdlaudio.c')],
9 ['jack', jack, files('jackaudio.c')],
10+ ['sndio', sndio, files('sndioaudio.c')],
11 ['spice', spice, files('spiceaudio.c')]
12 ]
13 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 @@
1sndio module
2
3Index: audio/sndioaudio.c
4--- audio/sndioaudio.c.orig
5+++ audio/sndioaudio.c
6@@ -0,0 +1,566 @@
7+/*
8+ * SPDX-License-Identifier: ISC
9+ *
10+ * Copyright (c) 2019 Alexandre Ratchov <alex@caoua.org>
11+ */
12+
13+/*
14+ * TODO :
15+ *
16+ * Use a single device and open it in full-duplex rather than
17+ * opening it twice (once for playback once for recording).
18+ *
19+ * This is the only way to ensure that playback doesn't drift with respect
20+ * to recording, which is what guest systems expect.
21+ */
22+
23+#include <poll.h>
24+#include <sndio.h>
25+#include "qemu/osdep.h"
26+#include "qemu/help-texts.h"
27+#include "qemu/main-loop.h"
28+#include "audio.h"
29+#include "trace.h"
30+
31+#define AUDIO_CAP "sndio"
32+#include "audio_int.h"
33+
34+/* default latency in microseconds if no option is set */
35+#define SNDIO_LATENCY_US 50000
36+
37+typedef struct SndioVoice {
38+ union {
39+ HWVoiceOut out;
40+ HWVoiceIn in;
41+ } hw;
42+ struct sio_par par;
43+ struct sio_hdl *hdl;
44+ struct pollfd *pfds;
45+ struct pollindex {
46+ struct SndioVoice *self;
47+ int index;
48+ } *pindexes;
49+ unsigned char *buf;
50+ size_t buf_size;
51+ size_t sndio_pos;
52+ size_t qemu_pos;
53+ unsigned int mode;
54+ unsigned int nfds;
55+ bool enabled;
56+} SndioVoice;
57+
58+typedef struct SndioConf {
59+ const char *devname;
60+ unsigned int latency;
61+} SndioConf;
62+
63+/* needed for forward reference */
64+static void sndio_poll_in(void *arg);
65+static void sndio_poll_out(void *arg);
66+
67+/*
68+ * stop polling descriptors
69+ */
70+static void sndio_poll_clear(SndioVoice *self)
71+{
72+ struct pollfd *pfd;
73+ int i;
74+
75+ for (i = 0; i < self->nfds; i++) {
76+ pfd = &self->pfds[i];
77+ qemu_set_fd_handler(pfd->fd, NULL, NULL, NULL);
78+ }
79+
80+ self->nfds = 0;
81+}
82+
83+/*
84+ * write data to the device until it blocks or
85+ * all of our buffered data is written
86+ */
87+static void sndio_write(SndioVoice *self)
88+{
89+ size_t todo, n;
90+
91+ todo = self->qemu_pos - self->sndio_pos;
92+
93+ /*
94+ * transfer data to device, until it blocks
95+ */
96+ while (todo > 0) {
97+ n = sio_write(self->hdl, self->buf + self->sndio_pos, todo);
98+ if (n == 0) {
99+ break;
100+ }
101+ self->sndio_pos += n;
102+ todo -= n;
103+ }
104+
105+ if (self->sndio_pos == self->buf_size) {
106+ /*
107+ * we complete the block
108+ */
109+ self->sndio_pos = 0;
110+ self->qemu_pos = 0;
111+ }
112+}
113+
114+/*
115+ * read data from the device until it blocks or
116+ * there no room any longer
117+ */
118+static void sndio_read(SndioVoice *self)
119+{
120+ size_t todo, n;
121+
122+ todo = self->buf_size - self->sndio_pos;
123+
124+ /*
125+ * transfer data from the device, until it blocks
126+ */
127+ while (todo > 0) {
128+ n = sio_read(self->hdl, self->buf + self->sndio_pos, todo);
129+ if (n == 0) {
130+ break;
131+ }
132+ self->sndio_pos += n;
133+ todo -= n;
134+ }
135+}
136+
137+/*
138+ * Set handlers for all descriptors libsndio needs to
139+ * poll
140+ */
141+static void sndio_poll_wait(SndioVoice *self)
142+{
143+ struct pollfd *pfd;
144+ int events, i;
145+
146+ events = 0;
147+ if (self->mode == SIO_PLAY) {
148+ if (self->sndio_pos < self->qemu_pos) {
149+ events |= POLLOUT;
150+ }
151+ } else {
152+ if (self->sndio_pos < self->buf_size) {
153+ events |= POLLIN;
154+ }
155+ }
156+
157+ /*
158+ * fill the given array of descriptors with the events sndio
159+ * wants, they are different from our 'event' variable because
160+ * sndio may use descriptors internally.
161+ */
162+ self->nfds = sio_pollfd(self->hdl, self->pfds, events);
163+
164+ for (i = 0; i < self->nfds; i++) {
165+ pfd = &self->pfds[i];
166+ if (pfd->fd < 0) {
167+ continue;
168+ }
169+ qemu_set_fd_handler(pfd->fd,
170+ (pfd->events & POLLIN) ? sndio_poll_in : NULL,
171+ (pfd->events & POLLOUT) ? sndio_poll_out : NULL,
172+ &self->pindexes[i]);
173+ pfd->revents = 0;
174+ }
175+}
176+
177+/*
178+ * call-back called when one of the descriptors
179+ * became readable or writable
180+ */
181+static void sndio_poll_event(SndioVoice *self, int index, int event)
182+{
183+ int revents;
184+
185+ /*
186+ * ensure we're not called twice this cycle
187+ */
188+ sndio_poll_clear(self);
189+
190+ /*
191+ * make self->pfds[] look as we're returning from poll syscal,
192+ * this is how sio_revents expects events to be.
193+ */
194+ self->pfds[index].revents = event;
195+
196+ /*
197+ * tell sndio to handle events and return whether we can read or
198+ * write without blocking.
199+ */
200+ revents = sio_revents(self->hdl, self->pfds);
201+ if (self->mode == SIO_PLAY) {
202+ if (revents & POLLOUT) {
203+ sndio_write(self);
204+ }
205+
206+ if (self->qemu_pos < self->buf_size) {
207+ audio_run(self->hw.out.s, "sndio_out");
208+ }
209+ } else {
210+ if (revents & POLLIN) {
211+ sndio_read(self);
212+ }
213+
214+ if (self->qemu_pos < self->sndio_pos) {
215+ audio_run(self->hw.in.s, "sndio_in");
216+ }
217+ }
218+
219+ /*
220+ * audio_run() may have changed state
221+ */
222+ if (self->enabled) {
223+ sndio_poll_wait(self);
224+ }
225+}
226+
227+/*
228+ * return the upper limit of the amount of free play buffer space
229+ */
230+static size_t sndio_buffer_get_free(HWVoiceOut *hw)
231+{
232+ SndioVoice *self = (SndioVoice *) hw;
233+
234+ return self->buf_size - self->qemu_pos;
235+}
236+
237+/*
238+ * return a buffer where data to play can be stored,
239+ * its size is stored in the location pointed by the size argument.
240+ */
241+static void *sndio_get_buffer_out(HWVoiceOut *hw, size_t *size)
242+{
243+ SndioVoice *self = (SndioVoice *) hw;
244+
245+ *size = self->buf_size - self->qemu_pos;
246+ return self->buf + self->qemu_pos;
247+}
248+
249+/*
250+ * return a buffer where data to play can be stored
251+ */
252+static size_t sndio_put_buffer_out(HWVoiceOut *hw, void *buf, size_t size)
253+{
254+ SndioVoice *self = (SndioVoice *) hw;
255+
256+ self->qemu_pos += size;
257+ sndio_poll_wait(self);
258+ return size;
259+}
260+
261+/*
262+ * return a buffer from where recorded data is available,
263+ * its size is stored in the location pointed by the size argument.
264+ * it may not exceed the initial value of "*size".
265+ */
266+static void *sndio_get_buffer_in(HWVoiceIn *hw, size_t *size)
267+{
268+ SndioVoice *self = (SndioVoice *) hw;
269+ size_t todo, max_todo;
270+
271+ /*
272+ * unlike the get_buffer_out() method, get_buffer_in()
273+ * must return a buffer of at most the given size, see audio.c
274+ */
275+ max_todo = *size;
276+
277+ todo = self->sndio_pos - self->qemu_pos;
278+ if (todo > max_todo) {
279+ todo = max_todo;
280+ }
281+
282+ *size = todo;
283+ return self->buf + self->qemu_pos;
284+}
285+
286+/*
287+ * discard the given amount of recorded data
288+ */
289+static void sndio_put_buffer_in(HWVoiceIn *hw, void *buf, size_t size)
290+{
291+ SndioVoice *self = (SndioVoice *) hw;
292+
293+ self->qemu_pos += size;
294+ if (self->qemu_pos == self->buf_size) {
295+ self->qemu_pos = 0;
296+ self->sndio_pos = 0;
297+ }
298+ sndio_poll_wait(self);
299+}
300+
301+/*
302+ * call-back called when one of our descriptors becomes writable
303+ */
304+static void sndio_poll_out(void *arg)
305+{
306+ struct pollindex *pindex = (struct pollindex *) arg;
307+
308+ sndio_poll_event(pindex->self, pindex->index, POLLOUT);
309+}
310+
311+/*
312+ * call-back called when one of our descriptors becomes readable
313+ */
314+static void sndio_poll_in(void *arg)
315+{
316+ struct pollindex *pindex = (struct pollindex *) arg;
317+
318+ sndio_poll_event(pindex->self, pindex->index, POLLIN);
319+}
320+
321+static void sndio_fini(SndioVoice *self)
322+{
323+ if (self->hdl) {
324+ sio_close(self->hdl);
325+ self->hdl = NULL;
326+ }
327+
328+ g_free(self->pfds);
329+ g_free(self->pindexes);
330+ g_free(self->buf);
331+}
332+
333+static int sndio_init(SndioVoice *self,
334+ struct audsettings *as, int mode, Audiodev *dev)
335+{
336+ AudiodevSndioOptions *opts = &dev->u.sndio;
337+ unsigned long long latency;
338+ const char *dev_name;
339+ struct sio_par req;
340+ unsigned int nch;
341+ int i, nfds;
342+
343+ dev_name = opts->has_dev ? opts->dev : SIO_DEVANY;
344+ latency = opts->has_latency ? opts->latency : SNDIO_LATENCY_US;
345+
346+ /* open the device in non-blocking mode */
347+ self->hdl = sio_open(dev_name, mode, 1);
348+ if (self->hdl == NULL) {
349+ dolog("failed to open device\n");
350+ return -1;
351+ }
352+
353+ self->mode = mode;
354+
355+ sio_initpar(&req);
356+
357+ switch (as->fmt) {
358+ case AUDIO_FORMAT_S8:
359+ req.bits = 8;
360+ req.sig = 1;
361+ break;
362+ case AUDIO_FORMAT_U8:
363+ req.bits = 8;
364+ req.sig = 0;
365+ break;
366+ case AUDIO_FORMAT_S16:
367+ req.bits = 16;
368+ req.sig = 1;
369+ break;
370+ case AUDIO_FORMAT_U16:
371+ req.bits = 16;
372+ req.sig = 0;
373+ break;
374+ case AUDIO_FORMAT_S32:
375+ req.bits = 32;
376+ req.sig = 1;
377+ break;
378+ case AUDIO_FORMAT_U32:
379+ req.bits = 32;
380+ req.sig = 0;
381+ break;
382+ default:
383+ dolog("unknown audio sample format\n");
384+ return -1;
385+ }
386+
387+ if (req.bits > 8) {
388+ req.le = as->endianness ? 0 : 1;
389+ }
390+
391+ req.rate = as->freq;
392+ if (mode == SIO_PLAY) {
393+ req.pchan = as->nchannels;
394+ } else {
395+ req.rchan = as->nchannels;
396+ }
397+
398+ /* set on-device buffer size */
399+ req.appbufsz = req.rate * latency / 1000000;
400+
401+ if (!sio_setpar(self->hdl, &req)) {
402+ dolog("failed set audio params\n");
403+ goto fail;
404+ }
405+
406+ if (!sio_getpar(self->hdl, &self->par)) {
407+ dolog("failed get audio params\n");
408+ goto fail;
409+ }
410+
411+ nch = (mode == SIO_PLAY) ? self->par.pchan : self->par.rchan;
412+
413+ /*
414+ * With the default setup, sndio supports any combination of parameters
415+ * so these checks are mostly to catch configuration errors.
416+ */
417+ if (self->par.bits != req.bits || self->par.bps != req.bits / 8 ||
418+ self->par.sig != req.sig || (req.bits > 8 && self->par.le != req.le) ||
419+ self->par.rate != as->freq || nch != as->nchannels) {
420+ dolog("unsupported audio params\n");
421+ goto fail;
422+ }
423+
424+ /*
425+ * we use one block as buffer size; this is how
426+ * transfers get well aligned
427+ */
428+ self->buf_size = self->par.round * self->par.bps * nch;
429+
430+ self->buf = g_malloc(self->buf_size);
431+ if (self->buf == NULL) {
432+ dolog("failed to allocate audio buffer\n");
433+ goto fail;
434+ }
435+
436+ nfds = sio_nfds(self->hdl);
437+
438+ self->pfds = g_malloc_n(nfds, sizeof(struct pollfd));
439+ if (self->pfds == NULL) {
440+ dolog("failed to allocate pollfd structures\n");
441+ goto fail;
442+ }
443+
444+ self->pindexes = g_malloc_n(nfds, sizeof(struct pollindex));
445+ if (self->pindexes == NULL) {
446+ dolog("failed to allocate pollindex structures\n");
447+ goto fail;
448+ }
449+
450+ for (i = 0; i < nfds; i++) {
451+ self->pindexes[i].self = self;
452+ self->pindexes[i].index = i;
453+ }
454+
455+ return 0;
456+fail:
457+ sndio_fini(self);
458+ return -1;
459+}
460+
461+static void sndio_enable(SndioVoice *self, bool enable)
462+{
463+ if (enable) {
464+ sio_start(self->hdl);
465+ self->enabled = true;
466+ sndio_poll_wait(self);
467+ } else {
468+ self->enabled = false;
469+ sndio_poll_clear(self);
470+ sio_stop(self->hdl);
471+ }
472+}
473+
474+static void sndio_enable_out(HWVoiceOut *hw, bool enable)
475+{
476+ SndioVoice *self = (SndioVoice *) hw;
477+
478+ sndio_enable(self, enable);
479+}
480+
481+static void sndio_enable_in(HWVoiceIn *hw, bool enable)
482+{
483+ SndioVoice *self = (SndioVoice *) hw;
484+
485+ sndio_enable(self, enable);
486+}
487+
488+static int sndio_init_out(HWVoiceOut *hw, struct audsettings *as, void *opaque)
489+{
490+ SndioVoice *self = (SndioVoice *) hw;
491+
492+ if (sndio_init(self, as, SIO_PLAY, opaque) == -1) {
493+ return -1;
494+ }
495+
496+ audio_pcm_init_info(&hw->info, as);
497+ hw->samples = self->par.round;
498+ return 0;
499+}
500+
501+static int sndio_init_in(HWVoiceIn *hw, struct audsettings *as, void *opaque)
502+{
503+ SndioVoice *self = (SndioVoice *) hw;
504+
505+ if (sndio_init(self, as, SIO_REC, opaque) == -1) {
506+ return -1;
507+ }
508+
509+ audio_pcm_init_info(&hw->info, as);
510+ hw->samples = self->par.round;
511+ return 0;
512+}
513+
514+static void sndio_fini_out(HWVoiceOut *hw)
515+{
516+ SndioVoice *self = (SndioVoice *) hw;
517+
518+ sndio_fini(self);
519+}
520+
521+static void sndio_fini_in(HWVoiceIn *hw)
522+{
523+ SndioVoice *self = (SndioVoice *) hw;
524+
525+ sndio_fini(self);
526+}
527+
528+static void *sndio_audio_init(Audiodev *dev)
529+{
530+ assert(dev->driver == AUDIODEV_DRIVER_SNDIO);
531+ return dev;
532+}
533+
534+static void sndio_audio_fini(void *opaque)
535+{
536+}
537+
538+static struct audio_pcm_ops sndio_pcm_ops = {
539+ .init_out = sndio_init_out,
540+ .fini_out = sndio_fini_out,
541+ .enable_out = sndio_enable_out,
542+ .write = audio_generic_write,
543+ .buffer_get_free = sndio_buffer_get_free,
544+ .get_buffer_out = sndio_get_buffer_out,
545+ .put_buffer_out = sndio_put_buffer_out,
546+ .init_in = sndio_init_in,
547+ .fini_in = sndio_fini_in,
548+ .read = audio_generic_read,
549+ .enable_in = sndio_enable_in,
550+ .get_buffer_in = sndio_get_buffer_in,
551+ .put_buffer_in = sndio_put_buffer_in,
552+};
553+
554+static struct audio_driver sndio_audio_driver = {
555+ .name = "sndio",
556+ .descr = "sndio https://sndio.org",
557+ .init = sndio_audio_init,
558+ .fini = sndio_audio_fini,
559+ .pcm_ops = &sndio_pcm_ops,
560+ .can_be_default = 1,
561+ .max_voices_out = INT_MAX,
562+ .max_voices_in = INT_MAX,
563+ .voice_size_out = sizeof(SndioVoice),
564+ .voice_size_in = sizeof(SndioVoice)
565+};
566+
567+static void register_audio_sndio(void)
568+{
569+ audio_driver_register(&sndio_audio_driver);
570+}
571+
572+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 @@
1Revert..
2
3[PATCH] configure: simplify creation of plugin symbol list
437650689473c4cdb5838f90cbc1aefbcd9332fb0
5
6Index: configure
7--- configure.orig
8+++ configure
9@@ -77,6 +77,7 @@ TMPC="${TMPDIR1}/${TMPB}.c"
10 TMPO="${TMPDIR1}/${TMPB}.o"
11 TMPM="${TMPDIR1}/${TMPB}.m"
12 TMPE="${TMPDIR1}/${TMPB}.exe"
13+TMPTXT="${TMPDIR1}/${TMPB}.txt"
14
15 rm -f config.log
16
17@@ -1314,7 +1315,6 @@ if test "$static" = "yes" ; then
18 plugins="no"
19 fi
20 fi
21-test "$plugins" = "" && plugins=yes
22
23 cat > $TMPC << EOF
24
25@@ -1459,6 +1459,56 @@ if ! has "$pkg_config_exe"; then
26 fi
27
28 ##########################################
29+# plugin linker support probe
30+
31+if test "$plugins" != "no"; then
32+
33+ #########################################
34+ # See if --dynamic-list is supported by the linker
35+
36+ ld_dynamic_list="no"
37+ cat > $TMPTXT <<EOF
38+{
39+ foo;
40+};
41+EOF
42+
43+ cat > $TMPC <<EOF
44+#include <stdio.h>
45+void foo(void);
46+
47+void foo(void)
48+{
49+ printf("foo\n");
50+}
51+
52+int main(void)
53+{
54+ foo();
55+ return 0;
56+}
57+EOF
58+
59+ if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then
60+ ld_dynamic_list="yes"
61+ fi
62+
63+ if test "$ld_dynamic_list" = "no" ; then
64+ if test "$plugins" = "yes"; then
65+ error_exit \
66+ "Plugin support requires dynamic linking and specifying a set of symbols " \
67+ "that are exported to plugins. Unfortunately your linker doesn't " \
68+ "support the flag (--dynamic-list) used " \
69+ "for this purpose."
70+ else
71+ plugins="no"
72+ fi
73+ else
74+ plugins="yes"
75+ fi
76+fi
77+
78+##########################################
79 # glib support probe
80
81 # When bumping glib_req_ver, please check also whether we should increase
82@@ -2390,6 +2440,15 @@ fi
83
84 if test "$plugins" = "yes" ; then
85 echo "CONFIG_PLUGIN=y" >> $config_host_mak
86+ # Copy the export object list to the build dir
87+ if test "$ld_dynamic_list" = "yes" ; then
88+ echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak
89+ ld_symbols=qemu-plugins-ld.symbols
90+ cp "$source_path/plugins/qemu-plugins.symbols" $ld_symbols
91+ else
92+ error_exit \
93+ "If \$plugins=yes, \$ld_dynamic_list should have been set to 'yes'."
94+ fi
95 fi
96
97 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 @@
1- localstatedir does not belong under prefix
2- Remove hardcoding of optimization
3- thread-posix: add support for setting threads name on OpenBSD
4
5Index: meson.build
6--- meson.build.orig
7+++ meson.build
8@@ -75,7 +75,7 @@ have_tools = get_option('tools') \
9 .allowed()
10 have_ga = get_option('guest_agent') \
11 .disable_auto_if(not have_system and not have_tools) \
12- .require(targetos in ['sunos', 'linux', 'windows', 'freebsd'],
13+ .require(targetos in ['sunos', 'linux', 'windows', 'freebsd', 'openbsd'],
14 error_message: 'unsupported OS for QEMU guest agent') \
15 .allowed()
16 have_block = have_system or have_tools
17@@ -1790,7 +1790,7 @@ config_host_data.set('CONFIG_QEMU_FIRMWAREPATH', qemu_
18 config_host_data.set_quoted('CONFIG_QEMU_HELPERDIR', get_option('prefix') / get_option('libexecdir'))
19 config_host_data.set_quoted('CONFIG_QEMU_ICONDIR', get_option('prefix') / qemu_icondir)
20 config_host_data.set_quoted('CONFIG_QEMU_LOCALEDIR', get_option('prefix') / get_option('localedir'))
21-config_host_data.set_quoted('CONFIG_QEMU_LOCALSTATEDIR', get_option('prefix') / get_option('localstatedir'))
22+config_host_data.set_quoted('CONFIG_QEMU_LOCALSTATEDIR', get_option('localstatedir'))
23 config_host_data.set_quoted('CONFIG_QEMU_MODDIR', get_option('prefix') / qemu_moddir)
24 config_host_data.set_quoted('CONFIG_SYSCONFDIR', get_option('prefix') / get_option('sysconfdir'))
25
26@@ -2123,6 +2123,18 @@ config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_WO_TID
27 pthread_create(&thread, 0, f, 0);
28 return 0;
29 }''', dependencies: threads))
30+config_host_data.set('CONFIG_PTHREAD_SET_NAME_NP', cc.links(gnu_source_prefix + '''
31+ #include <pthread.h>
32+ #include <pthread_np.h>
33+
34+ static void *f(void *p) { return NULL; }
35+ int main(void)
36+ {
37+ pthread_t thread;
38+ pthread_create(&thread, 0, f, 0);
39+ pthread_set_name_np(thread, "QEMU");
40+ return 0;
41+ }''', dependencies: threads))
42 config_host_data.set('CONFIG_PTHREAD_CONDATTR_SETCLOCK', cc.links(gnu_source_prefix + '''
43 #include <pthread.h>
44 #include <time.h>
45@@ -3756,11 +3768,9 @@ if targetos == 'darwin'
46 summary_info += {'Objective-C compiler': ' '.join(meson.get_compiler('objc').cmd_array())}
47 endif
48 summary_info += {'CFLAGS': ' '.join(get_option('c_args')
49- + ['-O' + get_option('optimization')]
50 + (get_option('debug') ? ['-g'] : []))}
51 if link_language == 'cpp'
52 summary_info += {'CXXFLAGS': ' '.join(get_option('cpp_args')
53- + ['-O' + get_option('optimization')]
54 + (get_option('debug') ? ['-g'] : []))}
55 endif
56 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 @@
1Index: meson/mesonbuild/compilers/cpp.py
2--- meson/mesonbuild/compilers/cpp.py.orig
3+++ meson/mesonbuild/compilers/cpp.py
4@@ -254,7 +254,7 @@ class ClangCPPCompiler(ClangCompiler, CPPCompiler):
5 search_dirs: T.List[str] = []
6 for d in self.get_compiler_dirs(env, 'libraries'):
7 search_dirs.append(f'-L{d}')
8- return search_dirs + ['-lstdc++']
9+ return search_dirs + ['-lc++']
10
11
12 class AppleClangCPPCompiler(ClangCPPCompiler):
13@@ -418,7 +418,7 @@ class GnuCPPCompiler(GnuCompiler, CPPCompiler):
14 search_dirs: T.List[str] = []
15 for d in self.get_compiler_dirs(env, 'libraries'):
16 search_dirs.append(f'-L{d}')
17- return ['-lstdc++']
18+ return ['-lestdc++']
19
20
21 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 @@
1sndio module
2
3Index: meson_options.txt
4--- meson_options.txt.orig
5+++ meson_options.txt
6@@ -21,7 +21,7 @@ option('tls_priority', type : 'string', value : 'NORMA
7 option('default_devices', type : 'boolean', value : true,
8 description: 'Include a default selection of devices in emulators')
9 option('audio_drv_list', type: 'array', value: ['default'],
10- choices: ['alsa', 'coreaudio', 'default', 'dsound', 'jack', 'oss', 'pa', 'sdl'],
11+ choices: ['alsa', 'coreaudio', 'default', 'dsound', 'jack', 'oss', 'pa', 'sdl', 'sndio'],
12 description: 'Set audio driver list')
13 option('block_drv_rw_whitelist', type : 'string', value : '',
14 description: 'set block driver read-write whitelist (by default affects only QEMU, not tools like qemu-img)')
15@@ -240,6 +240,8 @@ option('oss', type: 'feature', value: 'auto',
16 description: 'OSS sound support')
17 option('pa', type: 'feature', value: 'auto',
18 description: 'PulseAudio sound support')
19+option('sndio', type: 'feature', value: 'auto',
20+ description: 'sndio sound support')
21
22 option('vhost_kernel', type: 'feature', value: 'auto',
23 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 @@
1Revert..
2
3[PATCH] configure: simplify creation of plugin symbol list
437650689473c4cdb5838f90cbc1aefbcd9332fb0
5
6Index: plugins/meson.build
7--- plugins/meson.build.orig
8+++ plugins/meson.build
9@@ -1,15 +1,8 @@
10 plugin_ldflags = []
11 # Modules need more symbols than just those in plugins/qemu-plugins.symbols
12 if not enable_modules
13- if targetos == 'darwin'
14- configure_file(
15- input: files('qemu-plugins.symbols'),
16- output: 'qemu-plugins-ld64.symbols',
17- capture: true,
18- command: ['sed', '-ne', 's/^[[:space:]]*\\(qemu_.*\\);/_\\1/p', '@INPUT@'])
19- plugin_ldflags = ['-Wl,-exported_symbols_list,plugins/qemu-plugins-ld64.symbols']
20- else
21- plugin_ldflags = ['-Xlinker', '--dynamic-list=' + (meson.project_source_root() / 'plugins/qemu-plugins.symbols')]
22+ if 'CONFIG_HAS_LD_DYNAMIC_LIST' in config_host
23+ plugin_ldflags = ['-Wl,--dynamic-list=qemu-plugins-ld.symbols']
24 endif
25 endif
26
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 @@
1sndio module
2
3Index: qapi/audio.json
4--- qapi/audio.json.orig
5+++ qapi/audio.json
6@@ -107,6 +107,28 @@
7 '*threshold': 'uint32' } }
8
9 ##
10+# @AudiodevSndioOptions:
11+#
12+# Options of the sndio audio backend.
13+#
14+# @in: options of the capture stream
15+#
16+# @out: options of the playback stream
17+#
18+# @dev: the name of the sndio device to use (default 'default')
19+#
20+# @latency: play buffer size (in microseconds)
21+#
22+# Since: 7.2
23+##
24+{ 'struct': 'AudiodevSndioOptions',
25+ 'data': {
26+ '*in': 'AudiodevPerDirectionOptions',
27+ '*out': 'AudiodevPerDirectionOptions',
28+ '*dev': 'str',
29+ '*latency': 'uint32'} }
30+
31+##
32 # @AudiodevCoreaudioPerDirectionOptions:
33 #
34 # Options of the Core Audio backend that are used for both playback and
35@@ -387,7 +409,7 @@
36 ##
37 { 'enum': 'AudiodevDriver',
38 'data': [ 'none', 'alsa', 'coreaudio', 'dbus', 'dsound', 'jack', 'oss', 'pa',
39- 'sdl', 'spice', 'wav' ] }
40+ 'sdl', 'sndio', 'spice', 'wav' ] }
41
42 ##
43 # @Audiodev:
44@@ -418,5 +440,6 @@
45 'oss': 'AudiodevOssOptions',
46 'pa': 'AudiodevPaOptions',
47 'sdl': 'AudiodevSdlOptions',
48+ 'sndio': 'AudiodevSndioOptions',
49 'spice': 'AudiodevGenericOptions',
50 '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 @@
1sndio module
2
3Index: qemu-options.hx
4--- qemu-options.hx.orig
5+++ qemu-options.hx
6@@ -767,6 +767,9 @@ DEF("audiodev", HAS_ARG, QEMU_OPTION_audiodev,
7 "-audiodev sdl,id=id[,prop[=value][,...]]\n"
8 " in|out.buffer-count= number of buffers\n"
9 #endif
10+#ifdef CONFIG_AUDIO_SNDIO
11+ "-audiodev sndio,id=id[,prop[=value][,...]]\n"
12+#endif
13 #ifdef CONFIG_SPICE
14 "-audiodev spice,id=id[,prop[=value][,...]]\n"
15 #endif
16@@ -932,6 +935,19 @@ SRST
17
18 ``in|out.buffer-count=count``
19 Sets the count of the buffers.
20+
21+``-audiodev sndio,id=id[,prop[=value][,...]]``
22+ Creates a backend using SNDIO. This backend is available on
23+ OpenBSD and most other Unix-like systems.
24+
25+ Sndio specific options are:
26+
27+ ``in|out.dev=device``
28+ Specify the sndio device to use for input and/or output. Default
29+ is ``default``.
30+
31+ ``in|out.latency=usecs``
32+ Sets the desired period length in microseconds.
33
34 ``-audiodev spice,id=id[,prop[=value][,...]]``
35 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 @@
1Index: qga/commands-bsd.c
2--- qga/commands-bsd.c.orig
3+++ qga/commands-bsd.c
4@@ -21,7 +21,12 @@
5 #include <sys/ucred.h>
6 #include <sys/mount.h>
7 #include <net/if_dl.h>
8+#ifdef __OpenBSD__
9+#include <net/if_arp.h>
10+#include <netinet/if_ether.h>
11+#else
12 #include <net/ethernet.h>
13+#endif
14 #include <paths.h>
15
16 #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 @@
1Adapted from https://github.com/aborche/qemu-guest-agent
2
3Adds support for
4"guest-get-fsinfo"
5"guest-get-vcpus"
6"guest-network-get-interfaces"
7and guest shutdown from host.
8
9Setting user password is not supported on OpenBSD.
10
11Index: qga/commands-posix.c
12--- qga/commands-posix.c.orig
13+++ qga/commands-posix.c
14@@ -45,13 +45,23 @@
15 #include <arpa/inet.h>
16 #include <sys/socket.h>
17 #include <net/if.h>
18+#ifdef __OpenBSD__
19+#include <net/if_arp.h>
20+#include <netinet/if_ether.h>
21+#else
22 #include <net/ethernet.h>
23+#endif
24 #include <sys/types.h>
25 #ifdef CONFIG_SOLARIS
26 #include <sys/sockio.h>
27 #endif
28 #endif
29
30+#ifdef __OpenBSD__
31+#include <sys/sysctl.h>
32+#include <sys/statvfs.h>
33+#endif
34+
35 static void ga_wait_child(pid_t pid, int *status, Error **errp)
36 {
37 pid_t rpid;
38@@ -2232,12 +2242,118 @@ out:
39 close(datafd[1]);
40 }
41 }
42-#else /* __linux__ || __FreeBSD__ */
43+#elif defined(__OpenBSD__) /* __linux__ || __FreeBSD__ */
44 void qmp_guest_set_user_password(const char *username,
45 const char *password,
46 bool crypted,
47 Error **errp)
48 {
49+ Error *local_err = NULL;
50+ char *pw_path = NULL;
51+ pid_t pid;
52+ int status;
53+ int datafd[2] = { -1, -1 };
54+ char *rawpasswddata = NULL;
55+ size_t rawpasswdlen;
56+ char *chpasswddata = NULL;
57+ size_t chpasswdlen;
58+
59+ rawpasswddata = (char *)qbase64_decode(password, -1, &rawpasswdlen, errp);
60+ if (!rawpasswddata) {
61+ return;
62+ }
63+
64+ rawpasswddata = g_renew(char, rawpasswddata, rawpasswdlen + 1);
65+ rawpasswddata[rawpasswdlen] = '\0';
66+
67+ if (strchr(rawpasswddata, '\n')) {
68+ error_setg(errp, "forbidden characters in raw password");
69+ goto out;
70+ }
71+
72+ if (strchr(username, '\n') ||
73+ strchr(username, ':')) {
74+ error_setg(errp, "forbidden characters in username");
75+ goto out;
76+ }
77+
78+ chpasswddata = g_strdup_printf("%s", rawpasswddata);
79+ chpasswdlen = strlen(chpasswddata);
80+
81+ pw_path = g_find_program_in_path("pw");
82+
83+ if (!pw_path) {
84+ error_setg(errp, "cannot find 'pw' program in PATH");
85+ goto out;
86+ }
87+
88+ if (pipe(datafd) < 0) {
89+ error_setg(errp, "cannot create pipe FDs");
90+ goto out;
91+ }
92+
93+ pid = fork();
94+ if (pid == 0) {
95+ close(datafd[1]);
96+ /* child */
97+ setsid();
98+ dup2(datafd[0], 0);
99+ reopen_fd_to_null(1);
100+ reopen_fd_to_null(2);
101+
102+ if (crypted) {
103+ execl(pw_path, "pw", "usermod", username, "-H", "0", (char*)NULL);
104+ } else {
105+ execl(pw_path, "pw", "usermod", username, "-h", "0", (char*)NULL);
106+ }
107+ _exit(EXIT_FAILURE);
108+ } else if (pid < 0) {
109+ error_setg_errno(errp, errno, "failed to create child process");
110+ goto out;
111+ }
112+ close(datafd[0]);
113+ datafd[0] = -1;
114+
115+ if (qemu_write_full(datafd[1], chpasswddata, chpasswdlen) != chpasswdlen) {
116+ error_setg_errno(errp, errno, "cannot write new account password");
117+ goto out;
118+ }
119+ close(datafd[1]);
120+ datafd[1] = -1;
121+
122+ ga_wait_child(pid, &status, &local_err);
123+ if (local_err) {
124+ error_propagate(errp, local_err);
125+ goto out;
126+ }
127+
128+ if (!WIFEXITED(status)) {
129+ error_setg(errp, "child process has terminated abnormally");
130+ goto out;
131+ }
132+
133+ if (WEXITSTATUS(status)) {
134+ error_setg(errp, "child process has failed to set user password");
135+ goto out;
136+ }
137+
138+out:
139+ g_free(chpasswddata);
140+ g_free(rawpasswddata);
141+ g_free(pw_path);
142+ if (datafd[0] != -1) {
143+ close(datafd[0]);
144+ }
145+ if (datafd[1] != -1) {
146+ close(datafd[1]);
147+ }
148+}
149+#else /* __OpenBSD__ */
150+void qmp_guest_set_user_password(const char *username,
151+ const char *password,
152+ bool crypted,
153+ Error **errp)
154+{
155 error_setg(errp, QERR_UNSUPPORTED);
156 }
157 #endif /* __linux__ || __FreeBSD__ */
158@@ -2750,7 +2866,7 @@ GuestCpuStatsList *qmp_guest_get_cpustats(Error **errp
159 return head;
160 }
161
162-#else /* defined(__linux__) */
163+#elif defined(CONFIG_BSD)
164
165 void qmp_guest_suspend_disk(Error **errp)
166 {
167@@ -2769,10 +2885,103 @@ void qmp_guest_suspend_hybrid(Error **errp)
168
169 GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp)
170 {
171+ int64_t current;
172+ GuestLogicalProcessorList *head, **link;
173+ long sc_max;
174+ Error *local_err = NULL;
175+ int Query[2];
176+ int NumCpu = 0;
177+ size_t Length = sizeof(NumCpu);
178+
179+ Query[0] = CTL_HW;
180+#ifdef HW_NCPUONLINE
181+ Query[1] = HW_NCPUONLINE;
182+#else
183+ Query[1] = HW_NCPU;
184+#endif
185+
186+ current = 0;
187+ head = NULL;
188+ link = &head;
189+ if (sysctl(Query, 2, &NumCpu, &Length, NULL, 0) == -1) {
190+ error_setg(errp, "sysctl get CTL_HW.HW_NCPU failed");
191+ }
192+ sc_max = NumCpu;
193+
194+ while (local_err == NULL && current < sc_max) {
195+ GuestLogicalProcessor *vcpu;
196+ GuestLogicalProcessorList *entry;
197+ int64_t id = current++;
198+ vcpu = g_malloc0(sizeof *vcpu);
199+ vcpu->logical_id = id;
200+ vcpu->has_can_offline = false; /* lolspeak ftw */
201+ vcpu->online = true;
202+ vcpu->can_offline = false;
203+ entry = g_malloc0(sizeof *entry);
204+ entry->value = vcpu;
205+ *link = entry;
206+ link = &entry->next;
207+ }
208+
209+ if (local_err == NULL) {
210+ /* there's no guest with zero VCPUs */
211+ g_assert(head != NULL);
212+ return head;
213+ }
214+
215+ qapi_free_GuestLogicalProcessorList(head);
216+ error_propagate(errp, local_err);
217+ return NULL;
218+}
219+
220+int64_t qmp_guest_set_vcpus(GuestLogicalProcessorList *vcpus, Error **errp)
221+{
222 error_setg(errp, QERR_UNSUPPORTED);
223+ return -1;
224+}
225+
226+GuestMemoryBlockList *qmp_guest_get_memory_blocks(Error **errp)
227+{
228+ error_setg(errp, QERR_UNSUPPORTED);
229 return NULL;
230 }
231
232+GuestMemoryBlockResponseList *
233+qmp_guest_set_memory_blocks(GuestMemoryBlockList *mem_blks, Error **errp)
234+{
235+ error_setg(errp, QERR_UNSUPPORTED);
236+ return NULL;
237+}
238+
239+GuestMemoryBlockInfo *qmp_guest_get_memory_block_info(Error **errp)
240+{
241+ error_setg(errp, QERR_UNSUPPORTED);
242+ return NULL;
243+}
244+
245+#else /* defined(CONFIG_BSD) */
246+
247+void qmp_guest_suspend_disk(Error **errp)
248+{
249+ error_setg(errp, QERR_UNSUPPORTED);
250+}
251+
252+void qmp_guest_suspend_ram(Error **errp)
253+{
254+ error_setg(errp, QERR_UNSUPPORTED);
255+}
256+
257+void qmp_guest_suspend_hybrid(Error **errp)
258+{
259+ error_setg(errp, QERR_UNSUPPORTED);
260+}
261+
262+GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp)
263+{
264+ error_setg(errp, QERR_UNSUPPORTED);
265+ return NULL;
266+}
267+
268 int64_t qmp_guest_set_vcpus(GuestLogicalProcessorList *vcpus, Error **errp)
269 {
270 error_setg(errp, QERR_UNSUPPORTED);
271@@ -2881,7 +3090,7 @@ static int guest_get_network_stats(const char *name,
272 return -1;
273 }
274
275-#ifndef __FreeBSD__
276+#ifndef CONFIG_BSD
277 /*
278 * Fill "buf" with MAC address by ifaddrs. Pointer buf must point to a
279 * buffer with ETHER_ADDR_LEN length at least.
280@@ -2930,7 +3139,7 @@ bool guest_get_hw_addr(struct ifaddrs *ifa, unsigned c
281 close(sock);
282 return true;
283 }
284-#endif /* __FreeBSD__ */
285+#endif /* CONFIG_BSD */
286
287 /*
288 * Build information about guest interfaces
289@@ -3070,11 +3279,245 @@ GuestNetworkInterfaceList *qmp_guest_network_get_inter
290
291 #if !defined(CONFIG_FSFREEZE)
292
293+#ifdef CONFIG_BSD
294+typedef struct FsMount {
295+ char *dirname;
296+ char *devtype;
297+ char *size;
298+ char *used;
299+ char *free;
300+ char *load;
301+ char *mntpoint;
302+ unsigned int devmajor, devminor;
303+ QTAILQ_ENTRY(FsMount) next;
304+} FsMount;
305+
306+typedef QTAILQ_HEAD(FsMountList, FsMount) FsMountList;
307+
308+static void free_fs_mount_list(FsMountList *mounts)
309+{
310+ FsMount *mount, *temp;
311+
312+ if (!mounts) {
313+ return;
314+ }
315+
316+ QTAILQ_FOREACH_SAFE(mount, mounts, next, temp) {
317+ QTAILQ_REMOVE(mounts, mount, next);
318+ g_free(mount->dirname);
319+ g_free(mount->devtype);
320+ g_free(mount->size);
321+ g_free(mount->used);
322+ g_free(mount->free);
323+ g_free(mount->load);
324+ g_free(mount->mntpoint);
325+ g_free(mount);
326+ }
327+}
328+
329+static void build_fs_mount_list(FsMountList *mounts, Error **errp)
330+{
331+ FsMount *mount;
332+#ifdef __OpenBSD__
333+ char const *dfcmd = "/bin/df";
334+#else // defined(__OpenBSD__)
335+ char const *dfcmd = "/bin/df -hT";
336+#endif // defined(__OpenBSD__)
337+
338+ FILE *fp;
339+ char *line = NULL;
340+ size_t n;
341+ int ret;
342+ char dev_name[128], size[12], used[12], free[12], load[10], mounted[128];
343+#ifndef __OpenBSD__
344+ char fstype[12] = "";
345+#endif // !defined(__OpenBSD__)
346+
347+ if ((fp = popen(dfcmd, "r")) == NULL) {
348+ g_debug("Cannot open '%s'!!\n", dfcmd);
349+ error_setg_errno(errp, errno,
350+ "failed to create child process for command: %s",
351+ dfcmd);
352+ return;
353+ }
354+
355+ while (getline(&line, &n, fp) != -1) {
356+ //g_debug("line '%s'", line);
357+#ifdef __OpenBSD__
358+ ret = sscanf(line, "%127s%11s%11s%11s%9s%127s",
359+ dev_name, size, used, free, load, mounted);
360+#else // defined(__OpenBSD__)
361+ ret = sscanf(line, "%127s%11s%11s%11s%11s%9s%127s",
362+ dev_name, fstype, size, used, free, load, mounted);
363+ //g_debug("ret %d, dev_name '%s', fstype '%s', size '%s', used '%s', free '%s', load '%s', mounted '%s'",
364+ // ret, dev_name, fstype, size, used, free, load, mounted);
365+#endif // defined(__OpenBSD__)
366+ if (g_str_equal(dev_name, "Filesystem")
367+#ifndef __OpenBSD__
368+ ||g_str_equal(fstype,"devfs")
369+ ||g_str_equal(fstype,"procfs")
370+ ||g_str_equal(fstype,"fdescfs")
371+#endif // !defined(__OpenBSD__)
372+ ) {
373+ continue;
374+ }
375+
376+#ifdef __OpenBSD__
377+ if (ret < 6) {
378+#else // defined(__OpenBSD__)
379+ if (ret < 7) {
380+#endif // defined(__OpenBSD__)
381+ continue;
382+ }
383+
384+ mount = g_new0(FsMount, 1);
385+ mount->dirname = g_strdup(dev_name);
386+#ifndef __OpenBSD__
387+ mount->devtype = g_strdup(fstype);
388+#endif // defined(__OpenBSD__)
389+ mount->free = g_strdup(free);
390+ mount->load = g_strdup(load);
391+ mount->size = g_strdup(size);
392+ mount->used = g_strdup(used);
393+ mount->mntpoint = g_strdup(mounted);
394+ mount->devmajor = 0;
395+ mount->devminor = 0;
396+
397+ QTAILQ_INSERT_TAIL(mounts, mount, next);
398+ }
399+ g_free(line);
400+
401+ fclose(fp);
402+}
403+
404+#ifdef __OpenBSD__
405+
406+static void add_type_fs_mount_list(FsMountList *mounts, Error **errp)
407+{
408+ FILE *fp;
409+ char const *mountcmd = "/sbin/mount";
410+ char *line = NULL;
411+ size_t n;
412+ int ret;
413+ char mnt_fsname[128], mnt_dir[128], mnt_type[32], mnt_opts[128];
414+ struct FsMount *mount;
415+
416+ // get mounts from mount command
417+ if ((fp = popen(mountcmd, "r")) == NULL) {
418+ g_debug("Cannot open '%s'!!\n", mountcmd);
419+ error_setg_errno(errp, errno, "failed to create child process for command: %s", mountcmd);
420+ return;
421+ }
422+
423+ // loop through mounts from mount command
424+ while (getline(&line, &n, fp) != -1) {
425+ //g_debug("line '%s'", line);
426+
427+ ret = sscanf(line, "%127s on %127s type %31s (%127s)",
428+ mnt_fsname, mnt_dir, mnt_type, mnt_opts);
429+ //g_debug("ret %d, fsname '%s', dir '%s', type '%s', opts '%s'",
430+ // ret, mnt_fsname, mnt_dir, mnt_type, mnt_opts);
431+
432+ if (4 != ret ||
433+ '/' != mnt_fsname[0] ||
434+ '/' != mnt_dir[0] ||
435+ g_str_equal("smbfs", mnt_type) ||
436+ g_str_equal("cifs", mnt_type)) {
437+ continue;
438+ }
439+
440+ // find mount in supplied mounts list and update device type
441+ QTAILQ_FOREACH(mount, mounts, next) {
442+ if (NULL == mount->devtype && g_str_equal(mount->dirname, mnt_fsname)) {
443+ mount->devtype = g_strdup(mnt_type);
444+ break;
445+ }
446+ }
447+ }
448+ g_free(line);
449+
450+ fclose(fp);
451+}
452+
453+#endif // defined(__OpenBSD__)
454+
455+/* Return a list of the disk device(s)' info which @mount lies on */
456+static GuestFilesystemInfo *build_guest_fsinfo(struct FsMount *mount,
457+ Error **errp)
458+{
459+ GuestFilesystemInfo *fs = g_malloc0(sizeof(*fs));
460+ struct statvfs buf;
461+ unsigned long used, nonroot_total, fr_size;
462+
463+ fs->name = g_strdup(mount->dirname);
464+ fs->mountpoint = g_strdup(mount->mntpoint);
465+ fs->type = g_strdup(mount->devtype);
466+
467+ if (statvfs(fs->mountpoint, &buf) == 0) {
468+ fr_size = buf.f_frsize;
469+ used = buf.f_blocks - buf.f_bfree;
470+ nonroot_total = used + buf.f_bavail;
471+ fs->used_bytes = used * fr_size;
472+ fs->total_bytes = nonroot_total * fr_size;
473+
474+ fs->has_total_bytes = true;
475+ fs->has_used_bytes = true;
476+ }
477+
478+ //g_free(devpath);
479+
480+ return fs;
481+}
482+
483 GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp)
484 {
485+ FsMountList mounts;
486+ struct FsMount *mount;
487+ GuestFilesystemInfoList *new, *ret = NULL;
488+ Error *local_err = NULL;
489+
490+ QTAILQ_INIT(&mounts);
491+
492+ g_debug("Entering to guest_get_fsinfo");
493+ build_fs_mount_list(&mounts, &local_err);
494+ if (local_err) {
495+ error_propagate(errp, local_err);
496+ return NULL;
497+ }
498+
499+#ifdef __OpenBSD__
500+ add_type_fs_mount_list(&mounts, &local_err);
501+ if (local_err) {
502+ error_propagate(errp, local_err);
503+ return NULL;
504+ }
505+#endif // defined(__OpenBSD__)
506+
507+ QTAILQ_FOREACH(mount, &mounts, next) {
508+ //g_debug("Building guest fsinfo for '%s'", mount->dirname);
509+ //g_debug("Devtype '%s'", mount->devtype);
510+ new = g_malloc0(sizeof(*ret));
511+ new->value = build_guest_fsinfo(mount, &local_err);
512+ new->next = ret;
513+ ret = new;
514+ if (local_err) {
515+ error_propagate(errp, local_err);
516+ qapi_free_GuestFilesystemInfoList(ret);
517+ ret = NULL;
518+ break;
519+ }
520+ }
521+
522+ free_fs_mount_list(&mounts);
523+ return ret;
524+}
525+#else
526+GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp)
527+{
528 error_setg(errp, QERR_UNSUPPORTED);
529 return NULL;
530 }
531+#endif /* CONFIG_BSD */
532
533 GuestFsfreezeStatus qmp_guest_fsfreeze_status(Error **errp)
534 {
535@@ -3140,12 +3583,21 @@ GList *ga_command_init_blockedrpcs(GList *blockedrpcs)
536 {
537 #if !defined(__linux__)
538 {
539+#ifdef CONFIG_BSD
540 const char *list[] = {
541 "guest-suspend-disk", "guest-suspend-ram",
542+ "guest-suspend-hybrid", "guest-set-vcpus",
543+ "guest-get-memory-blocks", "guest-set-memory-blocks",
544+ "guest-get-memory-block-size", "guest-get-memory-block-info",
545+ NULL};
546+#else
547+ const char *list[] = {
548+ "guest-suspend-disk", "guest-suspend-ram",
549 "guest-suspend-hybrid", "guest-get-vcpus", "guest-set-vcpus",
550 "guest-get-memory-blocks", "guest-set-memory-blocks",
551 "guest-get-memory-block-size", "guest-get-memory-block-info",
552 NULL};
553+#endif /* CONFIG_BSD */
554 char **p = (char **)list;
555
556 while (*p) {
557@@ -3161,11 +3613,19 @@ GList *ga_command_init_blockedrpcs(GList *blockedrpcs)
558
559 #if !defined(CONFIG_FSFREEZE)
560 {
561+#ifdef CONFIG_BSD
562 const char *list[] = {
563+ "guest-fsfreeze-status",
564+ "guest-fsfreeze-freeze", "guest-fsfreeze-freeze-list",
565+ "guest-fsfreeze-thaw",
566+ "guest-get-disks", NULL};
567+#else
568+ const char *list[] = {
569 "guest-get-fsinfo", "guest-fsfreeze-status",
570 "guest-fsfreeze-freeze", "guest-fsfreeze-freeze-list",
571 "guest-fsfreeze-thaw", "guest-get-fsinfo",
572 "guest-get-disks", NULL};
573+#endif /* CONFIG_BSD */
574 char **p = (char **)list;
575
576 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 @@
1Adapted from https://github.com/aborche/qemu-guest-agent
2
3Index: qga/main.c
4--- qga/main.c.orig
5+++ qga/main.c
6@@ -40,12 +40,16 @@
7 #include "commands-common.h"
8
9 #ifndef _WIN32
10-#ifdef __FreeBSD__
11+#ifdef CONFIG_BSD
12 #define QGA_VIRTIO_PATH_DEFAULT "/dev/vtcon/org.qemu.guest_agent.0"
13-#else /* __FreeBSD__ */
14+#else /* CONFIG_BSD */
15 #define QGA_VIRTIO_PATH_DEFAULT "/dev/virtio-ports/org.qemu.guest_agent.0"
16-#endif /* __FreeBSD__ */
17+#endif /* CONFIG_BSD */
18+#ifdef __OpenBSD__
19+#define QGA_SERIAL_PATH_DEFAULT "/dev/cua01"
20+#else
21 #define QGA_SERIAL_PATH_DEFAULT "/dev/ttyS0"
22+#endif
23 #define QGA_STATE_RELATIVE_DIR "run"
24 #else
25 #define QGA_VIRTIO_PATH_DEFAULT "\\\\.\\Global\\org.qemu.guest_agent.0"
26@@ -1483,7 +1487,11 @@ int main(int argc, char **argv)
27 }
28
29 if (config->method == NULL) {
30+#ifdef CONFIG_BSD
31+ config->method = g_strdup("isa-serial");
32+#else
33 config->method = g_strdup("virtio-serial");
34+#endif
35 }
36
37 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 @@
1Set OpenBSD/powerpc cache sizes.
2
3Index: util/cacheflush.c
4--- util/cacheflush.c.orig
5+++ util/cacheflush.c
6@@ -163,6 +163,13 @@ static void arch_cache_info(int *isize, int *dsize)
7 have_coherent_icache = qemu_getauxval(AT_HWCAP) & PPC_FEATURE_ICACHE_SNOOP;
8 }
9
10+#elif defined(_ARCH_PPC) && defined (__OpenBSD__)
11+static void arch_cache_info(int *isize, int *dsize)
12+{
13+ *isize = 32;
14+ *dsize = 32;
15+}
16+
17 #else
18 static void arch_cache_info(int *isize, int *dsize) { }
19 #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 @@
1thread-posix: add support for setting threads name on OpenBSD
2
3Index: util/qemu-thread-posix.c
4--- util/qemu-thread-posix.c.orig
5+++ util/qemu-thread-posix.c
6@@ -18,6 +18,10 @@
7 #include "qemu/tsan.h"
8 #include "qemu/bitmap.h"
9
10+#ifdef CONFIG_PTHREAD_SET_NAME_NP
11+#include <pthread_np.h>
12+#endif
13+
14 static bool name_threads;
15
16 void qemu_thread_naming(bool enable)
17@@ -25,7 +29,8 @@ void qemu_thread_naming(bool enable)
18 name_threads = enable;
19
20 #if !defined CONFIG_PTHREAD_SETNAME_NP_W_TID && \
21- !defined CONFIG_PTHREAD_SETNAME_NP_WO_TID
22+ !defined CONFIG_PTHREAD_SETNAME_NP_WO_TID && \
23+ !defined CONFIG_PTHREAD_SET_NAME_NP
24 /* This is a debugging option, not fatal */
25 if (enable) {
26 fprintf(stderr, "qemu: thread naming not supported on this host\n");
27@@ -480,6 +485,8 @@ static void *qemu_thread_start(void *args)
28 pthread_setname_np(pthread_self(), qemu_thread_args->name);
29 # elif defined(CONFIG_PTHREAD_SETNAME_NP_WO_TID)
30 pthread_setname_np(qemu_thread_args->name);
31+# elif defined(CONFIG_PTHREAD_SET_NAME_NP)
32+ pthread_set_name_np(pthread_self(), qemu_thread_args->name);
33 # endif
34 }
35 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 @@
1/DESCR-ga/1.1/Sun Feb 28 18:38:41 2021//TOPENBSD_7_3
2/DESCR-main/1.1/Sun Feb 28 18:38:41 2021//TOPENBSD_7_3
3/PFRAG.plugins-main/1.2/Fri Mar 11 18:59:40 2022//TOPENBSD_7_3
4/PLIST-ga/1.5/Sat Apr 23 10:30:24 2022//TOPENBSD_7_3
5/PLIST-main/1.13/Tue Feb 21 23:06:55 2023//TOPENBSD_7_3
6/README-ga/1.1/Tue Mar 29 10:04:28 2022//TOPENBSD_7_3
7/README-main/1.3/Fri Mar 11 18:59:40 2022//TOPENBSD_7_3
8/qemu_ga.rc/1.1/Tue Mar 29 10:04:28 2022//TOPENBSD_7_3
9D
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 @@
1The QEMU guest agent provides a daemon to run inside QEMU guests. It
2communicates with the host system and allows to perform various tasks in
3the 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 @@
1QEMU is an open source machine emulator. It can run OSes and programs
2made for one machine (e.g. an ARM board) on a different machine (e.g.
3your own PC). By using dynamic translation, it achieves very good
4performance.
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 @@
1@conflict qemu-<=5.1.0p2
2@rcscript ${RCDIR}/qemu_ga
3@bin bin/qemu-ga
4@man man/man7/qemu-ga-ref.7
5@man man/man8/qemu-ga.8
6share/doc/pkg-readmes/${PKGSTEM}
7share/doc/qemu/
8share/doc/qemu/interop/
9share/doc/qemu/interop/qemu-ga-ref.html
10share/doc/qemu/interop/qemu-ga.html
11share/examples/qemu/
12@sample ${SYSCONFDIR}/qemu/
13share/examples/qemu/qemu-ga.conf
14@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 @@
1@pkgpath emulators/qemu
2@bin bin/elf2dmp
3@bin bin/qemu-edid
4@bin bin/qemu-img
5@bin bin/qemu-io
6@bin bin/qemu-keymap
7@bin bin/qemu-nbd
8@bin bin/qemu-storage-daemon
9@bin bin/qemu-system-aarch64
10@bin bin/qemu-system-alpha
11@bin bin/qemu-system-arm
12@bin bin/qemu-system-avr
13@bin bin/qemu-system-cris
14@bin bin/qemu-system-hppa
15@bin bin/qemu-system-i386
16@bin bin/qemu-system-loongarch64
17@bin bin/qemu-system-m68k
18@bin bin/qemu-system-microblaze
19@bin bin/qemu-system-microblazeel
20@bin bin/qemu-system-mips
21@bin bin/qemu-system-mips64
22@bin bin/qemu-system-mips64el
23@bin bin/qemu-system-mipsel
24@bin bin/qemu-system-nios2
25@bin bin/qemu-system-or1k
26@bin bin/qemu-system-ppc
27@bin bin/qemu-system-ppc64
28@bin bin/qemu-system-riscv32
29@bin bin/qemu-system-riscv64
30@bin bin/qemu-system-rx
31@bin bin/qemu-system-s390x
32@bin bin/qemu-system-sh4
33@bin bin/qemu-system-sh4eb
34@bin bin/qemu-system-sparc
35@bin bin/qemu-system-sparc64
36@bin bin/qemu-system-tricore
37@bin bin/qemu-system-x86_64
38@bin bin/qemu-system-xtensa
39@bin bin/qemu-system-xtensaeb
40%%plugins%%
41@man man/man1/qemu-img.1
42@man man/man1/qemu-storage-daemon.1
43@man man/man1/qemu.1
44@man man/man7/qemu-block-drivers.7
45@man man/man7/qemu-cpu-models.7
46@man man/man7/qemu-qmp-ref.7
47@man man/man7/qemu-storage-daemon-qmp-ref.7
48@man man/man8/qemu-nbd.8
49@man man/man8/qemu-pr-helper.8
50share/applications/qemu.desktop
51share/doc/pkg-readmes/${PKGSTEM}
52share/doc/qemu/.buildinfo
53share/doc/qemu/_static/
54share/doc/qemu/_static/basic.css
55share/doc/qemu/_static/css/
56share/doc/qemu/_static/css/badge_only.css
57share/doc/qemu/_static/css/fonts/
58share/doc/qemu/_static/css/fonts/Roboto-Slab-Bold.woff
59share/doc/qemu/_static/css/fonts/Roboto-Slab-Bold.woff2
60share/doc/qemu/_static/css/fonts/Roboto-Slab-Regular.woff
61share/doc/qemu/_static/css/fonts/Roboto-Slab-Regular.woff2
62share/doc/qemu/_static/css/fonts/fontawesome-webfont.eot
63share/doc/qemu/_static/css/fonts/fontawesome-webfont.svg
64share/doc/qemu/_static/css/fonts/fontawesome-webfont.ttf
65share/doc/qemu/_static/css/fonts/fontawesome-webfont.woff
66share/doc/qemu/_static/css/fonts/fontawesome-webfont.woff2
67share/doc/qemu/_static/css/fonts/lato-bold-italic.woff
68share/doc/qemu/_static/css/fonts/lato-bold-italic.woff2
69share/doc/qemu/_static/css/fonts/lato-bold.woff
70share/doc/qemu/_static/css/fonts/lato-bold.woff2
71share/doc/qemu/_static/css/fonts/lato-normal-italic.woff
72share/doc/qemu/_static/css/fonts/lato-normal-italic.woff2
73share/doc/qemu/_static/css/fonts/lato-normal.woff
74share/doc/qemu/_static/css/fonts/lato-normal.woff2
75share/doc/qemu/_static/css/theme.css
76share/doc/qemu/_static/custom.js
77share/doc/qemu/_static/doctools.js
78share/doc/qemu/_static/documentation_options.js
79share/doc/qemu/_static/file.png
80share/doc/qemu/_static/js/
81share/doc/qemu/_static/js/badge_only.js
82share/doc/qemu/_static/js/theme.js
83share/doc/qemu/_static/language_data.js
84share/doc/qemu/_static/minus.png
85share/doc/qemu/_static/plus.png
86share/doc/qemu/_static/pygments.css
87share/doc/qemu/_static/qemu_128x128.png
88share/doc/qemu/_static/qemu_32x32.png
89share/doc/qemu/_static/searchtools.js
90share/doc/qemu/_static/sphinx_highlight.js
91share/doc/qemu/_static/theme_overrides.css
92share/doc/qemu/about/
93share/doc/qemu/about/build-platforms.html
94share/doc/qemu/about/deprecated.html
95share/doc/qemu/about/index.html
96share/doc/qemu/about/license.html
97share/doc/qemu/about/removed-features.html
98share/doc/qemu/dbus-dbusindex.html
99share/doc/qemu/devel/
100share/doc/qemu/devel/acpi-bits.html
101share/doc/qemu/devel/atomics.html
102share/doc/qemu/devel/bitops.html
103share/doc/qemu/devel/block-coroutine-wrapper.html
104share/doc/qemu/devel/build-system.html
105share/doc/qemu/devel/ci.html
106share/doc/qemu/devel/clocks.html
107share/doc/qemu/devel/code-of-conduct.html
108share/doc/qemu/devel/conflict-resolution.html
109share/doc/qemu/devel/control-flow-integrity.html
110share/doc/qemu/devel/decodetree.html
111share/doc/qemu/devel/ebpf_rss.html
112share/doc/qemu/devel/fuzzing.html
113share/doc/qemu/devel/index-api.html
114share/doc/qemu/devel/index-build.html
115share/doc/qemu/devel/index-internals.html
116share/doc/qemu/devel/index-process.html
117share/doc/qemu/devel/index-tcg.html
118share/doc/qemu/devel/index.html
119share/doc/qemu/devel/kconfig.html
120share/doc/qemu/devel/loads-stores.html
121share/doc/qemu/devel/maintainers.html
122share/doc/qemu/devel/memory.html
123share/doc/qemu/devel/migration.html
124share/doc/qemu/devel/modules.html
125share/doc/qemu/devel/multi-process.html
126share/doc/qemu/devel/multi-thread-tcg.html
127share/doc/qemu/devel/qapi-code-gen.html
128share/doc/qemu/devel/qgraph.html
129share/doc/qemu/devel/qom.html
130share/doc/qemu/devel/qtest.html
131share/doc/qemu/devel/replay.html
132share/doc/qemu/devel/reset.html
133share/doc/qemu/devel/s390-dasd-ipl.html
134share/doc/qemu/devel/secure-coding-practices.html
135share/doc/qemu/devel/stable-process.html
136share/doc/qemu/devel/style.html
137share/doc/qemu/devel/submitting-a-patch.html
138share/doc/qemu/devel/submitting-a-pull-request.html
139share/doc/qemu/devel/tcg-icount.html
140share/doc/qemu/devel/tcg-plugins.html
141share/doc/qemu/devel/tcg.html
142share/doc/qemu/devel/testing.html
143share/doc/qemu/devel/tracing.html
144share/doc/qemu/devel/trivial-patches.html
145share/doc/qemu/devel/ui.html
146share/doc/qemu/devel/vfio-migration.html
147share/doc/qemu/devel/virtio-backends.html
148share/doc/qemu/devel/writing-monitor-commands.html
149share/doc/qemu/genindex.html
150share/doc/qemu/index.html
151share/doc/qemu/interop/barrier.html
152share/doc/qemu/interop/bitmaps.html
153share/doc/qemu/interop/dbus-display.html
154share/doc/qemu/interop/dbus-vmstate.html
155share/doc/qemu/interop/dbus.html
156share/doc/qemu/interop/index.html
157share/doc/qemu/interop/live-block-operations.html
158share/doc/qemu/interop/pr-helper.html
159share/doc/qemu/interop/qemu-qmp-ref.html
160share/doc/qemu/interop/qemu-storage-daemon-qmp-ref.html
161share/doc/qemu/interop/vhost-user-gpu.html
162share/doc/qemu/interop/vhost-user.html
163share/doc/qemu/interop/vhost-vdpa.html
164share/doc/qemu/interop/virtio-balloon-stats.html
165share/doc/qemu/objects.inv
166share/doc/qemu/search.html
167share/doc/qemu/searchindex.js
168share/doc/qemu/specs/
169share/doc/qemu/specs/acpi_cpu_hotplug.html
170share/doc/qemu/specs/acpi_erst.html
171share/doc/qemu/specs/acpi_hest_ghes.html
172share/doc/qemu/specs/acpi_hw_reduced_hotplug.html
173share/doc/qemu/specs/acpi_mem_hotplug.html
174share/doc/qemu/specs/acpi_nvdimm.html
175share/doc/qemu/specs/acpi_pci_hotplug.html
176share/doc/qemu/specs/fw_cfg.html
177share/doc/qemu/specs/index.html
178share/doc/qemu/specs/ppc-spapr-hcalls.html
179share/doc/qemu/specs/ppc-spapr-hotplug.html
180share/doc/qemu/specs/ppc-spapr-numa.html
181share/doc/qemu/specs/ppc-spapr-uv-hcalls.html
182share/doc/qemu/specs/ppc-spapr-xive.html
183share/doc/qemu/specs/ppc-xive.html
184share/doc/qemu/specs/sev-guest-firmware.html
185share/doc/qemu/specs/tpm.html
186share/doc/qemu/system/
187share/doc/qemu/system/arm/
188share/doc/qemu/system/arm/aspeed.html
189share/doc/qemu/system/arm/collie.html
190share/doc/qemu/system/arm/cpu-features.html
191share/doc/qemu/system/arm/cubieboard.html
192share/doc/qemu/system/arm/digic.html
193share/doc/qemu/system/arm/emcraft-sf2.html
194share/doc/qemu/system/arm/emulation.html
195share/doc/qemu/system/arm/gumstix.html
196share/doc/qemu/system/arm/highbank.html
197share/doc/qemu/system/arm/imx25-pdk.html
198share/doc/qemu/system/arm/integratorcp.html
199share/doc/qemu/system/arm/kzm.html
200share/doc/qemu/system/arm/mainstone.html
201share/doc/qemu/system/arm/mps2.html
202share/doc/qemu/system/arm/musca.html
203share/doc/qemu/system/arm/musicpal.html
204share/doc/qemu/system/arm/nrf.html
205share/doc/qemu/system/arm/nseries.html
206share/doc/qemu/system/arm/nuvoton.html
207share/doc/qemu/system/arm/orangepi.html
208share/doc/qemu/system/arm/palm.html
209share/doc/qemu/system/arm/raspi.html
210share/doc/qemu/system/arm/realview.html
211share/doc/qemu/system/arm/sabrelite.html
212share/doc/qemu/system/arm/sbsa.html
213share/doc/qemu/system/arm/stellaris.html
214share/doc/qemu/system/arm/stm32.html
215share/doc/qemu/system/arm/sx1.html
216share/doc/qemu/system/arm/versatile.html
217share/doc/qemu/system/arm/vexpress.html
218share/doc/qemu/system/arm/virt.html
219share/doc/qemu/system/arm/xlnx-versal-virt.html
220share/doc/qemu/system/arm/xscale.html
221share/doc/qemu/system/authz.html
222share/doc/qemu/system/barrier.html
223share/doc/qemu/system/bootindex.html
224share/doc/qemu/system/confidential-guest-support.html
225share/doc/qemu/system/cpu-hotplug.html
226share/doc/qemu/system/device-emulation.html
227share/doc/qemu/system/devices/
228share/doc/qemu/system/devices/can.html
229share/doc/qemu/system/devices/canokey.html
230share/doc/qemu/system/devices/ccid.html
231share/doc/qemu/system/devices/cxl.html
232share/doc/qemu/system/devices/ivshmem.html
233share/doc/qemu/system/devices/net.html
234share/doc/qemu/system/devices/nvme.html
235share/doc/qemu/system/devices/usb.html
236share/doc/qemu/system/devices/vhost-user-rng.html
237share/doc/qemu/system/devices/vhost-user.html
238share/doc/qemu/system/devices/virtio-pmem.html
239share/doc/qemu/system/gdb.html
240share/doc/qemu/system/generic-loader.html
241share/doc/qemu/system/guest-loader.html
242share/doc/qemu/system/i386/
243share/doc/qemu/system/i386/amd-memory-encryption.html
244share/doc/qemu/system/i386/cpu.html
245share/doc/qemu/system/i386/hyperv.html
246share/doc/qemu/system/i386/kvm-pv.html
247share/doc/qemu/system/i386/microvm.html
248share/doc/qemu/system/i386/pc.html
249share/doc/qemu/system/i386/sgx.html
250share/doc/qemu/system/images.html
251share/doc/qemu/system/index.html
252share/doc/qemu/system/invocation.html
253share/doc/qemu/system/keys.html
254share/doc/qemu/system/linuxboot.html
255share/doc/qemu/system/loongarch/
256share/doc/qemu/system/loongarch/loongson3.html
257share/doc/qemu/system/managed-startup.html
258share/doc/qemu/system/monitor.html
259share/doc/qemu/system/multi-process.html
260share/doc/qemu/system/mux-chardev.html
261share/doc/qemu/system/openrisc/
262share/doc/qemu/system/openrisc/cpu-features.html
263share/doc/qemu/system/openrisc/emulation.html
264share/doc/qemu/system/openrisc/or1k-sim.html
265share/doc/qemu/system/openrisc/virt.html
266share/doc/qemu/system/ppc/
267share/doc/qemu/system/ppc/embedded.html
268share/doc/qemu/system/ppc/powermac.html
269share/doc/qemu/system/ppc/powernv.html
270share/doc/qemu/system/ppc/ppce500.html
271share/doc/qemu/system/ppc/prep.html
272share/doc/qemu/system/ppc/pseries.html
273share/doc/qemu/system/pr-manager.html
274share/doc/qemu/system/qemu-block-drivers.html
275share/doc/qemu/system/qemu-cpu-models.html
276share/doc/qemu/system/qemu-manpage.html
277share/doc/qemu/system/quickstart.html
278share/doc/qemu/system/replay.html
279share/doc/qemu/system/riscv/
280share/doc/qemu/system/riscv/microchip-icicle-kit.html
281share/doc/qemu/system/riscv/shakti-c.html
282share/doc/qemu/system/riscv/sifive_u.html
283share/doc/qemu/system/riscv/virt.html
284share/doc/qemu/system/s390x/
285share/doc/qemu/system/s390x/3270.html
286share/doc/qemu/system/s390x/bootdevices.html
287share/doc/qemu/system/s390x/css.html
288share/doc/qemu/system/s390x/protvirt.html
289share/doc/qemu/system/s390x/vfio-ap.html
290share/doc/qemu/system/s390x/vfio-ccw.html
291share/doc/qemu/system/secrets.html
292share/doc/qemu/system/security.html
293share/doc/qemu/system/target-arm.html
294share/doc/qemu/system/target-avr.html
295share/doc/qemu/system/target-i386.html
296share/doc/qemu/system/target-m68k.html
297share/doc/qemu/system/target-mips.html
298share/doc/qemu/system/target-openrisc.html
299share/doc/qemu/system/target-ppc.html
300share/doc/qemu/system/target-riscv.html
301share/doc/qemu/system/target-rx.html
302share/doc/qemu/system/target-s390x.html
303share/doc/qemu/system/target-sparc.html
304share/doc/qemu/system/target-sparc64.html
305share/doc/qemu/system/target-xtensa.html
306share/doc/qemu/system/targets.html
307share/doc/qemu/system/tls.html
308share/doc/qemu/system/virtio-net-failover.html
309share/doc/qemu/system/vnc-security.html
310share/doc/qemu/tools/
311share/doc/qemu/tools/index.html
312share/doc/qemu/tools/qemu-img.html
313share/doc/qemu/tools/qemu-nbd.html
314share/doc/qemu/tools/qemu-pr-helper.html
315share/doc/qemu/tools/qemu-storage-daemon.html
316share/doc/qemu/tools/qemu-trace-stap.html
317share/doc/qemu/tools/virtfs-proxy-helper.html
318share/doc/qemu/tools/virtiofsd.html
319share/doc/qemu/user/
320share/doc/qemu/user/index.html
321share/doc/qemu/user/main.html
322share/examples/qemu/qemu-ifdown
323@mode 755
324@sample ${SYSCONFDIR}/qemu-ifdown
325@mode
326share/examples/qemu/qemu-ifup
327@mode 755
328@sample ${SYSCONFDIR}/qemu-ifup
329@mode
330share/icons/hicolor/128x128/apps/qemu.png
331share/icons/hicolor/16x16/apps/qemu.png
332share/icons/hicolor/24x24/apps/qemu.png
333share/icons/hicolor/256x256/apps/qemu.png
334share/icons/hicolor/32x32/apps/qemu.bmp
335share/icons/hicolor/32x32/apps/qemu.png
336share/icons/hicolor/48x48/apps/qemu.png
337share/icons/hicolor/512x512/apps/qemu.png
338share/icons/hicolor/64x64/apps/qemu.png
339share/icons/hicolor/scalable/apps/qemu.svg
340share/locale/bg/LC_MESSAGES/qemu.mo
341share/locale/de_DE/
342share/locale/de_DE/LC_MESSAGES/
343share/locale/de_DE/LC_MESSAGES/qemu.mo
344share/locale/fr_FR/
345share/locale/fr_FR/LC_MESSAGES/
346share/locale/fr_FR/LC_MESSAGES/qemu.mo
347share/locale/hu/LC_MESSAGES/qemu.mo
348share/locale/it/LC_MESSAGES/qemu.mo
349share/locale/sv/LC_MESSAGES/qemu.mo
350share/locale/tr/LC_MESSAGES/qemu.mo
351share/locale/uk/LC_MESSAGES/qemu.mo
352share/locale/zh_CN/LC_MESSAGES/qemu.mo
353share/qemu/
354share/qemu/QEMU,cgthree.bin
355share/qemu/QEMU,tcx.bin
356share/qemu/bamboo.dtb
357share/qemu/bios-256k.bin
358share/qemu/bios-microvm.bin
359share/qemu/bios.bin
360share/qemu/canyonlands.dtb
361share/qemu/edk2-aarch64-code.fd
362share/qemu/edk2-arm-code.fd
363share/qemu/edk2-arm-vars.fd
364share/qemu/edk2-i386-code.fd
365share/qemu/edk2-i386-secure-code.fd
366share/qemu/edk2-i386-vars.fd
367share/qemu/edk2-licenses.txt
368share/qemu/edk2-x86_64-code.fd
369share/qemu/edk2-x86_64-secure-code.fd
370share/qemu/efi-e1000.rom
371share/qemu/efi-e1000e.rom
372share/qemu/efi-eepro100.rom
373share/qemu/efi-ne2k_pci.rom
374share/qemu/efi-pcnet.rom
375share/qemu/efi-rtl8139.rom
376share/qemu/efi-virtio.rom
377share/qemu/efi-vmxnet3.rom
378share/qemu/firmware/
379share/qemu/firmware/50-edk2-i386-secure.json
380share/qemu/firmware/50-edk2-x86_64-secure.json
381share/qemu/firmware/60-edk2-aarch64.json
382share/qemu/firmware/60-edk2-arm.json
383share/qemu/firmware/60-edk2-i386.json
384share/qemu/firmware/60-edk2-x86_64.json
385share/qemu/hppa-firmware.img
386share/qemu/keymaps/
387share/qemu/keymaps/ar
388share/qemu/keymaps/bepo
389share/qemu/keymaps/cz
390share/qemu/keymaps/da
391share/qemu/keymaps/de
392share/qemu/keymaps/de-ch
393share/qemu/keymaps/en-gb
394share/qemu/keymaps/en-us
395share/qemu/keymaps/es
396share/qemu/keymaps/et
397share/qemu/keymaps/fi
398share/qemu/keymaps/fo
399share/qemu/keymaps/fr
400share/qemu/keymaps/fr-be
401share/qemu/keymaps/fr-ca
402share/qemu/keymaps/fr-ch
403share/qemu/keymaps/hr
404share/qemu/keymaps/hu
405share/qemu/keymaps/is
406share/qemu/keymaps/it
407share/qemu/keymaps/ja
408share/qemu/keymaps/lt
409share/qemu/keymaps/lv
410share/qemu/keymaps/mk
411share/qemu/keymaps/nl
412share/qemu/keymaps/no
413share/qemu/keymaps/pl
414share/qemu/keymaps/pt
415share/qemu/keymaps/pt-br
416share/qemu/keymaps/ru
417share/qemu/keymaps/sl
418share/qemu/keymaps/sv
419share/qemu/keymaps/th
420share/qemu/keymaps/tr
421share/qemu/kvmvapic.bin
422share/qemu/linuxboot.bin
423share/qemu/linuxboot_dma.bin
424share/qemu/multiboot.bin
425share/qemu/multiboot_dma.bin
426share/qemu/npcm7xx_bootrom.bin
427share/qemu/openbios-ppc
428share/qemu/openbios-sparc32
429share/qemu/openbios-sparc64
430share/qemu/opensbi-riscv32-generic-fw_dynamic.bin
431share/qemu/opensbi-riscv64-generic-fw_dynamic.bin
432share/qemu/palcode-clipper
433share/qemu/petalogix-ml605.dtb
434share/qemu/petalogix-s3adsp1800.dtb
435share/qemu/pvh.bin
436share/qemu/pxe-e1000.rom
437share/qemu/pxe-eepro100.rom
438share/qemu/pxe-ne2k_pci.rom
439share/qemu/pxe-pcnet.rom
440share/qemu/pxe-rtl8139.rom
441share/qemu/pxe-virtio.rom
442share/qemu/qboot.rom
443share/qemu/qemu-nsis.bmp
444share/qemu/qemu_vga.ndrv
445share/qemu/s390-ccw.img
446share/qemu/s390-netboot.img
447share/qemu/sgabios.bin
448share/qemu/skiboot.lid
449share/qemu/slof.bin
450share/qemu/trace-events-all
451share/qemu/u-boot-sam460-20100605.bin
452share/qemu/u-boot.e500
453share/qemu/vgabios-ati.bin
454share/qemu/vgabios-bochs-display.bin
455share/qemu/vgabios-cirrus.bin
456share/qemu/vgabios-qxl.bin
457share/qemu/vgabios-ramfb.bin
458share/qemu/vgabios-stdvga.bin
459share/qemu/vgabios-virtio.bin
460share/qemu/vgabios-vmware.bin
461share/qemu/vgabios.bin
462share/qemu/vof-nvram.bin
463share/qemu/vof.bin
464@tag update-desktop-database
465@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 @@
1+-----------------------------------------------------------------------
2| Running ${PKGSTEM} on OpenBSD
3+-----------------------------------------------------------------------
4
5To use qemu-ga, configure QEMU to present the guest agent interface as
6an isa-serial port.
7
8If you use Proxmox Virtual Environment, you can do this in the "Options"
9section; edit "QEMU Guest Agent", enable it, tick the box to show advanced
10settings, and set "Type" to ISA.
11
12An rc.d(8) script is provided; as usual you can enable it to start at
13boot with:
14
15# rcctl enable qemu_ga
16
17By default the script uses /dev/cua01 for the connection as would be
18the case where you have also enabled a serial console device. If you have
19not done this and the Guest Agent interface is on a different port, set
20that with e.g.
21
22# rcctl set qemu_ga flags -t /var/run/qemu-ga \
23 -f /var/run/qemu-ga/qemu-ga.pid -m isa-serial -p /dev/cua00
24
25Currently 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 @@
1+-----------------------------------------------------------------------
2| Running ${PKGSTEM} on OpenBSD
3+-----------------------------------------------------------------------
4
5==> Quick Start
6
71. Get a bootable CDROM image:
8
9 $ ftp https://cdn.openbsd.org/pub/OpenBSD/snapshots/i386/cd70.iso
10
11 or to use a 64-bit client OS or SPARC, respectively:
12
13 $ ftp https://cdn.openbsd.org/pub/OpenBSD/snapshots/amd64/cd70.iso
14
15 $ ftp https://cdn.openbsd.org/pub/OpenBSD/snapshots/sparc/cd70.iso
16
172. Create a virtual disk image:
18
19 $ qemu-img create -f qcow2 virtual.img 10G
20
213. Install the OS:
22
23 $ qemu-system-i386 -m 32 -monitor stdio -no-fd-bootchk \
24 -hda virtual.img -cdrom cd70.iso -boot d
25
26 or:
27
28 $ qemu-system-x86_64 -m 32 -monitor stdio -no-fd-bootchk \
29 -hda virtual.img -cdrom cd70.iso -boot d
30
31 $ qemu-system-sparc -m 32 -monitor stdio \
32 -hda virtual.img -cdrom cd70.iso -boot d
33
34 NOTE: start this inside an xterm or equivalent.
35 NOTE: be sure to choose serial console during install.
36 NOTE: -no-fd-bootchk permits booting faster when no floppy is
37 in use, but is not supported for qemu-system-sparc.
38 NOTE: qemu-system-ppc* and qemu-system-sparc* currently fail with
39 J or S malloc flags
40
414. Compress the virtual disk:
42
43 $ qemu-img convert -c -O qcow2 virtual.img v.tmp && \
44 mv v.tmp virtual.img
45
46 NOTE: do not do this while QEMU is running / using this virtual
47 disk.
48
495. Boot normally from the virtual disk:
50
51 $ qemu-system-i386 -m 32 -nographic -no-fd-bootchk -hda virtual.img
52
53 or:
54
55 $ qemu-system-x86_64 -m 32 -nographic -no-fd-bootchk -hda virtual.img
56
57 $ qemu-system-sparc -m 32 -nographic -hda virtual.img
58
59==> Networking
60
611. Default Settings
62
63 By default, QEMU sets up the equivalent of the following networking:
64
65 -net nic,vlan=0,model=e1000,macaddr=52:54:00:12:34:56
66 -net user,vlan=0
67
68 Also, inside this virtual usermode network, it uses the 10.0.2.0/24
69 and serves DHCP from inside this virtual network. Static address
70 can be used if one cannot or does not want to do DHCP in the
71 guest OS:
72
73 Guest OS IP : 10.0.2.15
74 Default Gateway : 10.0.2.2
75 Nameserver : 10.0.2.3
76
77 It is sufficient for most operations, QEMU itself performs NAT
78 and then makes userland network calls for TCP/UDP operations.
79 ICMP and other things are not possible in this mode.
80
81 NOTE: If you use one '-net' cmdline argument, QEMU assumes you
82 know what you want and clears defaults for the rest of the
83 -net defaults.
84
85 NOTE: The guest mode networking does not currently support IPv6,
86 and QEMU will complain that it cannot find a DNS server
87 if /etc/resolv.conf contains only IPv6 DNS servers.
88
892. tap mode
90
91 Sometimes it is desirable to configure QEMU to access a network
92 via layer2 directly. One way of doing this without having to run
93 QEMU as root is to let root open /dev/tapN and pass the file
94 descriptor to QEMU. The tap(4) interface should preferrably be
95 configured before starting QEMU:
96
97 $ doas ifconfig tap0 192.168.0.254
98
99 The interface can also be configured as part of a bridge(4), in
100 which case the ip address can be omitted:
101
102 $ doas ifconfig bridge0 add tap0 add em0 up
103
104 The tunnel and bridge interfaces can also be configured at system
105 startup by editing /etc/hostname.tapN and /etc/hostname.bridgeN,
106 respectively (see hostname.if(5)).
107
108 After configuring the virtual network we can use doas to let
109 root open the tunnel device and then use doas again to drop
110 privileges and start QEMU:
111
112 $ doas sh -c "doas -u $USER qemu-system-i386 -nographic -net nic \
113 -net tap,fd=3 -no-fd-bootchk -hda virtual.img 3<>/dev/tap0"
114
115 NOTE: if you use sudo instead of doas, remember that sudo calls
116 closefrom(2). In order to have more than one fd passed tap
117 interface, a line to sudoers akin to:
118
119 Defaults closefrom_override
120
121 then calling sudo via 'sudo -C 5 -u $USER qemu-system-i386 ..'
122 is required. See sudoers(5) and sudo(8) for details.
123
124 An alternative to the procedure described above is to have QEMU
125 set up the network via ${SYSCONFDIR}/qemu-ifup. This is not
126 recommended however, since you would have to run QEMU as root,
127 and there is no way to drop from root privileges at this point.
128
129 ${SYSCONFDIR}/qemu-ifup contains some default settings that
130 permit one to do the following:
131
132 # qemu-system-i386 -net nic -net tap -no-fd-bootchk -hda virtual.img
133
134 It presumes you wish the tap(4) interface to talk to the interface
135 holding the default IPv4 route (falling back to trunk0 if no
136 route is found), and that you want 'bridge0' to be used to bridge
137 the two.
138
139 Setting the environment variables ETHER and BRIDGE will override
140 these settings, respectively.
141
142 When starting QEMU, the script attempts to output useful
143 information, but there are also error messages that occur as
144 well. On my laptop, I want to route / nat natively using PF and
145 also have layer2 access to the QEMU networks. I thus have this
146 as /etc/hostname.trunk101:
147
148 inet6 fe80::1c 64 lladdr 00:03:25:0d:7a:2c
149 inet 10.7.255.1 255.255.255.0
150 inet6 alias 2001:240:58a:45::1c
151
152 I have dhcpd configured to run on trunk101, and also run rad.
153 For QEMU, the startup looks like this:
154
155 # export ETHER=trunk101
156 # export BRIDGE=bridge101
157 # qemu-system-i386 -net nic,vlan=0,macaddr=52:54:00:12:35:00 \
158 -net tap,vlan=0 -vnc :0 -localtime -usb -usbdevice tablet \
159 -m 256 -no-fd-bootchk -hda virtual.img -monitor stdio
160 {tap0 (bridge101 <-> trunk101)ifconfig: bridge101: No such process
161 ifconfig: bridge101: No such process
162 }
163 (qemu)
164
165 The errors are normal and should be ignored. One can verify the
166 networking is properly configured by verifying the bridge
167 interface:
168
169 $ ifconfig bridge101
170 bridge101: flags=41<UP,RUNNING>
171 groups: bridge
172 priority 32768 hellotime 2 fwddelay 15 maxage 20 holdcnt 6 proto rstp
173 designated: id 00:00:00:00:00:00 priority 0
174 tap0 flags=3<LEARNING,DISCOVER>
175 port 16 ifpriority 0 ifcost 0
176 trunk101 flags=3<LEARNING,DISCOVER>
177 port 6 ifpriority 0 ifcost 0
178 Addresses (max cache: 100, timeout: 240):
179
180 NOTE: When running multiple QEMU sessions simultaneously on the
181 same bridge, care must be taken because the network MAC
182 address defaults to 52:54:00:12:34:56 for every QEMU
183 instance. To change this, observe the macaddr= syntax in
184 the above example and choose a unique lladdr per QEMU nic.
185
186==> Mice
187
188 NOTE: Certain OS's work much better with the USB tablet device
189 than the normal PS/2 mouse handling. See the above example
190 for usage.
191
192==> Serial Console
193
194 Installing OpenBSD via serial console is sometimes desirable.
195 X may not be available, and so on. There are two ways to
196 accomplish this, both in effect the same solution:
197
198 a. qemu-system-i386 -vnc :0 -serial stdio .. virtual.img \
199 -cdrom install52.iso -boot d
200
201 - this option permits you to use VNC from some system to
202 connect to the QEMU instance and 'set tty com0' at the
203 'boot>' prompt.
204 - you may then disconnect VNC and use the terminal from
205 which you started QEMU to do the install.
206
207 b. qemu-system-i386 -nographic .. virtual.img -fda floppy52.fs -boot a
208
209 - this maps both the serial port and the (qemu) monitor
210 prompt to the terminal QEMU was started on.
211 - to flip between them, Ctrl-a c; see the QEMU man page for
212 other commands that work in -nographic mode.
213 - preparation of the floppy image to force serial console
214 mode is straightforward:
215
216 vnconfig vnd0 floppy52.fs
217 mount /dev/vnd0c /mnt
218 mkdir /mnt/etc
219 echo set tty com0 > /mnt/etc/boot.conf
220 umount /mnt
221 vnconfig -u vnd0
222
223 .. be sure to choose 'yes' for setting com0 to be the serial
224 console.
225
226 NOTE: OpenBSD poweroff does work with QEMU, which actually causes
227 QEMU itself to exit. This is a good thing, as it is
228 currently not possible to set what block device is booted
229 from at runtime from QEMU. So if you start an installation
230 booting from a CD-ROM, you will always boot off a CD-ROM
231 every time you reboot that QEMU session until you exit and
232 start QEMU again booting off the virtual hard drive.
233
234==> daemonized QEMU
235
236 Sometimes you want QEMU to start as part of a system script.
237
238 Adding to some of the above, the -daemonize option comes in
239 handy, as well as the telnet: designator for -serial and monitor.
240 This is a complete example that may be cut-and-pasted into
241 rc.local:
242
243 hddir=/var/vm
244 USER=qemu
245 if [ -x ${TRUEPREFIX}/bin/qemu ]; then
246 echo -n 'Qemu: vmi386'
247 (
248 ifconfig bridge101 add trunk101 add tap0 up
249
250 sh -c "doas -u $USER \
251 ${TRUEPREFIX}/bin/qemu-system-i386 \
252 -daemonize \
253 -nographic \
254 -net nic,vlan=0,macaddr=52:54:00:4e:62:8f \
255 -net tap,vlan=0,fd=3 \
256 -m 128 \
257 -hda $hddir/virtual.img \
258 -serial telnet:127.0.0.1:1080,server,nowait \
259 -monitor telnet:127.0.0.1:1081,server,nowait \
260 -no-fd-bootchk 3<>/dev/tap0"
261 )
262 echo "."
263 fi
264
265 NOTE: this presumes the user `qemu' exists, create it or set
266 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 @@
1#!/bin/ksh
2
3daemon="${TRUEPREFIX}/bin/qemu-ga -d"
4daemon_flags="-t /var/run/qemu-ga -f /var/run/qemu-ga/qemu-ga.pid"
5
6. /etc/rc.d/rc.subr
7
8rc_reload=NO
9
10rc_pre() {
11 install -d -o ${daemon_user} /var/run/qemu-ga
12}
13
14rc_cmd $1