Hi Jiri,
Thanks for replying. Actually the no-shutdown flag behavior in qemu is
not pausing the VM shutdown, the VM shuts down normally (like you see
the linux message saying it's powered off in the tty console, and you
can't log in again), but the qemu process stays to finish the async
(coroutine) jobs in the background. If the libvirt could take the
no-shutdown flag and pass it to qemu, qemu would handle this
automatically but somehow libvirt shouldn't kill the qemu process but
wait for the process to finish working and exit normally itself. If
the VM is started again before the qemu process quits itself, we would
need to find a way maybe wait for the last qemu process to quit before
launching a new one, or reuse the qmeu process just start the VM
virtualization coroutine again inside the same qemu process.
Thanks,
Luna
On Tue, Dec 1, 2020 at 11:09 AM Jiri Denemark <jdenemar(a)redhat.com> wrote:
On Tue, Dec 01, 2020 at 15:34:05 +0100, Peter Krempa wrote:
> On Mon, Nov 30, 2020 at 14:45:18 -0500, Luna Xu wrote:
> > Hi developers,
>
> Hi,
>
> [...]
>
> > When I start a VM with the qemu command I can specify the -no-shutdown
> > flag so that my qemu process doesn't quit even if I shutdown the VM
> > from the inside (issue shutdown or halt command inside VM). The VM is
> > shutdown but the qemu process is not killed so that the jobs I
> > submitted before for example backup (drive-backup) can continue to run
> > even after VM gets shutdown by the user, and I'm able to check the
> > status of the job through qmp commands (by communicating with the qemu
> > process).
>
> As I've noted in my reply on libvirt-users, we currently don't support
> this on the shutdown part of the VM lifecycle.
>
> On the startup part you can use VIR_DOMAIN_START_PAUSED for a VM which
> didn't yet excecute any guest instructions.
>
> > Is anyone aware of any project that is currently implementing this
> > functionality? Thanks for reading.
>
> I don't think that there's anybody working on it.
>
> If you are interested in implementing the feature the idea would be to
> add a 'pause' action for <on_poweroff>pause</on_poweroff> along
with a
> new 'virDomainPausedReason' such as VIR_DOMAIN_PAUSED_POWEROFF and
> implement the lifecycle transition from PAUSED -> RUNNING via
> qemuDomainResume, which would in this case have to issue a
> 'system-reset' qmp command and emit the appropriate events.
This is weird, the domain was paused just before being shut down so
resuming it should logically just resume the paused process and finish
the shutdown. On the other hand, domain shutdown as a result of calling
resume is weird too.
So how about just adding a check to qemuDomainResume to report an error
if you try to resume a domain which was paused for shutdown?
Jirka