Merge pull request #26492 from michalpalka/new-xen

xen_4_8: init at 4.8.1
This commit is contained in:
Joachim F 2017-06-30 20:27:04 +01:00 committed by GitHub
commit a8ba50db3e
5 changed files with 322 additions and 28 deletions

View File

@ -267,10 +267,20 @@ in
mkdir -p /var/lib/xen # so we create them here unconditionally. mkdir -p /var/lib/xen # so we create them here unconditionally.
grep -q control_d /proc/xen/capabilities grep -q control_d /proc/xen/capabilities
''; '';
serviceConfig.ExecStart = '' serviceConfig = if cfg.package.version < "4.8" then
{ ExecStart = ''
${cfg.stored}${optionalString cfg.trace " -T /var/log/xen/xenstored-trace.log"} --no-fork ${cfg.stored}${optionalString cfg.trace " -T /var/log/xen/xenstored-trace.log"} --no-fork
''; '';
} else {
ExecStart = ''
${cfg.package}/etc/xen/scripts/launch-xenstore
'';
Type = "notify";
RemainAfterExit = true;
NotifyAccess = "all";
};
postStart = '' postStart = ''
${optionalString (cfg.package.version < "4.8") ''
time=0 time=0
timeout=30 timeout=30
# Wait for xenstored to actually come up, timing out after 30 seconds # Wait for xenstored to actually come up, timing out after 30 seconds
@ -284,9 +294,9 @@ in
echo "Could not start Xenstore Daemon" echo "Could not start Xenstore Daemon"
exit 1 exit 1
fi fi
''}
${cfg.package}/bin/xenstore-write "/local/domain/0/name" "Domain-0" echo "executing xen-init-dom0"
${cfg.package}/bin/xenstore-write "/local/domain/0/domid" 0 ${cfg.package}/lib/xen/bin/xen-init-dom0
''; '';
}; };
@ -306,6 +316,7 @@ in
description = "Xen Console Daemon"; description = "Xen Console Daemon";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
after = [ "xen-store.service" ]; after = [ "xen-store.service" ];
requires = [ "xen-store.service" ];
preStart = '' preStart = ''
mkdir -p /var/run/xen mkdir -p /var/run/xen
${optionalString cfg.trace "mkdir -p /var/log/xen"} ${optionalString cfg.trace "mkdir -p /var/log/xen"}
@ -313,7 +324,9 @@ in
''; '';
serviceConfig = { serviceConfig = {
ExecStart = '' ExecStart = ''
${cfg.package}/bin/xenconsoled${optionalString cfg.trace " --log=all --log-dir=/var/log/xen"} ${cfg.package}/bin/xenconsoled\
${optionalString ((cfg.package.version >= "4.8")) " -i"}\
${optionalString cfg.trace " --log=all --log-dir=/var/log/xen"}
''; '';
}; };
}; };
@ -323,6 +336,7 @@ in
description = "Xen Qemu Daemon"; description = "Xen Qemu Daemon";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
after = [ "xen-console.service" ]; after = [ "xen-console.service" ];
requires = [ "xen-store.service" ];
serviceConfig.ExecStart = '' serviceConfig.ExecStart = ''
${cfg.qemu} -xen-attach -xen-domid 0 -name dom0 -M xenpv \ ${cfg.qemu} -xen-attach -xen-domid 0 -name dom0 -M xenpv \
-nographic -monitor /dev/null -serial /dev/null -parallel /dev/null -nographic -monitor /dev/null -serial /dev/null -parallel /dev/null
@ -333,7 +347,7 @@ in
systemd.services.xen-watchdog = { systemd.services.xen-watchdog = {
description = "Xen Watchdog Daemon"; description = "Xen Watchdog Daemon";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
after = [ "xen-qemu.service" ]; after = [ "xen-qemu.service" "xen-domains.service" ];
serviceConfig.ExecStart = "${cfg.package}/bin/xenwatchdogd 30 15"; serviceConfig.ExecStart = "${cfg.package}/bin/xenwatchdogd 30 15";
serviceConfig.Type = "forking"; serviceConfig.Type = "forking";
serviceConfig.RestartSec = "1"; serviceConfig.RestartSec = "1";
@ -426,6 +440,7 @@ in
description = "Xen domains - automatically starts, saves and restores Xen domains"; description = "Xen domains - automatically starts, saves and restores Xen domains";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
after = [ "xen-bridge.service" "xen-qemu.service" ]; after = [ "xen-bridge.service" "xen-qemu.service" ];
requires = [ "xen-bridge.service" "xen-qemu.service" ];
## To prevent a race between dhcpcd and xend's bridge setup script ## To prevent a race between dhcpcd and xend's bridge setup script
## (which renames eth* to peth* and recreates eth* as a virtual ## (which renames eth* to peth* and recreates eth* as a virtual
## device), start dhcpcd after xend. ## device), start dhcpcd after xend.

View File

@ -0,0 +1,217 @@
{ stdenv, callPackage, fetchurl, fetchpatch, fetchgit
, withInternalQemu ? true
, withInternalTraditionalQemu ? true
, withInternalSeabios ? true
, withSeabios ? !withInternalSeabios, seabios ? null
, withInternalOVMF ? false # FIXME: tricky to build
, withOVMF ? false, OVMF
, withLibHVM ? true
# qemu
, udev, pciutils, xorg, SDL, pixman, acl, glusterfs, spice_protocol, usbredir
, alsaLib
, ... } @ args:
assert withInternalSeabios -> !withSeabios;
assert withInternalOVMF -> !withOVMF;
with stdenv.lib;
# Patching XEN? Check the XSAs at
# https://xenbits.xen.org/xsa/
# and try applying all the ones we don't have yet.
let
xsaPatch = { name , sha256 }: (fetchpatch {
url = "https://xenbits.xen.org/xsa/xsa${name}.patch";
inherit sha256;
});
qemuDeps = [
udev pciutils xorg.libX11 SDL pixman acl glusterfs spice_protocol usbredir
alsaLib
];
in
callPackage (import ./generic.nix (rec {
version = "4.8.1";
src = fetchurl {
url = "http://bits.xensource.com/oss-xen/release/${version}/xen-${version}.tar.gz";
sha256 = "158kb1w61jmwxi3fc560s4269hhpxrin9xhm60ljj52njhxias8x";
};
# Sources needed to build tools and firmwares.
xenfiles = optionalAttrs withInternalQemu {
"qemu-xen" = {
src = fetchgit {
url = https://xenbits.xen.org/git-http/qemu-xen.git;
rev = "refs/tags/qemu-xen-${version}";
sha256 = "1v19pp86kcgwvsbkrdrn4rlaj02i4054avw8k70w1m0rnwgcsdbs";
};
buildInputs = qemuDeps;
patches = [
(xsaPatch {
name = "216-qemuu";
sha256 = "09gp980qdlfpfmxy0nk7ncyaa024jnrpzx9gpq2kah21xygy5ma1";
})
];
meta.description = "Xen's fork of upstream Qemu";
};
} // optionalAttrs withInternalTraditionalQemu {
"qemu-xen-traditional" = {
src = fetchgit {
url = https://xenbits.xen.org/git-http/qemu-xen-traditional.git;
rev = "refs/tags/xen-${version}";
sha256 = "0mryap5y53r09m7qc0b821f717ghwm654r8c3ik1w7adzxr0l5qk";
};
buildInputs = qemuDeps;
patches = [
];
postPatch = ''
substituteInPlace xen-hooks.mak \
--replace /usr/include/pci ${pciutils}/include/pci
'';
meta.description = "Xen's fork of upstream Qemu that uses old device model";
};
} // optionalAttrs withInternalSeabios {
"firmware/seabios-dir-remote" = {
src = fetchgit {
url = https://xenbits.xen.org/git-http/seabios.git;
rev = "f0cdc36d2f2424f6b40438f7ee7cc502c0eff4df";
sha256 = "1wq5pjkjrfzqnq3wyr15mcn1l4c563m65gdyf8jm97kgb13pwwfm";
};
patches = [ ./0000-qemu-seabios-enable-ATA_DMA.patch ];
meta.description = "Xen's fork of Seabios";
};
} // optionalAttrs withInternalOVMF {
"firmware/ovmf-dir-remote" = {
src = fetchgit {
url = https://xenbits.xen.org/git-http/ovmf.git;
rev = "173bf5c847e3ca8b42c11796ce048d8e2e916ff8";
sha256 = "07zmdj90zjrzip74fvd4ss8n8njk6cim85s58mc6snxmqqv7gmcr";
};
meta.description = "Xen's fork of OVMF";
};
} // {
# TODO: patch Xen to make this optional?
"firmware/etherboot/ipxe.git" = {
src = fetchgit {
url = https://git.ipxe.org/ipxe.git;
rev = "356f6c1b64d7a97746d1816cef8ca22bdd8d0b5d";
sha256 = "15n400vm3id5r8y3k6lrp9ab2911a9vh9856f5gvphkazfnmns09";
};
meta.description = "Xen's fork of iPXE";
};
} // optionalAttrs withLibHVM {
"xen-libhvm-dir-remote" = {
src = fetchgit {
name = "xen-libhvm";
url = https://github.com/michalpalka/xen-libhvm;
rev = "83065d36b36d6d527c2a4e0f5aaf0a09ee83122c";
sha256 = "1jzv479wvgjkazprqdzcdjy199azmx2xl3pnxli39kc5mvjz3lzd";
};
buildPhase = ''
make
cd biospt
cc -Wall -g -D_LINUX -Wstrict-prototypes biospt.c -o biospt -I../libhvm -L../libhvm -lxenhvm
'';
installPhase = ''
make install
cp biospt/biospt $out/bin/
'';
meta = {
description = ''
Helper library for reading ACPI and SMBIOS firmware values
from the host system for use with the HVM guest firmware
pass-through feature in Xen'';
license = licenses.bsd2;
};
};
};
configureFlags = []
++ optional (!withInternalQemu) "--with-system-qemu" # use qemu from PATH
++ optional (withInternalTraditionalQemu) "--enable-qemu-traditional"
++ optional (!withInternalTraditionalQemu) "--disable-qemu-traditional"
++ optional (withSeabios) "--with-system-seabios=${seabios}"
++ optional (!withInternalSeabios && !withSeabios) "--disable-seabios"
++ optional (withOVMF) "--with-system-ovmf=${OVMF.fd}/FV/OVMF.fd"
++ optional (withInternalOVMF) "--enable-ovmf";
patches =
[ (xsaPatch {
name = "213-4.8";
sha256 = "0ia3zr6r3bqy2h48fdy7p0iz423lniy3i0qkdvzgv5a8m80darr2";
})
(xsaPatch {
name = "214";
sha256 = "0qapzx63z0yl84phnpnglpkxp6b9sy1y7cilhwjhxyigpfnm2rrk";
})
(xsaPatch {
name = "217";
sha256 = "1khs5ilif14dzcm7lmikjzkwsrfzlmir1rgrgzkc411gf18ylzmj";
})
(xsaPatch {
name = "218-4.8/0001-gnttab-fix-unmap-pin-accounting-race";
sha256 = "0r363frai239r2wmwxi48kcr50gbk5l64nja0h9lppi3z2y3dkdd";
})
(xsaPatch {
name = "218-4.8/0002-gnttab-Avoid-potential-double-put-of-maptrack-entry";
sha256 = "07wm06i7frv7bsaykakx3g9h0hfqv96zcadvwf6wv194dggq1plc";
})
(xsaPatch {
name = "218-4.8/0003-gnttab-correct-maptrack-table-accesses";
sha256 = "0ad0irc3p4dmla8sp3frxbh2qciji1dipkslh0xqvy2hyf9p80y9";
})
(xsaPatch {
name = "219-4.8";
sha256 = "16q7kiamy86x8qdvls74wmq5j72kgzgdilryig4q1b21mp0ij1jq";
})
(xsaPatch {
name = "220-4.8";
sha256 = "0214qyqx7qap5y1pdi9fm0vz4y2fbyg71gaq36fisknj35dv2mh5";
})
(xsaPatch {
name = "221";
sha256 = "1mcr1nqgxyjrkywdg7qhlfwgz7vj2if1dhic425vgd41p9cdgl26";
})
(xsaPatch {
name = "222-1";
sha256 = "0x02x4kqwfw255638fh2zcxwig1dy6kadlmqim1jgnjgmrvvqas2";
})
(xsaPatch {
name = "222-2-4.8";
sha256 = "1xhyp6q3c5l8djh965g1i8201m2wvhms8k886h4sn30hks38giin";
})
(xsaPatch {
name = "224-4.8/0001-gnttab-Fix-handling-of-dev_bus_addr-during-unmap";
sha256 = "1k326yan5811qzyvpdfkv801a19nyd09nsqayi8gyh58xx9c21m4";
})
(xsaPatch {
name = "224-4.8/0002-gnttab-never-create-host-mapping-unless-asked-to";
sha256 = "06nj1x59bbx9hrj26xmvbw8z805lfqhld9hm0ld0fs6dmcpqzcck";
})
(xsaPatch {
name = "224-4.8/0003-gnttab-correct-logic-to-get-page-references-during-m";
sha256 = "0kmag6fdsskgplcvzqp341yfi6pgc14wvjj58bp7ydb9hdk53qx2";
})
(xsaPatch {
name = "224-4.8/0004-gnttab-__gnttab_unmap_common_complete-is-all-or-noth";
sha256 = "1ww80pi7jr4gjpymkcw8qxmr5as18b2asdqv35527nqprylsff9f";
})
];
# Fix build on Glibc 2.24.
NIX_CFLAGS_COMPILE = "-Wno-error=deprecated-declarations";
postPatch = ''
# Avoid a glibc >= 2.25 deprecation warnings that get fatal via -Werror.
sed 1i'#include <sys/sysmacros.h>' \
-i tools/blktap2/control/tap-ctl-allocate.c \
-i tools/libxl/libxl_device.c
'';
})) args

