Hi IanC, Here are some patches that fix the most important part of the lack of a working shutdown in the default init / sysconfig scripts when using xl. This patch series does *not* include the --all option, which is also lacking from xl/libxl and is used as "catch all" in the xendomains init script during shutdown. -- Sander [PATCH 1/3] init/sysconfig scripts: Remove --halt/-H option for shutdown command. [PATCH 2/3] init scripts: xendomains correct order of options for shutdown command [PATCH 3/3] xl/libxl: make shutdown accept the long option --wait for -w
linux@eikelenboom.it
2012-Oct-11 08:25 UTC
[PATCH 1/3] init/sysconfig scripts: Remove --halt/-H option for shutdown command.
From: Sander Eikelenboom <linux@eikelenboom.it> The --halt/-H option for the shutdown command is now pointless, since linux in a guest treats "halt" and "poweroff" identically. The option is not implemented in xl / libxl and if supplied causes the command to fail , so remove it from the init and sysconfig scripts. Signed-off-by: Sander Eikelenboom <linux@eikelenboom.it> --- tools/hotplug/Linux/init.d/sysconfig.xendomains | 12 ++++++------ tools/hotplug/Linux/init.d/xendomains | 4 ++-- tools/hotplug/NetBSD/rc.d/xendomains | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/hotplug/Linux/init.d/sysconfig.xendomains b/tools/hotplug/Linux/init.d/sysconfig.xendomains index e590d3f..4775277 100644 --- a/tools/hotplug/Linux/init.d/sysconfig.xendomains +++ b/tools/hotplug/Linux/init.d/sysconfig.xendomains @@ -56,29 +56,29 @@ XENDOMAINS_MIGRATE="" XENDOMAINS_SAVE=/var/lib/xen/save ## Type: string -## Default: "--halt --wait" +## Default: "--wait" # # If neither MIGRATE nor SAVE were enabled or if they failed, you can # try to shut down a domain by sending it a shutdown request. To do this, -# set this to "--halt --wait". Omit the "--wait" flag to avoid waiting +# set this to "--wait". Omit the "--wait" flag to avoid waiting # for the domain to be really down. Leave empty to skip domain shutdown. # -XENDOMAINS_SHUTDOWN="--halt --wait" +XENDOMAINS_SHUTDOWN="--wait" ## Type: string -## Default: "--all --halt --wait" +## Default: "--all --wait" # # After we have gone over all virtual machines (resp. all automatically # started ones, see XENDOMAINS_AUTO_ONLY below) in a loop and sent SysRq, # migrated, saved and/or shutdown according to the settings above, we # might want to shutdown the virtual machines that are still running # for some reason or another. To do this, set this variable to -# "--all --halt --wait", it will be passed to xm shutdown. +# "--all --wait", it will be passed to xm shutdown. # Leave it empty not to do anything special here. # (Note: This will hit all virtual machines, even if XENDOMAINS_AUTO_ONLY # is set.) # -XENDOMAINS_SHUTDOWN_ALL="--all --halt --wait" +XENDOMAINS_SHUTDOWN_ALL="--all --wait" ## Type: boolean ## Default: true diff --git a/tools/hotplug/Linux/init.d/xendomains b/tools/hotplug/Linux/init.d/xendomains index c033581..c363208 100644 --- a/tools/hotplug/Linux/init.d/xendomains +++ b/tools/hotplug/Linux/init.d/xendomains @@ -434,7 +434,7 @@ stop() fi fi if test -n "$XENDOMAINS_SHUTDOWN"; then - # XENDOMAINS_SHUTDOWN should be "--halt --wait" + # XENDOMAINS_SHUTDOWN should be "--wait" echo -n "(shut)" watchdog_xencmd shutdown & WDOG_PID=$! @@ -453,7 +453,7 @@ stop() # This is because it''s easier to do ;-) but arguably if this script is run # on system shutdown then it''s also the right thing to do. if ! all_zombies && test -n "$XENDOMAINS_SHUTDOWN_ALL"; then - # XENDOMAINS_SHUTDOWN_ALL should be "--all --halt --wait" + # XENDOMAINS_SHUTDOWN_ALL should be "--all --wait" echo -n " SHUTDOWN_ALL " watchdog_xencmd shutdown 1 false & WDOG_PID=$! diff --git a/tools/hotplug/NetBSD/rc.d/xendomains b/tools/hotplug/NetBSD/rc.d/xendomains index c368c58..3e62038 100644 --- a/tools/hotplug/NetBSD/rc.d/xendomains +++ b/tools/hotplug/NetBSD/rc.d/xendomains @@ -94,7 +94,7 @@ xendomains_stop() # echo "Stopping xen domains." for domain in $(xendomains_list); do - ${ctl_command} shutdown --halt $domain + ${ctl_command} shutdown $domain done while [ $timeout -gt 0 ]; do livedomains=$(xendomains_list) -- 1.7.2.5
linux@eikelenboom.it
2012-Oct-11 08:25 UTC
[PATCH 2/3] init scripts: xendomains correct order of options for shutdown command
From: Sander Eikelenboom <linux@eikelenboom.it> Options for the shutdown command that are supplied behind the domain id are ignored. In case of the default xendomains init script this means that it will not wait for the domains to be actually shutdown. Signed-off-by: Sander Eikelenboom <linux@eikelenboom.it> --- tools/hotplug/Linux/init.d/xendomains | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/tools/hotplug/Linux/init.d/xendomains b/tools/hotplug/Linux/init.d/xendomains index c363208..00e5944 100644 --- a/tools/hotplug/Linux/init.d/xendomains +++ b/tools/hotplug/Linux/init.d/xendomains @@ -438,7 +438,7 @@ stop() echo -n "(shut)" watchdog_xencmd shutdown & WDOG_PID=$! - XMR=`$CMD shutdown $id $XENDOMAINS_SHUTDOWN 2>&1 1>/dev/null` + XMR=`$CMD shutdown $XENDOMAINS_SHUTDOWN $id 2>&1 1>/dev/null` if test $? -ne 0; then echo -e "\nAn error occurred while shutting down domain:\n$XMR\n" rc_failed $? -- 1.7.2.5
linux@eikelenboom.it
2012-Oct-11 08:25 UTC
[PATCH 3/3] xl/libxl: make shutdown accept the long option --wait for -w
From: Sander Eikelenboom <linux@eikelenboom.it> Make xl/libxl accept the long option --wait for -w to be compatible with xm. The long options are used in the default init and sysconfig scripts Signed-off-by: Sander Eikelenboom <linux@eikelenboom.it> --- docs/man/xl.pod.1 | 2 +- tools/libxl/xl_cmdimpl.c | 7 ++++++- tools/libxl/xl_cmdtable.c | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/man/xl.pod.1 b/docs/man/xl.pod.1 index 25ce777..dd387c9 100644 --- a/docs/man/xl.pod.1 +++ b/docs/man/xl.pod.1 @@ -550,7 +550,7 @@ B<OPTIONS> =over 4 -=item B<-w> +=item B<-w>, B<--wait> Wait for the domain to complete shutdown before returning. diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 93066d3..768ba1f 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -3709,8 +3709,13 @@ int main_shutdown(int argc, char **argv) int opt; int wait_for_it = 0; int fallback_trigger = 0; + int option_index = 0; + static struct option long_options[] = { + {"wait", 0, 0, ''w''}, + {0, 0, 0, 0} + }; - while ((opt = def_getopt(argc, argv, "wF", "shutdown", 1)) != -1) { + while ((opt = getopt_long(argc, argv, "wF", long_options, &option_index)) != -1) { switch (opt) { case 0: case 2: return opt; diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c index 85ea768..b398c0a 100644 --- a/tools/libxl/xl_cmdtable.c +++ b/tools/libxl/xl_cmdtable.c @@ -64,7 +64,7 @@ struct cmd_spec cmd_table[] = { "-h Print this help.\n" "-F Fallback to ACPI power event for HVM guests with\n" " no PV drivers.\n" - "-w Wait for guest to shutdown.\n" + "-w, --wait Wait for guest to shutdown.\n" }, { "reboot", &main_reboot, 0, 1, -- 1.7.2.5
Ian Campbell
2012-Oct-11 08:52 UTC
Re: [PATCH 1/3] init/sysconfig scripts: Remove --halt/-H option for shutdown command.
On Thu, 2012-10-11 at 09:25 +0100, linux@eikelenboom.it wrote:> From: Sander Eikelenboom <linux@eikelenboom.it> > > The --halt/-H option for the shutdown command is now pointless, > since linux in a guest treats "halt" and "poweroff" identically.This looks good to me but I''d just like to confirm that Free&NetBSD also treat them the same before I commit it. Ian.> The option is not implemented in xl / libxl and if supplied causes the command > to fail , so remove it from the init and sysconfig scripts. > > Signed-off-by: Sander Eikelenboom <linux@eikelenboom.it> > --- > tools/hotplug/Linux/init.d/sysconfig.xendomains | 12 ++++++------ > tools/hotplug/Linux/init.d/xendomains | 4 ++-- > tools/hotplug/NetBSD/rc.d/xendomains | 2 +- > 3 files changed, 9 insertions(+), 9 deletions(-) > > diff --git a/tools/hotplug/Linux/init.d/sysconfig.xendomains b/tools/hotplug/Linux/init.d/sysconfig.xendomains > index e590d3f..4775277 100644 > --- a/tools/hotplug/Linux/init.d/sysconfig.xendomains > +++ b/tools/hotplug/Linux/init.d/sysconfig.xendomains > @@ -56,29 +56,29 @@ XENDOMAINS_MIGRATE="" > XENDOMAINS_SAVE=/var/lib/xen/save > > ## Type: string > -## Default: "--halt --wait" > +## Default: "--wait" > # > # If neither MIGRATE nor SAVE were enabled or if they failed, you can > # try to shut down a domain by sending it a shutdown request. To do this, > -# set this to "--halt --wait". Omit the "--wait" flag to avoid waiting > +# set this to "--wait". Omit the "--wait" flag to avoid waiting > # for the domain to be really down. Leave empty to skip domain shutdown. > # > -XENDOMAINS_SHUTDOWN="--halt --wait" > +XENDOMAINS_SHUTDOWN="--wait" > > ## Type: string > -## Default: "--all --halt --wait" > +## Default: "--all --wait" > # > # After we have gone over all virtual machines (resp. all automatically > # started ones, see XENDOMAINS_AUTO_ONLY below) in a loop and sent SysRq, > # migrated, saved and/or shutdown according to the settings above, we > # might want to shutdown the virtual machines that are still running > # for some reason or another. To do this, set this variable to > -# "--all --halt --wait", it will be passed to xm shutdown. > +# "--all --wait", it will be passed to xm shutdown. > # Leave it empty not to do anything special here. > # (Note: This will hit all virtual machines, even if XENDOMAINS_AUTO_ONLY > # is set.) > # > -XENDOMAINS_SHUTDOWN_ALL="--all --halt --wait" > +XENDOMAINS_SHUTDOWN_ALL="--all --wait" > > ## Type: boolean > ## Default: true > diff --git a/tools/hotplug/Linux/init.d/xendomains b/tools/hotplug/Linux/init.d/xendomains > index c033581..c363208 100644 > --- a/tools/hotplug/Linux/init.d/xendomains > +++ b/tools/hotplug/Linux/init.d/xendomains > @@ -434,7 +434,7 @@ stop() > fi > fi > if test -n "$XENDOMAINS_SHUTDOWN"; then > - # XENDOMAINS_SHUTDOWN should be "--halt --wait" > + # XENDOMAINS_SHUTDOWN should be "--wait" > echo -n "(shut)" > watchdog_xencmd shutdown & > WDOG_PID=$! > @@ -453,7 +453,7 @@ stop() > # This is because it''s easier to do ;-) but arguably if this script is run > # on system shutdown then it''s also the right thing to do. > if ! all_zombies && test -n "$XENDOMAINS_SHUTDOWN_ALL"; then > - # XENDOMAINS_SHUTDOWN_ALL should be "--all --halt --wait" > + # XENDOMAINS_SHUTDOWN_ALL should be "--all --wait" > echo -n " SHUTDOWN_ALL " > watchdog_xencmd shutdown 1 false & > WDOG_PID=$! > diff --git a/tools/hotplug/NetBSD/rc.d/xendomains b/tools/hotplug/NetBSD/rc.d/xendomains > index c368c58..3e62038 100644 > --- a/tools/hotplug/NetBSD/rc.d/xendomains > +++ b/tools/hotplug/NetBSD/rc.d/xendomains > @@ -94,7 +94,7 @@ xendomains_stop() > # > echo "Stopping xen domains." > for domain in $(xendomains_list); do > - ${ctl_command} shutdown --halt $domain > + ${ctl_command} shutdown $domain > done > while [ $timeout -gt 0 ]; do > livedomains=$(xendomains_list)
Ian Campbell
2012-Oct-11 08:58 UTC
Re: [PATCH 3/3] xl/libxl: make shutdown accept the long option --wait for -w
On Thu, 2012-10-11 at 09:25 +0100, linux@eikelenboom.it wrote:> From: Sander Eikelenboom <linux@eikelenboom.it> > > Make xl/libxl accept the long option --wait for -w to be compatible with xm. > The long options are used in the default init and sysconfig scripts > > Signed-off-by: Sander Eikelenboom <linux@eikelenboom.it> > --- > docs/man/xl.pod.1 | 2 +- > tools/libxl/xl_cmdimpl.c | 7 ++++++- > tools/libxl/xl_cmdtable.c | 2 +- > 3 files changed, 8 insertions(+), 3 deletions(-) > > diff --git a/docs/man/xl.pod.1 b/docs/man/xl.pod.1 > index 25ce777..dd387c9 100644 > --- a/docs/man/xl.pod.1 > +++ b/docs/man/xl.pod.1 > @@ -550,7 +550,7 @@ B<OPTIONS> > > =over 4 > > -=item B<-w> > +=item B<-w>, B<--wait> > > Wait for the domain to complete shutdown before returning. > > diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c > index 93066d3..768ba1f 100644 > --- a/tools/libxl/xl_cmdimpl.c > +++ b/tools/libxl/xl_cmdimpl.c > @@ -3709,8 +3709,13 @@ int main_shutdown(int argc, char **argv) > int opt; > int wait_for_it = 0; > int fallback_trigger = 0; > + int option_index = 0; > + static struct option long_options[] = { > + {"wait", 0, 0, ''w''}, > + {0, 0, 0, 0} > + }; > > - while ((opt = def_getopt(argc, argv, "wF", "shutdown", 1)) != -1) { > + while ((opt = getopt_long(argc, argv, "wF", long_options, &option_index)) != -1) {Since you don''t use it you can pass NULL instead of &option_index.> switch (opt) { > case 0: case 2: > return opt; > diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c > index 85ea768..b398c0a 100644 > --- a/tools/libxl/xl_cmdtable.c > +++ b/tools/libxl/xl_cmdtable.c > @@ -64,7 +64,7 @@ struct cmd_spec cmd_table[] = { > "-h Print this help.\n" > "-F Fallback to ACPI power event for HVM guests with\n" > " no PV drivers.\n" > - "-w Wait for guest to shutdown.\n" > + "-w, --wait Wait for guest to shutdown.\n" > }, > { "reboot", > &main_reboot, 0, 1,
Christoph Egger
2012-Oct-11 09:05 UTC
Re: [PATCH 1/3] init/sysconfig scripts: Remove --halt/-H option for shutdown command.
On 10/11/12 10:52, Ian Campbell wrote:> On Thu, 2012-10-11 at 09:25 +0100, linux@eikelenboom.it wrote: >> From: Sander Eikelenboom <linux@eikelenboom.it> >> >> The --halt/-H option for the shutdown command is now pointless, >> since linux in a guest treats "halt" and "poweroff" identically. > > This looks good to me but I''d just like to confirm that Free&NetBSD also > treat them the same before I commit it.shutdown in NetBSD never had a --halt option. shutdown runs the shutdown procedure and halts the system. shutdown -p runs the shutdown procedure and then powers off the system. Christoph> > Ian. > >> The option is not implemented in xl / libxl and if supplied causes the command >> to fail , so remove it from the init and sysconfig scripts. >> >> Signed-off-by: Sander Eikelenboom <linux@eikelenboom.it> >> --- >> tools/hotplug/Linux/init.d/sysconfig.xendomains | 12 ++++++------ >> tools/hotplug/Linux/init.d/xendomains | 4 ++-- >> tools/hotplug/NetBSD/rc.d/xendomains | 2 +- >> 3 files changed, 9 insertions(+), 9 deletions(-) >> >> diff --git a/tools/hotplug/Linux/init.d/sysconfig.xendomains b/tools/hotplug/Linux/init.d/sysconfig.xendomains >> index e590d3f..4775277 100644 >> --- a/tools/hotplug/Linux/init.d/sysconfig.xendomains >> +++ b/tools/hotplug/Linux/init.d/sysconfig.xendomains >> @@ -56,29 +56,29 @@ XENDOMAINS_MIGRATE="" >> XENDOMAINS_SAVE=/var/lib/xen/save >> >> ## Type: string >> -## Default: "--halt --wait" >> +## Default: "--wait" >> # >> # If neither MIGRATE nor SAVE were enabled or if they failed, you can >> # try to shut down a domain by sending it a shutdown request. To do this, >> -# set this to "--halt --wait". Omit the "--wait" flag to avoid waiting >> +# set this to "--wait". Omit the "--wait" flag to avoid waiting >> # for the domain to be really down. Leave empty to skip domain shutdown. >> # >> -XENDOMAINS_SHUTDOWN="--halt --wait" >> +XENDOMAINS_SHUTDOWN="--wait" >> >> ## Type: string >> -## Default: "--all --halt --wait" >> +## Default: "--all --wait" >> # >> # After we have gone over all virtual machines (resp. all automatically >> # started ones, see XENDOMAINS_AUTO_ONLY below) in a loop and sent SysRq, >> # migrated, saved and/or shutdown according to the settings above, we >> # might want to shutdown the virtual machines that are still running >> # for some reason or another. To do this, set this variable to >> -# "--all --halt --wait", it will be passed to xm shutdown. >> +# "--all --wait", it will be passed to xm shutdown. >> # Leave it empty not to do anything special here. >> # (Note: This will hit all virtual machines, even if XENDOMAINS_AUTO_ONLY >> # is set.) >> # >> -XENDOMAINS_SHUTDOWN_ALL="--all --halt --wait" >> +XENDOMAINS_SHUTDOWN_ALL="--all --wait" >> >> ## Type: boolean >> ## Default: true >> diff --git a/tools/hotplug/Linux/init.d/xendomains b/tools/hotplug/Linux/init.d/xendomains >> index c033581..c363208 100644 >> --- a/tools/hotplug/Linux/init.d/xendomains >> +++ b/tools/hotplug/Linux/init.d/xendomains >> @@ -434,7 +434,7 @@ stop() >> fi >> fi >> if test -n "$XENDOMAINS_SHUTDOWN"; then >> - # XENDOMAINS_SHUTDOWN should be "--halt --wait" >> + # XENDOMAINS_SHUTDOWN should be "--wait" >> echo -n "(shut)" >> watchdog_xencmd shutdown & >> WDOG_PID=$! >> @@ -453,7 +453,7 @@ stop() >> # This is because it''s easier to do ;-) but arguably if this script is run >> # on system shutdown then it''s also the right thing to do. >> if ! all_zombies && test -n "$XENDOMAINS_SHUTDOWN_ALL"; then >> - # XENDOMAINS_SHUTDOWN_ALL should be "--all --halt --wait" >> + # XENDOMAINS_SHUTDOWN_ALL should be "--all --wait" >> echo -n " SHUTDOWN_ALL " >> watchdog_xencmd shutdown 1 false & >> WDOG_PID=$! >> diff --git a/tools/hotplug/NetBSD/rc.d/xendomains b/tools/hotplug/NetBSD/rc.d/xendomains >> index c368c58..3e62038 100644 >> --- a/tools/hotplug/NetBSD/rc.d/xendomains >> +++ b/tools/hotplug/NetBSD/rc.d/xendomains >> @@ -94,7 +94,7 @@ xendomains_stop() >> # >> echo "Stopping xen domains." >> for domain in $(xendomains_list); do >> - ${ctl_command} shutdown --halt $domain >> + ${ctl_command} shutdown $domain >> done >> while [ $timeout -gt 0 ]; do >> livedomains=$(xendomains_list) > > >-- ---to satisfy European Law for business letters: Advanced Micro Devices GmbH Einsteinring 24, 85689 Dornach b. Muenchen Geschaeftsfuehrer: Alberto Bozzo Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632
Ian Campbell
2012-Oct-11 09:21 UTC
Re: [PATCH 2/3] init scripts: xendomains correct order of options for shutdown command
On Thu, 2012-10-11 at 09:25 +0100, linux@eikelenboom.it wrote:> From: Sander Eikelenboom <linux@eikelenboom.it> > > Options for the shutdown command that are supplied behind the domain id are > ignored. In case of the default xendomains init script this means that it will > not wait for the domains to be actually shutdown. > > Signed-off-by: Sander Eikelenboom <linux@eikelenboom.it>Acked-by: Ian Campbell <ian.campbell@citrix.com> and applied, thanks.> --- > tools/hotplug/Linux/init.d/xendomains | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/tools/hotplug/Linux/init.d/xendomains b/tools/hotplug/Linux/init.d/xendomains > index c363208..00e5944 100644 > --- a/tools/hotplug/Linux/init.d/xendomains > +++ b/tools/hotplug/Linux/init.d/xendomains > @@ -438,7 +438,7 @@ stop() > echo -n "(shut)" > watchdog_xencmd shutdown & > WDOG_PID=$! > - XMR=`$CMD shutdown $id $XENDOMAINS_SHUTDOWN 2>&1 1>/dev/null` > + XMR=`$CMD shutdown $XENDOMAINS_SHUTDOWN $id 2>&1 1>/dev/null` > if test $? -ne 0; then > echo -e "\nAn error occurred while shutting down domain:\n$XMR\n" > rc_failed $?
linux@eikelenboom.it
2012-Oct-11 10:25 UTC
[PATCH v2 3/3] xl/libxl: make shutdown accept the long option --wait for -w
From: Sander Eikelenboom <linux@eikelenboom.it> Make xl/libxl accept the long option --wait for -w to be compatible with xm. The long options are used in the default init and sysconfig scripts. Signed-off-by: Sander Eikelenboom <linux@eikelenboom.it> --- docs/man/xl.pod.1 | 2 +- tools/libxl/xl_cmdimpl.c | 6 +++++- tools/libxl/xl_cmdtable.c | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/man/xl.pod.1 b/docs/man/xl.pod.1 index 25ce777..dd387c9 100644 --- a/docs/man/xl.pod.1 +++ b/docs/man/xl.pod.1 @@ -550,7 +550,7 @@ B<OPTIONS> =over 4 -=item B<-w> +=item B<-w>, B<--wait> Wait for the domain to complete shutdown before returning. diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 93066d3..389b5f7 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -3709,8 +3709,12 @@ int main_shutdown(int argc, char **argv) int opt; int wait_for_it = 0; int fallback_trigger = 0; + static struct option long_options[] = { + {"wait", 0, 0, ''w''}, + {0, 0, 0, 0} + }; - while ((opt = def_getopt(argc, argv, "wF", "shutdown", 1)) != -1) { + while ((opt = getopt_long(argc, argv, "wF", long_options, NULL)) != -1) { switch (opt) { case 0: case 2: return opt; diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c index 85ea768..b398c0a 100644 --- a/tools/libxl/xl_cmdtable.c +++ b/tools/libxl/xl_cmdtable.c @@ -64,7 +64,7 @@ struct cmd_spec cmd_table[] = { "-h Print this help.\n" "-F Fallback to ACPI power event for HVM guests with\n" " no PV drivers.\n" - "-w Wait for guest to shutdown.\n" + "-w, --wait Wait for guest to shutdown.\n" }, { "reboot", &main_reboot, 0, 1, -- 1.7.2.5
Ian Campbell
2012-Oct-11 10:52 UTC
Re: [PATCH 1/3] init/sysconfig scripts: Remove --halt/-H option for shutdown command.
On Thu, 2012-10-11 at 10:05 +0100, Christoph Egger wrote:> On 10/11/12 10:52, Ian Campbell wrote: > > On Thu, 2012-10-11 at 09:25 +0100, linux@eikelenboom.it wrote: > >> From: Sander Eikelenboom <linux@eikelenboom.it> > >> > >> The --halt/-H option for the shutdown command is now pointless, > >> since linux in a guest treats "halt" and "poweroff" identically. > > > > This looks good to me but I''d just like to confirm that Free&NetBSD also > > treat them the same before I commit it. > > shutdown in NetBSD never had a --halt option. > shutdown runs the shutdown procedure and halts the system. > shutdown -p runs the shutdown procedure and then powers off the system.Thanks, I''ve acked + applied this now. Ian.> > Christoph > > > > > Ian. > > > >> The option is not implemented in xl / libxl and if supplied causes the command > >> to fail , so remove it from the init and sysconfig scripts. > >> > >> Signed-off-by: Sander Eikelenboom <linux@eikelenboom.it> > >> --- > >> tools/hotplug/Linux/init.d/sysconfig.xendomains | 12 ++++++------ > >> tools/hotplug/Linux/init.d/xendomains | 4 ++-- > >> tools/hotplug/NetBSD/rc.d/xendomains | 2 +- > >> 3 files changed, 9 insertions(+), 9 deletions(-) > >> > >> diff --git a/tools/hotplug/Linux/init.d/sysconfig.xendomains b/tools/hotplug/Linux/init.d/sysconfig.xendomains > >> index e590d3f..4775277 100644 > >> --- a/tools/hotplug/Linux/init.d/sysconfig.xendomains > >> +++ b/tools/hotplug/Linux/init.d/sysconfig.xendomains > >> @@ -56,29 +56,29 @@ XENDOMAINS_MIGRATE="" > >> XENDOMAINS_SAVE=/var/lib/xen/save > >> > >> ## Type: string > >> -## Default: "--halt --wait" > >> +## Default: "--wait" > >> # > >> # If neither MIGRATE nor SAVE were enabled or if they failed, you can > >> # try to shut down a domain by sending it a shutdown request. To do this, > >> -# set this to "--halt --wait". Omit the "--wait" flag to avoid waiting > >> +# set this to "--wait". Omit the "--wait" flag to avoid waiting > >> # for the domain to be really down. Leave empty to skip domain shutdown. > >> # > >> -XENDOMAINS_SHUTDOWN="--halt --wait" > >> +XENDOMAINS_SHUTDOWN="--wait" > >> > >> ## Type: string > >> -## Default: "--all --halt --wait" > >> +## Default: "--all --wait" > >> # > >> # After we have gone over all virtual machines (resp. all automatically > >> # started ones, see XENDOMAINS_AUTO_ONLY below) in a loop and sent SysRq, > >> # migrated, saved and/or shutdown according to the settings above, we > >> # might want to shutdown the virtual machines that are still running > >> # for some reason or another. To do this, set this variable to > >> -# "--all --halt --wait", it will be passed to xm shutdown. > >> +# "--all --wait", it will be passed to xm shutdown. > >> # Leave it empty not to do anything special here. > >> # (Note: This will hit all virtual machines, even if XENDOMAINS_AUTO_ONLY > >> # is set.) > >> # > >> -XENDOMAINS_SHUTDOWN_ALL="--all --halt --wait" > >> +XENDOMAINS_SHUTDOWN_ALL="--all --wait" > >> > >> ## Type: boolean > >> ## Default: true > >> diff --git a/tools/hotplug/Linux/init.d/xendomains b/tools/hotplug/Linux/init.d/xendomains > >> index c033581..c363208 100644 > >> --- a/tools/hotplug/Linux/init.d/xendomains > >> +++ b/tools/hotplug/Linux/init.d/xendomains > >> @@ -434,7 +434,7 @@ stop() > >> fi > >> fi > >> if test -n "$XENDOMAINS_SHUTDOWN"; then > >> - # XENDOMAINS_SHUTDOWN should be "--halt --wait" > >> + # XENDOMAINS_SHUTDOWN should be "--wait" > >> echo -n "(shut)" > >> watchdog_xencmd shutdown & > >> WDOG_PID=$! > >> @@ -453,7 +453,7 @@ stop() > >> # This is because it''s easier to do ;-) but arguably if this script is run > >> # on system shutdown then it''s also the right thing to do. > >> if ! all_zombies && test -n "$XENDOMAINS_SHUTDOWN_ALL"; then > >> - # XENDOMAINS_SHUTDOWN_ALL should be "--all --halt --wait" > >> + # XENDOMAINS_SHUTDOWN_ALL should be "--all --wait" > >> echo -n " SHUTDOWN_ALL " > >> watchdog_xencmd shutdown 1 false & > >> WDOG_PID=$! > >> diff --git a/tools/hotplug/NetBSD/rc.d/xendomains b/tools/hotplug/NetBSD/rc.d/xendomains > >> index c368c58..3e62038 100644 > >> --- a/tools/hotplug/NetBSD/rc.d/xendomains > >> +++ b/tools/hotplug/NetBSD/rc.d/xendomains > >> @@ -94,7 +94,7 @@ xendomains_stop() > >> # > >> echo "Stopping xen domains." > >> for domain in $(xendomains_list); do > >> - ${ctl_command} shutdown --halt $domain > >> + ${ctl_command} shutdown $domain > >> done > >> while [ $timeout -gt 0 ]; do > >> livedomains=$(xendomains_list) > > > > > > > >
Ian Campbell
2012-Oct-11 10:52 UTC
Re: [PATCH v2 3/3] xl/libxl: make shutdown accept the long option --wait for -w
On Thu, 2012-10-11 at 11:25 +0100, linux@eikelenboom.it wrote:> From: Sander Eikelenboom <linux@eikelenboom.it> > > Make xl/libxl accept the long option --wait for -w to be compatible with xm. > The long options are used in the default init and sysconfig scripts. > > Signed-off-by: Sander Eikelenboom <linux@eikelenboom.it>Acked-by: Ian Campbell <ian.campbell@citrix.com> and committed, thanks.> --- > docs/man/xl.pod.1 | 2 +- > tools/libxl/xl_cmdimpl.c | 6 +++++- > tools/libxl/xl_cmdtable.c | 2 +- > 3 files changed, 7 insertions(+), 3 deletions(-) > > diff --git a/docs/man/xl.pod.1 b/docs/man/xl.pod.1 > index 25ce777..dd387c9 100644 > --- a/docs/man/xl.pod.1 > +++ b/docs/man/xl.pod.1 > @@ -550,7 +550,7 @@ B<OPTIONS> > > =over 4 > > -=item B<-w> > +=item B<-w>, B<--wait> > > Wait for the domain to complete shutdown before returning. > > diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c > index 93066d3..389b5f7 100644 > --- a/tools/libxl/xl_cmdimpl.c > +++ b/tools/libxl/xl_cmdimpl.c > @@ -3709,8 +3709,12 @@ int main_shutdown(int argc, char **argv) > int opt; > int wait_for_it = 0; > int fallback_trigger = 0; > + static struct option long_options[] = { > + {"wait", 0, 0, ''w''}, > + {0, 0, 0, 0} > + }; > > - while ((opt = def_getopt(argc, argv, "wF", "shutdown", 1)) != -1) { > + while ((opt = getopt_long(argc, argv, "wF", long_options, NULL)) != -1) { > switch (opt) { > case 0: case 2: > return opt; > diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c > index 85ea768..b398c0a 100644 > --- a/tools/libxl/xl_cmdtable.c > +++ b/tools/libxl/xl_cmdtable.c > @@ -64,7 +64,7 @@ struct cmd_spec cmd_table[] = { > "-h Print this help.\n" > "-F Fallback to ACPI power event for HVM guests with\n" > " no PV drivers.\n" > - "-w Wait for guest to shutdown.\n" > + "-w, --wait Wait for guest to shutdown.\n" > }, > { "reboot", > &main_reboot, 0, 1,