From patchwork Tue Aug 2 10:39:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 9255449 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EFFA46089F for ; Tue, 2 Aug 2016 10:42:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E011428505 for ; Tue, 2 Aug 2016 10:42:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D47AA28512; Tue, 2 Aug 2016 10:42:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 96B1A28513 for ; Tue, 2 Aug 2016 10:42:23 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bUX6p-0003aQ-Ca; Tue, 02 Aug 2016 10:39:39 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bUX6n-0003Zc-DF for xen-devel@lists.xen.org; Tue, 02 Aug 2016 10:39:37 +0000 Received: from [193.109.254.147] by server-11.bemta-14.messagelabs.com id C0/03-09831-86870A75; Tue, 02 Aug 2016 10:39:36 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBLMWRWlGSWpSXmKPExsVyuP0Ov256xYJ wg64zVhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bmL+UFz+0q7rVfZ2xgvG3axcjJISFgJPF2 4j+mLkYuDiGBhYwS1z98YAZJsAmoSmy4fooVxBYRkJa49vkyI0gRs8B8Rol9/bNZQBLCAt4Sj QuWs4PYLEANr7dtA7N5BewlVhx+wwaxQU7i+szpTCA2p4CDxPR1h8FsIaCam3fnsU1g5F7AyL CKUaM4tagstUjX0FwvqSgzPaMkNzEzR9fQ0EQvN7W4ODE9NScxqVgvOT93EyPQv/UMDIw7GH+ e9jzEKMnBpCTK6/JlfrgQX1J+SmVGYnFGfFFpTmrxIUYZDg4lCd4TZQvChQSLUtNTK9Iyc4CB BpOW4OBREuHdCJLmLS5IzC3OTIdInWI05jg298ZaJo4/GyZfYRJiycvPS5US5z0NUioAUppRm gc3CBYBlxhlpYR5GRkYGIR4ClKLcjNLUOVfMYpzMCoJ8/KVA03hycwrgdv3CugUJqBTThiAnV KSiJCSamD0OvWxbZdVeH9Scmu6rXL/253lv5cWVMgXdXQ0f193+kz0ncveD2NXxr3qKBHb5e9 V3fHq5vwwNQHNeMnnB259fRP/1GiGWk5CnGNdXVakV+vK4+Ln000tKi39SlRFryQ8//5xhrr3 zr2eC/8y2PmLX69WD31/MNXtRUBU8Psf3W1CE6MVnyuxFGckGmoxFxUnAgCrDdYYewIAAA== X-Env-Sender: jgross@suse.com X-Msg-Ref: server-8.tower-27.messagelabs.com!1470134375!46906767!1 X-Originating-IP: [195.135.220.15] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.77; banners=-,-,- X-VirusChecked: Checked Received: (qmail 20755 invoked from network); 2 Aug 2016 10:39:35 -0000 Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by server-8.tower-27.messagelabs.com with DHE-RSA-CAMELLIA256-SHA encrypted SMTP; 2 Aug 2016 10:39:35 -0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E59EAACE5; Tue, 2 Aug 2016 10:39:34 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xen.org Date: Tue, 2 Aug 2016 12:39:26 +0200 Message-Id: <1470134368-13799-3-git-send-email-jgross@suse.com> X-Mailer: git-send-email 2.6.6 In-Reply-To: <1470134368-13799-1-git-send-email-jgross@suse.com> References: <1470134368-13799-1-git-send-email-jgross@suse.com> Cc: Juergen Gross , wei.liu2@citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, ross.lagerwall@citrix.com, dave@recoil.org Subject: [Xen-devel] [PATCH v4 2/4] tools: split out xenstored starting form xencommons X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP In order to prepare starting a xenstore domain split out the starting of the xenstore daemon from the xencommons script into a dedicated launch-xenstore script. Correct one error: don't remove old tdb files in background, as this could lead to very subtle races. A rerun of autogen.sh is required. Signed-off-by: Juergen Gross --- .gitignore | 1 + tools/configure | 3 +- tools/configure.ac | 1 + tools/hotplug/Linux/Makefile | 1 + tools/hotplug/Linux/init.d/xencommons.in | 36 ++------------------- tools/hotplug/Linux/launch-xenstore.in | 55 ++++++++++++++++++++++++++++++++ 6 files changed, 63 insertions(+), 34 deletions(-) create mode 100644 tools/hotplug/Linux/launch-xenstore.in diff --git a/.gitignore b/.gitignore index 9b8dece..d193820 100644 --- a/.gitignore +++ b/.gitignore @@ -157,6 +157,7 @@ tools/hotplug/Linux/init.d/xen-watchdog tools/hotplug/Linux/init.d/xencommons tools/hotplug/Linux/init.d/xendomains tools/hotplug/Linux/init.d/xendriverdomain +tools/hotplug/Linux/launch-xenstore tools/hotplug/Linux/systemd/*.conf tools/hotplug/Linux/systemd/*.mount tools/hotplug/Linux/systemd/*.socket diff --git a/tools/configure b/tools/configure index 1c84c6c..51f16c5 100755 --- a/tools/configure +++ b/tools/configure @@ -2410,7 +2410,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu -ac_config_files="$ac_config_files ../config/Tools.mk hotplug/FreeBSD/rc.d/xencommons hotplug/FreeBSD/rc.d/xendriverdomain hotplug/Linux/init.d/sysconfig.xencommons hotplug/Linux/init.d/sysconfig.xendomains hotplug/Linux/init.d/xen-watchdog hotplug/Linux/init.d/xencommons hotplug/Linux/init.d/xendomains hotplug/Linux/init.d/xendriverdomain hotplug/Linux/vif-setup hotplug/Linux/xen-hotplug-common.sh hotplug/Linux/xendomains hotplug/NetBSD/rc.d/xencommons hotplug/NetBSD/rc.d/xendriverdomain libxl/xenlight.pc.in libxl/xlutil.pc.in ocaml/xenstored/oxenstored.conf" +ac_config_files="$ac_config_files ../config/Tools.mk hotplug/FreeBSD/rc.d/xencommons hotplug/FreeBSD/rc.d/xendriverdomain hotplug/Linux/init.d/sysconfig.xencommons hotplug/Linux/init.d/sysconfig.xendomains hotplug/Linux/init.d/xen-watchdog hotplug/Linux/init.d/xencommons hotplug/Linux/init.d/xendomains hotplug/Linux/init.d/xendriverdomain hotplug/Linux/launch-xenstore hotplug/Linux/vif-setup hotplug/Linux/xen-hotplug-common.sh hotplug/Linux/xendomains hotplug/NetBSD/rc.d/xencommons hotplug/NetBSD/rc.d/xendriverdomain libxl/xenlight.pc.in libxl/xlutil.pc.in ocaml/xenstored/oxenstored.conf" ac_config_headers="$ac_config_headers config.h" @@ -10376,6 +10376,7 @@ do "hotplug/Linux/init.d/xencommons") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/init.d/xencommons" ;; "hotplug/Linux/init.d/xendomains") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/init.d/xendomains" ;; "hotplug/Linux/init.d/xendriverdomain") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/init.d/xendriverdomain" ;; + "hotplug/Linux/launch-xenstore") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/launch-xenstore" ;; "hotplug/Linux/vif-setup") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/vif-setup" ;; "hotplug/Linux/xen-hotplug-common.sh") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/xen-hotplug-common.sh" ;; "hotplug/Linux/xendomains") CONFIG_FILES="$CONFIG_FILES hotplug/Linux/xendomains" ;; diff --git a/tools/configure.ac b/tools/configure.ac index f991ab3..3a4abb5 100644 --- a/tools/configure.ac +++ b/tools/configure.ac @@ -15,6 +15,7 @@ hotplug/Linux/init.d/xen-watchdog hotplug/Linux/init.d/xencommons hotplug/Linux/init.d/xendomains hotplug/Linux/init.d/xendriverdomain +hotplug/Linux/launch-xenstore hotplug/Linux/vif-setup hotplug/Linux/xen-hotplug-common.sh hotplug/Linux/xendomains diff --git a/tools/hotplug/Linux/Makefile b/tools/hotplug/Linux/Makefile index 6d6ccee..29280cb 100644 --- a/tools/hotplug/Linux/Makefile +++ b/tools/hotplug/Linux/Makefile @@ -30,6 +30,7 @@ XEN_SCRIPTS += block-drbd-probe XEN_SCRIPTS += block-dummy XEN_SCRIPTS += $(XEN_SCRIPTS-y) XEN_SCRIPTS += colo-proxy-setup +XEN_SCRIPTS += launch-xenstore SUBDIRS-$(CONFIG_SYSTEMD) += systemd diff --git a/tools/hotplug/Linux/init.d/xencommons.in b/tools/hotplug/Linux/init.d/xencommons.in index 2d8f30b..a32608c 100644 --- a/tools/hotplug/Linux/init.d/xencommons.in +++ b/tools/hotplug/Linux/init.d/xencommons.in @@ -18,7 +18,6 @@ # Description: Starts and stops the daemons neeeded for xl/xend ### END INIT INFO -XENSTORED=@XENSTORED@ BACKEND_MODULES="@LINUX_BACKEND_MODULES@" . @XEN_SCRIPT_DIR@/hotplugpath.sh @@ -53,8 +52,6 @@ if test -f /proc/xen/capabilities && \ fi do_start () { - local time=0 - local timeout=30 local mod for mod in $BACKEND_MODULES ; do modprobe "$mod" &>/dev/null ; done @@ -62,37 +59,10 @@ do_start () { mkdir -p ${XEN_RUN_DIR} mkdir -p ${XEN_LOCK_DIR} - if ! `${bindir}/xenstore-read -s / >/dev/null 2>&1` - then - test -z "$XENSTORED_ROOTDIR" && XENSTORED_ROOTDIR="@XEN_LIB_STORED@" - rm -f "$XENSTORED_ROOTDIR"/tdb* &>/dev/null - test -z "$XENSTORED_TRACE" || XENSTORED_ARGS=" -T @XEN_LOG_DIR@/xenstored-trace.log" + @XEN_SCRIPT_DIR@/launch-xenstore || exit 1 - if [ -n "$XENSTORED" ] ; then - echo -n Starting $XENSTORED... - $XENSTORED --pid-file @XEN_RUN_DIR@/xenstored.pid $XENSTORED_ARGS - else - echo "No xenstored found" - exit 1 - fi - - # Wait for xenstored to actually come up, timing out after 30 seconds - while [ $time -lt $timeout ] && ! `${bindir}/xenstore-read -s / >/dev/null 2>&1` ; do - echo -n . - time=$(($time+1)) - sleep 1 - done - echo - - # Exit if we timed out - if ! [ $time -lt $timeout ] ; then - echo Could not start xenstored - exit 1 - fi - - echo Setting domain 0 name, domid and JSON config... - ${LIBEXEC_BIN}/xen-init-dom0 - fi + echo Setting domain 0 name, domid and JSON config... + ${LIBEXEC_BIN}/xen-init-dom0 echo Starting xenconsoled... test -z "$XENCONSOLED_TRACE" || XENCONSOLED_ARGS=" --log=$XENCONSOLED_TRACE" diff --git a/tools/hotplug/Linux/launch-xenstore.in b/tools/hotplug/Linux/launch-xenstore.in new file mode 100644 index 0000000..a0cbfd3 --- /dev/null +++ b/tools/hotplug/Linux/launch-xenstore.in @@ -0,0 +1,55 @@ +#!/bin/bash +# +# Copyright (c) 2016 SUSE Linux GmbH +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of version 2.1 of the GNU Lesser General Public +# License as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; If not, see . +# + +XENSTORED=@XENSTORED@ + +. @XEN_SCRIPT_DIR@/hotplugpath.sh +test -f @CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons && . @CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons + +time=0 +timeout=30 + +if ! `${bindir}/xenstore-read -s / >/dev/null 2>&1` +then + test -z "$XENSTORED_ROOTDIR" && XENSTORED_ROOTDIR="@XEN_LIB_STORED@" + rm -f "$XENSTORED_ROOTDIR"/tdb* 2>/dev/null + test -z "$XENSTORED_TRACE" || XENSTORED_ARGS=" -T @XEN_LOG_DIR@/xenstored-trace.log" + + if [ -n "$XENSTORED" ] ; then + echo -n Starting $XENSTORED... + $XENSTORED --pid-file @XEN_RUN_DIR@/xenstored.pid $XENSTORED_ARGS + else + echo "No xenstored found" + exit 1 + fi + + # Wait for xenstored to actually come up, timing out after 30 seconds + while [ $time -lt $timeout ] && ! `${bindir}/xenstore-read -s / >/dev/null 2>&1` ; do + echo -n . + time=$(($time+1)) + sleep 1 + done + echo + + # Exit if we timed out + if ! [ $time -lt $timeout ] ; then + echo Could not start xenstored + exit 1 + fi +fi + +exit 0