lxc: Prepare virLXCDriverGetCapabilities for automatic mutex management

No functional change intended. This change makes the recfatoring to
automatic mutex management easier to follow.

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Tim Wiederhake 2022-02-04 16:28:27 +01:00
parent 621fa350ab
commit 370fc9f47c

View File

@ -156,28 +156,28 @@ virCaps *virLXCDriverCapsInit(virLXCDriver *driver)
virCaps *virLXCDriverGetCapabilities(virLXCDriver *driver,
bool refresh)
{
virCaps *ret;
if (refresh) {
virCaps *caps = NULL;
if ((caps = virLXCDriverCapsInit(driver)) == NULL)
return NULL;
virCaps *ret = NULL;
virCaps *caps = NULL;
lxcDriverLock(driver);
lxcDriverLock(driver);
if (!refresh && !driver->caps) {
VIR_DEBUG("Capabilities didn't detect any guests. Forcing a refresh.");
refresh = true;
}
lxcDriverUnlock(driver);
if (refresh && !(caps = virLXCDriverCapsInit(driver)))
return NULL;
lxcDriverLock(driver);
if (refresh) {
virObjectUnref(driver->caps);
driver->caps = caps;
} else {
lxcDriverLock(driver);
if (driver->caps == NULL) {
VIR_DEBUG("Capabilities didn't detect any guests. Forcing a "
"refresh.");
lxcDriverUnlock(driver);
return virLXCDriverGetCapabilities(driver, true);
}
}
ret = virObjectRef(driver->caps);
lxcDriverUnlock(driver);
return ret;
}