<commit_before># Xen hypervisor support.

{ config, pkgs, ... }:

with pkgs.lib;

let cfg = config.virtualisation.xen; in

{
  ###### interface

  options = {

    virtualisation.xen.enable = 
      mkOption {
        default = false;
        description =
          ''
            Setting this option enables the Xen hypervisor, a
            virtualisation technology that allows multiple virtual
            machines, known as <emphasis>domains</emphasis>, to run
            concurrently on the physical machine.  NixOS runs as the
            privileged <emphasis>Domain 0</emphasis>.  This option
            requires a reboot to take effect.
          '';
      };

    virtualisation.xen.bootParams = 
      mkOption {
        default = "";
        description =
          ''
            Parameters passed to the Xen hypervisor at boot time.
          '';
      };

    virtualisation.xen.domain0MemorySize = 
      mkOption {
        default = 0;
        example = 512;
        description =
          ''
            Amount of memory (in MiB) allocated to Domain 0 on boot.
            If set to 0, all memory is assigned to Domain 0.
          '';
      };

  };


  ###### implementation

  config = mkIf cfg.enable {

    environment.systemPackages = [ pkgs.xen ];

    # Domain 0 requires a pvops-enabled kernel.
    boot.kernelPackages = pkgs.linuxPackages_2_6_32_xen;

    boot.kernelModules = [ "xen_evtchn" "xen_gntdev" ];

    # The radeonfb kernel module causes the screen to go black as soon
    # as it's loaded, so don't load it.
    boot.blacklistedKernelModules = [ "radeonfb" ];

    virtualisation.xen.bootParams = 
      [ "loglvl=all" "guest_loglvl=all" ] ++
      optional (cfg.domain0MemorySize != 0) "dom0_mem=${toString cfg.domain0MemorySize}M";

    system.extraSystemBuilderCmds =
      ''
        ln -s ${pkgs.xen}/boot/xen.gz $out/xen.gz
        echo "${toString cfg.bootParams}" > $out/xen-params
      '';

    # Mount the /proc/xen pseudo-filesystem.
    system.activationScripts.xen =
      ''
        if [ -d /proc/xen ]; then
            ${pkgs.sysvtools}/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 pkgs.xen pkgs.pciutils pkgs.procps
          ];

        preStart = "${pkgs.xen}/sbin/xend start";

        postStop = "${pkgs.xen}/sbin/xend stop";
      };

    # To prevent a race between dhclient and xend's bridge setup
    # script (which renames eth* to peth* and recreates eth* as a
    # virtual device), start dhclient after xend.
    jobs.dhclient.startOn = mkOverride 50 "started xend";

  };

}<commit_msg>* Add Xen's udev rules.  This is necessary to get automatically   created block and network devices to work.<commit_after># Xen hypervisor support.

{ config, pkgs, ... }:

with pkgs.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

{
  ###### interface

  options = {

    virtualisation.xen.enable = 
      mkOption {
        default = false;
        description =
          ''
            Setting this option enables the Xen hypervisor, a
            virtualisation technology that allows multiple virtual
            machines, known as <emphasis>domains</emphasis>, to run
            concurrently on the physical machine.  NixOS runs as the
            privileged <emphasis>Domain 0</emphasis>.  This option
            requires a reboot to take effect.
          '';
      };

    virtualisation.xen.bootParams = 
      mkOption {
        default = "";
        description =
          ''
            Parameters passed to the Xen hypervisor at boot time.
          '';
      };

    virtualisation.xen.domain0MemorySize = 
      mkOption {
        default = 0;
        example = 512;
        description =
          ''
            Amount of memory (in MiB) allocated to Domain 0 on boot.
            If set to 0, all memory is assigned to Domain 0.
          '';
      };

  };


  ###### implementation

  config = mkIf cfg.enable {

    environment.systemPackages = [ xen ];

    # Domain 0 requires a pvops-enabled kernel.
    boot.kernelPackages = pkgs.linuxPackages_2_6_32_xen;

    boot.kernelModules = [ "xen_evtchn" "xen_gntdev" "xen_blkback" "xen_netback" "xen_pciback" "blktap" ];

    # The radeonfb kernel module causes the screen to go black as soon
    # as it's loaded, so don't load it.
    boot.blacklistedKernelModules = [ "radeonfb" ];

    virtualisation.xen.bootParams = 
      [ "loglvl=all" "guest_loglvl=all" ] ++
      optional (cfg.domain0MemorySize != 0) "dom0_mem=${toString cfg.domain0MemorySize}M";

    system.extraSystemBuilderCmds =
      ''
        ln -s ${xen}/boot/xen.gz $out/xen.gz
        echo "${toString cfg.bootParams}" > $out/xen-params
      '';

    # Mount the /proc/xen pseudo-filesystem.
    system.activationScripts.xen =
      ''
        if [ -d /proc/xen ]; then
            ${pkgs.sysvtools}/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
          ];

        preStart = "${xen}/sbin/xend start";

        postStop = "${xen}/sbin/xend stop";
      };

    # To prevent a race between dhclient and xend's bridge setup
    # script (which renames eth* to peth* and recreates eth* as a
    # virtual device), start dhclient after xend.
    jobs.dhclient.startOn = mkOverride 50 "started xend";

    environment.etc =
      [ { source = xendConfig;
          target = "xen/xend-config.sxp";
        }
        { source = "${xen}/etc/xen/scripts";
          target = "xen/scripts";
        }
      ];

    # Xen provides udev rules.
    services.udev.packages = [ xen ];

    services.udev.path = [ pkgs.bridge_utils pkgs.iproute ];

  };

}
{'fraction_non_alphanumeric': 0.1074964639321075, 'fraction_numerical': 0.006286342920006287, 'mean_word_length': 2.0118315191670613, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2621766', 'n_tokens_mistral': 2097, 'n_tokens_neox': 1938, 'n_words': 510}