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.2.0.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 d3481d4108ce211a053ef15be69af1bdd9dde1510fda80d92be0f6c3e98768f0 62222068 qemu-4.2.0.tar.xz
142 [FILE:3171: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
229 edk2-i386-secure-code.fd
233 edk2-x86_64-secure-code.fd
250 opensbi-riscv32-virt-fw_jump.bin
251 opensbi-riscv64-sifive_u-fw_jump.bin
252 opensbi-riscv64-virt-fw_jump.bin
255 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:5218:manifests/plist.docs]
337 amd-memory-encryption.txt
340 block-replication.txt
354 multi-thread-compression.txt
357 pci_expander_bridge.txt
365 qemu-block-drivers.7.pod
366 qemu-block-drivers.texi
368 qemu-cpu-models.7.pod
381 virtio-balloon-stats.txt
382 virtio-net-failover.rst
385 xen-save-devices-state.txt
386 share/doc/qemu/docs/built/devel/
398 secure-coding-practices.html
403 share/doc/qemu/docs/built/devel/_static/
408 documentation_options.js
419 share/doc/qemu/docs/built/interop/
424 live-block-operations.html
433 share/doc/qemu/docs/built/interop/_static/
438 documentation_options.js
449 share/doc/qemu/docs/built/specs/
451 acpi_hw_reduced_hotplug.html
459 share/doc/qemu/docs/built/specs/_static/
464 documentation_options.js
475 share/doc/qemu/docs/config/
477 mach-virt-graphical.cfg
480 q35-virtio-graphical.cfg
481 q35-virtio-serial.cfg
482 share/doc/qemu/docs/devel/
496 multiple-iothreads.txt
501 secure-coding-practices.rst
508 writing-qmp-commands.txt
509 share/doc/qemu/docs/interop/
514 live-block-operations.rst
539 vnc-ledstate-Pseudo-encoding.txt
540 share/doc/qemu/docs/specs/
542 acpi_hw_reduced_hotplug.rst
555 ppc-spapr-hotplug.txt
556 ppc-spapr-uv-hcalls.txt
566 share/doc/qemu/docs/sphinx/qmp_lexer.py
567 share/doc/qemu/docs/sphinx/__pycache__/qmp_lexer.cpython-37.pyc
568 share/doc/qemu/docs/spin/
570 aio_notify_accept.promela
571 aio_notify_bug.promela
572 tcg-exclusive.promela
573 win32-qemu-event.promela
574 share/doc/qemu/interop/
579 live-block-operations.html
587 share/doc/qemu/interop/_static/
592 documentation_options.js
603 share/doc/qemu/specs/
605 acpi_hw_reduced_hotplug.html
613 share/doc/qemu/specs/_static/
618 documentation_options.js
631 [FILE:4086:patches/patch-configure]
632 --- configure.orig 2019-12-12 18:20:47 UTC
634 @@ -489,6 +489,9 @@ numa=""
644 @@ -1125,6 +1128,10 @@ for opt do
646 --enable-vnc-png) vnc_png="yes"
648 + --enable-pcap) pcap="yes"
650 + --disable-pcap) pcap="no"
652 --disable-slirp) slirp="no"
654 --enable-slirp=git) slirp="git"
655 @@ -3023,6 +3030,14 @@ if ! check_include "ifaddrs.h" ; then
658 ##########################################
659 +# getifaddrs (for tests/test-io-channel-socket )
662 +if ! check_include "ifaddrs.h" ; then
666 +##########################################
669 if test "$vte" != "no"; then
670 @@ -3710,7 +3725,7 @@ for i in $glib_modules; do
671 glib_libs=$($pkg_config --libs $i)
672 QEMU_CFLAGS="$glib_cflags $QEMU_CFLAGS"
673 LIBS="$glib_libs $LIBS"
674 - libs_qga="$glib_libs $libs_qga"
675 + libs_qga="$glib_libs -lintl $libs_qga"
677 error_exit "glib-$glib_req_ver $i is required to compile QEMU"
679 @@ -4802,11 +4817,6 @@ has_sphinx_build() {
680 if test "$docs" != "no" ; then
681 if has makeinfo && has pod2man && has_sphinx_build; then
684 - if test "$docs" = "yes" ; then
685 - feature_not_found "docs" "Install texinfo, Perl/perl-podlators and python-sphinx"
691 @@ -4940,7 +4950,7 @@ fi
694 if test "$libusb" != "no" ; then
695 - if $pkg_config --atleast-version=1.0.13 libusb-1.0; then
696 + if $pkg_config libusb-1.0; then
698 libusb_cflags=$($pkg_config --cflags libusb-1.0)
699 libusb_libs=$($pkg_config --libs libusb-1.0)
700 @@ -5330,6 +5340,50 @@ if test "$debug_stack_usage" = "yes"; th
704 +##########################################
707 +if test "$pcap" = "yes" -a "$pcap" != "no"; then
710 +int main(void) { return (pcap_lib_version() == (char *)0 ? 1 : 0); }
712 + if test "$mingw32" = "no" ; then
717 + if compile_prog "" "$libpcap" ; then
721 + echo "Error: Could not find pcap"
722 + echo "Make sure to have the pcap libs and headers installed."
730 + char errbuf[PCAP_ERRBUF_SIZE];
731 + return (pcap_create("foo", errbuf) == (pcap_t *)0 ? 1 : 0);
734 + if compile_prog "" "$libpcap" ; then
738 +#define PCAP_DONT_INCLUDE_PCAP_BPF_H
740 +#include <net/bpf.h>
741 +int main(void) { return (BPF_MAJOR_VERSION); }
743 + if compile_prog ; then
746 + libs_softmmu="$libpcap $libs_softmmu"
749 ##########################################
750 # check if we have open_by_handle_at
751 @@ -6497,6 +6551,7 @@ echo "Audio drivers $audio_drv_list"
752 echo "Block whitelist (rw) $block_drv_rw_whitelist"
753 echo "Block whitelist (ro) $block_drv_ro_whitelist"
754 echo "VirtFS support $virtfs"
755 +echo "pcap support $pcap"
756 echo "Multipath support $mpath"
757 echo "VNC support $vnc"
758 if test "$vnc" = "yes" ; then
759 @@ -6739,6 +6794,15 @@ fi
760 if test "$want_tools" = "yes" ; then
761 echo "CONFIG_TOOLS=y" >> $config_host_mak
763 +if test "$pcap" = "yes" ; then
764 + echo "CONFIG_PCAP=y" >> $config_host_mak
765 + if test "$pcap_create" = "yes" ; then
766 + echo "CONFIG_PCAP_CREATE=y" >> $config_host_mak
768 + if test "$bpf" = "yes" ; then
769 + echo "CONFIG_BPF=y" >> $config_host_mak
772 if test "$slirp" != "no"; then
773 echo "CONFIG_SLIRP=y" >> $config_host_mak
774 echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
775 @@ -6987,6 +7051,9 @@ fi
776 if test "$have_fsxattr" = "yes" ; then
777 echo "HAVE_FSXATTR=y" >> $config_host_mak
779 +if test "$have_ifaddrs_h" = "yes" ; then
780 + echo "HAVE_IFADDRS_H=y" >> $config_host_mak
782 if test "$have_copy_file_range" = "yes" ; then
783 echo "HAVE_COPY_FILE_RANGE=y" >> $config_host_mak
787 [FILE:365:patches/patch-disas_libvixl_vixl_a64_disasm-a64.cc]
788 --- disas/libvixl/vixl/a64/disasm-a64.cc.orig 2019-12-12 18:20:47 UTC
789 +++ disas/libvixl/vixl/a64/disasm-a64.cc
790 @@ -2693,7 +2693,7 @@ void Disassembler::AppendPCRelativeOffse
792 abs_offset = -abs_offset;
794 - AppendToOutput("#%c0x%" PRIx64, sign, abs_offset);
795 + AppendToOutput("#%c0x%" PRIx64, sign, offset < 0 ? -offset : offset);
801 [FILE:582:patches/patch-include_net_net.h]
802 --- include/net/net.h.orig 2019-12-12 18:20:48 UTC
803 +++ include/net/net.h
804 @@ -208,8 +208,8 @@ void qmp_netdev_add(QDict *qdict, QObjec
805 int net_hub_id_for_client(NetClientState *nc, int *id);
806 NetClientState *net_hub_port_find(int hub_id);
808 -#define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup"
809 -#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown"
810 +#define DEFAULT_NETWORK_SCRIPT PREFIX "/etc/qemu-ifup"
811 +#define DEFAULT_NETWORK_DOWN_SCRIPT PREFIX "/etc/qemu-ifdown"
812 #define DEFAULT_BRIDGE_HELPER CONFIG_QEMU_HELPERDIR "/qemu-bridge-helper"
813 #define DEFAULT_BRIDGE_INTERFACE "br0"
817 [FILE:2733:patches/patch-include_qemu_atomic.h]
818 --- include/qemu/atomic.h.orig 2019-12-12 18:20:48 UTC
819 +++ include/qemu/atomic.h
820 @@ -208,10 +208,12 @@
821 /* Provide shorter names for GCC atomic builtins, return old value */
822 #define atomic_fetch_inc(ptr) __atomic_fetch_add(ptr, 1, __ATOMIC_SEQ_CST)
823 #define atomic_fetch_dec(ptr) __atomic_fetch_sub(ptr, 1, __ATOMIC_SEQ_CST)
825 #define atomic_fetch_add(ptr, n) __atomic_fetch_add(ptr, n, __ATOMIC_SEQ_CST)
826 #define atomic_fetch_sub(ptr, n) __atomic_fetch_sub(ptr, n, __ATOMIC_SEQ_CST)
827 #define atomic_fetch_and(ptr, n) __atomic_fetch_and(ptr, n, __ATOMIC_SEQ_CST)
828 #define atomic_fetch_or(ptr, n) __atomic_fetch_or(ptr, n, __ATOMIC_SEQ_CST)
830 #define atomic_fetch_xor(ptr, n) __atomic_fetch_xor(ptr, n, __ATOMIC_SEQ_CST)
832 #define atomic_inc_fetch(ptr) __atomic_add_fetch(ptr, 1, __ATOMIC_SEQ_CST)
833 @@ -225,10 +227,12 @@
834 /* And even shorter names that return void. */
835 #define atomic_inc(ptr) ((void) __atomic_fetch_add(ptr, 1, __ATOMIC_SEQ_CST))
836 #define atomic_dec(ptr) ((void) __atomic_fetch_sub(ptr, 1, __ATOMIC_SEQ_CST))
838 #define atomic_add(ptr, n) ((void) __atomic_fetch_add(ptr, n, __ATOMIC_SEQ_CST))
839 #define atomic_sub(ptr, n) ((void) __atomic_fetch_sub(ptr, n, __ATOMIC_SEQ_CST))
840 #define atomic_and(ptr, n) ((void) __atomic_fetch_and(ptr, n, __ATOMIC_SEQ_CST))
841 #define atomic_or(ptr, n) ((void) __atomic_fetch_or(ptr, n, __ATOMIC_SEQ_CST))
843 #define atomic_xor(ptr, n) ((void) __atomic_fetch_xor(ptr, n, __ATOMIC_SEQ_CST))
845 #else /* __ATOMIC_RELAXED */
846 @@ -400,10 +404,12 @@
848 #define atomic_inc_fetch(ptr) __sync_add_and_fetch(ptr, 1)
849 #define atomic_dec_fetch(ptr) __sync_add_and_fetch(ptr, -1)
851 #define atomic_add_fetch(ptr, n) __sync_add_and_fetch(ptr, n)
852 #define atomic_sub_fetch(ptr, n) __sync_sub_and_fetch(ptr, n)
853 #define atomic_and_fetch(ptr, n) __sync_and_and_fetch(ptr, n)
854 #define atomic_or_fetch(ptr, n) __sync_or_and_fetch(ptr, n)
856 #define atomic_xor_fetch(ptr, n) __sync_xor_and_fetch(ptr, n)
858 #define atomic_cmpxchg(ptr, old, new) __sync_val_compare_and_swap(ptr, old, new)
859 @@ -412,10 +418,12 @@
860 /* And even shorter names that return void. */
861 #define atomic_inc(ptr) ((void) __sync_fetch_and_add(ptr, 1))
862 #define atomic_dec(ptr) ((void) __sync_fetch_and_add(ptr, -1))
864 #define atomic_add(ptr, n) ((void) __sync_fetch_and_add(ptr, n))
865 #define atomic_sub(ptr, n) ((void) __sync_fetch_and_sub(ptr, n))
866 #define atomic_and(ptr, n) ((void) __sync_fetch_and_and(ptr, n))
867 #define atomic_or(ptr, n) ((void) __sync_fetch_and_or(ptr, n))
869 #define atomic_xor(ptr, n) ((void) __sync_fetch_and_xor(ptr, n))
871 #endif /* __ATOMIC_RELAXED */
874 [FILE:436:patches/patch-net_clients.h]
875 --- net/clients.h.orig 2019-12-12 18:20:48 UTC
877 @@ -61,4 +61,10 @@ int net_init_netmap(const Netdev *netdev
878 int net_init_vhost_user(const Netdev *netdev, const char *name,
879 NetClientState *peer, Error **errp);
882 +int net_init_pcap(const Netdev *netdev, const char *name,
883 + NetClientState *peer, Error **errp);
887 #endif /* QEMU_NET_CLIENTS_H */
890 [FILE:6930:patches/patch-net_net.c]
891 --- net/net.c.orig 2019-12-12 18:20:48 UTC
894 #include "net/filter.h"
895 #include "qapi/string-output-visitor.h"
897 +#include <sys/ioctl.h>
898 +#if defined(__FreeBSD__) || defined(__DragonFly__)
902 /* Net bridge is currently not supported for W32. */
904 # define CONFIG_NET_BRIDGE
905 @@ -935,7 +940,225 @@ static int net_init_nic(const Netdev *ne
909 +#if defined(CONFIG_PCAP)
910 +#if defined(CONFIG_BPF)
911 +#define PCAP_DONT_INCLUDE_PCAP_BPF_H
912 +#include <net/bpf.h>
919 + int max_eth_frame_size;
922 +static ssize_t pcap_receive(NetClientState *nc, const uint8_t *buf, size_t size)
924 + struct PCAPState *s = DO_UPCAST(struct PCAPState, nc, nc);
926 + return pcap_inject(s->handle, (u_char*)buf, size);
929 +static void pcap_callback(u_char *user, struct pcap_pkthdr *phdr, u_char *pdata
932 + NetClientState *nc = (NetClientState *)user;
934 + int len = phdr->len;
935 +#if defined(__FreeBSD__) || defined(__DragonFly__)
936 + struct PCAPState *s = DO_UPCAST(struct PCAPState, nc, nc);
937 + int max_eth_frame_size = s->max_eth_frame_size;
939 + if (len > max_eth_frame_size) {
941 + "pcap_send: packet size > %d (%d), truncating\n",
942 + max_eth_frame_size, len);
943 + len = max_eth_frame_size;
946 + qemu_send_packet(nc, pdata, len);
949 +static void pcap_send(void *opaque)
951 + struct PCAPState *s = (struct PCAPState *)opaque;
954 + if (pcap_dispatch(s->handle, 0, (pcap_handler)&pcap_callback, (u_char *)&s->nc) >= 0)
959 +static void pcap_cleanup(NetClientState *nc)
961 + struct PCAPState *s = DO_UPCAST(struct PCAPState, nc, nc);
963 + qemu_purge_queued_packets(nc);
964 + pcap_close(s->handle);
967 +static NetClientInfo net_pcap_info = {
968 + .type = NET_CLIENT_DRIVER_PCAP,
969 + .size = sizeof(struct PCAPState),
970 + .receive = pcap_receive,
971 +// .receive_raw = pcap_receive_raw,
972 +// .receive_iov = pcap_receive_iov,
973 +// .poll = pcap_poll,
974 + .cleanup = pcap_cleanup,
977 + * ... -net pcap,ifname="..."
980 +int net_init_pcap(const Netdev *netdev,
981 + const char *name, NetClientState *peer, Error **errp)
983 + const NetdevPcapOptions *pcap_opts;
984 + NetClientState *nc;
985 + struct PCAPState *s;
986 + const char *ifname;
987 + char errbuf[PCAP_ERRBUF_SIZE];
993 + assert(netdev->type == NET_CLIENT_DRIVER_PCAP);
994 + pcap_opts = &netdev->u.pcap;
995 + if (!pcap_opts->has_ifname)
998 + ifname = pcap_opts->ifname;
1000 + /* create the object */
1001 + nc = qemu_new_net_client(&net_pcap_info, peer, "pcap", ifname);
1002 + s = DO_UPCAST(struct PCAPState, nc, nc);
1004 + if (ifname == NULL && (ifname = pcap_lookupdev(errbuf)) == NULL) {
1005 + fprintf(stderr, "qemu: pcap_create: %s\n", errbuf);
1009 +#if defined(__FreeBSD__) || defined(__DragonFly__)
1011 + * We want to avoid passing oversize packets to the guest, which
1012 + * at least on FreeBSD can happen if the host interface uses tso
1013 + * (seen with an em(4) in this case) - so find out the host
1014 + * interface's mtu and assume the guest is configured the same.
1016 + s->max_eth_frame_size = 1514;
1017 + i = socket(AF_INET, SOCK_DGRAM, 0);
1021 + (void) memset(&ifr, 0, sizeof(ifr));
1022 + strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
1023 + if (ioctl(i, SIOCGIFMTU, &ifr) != -1)
1024 + s->max_eth_frame_size = ifr.ifr_mtu + 14;
1029 +#if defined(CONFIG_PCAP_CREATE) || defined(_WIN32)
1031 + * Create pcap handle for the device, set promiscuous mode and activate.
1033 + s->handle = (void *)pcap_create(ifname, errbuf);
1035 + fprintf(stderr, "qemu: pcap_create: %s\n", errbuf);
1038 + if (pcap_set_promisc(s->handle, 1) != 0) {
1039 + pcap_perror(s->handle, (char *)"qemu: pcap_set_promisc:");
1042 + if (pcap_activate(s->handle) != 0) {
1043 + pcap_perror(s->handle, (char *)"qemu: pcap_activate:");
1047 + /* Attempt to connect device. */
1048 + s->handle = (void *)pcap_open_live(ifname, 65535, 1, 0, errbuf);
1050 + fprintf(stderr, "qemu: pcap_open_live: %s\n", errbuf);
1055 + /* Set non-blocking mode. */
1056 + if (pcap_setnonblock(s->handle, 1, errbuf) < 0) {
1057 + fprintf(stderr, "qemu: pcap_setnonblock: %s\n", errbuf);
1061 +#if defined(_WIN32)
1063 + * Tell the kernel that the packet has to be seen immediately.
1065 + if (pcap_setmintocopy(s->handle, 0) < 0) {
1066 + fprintf(stderr, "qemu: pcap failed to set immediate mode\n");
1069 +#else /* !_WIN32 */
1070 +#if defined(CONFIG_BPF)
1071 +#if defined(BIOCIMMEDIATE)
1073 + * Tell the kernel that the packet has to be seen immediately.
1076 + unsigned int one = 1;
1077 + if (ioctl(pcap_fileno(s->handle), BIOCIMMEDIATE, &one) < 0) {
1078 + fprintf(stderr, "qemu: pcap failed to set immediate mode\n");
1082 +#endif /* BIOCIMMEDIATE */
1083 +#if defined(BIOCFEEDBACK)
1085 + * Tell the kernel that the sent packet has to be fed back.
1086 + * This is necessary to connect host and guest.
1089 + unsigned int one = 1;
1090 + if (ioctl(pcap_fileno(s->handle), BIOCFEEDBACK, &one) < 0) {
1091 + fprintf(stderr, "qemu: pcap failed to set feedback mode\n");
1095 +#endif /* BIOCFEEDBACK */
1096 +#endif /* CONFIG_BPF */
1097 +#endif /* _WIN32 */
1099 + snprintf(s->nc.info_str, sizeof(s->nc.info_str), "pcap redirector");
1101 +#if defined(_WIN32)
1102 + if ((h = pcap_getevent(s->handle)) == NULL) {
1103 + fprintf(stderr, "qemu: pcap_getevent failed\n");
1106 + qemu_add_wait_object(h, pcap_send, s);
1107 +#else /* !_WIN32 */
1108 + if ((i = pcap_get_selectable_fd(s->handle)) < 0) {
1109 + fprintf(stderr, "qemu: pcap_get_selectable_fd failed\n");
1112 + qemu_set_fd_handler(i, pcap_send, NULL, s);
1113 +#endif /* _WIN32 */
1120 + pcap_close(s->handle);
1128 static int (* const net_client_init_fun[NET_CLIENT_DRIVER__MAX])(
1129 const Netdev *netdev,
1131 @@ -962,6 +1185,9 @@ static int (* const net_client_init_fun[
1132 #ifdef CONFIG_L2TPV3
1133 [NET_CLIENT_DRIVER_L2TPV3] = net_init_l2tpv3,
1136 + [NET_CLIENT_DRIVER_PCAP] = net_init_pcap,
1143 [FILE:423:patches/patch-net_tap-bsd.c]
1144 --- net/tap-bsd.c.orig 2019-12-12 18:20:48 UTC
1148 #if defined(__NetBSD__) || defined(__FreeBSD__)
1149 #include <sys/ioctl.h>
1150 +#include <sys/socket.h>
1152 #include <net/if_tap.h>
1154 +#if defined(__DragonFly)
1155 +#include <sys/ioctl.h>
1156 +#include <sys/socket.h>
1157 +#include <net/if.h>
1158 +#include <net/tap/if_tap.h>
1161 #if defined(__OpenBSD__)
1162 #include <sys/param.h>
1165 [FILE:1550:patches/patch-qapi_net.json]
1166 --- qapi/net.json.orig 2019-12-12 18:20:48 UTC
1168 @@ -385,6 +385,19 @@
1169 '*helper': 'str' } }
1172 +# @NetdevPcapOptions:
1174 +# Use ifname as a source to capture
1176 +# @ifname: #required to determine which interface to capture
1180 +{ 'struct': 'NetdevPcapOptions',
1182 + '*ifname': 'str' } }
1185 # @NetdevHubPortOptions:
1187 # Connect two or more net clients through a software hub.
1190 { 'enum': 'NetClientDriver',
1191 'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde',
1192 - 'bridge', 'hubport', 'netmap', 'vhost-user' ] }
1193 + 'bridge', 'hubport', 'netmap', 'vhost-user', 'pcap' ] }
1198 'user': 'NetdevUserOptions',
1199 'tap': 'NetdevTapOptions',
1200 'l2tpv3': 'NetdevL2TPv3Options',
1201 + 'pcap': 'NetdevPcapOptions',
1202 'socket': 'NetdevSocketOptions',
1203 'vde': 'NetdevVdeOptions',
1204 'bridge': 'NetdevBridgeOptions',
1207 { 'enum': 'NetLegacyOptionsType',
1208 'data': ['none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'vde',
1209 - 'bridge', 'netmap', 'vhost-user'] }
1210 + 'bridge', 'netmap', 'vhost-user', 'pcap'] }
1213 # @NetLegacyOptions:
1215 'user': 'NetdevUserOptions',
1216 'tap': 'NetdevTapOptions',
1217 'l2tpv3': 'NetdevL2TPv3Options',
1218 + 'pcap': 'NetdevPcapOptions',
1219 'socket': 'NetdevSocketOptions',
1220 'vde': 'NetdevVdeOptions',
1221 'bridge': 'NetdevBridgeOptions',
1224 [FILE:756:patches/patch-qemu-doc.texi]
1225 --- qemu-doc.texi.orig 2019-12-12 18:20:48 UTC
1227 @@ -205,7 +205,7 @@ VGA BIOS.
1228 QEMU uses YM3812 emulation by Tatsuyuki Satoh.
1230 QEMU uses GUS emulation (GUSEMU32 @url{http://www.deinmeister.de/gusemu/})
1231 -by Tibor "TS" Schütz.
1232 +by Tibor "TS" Schuetz.
1234 Note that, by default, GUS shares IRQ(7) with parallel ports and so
1235 QEMU must be told to not have parallel ports to have working GUS.
1236 @@ -573,7 +573,8 @@ Send the escape character to the fronten
1238 @c man begin SEEALSO
1239 The HTML documentation of QEMU for more precise information and Linux
1240 -user mode emulator invocation.
1241 +user mode emulator invocation, as well as the FreeBSD host notes in
1242 +@file{pkg-message} in the relevant qemu port directory.
1248 [FILE:7685:files/pkg-message-single]
1252 - Needs to set net.link.tap.user_open sysctl in order to use /dev/tap*
1253 networking as non-root. Don't forget to adjust device node permissions in
1256 - slirp (usermode networking) is fixed now in cvs, on FreeSBIE 1.0 guests you
1257 still have to manually do: echo nameserver 10.0.2.3 >/etc/resolv.conf but
1258 i've been told that that's normal. (fixed on FreeSBIE 1.1.) And you have
1259 to wait a bit for dhclient to do its thing; traffic to address 10.0.2.2 is
1260 routed to 127.1 on the host.
1262 - Expect timer problems when guest kernel HZ is > hosts, for example time
1263 sleep 1 takes 49 seconds and booting sleeps for minutes at the acd0 probe
1264 with a FreeSBIE 1.0 guest, thats because its kernel is built with HZ=5000,
1265 and FreeBSD's default is 100... (no longer a problem with FreeSBIE 1.1.)
1266 The linux 2.6 kernel uses 1000 by default btw. (changed to 250 later, and
1267 recent linux kernels now no longer have a fixed HZ, aka `tickless
1268 kernel'...) Enabling /dev/rtc doesn't seem to help either (not included
1269 since it needs a patch to emulators/rtc.)
1271 - Update: the above problem has gotten worse with FreeBSD guests
1272 somewhere before 8.0, mainly since the kernel now usually wants
1273 double or even quadruple number of timer irqs compared to HZ if
1274 it detects an apic (and at least early versions of FreeBSD 8 had
1275 a bug that essentially halved qemu's clock rate too); the only
1276 reason you usually don't see symptoms of this with FreeBSD 8
1277 guests is they automatically reduce their HZ to 100 when running
1278 in a VM while the default for the host kernel is still HZ=1000.
1279 Workaround: you can disable the apic clock in the guest by setting
1281 hint.apic.0.clock="0"
1283 in loader.conf(5) (or manually at the loader prompt), if that
1284 doesn't work the only things you can do is either reduce the
1285 guest's HZ to, say, 100 by setting e.g.
1289 from the loader as above (which usually is a good idea in a VM
1290 anyway and FreeBSD 8 now does by itself as mentioned), or otherwise
1291 increase the host's HZ to 2000 or even 4000 from the loader in
1294 - The -smb option (smb-export local dir to guest using the default
1295 slirp networking) needs the samba port/package installed
1296 in addition to qemu. (SAMBA knob.)
1298 - If you want to use usb devices connected to the host in the guest
1299 yot need either recent 10-current (not tested yet much) or you can
1300 use usbredir over the network (see below); also unless you are
1301 running qemu as root you then need to fix permissions for /dev/ugen*
1302 device nodes: if you are on 5.x or later (devfs) put a rule in
1303 /etc/devfs.rules, activate it in /etc/rc.conf and run /etc/rc.d/devfs
1304 restart. Example devfs.rules:
1307 add path 'ugen*' mode 660 group operator
1309 corresponding rc.conf line:
1311 devfs_system_ruleset="ugen_ruleset"
1313 - If you want to test the new (in 0.15.0) usb network redirection (USBREDIR
1314 option) see this thread by Hans de Goede <hdegoede <at> redhat.com>:
1316 http://thread.gmane.org/gmane.comp.emulators.qemu/110176/focus=110183
1322 1) Start usbredirserver for a usb device:
1323 sudo usbredirserver 045e:0772
1324 2) Start qemu with usb2 support + a chardev talking to usbredirserver +
1325 a usb-redir device using this chardev:
1327 -readconfig docs/ich9-ehci-uhci.cfg \
1328 -chardev socket,id=usbredirchardev,host=localhost,port=4000 \
1329 -device usb-redir,chardev=usbredirchardev,id=usbredirdev ...
1331 [you would replace docs/ich9-ehci-uhci.cfg with e.g.
1332 /raven/share/doc/qemu/docs/ich9-ehci-uhci.cfg, but turns out
1333 ehci was broken for me here with FreeBSD guests and the previous
1334 qemu version at least, I got:
1336 FETCHENTRY: entry at 22C5484 is of type 2 which is not supported yet processing error - resetting ehci HC
1337 Assertion failed: (0), function ehci_advance_state, file /data/ports/emulators/qemu-devel/work/qemu-0.15.0/hw/usb-ehci.c, line 2045.
1339 The new qemu version works better tho.]
1341 - Still usb: since the hub is no longer attached to the uchi controller and
1342 the wakeup mechanism, resume interrupt is not implemented yet linux guests
1343 will suspend the bus, i.e. they wont see devices usb_add'ed after its
1344 (linux') uhci module got loaded. Workaround: either add devices before
1345 linux loads the module or rmmod and modprobe it afterwards. [Not sure
1346 if this still applies to the new libusb host code used on recent
1349 - If you build qemu wihout SDL and then get crashes running it try passing it
1350 -nographic. This should probably be default in that case...
1352 - qemu's network boot roms (-boot n) have a bug when bootfiles sizes are a
1353 multiple of blksize, if this affects you (like with FreeBSD's /boot/pxeboot)
1356 cp /boot/pxeboot pxeboot-qemu && chmod +w pxeboot-qemu && echo >>pxeboot-qemu
1358 and then use pxeboot-qemu. Actually you need recent btx code
1359 (from after 7.0 was released) because of the real mode boot
1360 problem, so use at least pxeboot from there. And I just did that
1361 for the pxeboot extracted out of
1363 ftp://ftp.freebsd.org/pub/FreeBSD/snapshots/200805/7.0-STABLE-200805-i386-bootonly.iso
1367 http://people.freebsd.org/~nox/qemu/pxeboot-qemu
1369 - If you use slirp (usernet, the default) and want to mount nfs into the guest
1370 and you are not running qemu as root, then mountd(8) on the exporting box
1371 needs to be run with -n in order to accept requests from ports >= 1024.
1373 - (not FreeBSD-specific:) There have been reports of qcow2 corruption with (at
1374 least) win2k guests on recent kvm (which uses similar qcow2 code than qemu
1375 now, see this thread:
1377 http://lists.gnu.org/archive/html/qemu-devel/2009-02/msg00713.html -
1379 the consensus on that thread seems to be that qcow(2) code has always been
1380 experimental and you should use raw images if you want reliability; raw is
1381 also usually faster.) You should be able to migrate existing images to raw
1382 using qemu-img(1)'s convert function; raw doesn't support advanced features
1383 like snapshots tho. [a few important qcow2 bugfixed have been committed in
1384 the meantime so this _might_ be less of an issue now; and meanwhile there
1385 also is the new qed format - I don't know how stable that one is.]
1387 - (also not FreeBSD-specific:) It is recommended to pass raw images using the
1388 new -drive syntax, specifying format=raw explicitly in order to avoid
1389 malicious guests being able to exploit the format autodetection thats
1390 otherwise getting used. (Not that you should run malicious guests anyway,
1391 but this eleminates at least a known attack vector.)
1393 - qemu now has improved physical cdrom support, but still there is at
1394 least one known problem: you need to have the guest eject the disc if you
1395 want to change it/take it out, or otherwise the guest may continue using
1396 state (like size) of the old disc. (You can also do like `change ide1-cd0
1397 /dev/acd0' in the monitor after taking out the disc if a guest cannot eject
1400 - The default configuration location (qemu-ifup script etc.) has been changed
1401 from /etc to PREFIX/etc (usually /raven/etc). Move your files accordingly.
1403 - The pcap code (-net nic... -net pcap,ifname=...) should work properly now,
1404 with only one exception: Advanced features like TSO used on the host
1405 interface can cause oversize packets which now do get truncated to avoid
1406 confusing/panicing guests but of course still will cause retransmissions.
1407 So if you see slow throughput and `pcap_send: packet size > ..., truncating'
1408 messages on qemu's tty try disabling TSO etc on the host interface at least
1412 [FILE:20:files/qemu-ifdown.sample]
1417 [FILE:20:files/qemu-ifup.sample]
1422 [FILE:66:files/special.mk]
1423 .if "${ARCH_STANDARD}" == "x86_64"
1424 MAKE_ARGS+= ARCH=x86_64
1428 [FILE:436:dragonfly/patch-disas_libvixl_vixl_utils.h]
1429 --- disas/libvixl/vixl/utils.h.orig 2019-12-12 18:20:47 UTC
1430 +++ disas/libvixl/vixl/utils.h
1431 @@ -42,6 +42,13 @@ namespace vixl {
1432 #define PRINTF_CHECK(format_index, varargs_index)
1436 +#define INT32_C(c) c
1437 +#define INT64_C(c) (c ## LL)
1438 +#define UINT32_C(c) (c ## U)
1439 +#define UINT64_C(c) (c ## ULL)
1442 // Check number width.
1443 inline bool is_intn(unsigned n, int64_t x) {
1444 VIXL_ASSERT((0 < n) && (n < 64));
1447 [FILE:323:dragonfly/patch-hw-ppc_newworld.c]
1448 --- hw/ppc/mac_newworld.c.orig 2019-12-12 18:20:47 UTC
1449 +++ hw/ppc/mac_newworld.c
1451 #include "hw/sysbus.h"
1454 +/* FreeBSD headers define this */
1459 #define MAX_IDE_BUS 2
1460 #define CFG_ADDR 0xf0000510
1461 #define TBFREQ (100UL * 1000UL * 1000UL)
1464 [FILE:334:dragonfly/patch-hw_ppc_mac__oldworld.c]
1465 --- hw/ppc/mac_oldworld.c.orig 2019-12-12 18:20:47 UTC
1466 +++ hw/ppc/mac_oldworld.c
1469 #define GRACKLE_BASE 0xfec00000
1471 +/* FreeBSD headers define this */
1476 static void fw_cfg_boot_set(void *opaque, const char *boot_device,
1481 [FILE:843:dragonfly/patch-util_coroutine-ucontext.c]
1482 --- util/coroutine-ucontext.c.orig 2019-12-12 18:20:48 UTC
1483 +++ util/coroutine-ucontext.c
1484 @@ -158,7 +158,15 @@ Coroutine *qemu_coroutine_new(void)
1485 2, arg.i[0], arg.i[1]);
1487 /* swapcontext() in, siglongjmp() back out */
1488 - if (!sigsetjmp(old_env, 0)) {
1489 + /* Save signal mask in this sigsetjmp, because makecontext on DragonFly
1490 + * leaves all signals blocked when entering the new context with
1492 + * Workaround this, by just having the signal mask restored by the
1493 + * siglongjmp that brings us back from qemu_coroutine_new().
1494 + * XXX Remove this workaround when the makecontext behaviour is fixed
1497 + if (!sigsetjmp(old_env, 1)) {
1498 start_switch_fiber(&fake_stack_save, co->stack, co->stack_size);
1499 swapcontext(&old_uc, &uc);