2016-11-14 16:35:11 +01:00
|
|
|
|
{ stdenv, fetchurl, fetchpatch, python2, zlib, pkgconfig, glib
|
2017-01-25 15:33:23 +01:00
|
|
|
|
, ncurses, perl, pixman, vde2, alsaLib, texinfo, flex
|
2016-11-23 13:01:32 +01:00
|
|
|
|
, bison, lzo, snappy, libaio, gnutls, nettle, curl
|
2015-06-01 20:55:53 +02:00
|
|
|
|
, makeWrapper
|
2016-02-29 01:22:06 +01:00
|
|
|
|
, attr, libcap, libcap_ng
|
|
|
|
|
, CoreServices, Cocoa, rez, setfile
|
|
|
|
|
, numaSupport ? stdenv.isLinux, numactl
|
|
|
|
|
, seccompSupport ? stdenv.isLinux, libseccomp
|
|
|
|
|
, pulseSupport ? !stdenv.isDarwin, libpulseaudio
|
|
|
|
|
, sdlSupport ? !stdenv.isDarwin, SDL
|
2015-06-01 20:55:53 +02:00
|
|
|
|
, vncSupport ? true, libjpeg, libpng
|
2016-09-05 20:37:03 +02:00
|
|
|
|
, spiceSupport ? !stdenv.isDarwin, spice, spice_protocol
|
|
|
|
|
, usbredirSupport ? spiceSupport, usbredir
|
2016-11-02 17:06:48 +01:00
|
|
|
|
, xenSupport ? false, xen
|
2015-06-01 20:55:53 +02:00
|
|
|
|
, x86Only ? false
|
2016-11-17 17:06:17 +01:00
|
|
|
|
, nixosTestRunner ? false
|
2013-07-04 17:44:44 +02:00
|
|
|
|
}:
|
2013-02-08 02:44:02 +01:00
|
|
|
|
|
2014-08-28 20:21:23 +02:00
|
|
|
|
with stdenv.lib;
|
|
|
|
|
let
|
2017-04-02 02:18:52 +02:00
|
|
|
|
version = "2.8.1";
|
2015-06-01 20:55:53 +02:00
|
|
|
|
audio = optionalString (hasSuffix "linux" stdenv.system) "alsa,"
|
|
|
|
|
+ optionalString pulseSupport "pa,"
|
|
|
|
|
+ optionalString sdlSupport "sdl,";
|
2014-08-28 20:21:23 +02:00
|
|
|
|
in
|
2013-07-31 14:50:42 +02:00
|
|
|
|
|
2013-02-08 02:44:02 +01:00
|
|
|
|
stdenv.mkDerivation rec {
|
2017-01-25 15:33:23 +01:00
|
|
|
|
name = "qemu-"
|
2016-11-02 17:06:48 +01:00
|
|
|
|
+ stdenv.lib.optionalString xenSupport "xen-"
|
2016-12-15 13:40:33 +01:00
|
|
|
|
+ stdenv.lib.optionalString x86Only "x86-only-"
|
|
|
|
|
+ stdenv.lib.optionalString nixosTestRunner "for-vm-tests-"
|
|
|
|
|
+ version;
|
2013-02-08 02:44:02 +01:00
|
|
|
|
|
|
|
|
|
src = fetchurl {
|
2015-09-17 12:44:17 +02:00
|
|
|
|
url = "http://wiki.qemu.org/download/qemu-${version}.tar.bz2";
|
2017-04-02 02:18:52 +02:00
|
|
|
|
sha256 = "1kdv8aa800rbsz9qnm4saw79vr052p83by21ryah68ics9z4r3h1";
|
2013-02-08 02:44:02 +01:00
|
|
|
|
};
|
|
|
|
|
|
2015-06-01 20:55:53 +02:00
|
|
|
|
buildInputs =
|
2016-11-14 16:35:11 +01:00
|
|
|
|
[ python2 zlib pkgconfig glib ncurses perl pixman
|
2017-01-25 15:33:23 +01:00
|
|
|
|
vde2 texinfo flex bison makeWrapper lzo snappy
|
2016-11-23 13:01:32 +01:00
|
|
|
|
gnutls nettle curl
|
2015-06-01 20:55:53 +02:00
|
|
|
|
]
|
2016-02-29 01:22:06 +01:00
|
|
|
|
++ optionals stdenv.isDarwin [ CoreServices Cocoa rez setfile ]
|
|
|
|
|
++ optionals seccompSupport [ libseccomp ]
|
|
|
|
|
++ optionals numaSupport [ numactl ]
|
2015-06-01 20:55:53 +02:00
|
|
|
|
++ optionals pulseSupport [ libpulseaudio ]
|
|
|
|
|
++ optionals sdlSupport [ SDL ]
|
|
|
|
|
++ optionals vncSupport [ libjpeg libpng ]
|
2016-09-05 20:37:03 +02:00
|
|
|
|
++ optionals spiceSupport [ spice_protocol spice ]
|
|
|
|
|
++ optionals usbredirSupport [ usbredir ]
|
2016-11-02 17:06:48 +01:00
|
|
|
|
++ optionals stdenv.isLinux [ alsaLib libaio libcap_ng libcap attr ]
|
|
|
|
|
++ optionals xenSupport [ xen ];
|
2013-02-08 02:44:02 +01:00
|
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
2017-03-11 08:04:43 +01:00
|
|
|
|
patches = let
|
|
|
|
|
upstreamPatch = name: commit: sha256: fetchurl {
|
|
|
|
|
name = "${name}.patch";
|
|
|
|
|
url = "http://git.qemu-project.org/?p=qemu.git;a=patch;h=${commit}";
|
|
|
|
|
inherit sha256;
|
|
|
|
|
};
|
|
|
|
|
in [
|
2016-08-31 13:25:47 +02:00
|
|
|
|
./no-etc-install.patch
|
2017-02-22 09:06:49 +01:00
|
|
|
|
|
2017-03-11 08:04:43 +01:00
|
|
|
|
# bugfixes
|
2017-04-02 02:18:52 +02:00
|
|
|
|
# xhci: fix event queue IRQ handling
|
2017-03-11 08:04:43 +01:00
|
|
|
|
(upstreamPatch "qemu-fix-win7-xhci" "7da76e12cc5cc902dda4c168d8d608fd4e61cbc5"
|
|
|
|
|
"0m1ggbxziy7vqz9007ypzg23cni8cc4db36wlnhxz0kdpq70c6x0")
|
|
|
|
|
|
2017-04-02 02:18:52 +02:00
|
|
|
|
# xhci: only free completed transfers
|
2017-03-11 08:04:43 +01:00
|
|
|
|
(upstreamPatch "qemu-xhci-free-completed-transfers" "f94d18d6c6df388fde196d3ab252f57e33843a8b"
|
|
|
|
|
"0lk19qss6ky7cqnvis54742cr2z0vl8c64chhch0kp6n83hray9x")
|
|
|
|
|
|
|
|
|
|
# security fixes from upstream
|
2017-04-02 02:18:52 +02:00
|
|
|
|
# net: imx: limit buffer descriptor count
|
2017-03-11 08:04:43 +01:00
|
|
|
|
(upstreamPatch "CVE-2016-7907" "81f17e0d435c3db3a3e67e0d32ebf9c98973211f"
|
|
|
|
|
"0dzghbm3jmnyw34kd40a6akrr1cpizd9hdzqmhlc2ljab7pr1rcb")
|
2017-02-22 09:06:49 +01:00
|
|
|
|
|
2017-04-02 02:18:52 +02:00
|
|
|
|
# watchdog: 6300esb: add exit function
|
2017-03-11 08:04:43 +01:00
|
|
|
|
(upstreamPatch "CVE-2016-10155" "eb7a20a3616085d46aa6b4b4224e15587ec67e6e"
|
|
|
|
|
"1xk00fyls0hdza11dyfrnzcn6gibmmcrwy7sxgp6iizp6wgzi3vw")
|
|
|
|
|
|
2017-04-02 02:18:52 +02:00
|
|
|
|
# audio: ac97: add exit function
|
2017-03-11 08:04:43 +01:00
|
|
|
|
(upstreamPatch "CVE-2017-5525" "12351a91da97b414eec8cdb09f1d9f41e535a401"
|
|
|
|
|
"190b4aqr35p4lb3rjarknfi1ip1c9zizliqp1dd6frx4364y5yp2")
|
|
|
|
|
|
2017-04-02 02:18:52 +02:00
|
|
|
|
# audio: es1370: add exit function
|
2017-03-11 08:04:43 +01:00
|
|
|
|
(upstreamPatch "CVE-2017-5526" "069eb7b2b8fc47c7cb52e5a4af23ea98d939e3da"
|
|
|
|
|
"05xgzd3zldk3x2vqpjag9z5ilhdkpkyh633fb5kvnz8scns6v86f")
|
|
|
|
|
|
2017-04-02 02:18:52 +02:00
|
|
|
|
# serial: fix memory leak in serial exit
|
2017-03-11 08:04:43 +01:00
|
|
|
|
(upstreamPatch "CVE-2017-5579" "8409dc884a201bf74b30a9d232b6bbdd00cb7e2b"
|
|
|
|
|
"0lbcyhif1kdcy8my0bv8aqr2f421kmljcch3plrjzj9pgcm4sv83")
|
|
|
|
|
|
2017-04-02 02:18:52 +02:00
|
|
|
|
# megasas: fix guest-triggered memory leak
|
2017-03-11 08:04:43 +01:00
|
|
|
|
(upstreamPatch "CVE-2017-5856" "765a707000e838c30b18d712fe6cb3dd8e0435f3"
|
|
|
|
|
"03pjkn8l8rp9ip5h5rm1dp0nrwd43nmgpwamz4z1vy3rli1z3yjw")
|
|
|
|
|
|
2017-04-02 02:18:52 +02:00
|
|
|
|
# virtio-gpu: fix resource leak in virgl_cmd_resource_unref
|
2017-03-11 08:04:43 +01:00
|
|
|
|
(upstreamPatch "CVE-2017-5857" "5e8e3c4c75c199aa1017db816fca02be2a9f8798"
|
|
|
|
|
"1kz14rmxf049zl5m27apzpbvy8dk0g47n9gnwy0nm70g65rl1dh8")
|
|
|
|
|
|
2017-04-02 02:18:52 +02:00
|
|
|
|
# usb: ccid: check ccid apdu length
|
2017-03-11 08:04:43 +01:00
|
|
|
|
(upstreamPatch "CVE-2017-5898" "c7dfbf322595ded4e70b626bf83158a9f3807c6a"
|
|
|
|
|
"1y2j0qw04s8fl0cs8i619y08kj75lxn3c0y19g710fzpk3rq8dvn")
|
|
|
|
|
|
2017-04-02 02:18:52 +02:00
|
|
|
|
# xhci: apply limits to loops
|
2017-03-11 08:04:43 +01:00
|
|
|
|
(upstreamPatch "CVE-2017-5973" "f89b60f6e5fee3923bedf80e82b4e5efc1bb156b"
|
|
|
|
|
"06niyighjxb4p5z2as3mqfmrwrzn4sq47j7raipbq9gnda7x9sw6")
|
|
|
|
|
|
2017-04-02 02:18:52 +02:00
|
|
|
|
# sd: sdhci: check transfer mode register in multi block transfer
|
2017-03-11 08:04:43 +01:00
|
|
|
|
(upstreamPatch "CVE-2017-5987" "6e86d90352adf6cb08295255220295cf23c4286e"
|
|
|
|
|
"09yfxf93cisx8rhm0h48ib1ibwfs420k5pqpz8dnz33nci9567jm")
|
2017-02-22 09:06:49 +01:00
|
|
|
|
|
2017-03-11 14:59:26 +01:00
|
|
|
|
] ++ optional nixosTestRunner ./force-uid0-on-9p.patch;
|
2017-02-22 09:06:49 +01:00
|
|
|
|
|
2016-09-25 21:40:47 +02:00
|
|
|
|
hardeningDisable = [ "stackprotector" ];
|
2015-06-01 20:55:53 +02:00
|
|
|
|
|
|
|
|
|
configureFlags =
|
2016-02-29 01:22:06 +01:00
|
|
|
|
[ "--smbd=smbd" # use `smbd' from $PATH
|
2015-06-01 20:55:53 +02:00
|
|
|
|
"--audio-drv-list=${audio}"
|
|
|
|
|
"--sysconfdir=/etc"
|
|
|
|
|
"--localstatedir=/var"
|
|
|
|
|
]
|
2016-02-29 01:22:06 +01:00
|
|
|
|
++ optional numaSupport "--enable-numa"
|
|
|
|
|
++ optional seccompSupport "--enable-seccomp"
|
2015-06-01 20:55:53 +02:00
|
|
|
|
++ optional spiceSupport "--enable-spice"
|
2016-09-05 20:37:03 +02:00
|
|
|
|
++ optional usbredirSupport "--enable-usb-redir"
|
2015-06-01 20:55:53 +02:00
|
|
|
|
++ optional x86Only "--target-list=i386-softmmu,x86_64-softmmu"
|
2016-02-29 01:22:06 +01:00
|
|
|
|
++ optional stdenv.isDarwin "--enable-cocoa"
|
2016-11-02 17:06:48 +01:00
|
|
|
|
++ optional stdenv.isLinux "--enable-linux-aio"
|
|
|
|
|
++ optional xenSupport "--enable-xen";
|
2015-06-01 20:55:53 +02:00
|
|
|
|
|
2016-04-08 01:45:53 +02:00
|
|
|
|
postFixup =
|
|
|
|
|
''
|
|
|
|
|
for exe in $out/bin/qemu-system-* ; do
|
|
|
|
|
paxmark m $exe
|
|
|
|
|
done
|
|
|
|
|
'';
|
|
|
|
|
|
2015-06-01 20:55:53 +02:00
|
|
|
|
postInstall =
|
|
|
|
|
''
|
|
|
|
|
# Add a ‘qemu-kvm’ wrapper for compatibility/convenience.
|
|
|
|
|
p="$out/bin/qemu-system-${if stdenv.system == "x86_64-linux" then "x86_64" else "i386"}"
|
|
|
|
|
if [ -e "$p" ]; then
|
|
|
|
|
makeWrapper "$p" $out/bin/qemu-kvm --add-flags "\$([ -e /dev/kvm ] && echo -enable-kvm)"
|
|
|
|
|
fi
|
|
|
|
|
'';
|
2013-07-31 14:31:04 +02:00
|
|
|
|
|
2014-02-20 21:02:55 +01:00
|
|
|
|
meta = with stdenv.lib; {
|
2013-07-04 16:52:43 +02:00
|
|
|
|
homepage = http://www.qemu.org/;
|
|
|
|
|
description = "A generic and open source machine emulator and virtualizer";
|
2014-02-20 21:02:55 +01:00
|
|
|
|
license = licenses.gpl2Plus;
|
2015-07-01 14:11:05 +02:00
|
|
|
|
maintainers = with maintainers; [ viric eelco ];
|
2016-02-29 01:22:06 +01:00
|
|
|
|
platforms = platforms.linux ++ platforms.darwin;
|
2013-02-08 02:44:02 +01:00
|
|
|
|
};
|
|
|
|
|
}
|