From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id E7E00E00D79; Wed, 11 May 2016 08:15:27 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low * trust * [98.136.218.80 listed in list.dnswl.org] * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider * (vaduvajanalexandru[at]yahoo.com) * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * 0.0 HTML_MESSAGE BODY: HTML included in message * -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's * domain * 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily * valid * -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Received: from nm1-vm1.bullet.mail.gq1.yahoo.com (nm1-vm1.bullet.mail.gq1.yahoo.com [98.136.218.80]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 81738E00CA1 for ; Wed, 11 May 2016 08:15:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1462979723; bh=mV5W2Wt7IwvNCXH7jkf5txCV7A9hhdUWSuKgakyjwSE=; h=Date:From:Reply-To:To:In-Reply-To:References:Subject:From:Subject; b=trEEtoJYvBNhOmt4I7CvNM3xtbccTo66tQrg5Hl72qw7ZB+y3/OkILykRqHOOY00BQgyzmDjb5wx3WnIwzXRlTrgUIAF1WopkRPnpK5Je3akLElRk/N+g0Nnr0OleLj/0BPAIE9woby8ijVZ1IH0LUk0P1Ak3qZoWFaO4tkf0yeMxZz23gfVHmSX2oEm+UHKNG/pKIxQemHdaRgiAFEu/k6qtjvcy1QAxQvzYWnQM7VdqFGgITWvmup+eG3d5URNBJsmrExQkLUKCICCJ5PzFbg3Eh6r3GkPLHJIofUR1W4g7cVivm4qno4+l8DVSxjUiT9zBUdPF/R+CRbmN+RNiQ== Received: from [98.137.12.59] by nm1.bullet.mail.gq1.yahoo.com with NNFMP; 11 May 2016 15:15:23 -0000 Received: from [98.137.12.207] by tm4.bullet.mail.gq1.yahoo.com with NNFMP; 11 May 2016 15:15:23 -0000 Received: from [127.0.0.1] by omp1015.mail.gq1.yahoo.com with NNFMP; 11 May 2016 15:15:23 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 631894.263.bm@omp1015.mail.gq1.yahoo.com X-YMail-OSG: REAvv1gVM1nZUV6Enrt_VTneDXQ2u9FVsdhMrQ0pSNR2dNmSzuCqv0Srlyw1NNy KXd6Jk9r0tWiCT.kSFfOxh2n.4EkiD3XhsoaxFq7Dl1M3l1T9L.ZoXqTU2MaVv2Tna.yFivpyeny .x0YvVEFl98B5Qi8lVnH5a5bICZa1tzBxwORvnMyE_Wt3HrOIL2OH1aea2TfyswMKlqQj3DHOy38 shIPtGstCv1GY7pRzCCCG0DBMBPwpMehEWcg..pRG_X7zhdFXUlghNmH5D.ednPv5QgP4GPjNm7V nihjQwBosPs7DrCzMiCzBCgZAORznyQG8LKAQpO4TRJ_4GSCcXeanmD_I2Bgw2ha.4.8QHuXYwYh vXdj0UDUFEmRXFDlsScbMYXzRwXemj37kZ85TT5m1H2rhzEqqwQZlBqXvUQqOkaDHM1.Gz_O2eEl g_rObChhLxfqQVjbgIu5cHOsoJoQt3p8i3uccd3DEikQDT1LKGZcxRDJVHbld6DPwok47cGQ2lVJ NxC54sjK93x0u7sc- Received: from jws10715.mail.gq1.yahoo.com by sendmailws147.mail.gq1.yahoo.com; Wed, 11 May 2016 15:15:23 +0000; 1462979723.054 Date: Wed, 11 May 2016 15:15:22 +0000 (UTC) From: Alexandru Vaduva To: Adrian Dudau , "yocto@yoctoproject.org" Message-ID: <1765661136.531886.1462979722629.JavaMail.yahoo@mail.yahoo.com> In-Reply-To: <1462874748-57412-1-git-send-email-adrian.dudau@enea.com> References: <1462874748-57412-1-git-send-email-adrian.dudau@enea.com> MIME-Version: 1.0 Subject: Re: [meta-cgl][PATCH 1/2] Added device manager multipath support for root file system X-BeenThere: yocto@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: Alexandru Vaduva List-Id: Discussion of all things Yocto Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 May 2016 15:15:28 -0000 Content-Type: multipart/alternative; boundary="----=_Part_531885_1116036630.1462979722621" ------=_Part_531885_1116036630.1462979722621 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hello Adi,=C2=A0Cannot this two patches be redone by:=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 removingfro= m =C2=A0"[PATCH 1/2] Added devicemanager multipath support for root file sy= stem" the line "+IMAGE_CLASSES+=3D "image_types_uboot""=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 onlykeep= ing in "[PATCH 2/2] distro: Move IMAGE_CLASSES inheritance" =C2=A0the line = from " poky-cgl.conf". Also this patch has both require and inherit and in myopinion the inherit l= ine can be removed since the core-image-cgl also adds itindirectly. Another objection for this patch is that it should be brokenin more pieces:= multipath, images, initrdscripts and conf_setup or in anotherformat. Havin= g it like this is too big and in case of a revert too muchfunctionality cou= ld be lost or replicated.=C2=A0=C2=A0Thanks,Alex V.=20 On Tuesday, May 10, 2016 1:08 PM, Adrian Dudau = wrote: =20 From: Mats Liljegren This is implemented using an initramfs, built by core-image-cgl-initramfs i= mage recipe. Multipath device configurations are done using kernel boot paramete= rs. The multipath-root-howto.md explains how to use this. Also note that the meta-cgl/scripts/conf_setup.sh will now also add a BBMAS= K entry to mask out the meta-virtualization's version of multipath-tools, sin= ce we need the newer recipe in the meta-openembedded/meta-oe instead. Signed-off-by: Mats Liljegren Signed-off-by: Adrian Dudau --- meta-cgl-common/images/core-image-cgl-initramfs.bb |=C2=A0 22 +++ meta-cgl-common/images/core-image-cgl.bb=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= |=C2=A0 2 + .../packagegroups/packagegroup-cgl-middleware.bb=C2=A0 |=C2=A0 8 +- .../recipes-core/initrdscripts/files/init-boot.sh=C2=A0 | 179 ++++++++++++= +++++++++ .../initrdscripts/initramfs-cgl-boot_1.0.bb=C2=A0 =C2=A0 =C2=A0 =C2=A0 |= =C2=A0 14 ++ scripts/conf_setup.sh=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 2 + 6 files changed, 220 insertions(+), 7 deletions(-) create mode 100644 meta-cgl-common/images/core-image-cgl-initramfs.bb create mode 100644 meta-cgl-common/recipes-core/initrdscripts/files/init-b= oot.sh create mode 100644 meta-cgl-common/recipes-core/initrdscripts/initramfs-cg= l-boot_1.0.bb create mode 100755 scripts/conf_setup.sh diff --git a/meta-cgl-common/images/core-image-cgl-initramfs.bb b/meta-cgl-= common/images/core-image-cgl-initramfs.bb new file mode 100644 index 0000000..845fa07 --- /dev/null +++ b/meta-cgl-common/images/core-image-cgl-initramfs.bb @@ -0,0 +1,22 @@ +require core-image-cgl.bb + +# Recipe is based on core-image-minimal.bb +DESCRIPTION =3D "Initramfs used to mount multipath device as root file sys= tem" + +PACKAGE_INSTALL =3D "initramfs-cgl-boot busybox base-passwd udev ${ROOTFS_= BOOTSTRAP_INSTALL}" + +# Do not pollute the initrd image with rootfs features +IMAGE_FEATURES =3D "" + +export IMAGE_BASENAME =3D "core-image-cgl-initramfs" +IMAGE_LINGUAS =3D "" + +LICENSE =3D "MIT" + +IMAGE_FSTYPES =3D "cpio.gz.u-boot" +IMAGE_CLASSES +=3D "image_types_uboot" +inherit core-image + +IMAGE_ROOTFS_SIZE =3D "8192" + +BAD_RECOMMENDATIONS +=3D "busybox-syslog" diff --git a/meta-cgl-common/images/core-image-cgl.bb b/meta-cgl-common/ima= ges/core-image-cgl.bb index d12391b..5975601 100644 --- a/meta-cgl-common/images/core-image-cgl.bb +++ b/meta-cgl-common/images/core-image-cgl.bb @@ -21,6 +21,8 @@ IMAGE_INSTALL +=3D "\ =C2=A0 =C2=A0 kernel-modules \ =C2=A0 =C2=A0 " =20 +IMAGE_FSTYPES +=3D " ext3.gz" + # kexec-tools doesn't work on Mips KEXECTOOLS_mips ?=3D "" KEXECTOOLS_mipsel ?=3D "" diff --git a/meta-cgl-common/packagegroups/packagegroup-cgl-middleware.bb b= /meta-cgl-common/packagegroups/packagegroup-cgl-middleware.bb index 448e038..b0c2cac 100644 --- a/meta-cgl-common/packagegroups/packagegroup-cgl-middleware.bb +++ b/meta-cgl-common/packagegroups/packagegroup-cgl-middleware.bb @@ -18,14 +18,8 @@ DHCP =3D " \ =C2=A0 =C2=A0 " =20 MULTIPATH_TOOLS =3D " \ -=C2=A0 =C2=A0 libmpathpersist \ -=C2=A0 =C2=A0 mpathpersist \ +=C2=A0 =C2=A0 multipath-tools \ =C2=A0 =C2=A0 kpartx \ -=C2=A0 =C2=A0 libmultipath \ -=C2=A0 =C2=A0 multipath \ -=C2=A0 =C2=A0 multipathd \ -=C2=A0 =C2=A0 libmultipath-dev \ -=C2=A0 =C2=A0 libmpathpersist-dev \ =C2=A0 =C2=A0 " =20 RDEPENDS_packagegroup-cgl-middleware =3D "\ diff --git a/meta-cgl-common/recipes-core/initrdscripts/files/init-boot.sh = b/meta-cgl-common/recipes-core/initrdscripts/files/init-boot.sh new file mode 100644 index 0000000..fcadfc6 --- /dev/null +++ b/meta-cgl-common/recipes-core/initrdscripts/files/init-boot.sh @@ -0,0 +1,179 @@ +#!/bin/sh -eu + +# Fail function, either called explicitly or when shell will quit +fail () { +=C2=A0 =C2=A0 # Avoid recursive traps +=C2=A0 =C2=A0 trap '' ERR EXIT + +=C2=A0 =C2=A0 # If message provided, print it +=C2=A0 =C2=A0 [ -n '${1:-}' ] && echo $@ + +=C2=A0 =C2=A0 # Generic error message and shell access +=C2=A0 =C2=A0 echo "Error occured, giving a shell" +=C2=A0 =C2=A0 exec sh +} + +trap fail ERR EXIT + +interrupt () { +=C2=A0 =C2=A0 echo "User interrupt received, giving a shell. When exiting = shell, execution will continue." +=C2=A0 =C2=A0 sh +} + +trap interrupt INT + +# Find session ID for an iSCSI disk given its IQN name +iqn_to_sid () { +=C2=A0 =C2=A0 iscsiadm -m session | fgrep $1 | sed -r 's/.*\[([0-9])\].*/\= 1/' +} + +# Find device name, without path, for an iSCSI disk given its IQN name +iqn_to_dev () { +=C2=A0 =C2=A0 iscsiadm -m session -r $(iqn_to_sid $1) -P3 | sed -rn 's/.*A= ttached scsi disk ([a-zA-Z0-9_]+).*/\1/p' +} + +# Parse input parameters expecting name=3Dvalue pairs. +# Name only matches known parameters. +# On match, set variable to value . +# E.g. given "parse_cmdline trythis=3D"ok, do it" +# the shell variable "trythis" will now have the value "ok, do it". +parse_cmdline () { +=C2=A0 =C2=A0 iscsi_chap_user=3D"" +=C2=A0 =C2=A0 iscsi_chap_pwd=3D"" +=C2=A0 =C2=A0 iscsi_dev=3D"" +=C2=A0 =C2=A0 iscsi_debug=3D0 + +=C2=A0 =C2=A0 while [ -n "${1:-}" ]; do +=C2=A0 =C2=A0 =C2=A0 =C2=A0 name=3D"${1%%=3D*}" +=C2=A0 =C2=A0 =C2=A0 =C2=A0 val=3D"${1#*=3D}" +=C2=A0 =C2=A0 =C2=A0 =C2=A0 case $name in +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 iscsi_chap_user|iscsi_chap_pw) +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 eval $name=3D\"$va= l\";; +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 iscsi_dev) +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 eval $name=3D\"$is= csi_dev $val\" +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 iscsi_debug) +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 set -x +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 iscsi_debug=3D1 +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; +=C2=A0 =C2=A0 =C2=A0 =C2=A0 esac +=C2=A0 =C2=A0 =C2=A0 =C2=A0 shift +=C2=A0 =C2=A0 done + +=C2=A0 =C2=A0 [ -n "${iscsi_dev}" ] || fail "Mandatory kernel boot paramet= er 'iscsi_dev' not given." + +} + +PATH=3D/sbin:/bin:/usr/sbin:/usr/bin + +echo "Mounting /proc" +mount -t proc proc /proc + +KERNEL_CMDLINE=3D"$(cat /proc/cmdline)" + +echo "Parsing kernel parameters" +parse_cmdline $KERNEL_CMDLINE + +echo "Mounting /sys" +mount -t sysfs sysfs /sys + +# udev is needed for multipath +echo "Starting udev" +/etc/init.d/udev start + +# Add CHAP autenthication, if given as kernel boot parameters +echo "Configuring iSCSI" +[ -n "$iscsi_chap_user" -o -n "$iscsi_chap_pw" ] && cat <> /etc/iscs= i/iscsid.conf +node.session.auth.authmethod =3D CHAP +EOF +[ -n "$iscsi_chap_user" ] && cat <> /etc/iscsi/iscsid.conf +node.session.auth.username =3D $iscsi_chap_user +EOF +[ -n "$iscsi_chap_pw" ] && cat <> /etc/iscsi/iscsid.conf +node.session.auth.password =3D $iscsi_chap_pw +EOF + +echo >> /etc/iscsi/iscsid.conf + +echo "Starting iSCSI daemon" +/etc/init.d/iscsid restart + +echo "Discovering iSCSI devices" + +for dev in $iscsi_dev; do +=C2=A0 =C2=A0 target_ip=3D"${dev%%:*}" +=C2=A0 =C2=A0 dev_name=3D"${dev#*:}" +=C2=A0 =C2=A0 echo "Logging in to iscsi devices: $dev_name, target: $targe= t_ip" +=C2=A0 =C2=A0 iscsiadm --mode discoverydb --type sendtargets --discover --= portal $target_ip +=C2=A0 =C2=A0 iscsiadm --mode node --targetname $dev_name --login --portal= $target_ip +done + +echo "Configuring multipath" +cat < /etc/multipath.conf +defaults { +=C2=A0 =C2=A0 =C2=A0 =C2=A0 path_grouping_policy=C2=A0 =C2=A0 multibus +=C2=A0 =C2=A0 =C2=A0 =C2=A0 # If no path, then queue requests +=C2=A0 =C2=A0 =C2=A0 =C2=A0 no_path_retry queue +} +devices { +=C2=A0 =C2=A0 =C2=A0 =C2=A0 device { +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 vendor=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 IET +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 product=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 VIRTUAL-DISK +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 path_grouping_poli= cy=C2=A0 =C2=A0 multibus +=C2=A0 =C2=A0 =C2=A0 =C2=A0 } +} +blacklist { +=C2=A0 =C2=A0 =C2=A0 =C2=A0 devnode ".*" +} +blacklist_exceptions { +$(for dev in $iscsi_dev; do +=C2=A0 =C2=A0 echo "=C2=A0 =C2=A0 =C2=A0 =C2=A0 devnode=C2=A0 \"^$(iqn_to_= dev ${dev#*:})\"" +=C2=A0 done) +=C2=A0 =C2=A0 =C2=A0 =C2=A0 property=C2=A0 ".*" +} +EOF + +echo "Starting multipath daemon" +# Make sure lock file directory exists +mkdir -p /var/lock/subsys/multipathd +/etc/init.d/multipathd start + +mpath_template=3D'/dev/disk/by-id/dm-uuid-mpath-*' + +echo "Waiting for mpath device to appear" +while [ -z "$(ls $mpath_template 2>/dev/null)" ]; do +=C2=A0 =C2=A0 sleep 1 +done +MPATH_DEV=3D"$(ls $mpath_template)" +echo "mpath device: $MPATH_DEV" + +echo "Mounting mpath device $MPATH_DEV" +mount $MPATH_DEV /mnt + +echo "Stopping multipath daemon" +# Should be using "/etc/init.d/multipathd stop", but did not work. +# Got "killall: /sbin/multipathd: no process killed". +# Kill the process based on the saved pid. +kill $(cat /run/multipathd.pid) + +echo "Moving iscsi pid and lock files" +cp /run/iscsid.pid /mnt/run/iscsid.pid +cp /run/lock/iscsi/* /mnt/run/lock/iscsi + +# In case iscsi_debug is given, open a shell at this point +if [ $iscsi_debug -eq 1 ]; then +=C2=A0 =C2=A0 echo "iscsi_debug given, opening a shell. When exiting shell= , boot will continue." +=C2=A0 =C2=A0 sh +fi + +# udev needs to be restart when real init runs, so stop it +echo "Stopping udev" +/etc/init.d/udev stop + +echo "Moving sys, proc and dev mounts to new root" +mount --move /sys /mnt/sys +mount --move /proc /mnt/proc +mount --move /dev /mnt/dev + +echo "Switching to new root" +exec switch_root /mnt /sbin/init $KERNEL_CMDLINE diff --git a/meta-cgl-common/recipes-core/initrdscripts/initramfs-cgl-boot_= 1.0.bb b/meta-cgl-common/recipes-core/initrdscripts/initramfs-cgl-boot_1.0.= bb new file mode 100644 index 0000000..5265bf0 --- /dev/null +++ b/meta-cgl-common/recipes-core/initrdscripts/initramfs-cgl-boot_1.0.bb @@ -0,0 +1,14 @@ +SUMMARY =3D "Support for having multipath iSCSI devices as root file syste= m" +LICENSE =3D "MIT" +LIC_FILES_CHKSUM =3D "file://${COREBASE}/meta-cgl/COPYING.MIT;md5=3D838c36= 6f69b72c5df05c96dff79b35f2" +SRC_URI =3D "file://init-boot.sh" + +do_install() { +=C2=A0 =C2=A0 =C2=A0 =C2=A0 install -m 0755 ${WORKDIR}/init-boot.sh ${D}/i= nit +} + +inherit allarch + +RDEPENDS_${PN} +=3D "multipath-tools kpartx iscsi-initiator-utils" + +FILES_${PN} +=3D " /init " diff --git a/scripts/conf_setup.sh b/scripts/conf_setup.sh new file mode 100755 index 0000000..aad8e71 --- /dev/null +++ b/scripts/conf_setup.sh @@ -0,0 +1,2 @@ +#!/bin/bash +echo -e '\nBBMASK =3D "meta-virtualization/recipes-extended/multipath-tool= s/multipath-tools_git.bb"' >> conf/local.conf --=20 1.9.1 --=20 _______________________________________________ yocto mailing list yocto@yoctoproject.org https://lists.yoctoproject.org/listinfo/yocto ------=_Part_531885_1116036630.1462979722621 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hello Adi,
 
