Acquiring job introduced in commit [1] to fix a race described in the
commit. Actually it does not help because we get domain in create API
before acuiring job. Then [2] fixed the race but [1] was not reverted even
it is does not required by [2] to work properly.
[1] commit
b629c64e5e0a32ef439b8eeb3a697e2cd76f3248
Author: Martin Kletzander <mkletzan@redhat.com>
Date: Thu Oct 30 14:38:35 2014 +0100
qemu: avoid rare race when undefining domain
[2] commit
c7d1c139ca3402e875002753952e80ce8054374e
Author: Martin Kletzander <mkletzan@redhat.com>
Date: Thu Dec 11 11:14:08 2014 +0100
qemu: avoid rare race when undefining domain
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@openvz.org>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
* lock on driver->domains in order to call the remove obj
* from locked list method.
*/
-static void
+void
qemuDomainRemoveInactiveLocked(virQEMUDriver *driver,
virDomainObj *vm)
{
virDomainObjListRemoveLocked(driver->domains, vm);
}
-/**
- * qemuDomainRemoveInactiveJob:
- *
- * Just like qemuDomainRemoveInactive but it tries to grab a
- * VIR_JOB_MODIFY first. Even though it doesn't succeed in
- * grabbing the job the control carries with
- * qemuDomainRemoveInactive call.
- */
-void
-qemuDomainRemoveInactiveJob(virQEMUDriver *driver,
- virDomainObj *vm)
-{
- bool haveJob;
-
- haveJob = qemuDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) >= 0;
-
- qemuDomainRemoveInactive(driver, vm);
-
- if (haveJob)
- qemuDomainObjEndJob(vm);
-}
-
-
-/**
- * qemuDomainRemoveInactiveJobLocked:
- *
- * Similar to qemuDomainRemoveInactiveJob, except that the caller must
- * also hold the lock @driver->domains
- */
-void
-qemuDomainRemoveInactiveJobLocked(virQEMUDriver *driver,
- virDomainObj *vm)
-{
- bool haveJob;
-
- haveJob = qemuDomainObjBeginJob(driver, vm, VIR_JOB_MODIFY) >= 0;
-
- qemuDomainRemoveInactiveLocked(driver, vm);
-
- if (haveJob)
- qemuDomainObjEndJob(vm);
-}
-
void
qemuDomainSetFakeReboot(virDomainObj *vm,
void qemuDomainRemoveInactive(virQEMUDriver *driver,
virDomainObj *vm);
+void
+qemuDomainRemoveInactiveLocked(virQEMUDriver *driver,
+ virDomainObj *vm);
+
void qemuDomainSetFakeReboot(virDomainObj *vm,
bool value);
qemuDomainDefNumaCPUsRectify(virDomainDef *def,
virQEMUCaps *qemuCaps);
-void qemuDomainRemoveInactiveJob(virQEMUDriver *driver,
- virDomainObj *vm);
-
-void qemuDomainRemoveInactiveJobLocked(virQEMUDriver *driver,
- virDomainObj *vm);
-
int virQEMUFileOpenAs(uid_t fallback_uid,
gid_t fallback_gid,
bool dynamicOwnership,
if (qemuProcessBeginJob(driver, vm, VIR_DOMAIN_JOB_OPERATION_START,
flags) < 0) {
- qemuDomainRemoveInactiveJob(driver, vm);
+ qemuDomainRemoveInactive(driver, vm);
goto cleanup;
}
}
qemuDomainObjEndAsyncJob(vm);
if (ret == 0)
- qemuDomainRemoveInactiveJob(driver, vm);
+ qemuDomainRemoveInactive(driver, vm);
cleanup:
virQEMUSaveDataFree(data);
qemuDomainObjEndAsyncJob(vm);
if (ret == 0 && flags & VIR_DUMP_CRASH)
- qemuDomainRemoveInactiveJob(driver, vm);
+ qemuDomainRemoveInactive(driver, vm);
cleanup:
virDomainObjEndAPI(&vm);
endjob:
qemuDomainObjEndAsyncJob(vm);
if (removeInactive)
- qemuDomainRemoveInactiveJob(driver, vm);
+ qemuDomainRemoveInactive(driver, vm);
}
virFileWrapperFdFree(wrapperFd);
virQEMUSaveDataFree(data);
if (vm && ret < 0)
- qemuDomainRemoveInactiveJob(driver, vm);
+ qemuDomainRemoveInactive(driver, vm);
virDomainObjEndAPI(&vm);
return ret;
}
} else {
/* Brand new domain. Remove it */
VIR_INFO("Deleting domain '%s'", vm->def->name);
- qemuDomainRemoveInactiveJob(driver, vm);
+ qemuDomainRemoveInactive(driver, vm);
}
}
virPortAllocatorRelease(priv->nbdPort);
priv->nbdPort = 0;
virDomainObjRemoveTransientDef(vm);
- qemuDomainRemoveInactiveJob(driver, vm);
+ qemuDomainRemoveInactive(driver, vm);
}
virDomainObjEndAPI(&vm);
virObjectEventStateQueue(driver->domainEventState, event);
virDomainDeleteConfig(cfg->configDir, cfg->autostartDir, vm);
vm->persistent = 0;
}
- qemuDomainRemoveInactiveJob(driver, vm);
+ qemuDomainRemoveInactive(driver, vm);
}
cleanup:
virDomainDeleteConfig(cfg->configDir, cfg->autostartDir, vm);
vm->persistent = 0;
}
- qemuDomainRemoveInactiveJob(driver, vm);
+ qemuDomainRemoveInactive(driver, vm);
}
virErrorRestore(&orig_err);
}
if (!virDomainObjIsActive(vm))
- qemuDomainRemoveInactiveJob(driver, vm);
+ qemuDomainRemoveInactive(driver, vm);
return ret;
}
qemuMigrationJobFinish(vm);
if (!virDomainObjIsActive(vm))
- qemuDomainRemoveInactiveJob(driver, vm);
+ qemuDomainRemoveInactive(driver, vm);
cleanup:
g_clear_pointer(&jobData, virDomainJobDataFree);
driver->inhibitCallback(true, driver->inhibitOpaque);
cleanup:
- if (jobStarted) {
- if (!virDomainObjIsActive(obj))
- qemuDomainRemoveInactive(driver, obj);
+ if (jobStarted)
qemuDomainObjEndJob(obj);
- } else {
- if (!virDomainObjIsActive(obj))
- qemuDomainRemoveInactiveJob(driver, obj);
- }
+ if (!virDomainObjIsActive(obj))
+ qemuDomainRemoveInactive(driver, obj);
virDomainObjEndAPI(&obj);
virIdentitySetCurrent(NULL);
return;
*/
qemuProcessStop(src->driver, obj, VIR_DOMAIN_SHUTOFF_FAILED,
VIR_ASYNC_JOB_NONE, 0);
- qemuDomainRemoveInactiveJobLocked(src->driver, obj);
+ qemuDomainRemoveInactiveLocked(src->driver, obj);
virDomainObjEndAPI(&obj);
g_clear_object(&data->identity);