There's no need to check if @dom exists before trying to
call virDomainObjListRemove since it must exist due to
prior checks.
Additionally, if we do remove the @dom, then set it to NULL
so that the virObjectUnlock isn't referencing something that
is deleted.
Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
VIR_DOMAIN_EVENT_STOPPED,
VIR_DOMAIN_EVENT_STOPPED_DESTROYED);
- if (dom && !dom->persistent)
+ if (!dom->persistent) {
virDomainObjListRemove(data->driver->domains, dom);
+ dom = NULL;
+ }
if (dom)
virObjectUnlock(dom);