qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v1 1/1] osdep: asynchronous teardown for shutdown on Linux


From: Claudio Imbrenda
Subject: Re: [PATCH v1 1/1] osdep: asynchronous teardown for shutdown on Linux
Date: Mon, 6 Dec 2021 12:43:12 +0100

On Mon, 6 Dec 2021 11:21:10 +0000
Daniel P. Berrangé <berrange@redhat.com> wrote:

> On Mon, Dec 06, 2021 at 12:06:11PM +0100, Claudio Imbrenda wrote:
> > This patch adds support for asynchronously tearing down a VM on Linux.
> > 
> > When qemu terminates, either naturally or because of a fatal signal,
> > the VM is torn down. If the VM is huge, it can take a considerable
> > amount of time for it to be cleaned up. In case of a protected VM, it
> > might take even longer than a non-protected VM (this is the case on
> > s390x, for example).
> > 
> > Some users might want to shut down a VM and restart it immediately,
> > without having to wait. This is especially true if management
> > infrastructure like libvirt is used.
> > 
> > This patch implements a simple trick on Linux to allow qemu to return
> > immediately, with the teardown of the VM being performed
> > asynchronously.
> > 
> > If the new commandline option -async-teardown is used, a new process is
> > spawned from qemu using the clone syscall, so that it will share its
> > address space with qemu.
> > 
> > The new process will then wait until qemu terminates, and then it will
> > exit itself.
> > 
> > This allows qemu to terminate quickly, without having to wait for the
> > whole address space to be torn down. The teardown process will exit
> > after qemu, so it will be the last user of the address space, and
> > therefore it will take care of the actual teardown.
> > 
> > The teardown process will share the same cgroups as qemu, so both
> > memory usage and cpu time will be accounted properly.  
> 
> If this suggested workaround has any benefit to the shutdown of a VM
> with libvirt, then it is a bug in libvirt IMHO.
> 
> When libvirt tears down a QEMU VM, it should be waiting for *every*
> process in the VM's cgroup to be terminated before it reports that
> the VM is shutoff. IOW, the fact that this workaround lets the main
> QEMU process exit quickly should not matter. libvirt should still
> be blocked in exactly the same place in its code, waiting for the
> "async" cleanup process to exit. IOW, this should not be async at
> all from libvirt's POV.

interesting, I did not know that about libvirt.

maybe libvirt could be fixed/improved to allow this patch to work?

surely without this patch an asynchronous teardown will not be possible
at all

> 
> 
> Regards,
> Daniel




reply via email to

[Prev in Thread] Current Thread [Next in Thread]