From: 王鹏钧10288409 <10288409@zte.intra(a)LIN-184C297BAE7.zte.com.cn>
Virsh shutdown is executed firstly, virsh destroy is executed later,
and VM is recreated again. In this process, due to will delet Domain
object about the new VM in processMonitorEOFEvent(), which
virDomainObjListRemove is called to remove objlist, the new VM
cannot be found through virsh list command and qemu process is still
running. Therefore, add virDomainObjListFindByName function checks
to avoid delet Domain object about the new VM in objlist.
This process chart of problem is as follows
shutdown | destroy | create
============================+==================+===================
qemuMonitorIO | |
qemuProcessHandleMonitorEOF | |
| virDomainDestroy |
| qemuProcessStop |
| | qemuDomainCreateXML
| | qemuProcessInit
processMonitorEOFEvent | |
qemuDomainRemoveInactive | |
| | qemuProcessLaunch
Signed-off-by: Wang PengJun <wang.pengjun1(a)zte.com.cn>
Signed-off-by: Yi Wang <wang.yi59(a)zte.com.cn>
---
src/qemu/qemu_driver.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 8c0e36e9b2..c16e9a9795 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4024,6 +4024,7 @@ processMonitorEOFEvent(virQEMUDriver *driver,
const char *auditReason = "shutdown";
unsigned int stopFlags = 0;
virObjectEvent *event = NULL;
+ virDomainObj *obj;
if (qemuProcessBeginStopJob(driver, vm, VIR_JOB_DESTROY, true) < 0)
return;
@@ -4055,8 +4056,17 @@ processMonitorEOFEvent(virQEMUDriver *driver,
virObjectEventStateQueue(driver->domainEventState, event);
endjob:
- qemuDomainRemoveInactive(driver, vm);
- qemuDomainObjEndJob(vm);
+ virObjectUnlock(vm);
+ obj = virDomainObjListFindByName(driver->domains, vm->def->name);
+ if (vm == obj) {
+ qemuDomainRemoveInactive(driver, vm);
+ qemuDomainObjEndJob(vm);
+ }
+ virDomainObjEndAPI(&obj);
+ if (vm != NULL) {
+ virObjectLock(vm);
+ qemuDomainObjEndJob(vm);
+ }
}
--
2.27.0
Show replies by date