virObjectRef(vm);
virDomainObjListRemove(driver->domains, vm);
+ /*
+ * virDomainObjListRemove() leaves the domain unlocked so it can
+ * be unref'd for other drivers that depend on that, but we still
+ * need to reset a job and we have a reference from the API that
+ * called this function. So we need to lock it back. This is
+ * just a workaround for the qemu driver.
+ *
+ * XXX: Ideally, the global handling of domain objects and object
+ * lists would be refactored so we don't need hacks like
+ * this, but since that requires refactor of all drivers,
+ * it's a work for another day.
+ */
+ virObjectLock(vm);
virObjectUnref(cfg);
if (haveJob)
if (priv->beingDestroyed) {
VIR_DEBUG("Domain is being destroyed, EOF is expected");
- goto unlock;
+ goto cleanup;
}
if (!virDomainObjIsActive(vm)) {
VIR_DEBUG("Domain %p is not active, ignoring EOF", vm);
- goto unlock;
+ goto cleanup;
}
if (priv->monJSON && !priv->gotShutdown) {
qemuProcessStop(driver, vm, stopReason, stopFlags);
virDomainAuditStop(vm, auditReason);
- if (!vm->persistent) {
+ if (!vm->persistent)
qemuDomainRemoveInactive(driver, vm);
- goto cleanup;
- }
-
- unlock:
- virObjectUnlock(vm);
cleanup:
+ virObjectUnlock(vm);
if (event)
qemuDomainEventQueue(driver, event);
}
VIR_DEBUG("vm=%s, conn=%p", dom->def->name, conn);
+ virObjectRef(dom);
+
if (priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_IN)
stopFlags |= VIR_QEMU_PROCESS_STOP_MIGRATED;
qemuDomainObjEndJob(driver, dom);
- if (!dom->persistent) {
+ if (!dom->persistent)
qemuDomainRemoveInactive(driver, dom);
- dom = NULL;
- }
if (event)
qemuDomainEventQueue(driver, event);
cleanup:
+ virDomainObjEndAPI(&dom);
return dom;
}