diff options
author | Michal Privoznik <mprivozn@redhat.com> | 2015-04-23 18:00:01 +0200 |
---|---|---|
committer | Michal Privoznik <mprivozn@redhat.com> | 2015-04-24 13:22:45 +0200 |
commit | 620ff93bd39cd9c49eebbff11c6d6adbe7c67f86 (patch) | |
tree | f2a896d9e936e0c7f3f75af9cc57cac7040956ba /src/uml | |
parent | 79d14a9930e84efedc0b1baa572e997b6b244d08 (diff) | |
download | libvirt-620ff93bd39cd9c49eebbff11c6d6adbe7c67f86.tar.gz |
virDomainObjListFindByName: Return referenced object
Every domain that grabs a domain object to work over should
reference it to make sure it won't disappear meanwhile.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Diffstat (limited to 'src/uml')
-rw-r--r-- | src/uml/uml_driver.c | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 9cee541598..60f8eb5c6d 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -339,7 +339,7 @@ umlInotifyEvent(int watch, if (e.mask & IN_DELETE) { VIR_DEBUG("Got inotify domain shutdown '%s'", name); if (!virDomainObjIsActive(dom)) { - virObjectUnlock(dom); + virDomainObjEndAPI(&dom); continue; } @@ -348,20 +348,17 @@ umlInotifyEvent(int watch, event = virDomainEventLifecycleNewFromObj(dom, VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN); - if (!dom->persistent) { - virDomainObjListRemove(driver->domains, - dom); - dom = NULL; - } + if (!dom->persistent) + virDomainObjListRemove(driver->domains, dom); } else if (e.mask & (IN_CREATE | IN_MODIFY)) { VIR_DEBUG("Got inotify domain startup '%s'", name); if (virDomainObjIsActive(dom)) { - virObjectUnlock(dom); + virDomainObjEndAPI(&dom); continue; } if (umlReadPidFile(driver, dom) < 0) { - virObjectUnlock(dom); + virDomainObjEndAPI(&dom); continue; } @@ -382,11 +379,8 @@ umlInotifyEvent(int watch, event = virDomainEventLifecycleNewFromObj(dom, VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED_FAILED); - if (!dom->persistent) { - virDomainObjListRemove(driver->domains, - dom); - dom = NULL; - } + if (!dom->persistent) + virDomainObjListRemove(driver->domains, dom); } else if (umlIdentifyChrPTY(driver, dom) < 0) { VIR_WARN("Could not identify character devices for new domain"); umlShutdownVMDaemon(driver, dom, @@ -395,15 +389,11 @@ umlInotifyEvent(int watch, event = virDomainEventLifecycleNewFromObj(dom, VIR_DOMAIN_EVENT_STOPPED, VIR_DOMAIN_EVENT_STOPPED_FAILED); - if (!dom->persistent) { - virDomainObjListRemove(driver->domains, - dom); - dom = NULL; - } + if (!dom->persistent) + virDomainObjListRemove(driver->domains, dom); } } - if (dom) - virObjectUnlock(dom); + virDomainObjEndAPI(&dom); if (event) { umlDomainEventQueue(driver, event); event = NULL; @@ -1448,8 +1438,7 @@ static virDomainPtr umlDomainLookupByName(virConnectPtr conn, if (dom) dom->id = vm->def->id; cleanup: - if (vm) - virObjectUnlock(vm); + virDomainObjEndAPI(&vm); return dom; } |