Cannot this two patches b= e redone by:
    = ;           removi= ng from  "[PATCH 1/2] Added device manager multipath support for root file system" the line "+IMAGE_CLASSES +=3D "image_types_uboot""
    = ;           only keeping in "[PATCH 2/2] distro: Move IMAGE_CLASSES inheritance"  the line from " poky-cgl.conf".

Also this patch has both = require and inherit and in my opinion the inherit line can be removed since the core-image-cgl also adds = it indirectly.

Another objection for thi= s patch is that it should be broken in more pieces: multipath, images, initrdscripts and conf_setup or in anoth= er format. Having it like this is too big and in case of a revert too much functionality could be lost or replicated.
 
 
Thanks,
Alex V.


On Tuesday, May 10, 2016 1:08 PM, Adrian Dudau <= adrian.dudau@enea.com> wrote:


From: Mats Liljegren <mats.liljegren@enea.com= >

This is implemented using an initramfs, built by core-image= -cgl-initramfs image
recipe. Multipath device configurations are done us= ing kernel boot parameters.
The multipath-root-howto.md explains how to = use this.

Also note that the meta-cgl/scripts/conf_setup.sh will now= also add a BBMASK
entry to mask out the meta-virtualization's version o= f multipath-tools, since
we need the newer recipe in the meta-openembedd= ed/meta-oe instead.

