*
* To be called after completing the work associated with the
* earlier qemuDomainBeginJob() call
+ *
+ * Returns remaining refcount on 'obj', maybe 0 to indicated it
+ * was deleted
*/
-static void qemuDomainObjEndJob(virDomainObjPtr obj)
+static int ATTRIBUTE_RETURN_CHECK qemuDomainObjEndJob(virDomainObjPtr obj)
{
qemuDomainObjPrivatePtr priv = obj->privateData;
priv->jobActive = 0;
virCondSignal(&priv->jobCond);
- virDomainObjUnref(obj);
+ return virDomainObjUnref(obj);
}
goto cleanup; /* XXXX free the 'vm' we created ? */
if (qemudStartVMDaemon(conn, driver, vm, NULL, -1) < 0) {
- qemuDomainObjEndJob(vm);
- virDomainRemoveInactive(&driver->domains,
- vm);
+ if (qemuDomainObjEndJob(vm) > 0)
+ virDomainRemoveInactive(&driver->domains,
+ vm);
vm = NULL;
goto endjob;
}
if (dom) dom->id = vm->def->id;
endjob:
- if (vm)
- qemuDomainObjEndJob(vm);
+ if (vm &&
+ qemuDomainObjEndJob(vm) == 0)
+ vm = NULL;
cleanup:
virDomainDefFree(def);
ret = 0;
endjob:
- qemuDomainObjEndJob(vm);
+ if (qemuDomainObjEndJob(vm) == 0)
+ vm = NULL;
cleanup:
if (vm)
ret = 0;
endjob:
- qemuDomainObjEndJob(vm);
+ if (qemuDomainObjEndJob(vm) == 0)
+ vm = NULL;
cleanup:
if (vm)
qemuDomainObjExitMonitor(vm);
endjob:
- qemuDomainObjEndJob(vm);
+ if (qemuDomainObjEndJob(vm) == 0)
+ vm = NULL;
cleanup:
if (vm)
VIR_DOMAIN_EVENT_STOPPED,
VIR_DOMAIN_EVENT_STOPPED_DESTROYED);
if (!vm->persistent) {
- qemuDomainObjEndJob(vm);
- virDomainRemoveInactive(&driver->domains,
- vm);
+ if (qemuDomainObjEndJob(vm) > 0)
+ virDomainRemoveInactive(&driver->domains,
+ vm);
vm = NULL;
}
ret = 0;
endjob:
- if (vm)
- qemuDomainObjEndJob(vm);
+ if (vm &&
+ qemuDomainObjEndJob(vm) == 0)
+ vm = NULL;
cleanup:
if (vm)
ret = 0;
endjob:
- qemuDomainObjEndJob(vm);
+ if (qemuDomainObjEndJob(vm) == 0)
+ vm = NULL;
cleanup:
if (vm)
err = qemuMonitorGetBalloonInfo(priv->mon, &balloon);
qemuDomainObjExitMonitor(vm);
if (err < 0) {
- qemuDomainObjEndJob(vm);
+ if (qemuDomainObjEndJob(vm) == 0)
+ vm = NULL;
goto cleanup;
}
else
info->memory = balloon;
- qemuDomainObjEndJob(vm);
+ if (qemuDomainObjEndJob(vm) == 0) {
+ vm = NULL;
+ goto cleanup;
+ }
} else {
info->memory = vm->def->memory;
}
VIR_DOMAIN_EVENT_STOPPED,
VIR_DOMAIN_EVENT_STOPPED_SAVED);
if (!vm->persistent) {
- qemuDomainObjEndJob(vm);
- virDomainRemoveInactive(&driver->domains,
- vm);
+ if (qemuDomainObjEndJob(vm) > 0)
+ virDomainRemoveInactive(&driver->domains,
+ vm);
vm = NULL;
}
endjob:
- if (vm)
- qemuDomainObjEndJob(vm);
+ if (vm &&
+ qemuDomainObjEndJob(vm) == 0)
+ vm = NULL;
cleanup:
if (fd != -1)
}
endjob:
- qemuDomainObjEndJob(vm);
+ if (qemuDomainObjEndJob(vm) == 0)
+ vm = NULL;
cleanup:
if (vm)
ret = 0;
endjob:
- qemuDomainObjEndJob(vm);
+ if (qemuDomainObjEndJob(vm) == 0)
+ vm = NULL;
cleanup:
if (vm)
fd = -1;
if (ret < 0) {
if (!vm->persistent) {
- qemuDomainObjEndJob(vm);
- virDomainRemoveInactive(&driver->domains,
- vm);
+ if (qemuDomainObjEndJob(vm) > 0)
+ virDomainRemoveInactive(&driver->domains,
+ vm);
vm = NULL;
}
goto endjob;
ret = 0;
endjob:
- if (vm)
- qemuDomainObjEndJob(vm);
+ if (vm &&
+ qemuDomainObjEndJob(vm) == 0)
+ vm = NULL;
cleanup:
virDomainDefFree(def);
qemuDomainObjEnterMonitor(vm);
err = qemuMonitorGetBalloonInfo(priv->mon, &balloon);
qemuDomainObjExitMonitor(vm);
- qemuDomainObjEndJob(vm);
+ if (qemuDomainObjEndJob(vm) == 0) {
+ vm = NULL;
+ goto cleanup;
+ }
if (err < 0)
goto cleanup;
if (err > 0)
VIR_DOMAIN_EVENT_STARTED_BOOTED);
endjob:
- qemuDomainObjEndJob(vm);
+ if (qemuDomainObjEndJob(vm) == 0)
+ vm = NULL;
cleanup:
if (vm)
ret = -1;
endjob:
- qemuDomainObjEndJob(vm);
+ if (qemuDomainObjEndJob(vm) == 0)
+ vm = NULL;
cleanup:
if (cgroup)
ret = -1;
endjob:
- qemuDomainObjEndJob(vm);
+ if (qemuDomainObjEndJob(vm) == 0)
+ vm = NULL;
cleanup:
virDomainDeviceDefFree(dev);
qemuDomainObjExitMonitor(vm);
endjob:
- qemuDomainObjEndJob(vm);
+ if (qemuDomainObjEndJob(vm) == 0)
+ vm = NULL;
cleanup:
VIR_FREE(qemu_dev_name);
ret = 0;
endjob:
- qemuDomainObjEndJob(vm);
+ if (qemuDomainObjEndJob(vm) == 0)
+ vm = NULL;
cleanup:
VIR_FREE(tmp);
if (qemust == NULL) {
qemudShutdownVMDaemon(NULL, driver, vm);
if (!vm->persistent) {
- qemuDomainObjEndJob(vm);
- virDomainRemoveInactive(&driver->domains, vm);
+ if (qemuDomainObjEndJob(vm) > 0)
+ virDomainRemoveInactive(&driver->domains, vm);
vm = NULL;
}
virReportSystemError(dconn, errno,
ret = 0;
endjob:
- if (vm)
- qemuDomainObjEndJob(vm);
+ if (vm &&
+ qemuDomainObjEndJob(vm) == 0)
+ vm = NULL;
cleanup:
virDomainDefFree(def);
* should have already done that.
*/
if (!vm->persistent) {
- qemuDomainObjEndJob(vm);
- virDomainRemoveInactive(&driver->domains, vm);
+ if (qemuDomainObjEndJob(vm) > 0)
+ virDomainRemoveInactive(&driver->domains, vm);
vm = NULL;
}
goto endjob;
ret = 0;
endjob:
- if (vm)
- qemuDomainObjEndJob(vm);
+ if (vm &&
+ qemuDomainObjEndJob(vm) == 0)
+ vm = NULL;
cleanup:
virDomainDefFree(def);
VIR_DOMAIN_EVENT_STOPPED_MIGRATED);
if (!vm->persistent || (flags & VIR_MIGRATE_UNDEFINE_SOURCE)) {
virDomainDeleteConfig(dom->conn, driver->configDir, driver->autostartDir, vm);
- qemuDomainObjEndJob(vm);
- virDomainRemoveInactive(&driver->domains, vm);
+ if (qemuDomainObjEndJob(vm) > 0)
+ virDomainRemoveInactive(&driver->domains, vm);
vm = NULL;
}
ret = 0;
VIR_DOMAIN_EVENT_RESUMED,
VIR_DOMAIN_EVENT_RESUMED_MIGRATED);
}
- if (vm)
- qemuDomainObjEndJob(vm);
+ if (vm &&
+ qemuDomainObjEndJob(vm) == 0)
+ vm = NULL;
cleanup:
if (vm)
VIR_DOMAIN_EVENT_STOPPED,
VIR_DOMAIN_EVENT_STOPPED_FAILED);
if (!vm->persistent) {
- qemuDomainObjEndJob(vm);
- virDomainRemoveInactive(&driver->domains, vm);
+ if (qemuDomainObjEndJob(vm) > 0)
+ virDomainRemoveInactive(&driver->domains, vm);
vm = NULL;
}
}
endjob:
- if (vm)
- qemuDomainObjEndJob(vm);
+ if (vm &&
+ qemuDomainObjEndJob(vm) == 0)
+ vm = NULL;
cleanup:
if (vm)