xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
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 <jgross@suse.com>
Subject: [PATCH v4 13/14] tools: don't stop xenstore domain when stopping dom0
Date: Mon, 18 Jan 2016 09:04:03 +0100	[thread overview]
Message-ID: <1453104244-6268-14-git-send-email-jgross@suse.com> (raw)
In-Reply-To: <1453104244-6268-1-git-send-email-jgross@suse.com>

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. Here the xenstore domain is
flagged as "never stop".

Signed-off-by: Juergen Gross <jgross@suse.com>
---
V4: don't reuse wait_for_it as a counter as requested by Ian Campbell

V3: xl shutdown modified to query the "never_stop" flag instead of
    the xenstore domain id as requested by Ian Campbell
    drop usage of xenstore-exists as requested by Ian Campbell

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 tools/hotplug/Linux/xendomains.in | 15 +++++++++++++++
 tools/libxl/xl_cmdimpl.c          |  9 +++++----
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/tools/hotplug/Linux/xendomains.in b/tools/hotplug/Linux/xendomains.in
index dfe0b33..9f88649 100644
--- a/tools/hotplug/Linux/xendomains.in
+++ b/tools/hotplug/Linux/xendomains.in
@@ -196,6 +196,15 @@ rdnames()
     done
 }
 
+# get xenstore domain id (or 0 if no xenstore domain)
+get_xsdomid()
+{
+    XS_DOMID=`${bindir}/xenstore-read /tool/xenstored/domid 2>/dev/null`
+    if test $? -ne 0; then
+        XS_DOMID=0
+    fi
+}
+
 LIST_GREP='(domain\|(domid\|(name\|^    {$\|"name":\|"domid":'
 parseln()
 {
@@ -216,12 +225,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 +313,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 +364,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..25507c7 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -4820,7 +4820,7 @@ static int main_shutdown_or_reboot(int do_reboot, int argc, char **argv)
                libxl_evgen_domain_death **, libxl_ev_user, int) =
         do_reboot ? &reboot_domain : &shutdown_domain;
     int opt, i, nb_domain;
-    int wait_for_it = 0, all =0;
+    int wait_for_it = 0, all = 0, nrdeathws = 0;
     int fallback_trigger = 0;
     static struct option opts[] = {
         {"all", 0, 0, 'a'},
@@ -4857,14 +4857,15 @@ static int main_shutdown_or_reboot(int do_reboot, int argc, char **argv)
             deathws = calloc(nb_domain, sizeof(*deathws));
 
         for (i = 0; i<nb_domain; i++) {
-            if (dominfo[i].domid == 0)
+            if (dominfo[i].domid == 0 || dominfo[i].never_stop)
                 continue;
             fn(dominfo[i].domid, deathws ? &deathws[i] : NULL, i,
                fallback_trigger);
+            nrdeathws++;
         }
 
-        if (wait_for_it) {
-            wait_for_domain_deaths(deathws, nb_domain - 1 /* not dom 0 */);
+        if (deathws) {
+            wait_for_domain_deaths(deathws, nrdeathws);
             free(deathws);
         }
 
-- 
2.6.2

  parent reply	other threads:[~2016-01-18  8:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-18  8:03 [PATCH v4 00/14] xenstore: make it easier to run xenstore in a domain Juergen Gross
2016-01-18  8:03 ` [PATCH v4 01/14] libxc: support new xenstore domain flag in libxc Juergen Gross
2016-01-18  8:03 ` [PATCH v4 02/14] libxl: provide a flag in dominfo to avoid stopping it Juergen Gross
2016-01-18  8:03 ` [PATCH v4 03/14] xenstore: move init-xenstore-domain to tools/helpers Juergen Gross
2016-01-18  8:03 ` [PATCH v4 04/14] xenstore: adjust coding style of init-xenstore-domain.c Juergen Gross
2016-01-18  8:03 ` [PATCH v4 05/14] libxl: move xen-init-dom0 to tools/helpers Juergen Gross
2016-01-18  8:03 ` [PATCH v4 06/14] xenstore: destroy xenstore domain in case of error after creating it Juergen Gross
2016-01-18  8:03 ` [PATCH v4 07/14] xenstore: add error messages to init-xenstore-domain Juergen Gross
2016-01-18  8:03 ` [PATCH v4 08/14] xenstore: modify init-xenstore-domain parameter syntax Juergen Gross
2016-01-18  8:03 ` [PATCH v4 09/14] xenstore: make use of the "xenstore domain" flag Juergen Gross
2016-01-18  8:04 ` [PATCH v4 10/14] xenstore: add init-xenstore-domain parameter to specify cmdline Juergen Gross
2016-01-18  8:04 ` [PATCH v4 11/14] tools: split up xen-init-dom0.c Juergen Gross
2016-01-18  8:04 ` [PATCH v4 12/14] xenstore: write xenstore domain data to xenstore Juergen Gross
2016-01-18  8:04 ` Juergen Gross [this message]
2016-01-18  8:04 ` [PATCH v4 14/14] docs: document xenstore domain xenstore paths Juergen Gross
2016-01-18 16:55 ` [PATCH v4 00/14] xenstore: make it easier to run xenstore in a domain Ian Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1453104244-6268-14-git-send-email-jgross@suse.com \
    --to=jgross@suse.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=dgdegra@tycho.nsa.gov \
    --cc=ian.jackson@eu.citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).