# Buildsheet autogenerated by ravenadm tool -- Do not edit. NAMEBASE= qemu VERSION= 2.12.1 KEYWORDS= emulators VARIANTS= standard SDESC[standard]= Fast CPU emulator and virtualizer for x86 platform HOMEPAGE= https://www.qemu.org/ CONTACT= nobody DOWNLOAD_GROUPS= main SITES[main]= https://download.qemu.org/ DISTFILE[1]= qemu-2.12.1.tar.xz:main DF_INDEX= 1 SPKGS[standard]= complete primary docs OPTIONS_AVAILABLE= none OPTIONS_STANDARD= none BUILD_DEPENDS= texi2html:primary:standard BUILDRUN_DEPENDS= nettle:primary:standard fontconfig:primary:standard freetype:primary:standard gnutls:single:standard cyrus-sasl:primary:standard curl:primary:standard vde2:single:standard USES= cpe gmake pkgconfig bison perl:build python:2.7,build jpeg png mesa gettext-runtime gettext-tools ncurses makeinfo GNOME_COMPONENTS= gdkpixbuf gtk2 vte SDL_COMPONENTS= sdl2 XORG_COMPONENTS= x11 xext LICENSE= GPLv2:primary LICENSE_TERMS= primary:{{WRKSRC}}/LICENSE LICENSE_FILE= GPLv2:{{WRKSRC}}/COPYING LICENSE_SCHEME= solo FPC_EQUIVALENT= emulators/qemu MUST_CONFIGURE= yes CONFIGURE_ARGS= --disable-usb-redir --disable-stack-protector --disable-kvm --disable-linux-user --disable-linux-aio --disable-xen --disable-libssh2 --enable-pcap --enable-docs --enable-debug --enable-debug-info --prefix={{PREFIX}} --cc={{CC}} --python={{PYTHON_CMD}} --localstatedir=/var --extra-cflags="-I{{WRKSRC}} -I{{LOCALBASE}}/include -DPREFIX=\\\"\"{{PREFIX}}\\\"\"" --extra-ldflags="-L/usr/lib -L{{LOCALBASE}}/lib" MAKE_ENV= BSD_MAKE="{{MAKE}}" V=1 post-patch: ${REINPLACE_CMD} -e '/LIBS/s|-lprocstat|-lprocstat -lelf|' \ -e '/libusb/s/ --atleast-version=1\.0\.[0-9]*//' \ ${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 ${REINPLACE_CMD} -E \ -e "s|^(CFLAGS=).*|\1${CFLAGS} -fno-strict-aliasing|" \ -e "s|^(LDFLAGS=).*|\1${LDFLAGS}|" \ ${WRKSRC}/Makefile.target ${REINPLACE_CMD} -E \ -e "s|^(CFLAGS=).*|\1${CFLAGS} -fno-strict-aliasing -I.|" \ -e "s|^(LDFLAGS=).*|\1${LDFLAGS}|" \ ${WRKSRC}/Makefile ${REINPLACE_CMD} -E \ -e "1s|^(#! )/usr/bin/perl|\1${PERL}|" \ ${WRKSRC}/scripts/texi2pod.pl # GNS3 (promiscuous multicast) ${REINPLACE_CMD} -e 's|(buf\[0\] & 1) && (rctl & E1000_RCTL_MPE)|buf[0] \& 1|' \ ${WRKSRC}/hw/net/e1000.c # broken build for optionrom ${REINPLACE_CMD} -e '/roms="optionrom"/d' ${WRKSRC}/configure 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-* (cd ${WRKSRC} && ${COPYTREE_SHARE} docs ${STAGEDIR}${STD_DOCDIR}/) # remove empty directories ${RM} -r ${STAGEDIR}/var post-configure: ${REINPLACE_CMD} -E \ -e "s|^(HOST_USB=)bsd|\1stub|" \ ${WRKSRC}/config-host.mak [FILE:782:descriptions/desc.primary] QEMU is a fast processor emulator using dynamic translation to achieve good emulation speed. QEMU has two operating modes: * Full system emulation. In this mode, QEMU emulates a full system (for example a PC), including a processor and various peripherials. It can be used to launch different Operating Systems without rebooting the PC or to debug system code. * User mode emulation (Linux host only). In this mode, QEMU can launch Linux processes compiled for one CPU on another CPU. It can be used to launch the Wine Windows API emulator or to ease cross-compilation and cross-debugging. As QEMU requires no host kernel patches to run, it is safe and easy to use. See also the preconfigured system images on http://oszoo.org/ Many live cd isos also work. [FILE:97:distinfo] 33583800e0006cd00b78226b85be5a27c8e3b156bed2e60e83ecbeb7b9b8364f 35416404 qemu-2.12.1.tar.xz [FILE:2260:manifests/plist.primary] @sample etc/qemu-ifdown.sample @sample etc/qemu-ifup.sample bin/ qemu-ga qemu-i386 qemu-img qemu-io qemu-nbd qemu-sparc qemu-sparc64 qemu-system-aarch64 qemu-system-alpha qemu-system-arm qemu-system-cris qemu-system-hppa qemu-system-i386 qemu-system-lm32 qemu-system-m68k qemu-system-microblaze qemu-system-microblazeel qemu-system-mips qemu-system-mips64 qemu-system-mips64el qemu-system-mipsel qemu-system-moxie qemu-system-nios2 qemu-system-or1k qemu-system-ppc qemu-system-ppc64 qemu-system-ppcemb qemu-system-riscv32 qemu-system-riscv64 qemu-system-s390x qemu-system-sh4 qemu-system-sh4eb qemu-system-sparc qemu-system-sparc64 qemu-system-tricore qemu-system-unicore32 qemu-system-x86_64 qemu-system-xtensa qemu-system-xtensaeb qemu-x86_64 share/locale/bg/LC_MESSAGES/qemu.mo share/locale/de_DE/LC_MESSAGES/qemu.mo share/locale/fr_FR/LC_MESSAGES/qemu.mo share/locale/hu/LC_MESSAGES/qemu.mo share/locale/it/LC_MESSAGES/qemu.mo share/locale/tr/LC_MESSAGES/qemu.mo share/locale/zh_CN/LC_MESSAGES/qemu.mo share/man/man1/ qemu-img.1.gz qemu.1.gz share/man/man7/ qemu-block-drivers.7.gz qemu-ga-ref.7.gz qemu-qmp-ref.7.gz share/man/man8/ qemu-ga.8.gz qemu-nbd.8.gz share/qemu/ QEMU,cgthree.bin QEMU,tcx.bin bamboo.dtb bios-256k.bin bios.bin canyonlands.dtb efi-e1000.rom efi-e1000e.rom efi-eepro100.rom efi-ne2k_pci.rom efi-pcnet.rom efi-rtl8139.rom efi-virtio.rom efi-vmxnet3.rom hppa-firmware.img kvmvapic.bin linuxboot.bin linuxboot_dma.bin multiboot.bin openbios-ppc openbios-sparc32 openbios-sparc64 palcode-clipper petalogix-ml605.dtb petalogix-s3adsp1800.dtb ppc_rom.bin pxe-e1000.rom pxe-eepro100.rom pxe-ne2k_pci.rom pxe-pcnet.rom pxe-rtl8139.rom pxe-virtio.rom qemu-icon.bmp qemu_logo_no_text.svg qemu_vga.ndrv s390-ccw.img s390-netboot.img sgabios.bin skiboot.lid slof.bin spapr-rtas.bin trace-events-all u-boot-sam460-20100605.bin u-boot.e500 vgabios-cirrus.bin vgabios-qxl.bin vgabios-stdvga.bin vgabios-virtio.bin vgabios-vmware.bin vgabios.bin share/qemu/keymaps/ ar bepo common cz da de de-ch en-gb en-us es et fi fo fr fr-be fr-ca fr-ch hr hu is it ja lt lv mk modifiers nl nl-be no pl pt pt-br ru sl sv th tr [FILE:2272:manifests/plist.docs] share/doc/qemu/ qemu-doc.html qemu-qmp-ref.txt share/doc/qemu/docs/ qemu-block-drivers.7 version.texi virtio-balloon-stats.txt xbzrle.txt amd-memory-encryption.txt pr-manager.rst generic-loader.txt pci_expander_bridge.txt qdev-device-use.txt memory-hotplug.txt ccid.txt colo-proxy.txt share/doc/qemu/docs/interop/ qemu-qmp-ref.html qemu-ga-ref.txt qemu-qmp-ref.txt qemu-ga-qapi.texi qemu-ga-ref.7 qemu-ga-ref.html vnc-ledstate-Pseudo-encoding.txt bitmaps.rst qemu-ga-ref.texi qemu-qmp-ref.texi qed_spec.txt qmp-intro.txt qmp-spec.txt parallels.txt prl-xml.txt live-block-operations.rst qcow2.txt pr-helper.rst vhost-user.txt qemu-qmp-qapi.texi qemu-qmp-ref.7 qemu-qmp-ref.7.pod qemu-ga-ref.7.pod share/doc/qemu/docs/ xen-save-devices-state.txt block-replication.txt qcow2-cache.txt usb2.txt throttle.txt can.txt COLO-FT.txt igd-assign.txt spice-port-fqdn.txt usb-storage.txt multi-thread-compression.txt pcie.txt share/doc/qemu/docs/spin/ win32-qemu-event.promela aio_notify.promela aio_notify_bug.promela tcg-exclusive.promela aio_notify_accept.promela share/doc/qemu/docs/specs/ pvpanic.txt ppc-spapr-hcalls.txt pci-ids.txt vmcoreinfo.txt edu.txt rocker.txt acpi_nvdimm.txt tpm.txt acpi_pci_hotplug.txt vmgenid.txt ivshmem-spec.txt acpi_cpu_hotplug.txt ppc-spapr-hotplug.txt vmw_pvscsi-spec.txt fw_cfg.txt pci-testdev.txt acpi_mem_hotplug.txt pci-serial.txt standard-vga.txt share/doc/qemu/docs/ qemu-block-drivers.texi share/doc/qemu/docs/config/ q35-virtio-serial.cfg ich9-ehci-uhci.cfg mach-virt-graphical.cfg mach-virt-serial.cfg q35-virtio-graphical.cfg q35-emulated.cfg share/doc/qemu/docs/ qemu_logo.pdf qemupciserial.inf replay.txt nvdimm.txt image-fuzzer.txt rdma.txt pvrdma.txt pcie_pci_bridge.txt bootindex.txt multiseat.txt share/doc/qemu/docs/devel/ rcu.txt testing.rst lockcnt.txt writing-qmp-commands.txt stable-process.rst blkverify.txt build-system.txt tracing.txt qapi-code-gen.txt blkdebug.txt multiple-iothreads.txt atomics.txt migration.rst loads-stores.rst multi-thread-tcg.txt memory.txt virtio-migration.txt share/doc/qemu/docs/ qemu-block-drivers.7.pod share/doc/qemu/ qemu-doc.txt qemu-qmp-ref.html qemu-ga-ref.html qemu-ga-ref.txt [FILE:5613:patches/patch-configure] --- configure.orig 2018-08-02 21:48:53 UTC +++ configure @@ -353,6 +353,7 @@ hax="no" hvf="no" whpx="no" rdma="" +pvrdma="" gprof="no" debug_tcg="no" debug="no" @@ -449,6 +450,9 @@ numa="" tcmalloc="no" jemalloc="no" replication="yes" +pcap="no" +pcap_create="no" +bpf="no" vxhs="" libxml2="" @@ -1032,6 +1036,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" @@ -1308,6 +1316,10 @@ for opt do ;; --disable-rdma) rdma="no" ;; + --enable-pvrdma) pvrdma="yes" + ;; + --disable-pvrdma) pvrdma="no" + ;; --with-gtkabi=*) gtkabi="$optarg" ;; --disable-vte) vte="no" @@ -1593,7 +1605,8 @@ disabled with --disable-FEATURE, default 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 @@ -2791,6 +2804,56 @@ else tasn1=no fi +########################################## +# PVRDMA detection + +cat > $TMPC < + +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 ) + +have_ifaddrs_h=yes +if ! check_include "ifaddrs.h" ; then + have_ifaddrs_h=no +fi ########################################## # getifaddrs (for tests/test-io-channel-socket ) @@ -2971,6 +3034,50 @@ EOF fi fi +########################################## +# pcap probe + +if test "$pcap" = "yes" -a "$pcap" != "no"; then + cat > $TMPC << EOF +#include +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 +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 +#include +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 @@ -4333,14 +4440,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 @@ -5785,6 +5885,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 @@ -5820,6 +5921,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" @@ -6012,6 +6114,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 @@ -6250,6 +6361,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 "$vte" = "yes" ; then echo "CONFIG_VTE=y" >> $config_host_mak echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak @@ -6568,6 +6682,10 @@ if test "$rdma" = "yes" ; then 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 echo "CONFIG_RTNETLINK=y" >> $config_host_mak fi [FILE:365:patches/patch-disas_libvixl_vixl_a64_disasm-a64.cc] --- disas/libvixl/vixl/a64/disasm-a64.cc.orig 2018-08-02 21:48: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); } [FILE:332:patches/patch-hw_rdma_Makefile.objs] --- hw/rdma/Makefile.objs.orig 2018-08-02 21:48:53 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 [FILE:280:patches/patch-hw_rdma_vmw_pvrdma_cmd.c] --- hw/rdma/vmw/pvrdma_cmd.c.orig 2018-08-02 21:48:53 UTC +++ hw/rdma/vmw/pvrdma_cmd.c @@ -16,7 +16,6 @@ #include "qemu/osdep.h" #include "qemu/error-report.h" #include "cpu.h" -#include #include "hw/hw.h" #include "hw/pci/pci.h" #include "hw/pci/pci_ids.h" [FILE:582:patches/patch-include_net_net.h] --- include/net/net.h.orig 2018-08-02 21:48:53 UTC +++ include/net/net.h @@ -217,8 +217,8 @@ void qmp_netdev_add(QDict *qdict, QObjec 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" [FILE:2733:patches/patch-include_qemu_atomic.h] --- include/qemu/atomic.h.orig 2018-08-02 21:48:53 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 */ [FILE:436:patches/patch-net_clients.h] --- net/clients.h.orig 2018-08-02 21:48:53 UTC +++ net/clients.h @@ -61,4 +61,10 @@ int net_init_netmap(const Netdev *netdev 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 */ [FILE:6930:patches/patch-net_net.c] --- net/net.c.orig 2018-08-02 21:48:53 UTC +++ net/net.c @@ -52,6 +52,11 @@ #include "net/filter.h" #include "qapi/string-output-visitor.h" +#include +#if defined(__FreeBSD__) || defined(__DragonFly__) +#include +#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 *ne return idx; } +#if defined(CONFIG_PCAP) +#if defined(CONFIG_BPF) +#define PCAP_DONT_INCLUDE_PCAP_BPF_H +#include +#endif +#include + +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; +#if defined(__FreeBSD__) || defined(__DragonFly__) + 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; + } + +#if defined(__FreeBSD__) || defined(__DragonFly__) + /* + * 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, @@ -956,6 +1179,9 @@ static int (* const net_client_init_fun[ #ifdef CONFIG_L2TPV3 [NET_CLIENT_DRIVER_L2TPV3] = net_init_l2tpv3, #endif +#ifdef CONFIG_PCAP + [NET_CLIENT_DRIVER_PCAP] = net_init_pcap, +#endif }; [FILE:423:patches/patch-net_tap-bsd.c] --- net/tap-bsd.c.orig 2018-08-02 21:48:53 UTC +++ net/tap-bsd.c @@ -31,9 +31,16 @@ #if defined(__NetBSD__) || defined(__FreeBSD__) #include +#include #include #include #endif +#if defined(__DragonFly) +#include +#include +#include +#include +#endif #if defined(__OpenBSD__) #include [FILE:1550:patches/patch-qapi_net.json] --- qapi/net.json.orig 2018-08-02 21:48:53 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', [FILE:7685:files/pkg-message-single] FreeBSD host notes ================== - Needs to set net.link.tap.user_open sysctl in order to use /dev/tap* networking as non-root. Don't forget to adjust device node permissions in /etc/devfs.rules. - slirp (usermode networking) is fixed now in cvs, on FreeSBIE 1.0 guests you still have to manually do: echo nameserver 10.0.2.3 >/etc/resolv.conf but i've been told that that's normal. (fixed on FreeSBIE 1.1.) And you have to wait a bit for dhclient to do its thing; traffic to address 10.0.2.2 is routed to 127.1 on the host. - Expect timer problems when guest kernel HZ is > hosts, for example time sleep 1 takes 49 seconds and booting sleeps for minutes at the acd0 probe with a FreeSBIE 1.0 guest, thats because its kernel is built with HZ=5000, and FreeBSD's default is 100... (no longer a problem with FreeSBIE 1.1.) The linux 2.6 kernel uses 1000 by default btw. (changed to 250 later, and recent linux kernels now no longer have a fixed HZ, aka `tickless kernel'...) Enabling /dev/rtc doesn't seem to help either (not included since it needs a patch to emulators/rtc.) - Update: the above problem has gotten worse with FreeBSD guests somewhere before 8.0, mainly since the kernel now usually wants double or even quadruple number of timer irqs compared to HZ if it detects an apic (and at least early versions of FreeBSD 8 had a bug that essentially halved qemu's clock rate too); the only reason you usually don't see symptoms of this with FreeBSD 8 guests is they automatically reduce their HZ to 100 when running in a VM while the default for the host kernel is still HZ=1000. Workaround: you can disable the apic clock in the guest by setting hint.apic.0.clock="0" in loader.conf(5) (or manually at the loader prompt), if that doesn't work the only things you can do is either reduce the guest's HZ to, say, 100 by setting e.g. kern.hz="100" from the loader as above (which usually is a good idea in a VM anyway and FreeBSD 8 now does by itself as mentioned), or otherwise increase the host's HZ to 2000 or even 4000 from the loader in the same way. - The -smb option (smb-export local dir to guest using the default slirp networking) needs the samba port/package installed in addition to qemu. (SAMBA knob.) - If you want to use usb devices connected to the host in the guest yot need either recent 10-current (not tested yet much) or you can use usbredir over the network (see below); also unless you are running qemu as root you then need to fix permissions for /dev/ugen* device nodes: if you are on 5.x or later (devfs) put a rule in /etc/devfs.rules, activate it in /etc/rc.conf and run /etc/rc.d/devfs restart. Example devfs.rules: [ugen_ruleset=20] add path 'ugen*' mode 660 group operator corresponding rc.conf line: devfs_system_ruleset="ugen_ruleset" - If you want to test the new (in 0.15.0) usb network redirection (USBREDIR option) see this thread by Hans de Goede redhat.com>: http://thread.gmane.org/gmane.comp.emulators.qemu/110176/focus=110183 Quote: Example usage: 1) Start usbredirserver for a usb device: sudo usbredirserver 045e:0772 2) Start qemu with usb2 support + a chardev talking to usbredirserver + a usb-redir device using this chardev: qemu -usb \ -readconfig docs/ich9-ehci-uhci.cfg \ -chardev socket,id=usbredirchardev,host=localhost,port=4000 \ -device usb-redir,chardev=usbredirchardev,id=usbredirdev ... [you would replace docs/ich9-ehci-uhci.cfg with e.g. /raven/share/doc/qemu/docs/ich9-ehci-uhci.cfg, but turns out ehci was broken for me here with FreeBSD guests and the previous qemu version at least, I got: FETCHENTRY: entry at 22C5484 is of type 2 which is not supported yet processing error - resetting ehci HC Assertion failed: (0), function ehci_advance_state, file /data/ports/emulators/qemu-devel/work/qemu-0.15.0/hw/usb-ehci.c, line 2045. The new qemu version works better tho.] - Still usb: since the hub is no longer attached to the uchi controller and the wakeup mechanism, resume interrupt is not implemented yet linux guests will suspend the bus, i.e. they wont see devices usb_add'ed after its (linux') uhci module got loaded. Workaround: either add devices before linux loads the module or rmmod and modprobe it afterwards. [Not sure if this still applies to the new libusb host code used on recent 10-current.] - If you build qemu wihout SDL and then get crashes running it try passing it -nographic. This should probably be default in that case... - qemu's network boot roms (-boot n) have a bug when bootfiles sizes are a multiple of blksize, if this affects you (like with FreeBSD's /boot/pxeboot) you can do like cp /boot/pxeboot pxeboot-qemu && chmod +w pxeboot-qemu && echo >>pxeboot-qemu and then use pxeboot-qemu. Actually you need recent btx code (from after 7.0 was released) because of the real mode boot problem, so use at least pxeboot from there. And I just did that for the pxeboot extracted out of ftp://ftp.freebsd.org/pub/FreeBSD/snapshots/200805/7.0-STABLE-200805-i386-bootonly.iso and placed it here: http://people.freebsd.org/~nox/qemu/pxeboot-qemu - If you use slirp (usernet, the default) and want to mount nfs into the guest and you are not running qemu as root, then mountd(8) on the exporting box needs to be run with -n in order to accept requests from ports >= 1024. - (not FreeBSD-specific:) There have been reports of qcow2 corruption with (at least) win2k guests on recent kvm (which uses similar qcow2 code than qemu now, see this thread: http://lists.gnu.org/archive/html/qemu-devel/2009-02/msg00713.html - the consensus on that thread seems to be that qcow(2) code has always been experimental and you should use raw images if you want reliability; raw is also usually faster.) You should be able to migrate existing images to raw using qemu-img(1)'s convert function; raw doesn't support advanced features like snapshots tho. [a few important qcow2 bugfixed have been committed in the meantime so this _might_ be less of an issue now; and meanwhile there also is the new qed format - I don't know how stable that one is.] - (also not FreeBSD-specific:) It is recommended to pass raw images using the new -drive syntax, specifying format=raw explicitly in order to avoid malicious guests being able to exploit the format autodetection thats otherwise getting used. (Not that you should run malicious guests anyway, but this eleminates at least a known attack vector.) - qemu now has improved physical cdrom support, but still there is at least one known problem: you need to have the guest eject the disc if you want to change it/take it out, or otherwise the guest may continue using state (like size) of the old disc. (You can also do like `change ide1-cd0 /dev/acd0' in the monitor after taking out the disc if a guest cannot eject it itself.) - The default configuration location (qemu-ifup script etc.) has been changed from /etc to PREFIX/etc (usually /raven/etc). Move your files accordingly. - The pcap code (-net nic... -net pcap,ifname=...) should work properly now, with only one exception: Advanced features like TSO used on the host interface can cause oversize packets which now do get truncated to avoid confusing/panicing guests but of course still will cause retransmissions. So if you see slow throughput and `pcap_send: packet size > ..., truncating' messages on qemu's tty try disabling TSO etc on the host interface at least while using pcap. [FILE:20:files/qemu-ifdown.sample] #!/bin/sh exec true [FILE:20:files/qemu-ifup.sample] #!/bin/sh exec true [FILE:66:files/special.mk] .if "${ARCH_STANDARD}" == "x86_64" MAKE_ARGS+= ARCH=x86_64 .endif