1 # Buildsheet autogenerated by ravenadm tool -- Do not edit.
7 SDESC[standard]= Fast CPU emulator and virtualizer for x86 platform
8 HOMEPAGE= https://www.qemu.org/
12 SITES[main]= https://download.qemu.org/
13 DISTFILE[1]= qemu-4.1.1.tar.xz:main
15 SPKGS[standard]= complete
19 OPTIONS_AVAILABLE= none
20 OPTIONS_STANDARD= none
22 BUILD_DEPENDS= texi2html:primary:standard
23 python-Sphinx:single:python_default
24 BUILDRUN_DEPENDS= nettle:primary:standard
25 fontconfig:primary:standard
26 freetype:primary:standard
27 gnutls:single:standard
28 cyrus-sasl:primary:standard
31 libepoxy:single:standard
33 USES= cpe gmake pkgconfig bison perl:build python:build
34 jpeg png mesa gettext-runtime gettext-tools ncurses
36 GNOME_COMPONENTS= gdkpixbuf gtk2 vte
38 XORG_COMPONENTS= x11 xext
40 LICENSE= GPLv2:primary
41 LICENSE_TERMS= primary:{{WRKSRC}}/LICENSE
42 LICENSE_FILE= GPLv2:{{WRKSRC}}/COPYING
45 FPC_EQUIVALENT= emulators/qemu
48 CONFIGURE_ARGS= --disable-usb-redir
49 --disable-stack-protector
59 --python={{PYTHON_CMD}}
61 --extra-cflags="-I{{WRKSRC}} -I{{LOCALBASE}}/include -DPREFIX=\\\"\"{{PREFIX}}\\\"\""
62 --extra-ldflags="-L/usr/lib -L{{LOCALBASE}}/lib"
64 MAKE_ENV= BSD_MAKE="{{MAKE}}"
67 INSTALL_REQ_TOOLCHAIN= yes
69 VAR_OPSYS[freebsd]= CONFIGURE_ARGS=--enable-netmap
70 CONFIGURE_ARGS=--disable-linux-user
71 CONFIGURE_ARGS=--disable-linux-aio
72 VAR_OPSYS[linux]= CONFIGURE_ARGS=--enable-netmap
73 VAR_OPSYS[dragonfly]= CONFIGURE_ARGS=--disable-netmap
74 CONFIGURE_ARGS=--disable-linux-user
75 CONFIGURE_ARGS=--disable-linux-aio
78 ${REINPLACE_CMD} -e '/LIBS/s|-lprocstat|-lprocstat -lelf|' \
79 -e '/libusb/s/ --atleast-version=1\.0\.[0-9]*//' \
81 ${REINPLACE_CMD} -e '/libs_qga=/s|glib_libs|glib_libs -lintl|' \
84 -e "/^by Tibor .TS. S/s|Sch.*z.$$|Schuetz.|" \
85 ${WRKSRC}/qemu-doc.texi
87 -e "s|^(CFLAGS=).*|\1${CFLAGS} -fno-strict-aliasing|" \
88 -e "s|^(LDFLAGS=).*|\1${LDFLAGS}|" \
89 ${WRKSRC}/Makefile.target
91 -e "s|^(CFLAGS=).*|\1${CFLAGS} -fno-strict-aliasing -I.|" \
92 -e "s|^(LDFLAGS=).*|\1${LDFLAGS}|" \
95 -e "1s|^(#! )/usr/bin/perl|\1${PERL}|" \
96 ${WRKSRC}/scripts/texi2pod.pl
97 # GNS3 (promiscuous multicast)
98 ${REINPLACE_CMD} -e 's|(buf\[0\] & 1) && (rctl & E1000_RCTL_MPE)|buf[0] \& 1|' \
99 ${WRKSRC}/hw/net/e1000.c
100 # broken build for optionrom
101 ${REINPLACE_CMD} -e '/roms="optionrom"/d' ${WRKSRC}/configure
102 # silence some include warnings
103 ${MKDIR} ${WRKSRC}/bsd-user/dragonfly
106 # for some reason file is considered out-of-date
107 ${TOUCH} ${WRKSRC}/config-host.mak
110 ${INSTALL_SCRIPT} ${FILESDIR}/qemu-ifup.sample \
111 ${STAGEDIR}${PREFIX}/etc
112 ${INSTALL_SCRIPT} ${FILESDIR}/qemu-ifdown.sample \
113 ${STAGEDIR}${PREFIX}/etc
114 ${STRIP_CMD} ${STAGEDIR}${PREFIX}/bin/qemu-*
115 (cd ${WRKSRC} && ${COPYTREE_SHARE} docs ${STAGEDIR}${STD_DOCDIR}/)
116 # remove empty directories
117 ${RM} -r ${STAGEDIR}/var
119 [FILE:782:descriptions/desc.primary]
120 QEMU is a fast processor emulator using dynamic translation to achieve
121 good emulation speed. QEMU has two operating modes:
123 * Full system emulation. In this mode, QEMU emulates a full system (for
124 example a PC), including a processor and various peripherials. It can
125 be used to launch different Operating Systems without rebooting the PC
126 or to debug system code.
127 * User mode emulation (Linux host only). In this mode, QEMU can launch
128 Linux processes compiled for one CPU on another CPU. It can be used to
129 launch the Wine Windows API emulator or to ease cross-compilation and
132 As QEMU requires no host kernel patches to run, it is safe and easy to use.
134 See also the preconfigured system images on http://oszoo.org/
135 Many live cd isos also work.
139 ed6fdbbdd272611446ff8036991e9b9f04a2ab2e3ffa9e79f3bab0eb9a95a1d2 61932460 qemu-4.1.1.tar.xz
142 [FILE:3169:manifests/plist.primary]
143 @sample etc/qemu-ifdown.sample
144 @sample etc/qemu-ifup.sample
163 qemu-system-microblaze
164 qemu-system-microblazeel
182 qemu-system-unicore32
187 share/applications/qemu.desktop
188 share/icons/hicolor/128x128/apps/qemu.png
189 share/icons/hicolor/16x16/apps/qemu.png
190 share/icons/hicolor/24x24/apps/qemu.png
191 share/icons/hicolor/256x256/apps/qemu.png
192 share/icons/hicolor/32x32/apps/
195 share/icons/hicolor/48x48/apps/qemu.png
196 share/icons/hicolor/512x512/apps/qemu.png
197 share/icons/hicolor/64x64/apps/qemu.png
198 share/icons/hicolor/scalable/apps/qemu.svg
199 share/locale/bg/LC_MESSAGES/qemu.mo
200 share/locale/de_DE/LC_MESSAGES/qemu.mo
201 share/locale/fr_FR/LC_MESSAGES/qemu.mo
202 share/locale/hu/LC_MESSAGES/qemu.mo
203 share/locale/it/LC_MESSAGES/qemu.mo
204 share/locale/tr/LC_MESSAGES/qemu.mo
205 share/locale/zh_CN/LC_MESSAGES/qemu.mo
210 qemu-block-drivers.7.gz
228 edk2-i386-secure-code.fd
232 edk2-x86_64-secure-code.fd
249 opensbi-riscv32-virt-fw_jump.bin
250 opensbi-riscv64-sifive_u-fw_jump.bin
251 opensbi-riscv64-virt-fw_jump.bin
254 petalogix-s3adsp1800.dtb
272 u-boot-sam460-20100605.bin
275 vgabios-bochs-display.bin
284 50-edk2-i386-secure.json
285 50-edk2-x86_64-secure.json
327 [FILE:4915:manifests/plist.docs]
337 amd-memory-encryption.txt
338 block-replication.txt
351 multi-thread-compression.txt
354 pci_expander_bridge.txt
362 qemu-block-drivers.7.pod
363 qemu-block-drivers.texi
365 qemu-cpu-models.7.pod
378 virtio-balloon-stats.txt
380 xen-save-devices-state.txt
381 share/doc/qemu/docs/built/devel/
393 secure-coding-practices.html
397 share/doc/qemu/docs/built/devel/_static/
402 documentation_options.js
413 share/doc/qemu/docs/built/interop/
418 live-block-operations.html
425 share/doc/qemu/docs/built/interop/_static/
430 documentation_options.js
441 share/doc/qemu/docs/built/specs/
450 share/doc/qemu/docs/built/specs/_static/
455 documentation_options.js
466 share/doc/qemu/docs/config/
468 mach-virt-graphical.cfg
471 q35-virtio-graphical.cfg
472 q35-virtio-serial.cfg
473 share/doc/qemu/docs/devel/
487 multiple-iothreads.txt
491 secure-coding-practices.rst
497 writing-qmp-commands.txt
498 share/doc/qemu/docs/interop/
503 live-block-operations.rst
527 vnc-ledstate-Pseudo-encoding.txt
528 share/doc/qemu/docs/specs/
542 ppc-spapr-hotplug.txt
552 share/doc/qemu/docs/sphinx/qmp_lexer.py
553 share/doc/qemu/docs/sphinx/__pycache__/qmp_lexer.cpython-37.pyc
554 share/doc/qemu/docs/spin/
556 aio_notify_accept.promela
557 aio_notify_bug.promela
558 tcg-exclusive.promela
559 win32-qemu-event.promela
560 share/doc/qemu/interop/
565 live-block-operations.html
572 share/doc/qemu/interop/_static/
577 documentation_options.js
588 share/doc/qemu/specs/
597 share/doc/qemu/specs/_static/
602 documentation_options.js
615 [FILE:4087:patches/patch-configure]
616 --- configure.orig 2019-11-14 18:06:20 UTC
618 @@ -484,6 +484,9 @@ numa=""
628 @@ -1141,6 +1144,10 @@ for opt do
630 --enable-vnc-png) vnc_png="yes"
632 + --enable-pcap) pcap="yes"
634 + --disable-pcap) pcap="no"
636 --disable-slirp) slirp="no"
638 --enable-slirp=git) slirp="git"
639 @@ -2998,6 +3005,14 @@ if ! check_include "ifaddrs.h" ; then
642 ##########################################
643 +# getifaddrs (for tests/test-io-channel-socket )
646 +if ! check_include "ifaddrs.h" ; then
650 +##########################################
653 if test "$vte" != "no"; then
654 @@ -3655,7 +3670,7 @@ for i in $glib_modules; do
655 glib_libs=$($pkg_config --libs $i)
656 QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
657 LIBS="$glib_libs $LIBS"
658 - libs_qga="$glib_libs $libs_qga"
659 + libs_qga="$glib_libs -lintl $libs_qga"
661 error_exit "glib-$glib_req_ver $i is required to compile QEMU"
663 @@ -4747,11 +4762,6 @@ has_sphinx_build() {
664 if test "$docs" != "no" ; then
665 if has makeinfo && has pod2man && has_sphinx_build; then
668 - if test "$docs" = "yes" ; then
669 - feature_not_found "docs" "Install texinfo, Perl/perl-podlators and python-sphinx"
675 @@ -4885,7 +4895,7 @@ fi
678 if test "$libusb" != "no" ; then
679 - if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
680 + if $pkg_config libusb-1.0; then
682 libusb_cflags=$($pkg_config --cflags libusb-1.0)
683 libusb_libs=$($pkg_config --libs libusb-1.0)
684 @@ -5275,6 +5285,50 @@ if test "$debug_stack_usage" = "yes"; th
688 +##########################################
691 +if test "$pcap" = "yes" -a "$pcap" != "no"; then
694 +int main(void) { return (pcap_lib_version() == (char *)0 ? 1 : 0); }
696 + if test "$mingw32" = "no" ; then
701 + if compile_prog "" "$libpcap" ; then
705 + echo "Error: Could not find pcap"
706 + echo "Make sure to have the pcap libs and headers installed."
714 + char errbuf[PCAP_ERRBUF_SIZE];
715 + return (pcap_create("foo", errbuf) == (pcap_t *)0 ? 1 : 0);
718 + if compile_prog "" "$libpcap" ; then
722 +#define PCAP_DONT_INCLUDE_PCAP_BPF_H
724 +#include <net/bpf.h>
725 +int main(void) { return (BPF_MAJOR_VERSION); }
727 + if compile_prog ; then
730 + libs_softmmu="$libpcap $libs_softmmu"
733 ##########################################
734 # check if we have open_by_handle_at
735 @@ -6377,6 +6431,7 @@ echo "Audio drivers $audio_drv_list"
736 echo "Block whitelist (rw) $block_drv_rw_whitelist"
737 echo "Block whitelist (ro) $block_drv_ro_whitelist"
738 echo "VirtFS support $virtfs"
739 +echo "pcap support $pcap"
740 echo "Multipath support $mpath"
741 echo "VNC support $vnc"
742 if test "$vnc" = "yes" ; then
743 @@ -6617,6 +6672,15 @@ fi
744 if test "$profiler" = "yes" ; then
745 echo "CONFIG_PROFILER=y" >> $config_host_mak
747 +if test "$pcap" = "yes" ; then
748 + echo "CONFIG_PCAP=y" >> $config_host_mak
749 + if test "$pcap_create" = "yes" ; then
750 + echo "CONFIG_PCAP_CREATE=y" >> $config_host_mak
752 + if test "$bpf" = "yes" ; then
753 + echo "CONFIG_BPF=y" >> $config_host_mak
756 if test "$slirp" != "no"; then
757 echo "CONFIG_SLIRP=y" >> $config_host_mak
758 echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
759 @@ -6865,6 +6929,9 @@ fi
760 if test "$have_fsxattr" = "yes" ; then
761 echo "HAVE_FSXATTR=y" >> $config_host_mak
763 +if test "$have_ifaddrs_h" = "yes" ; then
764 + echo "HAVE_IFADDRS_H=y" >> $config_host_mak
766 if test "$have_copy_file_range" = "yes" ; then
767 echo "HAVE_COPY_FILE_RANGE=y" >> $config_host_mak
771 [FILE:365:patches/patch-disas_libvixl_vixl_a64_disasm-a64.cc]
772 --- disas/libvixl/vixl/a64/disasm-a64.cc.orig 2019-11-14 18:06:20 UTC
773 +++ disas/libvixl/vixl/a64/disasm-a64.cc
774 @@ -2693,7 +2693,7 @@ void Disassembler::AppendPCRelativeOffse
776 abs_offset = -abs_offset;
778 - AppendToOutput("#%c0x%" PRIx64, sign, abs_offset);
779 + AppendToOutput("#%c0x%" PRIx64, sign, offset < 0 ? -offset : offset);
785 [FILE:582:patches/patch-include_net_net.h]
786 --- include/net/net.h.orig 2019-11-14 18:06:20 UTC
787 +++ include/net/net.h
788 @@ -209,8 +209,8 @@ void qmp_netdev_add(QDict *qdict, QObjec
789 int net_hub_id_for_client(NetClientState *nc, int *id);
790 NetClientState *net_hub_port_find(int hub_id);
792 -#define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup"
793 -#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown"
794 +#define DEFAULT_NETWORK_SCRIPT PREFIX "/etc/qemu-ifup"
795 +#define DEFAULT_NETWORK_DOWN_SCRIPT PREFIX "/etc/qemu-ifdown"
796 #define DEFAULT_BRIDGE_HELPER CONFIG_QEMU_HELPERDIR "/qemu-bridge-helper"
797 #define DEFAULT_BRIDGE_INTERFACE "br0"
801 [FILE:2733:patches/patch-include_qemu_atomic.h]
802 --- include/qemu/atomic.h.orig 2019-11-14 18:06:20 UTC
803 +++ include/qemu/atomic.h
804 @@ -208,10 +208,12 @@
805 /* Provide shorter names for GCC atomic builtins, return old value */
806 #define atomic_fetch_inc(ptr) __atomic_fetch_add(ptr, 1, __ATOMIC_SEQ_CST)
807 #define atomic_fetch_dec(ptr) __atomic_fetch_sub(ptr, 1, __ATOMIC_SEQ_CST)
809 #define atomic_fetch_add(ptr, n) __atomic_fetch_add(ptr, n, __ATOMIC_SEQ_CST)
810 #define atomic_fetch_sub(ptr, n) __atomic_fetch_sub(ptr, n, __ATOMIC_SEQ_CST)
811 #define atomic_fetch_and(ptr, n) __atomic_fetch_and(ptr, n, __ATOMIC_SEQ_CST)
812 #define atomic_fetch_or(ptr, n) __atomic_fetch_or(ptr, n, __ATOMIC_SEQ_CST)
814 #define atomic_fetch_xor(ptr, n) __atomic_fetch_xor(ptr, n, __ATOMIC_SEQ_CST)
816 #define atomic_inc_fetch(ptr) __atomic_add_fetch(ptr, 1, __ATOMIC_SEQ_CST)
817 @@ -225,10 +227,12 @@
818 /* And even shorter names that return void. */
819 #define atomic_inc(ptr) ((void) __atomic_fetch_add(ptr, 1, __ATOMIC_SEQ_CST))
820 #define atomic_dec(ptr) ((void) __atomic_fetch_sub(ptr, 1, __ATOMIC_SEQ_CST))
822 #define atomic_add(ptr, n) ((void) __atomic_fetch_add(ptr, n, __ATOMIC_SEQ_CST))
823 #define atomic_sub(ptr, n) ((void) __atomic_fetch_sub(ptr, n, __ATOMIC_SEQ_CST))
824 #define atomic_and(ptr, n) ((void) __atomic_fetch_and(ptr, n, __ATOMIC_SEQ_CST))
825 #define atomic_or(ptr, n) ((void) __atomic_fetch_or(ptr, n, __ATOMIC_SEQ_CST))
827 #define atomic_xor(ptr, n) ((void) __atomic_fetch_xor(ptr, n, __ATOMIC_SEQ_CST))
829 #else /* __ATOMIC_RELAXED */
830 @@ -400,10 +404,12 @@
832 #define atomic_inc_fetch(ptr) __sync_add_and_fetch(ptr, 1)
833 #define atomic_dec_fetch(ptr) __sync_add_and_fetch(ptr, -1)
835 #define atomic_add_fetch(ptr, n) __sync_add_and_fetch(ptr, n)
836 #define atomic_sub_fetch(ptr, n) __sync_sub_and_fetch(ptr, n)
837 #define atomic_and_fetch(ptr, n) __sync_and_and_fetch(ptr, n)
838 #define atomic_or_fetch(ptr, n) __sync_or_and_fetch(ptr, n)
840 #define atomic_xor_fetch(ptr, n) __sync_xor_and_fetch(ptr, n)
842 #define atomic_cmpxchg(ptr, old, new) __sync_val_compare_and_swap(ptr, old, new)
843 @@ -412,10 +418,12 @@
844 /* And even shorter names that return void. */
845 #define atomic_inc(ptr) ((void) __sync_fetch_and_add(ptr, 1))
846 #define atomic_dec(ptr) ((void) __sync_fetch_and_add(ptr, -1))
848 #define atomic_add(ptr, n) ((void) __sync_fetch_and_add(ptr, n))
849 #define atomic_sub(ptr, n) ((void) __sync_fetch_and_sub(ptr, n))
850 #define atomic_and(ptr, n) ((void) __sync_fetch_and_and(ptr, n))
851 #define atomic_or(ptr, n) ((void) __sync_fetch_and_or(ptr, n))
853 #define atomic_xor(ptr, n) ((void) __sync_fetch_and_xor(ptr, n))
855 #endif /* __ATOMIC_RELAXED */
858 [FILE:436:patches/patch-net_clients.h]
859 --- net/clients.h.orig 2019-11-14 18:06:20 UTC
861 @@ -61,4 +61,10 @@ int net_init_netmap(const Netdev *netdev
862 int net_init_vhost_user(const Netdev *netdev, const char *name,
863 NetClientState *peer, Error **errp);
866 +int net_init_pcap(const Netdev *netdev, const char *name,
867 + NetClientState *peer, Error **errp);
871 #endif /* QEMU_NET_CLIENTS_H */
874 [FILE:6930:patches/patch-net_net.c]
875 --- net/net.c.orig 2019-11-14 18:06:20 UTC
878 #include "net/filter.h"
879 #include "qapi/string-output-visitor.h"
881 +#include <sys/ioctl.h>
882 +#if defined(__FreeBSD__) || defined(__DragonFly__)
886 /* Net bridge is currently not supported for W32. */
888 # define CONFIG_NET_BRIDGE
889 @@ -933,7 +938,225 @@ static int net_init_nic(const Netdev *ne
893 +#if defined(CONFIG_PCAP)
894 +#if defined(CONFIG_BPF)
895 +#define PCAP_DONT_INCLUDE_PCAP_BPF_H
896 +#include <net/bpf.h>
903 + int max_eth_frame_size;
906 +static ssize_t pcap_receive(NetClientState *nc, const uint8_t *buf, size_t size)
908 + struct PCAPState *s = DO_UPCAST(struct PCAPState, nc, nc);
910 + return pcap_inject(s->handle, (u_char*)buf, size);
913 +static void pcap_callback(u_char *user, struct pcap_pkthdr *phdr, u_char *pdata
916 + NetClientState *nc = (NetClientState *)user;
918 + int len = phdr->len;
919 +#if defined(__FreeBSD__) || defined(__DragonFly__)
920 + struct PCAPState *s = DO_UPCAST(struct PCAPState, nc, nc);
921 + int max_eth_frame_size = s->max_eth_frame_size;
923 + if (len > max_eth_frame_size) {
925 + "pcap_send: packet size > %d (%d), truncating\n",
926 + max_eth_frame_size, len);
927 + len = max_eth_frame_size;
930 + qemu_send_packet(nc, pdata, len);
933 +static void pcap_send(void *opaque)
935 + struct PCAPState *s = (struct PCAPState *)opaque;
938 + if (pcap_dispatch(s->handle, 0, (pcap_handler)&pcap_callback, (u_char *)&s->nc) >= 0)
943 +static void pcap_cleanup(NetClientState *nc)
945 + struct PCAPState *s = DO_UPCAST(struct PCAPState, nc, nc);
947 + qemu_purge_queued_packets(nc);
948 + pcap_close(s->handle);
951 +static NetClientInfo net_pcap_info = {
952 + .type = NET_CLIENT_DRIVER_PCAP,
953 + .size = sizeof(struct PCAPState),
954 + .receive = pcap_receive,
955 +// .receive_raw = pcap_receive_raw,
956 +// .receive_iov = pcap_receive_iov,
957 +// .poll = pcap_poll,
958 + .cleanup = pcap_cleanup,
961 + * ... -net pcap,ifname="..."
964 +int net_init_pcap(const Netdev *netdev,
965 + const char *name, NetClientState *peer, Error **errp)
967 + const NetdevPcapOptions *pcap_opts;
968 + NetClientState *nc;
969 + struct PCAPState *s;
970 + const char *ifname;
971 + char errbuf[PCAP_ERRBUF_SIZE];
977 + assert(netdev->type == NET_CLIENT_DRIVER_PCAP);
978 + pcap_opts = &netdev->u.pcap;
979 + if (!pcap_opts->has_ifname)
982 + ifname = pcap_opts->ifname;
984 + /* create the object */
985 + nc = qemu_new_net_client(&net_pcap_info, peer, "pcap", ifname);
986 + s = DO_UPCAST(struct PCAPState, nc, nc);
988 + if (ifname == NULL && (ifname = pcap_lookupdev(errbuf)) == NULL) {
989 + fprintf(stderr, "qemu: pcap_create: %s\n", errbuf);
993 +#if defined(__FreeBSD__) || defined(__DragonFly__)
995 + * We want to avoid passing oversize packets to the guest, which
996 + * at least on FreeBSD can happen if the host interface uses tso
997 + * (seen with an em(4) in this case) - so find out the host
998 + * interface's mtu and assume the guest is configured the same.
1000 + s->max_eth_frame_size = 1514;
1001 + i = socket(AF_INET, SOCK_DGRAM, 0);
1005 + (void) memset(&ifr, 0, sizeof(ifr));
1006 + strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
1007 + if (ioctl(i, SIOCGIFMTU, &ifr) != -1)
1008 + s->max_eth_frame_size = ifr.ifr_mtu + 14;
1013 +#if defined(CONFIG_PCAP_CREATE) || defined(_WIN32)
1015 + * Create pcap handle for the device, set promiscuous mode and activate.
1017 + s->handle = (void *)pcap_create(ifname, errbuf);
1019 + fprintf(stderr, "qemu: pcap_create: %s\n", errbuf);
1022 + if (pcap_set_promisc(s->handle, 1) != 0) {
1023 + pcap_perror(s->handle, (char *)"qemu: pcap_set_promisc:");
1026 + if (pcap_activate(s->handle) != 0) {
1027 + pcap_perror(s->handle, (char *)"qemu: pcap_activate:");
1031 + /* Attempt to connect device. */
1032 + s->handle = (void *)pcap_open_live(ifname, 65535, 1, 0, errbuf);
1034 + fprintf(stderr, "qemu: pcap_open_live: %s\n", errbuf);
1039 + /* Set non-blocking mode. */
1040 + if (pcap_setnonblock(s->handle, 1, errbuf) < 0) {
1041 + fprintf(stderr, "qemu: pcap_setnonblock: %s\n", errbuf);
1045 +#if defined(_WIN32)
1047 + * Tell the kernel that the packet has to be seen immediately.
1049 + if (pcap_setmintocopy(s->handle, 0) < 0) {
1050 + fprintf(stderr, "qemu: pcap failed to set immediate mode\n");
1053 +#else /* !_WIN32 */
1054 +#if defined(CONFIG_BPF)
1055 +#if defined(BIOCIMMEDIATE)
1057 + * Tell the kernel that the packet has to be seen immediately.
1060 + unsigned int one = 1;
1061 + if (ioctl(pcap_fileno(s->handle), BIOCIMMEDIATE, &one) < 0) {
1062 + fprintf(stderr, "qemu: pcap failed to set immediate mode\n");
1066 +#endif /* BIOCIMMEDIATE */
1067 +#if defined(BIOCFEEDBACK)
1069 + * Tell the kernel that the sent packet has to be fed back.
1070 + * This is necessary to connect host and guest.
1073 + unsigned int one = 1;
1074 + if (ioctl(pcap_fileno(s->handle), BIOCFEEDBACK, &one) < 0) {
1075 + fprintf(stderr, "qemu: pcap failed to set feedback mode\n");
1079 +#endif /* BIOCFEEDBACK */
1080 +#endif /* CONFIG_BPF */
1081 +#endif /* _WIN32 */
1083 + snprintf(s->nc.info_str, sizeof(s->nc.info_str), "pcap redirector");
1085 +#if defined(_WIN32)
1086 + if ((h = pcap_getevent(s->handle)) == NULL) {
1087 + fprintf(stderr, "qemu: pcap_getevent failed\n");
1090 + qemu_add_wait_object(h, pcap_send, s);
1091 +#else /* !_WIN32 */
1092 + if ((i = pcap_get_selectable_fd(s->handle)) < 0) {
1093 + fprintf(stderr, "qemu: pcap_get_selectable_fd failed\n");
1096 + qemu_set_fd_handler(i, pcap_send, NULL, s);
1097 +#endif /* _WIN32 */
1104 + pcap_close(s->handle);
1112 static int (* const net_client_init_fun[NET_CLIENT_DRIVER__MAX])(
1113 const Netdev *netdev,
1115 @@ -960,6 +1183,9 @@ static int (* const net_client_init_fun[
1116 #ifdef CONFIG_L2TPV3
1117 [NET_CLIENT_DRIVER_L2TPV3] = net_init_l2tpv3,
1120 + [NET_CLIENT_DRIVER_PCAP] = net_init_pcap,
1127 [FILE:423:patches/patch-net_tap-bsd.c]
1128 --- net/tap-bsd.c.orig 2019-11-14 18:06:20 UTC
1132 #if defined(__NetBSD__) || defined(__FreeBSD__)
1133 #include <sys/ioctl.h>
1134 +#include <sys/socket.h>
1136 #include <net/if_tap.h>
1138 +#if defined(__DragonFly)
1139 +#include <sys/ioctl.h>
1140 +#include <sys/socket.h>
1141 +#include <net/if.h>
1142 +#include <net/tap/if_tap.h>
1145 #if defined(__OpenBSD__)
1146 #include <sys/param.h>
1149 [FILE:1550:patches/patch-qapi_net.json]
1150 --- qapi/net.json.orig 2019-11-14 18:06:21 UTC
1152 @@ -385,6 +385,19 @@
1153 '*helper': 'str' } }
1156 +# @NetdevPcapOptions:
1158 +# Use ifname as a source to capture
1160 +# @ifname: #required to determine which interface to capture
1164 +{ 'struct': 'NetdevPcapOptions',
1166 + '*ifname': 'str' } }
1169 # @NetdevHubPortOptions:
1171 # Connect two or more net clients through a software hub.
1174 { 'enum': 'NetClientDriver',
1175 'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde',
1176 - 'bridge', 'hubport', 'netmap', 'vhost-user' ] }
1177 + 'bridge', 'hubport', 'netmap', 'vhost-user', 'pcap' ] }
1182 'user': 'NetdevUserOptions',
1183 'tap': 'NetdevTapOptions',
1184 'l2tpv3': 'NetdevL2TPv3Options',
1185 + 'pcap': 'NetdevPcapOptions',
1186 'socket': 'NetdevSocketOptions',
1187 'vde': 'NetdevVdeOptions',
1188 'bridge': 'NetdevBridgeOptions',
1191 { 'enum': 'NetLegacyOptionsType',
1192 'data': ['none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde',
1193 - 'bridge', 'netmap', 'vhost-user'] }
1194 + 'bridge', 'netmap', 'vhost-user', 'pcap'] }
1197 # @NetLegacyOptions:
1199 'user': 'NetdevUserOptions',
1200 'tap': 'NetdevTapOptions',
1201 'l2tpv3': 'NetdevL2TPv3Options',
1202 + 'pcap': 'NetdevPcapOptions',
1203 'socket': 'NetdevSocketOptions',
1204 'vde': 'NetdevVdeOptions',
1205 'bridge': 'NetdevBridgeOptions',
1208 [FILE:756:patches/patch-qemu-doc.texi]
1209 --- qemu-doc.texi.orig 2019-11-14 18:06:21 UTC
1211 @@ -201,7 +201,7 @@ VGA BIOS.
1212 QEMU uses YM3812 emulation by Tatsuyuki Satoh.
1214 QEMU uses GUS emulation (GUSEMU32 @url{http://www.deinmeister.de/gusemu/})
1215 -by Tibor "TS" Schütz.
1216 +by Tibor "TS" Schuetz.
1218 Note that, by default, GUS shares IRQ(7) with parallel ports and so
1219 QEMU must be told to not have parallel ports to have working GUS.
1220 @@ -561,7 +561,8 @@ Send the escape character to the fronten
1222 @c man begin SEEALSO
1223 The HTML documentation of QEMU for more precise information and Linux
1224 -user mode emulator invocation.
1225 +user mode emulator invocation, as well as the FreeBSD host notes in
1226 +@file{pkg-message} in the relevant qemu port directory.
1232 [FILE:7685:files/pkg-message-single]
1236 - Needs to set net.link.tap.user_open sysctl in order to use /dev/tap*
1237 networking as non-root. Don't forget to adjust device node permissions in
1240 - slirp (usermode networking) is fixed now in cvs, on FreeSBIE 1.0 guests you
1241 still have to manually do: echo nameserver 10.0.2.3 >/etc/resolv.conf but
1242 i've been told that that's normal. (fixed on FreeSBIE 1.1.) And you have
1243 to wait a bit for dhclient to do its thing; traffic to address 10.0.2.2 is
1244 routed to 127.1 on the host.
1246 - Expect timer problems when guest kernel HZ is > hosts, for example time
1247 sleep 1 takes 49 seconds and booting sleeps for minutes at the acd0 probe
1248 with a FreeSBIE 1.0 guest, thats because its kernel is built with HZ=5000,
1249 and FreeBSD's default is 100... (no longer a problem with FreeSBIE 1.1.)
1250 The linux 2.6 kernel uses 1000 by default btw. (changed to 250 later, and
1251 recent linux kernels now no longer have a fixed HZ, aka `tickless
1252 kernel'...) Enabling /dev/rtc doesn't seem to help either (not included
1253 since it needs a patch to emulators/rtc.)
1255 - Update: the above problem has gotten worse with FreeBSD guests
1256 somewhere before 8.0, mainly since the kernel now usually wants
1257 double or even quadruple number of timer irqs compared to HZ if
1258 it detects an apic (and at least early versions of FreeBSD 8 had
1259 a bug that essentially halved qemu's clock rate too); the only
1260 reason you usually don't see symptoms of this with FreeBSD 8
1261 guests is they automatically reduce their HZ to 100 when running
1262 in a VM while the default for the host kernel is still HZ=1000.
1263 Workaround: you can disable the apic clock in the guest by setting
1265 hint.apic.0.clock="0"
1267 in loader.conf(5) (or manually at the loader prompt), if that
1268 doesn't work the only things you can do is either reduce the
1269 guest's HZ to, say, 100 by setting e.g.
1273 from the loader as above (which usually is a good idea in a VM
1274 anyway and FreeBSD 8 now does by itself as mentioned), or otherwise
1275 increase the host's HZ to 2000 or even 4000 from the loader in
1278 - The -smb option (smb-export local dir to guest using the default
1279 slirp networking) needs the samba port/package installed
1280 in addition to qemu. (SAMBA knob.)
1282 - If you want to use usb devices connected to the host in the guest
1283 yot need either recent 10-current (not tested yet much) or you can
1284 use usbredir over the network (see below); also unless you are
1285 running qemu as root you then need to fix permissions for /dev/ugen*
1286 device nodes: if you are on 5.x or later (devfs) put a rule in
1287 /etc/devfs.rules, activate it in /etc/rc.conf and run /etc/rc.d/devfs
1288 restart. Example devfs.rules:
1291 add path 'ugen*' mode 660 group operator
1293 corresponding rc.conf line:
1295 devfs_system_ruleset="ugen_ruleset"
1297 - If you want to test the new (in 0.15.0) usb network redirection (USBREDIR
1298 option) see this thread by Hans de Goede <hdegoede <at> redhat.com>:
1300 http://thread.gmane.org/gmane.comp.emulators.qemu/110176/focus=110183
1306 1) Start usbredirserver for a usb device:
1307 sudo usbredirserver 045e:0772
1308 2) Start qemu with usb2 support + a chardev talking to usbredirserver +
1309 a usb-redir device using this chardev:
1311 -readconfig docs/ich9-ehci-uhci.cfg \
1312 -chardev socket,id=usbredirchardev,host=localhost,port=4000 \
1313 -device usb-redir,chardev=usbredirchardev,id=usbredirdev ...
1315 [you would replace docs/ich9-ehci-uhci.cfg with e.g.
1316 /raven/share/doc/qemu/docs/ich9-ehci-uhci.cfg, but turns out
1317 ehci was broken for me here with FreeBSD guests and the previous
1318 qemu version at least, I got:
1320 FETCHENTRY: entry at 22C5484 is of type 2 which is not supported yet processing error - resetting ehci HC
1321 Assertion failed: (0), function ehci_advance_state, file /data/ports/emulators/qemu-devel/work/qemu-0.15.0/hw/usb-ehci.c, line 2045.
1323 The new qemu version works better tho.]
1325 - Still usb: since the hub is no longer attached to the uchi controller and
1326 the wakeup mechanism, resume interrupt is not implemented yet linux guests
1327 will suspend the bus, i.e. they wont see devices usb_add'ed after its
1328 (linux') uhci module got loaded. Workaround: either add devices before
1329 linux loads the module or rmmod and modprobe it afterwards. [Not sure
1330 if this still applies to the new libusb host code used on recent
1333 - If you build qemu wihout SDL and then get crashes running it try passing it
1334 -nographic. This should probably be default in that case...
1336 - qemu's network boot roms (-boot n) have a bug when bootfiles sizes are a
1337 multiple of blksize, if this affects you (like with FreeBSD's /boot/pxeboot)
1340 cp /boot/pxeboot pxeboot-qemu && chmod +w pxeboot-qemu && echo >>pxeboot-qemu
1342 and then use pxeboot-qemu. Actually you need recent btx code
1343 (from after 7.0 was released) because of the real mode boot
1344 problem, so use at least pxeboot from there. And I just did that
1345 for the pxeboot extracted out of
1347 ftp://ftp.freebsd.org/pub/FreeBSD/snapshots/200805/7.0-STABLE-200805-i386-bootonly.iso
1351 http://people.freebsd.org/~nox/qemu/pxeboot-qemu
1353 - If you use slirp (usernet, the default) and want to mount nfs into the guest
1354 and you are not running qemu as root, then mountd(8) on the exporting box
1355 needs to be run with -n in order to accept requests from ports >= 1024.
1357 - (not FreeBSD-specific:) There have been reports of qcow2 corruption with (at
1358 least) win2k guests on recent kvm (which uses similar qcow2 code than qemu
1359 now, see this thread:
1361 http://lists.gnu.org/archive/html/qemu-devel/2009-02/msg00713.html -
1363 the consensus on that thread seems to be that qcow(2) code has always been
1364 experimental and you should use raw images if you want reliability; raw is
1365 also usually faster.) You should be able to migrate existing images to raw
1366 using qemu-img(1)'s convert function; raw doesn't support advanced features
1367 like snapshots tho. [a few important qcow2 bugfixed have been committed in
1368 the meantime so this _might_ be less of an issue now; and meanwhile there
1369 also is the new qed format - I don't know how stable that one is.]
1371 - (also not FreeBSD-specific:) It is recommended to pass raw images using the
1372 new -drive syntax, specifying format=raw explicitly in order to avoid
1373 malicious guests being able to exploit the format autodetection thats
1374 otherwise getting used. (Not that you should run malicious guests anyway,
1375 but this eleminates at least a known attack vector.)
1377 - qemu now has improved physical cdrom support, but still there is at
1378 least one known problem: you need to have the guest eject the disc if you
1379 want to change it/take it out, or otherwise the guest may continue using
1380 state (like size) of the old disc. (You can also do like `change ide1-cd0
1381 /dev/acd0' in the monitor after taking out the disc if a guest cannot eject
1384 - The default configuration location (qemu-ifup script etc.) has been changed
1385 from /etc to PREFIX/etc (usually /raven/etc). Move your files accordingly.
1387 - The pcap code (-net nic... -net pcap,ifname=...) should work properly now,
1388 with only one exception: Advanced features like TSO used on the host
1389 interface can cause oversize packets which now do get truncated to avoid
1390 confusing/panicing guests but of course still will cause retransmissions.
1391 So if you see slow throughput and `pcap_send: packet size > ..., truncating'
1392 messages on qemu's tty try disabling TSO etc on the host interface at least
1396 [FILE:20:files/qemu-ifdown.sample]
1401 [FILE:20:files/qemu-ifup.sample]
1406 [FILE:66:files/special.mk]
1407 .if "${ARCH_STANDARD}" == "x86_64"
1408 MAKE_ARGS+= ARCH=x86_64
1412 [FILE:436:dragonfly/patch-disas_libvixl_vixl_utils.h]
1413 --- disas/libvixl/vixl/utils.h.orig 2019-11-14 18:06:20 UTC
1414 +++ disas/libvixl/vixl/utils.h
1415 @@ -42,6 +42,13 @@ namespace vixl {
1416 #define PRINTF_CHECK(format_index, varargs_index)
1420 +#define INT32_C(c) c
1421 +#define INT64_C(c) (c ## LL)
1422 +#define UINT32_C(c) (c ## U)
1423 +#define UINT64_C(c) (c ## ULL)
1426 // Check number width.
1427 inline bool is_intn(unsigned n, int64_t x) {
1428 VIXL_ASSERT((0 < n) && (n < 64));
1431 [FILE:323:dragonfly/patch-hw-ppc_newworld.c]
1432 --- hw/ppc/mac_newworld.c.orig 2019-11-14 18:06:20 UTC
1433 +++ hw/ppc/mac_newworld.c
1435 #include "hw/sysbus.h"
1438 +/* FreeBSD headers define this */
1443 #define MAX_IDE_BUS 2
1444 #define CFG_ADDR 0xf0000510
1445 #define TBFREQ (100UL * 1000UL * 1000UL)
1448 [FILE:334:dragonfly/patch-hw_ppc_mac__oldworld.c]
1449 --- hw/ppc/mac_oldworld.c.orig 2019-11-14 18:06:20 UTC
1450 +++ hw/ppc/mac_oldworld.c
1453 #define GRACKLE_BASE 0xfec00000
1455 +/* FreeBSD headers define this */
1460 static void fw_cfg_boot_set(void *opaque, const char *boot_device,
1465 [FILE:843:dragonfly/patch-util_coroutine-ucontext.c]
1466 --- util/coroutine-ucontext.c.orig 2019-11-14 18:06:21 UTC
1467 +++ util/coroutine-ucontext.c
1468 @@ -158,7 +158,15 @@ Coroutine *qemu_coroutine_new(void)
1469 2, arg.i[0], arg.i[1]);
1471 /* swapcontext() in, siglongjmp() back out */
1472 - if (!sigsetjmp(old_env, 0)) {
1473 + /* Save signal mask in this sigsetjmp, because makecontext on DragonFly
1474 + * leaves all signals blocked when entering the new context with
1476 + * Workaround this, by just having the signal mask restored by the
1477 + * siglongjmp that brings us back from qemu_coroutine_new().
1478 + * XXX Remove this workaround when the makecontext behaviour is fixed
1481 + if (!sigsetjmp(old_env, 1)) {
1482 start_switch_fiber(&fake_stack_save, co->stack, co->stack_size);
1483 swapcontext(&old_uc, &uc);