summaryrefslogtreecommitdiffstats
path: root/testModule
diff options
context:
space:
mode:
authorJonathan Bauer2015-04-14 17:58:50 +0200
committerJonathan Bauer2015-04-14 17:58:50 +0200
commite4c036d247389cfaeb3da8675ce53f53bef90afe (patch)
treeae1c87aeb940147cb258c4b540ad920880781ac0 /testModule
parentstatic qemu-nbd (diff)
parentSome tries to fix kernel panic. (diff)
downloadsystemd-init-e4c036d247389cfaeb3da8675ce53f53bef90afe.tar.gz
systemd-init-e4c036d247389cfaeb3da8675ce53f53bef90afe.tar.xz
systemd-init-e4c036d247389cfaeb3da8675ce53f53bef90afe.zip
Merge branch 'master' of git.openslx.org:openslx-ng/systemd-init
Diffstat (limited to 'testModule')
-rwxr-xr-xtestModule/binaries/busybox (renamed from testModule/busybox)bin931664 -> 931664 bytes
-rwxr-xr-xtestModule/binaries/dnbd3-client (renamed from testModule/dnbd3-client)bin31150 -> 31150 bytes
-rwxr-xr-xtestModule/binaries/endlessbin0 -> 6752 bytes
-rwxr-xr-xtestModule/binaries/systemd_preserve_process_markerbin0 -> 7728 bytes
-rw-r--r--testModule/deprecated/network.functions (renamed from testModule/network.functions)0
-rw-r--r--testModule/deprecated/setup_network.sh (renamed from testModule/setup_network.sh)0
-rw-r--r--testModule/endless.c10
-rw-r--r--testModule/hooks/cmdline.sh (renamed from testModule/parse-ip.sh)10
-rw-r--r--testModule/hooks/pre-mount.sh10
-rw-r--r--testModule/hooks/pre-pivot.sh12
-rwxr-xr-xtestModule/kernel_modules/dnbd3.ko (renamed from testModule/dnbd3.ko)bin1345285 -> 1345285 bytes
-rw-r--r--testModule/kernel_modules/nbd.ko (renamed from testModule/nbd.ko)bin458623 -> 458623 bytes
-rw-r--r--testModule/module-setup.sh35
-rw-r--r--testModule/mount-dnbd3.sh15
-rw-r--r--testModule/systemd_preserve_process_marker.c31
-rw-r--r--testModule/wrap.c41
16 files changed, 89 insertions, 75 deletions
diff --git a/testModule/busybox b/testModule/binaries/busybox
index 1212ae20..1212ae20 100755
--- a/testModule/busybox
+++ b/testModule/binaries/busybox
Binary files differ
diff --git a/testModule/dnbd3-client b/testModule/binaries/dnbd3-client
index 76924b49..76924b49 100755
--- a/testModule/dnbd3-client
+++ b/testModule/binaries/dnbd3-client
Binary files differ
diff --git a/testModule/binaries/endless b/testModule/binaries/endless
new file mode 100755
index 00000000..de7a8c0a
--- /dev/null
+++ b/testModule/binaries/endless
Binary files differ
diff --git a/testModule/binaries/systemd_preserve_process_marker b/testModule/binaries/systemd_preserve_process_marker
new file mode 100755
index 00000000..0181cd80
--- /dev/null
+++ b/testModule/binaries/systemd_preserve_process_marker
Binary files differ
diff --git a/testModule/network.functions b/testModule/deprecated/network.functions
index 89ca5a20..89ca5a20 100644
--- a/testModule/network.functions
+++ b/testModule/deprecated/network.functions
diff --git a/testModule/setup_network.sh b/testModule/deprecated/setup_network.sh
index 3b32a68c..3b32a68c 100644
--- a/testModule/setup_network.sh
+++ b/testModule/deprecated/setup_network.sh
diff --git a/testModule/endless.c b/testModule/endless.c
new file mode 100644
index 00000000..22c9bc50
--- /dev/null
+++ b/testModule/endless.c
@@ -0,0 +1,10 @@
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+int main(int argc, char *argv[]) {
+ // Provides a dummy worker.
+ while (1)
+ sleep(999999999);
+}
diff --git a/testModule/parse-ip.sh b/testModule/hooks/cmdline.sh
index 3349787b..340467df 100644
--- a/testModule/parse-ip.sh
+++ b/testModule/hooks/cmdline.sh
@@ -3,11 +3,6 @@
source /usr/lib/test-library.sh
-# TODO
-warn 'LOAD ...........................'
-warn 'LOAD ...........................'
-warn 'LOAD ...........................'
-
for parameter in $(getargs ip=); do
local temp="$parameter:"
set --
@@ -22,8 +17,9 @@ for parameter in $(getargs ip=); do
[ -n "$4" ] && net_mask=$4
warn "PXE given net configuration: ip: $ip server_ip: $server_ip gateway_ip: $gateway_ip net_mask: $net_mask"
- # TODO
- replace_cmd ip "$ip::$gateway_ip:$net_mask:dracut_test_client:enp0s3:none"
+ local final_dracut_ip_config="$ip::$gateway_ip:$net_mask:dracut_test_client:enp0s3:none"
+ warn "Final dracut ip config: $final_dracut_ip_config"
+ replace_cmd ip "$final_dracut_ip_config"
done
# NOTE: Doesn't work since dracuts needed version of mount doesn't support
diff --git a/testModule/hooks/pre-mount.sh b/testModule/hooks/pre-mount.sh
new file mode 100644
index 00000000..7798622e
--- /dev/null
+++ b/testModule/hooks/pre-mount.sh
@@ -0,0 +1,10 @@
+# TODO
+warn '............START.............'
+
+insmod /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/dnbd3.ko
+local dnbd3_device_node="$(dnbd3-client -h 132.230.4.1 -i stage4/torben/test \
+ -r 1 -d /dev/dnbd0)"
+#qemu-img create -f qcow2 -o \
+# backing_file="$dnbd3_device_node",backing_fmt=qcow2 /test.qcow2
+#insmod /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/nbd.ko
+#systemd_preserve_process_marker qemu-nbd -c /dev/nbd0 /test.qcow2
diff --git a/testModule/hooks/pre-pivot.sh b/testModule/hooks/pre-pivot.sh
new file mode 100644
index 00000000..8b01779a
--- /dev/null
+++ b/testModule/hooks/pre-pivot.sh
@@ -0,0 +1,12 @@
+# TODO
+warn '............MOUNT.............'
+# TODO
+dnbd3_device_node='/dev/dnbd0'
+mount -o remount,rw /sysroot
+rm /sysroot/test.qcow2
+qemu-img create -f qcow2 -o \
+ backing_file="$dnbd3_device_node",backing_fmt=qcow2 /sysroot/test.qcow2
+insmod /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/nbd.ko
+systemd_preserve_process_marker qemu-nbd --connect /dev/nbd0 /sysroot/test.qcow2 --socket /sysroot/var/lock/qemu-nbd-TEST
+mount /dev/nbd0 /sysroot/TEST
+# strace -ff -o /sysroot/log.txt -p PID
diff --git a/testModule/dnbd3.ko b/testModule/kernel_modules/dnbd3.ko
index d7b7ce3b..d7b7ce3b 100755
--- a/testModule/dnbd3.ko
+++ b/testModule/kernel_modules/dnbd3.ko
Binary files differ
diff --git a/testModule/nbd.ko b/testModule/kernel_modules/nbd.ko
index 40b67a92..40b67a92 100644
--- a/testModule/nbd.ko
+++ b/testModule/kernel_modules/nbd.ko
Binary files differ
diff --git a/testModule/module-setup.sh b/testModule/module-setup.sh
index ae30de9f..513b9068 100644
--- a/testModule/module-setup.sh
+++ b/testModule/module-setup.sh
@@ -5,12 +5,13 @@ check() {
}
depends() {
- echo base network rootfs-block bash kernel-modules systemd shutdown udev-rules debug qemu btrfs
+ echo base network rootfs-block bash kernel-modules debug
+ # systemd
return 0
}
installkernel() {
- instmods dnbd3 nbd ext4 \
+ instmods ext4 mbcache jbd2 \
ip6t_rpfilter ip6t_REJEiCT ipt_REJECT xt_conntrack ebtable_nat \
ebtable_broute bridge stp llc ebtable_filter ebtables ip6table_nat \
nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6 ip6table_mangle \
@@ -20,23 +21,33 @@ installkernel() {
iptable_filter ip_tables vboxsf sg ppdev snd_intel8x0 snd_ac97_codec \
ac97_bus serio_raw snd_seq snd_seq_device i2c_piix4 pcspkr snd_pcm \
parport_pc parport snd_page_alloc snd_timer snd video soundcore e1000 \
- mperf xfs libcrc32c sd_mod crc_t10dif crct10dif_common sr_mod cdrom \
+ mperf libcrc32c sd_mod crc_t10dif crct10dif_common sr_mod cdrom \
ata_generic pata_acpi ahci libahci vboxvideo drm i2c_core ata_piix \
libata vboxguest dm_mirror dm_region_hash dm_log dm_mod
+ # Production: instmods ext4 mbcache jbd2
}
install() {
# Loads globally needed useful functions or fixes some native dracut ones.
inst "$moddir/library.sh" /usr/lib/test-library.sh
- inst "$moddir/dnbd3-client" /usr/bin/dnbd3-client
- inst "$moddir/dnbd3.ko" /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/dnbd3.ko
- inst "$moddir/nbd.ko" /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/nbd.ko
- # NOTE: Priority has to be greater than the network cmdline parsing hooks
+
+ inst "$moddir/binaries/systemd_preserve_process_marker" /usr/bin/systemd_preserve_process_marker
+ inst "$moddir/binaries/endless" /usr/bin/endless
+ inst "$moddir/binaries/dnbd3-client" /usr/bin/dnbd3-client
+ inst "$moddir/binaries/busybox" /usr/bin/busybox
+
+ inst "$moddir/kernel_modules/dnbd3.ko" /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/dnbd3.ko
+ inst "$moddir/kernel_modules/nbd.ko" /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/nbd.ko
+
+ # NOTE: Priority has to be lower than the network cmdline parsing hooks
# since we have to modify the some kernel parameter before.
- inst_hook cmdline 100 "$moddir/parse-ip.sh"
- inst_hook pre-mount 100 "$moddir/mount-dnbd3.sh"
- inst_simple "$moddir/busybox" /usr/bin/busybox
- #inst_hook pre-mount 20 "$moddir/setup_network.sh"
- inst_multiple lsblk ping ip ifconfig sshd htop dhclient tail head cat vim touch sed lsmod insmod qemu-img qemu-nbd sleep
+ inst_hook cmdline 1 "$moddir/hooks/cmdline.sh"
+ inst_hook pre-mount 10 "$moddir/hooks/pre-mount.sh"
+ inst_hook pre-pivot 10 "$moddir/hooks/pre-pivot.sh"
+
+ inst_multiple lsblk ping ip ifconfig sshd htop dhclient tail head cat vim \
+ touch sed lsmod insmod qemu-img qemu-nbd sleep route wget find lsof \
+ strace chroot switch_root pivot_root
+ # Production: inst_multiple insmod qemu-img qemu-nbd
return 0
}
diff --git a/testModule/mount-dnbd3.sh b/testModule/mount-dnbd3.sh
deleted file mode 100644
index 9629a153..00000000
--- a/testModule/mount-dnbd3.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-insmod /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/dnbd3.ko
-
-dnbd3-client --daemon &
-sleep 2
-local dnbd3_device_node="$(dnbd3-client -h 132.230.4.1 -i stage4/torben/test -r 1)"
-
-qemu-img create -f qcow2 -o backing_file="$dnbd3_device_node",backing_fmt=qcow2 /tmp/test.qcow2
-insmod /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/nbd.ko
-qemu-nbd -c /dev/nbd0 /tmp/test.qcow2
-mkdir /mnt
-mount /dev/nbd0 /mnt
-
-warn '............JAU.............'
-warn '............JAU.............'
-warn '............JAU.............'
diff --git a/testModule/systemd_preserve_process_marker.c b/testModule/systemd_preserve_process_marker.c
new file mode 100644
index 00000000..172a5546
--- /dev/null
+++ b/testModule/systemd_preserve_process_marker.c
@@ -0,0 +1,31 @@
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+void print_array(int argc, char *argv[]) {
+ // Helper function to print given array with given length.
+ int i = 0;
+ int j = 0;
+ for (i = 0; i < argc; i ++) {
+ j = 0;
+ while(argv[i][j] != '\0')
+ printf("%c", argv[i][j++]);
+ printf(" ");
+ }
+ printf("\n");
+}
+int main(int argc, char *argv[]) {
+ int count;
+ char **copy = malloc(sizeof(char *) * (argc-1));
+ for (count = 0; count < argc - 1; count++)
+ copy[count] = strdup(argv[count + 1]);
+ // Adding systemd indicator to preserve wrapped process during changing
+ // root filesystem. We mark wrapper and child process.
+ copy[0][0] = '@';
+ argv[0][0] = '@';
+ if (-1 == execvp(argv[1], copy)) {
+ perror("child process execve failed [%m]");
+ return -1;
+ }
+}
diff --git a/testModule/wrap.c b/testModule/wrap.c
deleted file mode 100644
index 0f118235..00000000
--- a/testModule/wrap.c
+++ /dev/null
@@ -1,41 +0,0 @@
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-
-void arg_print(int argc, char *argv[]) {
- int i = 0;
- int j = 0;
- for (i = 0; i < argc; i ++) {
- j = 0;
- while(argv[i][j] != '\0')
- printf("%c", argv[i][j++]);
-
- printf(" ");
- }
- printf("\n");
-}
-
-
-int main(int argc, char *argv[]) {
-
- arg_print(argc, argv);
-
- int count;
- char **copy = malloc(sizeof(char *) * (argc-1));
- for ( count = 0; count < argc - 1; count++ ) {
- copy[count] = strdup(argv[count + 1]);
- }
-
- arg_print(argc - 1, copy);
-
- copy[0][0] = '@';
- argv[0][0] = '@';
-
- arg_print(argc - 1, copy);
-
- if (-1 == execvp(argv[1], copy)) {
- perror("child process execve failed [%m]");
- return -1;
- }
-}