* [PATCH] xl: Allow shutdown wait for domain death
@ 2020-06-17 2:36 Jason Andryuk
2020-06-18 15:43 ` [PATCH for-4.14] " Ian Jackson
0 siblings, 1 reply; 4+ messages in thread
From: Jason Andryuk @ 2020-06-17 2:36 UTC (permalink / raw)
To: xen-devel; +Cc: Anthony PERARD, Ian Jackson, Wei Liu, Jason Andryuk
`xl shutdown -w` waits for the first of either domain shutdown or death.
Shutdown is the halting of the guest operating system, and death is the
freeing of domain resources.
Allow specifying -w multiple times to wait for only domain death. This
is useful in scripts so that all resources are free before the script
continues.
Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
---
docs/man/xl.1.pod.in | 4 +++-
tools/xl/xl_vmcontrol.c | 17 +++++++++++------
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/docs/man/xl.1.pod.in b/docs/man/xl.1.pod.in
index 09339282e6..52a47a6fbd 100644
--- a/docs/man/xl.1.pod.in
+++ b/docs/man/xl.1.pod.in
@@ -743,7 +743,9 @@ of a Xen system.
=item B<-w>, B<--wait>
-Wait for the domain to complete shutdown before returning.
+Wait for the domain to complete shutdown before returning. If given once,
+the wait is for domain shutdown or domain death. If given multiple times,
+the wait is for domain death only.
=item B<-F>
diff --git a/tools/xl/xl_vmcontrol.c b/tools/xl/xl_vmcontrol.c
index 17b4514c94..435155a033 100644
--- a/tools/xl/xl_vmcontrol.c
+++ b/tools/xl/xl_vmcontrol.c
@@ -162,7 +162,8 @@ static void shutdown_domain(uint32_t domid,
}
}
-static void wait_for_domain_deaths(libxl_evgen_domain_death **deathws, int nr)
+static void wait_for_domain_deaths(libxl_evgen_domain_death **deathws, int nr,
+ int wait_for_shutdown_or_death)
{
int rc, count = 0;
LOG("Waiting for %d domains", nr);
@@ -183,8 +184,12 @@ static void wait_for_domain_deaths(libxl_evgen_domain_death **deathws, int nr)
case LIBXL_EVENT_TYPE_DOMAIN_SHUTDOWN:
LOG("Domain %d has been shut down, reason code %d",
event->domid, event->u.domain_shutdown.shutdown_reason);
- libxl_evdisable_domain_death(ctx, deathws[event->for_user]);
- count++;
+ if (wait_for_shutdown_or_death) {
+ libxl_evdisable_domain_death(ctx, deathws[event->for_user]);
+ count++;
+ } else {
+ LOG("Domain %d continue waiting for death", event->domid);
+ }
break;
default:
LOG("Unexpected event type %d", event->type);
@@ -214,7 +219,7 @@ static int main_shutdown_or_reboot(int do_reboot, int argc, char **argv)
all = 1;
break;
case 'w':
- wait_for_it = 1;
+ wait_for_it++;
break;
case 'F':
fallback_trigger = 1;
@@ -246,7 +251,7 @@ static int main_shutdown_or_reboot(int do_reboot, int argc, char **argv)
}
if (deathws) {
- wait_for_domain_deaths(deathws, nrdeathws);
+ wait_for_domain_deaths(deathws, nrdeathws, wait_for_it == 1);
free(deathws);
}
@@ -258,7 +263,7 @@ static int main_shutdown_or_reboot(int do_reboot, int argc, char **argv)
fn(domid, wait_for_it ? &deathw : NULL, 0, fallback_trigger);
if (wait_for_it)
- wait_for_domain_deaths(&deathw, 1);
+ wait_for_domain_deaths(&deathw, 1, wait_for_it == 1);
}
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH for-4.14] xl: Allow shutdown wait for domain death
2020-06-17 2:36 [PATCH] xl: Allow shutdown wait for domain death Jason Andryuk
@ 2020-06-18 15:43 ` Ian Jackson
2020-06-18 15:52 ` Paul Durrant
0 siblings, 1 reply; 4+ messages in thread
From: Ian Jackson @ 2020-06-18 15:43 UTC (permalink / raw)
To: Jason Andryuk, Paul Durrant; +Cc: Anthony Perard, xen-devel, Wei Liu
Jason Andryuk writes ("[PATCH] xl: Allow shutdown wait for domain death"):
> `xl shutdown -w` waits for the first of either domain shutdown or death.
> Shutdown is the halting of the guest operating system, and death is the
> freeing of domain resources.
>
> Allow specifying -w multiple times to wait for only domain death. This
> is useful in scripts so that all resources are free before the script
> continues.
Thanks!
Reviewed-by: Ian Jackson <ian.jackson@eu.citrix.com>
Paul, I think this is a candidate for 4.14. Without this patch it is
not possible to reliably wait for a domain, with xl, and then restart
it. (At least not without a good deal of pratting about and polling
with xl list.) osstest has a `sleep' as a workaround...
I have reviewed this patch particularly carefully with a view to
understanding what happens if you pass just one `-w' as before.
I have convinced myself that there is definitely no change, so I don't
think this patch can introduce a regression.
Ian.
> Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
> ---
> docs/man/xl.1.pod.in | 4 +++-
> tools/xl/xl_vmcontrol.c | 17 +++++++++++------
> 2 files changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/docs/man/xl.1.pod.in b/docs/man/xl.1.pod.in
> index 09339282e6..52a47a6fbd 100644
> --- a/docs/man/xl.1.pod.in
> +++ b/docs/man/xl.1.pod.in
> @@ -743,7 +743,9 @@ of a Xen system.
>
> =item B<-w>, B<--wait>
>
> -Wait for the domain to complete shutdown before returning.
> +Wait for the domain to complete shutdown before returning. If given once,
> +the wait is for domain shutdown or domain death. If given multiple times,
> +the wait is for domain death only.
>
> =item B<-F>
>
> diff --git a/tools/xl/xl_vmcontrol.c b/tools/xl/xl_vmcontrol.c
> index 17b4514c94..435155a033 100644
> --- a/tools/xl/xl_vmcontrol.c
> +++ b/tools/xl/xl_vmcontrol.c
> @@ -162,7 +162,8 @@ static void shutdown_domain(uint32_t domid,
> }
> }
>
> -static void wait_for_domain_deaths(libxl_evgen_domain_death **deathws, int nr)
> +static void wait_for_domain_deaths(libxl_evgen_domain_death **deathws, int nr,
> + int wait_for_shutdown_or_death)
> {
> int rc, count = 0;
> LOG("Waiting for %d domains", nr);
> @@ -183,8 +184,12 @@ static void wait_for_domain_deaths(libxl_evgen_domain_death **deathws, int nr)
> case LIBXL_EVENT_TYPE_DOMAIN_SHUTDOWN:
> LOG("Domain %d has been shut down, reason code %d",
> event->domid, event->u.domain_shutdown.shutdown_reason);
> - libxl_evdisable_domain_death(ctx, deathws[event->for_user]);
> - count++;
> + if (wait_for_shutdown_or_death) {
> + libxl_evdisable_domain_death(ctx, deathws[event->for_user]);
> + count++;
> + } else {
> + LOG("Domain %d continue waiting for death", event->domid);
> + }
> break;
> default:
> LOG("Unexpected event type %d", event->type);
> @@ -214,7 +219,7 @@ static int main_shutdown_or_reboot(int do_reboot, int argc, char **argv)
> all = 1;
> break;
> case 'w':
> - wait_for_it = 1;
> + wait_for_it++;
> break;
> case 'F':
> fallback_trigger = 1;
> @@ -246,7 +251,7 @@ static int main_shutdown_or_reboot(int do_reboot, int argc, char **argv)
> }
>
> if (deathws) {
> - wait_for_domain_deaths(deathws, nrdeathws);
> + wait_for_domain_deaths(deathws, nrdeathws, wait_for_it == 1);
> free(deathws);
> }
>
> @@ -258,7 +263,7 @@ static int main_shutdown_or_reboot(int do_reboot, int argc, char **argv)
> fn(domid, wait_for_it ? &deathw : NULL, 0, fallback_trigger);
>
> if (wait_for_it)
> - wait_for_domain_deaths(&deathw, 1);
> + wait_for_domain_deaths(&deathw, 1, wait_for_it == 1);
> }
>
>
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH for-4.14] xl: Allow shutdown wait for domain death
2020-06-18 15:43 ` [PATCH for-4.14] " Ian Jackson
@ 2020-06-18 15:52 ` Paul Durrant
2020-06-18 16:00 ` Ian Jackson
0 siblings, 1 reply; 4+ messages in thread
From: Paul Durrant @ 2020-06-18 15:52 UTC (permalink / raw)
To: 'Ian Jackson', 'Jason Andryuk', 'Paul Durrant'
Cc: 'Anthony Perard', xen-devel, 'Wei Liu'
> -----Original Message-----
> From: Ian Jackson <ian.jackson@citrix.com>
> Sent: 18 June 2020 16:44
> To: Jason Andryuk <jandryuk@gmail.com>; Paul Durrant <xadimgnik@gmail.com>
> Cc: xen-devel@lists.xenproject.org; Wei Liu <wl@xen.org>; Anthony Perard <anthony.perard@citrix.com>
> Subject: Re: [PATCH for-4.14] xl: Allow shutdown wait for domain death
>
> Jason Andryuk writes ("[PATCH] xl: Allow shutdown wait for domain death"):
> > `xl shutdown -w` waits for the first of either domain shutdown or death.
> > Shutdown is the halting of the guest operating system, and death is the
> > freeing of domain resources.
> >
> > Allow specifying -w multiple times to wait for only domain death. This
> > is useful in scripts so that all resources are free before the script
> > continues.
>
> Thanks!
>
> Reviewed-by: Ian Jackson <ian.jackson@eu.citrix.com>
>
> Paul, I think this is a candidate for 4.14. Without this patch it is
> not possible to reliably wait for a domain, with xl, and then restart
> it. (At least not without a good deal of pratting about and polling
> with xl list.) osstest has a `sleep' as a workaround...
>
Yes, it would nice to drop such workarounds.
> I have reviewed this patch particularly carefully with a view to
> understanding what happens if you pass just one `-w' as before.
> I have convinced myself that there is definitely no change, so I don't
> think this patch can introduce a regression.
Ok, I'll trust your judgement.
Release-acked-by: Paul Durrant <paul@xen.org>
>
> Ian.
>
> > Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
> > ---
> > docs/man/xl.1.pod.in | 4 +++-
> > tools/xl/xl_vmcontrol.c | 17 +++++++++++------
> > 2 files changed, 14 insertions(+), 7 deletions(-)
> >
> > diff --git a/docs/man/xl.1.pod.in b/docs/man/xl.1.pod.in
> > index 09339282e6..52a47a6fbd 100644
> > --- a/docs/man/xl.1.pod.in
> > +++ b/docs/man/xl.1.pod.in
> > @@ -743,7 +743,9 @@ of a Xen system.
> >
> > =item B<-w>, B<--wait>
> >
> > -Wait for the domain to complete shutdown before returning.
> > +Wait for the domain to complete shutdown before returning. If given once,
> > +the wait is for domain shutdown or domain death. If given multiple times,
> > +the wait is for domain death only.
> >
> > =item B<-F>
> >
> > diff --git a/tools/xl/xl_vmcontrol.c b/tools/xl/xl_vmcontrol.c
> > index 17b4514c94..435155a033 100644
> > --- a/tools/xl/xl_vmcontrol.c
> > +++ b/tools/xl/xl_vmcontrol.c
> > @@ -162,7 +162,8 @@ static void shutdown_domain(uint32_t domid,
> > }
> > }
> >
> > -static void wait_for_domain_deaths(libxl_evgen_domain_death **deathws, int nr)
> > +static void wait_for_domain_deaths(libxl_evgen_domain_death **deathws, int nr,
> > + int wait_for_shutdown_or_death)
> > {
> > int rc, count = 0;
> > LOG("Waiting for %d domains", nr);
> > @@ -183,8 +184,12 @@ static void wait_for_domain_deaths(libxl_evgen_domain_death **deathws, int nr)
> > case LIBXL_EVENT_TYPE_DOMAIN_SHUTDOWN:
> > LOG("Domain %d has been shut down, reason code %d",
> > event->domid, event->u.domain_shutdown.shutdown_reason);
> > - libxl_evdisable_domain_death(ctx, deathws[event->for_user]);
> > - count++;
> > + if (wait_for_shutdown_or_death) {
> > + libxl_evdisable_domain_death(ctx, deathws[event->for_user]);
> > + count++;
> > + } else {
> > + LOG("Domain %d continue waiting for death", event->domid);
> > + }
> > break;
> > default:
> > LOG("Unexpected event type %d", event->type);
> > @@ -214,7 +219,7 @@ static int main_shutdown_or_reboot(int do_reboot, int argc, char **argv)
> > all = 1;
> > break;
> > case 'w':
> > - wait_for_it = 1;
> > + wait_for_it++;
> > break;
> > case 'F':
> > fallback_trigger = 1;
> > @@ -246,7 +251,7 @@ static int main_shutdown_or_reboot(int do_reboot, int argc, char **argv)
> > }
> >
> > if (deathws) {
> > - wait_for_domain_deaths(deathws, nrdeathws);
> > + wait_for_domain_deaths(deathws, nrdeathws, wait_for_it == 1);
> > free(deathws);
> > }
> >
> > @@ -258,7 +263,7 @@ static int main_shutdown_or_reboot(int do_reboot, int argc, char **argv)
> > fn(domid, wait_for_it ? &deathw : NULL, 0, fallback_trigger);
> >
> > if (wait_for_it)
> > - wait_for_domain_deaths(&deathw, 1);
> > + wait_for_domain_deaths(&deathw, 1, wait_for_it == 1);
> > }
> >
> >
> > --
> > 2.25.1
> >
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH for-4.14] xl: Allow shutdown wait for domain death
2020-06-18 15:52 ` Paul Durrant
@ 2020-06-18 16:00 ` Ian Jackson
0 siblings, 0 replies; 4+ messages in thread
From: Ian Jackson @ 2020-06-18 16:00 UTC (permalink / raw)
To: paul
Cc: Anthony Perard, xen-devel, 'Wei Liu',
'Paul Durrant', 'Jason Andryuk'
Paul Durrant writes ("RE: [PATCH for-4.14] xl: Allow shutdown wait for domain death"):
> > -----Original Message-----
> > From: Ian Jackson <ian.jackson@citrix.com>
...
> > I have reviewed this patch particularly carefully with a view to
> > understanding what happens if you pass just one `-w' as before.
> > I have convinced myself that there is definitely no change, so I don't
> > think this patch can introduce a regression.
>
> Ok, I'll trust your judgement.
Thanks :-). Pushed.
Ian.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-06-18 16:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-17 2:36 [PATCH] xl: Allow shutdown wait for domain death Jason Andryuk
2020-06-18 15:43 ` [PATCH for-4.14] " Ian Jackson
2020-06-18 15:52 ` Paul Durrant
2020-06-18 16:00 ` Ian Jackson
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).