From: Sander Eikelenboom Subject: [PATCH] xl: Introduce shutdown xm compatibility option -a to shutdown all domains Date: Thu, 06 Sep 2012 12:07:35 +0200 Message-ID: <67f9ef64993791d81845.1346926055@xentest.example.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: 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.xensource.com Cc: Ian.Campbell@citrix.com List-Id: xen-devel@lists.xenproject.org docs/man/xl.pod.1 | 6 +++++- tools/libxl/xl_cmdimpl.c | 39 ++++++++++++++++++++++++++++++++++++--- tools/libxl/xl_cmdtable.c | 3 ++- 3 files changed, 43 insertions(+), 5 deletions(-) xl: Introduce shutdown xm compatibility option -a to shutdown all domains Signed-off-by: Sander Eikelenboom diff -r 9dc729b75595 -r 67f9ef649937 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 12:04:12 2012 +0200 @@ -527,7 +527,7 @@ List specifically for that domain. Other =back -=item B [I] I +=item B [I] [I] 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 =over 4 +=item B<-a> + +-a Shutdown all 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 67f9ef649937 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 12:04:12 2012 +0200 @@ -3670,14 +3670,20 @@ int main_destroy(int argc, char **argv) int main_shutdown(int argc, char **argv) { - int opt; + libxl_dominfo *dominfo; + char *domname; + 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 +3693,34 @@ 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"); + goto main_shutdown_out; + } + + for (i = 0; i", + "[options] [Domain]", + "-a Shutdown all domains.\n" "-h Print this help.\n" "-F Fallback to ACPI power event for HVM guests with\n" " no PV drivers.\n"