[libvirt] [PATCH] lxc: Add destroy support for suspended domains
Michal Privoznik
mprivozn at redhat.com
Thu Feb 20 09:51:01 UTC 2014
On 14.02.2014 16:42, Richard Weinberger wrote:
> Destroying a suspended domain needs special action.
> We cannot simply terminate all process because they are frozen.
> Do deal with that we send them SIGKILL and thaw them.
> Upon wakeup the process sees the pending signal and dies immediately.
>
> Signed-off-by: Richard Weinberger <richard at nod.at>
> ---
> src/lxc/lxc_process.c | 25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
>
> diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
> index ed729f6..b518dce 100644
> --- a/src/lxc/lxc_process.c
> +++ b/src/lxc/lxc_process.c
> @@ -697,6 +697,30 @@ int virLXCProcessStop(virLXCDriverPtr driver,
> VIR_FREE(vm->def->seclabels[0]->imagelabel);
> }
>
> + /* If the LXC domain is suspended we send all processes a SIGKILL
> + * and thaw them. Upon wakeup the process sees the pending signal
> + * and dies immediately. It is guaranteed that priv->cgroup != NULL
> + * here because the domain has aleady been suspended using the
> + * freezer cgroup.
> + */
> + if (reason == VIR_DOMAIN_SHUTOFF_DESTROYED &&
> + virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED) {
> + if (virCgroupKillRecursive(priv->cgroup, SIGKILL) <= 0) {
> + virReportError(VIR_ERR_INTERNAL_ERROR,
> + _("Unable to kill all processes"));
Just a minor nit pick: we tend to write it as virReportError(code, "%s",
_("message")).
> + return -1;
> + }
> +
> + if (virCgroupSetFreezerState(priv->cgroup, "THAWED") < 0) {
> + virReportError(VIR_ERR_OPERATION_FAILED,
> + _("Unable to thaw all processes"));
Here too.
> +
> + return -1;
> + }
> +
> + goto cleanup;
> + }
> +
> if (priv->cgroup) {
> rc = virCgroupKillPainfully(priv->cgroup);
> if (rc < 0)
> @@ -716,6 +740,7 @@ int virLXCProcessStop(virLXCDriverPtr driver,
> }
> }
>
> +cleanup:
> virLXCProcessCleanup(driver, vm, reason);
>
> return 0;
>
Fixed, ACKed & pushed. Thanks.
Michal
More information about the libvir-list
mailing list