Signed-off-by: Mats Liljegren <mat= s.liljegren@enea.com>
Signed-off-by: Adrian Dudau <adr= ian.dudau@enea.com>
---
meta-cgl-common/images/core-image-cgl= -initramfs.bb |  22 +++
meta-cgl-common/images/core-image-cgl.bb&n= bsp;         |  2 +
.../packagegroups/packag= egroup-cgl-middleware.bb  |  8 +-
.../recipes-core/initrdsc= ripts/files/init-boot.sh  | 179 +++++++++++++++++++++
.../initrdsc= ripts/initramfs-cgl-boot_1.0.bb        |  14 ++ scripts/conf_setup.sh              &nb= sp;               |  2 +
6 fil= es changed, 220 insertions(+), 7 deletions(-)
create mode 100644 meta-c= gl-common/images/core-image-cgl-initramfs.bb
create mode 100644 meta-cg= l-common/recipes-core/initrdscripts/files/init-boot.sh
create mode 1006= 44 meta-cgl-common/recipes-core/initrdscripts/initramfs-cgl-boot_1.0.bb
= create mode 100755 scripts/conf_setup.sh

diff --git a/meta-cgl-comm= on/images/core-image-cgl-initramfs.bb b/meta-cgl-common/images/core-image-c= gl-initramfs.bb
new file mode 100644
index 0000000..845fa07
--- /d= ev/null
+++ b/meta-cgl-common/images/core-image-cgl-initramfs.bb
@@ -= 0,0 +1,22 @@
+require core-image-cgl.bb
+
+# Recipe is based on co= re-image-minimal.bb
+DESCRIPTION =3D "Initramfs used to mount multipath = device as root file system"
+
+PACKAGE_INSTALL =3D "initramfs-cgl-boo= t busybox base-passwd udev ${ROOTFS_BOOTSTRAP_INSTALL}"
+
+# Do not p= ollute the initrd image with rootfs features
+IMAGE_FEATURES =3D ""
+=
+export IMAGE_BASENAME =3D "core-image-cgl-initramfs"
+IMAGE_LINGUAS= =3D ""
+
+LICENSE =3D "MIT"
+
+IMAGE_FSTYPES =3D "cpio.gz.u-bo= ot"
+IMAGE_CLASSES +=3D "image_types_uboot"
+inherit core-image
+<= br>+IMAGE_ROOTFS_SIZE =3D "8192"
+
+BAD_RECOMMENDATIONS +=3D "busybox= -syslog"
diff --git a/meta-cgl-common/images/core-image-cgl.bb b/meta-cg= l-common/images/core-image-cgl.bb
index d12391b..5975601 100644
--- a= /meta-cgl-common/images/core-image-cgl.bb
+++ b/meta-cgl-common/images/c= ore-image-cgl.bb
@@ -21,6 +21,8 @@ IMAGE_INSTALL +=3D "\
   = ; kernel-modules \
    "

