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. 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 very safe and easy to use.
WWW: http://wiki.qemu.org/Main_Page
This is building sbruno's bsd-user github branch:
WWW: https://github.com/seanbruno/qemu-bsd-user/commits/bsd-user
===> The following configuration options are available for qemu-sbruno-2.11.50.g20191211_4:
BSD_USER=off: Also build bsd-user targets (for testing)
CDROM_DMA=on: IDE CDROM DMA
CURL=on: Data transfer support via cURL
DOCS=on: Build and/or install documentation
GNUTLS=on: gnutls dependency (vnc encryption)
GTK2=on: GTK+ 2 GUI toolkit support
JPEG=on: jpeg dependency (vnc lossy compression)
OPENGL=on: 2D/3D rendering support via OpenGL
PCAP=on: pcap dependency (networking with bpf)
PNG=on: png dependency (vnc compression)
SAMBA=off: samba dependency (for -smb)
SASL=on: cyrus-sasl dependency (vnc encryption)
STATIC_LINK=off: Statically link the executables
USBREDIR=off: usb device network redirection (experimental!)
X11=on: X11 (graphics) support
X86_TARGETS=off: Don't build non-x86 system targets
===> Use 'make config' to modify these settings
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 <hdegoede <at> 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.
/usr/local/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 get repeated `atapi_poll called!' console messages with FreeBSD
guests or other weird cdrom problems then thats probably because the guest
has atapicam loaded, which for reasons still to be determined has problems
with qemu's now by default enabled cdrom dma. You can build the port with
CDROM_DMA disabled to disable it. [Looks like this is fixed in recent
FreeBSD guest versions.]
- 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 /usr/local/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.
)
Remove expired ports:
2020-09-30 audio/zinf: Does not build, no upstream
2020-10-01 emulators/qemu-sbruno: Port will be removed in favor of
emulators/qemu
emulators/qemu-sbruno: bump PORTREVISION for recent DEPRECATION
DEPRECATED was added in r533075 and gets encoded in the pkg; make sure that
users of the pkg get the notice far in advance that this port is going away,
as it will not receive any further updates that would trigger the rebuild.
Approved by: koobs (mentor)
MFH: 2020Q2 (blanket: metadata correction)
emulators/qemu-user-static: revive as a copy of qemu-user-static-devel
This is effectively the 3.1 update of qemu-user-static. The main feature of
the update to 3.1 is RISC-V support, contributed by Embecosm.
PR: 243906
Approved by: koobs (mentor)
reated attachment 212362 [details]
Fix emulators/qemu-sbruno build with lld 10.0.0
As reported in bug 244251, with clang and lld 10.0.0 the emulators/qemu-sbruno
port fails in the configure stage:
===> Configuring for qemu-user-static-2.11.50.g20191211_3
ERROR: We need to link the QEMU user mode binaries at a
specific text address. Unfortunately your linker
doesn't support either the -Ttext-segment option or
printing the default linker script with --verbose.
If you don't want the user mode binaries, pass the
--disable-user option to configure.
===> Script "configure" failed unexpectedly.
(Only the first 15 lines of the commit message are shown above )
qemu-user-static: revert SSP_CFLAGS workaround (ports r501032)
This was later diagnosed to be a bug in libc, which has since been addressed
in all supported releases and branches. PORTREVISION is bumped as SSP_CFLAGS
will change the output, and for consumers of these two ports it is
imperative that it be rebuilt against the updated libc to avoid high failure
rates. In testing qemu-user-static-devel failed roughly 60% of the time,
rendering it unusable as each fork/exec was yet one more chance to fail.
The bug was fixed in the following patch levels (FreeBSD-EN-20:01.ssp):
- 12.1-p2
- 12.0-p13
- 11.3-p6
PR: 243735
Approved by: koobs (ports)
MFH: 2020Q1
emulators/qemu-sbruno: allow 64-bit targets on powerpc64
Builds fine, I have no way to confirm it builds working binaries for those
targets, but binaries for armv7 are fine.
Approved by: kevans91
emulators/qemu-user-static{,-devel}: unbreak after base r355641
r355641 added sigorset to base, which collides with sigorset in
qemu-user-static. This is effectively a patch (applied in the qemu-bsd-user
repo) that makes the qemu version private and uses that for now, until
sigorset in FreeBSD stabilizes across older branches.
Approved by: 0mp (ports)
NEW PORT: emulators/qemu-user-static-devel: QEMU user-mode emulation
This port represents the to-be-released version of qemu-user-static for
testing prior to unleashing it upon the community at large and the package
building infrastructure. Currently, it is based on the bsd-user-rebase-3.1
branch that moves the base qemu version of this work forward.
The main highlight of the update to 3.1 is initial riscv64 bsd-user support,
submitted by Embecosm.
This version of the port is also notably no longer based on the master port,
qemu-sbruno, but repocopied from it due to reusing a good portion of it. As
such, it's been severely reduced to eliminate all of the bits not relevant
to building bsd-user/ (including the various port options), so much of the
diff is eliminating the option-enabled checks and combining them all into a
(Only the first 15 lines of the commit message are shown above )
emulators/qemu-user-static: update to head as of 2019/11/12
With this update, sendmsg/recvmsg (thus, casper'ized) applications now work
again on mips. Various signal handling issues have also been addressed,
most notably qemu-user-static should no longer deadlock when evaluating
whether printf survives out-of-memory conditions or not.
PR: 224740
Approved by: ler (ports), sbruno (maintainer, implicit)
MFH: 2019Q4
qemu-user-static: fix the RFSPAWN fix + kevent(2) emulation
The RFSPAWN fix included a bogus dependency on qemu-user-static being built
against headers that included the RFSPAWN flag. This is incorrect in
emulation-land, where we must assume the target may not match the host.
kevent(2) emulation was also not preserving event udata coming from the
kernel; the fix for this is als included.
Approved by: antoine (ports), sbruno (maintainer, implicit)
MFH: 2019Q4
qemu-user-static: pull in fixes for the 2.x branch
Short list:
- __sysctlbyname(2) implemented
- posix_spawn breakage due to RFSPAWN averted
- some _umtx_op misbehavior fixed*
Some _umtx_op operations were processing a timeout, but failed to pass in
the size of the timespec/_umtx_time to the kernel, passing in '0' instead.
This would cause unbounded sleep until interrupted, rather than timeout
expected by the caller.
PR: 240763
Approved by: ler (ports), sbruno (maintainer, implicit)
MFH: 2019Q4 (runtime fix)
qemu-sbruno:
- fix qemu-user-static hangs with wc -l //
- add qemu-user-static redirection for riscv64, no support, yet.
Thanks to kevans, miki and others for fixing this nonsense.
Submitted by: kevans miki
emulators/qemu-sbruno:
- Add a "-O argv0" argument to qemu-bsd-user for use in execve() calls:
Prior to this commit, the value of argv[0] was discarded as it was
overwritten by the path to the program being executed. This commit
uses the new -0 option to retain that information; in particular,
this unbreaks mailwrapper+sendmail, which makes use of this to know
which of multiple functions should be performed.
Submitted by: cperciva
Bump qemu-sbruno to capture 4ef7d07
- Avoid the overflow reported by Mark Millard...New version is safer
end_addr >= addr is assured earlier in this loop.
Submitted by: kevans
Reported by: Mark Millard <marklmi@yahoo.com>
Remove compatibility code for FreeBSD < 11.2 from all ports.
Simplify some ports where DragonFlyBSD no longer needs to be special-cased.
Submitted by: rene
Reviewed by: bapt, jbeich
Differential Revision: https://reviews.freebsd.org/D17724
Switch default version of samba to 4.7
Samba 4.6 will be discontinued in a few weeks
Reviewed by: mat
Differential Revision: https://reviews.freebsd.org/D16904
Work around the lack of definition of union semun per POSIX.
When feasible do this by adding -D_WANT_SEMUN to CFLAGS or CXXFLAGS.
Where this fails due to ports not honoring C*FLAGS, patch using
__FreeBSD_version to enable the definition.
PR: 224300, 224443 (exp-run)
Approved by: portmgr (antoine)
Exp-run: antoine
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D14137
Rename and regenerate the patch files so they have normal syntax and
names and don't require -p1.
No functional change.
Approved by: sbruno (maintainer)
Update to the latest on github.
Clean up distfile handling.
Suppress unimportant and very noisy warnings in qemu-user-static.
PR: 225831
Approved by: sbruno (maintainer)
Sponsored by: DARPA, AFRL
emulators/qemu-sbruno
emulators/qemu-user-static
Update to 2.11.50 + patches from submitters. Upstream introduced some git
nonsense with remotes inside their repos. Change the way we fetch our
distributions with GH_TUPLE instead of the previous way. Clean up a couple
lines commented out for the PCAP features that aren't stored in a patch, but
merely direct committed to this tree.
- Remove the interpreter name and interpreter prefix when retrieving the
argument vectors using kvm_getargv (Mikael Urankar)
- No need to check msg_controllen: msg_controllen can have the value 0 and
the kernel discards negative value (Mikael Urankar)
- Implement/modify kevent64 related syscalls. (Mikael Urankar)
- Implement ktimer_{create, delete, settime, gettime} (Mikael Urankar)
- Stop using basename_r(3). Fix build after FreeBSD svn r326719 (Ed Shouten)
Changelogs can be found at https://github.com/seanbruno/qemu-bsd-user
PR: 224016
Bump qemu-sbruno to chase qemu release candidates.
Add redirection for "armv7" so the poudriere can be tested for this
target when its ready.
Fix bsd-mem.h do_obreak() to invoke an mmap() with a proper -1 argument
for the fd argument.
Submitted by: Mikael Urankanar <mikael.urankar@gmail.com>
Update host kernel signal state when using sa_sigaction.
Merge linux-user change to allocate heap memory for execve args.
Submitted by: Mikael Urankanar <mikael.urankar@gmail.com>
Sync to QEMU for today.
Switch to using sysutils/dtc for libfdt with qemu-sbruno, remove
use of nox's homedir for providing dtc/libfdt and remove it as
a build depend in the qemu-user-static path if it was even being
built.
Bump after pull requests.
- add strace logging for new syscalls after ino64 update
- sync mmap() code with linux-user
- implement posix_fallocate()
-- this should help building aarch64 ports a bit.
- tcg: add handling for EXCP_ATOMIC
Submitted by: Mikael Urankanar <mikael.urankar@gmail.com>
Bump for today's pull request:
Change certain bits of mmap.c to check for the fd that is passed into
mmap() for the value -1 instead of MAP_ANONYMOUS. This should be much
more reliable as we will avoid doing an mmap() of -1. :-)
Also include sys/param.h in mmap.c to capture __FreeBSD_version so that
MAP_GUARD code is actually run on versions that support it.
https://github.com/seanbruno/qemu-bsd-user/pull/45
Submitted by: Guy Yur
Bump qemu-sbruno/qemu-user-static to capture fixes that are now required
in -current in support of mmap() MAP_GUARD.
Thanks to kib@ for the explanations and test program that I used to
come up with a solution.
While here, sync to upstream a bit. This requires a little bit of a
fixup for NODOC builds.
Update qemu-sbruno and qemu-user-static to 2.9.50
- Fix handling of ino64 changes in head (Michal Meloun)
- Don't return 0 if pending signal is detected before call to real select().
This causes cmake timeout failures - a select() with NULL as
timeout argument returns (erroneously) 0. (Michal Meloun)
- Allow users to compile bsd-user dynamically (Michal Meloun)
Revision bump of all ports with USE_GL after consolidation of mesa-libs
Approved by: swills (mentor)
Differential Revision: https://reviews.freebsd.org/D10845
Mark some ports failing on power64. In cases where the error message
was a stub, provide a real one.
While here, pet portlint.
Approved by: portmgr (tier-2 blanket)
Reported by: swills
Disable FPU on 32 bit mips. This will cause some additional breakage in
pkg building on mips. Some ports errneously try and use FPU instructions
and will insta-crash when run on real hardware. This change will identify
those ports that have these types of instructions so they can be fixed.
- dnelson
Add handler for fdatasync(). Quiesce noise about missing handler.
- jkim
Bump qemu-sbruno to capture today's removal of signal blocking in
the bsd-user code. This update should allow normal operation with the
bugs that we all were familiar with!
PR: 214944215552
Update to qemu 2.8.50:
- we should be able to build devel/m4 again, even though the configure
script will segfault instead of hanging forever. Progress!
PR: 214944
QEMU requires pixman to build qemu-system-* targets regardless of
whether we are building for X or not. Add the dependency if
PR: 214668
Submitted by: mail+freebsd@gerritbeine.de
- Mark broken on 9.x: does not build:
multiboot.raw: option ROM does not begin with magic 55 aa
- Add missing files to plist
Approved by: portmgr blanket
Update qemu-sbruno/qemu-static-user to track upstream development.
Change the way qemu-user-static builds with relationship to glib20 (ian@)
Update a couple of patches for changes to include file locations.
Update qemu-sbruno/user-static to capture pull request:
- Allow utimensat() syscall on FreeBSD 10.3, where pkg(8) requires it.
Update qemu-sbruno Makefile to not build qemu-tools when building
qemu-user-static slave port. (ian@)
Capture upstream pull request from jkim@
https://github.com/seanbruno/qemu-bsd-user/pull/23
Limit sysctl(3) output for hw.availpages to 4GB.
- This output should be limited to 4GB on 32-bit targets to be consistent
with hw.physmem. Note this also limits sysconf(3) with _SC_PHYS_PAGES
because libc uses sysctlbyname("hw.availpages", ...) to get the value.
- Properly swap output for hw.physmem, etc. while I am in the neighborhood.
Submitted by: jkim@
Update qemu-sbruno/qemu-static-user:
Disable atomic macros which conflict with C++ QEMU's atomic header defines
a few macros which conflict with standard C++ function names, namely
atomic_fetch_{add,sub,and,or}. Disable these macros when compiling for C++.
PR: 209590
Submitted by: dim
- Update security/gnutls to 3.4.10.
- Rename the LIBDANE option DANE because that's the name of the protocol
supported by libgnutls-dane and gnutls-cli. Also clarify the option
description.
- Add an IDN option.
- libgnutls-openssl has been removed in 3.4. Some ports used this library
in their LIB_DEPENDS but no port actually required it.
- Some old API functions have been removed. Ports that used these have been
updated or patched to use the new API.
- Add a patch to print/cups to prevent overlinking of libgnutls.so.
- Bump PORTREVISION on dependent ports.
net-im/jabber: This port used the old API to give users fine grained
control over which crypto algorithms were used via a configuration file.
It's not immediately obvious how to port this to the new API so the port
always uses the defaults now.
www/hydra: Mark BROKEN. This uses more removed calls than the other ports,
is said to be alpha quality and not fully functional and has been abandoned
10 years ago.
PR: 207768
Exp-run by: antoine
Approved by: portmgr (antoine)
Attempt to unbreak stage (pointed out by amdmi3/junovitch)
- Add ivshmem-client/server to the pkg-plist of qemu-sbruno.
- Forceably nuke ivshmem-client/server during the build of qemu-user-static.
Bump PORTREVISION.
A couple of portlint nits for tabs/spaces and a proper WWW note in a
URL in the pkg-descr.
Install stripped enabled for ivshmem* and the palcode-clipper utility.
Drop patch for procctl() and commit it upstream.
Update qemu-sbruno and qemu-user-static.
Sync bsd-user do_obreak with linux-user (do_brk).
Merging to QEMU upstream provides fixes for the following CVEs:
CVE-2015-8345
CVE-2015-8567
CVE-2015-8568
CVE-2015-8613
CVE-2015-8619
CVE-2015-8701
libvxl upstream has been updated to 1.12 and has accepted a slightly
modified version that addresses the issue in the patch.
PR: 205813
Bump qemu-sbruno to capture merge request that sync's bsd-user mmap()
code to look/feel/behave like the linux-user mmap() code.
Submitted by: mikhael.urankar@gmail.com
Bump to 2.5.50.g20160103, catchup with latest bug fixes.
Fix dereference of wrong pointer arg in ipc/semctl syscall.
Fix return from mmap() to setEINVAL and MAP_FAILED when len is 0
PR: 203852200613
Submitted by: mikael.urankar@gmail.com