From: Sander Eikelenboom <linux@eikelenboom.it>
To: xen-devel@lists.xensource.com
Cc: Ian.Campbell@citrix.com
Subject: [PATCH] xl: Introduce shutdown xm compatibility option -a to shutdown all domains
Date: Thu, 06 Sep 2012 16:36:27 +0200 [thread overview]
Message-ID: <c6d5f62c345b6b41b9ff.1346942187@xentest.example.org> (raw)
xl: Introduce shutdown xm compatibility option -a to shutdown all domains
v2: address review comments.
- Change shutdown_domain to take domid instead of domname
- Docs: Make it more clear -a only shuts down GUEST domains
Signed-off-by: Sander Eikelenboom <linux@eikelenboom.it>
diff -r 9dc729b75595 -r c6d5f62c345b docs/man/xl.pod.1
--- a/docs/man/xl.pod.1 Mon Sep 03 11:22:02 2012 +0100
+++ b/docs/man/xl.pod.1 Thu Sep 06 16:35:04 2012 +0200
@@ -527,7 +527,7 @@ List specifically for that domain. Other
=back
-=item B<shutdown> [I<OPTIONS>] I<domain-id>
+=item B<shutdown> [I<OPTIONS>] I<-a|domain-id>
Gracefully shuts down a domain. This coordinates with the domain OS
to perform graceful shutdown, so there is no guarantee that it will
@@ -550,6 +550,10 @@ B<OPTIONS>
=over 4
+=item B<-a>
+
+-a Shutdown all guest domains. Often used when doing a complete shutdown of a Xen system.
+
=item B<-w>
Wait for the domain to complete shutdown before returning.
diff -r 9dc729b75595 -r c6d5f62c345b tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c Mon Sep 03 11:22:02 2012 +0100
+++ b/tools/libxl/xl_cmdimpl.c Thu Sep 06 16:35:04 2012 +0200
@@ -2683,12 +2683,11 @@ static void destroy_domain(const char *p
if (rc) { fprintf(stderr,"destroy failed (rc=%d)\n",rc); exit(-1); }
}
-static void shutdown_domain(const char *p, int wait, int fallback_trigger)
+static void shutdown_domain(uint32_t domid, int wait, int fallback_trigger)
{
int rc;
libxl_event *event;
- find_domain(p);
rc=libxl_domain_shutdown(ctx, domid);
if (rc == ERROR_NOPARAVIRT) {
if (fallback_trigger) {
@@ -3670,14 +3669,19 @@ int main_destroy(int argc, char **argv)
int main_shutdown(int argc, char **argv)
{
- int opt;
+ libxl_dominfo *dominfo;
+ int opt, i, nb_domain;
+ int all = 0;
int wait = 0;
int fallback_trigger = 0;
- while ((opt = def_getopt(argc, argv, "wF", "shutdown", 1)) != -1) {
+ while ((opt = def_getopt(argc, argv, "awF", "shutdown", 0)) != -1) {
switch (opt) {
case 0: case 2:
return opt;
+ case 'a':
+ all = 1;
+ break;
case 'w':
wait = 1;
break;
@@ -3687,7 +3691,30 @@ int main_shutdown(int argc, char **argv)
}
}
- shutdown_domain(argv[optind], wait, fallback_trigger);
+ if (!argv[optind] && !all) {
+ fprintf(stderr, "You must specify -a or a domain id.\n\n");
+ return opt;
+ }
+
+ if (all) {
+ if (!(dominfo = libxl_list_domain(ctx, &nb_domain))) {
+ fprintf(stderr, "libxl_list_domain failed.\n");
+ return -1;
+ }
+
+ for (i = 0; i<nb_domain; i++) {
+ if (dominfo[i].domid == 0)
+ continue;
+
+ shutdown_domain(dominfo[i].domid, wait, fallback_trigger);
+ }
+
+ libxl_dominfo_list_free(dominfo, nb_domain);
+ } else {
+ find_domain(argv[optind]);
+ shutdown_domain(domid, wait, fallback_trigger);
+ }
+
return 0;
}
diff -r 9dc729b75595 -r c6d5f62c345b tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c Mon Sep 03 11:22:02 2012 +0100
+++ b/tools/libxl/xl_cmdtable.c Thu Sep 06 16:35:04 2012 +0200
@@ -60,7 +60,8 @@ struct cmd_spec cmd_table[] = {
{ "shutdown",
&main_shutdown, 0, 1,
"Issue a shutdown signal to a domain",
- "[options] <Domain>",
+ "[options] <-a|Domain>",
+ "-a Shutdown all guest domains.\n"
"-h Print this help.\n"
"-F Fallback to ACPI power event for HVM guests with\n"
" no PV drivers.\n"
next reply other threads:[~2012-09-06 14:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-06 14:36 Sander Eikelenboom [this message]
2012-09-06 16:02 ` [PATCH] xl: Introduce shutdown xm compatibility option -a to shutdown all domains Sander Eikelenboom
2012-09-06 16:32 ` Ian Campbell
2012-09-06 16:40 ` Sander Eikelenboom
2012-09-06 16:49 ` Ian Campbell
-- strict thread matches above, loose matches on Subject: below --
2012-09-06 10:07 Sander Eikelenboom
2012-09-06 9:27 ` Ian Campbell
2012-09-06 9:43 ` Sander Eikelenboom
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=c6d5f62c345b6b41b9ff.1346942187@xentest.example.org \
--to=linux@eikelenboom.it \
--cc=Ian.Campbell@citrix.com \
--cc=xen-devel@lists.xensource.com \
/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).