+IMAGE_FSTYPES +=3D " ext3.= gz"
+
# kexec-tools doesn't work on Mips
KEXECTOOLS_mips ?=3D ""=
KEXECTOOLS_mipsel ?=3D ""
diff --git a/meta-cgl-common/packagegroup= s/packagegroup-cgl-middleware.bb b/meta-cgl-common/packagegroups/packagegro= up-cgl-middleware.bb
index 448e038..b0c2cac 100644
--- a/meta-cgl-com= mon/packagegroups/packagegroup-cgl-middleware.bb
+++ b/meta-cgl-common/p= ackagegroups/packagegroup-cgl-middleware.bb
@@ -18,14 +18,8 @@ DHCP =3D = " \
    "

MULTIPATH_TOOLS =3D " \
-    = libmpathpersist \
-    mpathpersist \
+    multip= ath-tools \
    kpartx \
-    libmultipath \
= -    multipath \
-    multipathd \
-   = libmultipath-dev \
-    libmpathpersist-dev \
   = ; "

RDEPENDS_packagegroup-cgl-middleware =3D "\
diff --git a/m= eta-cgl-common/recipes-core/initrdscripts/files/init-boot.sh b/meta-cgl-com= mon/recipes-core/initrdscripts/files/init-boot.sh
new file mode 100644index 0000000..fcadfc6
--- /dev/null
+++ b/meta-cgl-common/recipes-= core/initrdscripts/files/init-boot.sh
@@ -0,0 +1,179 @@
+#!/bin/sh -e= u
+
+# Fail function, either called explicitly or when shell will qui= t
+fail () {
+    # Avoid recursive traps
+   = trap '' ERR EXIT
+
+    # If message provided, print it+    [ -n '${1:-}' ] && echo $@
+
+    #= Generic error message and shell access
+    echo "Error occur= ed, giving a shell"
+    exec sh
+}
+
+trap fail ERR = EXIT
+
+interrupt () {
+    echo "User interrupt receive= d, giving a shell. When exiting shell, execution will continue."
+ =   sh
+}
+
+trap interrupt INT
+
+# Find session ID for= an iSCSI disk given its IQN name
+iqn_to_sid () {
+    isc= siadm -m session | fgrep $1 | sed -r 's/.*\[([0-9])\].*/\1/'
+}
+
= +# Find device name, without path, for an iSCSI disk given its IQN name
= +iqn_to_dev () {
+    iscsiadm -m session -r $(iqn_to_sid $1) = -P3 | sed -rn 's/.*Attached scsi disk ([a-zA-Z0-9_]+).*/\1/p'
+}
++# Parse input parameters expecting name=3Dvalue pairs.
+# Name only ma= tches known parameters.
+# On match, set variable <name> to value = <value>.
+# E.g. given "parse_cmdline trythis=3D"ok, do it"
+# = the shell variable "trythis" will now have the value "ok, do it".
+parse= _cmdline () {
+    iscsi_chap_user=3D""
+    iscs= i_chap_pwd=3D""
+    iscsi_dev=3D""
+    iscsi_de= bug=3D0
+
+    while [ -n "${1:-}" ]; do
+    =     name=3D"${1%%=3D*}"
+        val=3D"${= 1#*=3D}"
+        case $name in
+    &n= bsp;       iscsi_chap_user|iscsi_chap_pw)
+    =             eval $name=3D\"$val\";;
+ = ;           iscsi_dev)
+      &n= bsp;         eval $name=3D\"$iscsi_dev $val\"
+ = ;               ;;
+    &nb= sp;       iscsi_debug)
+         = ;       set -x
+           =     iscsi_debug=3D1
+           = ;     ;;
+        esac
+    &= nbsp;   shift
+    done
+
+    [ -n "${is= csi_dev}" ] || fail "Mandatory kernel boot parameter 'iscsi_dev' not given.= "
+
+}
+
+PATH=3D/sbin:/bin:/usr/sbin:/usr/bin
+
+echo "M= ounting /proc"
+mount -t proc proc /proc
+
+KERNEL_CMDLINE=3D"$(ca= t /proc/cmdline)"
+
+echo "Parsing kernel parameters"
+parse_cmdli= ne $KERNEL_CMDLINE
+
+echo "Mounting /sys"
+mount -t sysfs sysfs /= sys
+
+# udev is needed for multipath
+echo "Starting udev"
+/e= tc/init.d/udev start
+
+# Add CHAP autenthication, if given as kernel= boot parameters
+echo "Configuring iSCSI"
+[ -n "$iscsi_chap_user" -= o -n "$iscsi_chap_pw" ] && cat <<EOF >> /etc/iscsi/iscs= id.conf
+node.session.auth.authmethod =3D CHAP
+EOF
+[ -n "$iscsi_= chap_user" ] && cat <<EOF >> /etc/iscsi/iscsid.conf
= +node.session.auth.username =3D $iscsi_chap_user
+EOF
+[ -n "$iscsi_c= hap_pw" ] && cat <<EOF >> /etc/iscsi/iscsid.conf
+no= de.session.auth.password =3D $iscsi_chap_pw
+EOF
+
+echo >> = /etc/iscsi/iscsid.conf
+
+echo "Starting iSCSI daemon"
+/etc/init.= d/iscsid restart
+
+echo "Discovering iSCSI devices"
+
+for dev= in $iscsi_dev; do
+    target_ip=3D"${dev%%:*}"
+  &n= bsp; dev_name=3D"${dev#*:}"
+    echo "Logging in to iscsi dev= ices: $dev_name, target: $target_ip"
+    iscsiadm --mode disc= overydb --type sendtargets --discover --portal $target_ip
+   = iscsiadm --mode node --targetname $dev_name --login --portal $target_ip+done
+
+echo "Configuring multipath"
+cat <<EOF > /etc/= multipath.conf
+defaults {
+        path_grouping= _policy    multibus
+        # If no path,= then queue requests
+        no_path_retry queue+}
+devices {
+        device {
+   = ;             vendor      &nbs= p;           IET
+        &= nbsp;       product           =     VIRTUAL-DISK
+            =     path_grouping_policy    multibus
+    =     }
+}
+blacklist {
+        devno= de ".*"
+}
+blacklist_exceptions {
+$(for dev in $iscsi_dev; do+    echo "        devnode  \"^$(iqn_t= o_dev ${dev#*:})\""
+  done)
+        proper= ty  ".*"
+}
+EOF
+
+echo "Starting multipath daemon"
+#= Make sure lock file directory exists
+mkdir -p /var/lock/subsys/multipa= thd
+/etc/init.d/multipathd start
+
+mpath_template=3D'/dev/disk/b= y-id/dm-uuid-mpath-*'
+
+echo "Waiting for mpath device to appear"+while [ -z "$(ls $mpath_template 2>/dev/null)" ]; do
+   = sleep 1
+done
+MPATH_DEV=3D"$(ls $mpath_template)"
+echo "mpath d= evice: $MPATH_DEV"
+
+echo "Mounting mpath device $MPATH_DEV"
+mou= nt $MPATH_DEV /mnt
+
+echo "Stopping multipath daemon"
+# Should b= e using "/etc/init.d/multipathd stop", but did not work.
+# Got "killall= : /sbin/multipathd: no process killed".
+# Kill the process based on the= saved pid.
+kill $(cat /run/multipathd.pid)
+
+echo "Moving iscsi= pid and lock files"
+cp /run/iscsid.pid /mnt/run/iscsid.pid
+cp /run= /lock/iscsi/* /mnt/run/lock/iscsi
+
+# In case iscsi_debug is given, = open a shell at this point
+if [ $iscsi_debug -eq 1 ]; then
+  &= nbsp; echo "iscsi_debug given, opening a shell. When exiting shell, boot wi= ll continue."
+    sh
+fi
+
+# udev needs to be resta= rt when real init runs, so stop it
+echo "Stopping udev"
+/etc/init.d= /udev stop
+
+echo "Moving sys, proc and dev mounts to new root"
+= mount --move /sys /mnt/sys
+mount --move /proc /mnt/proc
+mount --mov= e /dev /mnt/dev
+
+echo "Switching to new root"
+exec switch_root = /mnt /sbin/init $KERNEL_CMDLINE
diff --git a/meta-cgl-common/recipes-cor= e/initrdscripts/initramfs-cgl-boot_1.0.bb b/meta-cgl-common/recipes-core/in= itrdscripts/initramfs-cgl-boot_1.0.bb
new file mode 100644
index 0000= 000..5265bf0
--- /dev/null
+++ b/meta-cgl-common/recipes-core/initrds= cripts/initramfs-cgl-boot_1.0.bb
@@ -0,0 +1,14 @@
+SUMMARY =3D "Suppo= rt for having multipath iSCSI devices as root file system"
+LICENSE =3D = "MIT"
+LIC_FILES_CHKSUM =3D "file://${COREBASE}/meta-cgl/COPYING.MIT;md5= =3D838c366f69b72c5df05c96dff79b35f2"
+SRC_URI =3D "file://init-boot.sh"<= br>+
+do_install() {
+        install -m 0755 ${W= ORKDIR}/init-boot.sh ${D}/init
+}
+
+inherit allarch
+
+RDEP= ENDS_${PN} +=3D "multipath-tools kpartx iscsi-initiator-utils"
+
+FIL= ES_${PN} +=3D " /init "
diff --git a/scripts/conf_setup.sh b/scripts/con= f_setup.sh
new file mode 100755
index 0000000..aad8e71
--- /dev/nu= ll
+++ b/scripts/conf_setup.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+ec= ho -e '\nBBMASK =3D "meta-virtualization/recipes-extended/multipath-tools/m= ultipath-tools_git.bb"' >> conf/local.conf
--
1.9.1

-- =
_______________________________________________
yocto mailing listyocto@yoctoproject.org
https://lists.yoctoproject.org/li= stinfo/yocto


------=_Part_531885_1116036630.1462979722621--