virDomainObjPtr vm;
int ret = -1;
virDomainEventPtr event = NULL;
+ qemuDomainObjPrivatePtr priv;
virCheckFlags(0, -1);
goto cleanup;
}
+ priv = vm->privateData;
+
qemuDomainSetFakeReboot(driver, vm, false);
/* Although qemuProcessStop does this already, there may
*/
qemuProcessKill(vm, false);
+ /* We need to prevent monitor EOF callback from doing our work (and sending
+ * misleading events) while the vm is unlocked inside BeginJob API
+ */
+ priv->beingDestroyed = true;
+
if (qemuDomainObjBeginJobWithDriver(driver, vm, QEMU_JOB_DESTROY) < 0)
goto cleanup;
+ priv->beingDestroyed = false;
+
if (!virDomainObjIsActive(vm)) {
qemuReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("domain is not running"));
qemuDriverLock(driver);
virDomainObjLock(vm);
+ priv = vm->privateData;
+
+ if (priv->beingDestroyed) {
+ VIR_DEBUG("Domain is being destroyed, EOF is expected");
+ goto unlock;
+ }
+
if (!virDomainObjIsActive(vm)) {
VIR_DEBUG("Domain %p is not active, ignoring EOF", vm);
- virDomainObjUnlock(vm);
- qemuDriverUnlock(driver);
- return;
+ goto unlock;
}
- priv = vm->privateData;
if (priv->monJSON && !priv->gotShutdown) {
VIR_DEBUG("Monitor connection to '%s' closed without SHUTDOWN event; "
"assuming the domain crashed", vm->def->name);
qemuProcessStop(driver, vm, 0, stopReason);
virDomainAuditStop(vm, auditReason);
- if (!vm->persistent)
+ if (!vm->persistent) {
qemuDomainRemoveInactive(driver, vm);
- else
- virDomainObjUnlock(vm);
+ goto cleanup;
+ }
+unlock:
+ virDomainObjUnlock(vm);
+
+cleanup:
if (event)
qemuDomainEventQueue(driver, event);
qemuDriverUnlock(driver);