3 # Copyright (C) SUSE LINUX GmbH 2016, all rights reserved.
5 # This library is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU Lesser General Public License as published
7 # by the Free Software Foundation; either version 2.1 of the License, or
8 # (at your option) version 3.
10 # This library is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
13 # License for more details.
15 if [ ! -f /vm_autorun.env ]; then
16 echo "Error: autorun scripts must be run from within an initramfs VM"
24 # this path is reliant on the rbd udev rule to setup the link
25 CEPH_RBD_DEV=/dev/rbd/${CEPH_RBD_POOL}/${CEPH_RBD_IMAGE}
27 #### start udevd, otherwise rbd hangs in wait_for_udev_add()
28 ps -eo args | grep -v grep | grep /usr/lib/systemd/systemd-udevd \
29 || /usr/lib/systemd/systemd-udevd --daemon
32 cat /proc/mounts | grep debugfs &> /dev/null
34 mount -t debugfs debugfs /sys/kernel/debug/
37 # mount configfs first
38 cat /proc/mounts | grep configfs &> /dev/null
40 mount -t configfs configfs /sys/kernel/config/
44 _ini_parse "/etc/ceph/keyring" "client.${CEPH_USER}" "key"
45 [ -z "$key" ] && _fatal "client.${CEPH_USER} key not found in keyring"
46 if [ -z "$CEPH_MON_NAME" ]; then
47 # pass global section and use mon_host
48 _ini_parse "/etc/ceph/ceph.conf" "global" "mon_host"
49 MON_ADDRESS="$mon_host"
51 _ini_parse "/etc/ceph/ceph.conf" "mon.${CEPH_MON_NAME}" "mon_addr"
52 MON_ADDRESS="$mon_addr"
55 echo -n "$MON_ADDRESS name=${CEPH_USER},secret=$key \
56 $CEPH_RBD_POOL $CEPH_RBD_IMAGE -" \
57 > /sys/bus/rbd/add || _fatal "RBD map failed"
58 udevadm settle || _fatal
60 # confirm that udev brought up the $pool/$img device path link
61 [ -L $CEPH_RBD_DEV ] || _fatal
64 cat /proc/mounts | grep debugfs &> /dev/null
66 mount -t debugfs debugfs /sys/kernel/debug/
69 for i in $DYN_DEBUG_MODULES; do
70 echo "module $i +pf" > /sys/kernel/debug/dynamic_debug/control || _fatal
72 for i in $DYN_DEBUG_FILES; do
73 echo "file $i +pf" > /sys/kernel/debug/dynamic_debug/control || _fatal
76 mkdir -p /sys/kernel/config/nvmet/subsystems/nvmf-test
77 cd /sys/kernel/config/nvmet/subsystems/nvmf-test
78 echo 1 > attr_allow_any_host
81 echo -n $CEPH_RBD_DEV > device_path
84 mkdir /sys/kernel/config/nvmet/ports/1
85 cd /sys/kernel/config/nvmet/ports/1
86 echo loop > addr_trtype
88 ln -s /sys/kernel/config/nvmet/subsystems/nvmf-test subsystems/nvmf-test
90 echo "transport=loop,nqn=nvmf-test" > /dev/nvme-fabrics
94 echo "RBD mapped at: $CEPH_RBD_DEV, NVMe mapped"