Date: Fri, 19 Aug 2016 20:52:57 +0000 (UTC) From: Muhammad Moinur Rahman <bofh@FreeBSD.org> To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r420489 - in head/emulators/qemu: . files Message-ID: <201608192052.u7JKqvhv098087@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: bofh Date: Fri Aug 19 20:52:57 2016 New Revision: 420489 URL: https://svnweb.freebsd.org/changeset/ports/420489 Log: emulators/qemu: Update version 2.5.1.1=>2.6.1 - Remove BSD_USER related codes - Add NCURSES support [1] - Fix STATIC_LINKS code to not build with X11 support PR: 211973 [1] Submitted by: ilavsky.martin@gmail.com [1] Added: head/emulators/qemu/files/patch-disas_libvixl_vixl_a64_disasm-a64.cc (contents, props changed) head/emulators/qemu/files/pcap-patch-net_net.c (contents, props changed) Deleted: head/emulators/qemu/files/patch-disas_libvixl_a64_disasm-a64.cc head/emulators/qemu/files/patch-include_qemu-common.h Modified: head/emulators/qemu/Makefile head/emulators/qemu/distinfo head/emulators/qemu/files/patch-Makefile head/emulators/qemu/files/patch-configure head/emulators/qemu/files/pcap-patch head/emulators/qemu/pkg-plist Modified: head/emulators/qemu/Makefile ============================================================================== --- head/emulators/qemu/Makefile Fri Aug 19 19:26:26 2016 (r420488) +++ head/emulators/qemu/Makefile Fri Aug 19 20:52:57 2016 (r420489) @@ -2,7 +2,7 @@ # $FreeBSD$ PORTNAME= qemu -PORTVERSION= 2.5.1.1 +PORTVERSION= 2.6.1 CATEGORIES= emulators MASTER_SITES= http://wiki.qemu.org/download/ DIST_SUBDIR= qemu/${PORTVERSION} @@ -16,13 +16,13 @@ HAS_CONFIGURE= yes USES= cpe gmake pkgconfig bison perl5 python:2,build tar:bzip2 USE_PERL5= build USE_XORG= pixman -USE_GNOME+= glib20 +USE_GNOME+= cairo glib20 MAKE_ENV+= BSD_MAKE="${MAKE}" ONLY_FOR_ARCHS= amd64 i386 powerpc powerpc64 # XXX someone wants to debug sparc64 hosts? OPTIONS_DEFINE= SAMBA X11 GTK2 OPENGL GNUTLS SASL JPEG PNG CURL \ CDROM_DMA PCAP USBREDIR GNS3 X86_TARGETS \ - STATIC_LINK DOCS BSD_USER + STATIC_LINK DOCS NCURSES SAMBA_DESC= samba dependency (for -smb) GNUTLS_DESC= gnutls dependency (vnc encryption) SASL_DESC= cyrus-sasl dependency (vnc encryption) @@ -33,18 +33,16 @@ PCAP_DESC= pcap dependency (networking USBREDIR_DESC= usb device network redirection (experimental!) GNS3_DESC= gns3 patches (promiscuous multicast) X86_TARGETS_DESC= Build only x86 system targets -BSD_USER_DESC= Also build bsd-user targets (for testing) STATIC_LINK_DESC= Statically link the executables -OPTIONS_DEFAULT=X11 GTK2 OPENGL GNUTLS SASL JPEG PNG CDROM_DMA CURL PCAP GNS3 +OPTIONS_DEFAULT=X11 GTK2 OPENGL GNUTLS SASL JPEG PNG CDROM_DMA CURL PCAP GNS3 NCURSES OPTIONS_SUB= yes -X11_USE= SDL=sdl -X11_CONFIGURE_ON= --enable-sdl -X11_CONFIGURE_OFF= --disable-sdl +X11_USE= SDL=sdl XORG=x11,xext GNOME=gdkpixbuf2 +X11_CONFIGURE_ENABLE= sdl GTK2_USE= GNOME=gtk20,vte GTK2_USES= gettext GTK2_CONFIGURE_OFF= --disable-gtk --disable-vte GNUTLS_LIB_DEPENDS= libgnutls.so:security/gnutls -GNUTLS_CONFIGURE_OFF= --disable-vnc-tls +GNUTLS_CONFIGURE_OFF= --disable-gnutls SASL_LIB_DEPENDS= libsasl2.so:security/cyrus-sasl2 SASL_CONFIGURE_OFF= --disable-vnc-sasl JPEG_USES= jpeg @@ -59,76 +57,32 @@ USBREDIR_BUILD_DEPENDS= usbredir>=0.6:ne USBREDIR_RUN_DEPENDS= usbredir>=0.6:net/usbredir USBREDIR_CONFIGURE_OFF= --disable-usb-redir PCAP_CONFIGURE_ON= --enable-pcap +PCAP_EXTRA_PATCHES= ${FILESDIR}/pcap-patch ${FILESDIR}/pcap-patch-net_net.c STATIC_LINK_CONFIGURE_ON= --static +STATIC_LINK_PREVENTS= GTK2 X11 +STATIC_LINK_PREVENTS_MSG= X11 ui cannot be built static +NCURSES_USES= ncurses SAMBA_RUN_DEPENDS= ${LOCALBASE}/sbin/smbd:net/samba36 DOCS_BUILD_DEPENDS= texi2html:textproc/texi2html DOCS_USES= makeinfo DOCS_MAKE_ARGS_OFF= NOPORTDOCS=1 -.if !defined(QEMU_USER_STATIC) -CONFLICTS_INSTALL= qemu-devel-[0-9]* qemu-sbruno-[0-9]* -.endif - PORTDOCS= docs qemu-doc.html qemu-tech.html qmp-commands.txt WITHOUT_CPU_CFLAGS=yes #to avoid problems with register allocation CFLAGS:= ${CFLAGS:C/-fno-tree-vrp//} CONFIGURE_ARGS+=--localstatedir=/var --extra-ldflags=-L\"${LOCALBASE}/lib\" \ - --disable-libssh2 --enable-debug \ + --disable-libssh2 --enable-debug --enable-curses \ --prefix=${PREFIX} --cc=${CC} --enable-docs --disable-kvm \ --disable-linux-user --disable-linux-aio --disable-xen \ --smbd=${LOCALBASE}/sbin/smbd --enable-debug-info --python=${PYTHON_CMD} \ --extra-cflags=-I${WRKSRC}\ -I${LOCALBASE}/include\ -DPREFIX=\\\"\"${PREFIX}\\\"\" -.include <bsd.port.options.mk> - -.if defined(QEMU_USER_STATIC) -.if ${ARCH} != "amd64" -CONFIGURE_ARGS+= --target-list=i386-bsd-user,sparc-bsd-user,arm-bsd-user,mips-bsd-user,mipsel-bsd-user -.else -CONFIGURE_ARGS+= --target-list=i386-bsd-user,x86_64-bsd-user,sparc-bsd-user,sparc64-bsd-user,arm-bsd-user,mips-bsd-user,mipsel-bsd-user,mips64-bsd-user,mips64el-bsd-user -.endif -.else -.if ${PORT_OPTIONS:MX86_TARGETS} -.if ${PORT_OPTIONS:MBSD_USER} -.if ${ARCH} != "amd64" -CONFIGURE_ARGS+= --target-list=i386-softmmu,x86_64-softmmu,i386-bsd-user,sparc-bsd-user,arm-bsd-user,mips-bsd-user,mipsel-bsd-user -.else -CONFIGURE_ARGS+= --target-list=i386-softmmu,x86_64-softmmu,i386-bsd-user,x86_64-bsd-user,sparc-bsd-user,sparc64-bsd-user,arm-bsd-user,mips-bsd-user,mipsel-bsd-user,mips64-bsd-user,mips64el-bsd-user -.endif -.else -CONFIGURE_ARGS+= --target-list=i386-softmmu,x86_64-softmmu -.endif -.else -.if empty(PORT_OPTIONS:MBSD_USER) -CONFIGURE_ARGS+= --disable-bsd-user -.else -.if ${ARCH} != "amd64" -CONFIGURE_ARGS+= --target-list=i386-softmmu,x86_64-softmmu,aarch64-softmmu,alpha-softmmu,arm-softmmu,cris-softmmu,lm32-softmmu,m68k-softmmu,microblaze-softmmu,microblazeel-softmmu,mips-softmmu,mipsel-softmmu,mips64-softmmu,mips64el-softmmu,or32-softmmu,ppc-softmmu,ppcemb-softmmu,ppc64-softmmu,sh4-softmmu,sh4eb-softmmu,sparc-softmmu,sparc64-softmmu,s390x-softmmu,xtensa-softmmu,xtensaeb-softmmu,unicore32-softmmu,moxie-softmmu,i386-bsd-user,sparc-bsd-user,arm-bsd-user,mips-bsd-user,mipsel-bsd-user -.endif -.endif -.endif -.endif - -.if ${PORT_OPTIONS:MBSD_USER} && ${ARCH} == "sparc64" -IGNORE= bsd-user targets not tested on sparc64 -.endif - -.if empty(PORT_OPTIONS:MBSD_USER) || ${ARCH} != "amd64" -PLIST_SUB+= BSD_USER64="@comment " -.else -PLIST_SUB+= BSD_USER64="" -.endif - -.if defined(QEMU_USER_STATIC) -PLIST_SUB+= SOFTMMU="@comment " STATIC="-static" -.else -PLIST_SUB+= SOFTMMU="" STATIC="" -.endif +LIB_DEPENDS+= libnettle.so:security/nettle \ + libfontconfig.so:x11-fonts/fontconfig \ + libfreetype.so:print/freetype2 -.if ${PORT_OPTIONS:MSTATIC_LINK} && (${PORT_OPTIONS:MGTK2} || ${PORT_OPTIONS:MX11}) -IGNORE= X11 ui cannot be built static -.endif +.include <bsd.port.options.mk> .if !defined(STRIP) || ${STRIP} == "" CONFIGURE_ARGS+=--disable-strip @@ -153,6 +107,9 @@ CONFIGURE_ARGS+= --sparc_cpu=v9 # -lprocstat actually only _needs_ -lelf after r249666 or r250870 (MFC) # but it shouldn't matter much post-patch: + @${REINPLACE_CMD} -e '/LIBS/s|-lprocstat|-lprocstat -lelf|' \ + ${WRKSRC}/configure + @${REINPLACE_CMD} -e '/libs_qga=/s|glib_libs|glib_libs -lintl|' ${WRKSRC}/configure @${REINPLACE_CMD} -E \ -e "/^by Tibor .TS. S/s|Sch.*z.$$|Schuetz.|" \ ${WRKSRC}/qemu-doc.texi @@ -175,9 +132,6 @@ post-patch-GNS3-on: @${REINPLACE_CMD} -e 's|(buf\[0\] & 1) && (rctl & E1000_RCTL_MPE)|buf[0] \& 1|' \ ${WRKSRC}/hw/net/e1000.c -post-patch-PCAP-on: - @cd ${WRKSRC} && ${PATCH} --quiet < ${FILESDIR}/pcap-patch - # XXX need to disable usb host code on head while it's not ported to the # new usb stack yet post-configure: @@ -190,6 +144,7 @@ post-install: ${INSTALL_SCRIPT} ${FILESDIR}/qemu-ifup.sample ${STAGEDIR}${PREFIX}/etc ${INSTALL_SCRIPT} ${FILESDIR}/qemu-ifdown.sample ${STAGEDIR}${PREFIX}/etc @${STRIP_CMD} ${STAGEDIR}${PREFIX}/bin/qemu-* + @${STRIP_CMD} ${STAGEDIR}${PREFIX}/bin/ivshmem-* post-install-DOCS-on: @(cd ${WRKSRC} && ${COPYTREE_SHARE} docs ${STAGEDIR}${DOCSDIR}/) Modified: head/emulators/qemu/distinfo ============================================================================== --- head/emulators/qemu/distinfo Fri Aug 19 19:26:26 2016 (r420488) +++ head/emulators/qemu/distinfo Fri Aug 19 20:52:57 2016 (r420489) @@ -1,3 +1,3 @@ -TIMESTAMP = 1464476316 -SHA256 (qemu/2.5.1.1/qemu-2.5.1.1.tar.bz2) = 28d9946e43765a44ccccca3cba5f4f9034f2759ec1f2ce16594ddb6776c8efe6 -SIZE (qemu/2.5.1.1/qemu-2.5.1.1.tar.bz2) = 25474902 +TIMESTAMP = 1471559363 +SHA256 (qemu/2.6.1/qemu-2.6.1.tar.bz2) = 4942fd1b6ee31f2f55ffc2201dd7397e6b9c55a2ef332e6d660c730d268e08d1 +SIZE (qemu/2.6.1/qemu-2.6.1.tar.bz2) = 25762855 Modified: head/emulators/qemu/files/patch-Makefile ============================================================================== --- head/emulators/qemu/files/patch-Makefile Fri Aug 19 19:26:26 2016 (r420488) +++ head/emulators/qemu/files/patch-Makefile Fri Aug 19 20:52:57 2016 (r420489) @@ -1,19 +1,18 @@ ---- Makefile.orig 2016-03-29 21:01:14 UTC +--- Makefile.orig 2016-04-14 20:19:53 UTC +++ Makefile -@@ -90,8 +90,12 @@ LIBS+=-lz $(LIBS_TOOLS) +@@ -90,7 +90,11 @@ LIBS+=-lz $(LIBS_TOOLS) HELPERS-$(CONFIG_LINUX) = qemu-bridge-helper$(EXESUF) ifdef BUILD_DOCS +ifdef NOPORTDOCS -+DOCS=qemu.1 qemu-img.1 qemu-nbd.8 ++DOCS=qemu.1 qemu-img.1 qemu-nbd.8 qemu-ga.8 +else DOCS=qemu-doc.html qemu-tech.html qemu.1 qemu-img.1 qemu-nbd.8 qemu-ga.8 - DOCS+=qmp-commands.txt +endif + DOCS+=qmp-commands.txt ifdef CONFIG_LINUX DOCS+=kvm_stat.1 - endif -@@ -407,8 +411,10 @@ endif +@@ -410,8 +414,10 @@ endif install-doc: $(DOCS) $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)" Modified: head/emulators/qemu/files/patch-configure ============================================================================== --- head/emulators/qemu/files/patch-configure Fri Aug 19 19:26:26 2016 (r420488) +++ head/emulators/qemu/files/patch-configure Fri Aug 19 20:52:57 2016 (r420489) @@ -1,6 +1,6 @@ ---- configure.orig 2016-03-30 17:53:28 UTC +--- configure.orig 2016-04-14 20:19:53 UTC +++ configure -@@ -276,7 +276,7 @@ DSOSUF=".so" +@@ -245,7 +245,7 @@ DSOSUF=".so" LDFLAGS_SHARED="-shared" modules="no" prefix="/usr/local" @@ -9,17 +9,27 @@ datadir="\${prefix}/share" qemu_docdir="\${prefix}/share/doc/qemu" bindir="\${prefix}/bin" -@@ -344,6 +344,9 @@ libssh2="" +@@ -316,6 +316,10 @@ virglrenderer="" + tpm="yes" + libssh2="" vhdx="" - numa="" - tcmalloc="no" ++quorum="no" +pcap="no" +pcap_create="no" +bpf="no" + numa="" + tcmalloc="no" jemalloc="no" - - # parse CC options first -@@ -905,6 +908,10 @@ for opt do +@@ -575,7 +579,7 @@ FreeBSD) + audio_drv_list="oss" + audio_possible_drivers="oss sdl pa" + # needed for kinfo_getvmmap(3) in libutil.h +- LIBS="-lutil $LIBS" ++ LIBS="-lprocstat -lkvm -lelf -lutil $LIBS" + netmap="" # enable netmap autodetect + HOST_VARIANT_DIR="freebsd" + ;; +@@ -878,6 +882,10 @@ for opt do ;; --enable-vnc-png) vnc_png="yes" ;; @@ -30,7 +40,7 @@ --disable-slirp) slirp="no" ;; --disable-uuid) uuid="no" -@@ -2241,7 +2248,7 @@ if test "$gtk" != "no"; then +@@ -2157,7 +2165,7 @@ if test "$gtk" != "no"; then gtk_cflags="$gtk_cflags $x11_cflags" gtk_libs="$gtk_libs $x11_libs" fi @@ -39,11 +49,28 @@ gtk="yes" elif test "$gtk" = "yes"; then feature_not_found "gtk" "Install gtk2 or gtk3 devel" -@@ -2413,6 +2420,50 @@ then +@@ -2384,6 +2392,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 +@@ -2526,6 +2542,50 @@ EOF + fi + fi + ++########################################## +# pcap probe ++ +if test "$pcap" = "yes" -a "$pcap" != "no"; then + cat > $TMPC << EOF +#include <pcap.h> @@ -57,7 +84,7 @@ + if compile_prog "" "$libpcap" ; then + : + else -+ echo ++ echo + echo "Error: Could not find pcap" + echo "Make sure to have the pcap libs and headers installed." + echo @@ -85,37 +112,25 @@ + fi + libs_softmmu="$libpcap $libs_softmmu" +fi # test "$pcap" -+ -+########################################## - # libtasn1 - only for the TLS creds/session test suite - tasn1=yes -@@ -2983,7 +3034,7 @@ for i in $glib_modules; do - glib_libs=`$pkg_config --libs $i` - CFLAGS="$glib_cflags $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 -@@ -3864,14 +3915,7 @@ fi + ########################################## + # VNC SASL detection +@@ -3857,14 +3917,7 @@ fi # Check if tools are available to build documentation. if test "$docs" != "no" ; then - if has makeinfo && has pod2man; then -- docs=yes + docs=yes - else - if test "$docs" = "yes" ; then - feature_not_found "docs" "Install texinfo and Perl/perl-podlators" - fi - docs=no - fi -+docs=yes fi # Search for bswap_32 function -@@ -3999,6 +4043,17 @@ fi +@@ -3992,6 +4045,17 @@ fi # check for libusb if test "$libusb" != "no" ; then @@ -133,7 +148,7 @@ if $pkg_config --atleast-version=1.0.13 libusb-1.0; then libusb="yes" libusb_cflags=$($pkg_config --cflags libusb-1.0) -@@ -4011,6 +4066,7 @@ if test "$libusb" != "no" ; then +@@ -4004,6 +4068,7 @@ if test "$libusb" != "no" ; then fi libusb="no" fi @@ -141,7 +156,7 @@ fi # check for usbredirparser for usb network redirection support -@@ -4773,6 +4829,7 @@ echo "Audio drivers $audio_drv_list" +@@ -4769,6 +4834,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" @@ -149,7 +164,7 @@ echo "VNC support $vnc" if test "$vnc" = "yes" ; then echo "VNC SASL support $vnc_sasl" -@@ -4951,6 +5008,15 @@ fi +@@ -4950,6 +5016,15 @@ fi if test "$profiler" = "yes" ; then echo "CONFIG_PROFILER=y" >> $config_host_mak fi @@ -165,3 +180,13 @@ if test "$slirp" = "yes" ; then echo "CONFIG_SLIRP=y" >> $config_host_mak echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak +@@ -5153,6 +5228,9 @@ fi + if test "$have_ifaddrs_h" = "yes" ; then + echo "HAVE_IFADDRS_H=y" >> $config_host_mak + fi ++if test "$have_ifaddrs_h" = "yes" ; then ++ echo "HAVE_IFADDRS_H=y" >> $config_host_mak ++fi + if test "$vte" = "yes" ; then + echo "CONFIG_VTE=y" >> $config_host_mak + echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak Added: head/emulators/qemu/files/patch-disas_libvixl_vixl_a64_disasm-a64.cc ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/emulators/qemu/files/patch-disas_libvixl_vixl_a64_disasm-a64.cc Fri Aug 19 20:52:57 2016 (r420489) @@ -0,0 +1,11 @@ +--- disas/libvixl/vixl/a64/disasm-a64.cc.orig 2016-04-14 20:19:53 UTC ++++ disas/libvixl/vixl/a64/disasm-a64.cc +@@ -2693,7 +2693,7 @@ void Disassembler::AppendPCRelativeOffse + if (offset < 0) { + abs_offset = -abs_offset; + } +- AppendToOutput("#%c0x%" PRIx64, sign, abs_offset); ++ AppendToOutput("#%c0x%" PRIx64, sign, offset < 0 ? -offset : offset); + } + + Modified: head/emulators/qemu/files/pcap-patch ============================================================================== --- head/emulators/qemu/files/pcap-patch Fri Aug 19 19:26:26 2016 (r420488) +++ head/emulators/qemu/files/pcap-patch Fri Aug 19 20:52:57 2016 (r420489) @@ -1,21 +1,22 @@ ---- net/clients.h.orig 2015-08-11 19:11:09 UTC -+++ net/clients.h -@@ -49,6 +49,12 @@ int net_init_bridge(const NetClientOptio - - int net_init_l2tpv3(const NetClientOptions *opts, const char *name, +diff -ruN net/clients.h net/clients.h +--- net/clients.h 2015-12-17 04:04:50.000000000 +0600 ++++ net/clients.h 2015-12-25 01:32:09.000000000 +0600 +@@ -47,6 +47,11 @@ + int net_init_bridge(const NetClientOptions *opts, const char *name, NetClientState *peer, Error **errp); -+ + +#ifdef CONFIG_PCAP +int net_init_pcap(const NetClientOptions *opts, const char *name, -+ NetClientState *peer); ++ NetClientState *peer, Error **errp); +#endif + + int net_init_l2tpv3(const NetClientOptions *opts, const char *name, + NetClientState *peer, Error **errp); #ifdef CONFIG_VDE - int net_init_vde(const NetClientOptions *opts, const char *name, - NetClientState *peer, Error **errp); ---- net/hub.c.orig 2015-08-11 19:11:09 UTC -+++ net/hub.c -@@ -322,6 +322,7 @@ void net_hub_check_clients(void) +diff -ruN net/hub.c net/hub.c +--- net/hub.c 2015-12-17 04:04:50.000000000 +0600 ++++ net/hub.c 2015-12-25 01:32:09.000000000 +0600 +@@ -322,6 +322,7 @@ case NET_CLIENT_OPTIONS_KIND_SOCKET: case NET_CLIENT_OPTIONS_KIND_VDE: case NET_CLIENT_OPTIONS_KIND_VHOST_USER: @@ -23,255 +24,10 @@ has_host_dev = 1; break; default: ---- net/net.c.orig 2015-08-11 19:11:09 UTC -+++ net/net.c -@@ -45,6 +45,11 @@ - #include "qapi/dealloc-visitor.h" - #include "sysemu/sysemu.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 -@@ -880,6 +885,221 @@ static int net_init_nic(const NetClientO - 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_OPTIONS_KIND_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 NetClientOptions *opts, const char *name, NetClientState *peer) -+{ -+ const NetdevPcapOptions *pcap_opts = opts->u.pcap; -+ NetClientState *nc; -+ struct PCAPState *s; -+ const char *ifname; -+ char errbuf[PCAP_ERRBUF_SIZE]; -+#if defined(_WIN32) -+ HANDLE h; -+#endif -+ int i; -+ -+ 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_OPTIONS_KIND_MAX])( - const NetClientOptions *opts, -@@ -901,6 +1121,9 @@ static int (* const net_client_init_fun[ - #ifdef CONFIG_NET_BRIDGE - [NET_CLIENT_OPTIONS_KIND_BRIDGE] = net_init_bridge, - #endif -+#ifdef CONFIG_PCAP -+ [NET_CLIENT_OPTIONS_KIND_PCAP] = net_init_pcap, -+#endif - [NET_CLIENT_OPTIONS_KIND_HUBPORT] = net_init_hubport, - #ifdef CONFIG_VHOST_NET_USED - [NET_CLIENT_OPTIONS_KIND_VHOST_USER] = net_init_vhost_user, ---- qapi-schema.json.orig 2015-08-11 19:11:09 UTC -+++ qapi-schema.json -@@ -2423,6 +2423,10 @@ +diff -ruN qapi-schema.json qapi-schema.json +--- qapi-schema.json 2015-12-17 04:04:50.000000000 +0600 ++++ qapi-schema.json 2015-12-25 01:32:09.000000000 +0600 +@@ -2538,6 +2538,10 @@ '*br': 'str', '*helper': 'str' } } @@ -282,11 +38,11 @@ ## # @NetdevHubPortOptions # -@@ -2490,6 +2494,7 @@ +@@ -2608,6 +2612,7 @@ + 'nic': 'NetLegacyNicOptions', 'user': 'NetdevUserOptions', 'tap': 'NetdevTapOptions', - 'l2tpv3': 'NetdevL2TPv3Options', + 'pcap': 'NetdevPcapOptions', + 'l2tpv3': 'NetdevL2TPv3Options', 'socket': 'NetdevSocketOptions', 'vde': 'NetdevVdeOptions', - 'dump': 'NetdevDumpOptions', Added: head/emulators/qemu/files/pcap-patch-net_net.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/emulators/qemu/files/pcap-patch-net_net.c Fri Aug 19 20:52:57 2016 (r420489) @@ -0,0 +1,248 @@ +--- net/net.c.orig 2016-04-14 20:19:54 UTC ++++ net/net.c +@@ -48,6 +48,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 +@@ -931,7 +936,223 @@ static int net_init_nic(const NetClientO + 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_OPTIONS_KIND_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 NetClientOptions *opts, ++ const char *name, NetClientState *peer, Error **errp) ++{ ++ const NetdevPcapOptions *pcap_opts = opts->u.pcap.data; ++ NetClientState *nc; ++ struct PCAPState *s; ++ const char *ifname; ++ char errbuf[PCAP_ERRBUF_SIZE]; ++#if defined(_WIN32) ++ HANDLE h; ++#endif ++ int i; ++ ++ 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_OPTIONS_KIND__MAX])( + const NetClientOptions *opts, + const char *name, +@@ -952,6 +1172,9 @@ static int (* const net_client_init_fun[ + #ifdef CONFIG_NET_BRIDGE + [NET_CLIENT_OPTIONS_KIND_BRIDGE] = net_init_bridge, + #endif ++#ifdef CONFIG_PCAP ++ [NET_CLIENT_OPTIONS_KIND_PCAP] = net_init_pcap, ++#endif + [NET_CLIENT_OPTIONS_KIND_HUBPORT] = net_init_hubport, + #ifdef CONFIG_VHOST_NET_USED + [NET_CLIENT_OPTIONS_KIND_VHOST_USER] = net_init_vhost_user, Modified: head/emulators/qemu/pkg-plist ============================================================================== --- head/emulators/qemu/pkg-plist Fri Aug 19 19:26:26 2016 (r420488) +++ head/emulators/qemu/pkg-plist Fri Aug 19 20:52:57 2016 (r420489) @@ -1,14 +1,17 @@ -%%SOFTMMU%%bin/ivshmem-client -%%SOFTMMU%%bin/ivshmem-server -%%SOFTMMU%%bin/qemu-ga -%%SOFTMMU%%bin/qemu-img -%%SOFTMMU%%bin/qemu-io -%%SOFTMMU%%bin/qemu-nbd +bin/ivshmem-server +bin/ivshmem-client +bin/qemu-ga +bin/qemu-i386 +bin/qemu-img +bin/qemu-io +bin/qemu-nbd +%%NO_X86_TARGETS%%bin/qemu-sparc +%%NO_X86_TARGETS%%bin/qemu-sparc64 %%NO_X86_TARGETS%%bin/qemu-system-aarch64 %%NO_X86_TARGETS%%bin/qemu-system-alpha %%NO_X86_TARGETS%%bin/qemu-system-arm %%NO_X86_TARGETS%%bin/qemu-system-cris -%%SOFTMMU%%bin/qemu-system-i386 +bin/qemu-system-i386 %%NO_X86_TARGETS%%bin/qemu-system-lm32 %%NO_X86_TARGETS%%bin/qemu-system-m68k %%NO_X86_TARGETS%%bin/qemu-system-microblaze @@ -29,105 +32,95 @@ %%NO_X86_TARGETS%%bin/qemu-system-sparc64 %%NO_X86_TARGETS%%bin/qemu-system-tricore %%NO_X86_TARGETS%%bin/qemu-system-unicore32 -%%BSD_USER%%bin/qemu-arm%%STATIC%% -%%BSD_USER%%bin/qemu-i386%%STATIC%% -%%BSD_USER%%bin/qemu-mips%%STATIC%% -%%BSD_USER64%%bin/qemu-mips64%%STATIC%% -%%BSD_USER64%%bin/qemu-mips64el%%STATIC%% -%%BSD_USER%%bin/qemu-mipsel%%STATIC%% -%%BSD_USER%%bin/qemu-sparc%%STATIC%% -%%BSD_USER64%%bin/qemu-sparc64%%STATIC%% -%%BSD_USER64%%bin/qemu-x86_64%%STATIC%% -%%SOFTMMU%%bin/qemu-system-x86_64 +bin/qemu-system-x86_64 %%NO_X86_TARGETS%%bin/qemu-system-xtensa %%NO_X86_TARGETS%%bin/qemu-system-xtensaeb -%%SOFTMMU%%man/man1/qemu.1.gz -%%SOFTMMU%%man/man8/qemu-ga.8.gz *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201608192052.u7JKqvhv098087>