2 # Copyright (C) SUSE LINUX GmbH 2016-2017, all rights reserved.
4 # This library is free software; you can redistribute it and/or modify it
5 # under the terms of the GNU Lesser General Public License as published
6 # by the Free Software Foundation; either version 2.1 of the License, or
7 # (at your option) version 3.
9 # This library is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
12 # License for more details.
23 # process user defined configuration
24 . ${RAPIDO_DIR}/rapido.conf \
25 || _fail "rapido.conf missing - see rapido.conf.example"
27 function _rt_ceph_src_globals_set {
28 if [ -f "${CEPH_SRC}/../build/CMakeCache.txt" ]; then
29 # cmake build, compiled binaries and configs are in build subdir
30 CEPH_BIN="${CEPH_SRC}/../build/bin/ceph"
31 CEPH_RBD_BIN="${CEPH_SRC}/../build/bin/rbd"
32 CEPH_MOUNT_BIN="${CEPH_SRC}/../build/bin/mount.ceph"
33 CEPH_RADOS_BIN="${CEPH_SRC}/../build/bin/rados"
34 CEPH_FUSE_BIN="${CEPH_SRC}/../build/bin/ceph-fuse"
35 CEPH_RADOS_LIB="${CEPH_SRC}/../build/lib/librados.so"
36 CEPH_RBD_LIB="${CEPH_SRC}/../build/lib/librbd.so"
37 CEPH_CONF="${CEPH_SRC}/../build/ceph.conf"
38 CEPH_KEYRING="${CEPH_SRC}/../build/keyring"
41 CEPH_BIN="${CEPH_SRC}/ceph"
42 CEPH_RBD_BIN="${CEPH_SRC}/rbd"
43 CEPH_MOUNT_BIN="${CEPH_SRC}/mount.ceph"
44 CEPH_RADOS_BIN="${CEPH_SRC}/rados"
45 CEPH_FUSE_BIN="${CEPH_SRC}/ceph-fuse"
46 CEPH_RADOS_LIB="${CEPH_SRC}/.libs/librados.so"
47 CEPH_RBD_LIB="${CEPH_SRC}/.libs/librbd.so"
48 CEPH_CONF="${CEPH_SRC}/ceph.conf"
49 CEPH_KEYRING="${CEPH_SRC}/keyring"
52 RBD_NAMER_BIN="${CEPH_SRC}/ceph-rbdnamer"
53 RBD_UDEV_RULES="${CEPH_SRC}/../udev/50-rbd.rules"
54 CEPH_UDEV_RULES="${CEPH_SRC}/../udev/95-ceph-osd.rules"
55 CEPH_DISK_SYSTEMD_SVC="${CEPH_SRC}/../systemd/ceph-disk@.service"
56 CEPH_OSD_SYSTEMD_SVC="${CEPH_SRC}/../systemd/ceph-osd@.service"
59 function _rt_ceph_installed_globals_set {
60 # use installed Ceph binaries and configs
61 RBD_NAMER_BIN="/usr/bin/ceph-rbdnamer"
62 RBD_UDEV_RULES="/usr/lib/udev/rules.d/50-rbd.rules"
63 CEPH_UDEV_RULES="/usr/lib/udev/rules.d/95-ceph-osd.rules"
64 CEPH_DISK_SYSTEMD_SVC="/usr/lib/systemd/system/ceph-disk@.service"
65 CEPH_OSD_SYSTEMD_SVC="/usr/lib/systemd/system/ceph-osd@.service"
66 CEPH_BIN="/usr/bin/ceph"
67 CEPH_RBD_BIN="/usr/bin/rbd"
68 CEPH_MOUNT_BIN="/usr/sbin/mount.ceph"
69 CEPH_RADOS_BIN="/usr/bin/rados"
70 CEPH_FUSE_BIN="/usr/bin/ceph-fuse"
71 CEPH_RADOS_LIB="/usr/lib64/librados.so"
72 CEPH_RBD_LIB="/usr/lib64/librbd.so"
73 CEPH_CONF="/etc/ceph/ceph.conf"
74 CEPH_KEYRING="/etc/ceph/ceph.client.${CEPH_USER}.keyring"
77 function _rt_require_ceph {
78 if [ -n "$CEPH_SRC" ]; then
79 _rt_ceph_src_globals_set
81 _rt_ceph_installed_globals_set
84 [ -f "$RBD_NAMER_BIN" ] || _fail "missing $RBD_NAMER_BIN"
85 [ -f "$RBD_UDEV_RULES" ] || _fail "missing $RBD_UDEV_RULES"
86 [ -f "$CEPH_UDEV_RULES" ] || _fail "missing $CEPH_UDEV_RULES"
87 [ -f "$CEPH_DISK_SYSTEMD_SVC" ] \
88 || _fail "missing $CEPH_DISK_SYSTEMD_SVC"
89 [ -f "$CEPH_OSD_SYSTEMD_SVC" ] || _fail "missing $CEPH_OSD_SYSTEMD_SVC"
90 [ -f "$CEPH_BIN" ] || _fail "missing $CEPH_BIN"
91 [ -f "$CEPH_RBD_BIN" ] || _fail "missing $CEPH_RBD_BIN"
92 [ -f "$CEPH_MOUNT_BIN" ] || _fail "missing $CEPH_MOUNT_BIN"
93 [ -f "$CEPH_RADOS_BIN" ] || _fail "missing $CEPH_RADOS_BIN"
94 [ -f "$CEPH_FUSE_BIN" ] || _fail "missing $CEPH_FUSE_BIN"
95 [ -f "$CEPH_RADOS_LIB" ] || _fail "missing $CEPH_RADOS_LIB"
96 [ -f "$CEPH_RBD_LIB" ] || _fail "missing $CEPH_RBD_LIB"
97 [ -f "$CEPH_CONF" ] || _fail "missing $CEPH_CONF"
98 [ -f "$CEPH_KEYRING" ] || _fail "missing $CEPH_KEYRING"
101 function _rt_require_fstests() {
102 if [ -n "$FSTESTS_DIR" ]; then
103 # FSTESTS_DIR is an old config parameter which was used when
104 # Dracut didn't correctly install files directly nested under
105 # "--include <dir>" paths, only subdirectories were handled.
106 # To work around this, FSTESTS_DIR referred to a path with an
107 # immediate xfstests subdirectory.
108 [ -n "$FSTESTS_SRC" ] \
109 && _fail "both FSTESTS_DIR and FSTESTS_SRC defined"
110 FSTESTS_SRC="${FSTESTS_DIR}/xfstests"
111 _warn "FSTESTS_DIR deprecated, use FSTESTS_SRC=${FSTESTS_SRC}"
114 [ -n "$FSTESTS_SRC" ] || _fail "FSTESTS_SRC not configured"
115 [ -d "$FSTESTS_SRC" ] || _fail "missing $FSTESTS_SRC directory"
116 [ -x "$FSTESTS_SRC/check" ] || _fail "missing $FSTESTS_SRC/check"
119 function _rt_require_blktests() {
120 [ -n "$BLKTESTS_SRC" ] || _fail "BLKTESTS_SRC not configured"
121 [ -d "$BLKTESTS_SRC" ] || _fail "missing $BLKTESTS_SRC directory"
122 [ -x "$BLKTESTS_SRC/check" ] || _fail "missing $BLKTESTS_SRC/check"
125 function _rt_require_zram_params {
126 # initramfs ramdisk details
127 ZRAM_INITRD_SIZE="1G"
128 ZRAM_INITRD_MNT="$RAPIDO_DIR/initrds"
130 # ramdisk for vstart.sh logs and data
131 ZRAM_VSTART_OUT_SIZE="1G"
132 ZRAM_VSTART_DATA_SIZE="1G"
134 if [ -n "$CEPH_SRC" ]; then
135 if [ -f "${CEPH_SRC}/../build/CMakeCache.txt" ]; then
136 # with cmake, vstart.sh is triggered from the build dir
137 ZRAM_VSTART_OUT_MNT="${CEPH_SRC}/../build/out"
138 ZRAM_VSTART_DATA_MNT="${CEPH_SRC}/../build/dev"
140 # vstart.sh is triggered from the src dir
141 ZRAM_VSTART_OUT_MNT="${CEPH_SRC}/out"
142 ZRAM_VSTART_DATA_MNT="${CEPH_SRC}/dev"
145 [ -d "$ZRAM_VSTART_OUT_MNT" ] \
146 || _fail "missing $ZRAM_VSTART_OUT_MNT"
147 [ -d "$ZRAM_VSTART_DATA_MNT" ] \
148 || _fail "missing $ZRAM_VSTART_DATA_MNT"
152 function _rt_require_dracut_args() {
153 [ -f "${KERNEL_SRC}/include/config/kernel.release" ] \
154 || _fail "kernel.release file missing $KERNEL_SRC"
155 local kver="$(cat ${KERNEL_SRC}/include/config/kernel.release)"
157 local dracut_args="--no-compress --no-hostonly --no-hostonly-cmdline \
158 --force --tmpdir $RAPIDO_DIR/initrds/ \
161 # The optional KERNEL_INSTALL_MOD_PATH rapido.conf parameter can be used
162 # to specify where Dracut should try to pull built kernel modules from.
163 if [ -n "$KERNEL_INSTALL_MOD_PATH" ]; then
164 local kmoddir="$KERNEL_INSTALL_MOD_PATH/lib/modules/$kver"
166 || _fail "missing $kmoddir"
167 dracut_args="$dracut_args --kmoddir $kmoddir"
170 DRACUT_EXTRA_ARGS="$dracut_args"
173 function _rt_require_qemu_kvm_bin {
174 QEMU_KVM_BIN="$(which qemu-kvm 2>/dev/null)"
176 if [ -z "$QEMU_KVM_BIN" ]; then
177 # Debian uses kvm instead of qemu-kvm
178 QEMU_KVM_BIN="$(which kvm 2>/dev/null)"
181 [ -z "$QEMU_KVM_BIN" ] && _fail "missing qemu-kvm"
184 # initramfs output path
185 DRACUT_OUT="${RAPIDO_DIR}/initrds/myinitrd"
187 function _rt_xattr_qemu_args_set
191 local xattr_key="user.rapido.qemu_args"
193 [ -n "$img" ] || _fail "img parameter is manditory"
194 [ -f "$img" ] || _fail "no image at $img"
195 [ -n "$qemu_args" ] || _fail "qemu_args parameter is manditory"
197 setfattr -n "$xattr_key" -v "$qemu_args" $img \
198 || _fail "failed to set xattr on $img"
201 function _rt_xattr_qemu_args_get
204 local xattr_key="user.rapido.qemu_args"
206 [ -n "$img" ] || _fail "img parameter is manditory"
207 [ -f "$img" ] || _fail "no image at $img"
209 getfattr --only-values -n $xattr_key $img 2> /dev/null
212 function _rt_xattr_vm_networkless_set
215 local xattr_key="user.rapido.vm_networkless"
217 [ -n "$img" ] || _fail "img parameter is manditory"
218 [ -f "$img" ] || _fail "no image at $img"
220 setfattr -n "$xattr_key" -v "1" $img \
221 || _fail "failed to set xattr on $img"
224 function _rt_xattr_vm_networkless_get
227 local xattr_key="user.rapido.vm_networkless"
229 [ -n "$img" ] || _fail "img parameter is manditory"
230 [ -f "$img" ] || _fail "no image at $img"
232 getfattr --only-values -n $xattr_key $img 2> /dev/null
235 function _rt_xattr_vm_resources_set
240 local xattr_key="user.rapido.vm_resources"
243 [ -n "$img" ] || _fail "img parameter is manditory"
244 [ -f "$img" ] || _fail "no image at $img"
245 [[ $cpus =~ $re ]] || _fail "num CPUs must be numeric"
247 [[ $mem =~ $re ]] || _fail "invalid memory string: $mem"
249 setfattr -n "$xattr_key" -v "-smp cpus=${cpus} -m $mem" $img \
250 || _fail "failed to set xattr on $img"
253 function _rt_xattr_vm_resources_get
256 local xattr_key="user.rapido.vm_resources"
258 [ -n "$img" ] || _fail "img parameter is manditory"
259 [ -f "$img" ] || _fail "no image at $img"
261 getfattr --only-values -n $xattr_key $img 2> /dev/null