Update: add new Xen versions + update NixOS Xen modules

Versions of XEN:
- Xen 4.5
- Xen 4.5 + XenServer patches
- Xen 4.4.1
wip/yesman
Thomas Strobel 9 years ago
parent 7cc7e9b64a
commit 3d4fbb874c
  1. 2
      nixos/modules/module-list.nix
  2. 259
      nixos/modules/virtualisation/xen-dom0.nix
  3. 5
      nixos/modules/virtualisation/xen-domU.nix
  4. 46
      pkgs/applications/virtualization/xen/4.4.1.nix
  5. 58
      pkgs/applications/virtualization/xen/4.5.0.nix
  6. 87
      pkgs/applications/virtualization/xen/generic.nix
  7. 7
      pkgs/top-level/all-packages.nix

@ -432,5 +432,5 @@
./virtualisation/openvswitch.nix
./virtualisation/parallels-guest.nix
./virtualisation/virtualbox-guest.nix
#./virtualisation/xen-dom0.nix
./virtualisation/xen-dom0.nix
]

@ -5,18 +5,8 @@
with lib;
let
cfg = config.virtualisation.xen;
xen = pkgs.xen;
xendConfig = pkgs.writeText "xend-config.sxp"
''
(loglevel DEBUG)
(network-script network-bridge)
(vif-script vif-bridge)
'';
in
{
@ -58,23 +48,60 @@ in
'';
};
virtualisation.xen.bridge =
mkOption {
default = "xenbr0";
description =
''
Create a bridge for the Xen domUs to connect to.
'';
};
virtualisation.xen.stored =
mkOption {
default = "${pkgs.xen}/bin/oxenstored";
description =
''
Xen Store daemon to use.
'';
};
virtualisation.xen.trace =
mkOption {
default = false;
description =
''
Enable Xen tracing.
'';
};
};
###### implementation
config = mkIf cfg.enable {
assertions = [ {
assertion = pkgs.stdenv.isx86_64;
message = "Xen currently not supported on ${pkgs.stdenv.system}";
} {
assertion = config.boot.loader.grub.enable && (config.boot.loader.grub.efiSupport == false);
message = "Xen currently does not support EFI boot";
} ];
environment.systemPackages = [ xen ];
# Domain 0 requires a pvops-enabled kernel.
boot.kernelPackages = pkgs.linuxPackages_3_2_xen;
# Make sure Domain 0 gets the required configuration
#boot.kernelPackages = pkgs.boot.kernelPackages.override { features={xen_dom0=true;}; };
boot.kernelModules =
[ "xen_evtchn" "xen_gntdev" "xen_blkback" "xen_netback" "xen_pciback"
"blktap" "tun"
[ "xen-evtchn" "xen-gntdev" "xen-gntalloc" "xen-blkback" "xen-netback"
"xen-pciback" "evtchn" "gntdev" "netbk" "blkbk" "xen-scsibk"
"usbbk" "pciback" "xen-acpi-processor" "blktap2" "tun" "netxen_nic"
"xen_wdt" "xen-acpi-processor" "xen-privcmd" "xen-scsiback"
"xenfs"
];
# The radeonfb kernel module causes the screen to go black as soon
# as it's loaded, so don't load it.
boot.blacklistedKernelModules = [ "radeonfb" ];
@ -87,8 +114,8 @@ in
options loop max_loop=64
'';
virtualisation.xen.bootParams =
[ "loglvl=all" "guest_loglvl=all" ] ++
virtualisation.xen.bootParams = [] ++
optionals cfg.trace [ "loglvl=all" "guest_loglvl=all" ] ++
optional (cfg.domain0MemorySize != 0) "dom0_mem=${toString cfg.domain0MemorySize}M";
system.extraSystemBuilderCmds =
@ -101,71 +128,36 @@ in
system.activationScripts.xen =
''
if [ -d /proc/xen ]; then
${pkgs.sysvtools}/bin/mountpoint -q /proc/xen || \
${pkgs.kmod}/bin/modprobe xenfs 2> /dev/null
${pkgs.utillinux}/bin/mountpoint -q /proc/xen || \
${pkgs.utillinux}/bin/mount -t xenfs none /proc/xen
fi
'';
jobs.xend =
{ description = "Xen Control Daemon";
startOn = "stopped udevtrigger";
path =
[ pkgs.bridge-utils pkgs.gawk pkgs.iproute pkgs.nettools
pkgs.utillinux pkgs.bash xen pkgs.pciutils pkgs.procps
];
environment.XENCONSOLED_TRACE = "hv";
preStart =
''
mkdir -p /var/log/xen/console -m 0700
${xen}/sbin/xend start
# Wait until Xend is running.
for ((i = 0; i < 60; i++)); do echo "waiting for xend..."; ${xen}/sbin/xend status && break; done
${xen}/sbin/xend status || exit 1
'';
postStop = "${xen}/sbin/xend stop";
};
jobs.xendomains =
{ description = "Automatically starts, saves and restores Xen domains on startup/shutdown";
startOn = "started xend";
stopOn = "starting shutdown and stopping xend";
restartIfChanged = false;
path = [ pkgs.xen ];
environment.XENDOM_CONFIG = "${xen}/etc/sysconfig/xendomains";
preStart =
''
mkdir -p /var/lock/subsys -m 755
${xen}/etc/init.d/xendomains start
'';
postStop = "${xen}/etc/init.d/xendomains stop";
};
# Domain 0 requires a pvops-enabled kernel.
system.requiredKernelConfig = with config.lib.kernelConfig;
[ (isYes "XEN")
(isYes "X86_IO_APIC")
(isYes "ACPI")
(isYes "XEN_DOM0")
(isYes "PCI_XEN")
(isYes "XEN_DEV_EVTCHN")
(isYes "XENFS")
(isYes "XEN_COMPAT_XENFS")
(isYes "XEN_SYS_HYPERVISOR")
(isYes "XEN_GNTDEV")
(isYes "XEN_BACKEND")
(isModule "XEN_NETDEV_BACKEND")
(isModule "XEN_BLKDEV_BACKEND")
(isModule "XEN_PCIDEV_BACKEND")
(isYes "XEN_BALLOON")
(isYes "XEN_SCRUB_PAGES")
];
# To prevent a race between dhcpcd and xend's bridge setup script
# (which renames eth* to peth* and recreates eth* as a virtual
# device), start dhcpcd after xend.
jobs.dhcpcd.startOn = mkOverride 50 "started xend";
environment.etc =
[ { source = xendConfig;
target = "xen/xend-config.sxp";
}
{ source = "${xen}/etc/xen/scripts";
target = "xen/scripts";
[ { source = "${xen}/etc/xen/xl.conf";
target = "xen/xl.conf";
}
];
@ -174,6 +166,125 @@ in
services.udev.path = [ pkgs.bridge-utils pkgs.iproute ];
systemd.services.xen-store = {
description = "Xen Store Daemon";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" "xen-store.socket" ];
requires = [ "xen-store.socket" ];
preStart = ''
export XENSTORED_ROOTDIR="/var/lib/xenstored"
rm -f "$XENSTORED_ROOTDIR"/tdb* &>/dev/null
mkdir -p /var/run
${optionalString cfg.trace "mkdir -p /var/log/xen"}
grep -q control_d /proc/xen/capabilities
'';
serviceConfig.ExecStart = ''
${cfg.stored}${optionalString cfg.trace " -T /var/log/xen/xenstored-trace.log"} --no-fork
'';
postStart = ''
time=0
timeout=30
# Wait for xenstored to actually come up, timing out after 30 seconds
while [ $time -lt $timeout ] && ! `${pkgs.xen}/bin/xenstore-read -s / >/dev/null 2>&1` ; do
time=$(($time+1))
sleep 1
done
# Exit if we timed out
if ! [ $time -lt $timeout ] ; then
echo "Could not start Xenstore Daemon"
exit 1
fi
${pkgs.xen}/bin/xenstore-write "/local/domain/0/name" "Domain-0"
${pkgs.xen}/bin/xenstore-write "/local/domain/0/domid" 0
'';
};
systemd.sockets.xen-store = {
description = "XenStore Socket for userspace API";
wantedBy = [ "sockets.target" ];
socketConfig = {
ListenStream = [ "/var/run/xenstored/socket" "/var/run/xenstored/socket_ro" ];
SocketMode = "0660";
SocketUser = "root";
SocketGroup = "root";
};
};
systemd.services.xen-console = {
description = "Xen Console Daemon";
wantedBy = [ "multi-user.target" ];
after = [ "xen-store.service" ];
preStart = ''
mkdir -p /var/run/xen
${optionalString cfg.trace "mkdir -p /var/log/xen"}
grep -q control_d /proc/xen/capabilities
'';
serviceConfig = {
ExecStart = ''
${pkgs.xen}/bin/xenconsoled${optionalString cfg.trace " --log=all --log-dir=/var/log/xen"}
'';
};
};
systemd.services.xen-qemu = {
description = "Xen Qemu Daemon";
wantedBy = [ "multi-user.target" ];
after = [ "xen-console.service" ];
serviceConfig.ExecStart = ''
${pkgs.xen}/lib/xen/bin/qemu-system-i386 -xen-domid 0 -xen-attach -name dom0 -nographic -M xenpv \
-monitor /dev/null -serial /dev/null -parallel /dev/null
'';
};
systemd.services.xen-watchdog = {
description = "Xen Watchdog Daemon";
wantedBy = [ "multi-user.target" ];
after = [ "xen-qemu.service" ];
serviceConfig.ExecStart = "${pkgs.xen}/bin/xenwatchdogd 30 15";
serviceConfig.Type = "forking";
serviceConfig.RestartSec = "1";
serviceConfig.Restart = "on-failure";
};
systemd.services.xen-bridge = {
description = "Xen bridge";
wantedBy = [ "multi-user.target" ];
before = [ "xen-domains.service" ];
serviceConfig.RemainAfterExit = "yes";
serviceConfig.ExecStart = ''
${pkgs.bridge-utils}/bin/brctl addbr ${cfg.bridge}
${pkgs.inetutils}/bin/ifconfig ${cfg.bridge} up
'';
serviceConfig.ExecStop = ''
${pkgs.inetutils}/bin/ifconfig ${cfg.bridge} down
${pkgs.bridge-utils}/bin/brctl delbr ${cfg.bridge}
'';
};
systemd.services.xen-domains = {
description = "Xen domains - automatically starts, saves and restores Xen domains";
wantedBy = [ "multi-user.target" ];
after = [ "xen-bridge.service" "xen-qemu.service" ];
## To prevent a race between dhcpcd and xend's bridge setup script
## (which renames eth* to peth* and recreates eth* as a virtual
## device), start dhcpcd after xend.
before = [ "dhcpd.service" ];
restartIfChanged = false;
serviceConfig.RemainAfterExit = "yes";
path = [ pkgs.xen ];
environment.XENDOM_CONFIG = "${pkgs.xen}/etc/sysconfig/xendomains";
preStart = "mkdir -p /var/lock/subsys -m 755";
serviceConfig.ExecStart = "${pkgs.xen}/etc/init.d/xendomains start";
serviceConfig.ExecStop = "${pkgs.xen}/etc/init.d/xendomains stop";
};
};
}

@ -9,7 +9,10 @@
boot.loader.grub.device = "nodev";
boot.loader.grub.extraPerEntryConfig = "root (hd0)";
boot.initrd.kernelModules = [ "xen-blkfront" ];
boot.initrd.kernelModules =
[ "xen-blkfront" "xen-tpmfront" "xen-kbdfront" "xen-fbfront"
"xen-netfront" "xen-pcifront" "xen-scsifront"
];
# Send syslog messages to the Xen console.
services.syslogd.tty = "hvc0";

@ -0,0 +1,46 @@
{ callPackage, fetchurl, ... } @ args:
let
# Xen 4.4.1
xenConfig = {
name = "xen-4.4.1";
version = "4.4.1";
src = fetchurl {
url = "http://bits.xensource.com/oss-xen/release/4.4.1/xen-4.4.1.tar.gz";
sha256 = "09gaqydqmy64s5pqnwgjyzhd3wc61xyghpqjfl97kmvm8ly9vd2m";
};
# Sources needed to build the xen tools and tools/firmware.
toolsGits =
[ # tag qemu-xen-4.4.1
{ name = "qemu-xen";
url = git://xenbits.xen.org/qemu-upstream-4.4-testing.git;
rev = "65fc9b78ba3d868a26952db0d8e51cecf01d47b4";
sha256 = "e24fb58f773fd9134c5aae6d3ca7e9f754dc9822de92b1eb2cedc76faf911f18";
}
# tag xen-4.4.1
{ name = "qemu-xen-traditional";
url = git://xenbits.xen.org/qemu-xen-4.4-testing.git;
rev = "6ae4e588081620b141071eb010ec40aca7e12876";
sha256 = "b1ed1feb92fbe658273a8d6d38d6ea60b79c1658413dd93979d6d128d8554ded";
}
];
firmwareGits =
[ # tag 1.7.3.1
{ name = "seabios";
url = git://xenbits.xen.org/seabios.git;
rev = "7d9cbe613694924921ed1a6f8947d711c5832eee";
sha256 = "c071282bbcb1dd0d98536ef90cd1410f5d8da19648138e0e3863bc540d954a87";
}
{ name = "ovmf";
url = git://xenbits.xen.org/ovmf.git;
rev = "447d264115c476142f884af0be287622cd244423";
sha256 = "7086f882495a8be1497d881074e8f1005dc283a5e1686aec06c1913c76a6319b";
}
];
};
in callPackage ./generic.nix (args // { xenConfig=xenConfig; })

@ -0,0 +1,58 @@
{ callPackage, fetchurl, fetchgit, ... } @ args:
let
# Xen 4.5.0
xenConfig = {
name = "xen-4.5.0";
version = "4.5.0";
src = fetchurl {
url = "http://bits.xensource.com/oss-xen/release/4.5.0/xen-4.5.0.tar.gz";
sha256 = "0fvg00d596gh6cfm51xr8kj2mghcyivrf6np3dafnbldnbi41nsv";
};
# Sources needed to build the xen tools and tools/firmware.
firmwareGits =
[ # tag 1.7.5
{ name = "seabios";
url = git://xenbits.xen.org/seabios.git;
rev = "e51488c5f8800a52ac5c8da7a31b85cca5cc95d2";
sha256 = "b96a0b9f31cab0f3993d007dcbe5f1bd69ad02b0a23eb2dc8a3ed1aafe7985cb";
}
{ name = "ovmf";
url = git://xenbits.xen.org/ovmf.git;
rev = "447d264115c476142f884af0be287622cd244423";
sha256 = "7086f882495a8be1497d881074e8f1005dc283a5e1686aec06c1913c76a6319b";
}
];
toolsGits =
[ # tag qemu-xen-4.5.0
{ name = "qemu-xen";
url = git://xenbits.xen.org/qemu-upstream-4.5-testing.git;
rev = "1ebb75b1fee779621b63e84fefa7b07354c43a99";
sha256 = "1j312q2mqvkvby9adkkxf7f1pn3nz85g5mr9nbg4qpf2y9cg122z";
}
# tag xen-4.5.0
{ name = "qemu-xen-traditional";
url = git://xenbits.xen.org/qemu-xen-4.5-testing.git;
rev = "b0d42741f8e9a00854c3b3faca1da84bfc69bf22";
sha256 = "ce52b5108936c30ab85ec0c9554f88d5e7b34896f3acb666d56765b49c86f2af";
}
];
xenserverPatches = let
patches = {
url = https://github.com/ts468/xen-4.5.pg.git;
rev = "3442b65b490f43c817cbc53369220d0b1ab9b785";
sha256 = "31436c15def0a300b3ea1a63b2208c4a3bcbb143db5c6488d4db370b3ceeb845";
};
in ''
cp -r ${fetchgit patches}/master patches
quilt push -a
substituteInPlace tools/xenguest/Makefile --replace "_BSD_SOURCE" "_DEFAULT_SOURCE"
'';
};
in callPackage ./generic.nix (args // { xenConfig=xenConfig; })

@ -3,46 +3,20 @@
, lvm2, utillinux, procps, texinfo, perl, pythonPackages
, glib, bridge-utils, xlibs, pixman, iproute, udev, bison
, flex, cmake, ocaml, ocamlPackages, figlet, libaio, yajl
, checkpolicy, transfig, glusterfs, fetchgit, xz }:
, checkpolicy, transfig, glusterfs, fetchgit, xz, spice
, spice_protocol, usbredir, alsaLib, quilt
, coreutils, gawk, gnused, gnugrep, diffutils, multipath_tools
, inetutils, iptables, openvswitch, nbd, drbd, xenConfig
, xenserverPatched ? false, ... }:
with stdenv.lib;
let
version = "4.4.1";
libDir = if stdenv.is64bit then "lib64" else "lib";
# Sources needed to build the xen tools and tools/firmware.
toolsGits =
[ # tag qemu-xen-4.4.1
#{ name = "qemu-xen";
# url = git://xenbits.xen.org/qemu-upstream-4.4-testing.git;
# rev = "65fc9b78ba3d868a26952db0d8e51cecf01d47b4";
# sha256 = "e7abaf0e927f7a2bba4c59b6dad6ae19e77c92689c94fa0384e2c41742f8cdb6";
#}
# tag xen-4.4.1
{ name = "qemu-xen-traditional";
url = git://xenbits.xen.org/qemu-xen-4.4-testing.git;
rev = "6ae4e588081620b141071eb010ec40aca7e12876";
sha256 = "b1ed1feb92fbe658273a8d6d38d6ea60b79c1658413dd93979d6d128d8554ded";
}
];
firmwareGits =
[ # tag 1.7.3.1
{ name = "seabios";
url = git://xenbits.xen.org/seabios.git;
rev = "7d9cbe613694924921ed1a6f8947d711c5832eee";
sha256 = "c071282bbcb1dd0d98536ef90cd1410f5d8da19648138e0e3863bc540d954a87";
}
{ name = "ovmf";
url = git://xenbits.xen.org/ovmf.git;
rev = "447d264115c476142f884af0be287622cd244423";
sha256 = "7086f882495a8be1497d881074e8f1005dc283a5e1686aec06c1913c76a6319b";
}
];
# Sources needed to build the stubdoms and tools
# These sources are already rather old and probably do not change frequently
xenExtfiles = [
{ url = http://xenbits.xensource.com/xen-extfiles/lwip-1.3.0.tar.gz;
sha256 = "13wlr85s1hnvia6a698qpryyy12lvmqw0a05xmjnd0h71ralsbkp";
@ -76,15 +50,15 @@ let
}
];
scriptEnvPath = stdenv.lib.concatStrings (stdenv.lib.intersperse ":" (map (x: "${x}/bin")
[ coreutils gawk gnused gnugrep which perl diffutils utillinux multipath_tools
iproute inetutils iptables bridge_utils openvswitch nbd drbd ]));
in
stdenv.mkDerivation {
name = "xen-${version}";
src = fetchurl {
url = "http://bits.xensource.com/oss-xen/release/${version}/xen-${version}.tar.gz";
sha256 = "09gaqydqmy64s5pqnwgjyzhd3wc61xyghpqjfl97kmvm8ly9vd2m";
};
stdenv.mkDerivation {
inherit (xenConfig) name version src;
dontUseCmakeConfigure = true;
@ -95,11 +69,15 @@ stdenv.mkDerivation {
glib bridge-utils pixman iproute udev bison xlibs.libX11
flex ocaml ocamlPackages.findlib figlet libaio
checkpolicy pythonPackages.markdown transfig
glusterfs cmake
glusterfs cmake spice spice_protocol usbredir
alsaLib quilt
];
pythonPath = [ pythonPackages.curses ];
patchPhase = if ((xenserverPatched == true) && (builtins.hasAttr "xenserverPatches" xenConfig))
then xenConfig.xenserverPatches
else "";
preConfigure = ''
# Fake wget: copy prefetched downloads instead
@ -111,6 +89,13 @@ stdenv.mkDerivation {
export PATH=$PATH:$PWD/wget
'';
# TODO: If multiple arguments are given with with-extra-qemuu,
# then the configuration aborts; the reason is unclear.
# If you know how to fix it, please let me know! :)
#configureFlags = "--with-extra-qemuu-configure-args='--enable-spice --enable-usb-redir --enable-linux-aio'";
# TODO: Flask needs more testing before enabling it by default.
#makeFlags = "XSM_ENABLE=y FLASK_ENABLE=y PREFIX=$(out) CONFIG_DIR=/etc XEN_EXTFILES_URL=\\$(XEN_ROOT)/xen_ext_files ";
makeFlags = "PREFIX=$(out) CONFIG_DIR=/etc XEN_EXTFILES_URL=\\$(XEN_ROOT)/xen_ext_files ";
buildFlags = "xen tools stubdom";
@ -136,6 +121,12 @@ stdenv.mkDerivation {
substituteInPlace tools/ioemu-qemu-xen/xen-hooks.mak \
--replace /usr/include/pci ${pciutils}/include/pci
substituteInPlace tools/hotplug/Linux/xen-backend.rules \
--replace /etc/xen/scripts $out/etc/xen/scripts
# blktap is not provided by xen, but by xapi
sed -i '/blktap/d' tools/hotplug/Linux/xen-backend.rules
# Work around a bug in our GCC wrapper: `gcc -MF foo -v' doesn't
# print the GCC version number properly.
substituteInPlace xen/Makefile \
@ -157,15 +148,17 @@ stdenv.mkDerivation {
# overriden at runtime.
substituteInPlace tools/hotplug/Linux/init.d/xendomains \
--replace 'XENDOM_CONFIG=/etc/sysconfig/xendomains' "" \
--replace 'XENDOM_CONFIG=/etc/default/xendomains' "" \
--replace /etc/xen/scripts/hotplugpath.sh $out/etc/xen/scripts/hotplugpath.sh \
--replace /bin/ls ls
# Xen's tools and firmares need various git repositories that it
# usually checks out at time using git. We can't have that.
${flip concatMapStrings toolsGits (x: let src = fetchgit x; in ''
${flip concatMapStrings xenConfig.toolsGits (x: let src = fetchgit x; in ''
cp -r ${src} tools/${src.name}-dir-remote
chmod +w tools/${src.name}-dir-remote
'')}
${flip concatMapStrings firmwareGits (x: let src = fetchgit x; in ''
${flip concatMapStrings xenConfig.firmwareGits (x: let src = fetchgit x; in ''
cp -r ${src} tools/firmware/${src.name}-dir-remote
chmod +w tools/firmware/${src.name}-dir-remote
'')}
@ -189,13 +182,19 @@ stdenv.mkDerivation {
installPhase =
''
mkdir -p $out
mkdir -p $out $out/share
cp -prvd dist/install/nix/store/*/* $out/
cp -prvd dist/install/boot $out/boot
cp -prvd dist/install/etc $out/etc
cp -prvd dist/install/etc $out
cp -dR docs/man1 docs/man5 $out/share/man/
wrapPythonPrograms
''; # */
substituteInPlace $out/etc/xen/scripts/hotplugpath.sh --replace SBINDIR=\"$out/sbin\" SBINDIR=\"$out/bin\"
shopt -s extglob
for i in $out/etc/xen/scripts/!(*.sh); do
sed -i '2s@^@export PATH=$out/bin:${scriptEnvPath}@' $i
done
'';
meta = {
homepage = http://www.xen.org/;

@ -12008,9 +12008,10 @@ let
xdotool = callPackage ../tools/X11/xdotool { };
xen = callPackage ../applications/virtualization/xen {
stdenv = overrideCC stdenv gcc45;
};
xen_4_4_1 = callPackage ../applications/virtualization/xen/4.4.1.nix { };
xen_4_5_0 = callPackage ../applications/virtualization/xen/4.5.0.nix { };
xen_xenServer = callPackage ../applications/virtualization/xen/4.5.0.nix { xenserverPatched = true; };
xen = xen_4_5_0;
xfe = callPackage ../applications/misc/xfe {
fox = fox_1_6;

Loading…
Cancel
Save