From 7bba427e939839d286d87a8c5f5fef3383e6dbc5 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 20 Nov 2006 17:28:08 +0000 Subject: [PATCH] * Put the PCI module probing in an Upstart task. We now have more-or-less "asynchronous" booting: the login prompt appears almost immediately, before the hardware and the network are started. svn path=/nixu/trunk/; revision=7082 --- test/boot-environment.nix | 10 ++++++++-- test/boot-stage-2-init.sh | 8 -------- test/boot-stage-2.nix | 4 +--- test/upstart-jobs/dhclient.nix | 2 +- test/upstart-jobs/hardware-scan.nix | 23 +++++++++++++++++++++++ test/upstart-jobs/network-interfaces.nix | 6 +++--- 6 files changed, 36 insertions(+), 17 deletions(-) create mode 100644 test/upstart-jobs/hardware-scan.nix diff --git a/test/boot-environment.nix b/test/boot-environment.nix index e0acb16252e..b70906b13f6 100644 --- a/test/boot-environment.nix +++ b/test/boot-environment.nix @@ -87,9 +87,14 @@ rec { inherit (pkgs) sysklogd; }) + # Hardware scan; loads modules for PCI devices. + (import ./upstart-jobs/hardware-scan.nix { + inherit (pkgs) kernel module_init_tools; + }) + # Network interfaces. (import ./upstart-jobs/network-interfaces.nix { - inherit (pkgs) nettools kernel; + inherit (pkgs) nettools kernel module_init_tools; }) # DHCP client. @@ -121,7 +126,7 @@ rec { # everything else to bring up the system. bootStage2 = import ./boot-stage-2.nix { inherit (pkgs) genericSubstituter coreutils findutils - utillinux kernel udev module_init_tools + utillinux kernel udev upstart; inherit upstartJobs; shell = pkgs.bash + "/bin/sh"; @@ -140,6 +145,7 @@ rec { pkgs.gzip pkgs.iputils pkgs.less + pkgs.module_init_tools pkgs.nano pkgs.netcat pkgs.nettools diff --git a/test/boot-stage-2-init.sh b/test/boot-stage-2-init.sh index e624fdbacc1..d8bcf620d48 100644 --- a/test/boot-stage-2-init.sh +++ b/test/boot-stage-2-init.sh @@ -74,14 +74,6 @@ echo "*.* /dev/tty10" > /etc/syslog.conf echo "syslog 514/udp" > /etc/services # required, even if we don't use it -# Try to load modules for all PCI devices. -for i in /sys/bus/pci/devices/*/modalias; do - echo "Trying to load a module for $(basename $(dirname $i))..." - modprobe $(cat $i) - echo "" -done - - # login/su absolutely need this. test -e /etc/login.defs || touch /etc/login.defs diff --git a/test/boot-stage-2.nix b/test/boot-stage-2.nix index dc8cfbf891f..1bf8856f480 100644 --- a/test/boot-stage-2.nix +++ b/test/boot-stage-2.nix @@ -1,6 +1,5 @@ { genericSubstituter, shell, coreutils, findutils -, utillinux, kernel, udev -, module_init_tools, upstart +, utillinux, kernel, udev, upstart , path ? [] , # Whether the root device is root only. If so, we'll mount a @@ -20,7 +19,6 @@ genericSubstituter { findutils utillinux udev - module_init_tools upstart ]; extraPath = path; diff --git a/test/upstart-jobs/dhclient.nix b/test/upstart-jobs/dhclient.nix index a9c9f375bbb..3eb71f1745a 100644 --- a/test/upstart-jobs/dhclient.nix +++ b/test/upstart-jobs/dhclient.nix @@ -6,7 +6,7 @@ job = " description \"DHCP client\" -start on network-interfaces +start on network-interfaces/started stop on network-interfaces/stop script diff --git a/test/upstart-jobs/hardware-scan.nix b/test/upstart-jobs/hardware-scan.nix new file mode 100644 index 00000000000..3ffd8f9223f --- /dev/null +++ b/test/upstart-jobs/hardware-scan.nix @@ -0,0 +1,23 @@ +# !!! Don't like it that I have to pass the kernel here. +{kernel, module_init_tools}: + +{ + name = "hardware-scan"; + + job = " +start on startup + +script + export MODULE_DIR=${kernel}/lib/modules/ + + # Try to load modules for all PCI devices. + for i in /sys/bus/pci/devices/*/modalias; do + echo \"Trying to load a module for $(basename $(dirname $i))...\" + ${module_init_tools}/sbin/modprobe $(cat $i) || true + echo \"\" + done +end script + + "; + +} diff --git a/test/upstart-jobs/network-interfaces.nix b/test/upstart-jobs/network-interfaces.nix index 3539a29afeb..844ccd3f507 100644 --- a/test/upstart-jobs/network-interfaces.nix +++ b/test/upstart-jobs/network-interfaces.nix @@ -1,17 +1,17 @@ # !!! Don't like it that I have to pass the kernel here. -{nettools, kernel}: +{nettools, kernel, module_init_tools}: { name = "network-interfaces"; job = " -start on startup +start on hardware-scan stop on shutdown start script export MODULE_DIR=${kernel}/lib/modules/ - modprobe af_packet + ${module_init_tools}/sbin/modprobe af_packet for i in $(cd /sys/class/net && ls -d *); do echo \"Bringing up network device $i...\"