Konrad Rzeszutek Wilk
2013-Nov-08 17:38 UTC
[PATCH 2/4] xen/manage: Poweroff forcefully if user-space is not yet up.
The user can launch the guest in this sequence: xl create -p /vm.cfg [launch, but pause it] xl shutdown latest [sets control/shutdown=poweroff] xl unpause latest xl console latest [and see that the guest has completely ignored the shutdown request] In reality the guest hasn''t ignored it. It registers a watch and gets a notification that there is value. It then calls the shutdown_handler which ends up calling orderly_shutdown. Unfortunately that is so early in the bootup that there are no user-space. Which means that the orderly_shutdown fails. But since the force flag was set to false it continues on without reporting. We check if the system is still in the booting stage and if so enable the force option (which will shutdown in early bootup process). If in normal running case we don''t force it. Fixes-Bug: http://bugs.xenproject.org/xen/bug/6 Reported-by: Alex Bligh <alex@alex.org.uk> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> [v2: Add switch statement] --- drivers/xen/manage.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c index 624e8dc..3f8496c 100644 --- a/drivers/xen/manage.c +++ b/drivers/xen/manage.c @@ -185,7 +185,18 @@ struct shutdown_handler { static void do_poweroff(void) { shutting_down = SHUTDOWN_POWEROFF; - orderly_poweroff(false); + switch (system_state) { + case SYSTEM_BOOTING: + orderly_poweroff(true); + break; + case SYSTEM_RUNNING: + orderly_poweroff(false); + break; + default: + /* Don''t do it when we are halting/rebooting. */ + pr_info("Ignoring Xen toolstack shutdown.\n"); + break; + } } static void do_reboot(void) -- 1.8.3.1
Boris Ostrovsky
2013-Nov-20 21:11 UTC
Re: [PATCH 2/4] xen/manage: Poweroff forcefully if user-space is not yet up.
On 11/08/2013 12:38 PM, Konrad Rzeszutek Wilk wrote:> The user can launch the guest in this sequence: > > xl create -p /vm.cfg [launch, but pause it] > xl shutdown latest [sets control/shutdown=poweroff] > xl unpause latest > xl console latest [and see that the guest has completely > ignored the shutdown request] > > In reality the guest hasn''t ignored it. It registers a watch > and gets a notification that there is value. It then calls > the shutdown_handler which ends up calling orderly_shutdown. > > Unfortunately that is so early in the bootup that there > are no user-space. Which means that the orderly_shutdown fails. > But since the force flag was set to false it continues on without > reporting. > > We check if the system is still in the booting stage and if so > enable the force option (which will shutdown in early bootup > process). If in normal running case we don''t force it. > > Fixes-Bug: http://bugs.xenproject.org/xen/bug/6 > Reported-by: Alex Bligh <alex@alex.org.uk> > Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> > [v2: Add switch statement]Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>> --- > drivers/xen/manage.c | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c > index 624e8dc..3f8496c 100644 > --- a/drivers/xen/manage.c > +++ b/drivers/xen/manage.c > @@ -185,7 +185,18 @@ struct shutdown_handler { > static void do_poweroff(void) > { > shutting_down = SHUTDOWN_POWEROFF; > - orderly_poweroff(false); > + switch (system_state) { > + case SYSTEM_BOOTING: > + orderly_poweroff(true); > + break; > + case SYSTEM_RUNNING: > + orderly_poweroff(false); > + break; > + default: > + /* Don''t do it when we are halting/rebooting. */ > + pr_info("Ignoring Xen toolstack shutdown.\n"); > + break; > + } > } > > static void do_reboot(void)
David Vrabel
2013-Nov-21 11:33 UTC
Re: [PATCH 2/4] xen/manage: Poweroff forcefully if user-space is not yet up.
On 08/11/13 17:38, Konrad Rzeszutek Wilk wrote:> The user can launch the guest in this sequence: > > xl create -p /vm.cfg [launch, but pause it] > xl shutdown latest [sets control/shutdown=poweroff] > xl unpause latest > xl console latest [and see that the guest has completely > ignored the shutdown request] > > In reality the guest hasn''t ignored it. It registers a watch > and gets a notification that there is value. It then calls > the shutdown_handler which ends up calling orderly_shutdown.Is this really a bug?. From the xl(1) man page. shutdown [OPTIONS] -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 succeed, and may take a variable length of time depending on what services must be shutdown in the domain. Seems like ignoring a shutdown request when the guest cannot yet shutdown gracefully is the expected behaviour. This also doesn''t seem sufficient. SYSTEM_RUNNING is set prior to starting init in an initramfs and orderly_power_off(false) will still likely fail at this point. David
Konrad Rzeszutek Wilk
2013-Nov-26 16:47 UTC
Re: [PATCH 2/4] xen/manage: Poweroff forcefully if user-space is not yet up.
On Thu, Nov 21, 2013 at 11:33:49AM +0000, David Vrabel wrote:> On 08/11/13 17:38, Konrad Rzeszutek Wilk wrote: > > The user can launch the guest in this sequence: > > > > xl create -p /vm.cfg [launch, but pause it] > > xl shutdown latest [sets control/shutdown=poweroff] > > xl unpause latest > > xl console latest [and see that the guest has completely > > ignored the shutdown request] > > > > In reality the guest hasn''t ignored it. It registers a watch > > and gets a notification that there is value. It then calls > > the shutdown_handler which ends up calling orderly_shutdown. > > Is this really a bug?.Yes. We did get the action, we just did not properly act on it.> > >From the xl(1) man page. > > shutdown [OPTIONS] -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 succeed, and may take a variable length of time > depending on what services must be shutdown in the domain. > > Seems like ignoring a shutdown request when the guest cannot yet > shutdown gracefully is the expected behaviour. > > This also doesn''t seem sufficient. SYSTEM_RUNNING is set prior to > starting init in an initramfs and orderly_power_off(false) will still > likely fail at this point.Ugh, will have to figure out how else to realize when it the user-space is ready to launch programs.> > David