Hello, Peter, 

I submitted one issue as the link: 
https://gitlab.com/libvirt/libvirt/-/issues/201 

Create memory snapshot while kill -9 the pid of the vm, snapshot-create-as command failed and the vm can not started again for blocked . (#201) · Issues · libvirt / libvirt · GitLab

With libvirtd debug log level.  The issue I reproduced with work flows.

Thank You!



13520781732@189.cn
 
From: Peter Krempa
Date: 2021-08-16 17:17
To: 13520781732@189.cn
CC: libvir-list
Subject: Re: Issue report: Snapshot-create-as block while the vm's process is killed out.
On Mon, Aug 16, 2021 at 11:04:12 +0800, 13520781732@189.cn wrote:
>
> Hello,
>
> I have meet one issues while using snapshot-create-as with external file.
>
> Centos 8,
> Libivirt 7.0.0
> Qemu: 5.2.0
>
> While making one snapshot with  memory and disk extaernal file,  and killing the process of the vm qemu same time mostly,  the snapshot-create-as command blocked.
> So it will failed to  start the vm again for "cannot acquire state change lock (held by monitor=remoteDispatchDomainSnapshotCreateXML)".
 
[...]
 
>
>
> The call work flow one is:
> qemuSnapshotCreateActiveExternal -> qemuSaveImageCreate -> qemuMigrationSrcToFile -> qemuMigrationSrcWaitForCompletion -> virDomainObjWait
>
> The others is similar :
>  qemuSnapshotCreateXML  -> ...
>
>
> It may be resume after the restart libvirtd.service.
>
> Is it correct that the stat change lock should be unlocked while the vm is terminal or shutdown and how to fix it?
 
The function handling the shutdown of the monitor is supposed to wake up
all waiting threads, which should prevent such a problem.
 
In this case the log attached is not enough to see what's really
happening, so please attach a full debug log and ideally report the
issue in our gitlab issue tracker:
 
https://gitlab.com/libvirt/libvirt/-/issues/new
 
Guidance on how to setup logging for debugging can be found at:
 
https://libvirt.org/kbase/debuglogs.html#less-verbose-logging-for-qemu-vms