git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #36292 from xeji/xen-4-10

xen: add v 4.10

commit5a95fe293978b94feef230016321b53fd6a579a7 authorMichael Raskin <7c6f434c@mail.ru> dateWed 7 Mar 2018, 22:07 (9 years ago) parentfa051cd08894b4
6 files changed+278−5
nixos/modules/virtualisation/xen-dom0.nix+9−3 pkgs/applications/virtualization/xen/4.10.nix+176 pkgs/applications/virtualization/xen/generic.nix+2−2 pkgs/applications/virtualization/xen/packages.nix+46 pkgs/applications/virtualization/xen/xsa-patches.nix+40 pkgs/top-level/all-packages.nix+5
nixos/modules/virtualisation/xen-dom0.nix+9−3
@@ -241,6 +241,12 @@ in
241241 '';
242242 target = "default/xendomains";
243243 }
244+ ]
245+ ++ lib.optionals (builtins.compareVersions cfg.package.version "4.10" >= 0) [
246+ # in V 4.10 oxenstored requires /etc/xen/oxenstored.conf to start
247+ { source = "${cfg.package}/etc/xen/oxenstored.conf";
248+ target = "xen/oxenstored.conf";
249+ }
244250 ];
245251
246252 # Xen provides udev rules.
@@ -262,7 +268,7 @@ in
262268 mkdir -p /var/lib/xen # so we create them here unconditionally.
263269 grep -q control_d /proc/xen/capabilities
264270 '';
265− serviceConfig = if cfg.package.version < "4.8" then
271+ serviceConfig = if (builtins.compareVersions cfg.package.version "4.8" < 0) then
266272 { ExecStart = ''
267273 ${cfg.stored}${optionalString cfg.trace " -T /var/log/xen/xenstored-trace.log"} --no-fork
268274 '';
@@ -275,7 +281,7 @@ in
275281 NotifyAccess = "all";
276282 };
277283 postStart = ''
278− ${optionalString (cfg.package.version < "4.8") ''
284+ ${optionalString (builtins.compareVersions cfg.package.version "4.8" < 0) ''
279285 time=0
280286 timeout=30
281287 # Wait for xenstored to actually come up, timing out after 30 seconds
@@ -320,7 +326,7 @@ in
320326 serviceConfig = {
321327 ExecStart = ''
322328 ${cfg.package}/bin/xenconsoled\
323− ${optionalString ((cfg.package.version >= "4.8")) " -i"}\
329+ ${optionalString ((builtins.compareVersions cfg.package.version "4.8" >= 0)) " -i"}\
324330 ${optionalString cfg.trace " --log=all --log-dir=/var/log/xen"}
325331 '';
326332 };
pkgs/applications/virtualization/xen/4.10.nixnew file+176
@@ -0,0 +1,176 @@
1+{ stdenv, callPackage, fetchurl, fetchpatch, fetchgit
2+, withInternalQemu ? true
3+, withInternalTraditionalQemu ? true
4+, withInternalSeabios ? true
5+, withSeabios ? !withInternalSeabios, seabios ? null
6+, withInternalOVMF ? false # FIXME: tricky to build
7+, withOVMF ? false, OVMF
8+, withLibHVM ? true
9+
10+# qemu
11+, udev, pciutils, xorg, SDL, pixman, acl, glusterfs, spice-protocol, usbredir
12+, alsaLib, glib, python2
13+, ... } @ args:
14+
15+assert withInternalSeabios -> !withSeabios;
16+assert withInternalOVMF -> !withOVMF;
17+
18+with stdenv.lib;
19+
20+# Patching XEN? Check the XSAs at
21+# https://xenbits.xen.org/xsa/
22+# and try applying all the ones we don't have yet.
23+
24+let
25+ xsaPatch = { name , sha256 }: (fetchpatch {
26+ url = "https://xenbits.xen.org/xsa/xsa${name}.patch";
27+ inherit sha256;
28+ });
29+
30+ xsa = import ./xsa-patches.nix { inherit fetchpatch; };
31+
32+ qemuDeps = [
33+ udev pciutils xorg.libX11 SDL pixman acl glusterfs spice-protocol usbredir
34+ alsaLib glib python2
35+ ];
36+in
37+
38+callPackage (import ./generic.nix (rec {
39+ version = "4.10.0";
40+
41+ src = fetchurl {
42+ url = "https://downloads.xenproject.org/release/xen/${version}/xen-${version}.tar.gz";
43+ sha256 = "0i38ap5b5m1kix6xb0vn9ya1yab35adyc98bzfnbq4lb7w1afqh2";
44+ };
45+
46+ # Sources needed to build tools and firmwares.
47+ xenfiles = optionalAttrs withInternalQemu {
48+ "qemu-xen" = {
49+ src = fetchgit {
50+ url = https://xenbits.xen.org/git-http/qemu-xen.git;
51+ # rev = "refs/tags/qemu-xen-${version}";
52+ # use revision hash - reproducible but must be updated with each new version
53+ rev = "b79708a8ed1b3d18bee67baeaf33b3fa529493e2";
54+ sha256 = "1yxxad6nvlfmrbgyc8ix19qmrsn1rx4zpyiqnfi4x4kg94acwa5w";
55+ };
56+ buildInputs = qemuDeps;
57+ postPatch = ''
58+ # needed in build but /usr/bin/env is not available in sandbox
59+ substituteInPlace scripts/tracetool.py \
60+ --replace "/usr/bin/env python" "${python2}/bin/python"
61+ '';
62+ meta.description = "Xen's fork of upstream Qemu";
63+ };
64+ } // optionalAttrs withInternalTraditionalQemu {
65+ "qemu-xen-traditional" = {
66+ src = fetchgit {
67+ url = https://xenbits.xen.org/git-http/qemu-xen-traditional.git;
68+ # rev = "refs/tags/xen-${version}";
69+ # use revision hash - reproducible but must be updated with each new version
70+ rev = "c8ea0457495342c417c3dc033bba25148b279f60";
71+ sha256 = "0v5nl3c08kpjg57fb8l191h1y57ykp786kz6l525jgplif28vx13";
72+ };
73+ buildInputs = qemuDeps;
74+ patches = [
75+ ];
76+ postPatch = ''
77+ substituteInPlace xen-hooks.mak \
78+ --replace /usr/include/pci ${pciutils}/include/pci
79+ '';
80+ meta.description = "Xen's fork of upstream Qemu that uses old device model";
81+ };
82+ } // optionalAttrs withInternalSeabios {
83+ "firmware/seabios-dir-remote" = {
84+ src = fetchgit {
85+ url = https://xenbits.xen.org/git-http/seabios.git;
86+ rev = "f0cdc36d2f2424f6b40438f7ee7cc502c0eff4df";
87+ sha256 = "1wq5pjkjrfzqnq3wyr15mcn1l4c563m65gdyf8jm97kgb13pwwfm";
88+ };
89+ patches = [ ./0000-qemu-seabios-enable-ATA_DMA.patch ];
90+ meta.description = "Xen's fork of Seabios";
91+ };
92+ } // optionalAttrs withInternalOVMF {
93+ "firmware/ovmf-dir-remote" = {
94+ src = fetchgit {
95+ url = https://xenbits.xen.org/git-http/ovmf.git;
96+ rev = "173bf5c847e3ca8b42c11796ce048d8e2e916ff8";
97+ sha256 = "07zmdj90zjrzip74fvd4ss8n8njk6cim85s58mc6snxmqqv7gmcr";
98+ };
99+ meta.description = "Xen's fork of OVMF";
100+ };
101+ } // {
102+ # TODO: patch Xen to make this optional?
103+ "firmware/etherboot/ipxe.git" = {
104+ src = fetchgit {
105+ url = https://git.ipxe.org/ipxe.git;
106+ rev = "356f6c1b64d7a97746d1816cef8ca22bdd8d0b5d";
107+ sha256 = "15n400vm3id5r8y3k6lrp9ab2911a9vh9856f5gvphkazfnmns09";
108+ };
109+ meta.description = "Xen's fork of iPXE";
110+ };
111+ } // optionalAttrs withLibHVM {
112+ "xen-libhvm-dir-remote" = {
113+ src = fetchgit {
114+ name = "xen-libhvm";
115+ url = https://github.com/michalpalka/xen-libhvm;
116+ rev = "83065d36b36d6d527c2a4e0f5aaf0a09ee83122c";
117+ sha256 = "1jzv479wvgjkazprqdzcdjy199azmx2xl3pnxli39kc5mvjz3lzd";
118+ };
119+ buildPhase = ''
120+ make
121+ cd biospt
122+ cc -Wall -g -D_LINUX -Wstrict-prototypes biospt.c -o biospt -I../libhvm -L../libhvm -lxenhvm
123+ '';
124+ installPhase = ''
125+ make install
126+ cp biospt/biospt $out/bin/
127+ '';
128+ meta = {
129+ description = ''
130+ Helper library for reading ACPI and SMBIOS firmware values
131+ from the host system for use with the HVM guest firmware
132+ pass-through feature in Xen'';
133+ license = licenses.bsd2;
134+ };
135+ };
136+ };
137+
138+ configureFlags = []
139+ ++ optional (!withInternalQemu) "--with-system-qemu" # use qemu from PATH
140+ ++ optional (withInternalTraditionalQemu) "--enable-qemu-traditional"
141+ ++ optional (!withInternalTraditionalQemu) "--disable-qemu-traditional"
142+
143+ ++ optional (withSeabios) "--with-system-seabios=${seabios}"
144+ ++ optional (!withInternalSeabios && !withSeabios) "--disable-seabios"
145+
146+ ++ optional (withOVMF) "--with-system-ovmf=${OVMF.fd}/FV/OVMF.fd"
147+ ++ optional (withInternalOVMF) "--enable-ovmf";
148+
149+ patches = with xsa; flatten [
150+ XSA_252
151+ XSA_253
152+ XSA_255_1
153+ XSA_255_2
154+ XSA_256
155+ ];
156+
157+ # Fix build on Glibc 2.24.
158+ NIX_CFLAGS_COMPILE = "-Wno-error=deprecated-declarations";
159+
160+ postPatch = ''
161+ # Avoid a glibc >= 2.25 deprecation warnings that get fatal via -Werror.
162+ sed 1i'#include <sys/sysmacros.h>' \
163+ -i tools/blktap2/control/tap-ctl-allocate.c \
164+ -i tools/libxl/libxl_device.c
165+ # Makefile didn't include previous PKG_CONFIG_PATH so glib wasn't found
166+ substituteInPlace tools/Makefile \
167+ --replace 'PKG_CONFIG_PATH=$(XEN_ROOT)/tools/pkg-config' 'PKG_CONFIG_PATH=$(XEN_ROOT)/tools/pkg-config:$(PKG_CONFIG_PATH)'
168+ '';
169+
170+ passthru = {
171+ qemu-system-i386 = if withInternalQemu
172+ then "lib/xen/bin/qemu-system-i386"
173+ else throw "this xen has no qemu builtin";
174+ };
175+
176+})) args
pkgs/applications/virtualization/xen/generic.nix+2−2
@@ -154,12 +154,12 @@ stdenv.mkDerivation (rec {
154154 substituteInPlace tools/xenstat/Makefile \
155155 --replace /usr/include/curses.h ${ncurses.dev}/include/curses.h
156156
157− ${optionalString (config.version >= "4.8") ''
157+ ${optionalString (builtins.compareVersions config.version "4.8" >= 0) ''
158158 substituteInPlace tools/hotplug/Linux/launch-xenstore.in \
159159 --replace /bin/mkdir mkdir
160160 ''}
161161
162− ${optionalString (config.version < "4.6") ''
162+ ${optionalString (builtins.compareVersions config.version "4.6" < 0) ''
163163 # TODO: use this as a template and support our own if-up scripts instead?
164164 substituteInPlace tools/hotplug/Linux/xen-backend.rules.in \
165165 --replace "@XEN_SCRIPT_DIR@" $out/etc/xen/scripts
pkgs/applications/virtualization/xen/packages.nix+46
@@ -103,6 +103,52 @@ rec {
103103 };
104104 };
105105
106+ xen_4_10-vanilla = callPackage ./4.10.nix {
107+ meta = {
108+ description = "vanilla";
109+ longDescription = ''
110+ Vanilla version of Xen. Uses forks of Qemu and Seabios bundled
111+ with Xen. This gives vanilla experince, but wastes space and
112+ build time: typical NixOS setup that runs lots of VMs will
113+ build three different versions of Qemu when using this (two
114+ forks and upstream).
115+ '';
116+ };
117+ };
118+
119+ xen_4_10-slim = xen_4_10-vanilla.override {
120+ withInternalQemu = false;
121+ withInternalTraditionalQemu = true;
122+ withInternalSeabios = false;
123+ withSeabios = true;
124+
125+ meta = {
126+ description = "slim";
127+ longDescription = ''
128+ Slimmed-down version of Xen that reuses nixpkgs packages as
129+ much as possible. Different parts may get out of sync, but
130+ this builds faster and uses less space than vanilla. Use with
131+ `qemu_xen` from nixpkgs.
132+ '';
133+ };
134+ };
135+
136+ xen_4_10-light = xen_4_10-vanilla.override {
137+ withInternalQemu = false;
138+ withInternalTraditionalQemu = false;
139+ withInternalSeabios = false;
140+ withSeabios = true;
141+
142+ meta = {
143+ description = "light";
144+ longDescription = ''
145+ Slimmed-down version of Xen without `qemu-traditional` (you
146+ don't need it if you don't know what it is). Use with
147+ `qemu_xen-light` from nixpkgs.
148+ '';
149+ };
150+ };
151+
106152 xen-vanilla = xen_4_5-vanilla;
107153 xen-slim = xen_4_5-slim;
108154 xen-light = xen_4_5-light;
pkgs/applications/virtualization/xen/xsa-patches.nix+40
@@ -893,4 +893,44 @@ in rec {
893893 ];
894894
895895
896+ # 4.10
897+ XSA_252 = [
898+ (xsaPatch {
899+ name = "252";
900+ sha256 = "0v4sg20dnvnwrjh3x69gk81v2kmcql7g2s044vg3wcxhzvij1rrn";
901+ })
902+ ];
903+
904+ # 4.10
905+ XSA_253 = [
906+ (xsaPatch {
907+ name = "253";
908+ sha256 = "0445vzlzy3gd499xraqh5r4qjar6qr0y3813h22jy1n84nhxz27i";
909+ })
910+ ];
911+
912+ # 4.10
913+ XSA_255_1 = [
914+ (xsaPatch {
915+ name = "255-1";
916+ sha256 = "05g2f3ji1rrjlw3yw4nrns50pnmsib8ybrf64scr1817mj0q9myr";
917+ })
918+ ];
919+
920+ # 4.10
921+ XSA_255_2 = [
922+ (xsaPatch {
923+ name = "255-2";
924+ sha256 = "08wbngw5z0f9g8di59hww3hhi7j9z49bpc4xlwn5akfcwbgf0961";
925+ })
926+ ];
927+
928+ # 4.10
929+ XSA_256 = [
930+ (xsaPatch {
931+ name = "256";
932+ sha256 = "1hicwhbwj6k25px55f4ncx1c5xiihi8pfvsb3kv57k7kaicb7pza";
933+ })
934+ ];
935+
896936}
pkgs/top-level/all-packages.nix+5
@@ -13674,6 +13674,8 @@ with pkgs;
1367413674 qemu_xen-light = lowPrio (qemu.override { hostCpuOnly = true; xenSupport = true; xen = xen-light; });
1367513675 qemu_xen_4_8 = lowPrio (qemu.override { hostCpuOnly = true; xenSupport = true; xen = xen_4_8-slim; });
1367613676 qemu_xen_4_8-light = lowPrio (qemu.override { hostCpuOnly = true; xenSupport = true; xen = xen_4_8-light; });
13677+ qemu_xen_4_10 = lowPrio (qemu.override { hostCpuOnly = true; xenSupport = true; xen = xen_4_10-slim; });
13678+ qemu_xen_4_10-light = lowPrio (qemu.override { hostCpuOnly = true; xenSupport = true; xen = xen_4_10-light; });
1367713679
1367813680 qemu_test = lowPrio (qemu.override { hostCpuOnly = true; nixosTestRunner = true; });
1367913681
@@ -18315,6 +18317,9 @@ with pkgs;
1831518317 xen_4_8 = xenPackages.xen_4_8-vanilla;
1831618318 xen_4_8-slim = xenPackages.xen_4_8-slim;
1831718319 xen_4_8-light = xenPackages.xen_4_8-light;
18320+ xen_4_10 = xenPackages.xen_4_10-vanilla;
18321+ xen_4_10-slim = xenPackages.xen_4_10-slim;
18322+ xen_4_10-light = xenPackages.xen_4_10-light;
1831818323
1831918324 xkbset = callPackage ../tools/X11/xkbset { };
1832018325