From: "Daniel P. Berrange" <berrange@xxxxxxxxxx> Switch virDomainObjPtr to use the virObject APIs for reference counting. The main change is that virObjectUnref does not return the reference count, merely a bool indicating whether the object still has any refs left. Checking the return value is also not mandatory. Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx> --- src/conf/domain_conf.c | 59 ++++++++++++++++++++------------------------- src/conf/domain_conf.h | 8 +++--- src/libvirt_private.syms | 3 +-- src/libxl/libxl_driver.c | 6 ++--- src/openvz/openvz_conf.c | 17 ++----------- src/qemu/qemu_domain.c | 27 +++++++++------------ src/qemu/qemu_domain.h | 8 +++--- src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_migration.c | 22 ++++++++--------- src/qemu/qemu_migration.h | 4 +-- src/qemu/qemu_process.c | 50 ++++++++++++++++++-------------------- src/vmware/vmware_conf.c | 4 +-- 12 files changed, 89 insertions(+), 121 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3fb90db..e9527b4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -661,6 +661,21 @@ VIR_ENUM_IMPL(virDomainNumatuneMemPlacementMode, #define VIR_DOMAIN_XML_WRITE_FLAGS VIR_DOMAIN_XML_SECURE #define VIR_DOMAIN_XML_READ_FLAGS VIR_DOMAIN_XML_INACTIVE +static virClassPtr virDomainObjClass; +static void virDomainObjDispose(void *obj); + +static int virDomainObjOnceInit(void) +{ + if (!(virDomainObjClass = virClassNew("virDomainObj", + sizeof(virDomainObj), + virDomainObjDispose))) + return -1; + + return 0; +} + +VIR_ONCE_GLOBAL_INIT(virDomainObj) + void virBlkioDeviceWeightArrayClear(virBlkioDeviceWeightPtr deviceWeights, int ndevices) @@ -726,7 +741,7 @@ virDomainObjListDataFree(void *payload, const void *name ATTRIBUTE_UNUSED) { virDomainObjPtr obj = payload; virDomainObjLock(obj); - if (virDomainObjUnref(obj) > 0) + if (!virObjectUnref(obj)) virDomainObjUnlock(obj); } @@ -1640,10 +1655,10 @@ void virDomainDefFree(virDomainDefPtr def) } static void virDomainSnapshotObjListDeinit(virDomainSnapshotObjListPtr snapshots); -static void virDomainObjFree(virDomainObjPtr dom) + +static void virDomainObjDispose(void *obj) { - if (!dom) - return; + virDomainObjPtr dom = obj; VIR_DEBUG("obj=%p", dom); virDomainDefFree(dom->def); @@ -1655,37 +1670,18 @@ static void virDomainObjFree(virDomainObjPtr dom) virMutexDestroy(&dom->lock); virDomainSnapshotObjListDeinit(&dom->snapshots); - - VIR_FREE(dom); -} - -void virDomainObjRef(virDomainObjPtr dom) -{ - dom->refs++; - VIR_DEBUG("obj=%p refs=%d", dom, dom->refs); } -int virDomainObjUnref(virDomainObjPtr dom) -{ - dom->refs--; - VIR_DEBUG("obj=%p refs=%d", dom, dom->refs); - if (dom->refs == 0) { - virDomainObjUnlock(dom); - virDomainObjFree(dom); - return 0; - } - return dom->refs; -} - -static virDomainObjPtr virDomainObjNew(virCapsPtr caps) +virDomainObjPtr virDomainObjNew(virCapsPtr caps) { virDomainObjPtr domain; - if (VIR_ALLOC(domain) < 0) { - virReportOOMError(); + if (virDomainObjInitialize() < 0) + return NULL; + + if (!(domain = virObjectNew(virDomainObjClass))) return NULL; - } if (caps->privateDataAllocFunc && !(domain->privateData = (caps->privateDataAllocFunc)())) { @@ -1707,7 +1703,6 @@ static virDomainObjPtr virDomainObjNew(virCapsPtr caps) virDomainObjLock(domain); virDomainObjSetState(domain, VIR_DOMAIN_SHUTOFF, VIR_DOMAIN_SHUTOFF_UNKNOWN); - domain->refs = 1; virDomainSnapshotObjListInit(&domain->snapshots); @@ -9316,8 +9311,7 @@ static virDomainObjPtr virDomainObjParseXML(virCapsPtr caps, return obj; error: - /* obj was never shared, so unref should return 0 */ - ignore_value(virDomainObjUnref(obj)); + virObjectUnref(obj); VIR_FREE(nodes); return NULL; } @@ -13374,9 +13368,8 @@ static virDomainObjPtr virDomainLoadStatus(virCapsPtr caps, return obj; error: - /* obj was never shared, so unref should return 0 */ if (obj) - ignore_value(virDomainObjUnref(obj)); + virObjectUnref(obj); VIR_FREE(statusFile); return NULL; } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 7d5d60b..d79e4ee 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -43,6 +43,7 @@ # include "virnetdevvportprofile.h" # include "virnetdevopenvswitch.h" # include "virnetdevbandwidth.h" +# include "virobject.h" /* forward declarations of all device types, required by * virDomainDeviceDef @@ -1806,8 +1807,9 @@ struct _virDomainStateReason { typedef struct _virDomainObj virDomainObj; typedef virDomainObj *virDomainObjPtr; struct _virDomainObj { + virObject object; + virMutex lock; - int refs; pid_t pid; virDomainStateReason state; @@ -1844,6 +1846,7 @@ virDomainObjIsActive(virDomainObjPtr dom) return dom->def->id != -1; } +virDomainObjPtr virDomainObjNew(virCapsPtr caps); int virDomainObjListInit(virDomainObjListPtr objs); void virDomainObjListDeinit(virDomainObjListPtr objs); @@ -1906,9 +1909,6 @@ int virDomainDeviceInfoIterate(virDomainDefPtr def, void *opaque); void virDomainDefFree(virDomainDefPtr vm); -void virDomainObjRef(virDomainObjPtr vm); -/* Returns 1 if the object was freed, 0 if more refs exist */ -int virDomainObjUnref(virDomainObjPtr vm) ATTRIBUTE_RETURN_CHECK; virDomainChrDefPtr virDomainChrDefNew(void); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 9327d9a..3551fd0 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -422,12 +422,11 @@ virDomainObjListGetInactiveNames; virDomainObjListInit; virDomainObjListNumOfDomains; virDomainObjLock; -virDomainObjRef; +virDomainObjNew; virDomainObjSetDefTransient; virDomainObjSetState; virDomainObjTaint; virDomainObjUnlock; -virDomainObjUnref; virDomainPausedReasonTypeFromString; virDomainPausedReasonTypeToString; virDomainPciRombarModeTypeFromString; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 4d1db3a..779c737 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -134,7 +134,7 @@ libxlDomainObjUnref(void *data) { virDomainObjPtr vm = data; - ignore_value(virDomainObjUnref(vm)); + virObjectUnref(vm); } static void @@ -484,13 +484,13 @@ libxlCreateDomEvents(virDomainObjPtr vm) /* Add a reference to the domain object while it is injected in * the event loop. */ - virDomainObjRef(vm); + virObjectRef(vm); if ((priv->eventHdl = virEventAddHandle( fd, VIR_EVENT_HANDLE_READABLE | VIR_EVENT_HANDLE_ERROR, libxlEventHandler, vm, libxlDomainObjUnref)) < 0) { - ignore_value(virDomainObjUnref(vm)); + virObjectUnref(vm); goto error; } diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index ad27d37..cd3a683 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -599,17 +599,8 @@ int openvzLoadDomains(struct openvz_driver *driver) { } *line++ = '\0'; - if (VIR_ALLOC(dom) < 0) - goto no_memory; - - if (virMutexInit(&dom->lock) < 0) { - openvzError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot initialize mutex")); - VIR_FREE(dom); + if (!(dom = virDomainObjNew(driver->caps))) goto cleanup; - } - - virDomainObjLock(dom); if (VIR_ALLOC(dom->def) < 0) goto no_memory; @@ -624,7 +615,6 @@ int openvzLoadDomains(struct openvz_driver *driver) { VIR_DOMAIN_RUNNING_UNKNOWN); } - dom->refs = 1; dom->pid = veid; if (virDomainObjGetState(dom, NULL) == VIR_DOMAIN_SHUTOFF) dom->def->id = -1; @@ -674,7 +664,6 @@ int openvzLoadDomains(struct openvz_driver *driver) { if (virHashAddEntry(driver->domains.objs, uuidstr, dom) < 0) goto cleanup; - virDomainObjUnlock(dom); dom = NULL; } @@ -691,9 +680,7 @@ int openvzLoadDomains(struct openvz_driver *driver) { virCommandFree(cmd); VIR_FREE(temp); VIR_FREE(outbuf); - /* dom hasn't been shared yet, so unref should return 0 */ - if (dom) - ignore_value(virDomainObjUnref(dom)); + virObjectUnref(dom); return -1; } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 201ec03..d164ef0 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -774,7 +774,7 @@ qemuDomainObjBeginJobInternal(struct qemud_driver *driver, return -1; then = now + QEMU_JOB_WAIT_TIME; - virDomainObjRef(obj); + virObjectRef(obj); if (driver_locked) qemuDriverUnlock(driver); @@ -854,8 +854,7 @@ error: qemuDriverLock(driver); virDomainObjLock(obj); } - /* Safe to ignore value since ref count was incremented above */ - ignore_value(virDomainObjUnref(obj)); + virObjectUnref(obj); return -1; } @@ -922,10 +921,10 @@ int qemuDomainObjBeginAsyncJobWithDriver(struct qemud_driver *driver, * 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 + * Returns true if @obj was still referenced, false if it was + * disposed of. */ -int qemuDomainObjEndJob(struct qemud_driver *driver, virDomainObjPtr obj) +bool qemuDomainObjEndJob(struct qemud_driver *driver, virDomainObjPtr obj) { qemuDomainObjPrivatePtr priv = obj->privateData; enum qemuDomainJob job = priv->job.active; @@ -941,10 +940,10 @@ int qemuDomainObjEndJob(struct qemud_driver *driver, virDomainObjPtr obj) qemuDomainObjSaveJob(driver, obj); virCondSignal(&priv->job.cond); - return virDomainObjUnref(obj); + return virObjectUnref(obj); } -int +bool qemuDomainObjEndAsyncJob(struct qemud_driver *driver, virDomainObjPtr obj) { qemuDomainObjPrivatePtr priv = obj->privateData; @@ -958,7 +957,7 @@ qemuDomainObjEndAsyncJob(struct qemud_driver *driver, virDomainObjPtr obj) qemuDomainObjSaveJob(driver, obj); virCondBroadcast(&priv->job.asyncCond); - return virDomainObjUnref(obj); + return virObjectUnref(obj); } static int @@ -1031,9 +1030,7 @@ qemuDomainObjExitMonitorInternal(struct qemud_driver *driver, qemuDomainObjSaveJob(driver, obj); virCondSignal(&priv->job.cond); - /* safe to ignore since the surrounding async job increased - * the reference counter as well */ - ignore_value(virDomainObjUnref(obj)); + virObjectUnref(obj); } } @@ -1207,7 +1204,7 @@ void qemuDomainObjExitAgentWithDriver(struct qemud_driver *driver, void qemuDomainObjEnterRemoteWithDriver(struct qemud_driver *driver, virDomainObjPtr obj) { - virDomainObjRef(obj); + virObjectRef(obj); virDomainObjUnlock(obj); qemuDriverUnlock(driver); } @@ -1217,9 +1214,7 @@ void qemuDomainObjExitRemoteWithDriver(struct qemud_driver *driver, { qemuDriverLock(driver); virDomainObjLock(obj); - /* Safe to ignore value, since we incremented ref in - * qemuDomainObjEnterRemoteWithDriver */ - ignore_value(virDomainObjUnref(obj)); + virObjectUnref(obj); } diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 3a5f1f3..1f7e5e4 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -193,11 +193,11 @@ int qemuDomainObjBeginAsyncJobWithDriver(struct qemud_driver *driver, enum qemuDomainAsyncJob asyncJob) ATTRIBUTE_RETURN_CHECK; -int qemuDomainObjEndJob(struct qemud_driver *driver, - virDomainObjPtr obj) +bool qemuDomainObjEndJob(struct qemud_driver *driver, + virDomainObjPtr obj) ATTRIBUTE_RETURN_CHECK; -int qemuDomainObjEndAsyncJob(struct qemud_driver *driver, - virDomainObjPtr obj) +bool qemuDomainObjEndAsyncJob(struct qemud_driver *driver, + virDomainObjPtr obj) ATTRIBUTE_RETURN_CHECK; void qemuDomainObjSetJobPhase(struct qemud_driver *driver, virDomainObjPtr obj, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 3410535..6c1c2ef 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -3402,7 +3402,7 @@ endjob: ignore_value(qemuDomainObjEndAsyncJob(driver, wdEvent->vm)); unlock: - if (virDomainObjUnref(wdEvent->vm) > 0) + if (virObjectUnref(wdEvent->vm)) virDomainObjUnlock(wdEvent->vm); qemuDriverUnlock(driver); VIR_FREE(wdEvent); diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 558f064..61d3d68 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1369,7 +1369,7 @@ qemuMigrationPrepareAny(struct qemud_driver *driver, * This prevents any other APIs being invoked while incoming * migration is taking place. */ - if (qemuMigrationJobContinue(vm) == 0) { + if (!qemuMigrationJobContinue(vm)) { vm = NULL; qemuReportError(VIR_ERR_OPERATION_FAILED, "%s", _("domain disappeared")); @@ -1396,7 +1396,7 @@ cleanup: return ret; endjob: - if (qemuMigrationJobFinish(driver, vm) == 0) { + if (!qemuMigrationJobFinish(driver, vm)) { vm = NULL; } goto cleanup; @@ -2682,7 +2682,7 @@ endjob: VIR_DOMAIN_EVENT_RESUMED_MIGRATED); } - if (qemuMigrationJobFinish(driver, vm) == 0) { + if (!qemuMigrationJobFinish(driver, vm)) { vm = NULL; } else if (!virDomainObjIsActive(vm) && (!vm->persistent || @@ -2724,7 +2724,7 @@ qemuMigrationPerformPhase(struct qemud_driver *driver, virDomainEventPtr event = NULL; int ret = -1; bool resume; - int refs; + bool hasrefs; /* If we didn't start the job in the begin phase, start it now. */ if (!(flags & VIR_MIGRATE_CHANGE_PROTECTION)) { @@ -2772,10 +2772,10 @@ qemuMigrationPerformPhase(struct qemud_driver *driver, endjob: if (ret < 0) - refs = qemuMigrationJobFinish(driver, vm); + hasrefs = qemuMigrationJobFinish(driver, vm); else - refs = qemuMigrationJobContinue(vm); - if (refs == 0) { + hasrefs = qemuMigrationJobContinue(vm); + if (!hasrefs) { vm = NULL; } else if (!virDomainObjIsActive(vm) && !vm->persistent) { qemuDomainRemoveInactive(driver, vm); @@ -3376,15 +3376,15 @@ qemuMigrationJobStartPhase(struct qemud_driver *driver, virDomainObjPtr vm, enum qemuMigrationJobPhase phase) { - virDomainObjRef(vm); + virObjectRef(vm); qemuMigrationJobSetPhase(driver, vm, phase); } -int +bool qemuMigrationJobContinue(virDomainObjPtr vm) { qemuDomainObjReleaseAsyncJob(vm); - return virDomainObjUnref(vm); + return virObjectUnref(vm); } bool @@ -3407,7 +3407,7 @@ qemuMigrationJobIsActive(virDomainObjPtr vm, return true; } -int +bool qemuMigrationJobFinish(struct qemud_driver *driver, virDomainObjPtr vm) { return qemuDomainObjEndAsyncJob(driver, vm); diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h index 5fab0ca..4a119bf 100644 --- a/src/qemu/qemu_migration.h +++ b/src/qemu/qemu_migration.h @@ -66,12 +66,12 @@ void qemuMigrationJobStartPhase(struct qemud_driver *driver, virDomainObjPtr vm, enum qemuMigrationJobPhase phase) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); -int qemuMigrationJobContinue(virDomainObjPtr obj) +bool qemuMigrationJobContinue(virDomainObjPtr obj) ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK; bool qemuMigrationJobIsActive(virDomainObjPtr vm, enum qemuDomainAsyncJob job) ATTRIBUTE_NONNULL(1); -int qemuMigrationJobFinish(struct qemud_driver *driver, virDomainObjPtr obj) +bool qemuMigrationJobFinish(struct qemud_driver *driver, virDomainObjPtr obj) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; int qemuMigrationSetOffline(struct qemud_driver *driver, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 2aa6af1..74bf617 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -173,7 +173,7 @@ static void qemuProcessHandleAgentDestroy(qemuAgentPtr agent, priv = vm->privateData; if (priv->agent == agent) priv->agent = NULL; - if (virDomainObjUnref(vm) > 0) + if (virObjectUnref(vm)) virDomainObjUnlock(vm); } @@ -225,7 +225,7 @@ qemuConnectAgent(struct qemud_driver *driver, virDomainObjPtr vm) /* Hold an extra reference because we can't allow 'vm' to be * deleted while the agent is active */ - virDomainObjRef(vm); + virObjectRef(vm); ignore_value(virTimeMillisNow(&priv->agentStart)); virDomainObjUnlock(vm); @@ -246,9 +246,8 @@ qemuConnectAgent(struct qemud_driver *driver, virDomainObjPtr vm) goto cleanup; } - /* Safe to ignore value since ref count was incremented above */ if (agent == NULL) - ignore_value(virDomainObjUnref(vm)); + virObjectUnref(vm); if (!virDomainObjIsActive(vm)) { qemuAgentClose(agent); @@ -584,7 +583,7 @@ qemuProcessFakeReboot(void *opaque) ret = 0; endjob: - if (qemuDomainObjEndJob(driver, vm) == 0) + if (!qemuDomainObjEndJob(driver, vm)) vm = NULL; cleanup: @@ -593,7 +592,7 @@ cleanup: ignore_value(qemuProcessKill(driver, vm, VIR_QEMU_PROCESS_KILL_FORCE)); } - if (virDomainObjUnref(vm) > 0) + if (virObjectUnref(vm)) virDomainObjUnlock(vm); } if (event) @@ -610,7 +609,7 @@ qemuProcessShutdownOrReboot(struct qemud_driver *driver, if (priv->fakeReboot) { qemuDomainSetFakeReboot(driver, vm, false); - virDomainObjRef(vm); + virObjectRef(vm); virThread th; if (virThreadCreate(&th, false, @@ -619,8 +618,7 @@ qemuProcessShutdownOrReboot(struct qemud_driver *driver, VIR_ERROR(_("Failed to create reboot thread, killing domain")); ignore_value(qemuProcessKill(driver, vm, VIR_QEMU_PROCESS_KILL_NOWAIT)); - /* Safe to ignore value since ref count was incremented above */ - ignore_value(virDomainObjUnref(vm)); + virObjectUnref(vm); } } else { ignore_value(qemuProcessKill(driver, vm, VIR_QEMU_PROCESS_KILL_NOWAIT)); @@ -801,9 +799,9 @@ qemuProcessHandleWatchdog(qemuMonitorPtr mon ATTRIBUTE_UNUSED, /* Hold an extra reference because we can't allow 'vm' to be * deleted before handling watchdog event is finished. */ - virDomainObjRef(vm); + virObjectRef(vm); if (virThreadPoolSendJob(driver->workerPool, 0, wdEvent) < 0) { - if (virDomainObjUnref(vm) == 0) + if (!virObjectUnref(vm)) vm = NULL; VIR_FREE(wdEvent); } @@ -1022,7 +1020,7 @@ static void qemuProcessHandleMonitorDestroy(qemuMonitorPtr mon, priv = vm->privateData; if (priv->mon == mon) priv->mon = NULL; - if (virDomainObjUnref(vm) > 0) + if (virObjectUnref(vm)) virDomainObjUnlock(vm); } @@ -1182,7 +1180,7 @@ qemuConnectMonitor(struct qemud_driver *driver, virDomainObjPtr vm) /* Hold an extra reference because we can't allow 'vm' to be * deleted while the monitor is active */ - virDomainObjRef(vm); + virObjectRef(vm); ignore_value(virTimeMillisNow(&priv->monStart)); virDomainObjUnlock(vm); @@ -1197,9 +1195,8 @@ qemuConnectMonitor(struct qemud_driver *driver, virDomainObjPtr vm) virDomainObjLock(vm); priv->monStart = 0; - /* Safe to ignore value since ref count was incremented above */ if (mon == NULL) - ignore_value(virDomainObjUnref(vm)); + virObjectUnref(vm); if (!virDomainObjIsActive(vm)) { qemuMonitorClose(mon); @@ -3037,7 +3034,7 @@ qemuProcessReconnect(void *opaque) /* Hold an extra reference because we can't allow 'vm' to be * deleted if qemuConnectMonitor() failed */ - virDomainObjRef(obj); + virObjectRef(obj); /* XXX check PID liveliness & EXE path */ if (qemuConnectMonitor(driver, obj) < 0) @@ -3138,10 +3135,10 @@ qemuProcessReconnect(void *opaque) driver->nextvmid = obj->def->id + 1; endjob: - if (qemuDomainObjEndJob(driver, obj) == 0) + if (!qemuDomainObjEndJob(driver, obj)) obj = NULL; - if (obj && virDomainObjUnref(obj) > 0) + if (obj && virObjectUnref(obj)) virDomainObjUnlock(obj); qemuDriverUnlock(driver); @@ -3151,18 +3148,18 @@ endjob: return; error: - if (qemuDomainObjEndJob(driver, obj) == 0) + if (!qemuDomainObjEndJob(driver, obj)) obj = NULL; if (obj) { if (!virDomainObjIsActive(obj)) { - if (virDomainObjUnref(obj) > 0) + if (virObjectUnref(obj)) virDomainObjUnlock(obj); qemuDriverUnlock(driver); return; } - if (virDomainObjUnref(obj) > 0) { + if (virObjectUnref(obj)) { /* We can't get the monitor back, so must kill the VM * to remove danger of it ending up running twice if * user tries to start it again later @@ -3250,9 +3247,9 @@ qemuProcessReconnectHelper(void *payload, qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Could not create thread. QEMU initialization " "might be incomplete")); - if (qemuDomainObjEndJob(src->driver, obj) == 0) { + if (!qemuDomainObjEndJob(src->driver, obj)) { obj = NULL; - } else if (virDomainObjUnref(obj) > 0) { + } else if (virObjectUnref(obj)) { /* We can't spawn a thread and thus connect to monitor. * Kill qemu */ qemuProcessStop(src->driver, obj, VIR_DOMAIN_SHUTOFF_FAILED, 0); @@ -3937,12 +3934,11 @@ cleanup: * a case, but there are too many to maintain certainty, so we * will do this as a precaution). */ - virDomainObjRef(vm); + virObjectRef(vm); virDomainObjUnlock(vm); qemuDriverLock(driver); virDomainObjLock(vm); - /* Safe to ignore value since ref count was incremented above */ - ignore_value(virDomainObjUnref(vm)); + virObjectUnref(vm); } return ret; } @@ -4407,7 +4403,7 @@ qemuProcessAutoDestroy(struct qemud_driver *driver, VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED_DESTROYED); - if (qemuDomainObjEndJob(driver, dom) == 0) + if (!qemuDomainObjEndJob(driver, dom)) dom = NULL; if (dom && !dom->persistent) qemuDomainRemoveInactive(driver, dom); diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c index 847d146..433b28a 100644 --- a/src/vmware/vmware_conf.c +++ b/src/vmware/vmware_conf.c @@ -213,9 +213,7 @@ cleanup: VIR_FREE(directoryName); VIR_FREE(fileName); VIR_FREE(vmx); - /* any non-NULL vm here has not been shared, so unref will return 0 */ - if (vm) - ignore_value(virDomainObjUnref(vm)); + virObjectUnref(vm); return ret; } -- 1.7.10.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list