View File

@ -14,7 +14,7 @@ config:
# Scripts # Scripts
, coreutils, gawk, gnused, gnugrep, diffutils, multipath-tools , coreutils, gawk, gnused, gnugrep, diffutils, multipath-tools
, iproute, inetutils, iptables, bridge-utils, openvswitch, nbd, drbd , iproute, inetutils, iptables, bridge-utils, openvswitch, nbd, drbd
, lvm2, utillinux, procps , lvm2, utillinux, procps, systemd
# Documentation # Documentation
# python2Packages.markdown # python2Packages.markdown
@ -61,7 +61,7 @@ stdenv.mkDerivation (rec {
libiconv libuuid ncurses openssl perl python2Packages.python xz yajl zlib libiconv libuuid ncurses openssl perl python2Packages.python xz yajl zlib
# oxenstored # oxenstored
ocamlPackages.findlib ocamlPackages.ocaml ocamlPackages.findlib ocamlPackages.ocaml systemd
# Python fixes # Python fixes
python2Packages.wrapPython python2Packages.wrapPython
@ -153,12 +153,19 @@ stdenv.mkDerivation (rec {
substituteInPlace tools/xenstat/Makefile \ substituteInPlace tools/xenstat/Makefile \
--replace /usr/include/curses.h ${ncurses.dev}/include/curses.h --replace /usr/include/curses.h ${ncurses.dev}/include/curses.h
${optionalString (config.version >= "4.8") ''
substituteInPlace tools/hotplug/Linux/launch-xenstore.in \
--replace /bin/mkdir mkdir
''}
${optionalString (config.version < "4.6") ''
# TODO: use this as a template and support our own if-up scripts instead? # TODO: use this as a template and support our own if-up scripts instead?
substituteInPlace tools/hotplug/Linux/xen-backend.rules.in \ substituteInPlace tools/hotplug/Linux/xen-backend.rules.in \
--replace "@XEN_SCRIPT_DIR@" $out/etc/xen/scripts --replace "@XEN_SCRIPT_DIR@" $out/etc/xen/scripts
# blktap is not provided by xen, but by xapi # blktap is not provided by xen, but by xapi
sed -i '/blktap/d' tools/hotplug/Linux/xen-backend.rules.in sed -i '/blktap/d' tools/hotplug/Linux/xen-backend.rules.in
''}
${withTools "patches" (name: x: '' ${withTools "patches" (name: x: ''
${concatMapStringsSep "\n" (p: '' ${concatMapStringsSep "\n" (p: ''
@ -191,7 +198,7 @@ stdenv.mkDerivation (rec {
''; '';
installPhase = '' installPhase = ''
mkdir -p $out $out/share mkdir -p $out $out/share $out/share/man
cp -prvd dist/install/nix/store/*/* $out/ cp -prvd dist/install/nix/store/*/* $out/
cp -prvd dist/install/boot $out/boot cp -prvd dist/install/boot $out/boot
cp -prvd dist/install/etc $out cp -prvd dist/install/etc $out

View File

@ -57,6 +57,56 @@ rec {
}; };
}; };
xen_4_8-vanilla = callPackage ./4.8.nix {
# At the very least included seabios and etherboot need gcc49,
# so we have to build all of it with gcc49.
stdenv = overrideCC stdenv gcc49;
meta = {
description = "vanilla";
longDescription = ''
Vanilla version of Xen. Uses forks of Qemu and Seabios bundled
with Xen. This gives vanilla experince, but wastes space and
build time: typical NixOS setup that runs lots of VMs will
build three different versions of Qemu when using this (two
forks and upstream).
'';
};
};
xen_4_8-slim = xen_4_8-vanilla.override {
withInternalQemu = false;
withInternalTraditionalQemu = true;
withInternalSeabios = false;
withSeabios = true;
meta = {
description = "slim";
longDescription = ''
Slimmed-down version of Xen that reuses nixpkgs packages as
much as possible. Different parts may get out of sync, but
this builds faster and uses less space than vanilla. Use with
`qemu_xen` from nixpkgs.
'';
};
};
xen_4_8-light = xen_4_8-vanilla.override {
withInternalQemu = false;
withInternalTraditionalQemu = false;
withInternalSeabios = false;
withSeabios = true;
meta = {
description = "light";
longDescription = ''
Slimmed-down version of Xen without `qemu-traditional` (you
don't need it if you don't know what it is). Use with
`qemu_xen-light` from nixpkgs.
'';
};
};
xen-vanilla = xen_4_5-vanilla; xen-vanilla = xen_4_5-vanilla;
xen-slim = xen_4_5-slim; xen-slim = xen_4_5-slim;
xen-light = xen_4_5-light; xen-light = xen_4_5-light;

View File

@ -12383,6 +12383,8 @@ with pkgs;
# Building with `xen` instead of `xen-slim` is possible, but makes no sense. # Building with `xen` instead of `xen-slim` is possible, but makes no sense.
qemu_xen = lowPrio (qemu.override { x86Only = true; xenSupport = true; xen = xen-slim; }); qemu_xen = lowPrio (qemu.override { x86Only = true; xenSupport = true; xen = xen-slim; });
qemu_xen-light = lowPrio (qemu.override { x86Only = true; xenSupport = true; xen = xen-light; }); qemu_xen-light = lowPrio (qemu.override { x86Only = true; xenSupport = true; xen = xen-light; });
qemu_xen_4_8 = lowPrio (qemu.override { x86Only = true; xenSupport = true; xen = xen_4_8-slim; });
qemu_xen_4_8-light = lowPrio (qemu.override { x86Only = true; xenSupport = true; xen = xen_4_8-light; });
qemu_test = lowPrio (qemu.override { x86Only = true; nixosTestRunner = true; }); qemu_test = lowPrio (qemu.override { x86Only = true; nixosTestRunner = true; });
@ -16676,6 +16678,9 @@ with pkgs;
xen = xenPackages.xen_4_5-vanilla; xen = xenPackages.xen_4_5-vanilla;
xen-slim = xenPackages.xen_4_5-slim; xen-slim = xenPackages.xen_4_5-slim;
xen-light = xenPackages.xen_4_5-light; xen-light = xenPackages.xen_4_5-light;
xen_4_8 = xenPackages.xen_4_8-vanilla;
xen_4_8-slim = xenPackages.xen_4_8-slim;
xen_4_8-light = xenPackages.xen_4_8-light;
xkbset = callPackage ../tools/X11/xkbset { }; xkbset = callPackage ../tools/X11/xkbset { };