aboutsummaryrefslogtreecommitdiffstats
path: root/emulators/qemu30/files
diff options
context:
space:
mode:
authorbofh <bofh@FreeBSD.org>2019-08-06 17:31:00 +0800
committerbofh <bofh@FreeBSD.org>2019-08-06 17:31:00 +0800
commit426baf0ab41923d2a91ff782afb9003551aab910 (patch)
tree2ad120014f5c4c641c2229c479a74173aceac777 /emulators/qemu30/files
parentdb52df8326ba32198edbeee0c73a01908e5223e5 (diff)
downloadfreebsd-ports-gnome-426baf0ab41923d2a91ff782afb9003551aab910.tar.gz
freebsd-ports-gnome-426baf0ab41923d2a91ff782afb9003551aab910.tar.zst
freebsd-ports-gnome-426baf0ab41923d2a91ff782afb9003551aab910.zip
emulators/qemu30: QEMU CPU Emulator
- Specific to version 3.0 in preperation for upgrading qemu to 3.1.X - USES=gl is not always needed [1] PR: 238364 [1] Submitted by: pizzamig [1]
Diffstat (limited to 'emulators/qemu30/files')
-rw-r--r--emulators/qemu30/files/patch-Makefile42
-rw-r--r--emulators/qemu30/files/patch-configure264
-rw-r--r--emulators/qemu30/files/patch-disas_libvixl_vixl_a64_disasm-a64.cc11
-rw-r--r--emulators/qemu30/files/patch-hw_rdma_Makefile.objs8
-rw-r--r--emulators/qemu30/files/patch-hw_rdma_vmw_pvrdma__cmd.c10
-rw-r--r--emulators/qemu30/files/patch-include_net_net.h13
-rw-r--r--emulators/qemu30/files/patch-include_qemu_atomic.h54
-rw-r--r--emulators/qemu30/files/patch-net_tap-bsd.c10
-rw-r--r--emulators/qemu30/files/patch-qemu-doc.texi21
-rw-r--r--emulators/qemu30/files/pcap-patch56
-rw-r--r--emulators/qemu30/files/pcap-patch-net_clients.h13
-rw-r--r--emulators/qemu30/files/pcap-patch-net_net.c250
-rw-r--r--emulators/qemu30/files/qemu-ifdown.sample2
-rw-r--r--emulators/qemu30/files/qemu-ifup.sample2
14 files changed, 756 insertions, 0 deletions
diff --git a/emulators/qemu30/files/patch-Makefile b/emulators/qemu30/files/patch-Makefile
new file mode 100644
index 000000000000..df517e09efcf
--- /dev/null
+++ b/emulators/qemu30/files/patch-Makefile
@@ -0,0 +1,42 @@
+--- Makefile.orig 2019-04-12 03:28:28 UTC
++++ Makefile
+@@ -353,9 +353,14 @@ LIBS+=-lz $(LIBS_TOOLS)
+ HELPERS-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_LINUX)) = qemu-bridge-helper$(EXESUF)
+
+ ifdef BUILD_DOCS
++ifdef NOPORTDOCS
++DOCS=qemu.1 qemu-img.1 qemu-nbd.8 qemu-ga.8
++DOCS+=docs/interop/qemu-qmp-ref.7 docs/interop/qemu-ga-ref.7
++else
+ DOCS=qemu-doc.html qemu-doc.txt qemu.1 qemu-img.1 qemu-nbd.8 qemu-ga.8
+ DOCS+=docs/interop/qemu-qmp-ref.html docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7
+ DOCS+=docs/interop/qemu-ga-ref.html docs/interop/qemu-ga-ref.txt docs/interop/qemu-ga-ref.7
++endif
+ DOCS+=docs/qemu-block-drivers.7
+ ifdef CONFIG_VIRTFS
+ DOCS+=fsdev/virtfs-proxy-helper.1
+@@ -812,11 +817,13 @@ BLOBS=
+ endif
+
+ install-doc: $(DOCS)
++ifndef NOPORTDOCS
+ $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)"
+ $(INSTALL_DATA) qemu-doc.html "$(DESTDIR)$(qemu_docdir)"
+ $(INSTALL_DATA) qemu-doc.txt "$(DESTDIR)$(qemu_docdir)"
+ $(INSTALL_DATA) docs/interop/qemu-qmp-ref.html "$(DESTDIR)$(qemu_docdir)"
+ $(INSTALL_DATA) docs/interop/qemu-qmp-ref.txt "$(DESTDIR)$(qemu_docdir)"
++endif
+ ifdef CONFIG_POSIX
+ $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
+ $(INSTALL_DATA) qemu.1 "$(DESTDIR)$(mandir)/man1"
+@@ -830,8 +837,10 @@ ifneq ($(TOOLS),)
+ endif
+ ifneq (,$(findstring qemu-ga,$(TOOLS)))
+ $(INSTALL_DATA) qemu-ga.8 "$(DESTDIR)$(mandir)/man8"
++ifndef NOPORTDOCS
+ $(INSTALL_DATA) docs/interop/qemu-ga-ref.html "$(DESTDIR)$(qemu_docdir)"
+ $(INSTALL_DATA) docs/interop/qemu-ga-ref.txt "$(DESTDIR)$(qemu_docdir)"
++endif
+ $(INSTALL_DATA) docs/interop/qemu-ga-ref.7 "$(DESTDIR)$(mandir)/man7"
+ endif
+ endif
diff --git a/emulators/qemu30/files/patch-configure b/emulators/qemu30/files/patch-configure
new file mode 100644
index 000000000000..73b581bc594b
--- /dev/null
+++ b/emulators/qemu30/files/patch-configure
@@ -0,0 +1,264 @@
+--- configure.orig 2019-04-14 21:25:18 UTC
++++ configure
+@@ -375,6 +375,7 @@ hax="no"
+ hvf="no"
+ whpx="no"
+ rdma=""
++pvrdma=""
+ gprof="no"
+ debug_tcg="no"
+ debug="no"
+@@ -391,7 +392,7 @@ DSOSUF=".so"
+ LDFLAGS_SHARED="-shared"
+ modules="no"
+ prefix="/usr/local"
+-mandir="\${prefix}/share/man"
++mandir="\${prefix}/man"
+ datadir="\${prefix}/share"
+ firmwarepath="\${prefix}/share/qemu-firmware"
+ qemu_docdir="\${prefix}/share/doc/qemu"
+@@ -471,6 +472,9 @@ numa=""
+ tcmalloc="no"
+ jemalloc="no"
+ replication="yes"
++pcap="no"
++pcap_create="no"
++bpf="no"
+ vxhs=""
+ libxml2=""
+ docker="no"
+@@ -1087,6 +1091,10 @@ for opt do
+ ;;
+ --enable-vnc-png) vnc_png="yes"
+ ;;
++ --enable-pcap) pcap="yes"
++ ;;
++ --disable-pcap) pcap="no"
++ ;;
+ --disable-slirp) slirp="no"
+ ;;
+ --disable-vde) vde="no"
+@@ -1363,6 +1371,10 @@ for opt do
+ ;;
+ --disable-rdma) rdma="no"
+ ;;
++ --enable-pvrdma) pvrdma="yes"
++ ;;
++ --disable-pvrdma) pvrdma="no"
++ ;;
+ --with-gtkabi=*) gtkabi="$optarg"
+ ;;
+ --disable-vte) vte="no"
+@@ -1669,7 +1681,8 @@ disabled with --disable-FEATURE, default is enabled if
+ hax HAX acceleration support
+ hvf Hypervisor.framework acceleration support
+ whpx Windows Hypervisor Platform acceleration support
+- rdma Enable RDMA-based migration and PVRDMA support
++ rdma Enable RDMA-based migration
++ pvrdma Enable PVRDMA support
+ vde support for vde network
+ netmap support for netmap network
+ linux-aio Linux AIO support
+@@ -2881,7 +2894,49 @@ else
+ tasn1=no
+ fi
+
++##########################################
++# PVRDMA detection
+
++cat > $TMPC <<EOF &&
++#include <sys/mman.h>
++
++int
++main(void)
++{
++ char buf = 0;
++ void *addr = &buf;
++ addr = mremap(addr, 0, 1, MREMAP_MAYMOVE | MREMAP_FIXED);
++
++ return 0;
++}
++EOF
++
++if test "$rdma" = "yes" ; then
++ case "$pvrdma" in
++ "")
++ if compile_prog "" ""; then
++ pvrdma="yes"
++ else
++ pvrdma="no"
++ fi
++ ;;
++ "yes")
++ if ! compile_prog "" ""; then
++ error_exit "PVRDMA is not supported since mremap is not implemented"
++ fi
++ pvrdma="yes"
++ ;;
++ "no")
++ pvrdma="no"
++ ;;
++ esac
++else
++ if test "$pvrdma" = "yes" ; then
++ error_exit "PVRDMA requires rdma suppport"
++ fi
++ pvrdma="no"
++fi
++
+ ##########################################
+ # getifaddrs (for tests/test-io-channel-socket )
+
+@@ -2891,6 +2946,14 @@ if ! check_include "ifaddrs.h" ; then
+ fi
+
+ ##########################################
++# getifaddrs (for tests/test-io-channel-socket )
++
++have_ifaddrs_h=yes
++if ! check_include "ifaddrs.h" ; then
++ have_ifaddrs_h=no
++fi
++
++##########################################
+ # VTE probe
+
+ if test "$vte" != "no"; then
+@@ -3061,7 +3124,51 @@ EOF
+ fi
+ fi
+
++##########################################
++# pcap probe
+
++if test "$pcap" = "yes" -a "$pcap" != "no"; then
++ cat > $TMPC << EOF
++#include <pcap.h>
++int main(void) { return (pcap_lib_version() == (char *)0 ? 1 : 0); }
++EOF
++ if test "$mingw32" = "no" ; then
++ libpcap=-lpcap
++ else
++ libpcap=-lwpcap
++ fi
++ if compile_prog "" "$libpcap" ; then
++ :
++ else
++ echo
++ echo "Error: Could not find pcap"
++ echo "Make sure to have the pcap libs and headers installed."
++ echo
++ exit 1
++ fi
++ cat > $TMPC << EOF
++#include <pcap.h>
++int main(void)
++{
++ char errbuf[PCAP_ERRBUF_SIZE];
++ return (pcap_create("foo", errbuf) == (pcap_t *)0 ? 1 : 0);
++}
++EOF
++ if compile_prog "" "$libpcap" ; then
++ pcap_create="yes"
++ fi
++ cat > $TMPC << EOF
++#define PCAP_DONT_INCLUDE_PCAP_BPF_H
++#include <pcap.h>
++#include <net/bpf.h>
++int main(void) { return (BPF_MAJOR_VERSION); }
++EOF
++ if compile_prog ; then
++ bpf="yes"
++ fi
++ libs_softmmu="$libpcap $libs_softmmu"
++fi # test "$pcap"
++
+ ##########################################
+ # VNC SASL detection
+ if test "$vnc" = "yes" -a "$vnc_sasl" != "no" ; then
+@@ -3474,7 +3581,7 @@ for i in $glib_modules; do
+ glib_libs=$($pkg_config --libs $i)
+ QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
+ LIBS="$glib_libs $LIBS"
+- libs_qga="$glib_libs $libs_qga"
++ libs_qga="$glib_libs -lintl $libs_qga"
+ else
+ error_exit "glib-$glib_req_ver $i is required to compile QEMU"
+ fi
+@@ -4419,14 +4526,7 @@ fi
+
+ # Check if tools are available to build documentation.
+ if test "$docs" != "no" ; then
+- if has makeinfo && has pod2man; then
+ docs=yes
+- else
+- if test "$docs" = "yes" ; then
+- feature_not_found "docs" "Install texinfo and Perl/perl-podlators"
+- fi
+- docs=no
+- fi
+ fi
+
+ # Search for bswap_32 function
+@@ -4551,7 +4651,7 @@ fi
+
+ # check for libusb
+ if test "$libusb" != "no" ; then
+- if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
++ if $pkg_config libusb-1.0; then
+ libusb="yes"
+ libusb_cflags=$($pkg_config --cflags libusb-1.0)
+ libusb_libs=$($pkg_config --libs libusb-1.0)
+@@ -5914,6 +6014,7 @@ echo "Audio drivers $audio_drv_list"
+ echo "Block whitelist (rw) $block_drv_rw_whitelist"
+ echo "Block whitelist (ro) $block_drv_ro_whitelist"
+ echo "VirtFS support $virtfs"
++echo "pcap support $pcap"
+ echo "Multipath support $mpath"
+ echo "VNC support $vnc"
+ if test "$vnc" = "yes" ; then
+@@ -5949,6 +6050,7 @@ if test "$tcg" = "yes" ; then
+ fi
+ echo "malloc trim support $malloc_trim"
+ echo "RDMA support $rdma"
++echo "PVRDMA support $pvrdma"
+ echo "fdt support $fdt"
+ echo "membarrier $membarrier"
+ echo "preadv support $preadv"
+@@ -6143,6 +6245,15 @@ fi
+ if test "$profiler" = "yes" ; then
+ echo "CONFIG_PROFILER=y" >> $config_host_mak
+ fi
++if test "$pcap" = "yes" ; then
++ echo "CONFIG_PCAP=y" >> $config_host_mak
++ if test "$pcap_create" = "yes" ; then
++ echo "CONFIG_PCAP_CREATE=y" >> $config_host_mak
++ fi
++ if test "$bpf" = "yes" ; then
++ echo "CONFIG_BPF=y" >> $config_host_mak
++ fi
++fi
+ if test "$slirp" = "yes" ; then
+ echo "CONFIG_SLIRP=y" >> $config_host_mak
+ echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
+@@ -6384,6 +6495,9 @@ fi
+ if test "$have_fsxattr" = "yes" ; then
+ echo "HAVE_FSXATTR=y" >> $config_host_mak
+ fi
++if test "$have_ifaddrs_h" = "yes" ; then
++ echo "HAVE_IFADDRS_H=y" >> $config_host_mak
++fi
+ if test "$have_copy_file_range" = "yes" ; then
+ echo "HAVE_COPY_FILE_RANGE=y" >> $config_host_mak
+ fi
+@@ -6703,6 +6817,10 @@ echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_m
+ if test "$rdma" = "yes" ; then
+ echo "CONFIG_RDMA=y" >> $config_host_mak
+ echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
++fi
++
++if test "$pvrdma" = "yes" ; then
++ echo "CONFIG_PVRDMA=y" >> $config_host_mak
+ fi
+
+ if test "$have_rtnetlink" = "yes" ; then
diff --git a/emulators/qemu30/files/patch-disas_libvixl_vixl_a64_disasm-a64.cc b/emulators/qemu30/files/patch-disas_libvixl_vixl_a64_disasm-a64.cc
new file mode 100644
index 000000000000..debacff9c250
--- /dev/null
+++ b/emulators/qemu30/files/patch-disas_libvixl_vixl_a64_disasm-a64.cc
@@ -0,0 +1,11 @@
+--- disas/libvixl/vixl/a64/disasm-a64.cc.orig 2019-04-12 03:28:28 UTC
++++ disas/libvixl/vixl/a64/disasm-a64.cc
+@@ -2693,7 +2693,7 @@ void Disassembler::AppendPCRelativeOffsetToOutput(cons
+ if (offset < 0) {
+ abs_offset = -abs_offset;
+ }
+- AppendToOutput("#%c0x%" PRIx64, sign, abs_offset);
++ AppendToOutput("#%c0x%" PRIx64, sign, offset < 0 ? -offset : offset);
+ }
+
+
diff --git a/emulators/qemu30/files/patch-hw_rdma_Makefile.objs b/emulators/qemu30/files/patch-hw_rdma_Makefile.objs
new file mode 100644
index 000000000000..8be728796d98
--- /dev/null
+++ b/emulators/qemu30/files/patch-hw_rdma_Makefile.objs
@@ -0,0 +1,8 @@
+--- hw/rdma/Makefile.objs.orig 2019-04-12 03:28:28 UTC
++++ hw/rdma/Makefile.objs
+@@ -1,4 +1,4 @@
+-ifeq ($(CONFIG_RDMA),y)
++ifeq ($(CONFIG_PVRDMA),y)
+ obj-$(CONFIG_PCI) += rdma_utils.o rdma_backend.o rdma_rm.o
+ obj-$(CONFIG_PCI) += vmw/pvrdma_dev_ring.o vmw/pvrdma_cmd.o \
+ vmw/pvrdma_qp_ops.o vmw/pvrdma_main.o
diff --git a/emulators/qemu30/files/patch-hw_rdma_vmw_pvrdma__cmd.c b/emulators/qemu30/files/patch-hw_rdma_vmw_pvrdma__cmd.c
new file mode 100644
index 000000000000..1da747376deb
--- /dev/null
+++ b/emulators/qemu30/files/patch-hw_rdma_vmw_pvrdma__cmd.c
@@ -0,0 +1,10 @@
+--- hw/rdma/vmw/pvrdma_cmd.c.orig 2019-04-12 03:28:28 UTC
++++ hw/rdma/vmw/pvrdma_cmd.c
+@@ -16,7 +16,6 @@
+ #include "qemu/osdep.h"
+ #include "qemu/error-report.h"
+ #include "cpu.h"
+-#include <linux/types.h>
+ #include "hw/hw.h"
+ #include "hw/pci/pci.h"
+ #include "hw/pci/pci_ids.h"
diff --git a/emulators/qemu30/files/patch-include_net_net.h b/emulators/qemu30/files/patch-include_net_net.h
new file mode 100644
index 000000000000..a909f8693029
--- /dev/null
+++ b/emulators/qemu30/files/patch-include_net_net.h
@@ -0,0 +1,13 @@
+--- include/net/net.h.orig 2019-04-12 03:28:28 UTC
++++ include/net/net.h
+@@ -210,8 +210,8 @@ void qmp_netdev_add(QDict *qdict, QObject **ret, Error
+ int net_hub_id_for_client(NetClientState *nc, int *id);
+ NetClientState *net_hub_port_find(int hub_id);
+
+-#define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup"
+-#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown"
++#define DEFAULT_NETWORK_SCRIPT PREFIX "/etc/qemu-ifup"
++#define DEFAULT_NETWORK_DOWN_SCRIPT PREFIX "/etc/qemu-ifdown"
+ #define DEFAULT_BRIDGE_HELPER CONFIG_QEMU_HELPERDIR "/qemu-bridge-helper"
+ #define DEFAULT_BRIDGE_INTERFACE "br0"
+
diff --git a/emulators/qemu30/files/patch-include_qemu_atomic.h b/emulators/qemu30/files/patch-include_qemu_atomic.h
new file mode 100644
index 000000000000..c57a273abfe5
--- /dev/null
+++ b/emulators/qemu30/files/patch-include_qemu_atomic.h
@@ -0,0 +1,54 @@
+--- include/qemu/atomic.h.orig 2019-04-12 03:28:28 UTC
++++ include/qemu/atomic.h
+@@ -200,10 +200,12 @@
+ /* Provide shorter names for GCC atomic builtins, return old value */
+ #define atomic_fetch_inc(ptr) __atomic_fetch_add(ptr, 1, __ATOMIC_SEQ_CST)
+ #define atomic_fetch_dec(ptr) __atomic_fetch_sub(ptr, 1, __ATOMIC_SEQ_CST)
++#ifndef __cplusplus
+ #define atomic_fetch_add(ptr, n) __atomic_fetch_add(ptr, n, __ATOMIC_SEQ_CST)
+ #define atomic_fetch_sub(ptr, n) __atomic_fetch_sub(ptr, n, __ATOMIC_SEQ_CST)
+ #define atomic_fetch_and(ptr, n) __atomic_fetch_and(ptr, n, __ATOMIC_SEQ_CST)
+ #define atomic_fetch_or(ptr, n) __atomic_fetch_or(ptr, n, __ATOMIC_SEQ_CST)
++#endif
+ #define atomic_fetch_xor(ptr, n) __atomic_fetch_xor(ptr, n, __ATOMIC_SEQ_CST)
+
+ #define atomic_inc_fetch(ptr) __atomic_add_fetch(ptr, 1, __ATOMIC_SEQ_CST)
+@@ -217,10 +219,12 @@
+ /* And even shorter names that return void. */
+ #define atomic_inc(ptr) ((void) __atomic_fetch_add(ptr, 1, __ATOMIC_SEQ_CST))
+ #define atomic_dec(ptr) ((void) __atomic_fetch_sub(ptr, 1, __ATOMIC_SEQ_CST))
++#ifndef __cplusplus
+ #define atomic_add(ptr, n) ((void) __atomic_fetch_add(ptr, n, __ATOMIC_SEQ_CST))
+ #define atomic_sub(ptr, n) ((void) __atomic_fetch_sub(ptr, n, __ATOMIC_SEQ_CST))
+ #define atomic_and(ptr, n) ((void) __atomic_fetch_and(ptr, n, __ATOMIC_SEQ_CST))
+ #define atomic_or(ptr, n) ((void) __atomic_fetch_or(ptr, n, __ATOMIC_SEQ_CST))
++#endif
+ #define atomic_xor(ptr, n) ((void) __atomic_fetch_xor(ptr, n, __ATOMIC_SEQ_CST))
+
+ #else /* __ATOMIC_RELAXED */
+@@ -388,10 +392,12 @@
+
+ #define atomic_inc_fetch(ptr) __sync_add_and_fetch(ptr, 1)
+ #define atomic_dec_fetch(ptr) __sync_add_and_fetch(ptr, -1)
++#ifndef __cplusplus
+ #define atomic_add_fetch(ptr, n) __sync_add_and_fetch(ptr, n)
+ #define atomic_sub_fetch(ptr, n) __sync_sub_and_fetch(ptr, n)
+ #define atomic_and_fetch(ptr, n) __sync_and_and_fetch(ptr, n)
+ #define atomic_or_fetch(ptr, n) __sync_or_and_fetch(ptr, n)
++#endif
+ #define atomic_xor_fetch(ptr, n) __sync_xor_and_fetch(ptr, n)
+
+ #define atomic_cmpxchg(ptr, old, new) __sync_val_compare_and_swap(ptr, old, new)
+@@ -400,10 +406,12 @@
+ /* And even shorter names that return void. */
+ #define atomic_inc(ptr) ((void) __sync_fetch_and_add(ptr, 1))
+ #define atomic_dec(ptr) ((void) __sync_fetch_and_add(ptr, -1))
++#ifndef __cplusplus
+ #define atomic_add(ptr, n) ((void) __sync_fetch_and_add(ptr, n))
+ #define atomic_sub(ptr, n) ((void) __sync_fetch_and_sub(ptr, n))
+ #define atomic_and(ptr, n) ((void) __sync_fetch_and_and(ptr, n))
+ #define atomic_or(ptr, n) ((void) __sync_fetch_and_or(ptr, n))
++#endif
+ #define atomic_xor(ptr, n) ((void) __sync_fetch_and_xor(ptr, n))
+
+ #endif /* __ATOMIC_RELAXED */
diff --git a/emulators/qemu30/files/patch-net_tap-bsd.c b/emulators/qemu30/files/patch-net_tap-bsd.c
new file mode 100644
index 000000000000..bc2d0ec5b43f
--- /dev/null
+++ b/emulators/qemu30/files/patch-net_tap-bsd.c
@@ -0,0 +1,10 @@
+--- net/tap-bsd.c.orig 2019-04-12 03:28:28 UTC
++++ net/tap-bsd.c
+@@ -31,6 +31,7 @@
+
+ #if defined(__NetBSD__) || defined(__FreeBSD__)
+ #include <sys/ioctl.h>
++#include <sys/socket.h>
+ #include <net/if.h>
+ #include <net/if_tap.h>
+ #endif
diff --git a/emulators/qemu30/files/patch-qemu-doc.texi b/emulators/qemu30/files/patch-qemu-doc.texi
new file mode 100644
index 000000000000..a99fae61e45f
--- /dev/null
+++ b/emulators/qemu30/files/patch-qemu-doc.texi
@@ -0,0 +1,21 @@
+--- qemu-doc.texi.orig 2019-04-12 03:28:29 UTC
++++ qemu-doc.texi
+@@ -198,7 +198,7 @@ VGA BIOS.
+ QEMU uses YM3812 emulation by Tatsuyuki Satoh.
+
+ QEMU uses GUS emulation (GUSEMU32 @url{http://www.deinmeister.de/gusemu/})
+-by Tibor "TS" Schütz.
++by Tibor "TS" Schuetz.
+
+ Note that, by default, GUS shares IRQ(7) with parallel ports and so
+ QEMU must be told to not have parallel ports to have working GUS.
+@@ -558,7 +558,8 @@ Send the escape character to the frontend
+
+ @c man begin SEEALSO
+ The HTML documentation of QEMU for more precise information and Linux
+-user mode emulator invocation.
++user mode emulator invocation, as well as the FreeBSD host notes in
++@file{pkg-message} in the relevant qemu port directory.
+ @c man end
+
+ @c man begin AUTHOR
diff --git a/emulators/qemu30/files/pcap-patch b/emulators/qemu30/files/pcap-patch
new file mode 100644
index 000000000000..39114c65d591
--- /dev/null
+++ b/emulators/qemu30/files/pcap-patch
@@ -0,0 +1,56 @@
+--- qapi/net.json.orig 2018-04-24 16:30:47 UTC
++++ qapi/net.json
+@@ -388,6 +388,19 @@
+ '*helper': 'str' } }
+
+ ##
++# @NetdevPcapOptions:
++#
++# Use ifname as a source to capture
++#
++# @ifname: #required to determine which interface to capture
++#
++# Since: 1.2
++##
++{ 'struct': 'NetdevPcapOptions',
++ 'data': {
++ '*ifname': 'str' } }
++
++##
+ # @NetdevHubPortOptions:
+ #
+ # Connect two or more net clients through a software hub.
+@@ -454,7 +467,7 @@
+ ##
+ { 'enum': 'NetClientDriver',
+ 'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde',
+- 'bridge', 'hubport', 'netmap', 'vhost-user' ] }
++ 'bridge', 'hubport', 'netmap', 'vhost-user', 'pcap' ] }
+
+ ##
+ # @Netdev:
+@@ -478,6 +491,7 @@
+ 'user': 'NetdevUserOptions',
+ 'tap': 'NetdevTapOptions',
+ 'l2tpv3': 'NetdevL2TPv3Options',
++ 'pcap': 'NetdevPcapOptions',
+ 'socket': 'NetdevSocketOptions',
+ 'vde': 'NetdevVdeOptions',
+ 'bridge': 'NetdevBridgeOptions',
+@@ -514,7 +528,7 @@
+ ##
+ { 'enum': 'NetLegacyOptionsType',
+ 'data': ['none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde',
+- 'bridge', 'netmap', 'vhost-user'] }
++ 'bridge', 'netmap', 'vhost-user', 'pcap'] }
+
+ ##
+ # @NetLegacyOptions:
+@@ -532,6 +546,7 @@
+ 'user': 'NetdevUserOptions',
+ 'tap': 'NetdevTapOptions',
+ 'l2tpv3': 'NetdevL2TPv3Options',
++ 'pcap': 'NetdevPcapOptions',
+ 'socket': 'NetdevSocketOptions',
+ 'vde': 'NetdevVdeOptions',
+ 'bridge': 'NetdevBridgeOptions',
diff --git a/emulators/qemu30/files/pcap-patch-net_clients.h b/emulators/qemu30/files/pcap-patch-net_clients.h
new file mode 100644
index 000000000000..5b56f1b2f49a
--- /dev/null
+++ b/emulators/qemu30/files/pcap-patch-net_clients.h
@@ -0,0 +1,13 @@
+--- net/clients.h.orig 2018-04-24 16:30:47 UTC
++++ net/clients.h
+@@ -61,4 +61,10 @@ int net_init_netmap(const Netdev *netdev, const char *
+ int net_init_vhost_user(const Netdev *netdev, const char *name,
+ NetClientState *peer, Error **errp);
+
++#ifdef CONFIG_PCAP
++int net_init_pcap(const Netdev *netdev, const char *name,
++ NetClientState *peer, Error **errp);
++#endif
++
++
+ #endif /* QEMU_NET_CLIENTS_H */
diff --git a/emulators/qemu30/files/pcap-patch-net_net.c b/emulators/qemu30/files/pcap-patch-net_net.c
new file mode 100644
index 000000000000..6fa5ca941f7d
--- /dev/null
+++ b/emulators/qemu30/files/pcap-patch-net_net.c
@@ -0,0 +1,250 @@
+--- net/net.c.orig 2018-04-24 16:30:47 UTC
++++ net/net.c
+@@ -52,6 +52,11 @@
+ #include "net/filter.h"
+ #include "qapi/string-output-visitor.h"
+
++#include <sys/ioctl.h>
++#ifdef __FreeBSD__
++#include <net/if.h>
++#endif
++
+ /* Net bridge is currently not supported for W32. */
+ #if !defined(_WIN32)
+ # define CONFIG_NET_BRIDGE
+@@ -929,7 +934,225 @@ static int net_init_nic(const Netdev *netdev, const ch
+ return idx;
+ }
+
++#if defined(CONFIG_PCAP)
++#if defined(CONFIG_BPF)
++#define PCAP_DONT_INCLUDE_PCAP_BPF_H
++#include <net/bpf.h>
++#endif
++#include <pcap.h>
+
++struct PCAPState {
++ NetClientState nc;
++ pcap_t *handle;
++ int max_eth_frame_size;
++};
++
++static ssize_t pcap_receive(NetClientState *nc, const uint8_t *buf, size_t size)
++{
++ struct PCAPState *s = DO_UPCAST(struct PCAPState, nc, nc);
++
++ return pcap_inject(s->handle, (u_char*)buf, size);
++}
++
++static void pcap_callback(u_char *user, struct pcap_pkthdr *phdr, u_char *pdata
++ )
++{
++ NetClientState *nc = (NetClientState *)user;
++
++ int len = phdr->len;
++#ifdef __FreeBSD__
++ struct PCAPState *s = DO_UPCAST(struct PCAPState, nc, nc);
++ int max_eth_frame_size = s->max_eth_frame_size;
++
++ if (len > max_eth_frame_size) {
++ fprintf(stderr,
++ "pcap_send: packet size > %d (%d), truncating\n",
++ max_eth_frame_size, len);
++ len = max_eth_frame_size;
++ }
++#endif
++ qemu_send_packet(nc, pdata, len);
++}
++
++static void pcap_send(void *opaque)
++{
++ struct PCAPState *s = (struct PCAPState *)opaque;
++
++ for (;;) {
++ if (pcap_dispatch(s->handle, 0, (pcap_handler)&pcap_callback, (u_char *)&s->nc) >= 0)
++ break;
++ }
++}
++
++static void pcap_cleanup(NetClientState *nc)
++{
++ struct PCAPState *s = DO_UPCAST(struct PCAPState, nc, nc);
++
++ qemu_purge_queued_packets(nc);
++ pcap_close(s->handle);
++}
++
++static NetClientInfo net_pcap_info = {
++ .type = NET_CLIENT_DRIVER_PCAP,
++ .size = sizeof(struct PCAPState),
++ .receive = pcap_receive,
++// .receive_raw = pcap_receive_raw,
++// .receive_iov = pcap_receive_iov,
++// .poll = pcap_poll,
++ .cleanup = pcap_cleanup,
++};
++/*
++ * ... -net pcap,ifname="..."
++ */
++
++int net_init_pcap(const Netdev *netdev,
++ const char *name, NetClientState *peer, Error **errp)
++{
++ const NetdevPcapOptions *pcap_opts;
++ NetClientState *nc;
++ struct PCAPState *s;
++ const char *ifname;
++ char errbuf[PCAP_ERRBUF_SIZE];
++#if defined(_WIN32)
++ HANDLE h;
++#endif
++ int i;
++
++ assert(netdev->type == NET_CLIENT_DRIVER_PCAP);
++ pcap_opts = &netdev->u.pcap;
++ if (!pcap_opts->has_ifname)
++ return -1;
++
++ ifname = pcap_opts->ifname;
++
++ /* create the object */
++ nc = qemu_new_net_client(&net_pcap_info, peer, "pcap", ifname);
++ s = DO_UPCAST(struct PCAPState, nc, nc);
++
++ if (ifname == NULL && (ifname = pcap_lookupdev(errbuf)) == NULL) {
++ fprintf(stderr, "qemu: pcap_create: %s\n", errbuf);
++ goto fail;
++ }
++
++#ifdef __FreeBSD__
++ /*
++ * We want to avoid passing oversize packets to the guest, which
++ * at least on FreeBSD can happen if the host interface uses tso
++ * (seen with an em(4) in this case) - so find out the host
++ * interface's mtu and assume the guest is configured the same.
++ */
++ s->max_eth_frame_size = 1514;
++ i = socket(AF_INET, SOCK_DGRAM, 0);
++ if (i >= 0) {
++ struct ifreq ifr;
++
++ (void) memset(&ifr, 0, sizeof(ifr));
++ strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
++ if (ioctl(i, SIOCGIFMTU, &ifr) != -1)
++ s->max_eth_frame_size = ifr.ifr_mtu + 14;
++ close(i);
++ }
++#endif
++
++#if defined(CONFIG_PCAP_CREATE) || defined(_WIN32)
++ /*
++ * Create pcap handle for the device, set promiscuous mode and activate.
++ */
++ s->handle = (void *)pcap_create(ifname, errbuf);
++ if (!s->handle) {
++ fprintf(stderr, "qemu: pcap_create: %s\n", errbuf);
++ goto fail;
++ }
++ if (pcap_set_promisc(s->handle, 1) != 0) {
++ pcap_perror(s->handle, (char *)"qemu: pcap_set_promisc:");
++ goto fail;
++ }
++ if (pcap_activate(s->handle) != 0) {
++ pcap_perror(s->handle, (char *)"qemu: pcap_activate:");
++ goto fail;
++ }
++#else
++ /* Attempt to connect device. */
++ s->handle = (void *)pcap_open_live(ifname, 65535, 1, 0, errbuf);
++ if (!s->handle) {
++ fprintf(stderr, "qemu: pcap_open_live: %s\n", errbuf);
++ goto fail;
++ }
++#endif
++
++ /* Set non-blocking mode. */
++ if (pcap_setnonblock(s->handle, 1, errbuf) < 0) {
++ fprintf(stderr, "qemu: pcap_setnonblock: %s\n", errbuf);
++ goto fail;
++ }
++
++#if defined(_WIN32)
++ /*
++ * Tell the kernel that the packet has to be seen immediately.
++ */
++ if (pcap_setmintocopy(s->handle, 0) < 0) {
++ fprintf(stderr, "qemu: pcap failed to set immediate mode\n");
++ goto fail;
++ }
++#else /* !_WIN32 */
++#if defined(CONFIG_BPF)
++#if defined(BIOCIMMEDIATE)
++ /*
++ * Tell the kernel that the packet has to be seen immediately.
++ */
++ {
++ unsigned int one = 1;
++ if (ioctl(pcap_fileno(s->handle), BIOCIMMEDIATE, &one) < 0) {
++ fprintf(stderr, "qemu: pcap failed to set immediate mode\n");
++ goto fail;
++ }
++ }
++#endif /* BIOCIMMEDIATE */
++#if defined(BIOCFEEDBACK)
++ /*
++ * Tell the kernel that the sent packet has to be fed back.
++ * This is necessary to connect host and guest.
++ */
++ {
++ unsigned int one = 1;
++ if (ioctl(pcap_fileno(s->handle), BIOCFEEDBACK, &one) < 0) {
++ fprintf(stderr, "qemu: pcap failed to set feedback mode\n");
++ goto fail;
++ }
++ }
++#endif /* BIOCFEEDBACK */
++#endif /* CONFIG_BPF */
++#endif /* _WIN32 */
++
++ snprintf(s->nc.info_str, sizeof(s->nc.info_str), "pcap redirector");
++
++#if defined(_WIN32)
++ if ((h = pcap_getevent(s->handle)) == NULL) {
++ fprintf(stderr, "qemu: pcap_getevent failed\n");
++ goto fail;
++ }
++ qemu_add_wait_object(h, pcap_send, s);
++#else /* !_WIN32 */
++ if ((i = pcap_get_selectable_fd(s->handle)) < 0) {
++ fprintf(stderr, "qemu: pcap_get_selectable_fd failed\n");
++ goto fail;
++ }
++ qemu_set_fd_handler(i, pcap_send, NULL, s);
++#endif /* _WIN32 */
++
++ return 0;
++
++fail:
++ if (s) {
++ if (s->handle)
++ pcap_close(s->handle);
++ }
++
++ return -1;
++}
++
++#endif
++
+ static int (* const net_client_init_fun[NET_CLIENT_DRIVER__MAX])(
+ const Netdev *netdev,
+ const char *name,
+@@ -955,6 +1178,9 @@ static int (* const net_client_init_fun[NET_CLIENT_DRI
+ #endif
+ #ifdef CONFIG_L2TPV3
+ [NET_CLIENT_DRIVER_L2TPV3] = net_init_l2tpv3,
++#endif
++#ifdef CONFIG_PCAP
++ [NET_CLIENT_DRIVER_PCAP] = net_init_pcap,
+ #endif
+ };
+
diff --git a/emulators/qemu30/files/qemu-ifdown.sample b/emulators/qemu30/files/qemu-ifdown.sample
new file mode 100644
index 000000000000..89d9a9bff436
--- /dev/null
+++ b/emulators/qemu30/files/qemu-ifdown.sample
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec true
diff --git a/emulators/qemu30/files/qemu-ifup.sample b/emulators/qemu30/files/qemu-ifup.sample
new file mode 100644
index 000000000000..89d9a9bff436
--- /dev/null
+++ b/emulators/qemu30/files/qemu-ifup.sample
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec true