[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [stage1-xen (RFC) PATCH 06/10] build/fedora: Add `xen-unstable-runit/*` scripts



On Mon, 21 Aug 2017, Rajiv Ranganath wrote:
> From: Rajiv M Ranganath <rajiv.ranganath@xxxxxxxxxxx>
> 
> 
> ---
>  build/fedora/xen-unstable-runit/setup.sh           |   21 
> ++++++++++++++++++++
>  build/fedora/xen-unstable-runit/teardown.sh        |   21 
> ++++++++++++++++++++
>  .../xen-init-dom0-disk-backend/run                 |    8 ++++++++
>  build/fedora/xen-unstable-runit/xen-init-dom0/run  |    6 ++++++
>  build/fedora/xen-unstable-runit/xenconsoled/run    |   10 ++++++++++
>  build/fedora/xen-unstable-runit/xenstored/run      |   20 +++++++++++++++++++
>  6 files changed, 86 insertions(+)
>  create mode 100755 build/fedora/xen-unstable-runit/setup.sh
>  create mode 100755 build/fedora/xen-unstable-runit/teardown.sh
>  create mode 100755 
> build/fedora/xen-unstable-runit/xen-init-dom0-disk-backend/run
>  create mode 100755 build/fedora/xen-unstable-runit/xen-init-dom0/run
>  create mode 100755 build/fedora/xen-unstable-runit/xenconsoled/run
>  create mode 100755 build/fedora/xen-unstable-runit/xenstored/run
> 
> diff --git a/build/fedora/xen-unstable-runit/setup.sh 
> b/build/fedora/xen-unstable-runit/setup.sh
> new file mode 100755
> index 0000000..16699be
> --- /dev/null
> +++ b/build/fedora/xen-unstable-runit/setup.sh
> @@ -0,0 +1,21 @@
> +#!/bin/bash
> +
> +set -e
> +set -o pipefail

In most of my script I tend not to use pipefail because if I use a pipe
is exactly because one of the commands might fail. I do it on purpose.
This script doesn't even have any pipes, I would drop it.


> +# runit RPM creates `/etc/service` directory
> +if [ ! -d "/etc/service" ]; then
> +    echo "/etc/service directory not found. Please install runit RPM."
> +    exit 1
> +fi
> +
> +runit_services="xenconsoled xen-init-dom0 xen-init-dom0-disk-backend 
> xenstored"
> +
> +pushd /etc/service > /dev/null
> +for service in $runit_services; do
> +    ln -sf /opt/xen-unstable-runit/$service $service
> +done
> +popd > /dev/null

pushd and popd are not useful in this script, I would remove them


> +echo "Successfully created symlinks in /etc/service directory."
> +exit 0
> diff --git a/build/fedora/xen-unstable-runit/teardown.sh 
> b/build/fedora/xen-unstable-runit/teardown.sh
> new file mode 100755
> index 0000000..c0895f4
> --- /dev/null
> +++ b/build/fedora/xen-unstable-runit/teardown.sh
> @@ -0,0 +1,21 @@
> +#!/bin/bash
> +
> +set -e
> +set -o pipefail

same comment on pipefail


> +# runit RPM creates `/etc/service` directory
> +if [ ! -d "/etc/service" ]; then
> +    echo "/etc/service directory not found."
> +    exit 1
> +fi
> +
> +runit_services="xenconsoled xen-init-dom0 xen-init-dom0-disk-backend 
> xenstored"
> +
> +pushd /etc/service > /dev/null
> +for service in $runit_services; do
> +    rm -f $service
> +done
> +popd > /dev/null

same comment on pushd and popd


> +echo "Successfully deleted symlinks in /etc/service directory."
> +exit 0
> diff --git a/build/fedora/xen-unstable-runit/xen-init-dom0-disk-backend/run 
> b/build/fedora/xen-unstable-runit/xen-init-dom0-disk-backend/run
> new file mode 100755
> index 0000000..a952890
> --- /dev/null
> +++ b/build/fedora/xen-unstable-runit/xen-init-dom0-disk-backend/run
> @@ -0,0 +1,8 @@
> +#!/bin/sh

Why /bin/sh instead of bash? The container should have bash installed,
right?

If we are using bash, I would consider adding a set -e, also in the
other sh scripts below.


> +sv check xenstored >/dev/null || exit 1
> +sv check xenconsoled >/dev/null || exit 1
> +
> +# In case of failure, allow user to run teardown script
> +sleep 5s
> +
> +exec /opt/xen-unstable/lib/xen/bin/qemu-system-i386 -xen-domid 0 -xen-attach 
> -name dom0 -nographic -M xenpv -monitor /dev/null -serial /dev/null -parallel 
> /dev/null -nodefaults -no-user-config
> diff --git a/build/fedora/xen-unstable-runit/xen-init-dom0/run 
> b/build/fedora/xen-unstable-runit/xen-init-dom0/run
> new file mode 100755
> index 0000000..f7f56ed
> --- /dev/null
> +++ b/build/fedora/xen-unstable-runit/xen-init-dom0/run
> @@ -0,0 +1,6 @@
> +#!/bin/sh
> +sv check xenstored >/dev/null || exit 1
> +
> +/opt/xen-unstable/lib/xen/bin/xen-init-dom0
> +
> +exec chpst -b xen-init-dom0 runit-pause
> diff --git a/build/fedora/xen-unstable-runit/xenconsoled/run 
> b/build/fedora/xen-unstable-runit/xenconsoled/run
> new file mode 100755
> index 0000000..7a3ab4e
> --- /dev/null
> +++ b/build/fedora/xen-unstable-runit/xenconsoled/run
> @@ -0,0 +1,10 @@
> +#!/bin/sh
> +sv check xen-init-dom0 >/dev/null || exit 1
> +
> +[ ! -d /var/log/xen/console ] && mkdir -p /var/log/xen/console
> +
> +# In case of failure, allow user to run teardown script
> +sleep 5s
> +
> +# --log=[none|guest|hv|all]
> +exec /opt/xen-unstable/sbin/xenconsoled -i --log=none
> diff --git a/build/fedora/xen-unstable-runit/xenstored/run 
> b/build/fedora/xen-unstable-runit/xenstored/run
> new file mode 100755
> index 0000000..42e5e41
> --- /dev/null
> +++ b/build/fedora/xen-unstable-runit/xenstored/run
> @@ -0,0 +1,20 @@
> +#!/bin/sh
> +[ ! -d /var/run/xen ] && mkdir -p /var/run/xen
> +[ ! -d /var/run/xenstored ] && mkdir -p /var/run/xenstored
> +[ ! -d /var/log/xen ] && mkdir -p /var/log/xen
> +[ ! -d /var/lib/xen ] && mkdir -p /var/lib/xen
> +[ ! -d /var/lib/xen/dump ] && mkdir -p /var/lib/xen/dump
> +[ ! -d /var/lib/xen/xenpaging ] && mkdir -p /var/lib/xen/paging
> +[ ! -d /var/lib/xenstored ] && mkdir -p /var/lib/xenstored
> +modprobe -q xen-evtchn || exit 1
> +modprobe -q xen-gntdev || exit 1
> +modprobe -q xen-gntalloc || exit 1
> +mountpoint -q /proc/xen || mount -t xenfs xenfs /proc/xen
> +mountpoint -q /var/lib/xenstored || mount -t tmpfs xenstored 
> /var/lib/xenstored
> +grep -q "control_d" /proc/xen/capabilities || exit 1
> +
> +# In case of failure, allow user to run teardown script
> +sleep 5s
> +
> +# Use `--trace-file /var/log/xen/xenstored-trace.log` for logs
> +exec /opt/xen-unstable/sbin/xenstored --no-fork

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.