From mboxrd@z Thu Jan 1 00:00:00 1970 From: Juergen Gross Subject: [PATCH v2 13/13] tools: don't stop xenstore domain when stopping dom0 Date: Fri, 18 Dec 2015 14:14:31 +0100 Message-ID: <1450444471-6454-14-git-send-email-jgross@suse.com> References: <1450444471-6454-1-git-send-email-jgross@suse.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1450444471-6454-1-git-send-email-jgross@suse.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org, Ian.Campbell@citrix.com, ian.jackson@eu.citrix.com, stefano.stabellini@eu.citrix.com, wei.liu2@citrix.com, dgdegra@tycho.nsa.gov Cc: Juergen Gross List-Id: xen-devel@lists.xenproject.org When restarting or shutting down dom0 the xendomains script tries to stop all other domains. Don't do this for the xenstore domain, as it might survive a dom0 reboot in the future. The same applies to xl shutdown --all. Signed-off-by: Juergen Gross --- tools/hotplug/Linux/xendomains.in | 17 +++++++++++++++++ tools/libxl/xl_cmdimpl.c | 19 +++++++++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/tools/hotplug/Linux/xendomains.in b/tools/hotplug/Linux/xendomains.in index dfe0b33..70b7f16 100644 --- a/tools/hotplug/Linux/xendomains.in +++ b/tools/hotplug/Linux/xendomains.in @@ -196,6 +196,17 @@ rdnames() done } +# set xenstore domain id (or 0 if no xenstore domain) +get_xsdomid() +{ + ${bindir}/xenstore-exists /tool/xenstored/domid + if test $? -ne 0; then + XS_DOMID=0 + else + XS_DOMID=`${bindir}/xenstore-read /tool/xenstored/domid` + fi +} + LIST_GREP='(domain\|(domid\|(name\|^ {$\|"name":\|"domid":' parseln() { @@ -216,12 +227,14 @@ parseln() is_running() { + get_xsdomid rdname $1 RC=1 name=;id= while read LN; do parseln "$LN" || continue if test $id = 0; then continue; fi + if test $id = $XS_DOMID; then continue; fi case $name in ($NM) RC=0 @@ -302,10 +315,12 @@ start() all_zombies() { + get_xsdomid name=;id= while read LN; do parseln "$LN" || continue if test $id = 0; then continue; fi + if test $id = $XS_DOMID; then continue; fi if test "$state" != "-b---d" -a "$state" != "-----d"; then return 1; fi @@ -351,11 +366,13 @@ stop() if test "$XENDOMAINS_AUTO_ONLY" = "true"; then rdnames fi + get_xsdomid echo -n "Shutting down Xen domains:" name=;id= while read LN; do parseln "$LN" || continue if test $id = 0; then continue; fi + if test $id = $XS_DOMID; then continue; fi echo -n " $name" if test "$XENDOMAINS_AUTO_ONLY" = "true"; then eval " diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index f9933cb..bf30030 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -4822,6 +4822,7 @@ static int main_shutdown_or_reboot(int do_reboot, int argc, char **argv) int opt, i, nb_domain; int wait_for_it = 0, all =0; int fallback_trigger = 0; + uint32_t domid; static struct option opts[] = { {"all", 0, 0, 'a'}, {"wait", 0, 0, 'w'}, @@ -4846,32 +4847,42 @@ static int main_shutdown_or_reboot(int do_reboot, int argc, char **argv) } if (all) { + int ret; libxl_dominfo *dominfo; libxl_evgen_domain_death **deathws = NULL; if (!(dominfo = libxl_list_domain(ctx, &nb_domain))) { fprintf(stderr, "libxl_list_domain failed.\n"); return -1; } + ret = libxl_xenstore_domid(ctx, &domid); + if (ret == ERROR_DOMAIN_NOTFOUND) { + domid = 0; + } else if (ret != 0) { + fprintf(stderr, "libxl_xenstore_domid failed.\n"); + return -1; + } if (wait_for_it) deathws = calloc(nb_domain, sizeof(*deathws)); + wait_for_it = 0; for (i = 0; i