remote: in per-driver daemons ensure that state initialize succeeds

When running in libvirtd, we are happy for any of the drivers to simply
skip their initialization in virStateInitialize, as other drivers are
still potentially useful.

When running in per-driver daemons though, we want the daemon to abort
startup if the driver cannot initialize itself, as the daemon will be
useless without it.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé
2019-07-23 13:05:18 +01:00
parent 808b0d2d94
commit 4ce29411fc
18 changed files with 86 additions and 64 deletions

View File

@@ -1816,14 +1816,14 @@ nodeStateInitialize(bool privileged,
virThread enumThread;
if (VIR_ALLOC(driver) < 0)
return -1;
return VIR_DRV_STATE_INIT_ERROR;
driver->lockFD = -1;
if (virMutexInit(&driver->lock) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to initialize mutex"));
VIR_FREE(driver);
return -1;
return VIR_DRV_STATE_INIT_ERROR;
}
driver->privileged = privileged;
@@ -1919,11 +1919,11 @@ nodeStateInitialize(bool privileged,
goto cleanup;
}
return 0;
return VIR_DRV_STATE_INIT_COMPLETE;
cleanup:
nodeStateCleanup();
return -1;
return VIR_DRV_STATE_INIT_ERROR;
unlock:
virObjectUnlock(priv);