mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
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:
parent
808b0d2d94
commit
4ce29411fc
@ -1220,16 +1220,16 @@ bhyveStateInitialize(bool privileged,
|
|||||||
{
|
{
|
||||||
if (!privileged) {
|
if (!privileged) {
|
||||||
VIR_INFO("Not running privileged, disabling driver");
|
VIR_INFO("Not running privileged, disabling driver");
|
||||||
return 0;
|
return VIR_DRV_STATE_INIT_SKIPPED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC(bhyve_driver) < 0)
|
if (VIR_ALLOC(bhyve_driver) < 0)
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
|
|
||||||
bhyve_driver->lockFD = -1;
|
bhyve_driver->lockFD = -1;
|
||||||
if (virMutexInit(&bhyve_driver->lock) < 0) {
|
if (virMutexInit(&bhyve_driver->lock) < 0) {
|
||||||
VIR_FREE(bhyve_driver);
|
VIR_FREE(bhyve_driver);
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(bhyve_driver->closeCallbacks = virCloseCallbacksNew()))
|
if (!(bhyve_driver->closeCallbacks = virCloseCallbacksNew()))
|
||||||
@ -1303,11 +1303,11 @@ bhyveStateInitialize(bool privileged,
|
|||||||
|
|
||||||
bhyveAutostartDomains(bhyve_driver);
|
bhyveAutostartDomains(bhyve_driver);
|
||||||
|
|
||||||
return 0;
|
return VIR_DRV_STATE_INIT_COMPLETE;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
bhyveStateCleanup();
|
bhyveStateCleanup();
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned
|
unsigned
|
||||||
|
@ -24,7 +24,13 @@
|
|||||||
# error "Don't include this file directly, only use driver.h"
|
# error "Don't include this file directly, only use driver.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef int
|
typedef enum {
|
||||||
|
VIR_DRV_STATE_INIT_ERROR = -1,
|
||||||
|
VIR_DRV_STATE_INIT_SKIPPED,
|
||||||
|
VIR_DRV_STATE_INIT_COMPLETE,
|
||||||
|
} virDrvStateInitResult;
|
||||||
|
|
||||||
|
typedef virDrvStateInitResult
|
||||||
(*virDrvStateInitialize)(bool privileged,
|
(*virDrvStateInitialize)(bool privileged,
|
||||||
virStateInhibitCallback callback,
|
virStateInhibitCallback callback,
|
||||||
void *opaque);
|
void *opaque);
|
||||||
|
@ -93,10 +93,10 @@ netcfStateInitialize(bool privileged,
|
|||||||
void *opaque ATTRIBUTE_UNUSED)
|
void *opaque ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
if (virNetcfDriverStateInitialize() < 0)
|
if (virNetcfDriverStateInitialize() < 0)
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
|
|
||||||
if (!(driver = virObjectLockableNew(virNetcfDriverStateClass)))
|
if (!(driver = virObjectLockableNew(virNetcfDriverStateClass)))
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
|
|
||||||
driver->privileged = privileged;
|
driver->privileged = privileged;
|
||||||
|
|
||||||
@ -129,12 +129,12 @@ netcfStateInitialize(bool privileged,
|
|||||||
_("failed to initialize netcf"));
|
_("failed to initialize netcf"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
return 0;
|
return VIR_DRV_STATE_INIT_COMPLETE;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
virObjectUnref(driver);
|
virObjectUnref(driver);
|
||||||
driver = NULL;
|
driver = NULL;
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1172,7 +1172,7 @@ udevStateInitialize(bool privileged,
|
|||||||
virStateInhibitCallback callback ATTRIBUTE_UNUSED,
|
virStateInhibitCallback callback ATTRIBUTE_UNUSED,
|
||||||
void *opaque ATTRIBUTE_UNUSED)
|
void *opaque ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = VIR_DRV_STATE_INIT_ERROR;
|
||||||
|
|
||||||
if (VIR_ALLOC(driver) < 0)
|
if (VIR_ALLOC(driver) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1210,7 +1210,7 @@ udevStateInitialize(bool privileged,
|
|||||||
}
|
}
|
||||||
driver->privileged = privileged;
|
driver->privileged = privileged;
|
||||||
|
|
||||||
ret = 0;
|
ret = VIR_DRV_STATE_INIT_COMPLETE;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
@ -622,6 +622,7 @@ virRegisterStateDriver(virStateDriverPtr driver)
|
|||||||
/**
|
/**
|
||||||
* virStateInitialize:
|
* virStateInitialize:
|
||||||
* @privileged: set to true if running with root privilege, false otherwise
|
* @privileged: set to true if running with root privilege, false otherwise
|
||||||
|
* @mandatory: set to true if all drivers must report success, not skipped
|
||||||
* @callback: callback to invoke to inhibit shutdown of the daemon
|
* @callback: callback to invoke to inhibit shutdown of the daemon
|
||||||
* @opaque: data to pass to @callback
|
* @opaque: data to pass to @callback
|
||||||
*
|
*
|
||||||
@ -631,6 +632,7 @@ virRegisterStateDriver(virStateDriverPtr driver)
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virStateInitialize(bool privileged,
|
virStateInitialize(bool privileged,
|
||||||
|
bool mandatory,
|
||||||
virStateInhibitCallback callback,
|
virStateInhibitCallback callback,
|
||||||
void *opaque)
|
void *opaque)
|
||||||
{
|
{
|
||||||
@ -641,15 +643,22 @@ virStateInitialize(bool privileged,
|
|||||||
|
|
||||||
for (i = 0; i < virStateDriverTabCount; i++) {
|
for (i = 0; i < virStateDriverTabCount; i++) {
|
||||||
if (virStateDriverTab[i]->stateInitialize) {
|
if (virStateDriverTab[i]->stateInitialize) {
|
||||||
|
virDrvStateInitResult ret;
|
||||||
VIR_DEBUG("Running global init for %s state driver",
|
VIR_DEBUG("Running global init for %s state driver",
|
||||||
virStateDriverTab[i]->name);
|
virStateDriverTab[i]->name);
|
||||||
if (virStateDriverTab[i]->stateInitialize(privileged,
|
ret = virStateDriverTab[i]->stateInitialize(privileged,
|
||||||
callback,
|
callback,
|
||||||
opaque) < 0) {
|
opaque);
|
||||||
|
VIR_DEBUG("State init result %d (mandatory=%d)", ret, mandatory);
|
||||||
|
if (ret == VIR_DRV_STATE_INIT_ERROR) {
|
||||||
VIR_ERROR(_("Initialization of %s state driver failed: %s"),
|
VIR_ERROR(_("Initialization of %s state driver failed: %s"),
|
||||||
virStateDriverTab[i]->name,
|
virStateDriverTab[i]->name,
|
||||||
virGetLastErrorMessage());
|
virGetLastErrorMessage());
|
||||||
return -1;
|
return -1;
|
||||||
|
} else if (ret == VIR_DRV_STATE_INIT_SKIPPED && mandatory) {
|
||||||
|
VIR_ERROR(_("Initialization of mandatory %s state driver skipped"),
|
||||||
|
virStateDriverTab[i]->name);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ typedef void (*virStateInhibitCallback)(bool inhibit,
|
|||||||
void *opaque);
|
void *opaque);
|
||||||
|
|
||||||
int virStateInitialize(bool privileged,
|
int virStateInitialize(bool privileged,
|
||||||
|
bool mandatory,
|
||||||
virStateInhibitCallback inhibit,
|
virStateInhibitCallback inhibit,
|
||||||
void *opaque);
|
void *opaque);
|
||||||
int virStateCleanup(void);
|
int virStateCleanup(void);
|
||||||
|
@ -657,17 +657,17 @@ libxlStateInitialize(bool privileged,
|
|||||||
char ebuf[1024];
|
char ebuf[1024];
|
||||||
|
|
||||||
if (!libxlDriverShouldLoad(privileged))
|
if (!libxlDriverShouldLoad(privileged))
|
||||||
return 0;
|
return VIR_DRV_STATE_INIT_SKIPPED;
|
||||||
|
|
||||||
if (VIR_ALLOC(libxl_driver) < 0)
|
if (VIR_ALLOC(libxl_driver) < 0)
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
|
|
||||||
libxl_driver->lockFD = -1;
|
libxl_driver->lockFD = -1;
|
||||||
if (virMutexInit(&libxl_driver->lock) < 0) {
|
if (virMutexInit(&libxl_driver->lock) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("cannot initialize mutex"));
|
"%s", _("cannot initialize mutex"));
|
||||||
VIR_FREE(libxl_driver);
|
VIR_FREE(libxl_driver);
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate bitmap for vnc port reservation */
|
/* Allocate bitmap for vnc port reservation */
|
||||||
@ -806,12 +806,12 @@ libxlStateInitialize(bool privileged,
|
|||||||
virDomainObjListForEach(libxl_driver->domains, libxlDomainManagedSaveLoad,
|
virDomainObjListForEach(libxl_driver->domains, libxlDomainManagedSaveLoad,
|
||||||
libxl_driver);
|
libxl_driver);
|
||||||
|
|
||||||
return 0;
|
return VIR_DRV_STATE_INIT_COMPLETE;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
VIR_FREE(driverConf);
|
VIR_FREE(driverConf);
|
||||||
libxlStateCleanup();
|
libxlStateCleanup();
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -1545,7 +1545,7 @@ static int lxcStateInitialize(bool privileged,
|
|||||||
/* Check that the user is root, silently disable if not */
|
/* Check that the user is root, silently disable if not */
|
||||||
if (!privileged) {
|
if (!privileged) {
|
||||||
VIR_INFO("Not running privileged, disabling driver");
|
VIR_INFO("Not running privileged, disabling driver");
|
||||||
return 0;
|
return VIR_DRV_STATE_INIT_SKIPPED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check that this is a container enabled kernel */
|
/* Check that this is a container enabled kernel */
|
||||||
@ -1554,15 +1554,15 @@ static int lxcStateInitialize(bool privileged,
|
|||||||
VIR_PROCESS_NAMESPACE_UTS |
|
VIR_PROCESS_NAMESPACE_UTS |
|
||||||
VIR_PROCESS_NAMESPACE_IPC) < 0) {
|
VIR_PROCESS_NAMESPACE_IPC) < 0) {
|
||||||
VIR_INFO("LXC support not available in this kernel, disabling driver");
|
VIR_INFO("LXC support not available in this kernel, disabling driver");
|
||||||
return 0;
|
return VIR_DRV_STATE_INIT_SKIPPED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC(lxc_driver) < 0)
|
if (VIR_ALLOC(lxc_driver) < 0)
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
lxc_driver->lockFD = -1;
|
lxc_driver->lockFD = -1;
|
||||||
if (virMutexInit(&lxc_driver->lock) < 0) {
|
if (virMutexInit(&lxc_driver->lock) < 0) {
|
||||||
VIR_FREE(lxc_driver);
|
VIR_FREE(lxc_driver);
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(lxc_driver->domains = virDomainObjListNew()))
|
if (!(lxc_driver->domains = virDomainObjListNew()))
|
||||||
@ -1633,12 +1633,12 @@ static int lxcStateInitialize(bool privileged,
|
|||||||
virLXCProcessAutostartAll(lxc_driver);
|
virLXCProcessAutostartAll(lxc_driver);
|
||||||
|
|
||||||
virObjectUnref(caps);
|
virObjectUnref(caps);
|
||||||
return 0;
|
return VIR_DRV_STATE_INIT_COMPLETE;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virObjectUnref(caps);
|
virObjectUnref(caps);
|
||||||
lxcStateCleanup();
|
lxcStateCleanup();
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lxcNotifyLoadDomain(virDomainObjPtr vm, int newVM, void *opaque)
|
static void lxcNotifyLoadDomain(virDomainObjPtr vm, int newVM, void *opaque)
|
||||||
|
@ -713,7 +713,7 @@ networkStateInitialize(bool privileged,
|
|||||||
virStateInhibitCallback callback ATTRIBUTE_UNUSED,
|
virStateInhibitCallback callback ATTRIBUTE_UNUSED,
|
||||||
void *opaque ATTRIBUTE_UNUSED)
|
void *opaque ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = VIR_DRV_STATE_INIT_ERROR;
|
||||||
char *configdir = NULL;
|
char *configdir = NULL;
|
||||||
char *rundir = NULL;
|
char *rundir = NULL;
|
||||||
#ifdef WITH_FIREWALLD
|
#ifdef WITH_FIREWALLD
|
||||||
@ -847,7 +847,7 @@ networkStateInitialize(bool privileged,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ret = 0;
|
ret = VIR_DRV_STATE_INIT_COMPLETE;
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(configdir);
|
VIR_FREE(configdir);
|
||||||
VIR_FREE(rundir);
|
VIR_FREE(rundir);
|
||||||
|
@ -599,7 +599,7 @@ nodeStateInitialize(bool privileged ATTRIBUTE_UNUSED,
|
|||||||
char **udi = NULL;
|
char **udi = NULL;
|
||||||
int num_devs;
|
int num_devs;
|
||||||
size_t i;
|
size_t i;
|
||||||
int ret = -1;
|
int ret = VIR_DRV_STATE_INIT_ERROR;
|
||||||
DBusConnection *sysbus;
|
DBusConnection *sysbus;
|
||||||
DBusError err;
|
DBusError err;
|
||||||
|
|
||||||
@ -608,12 +608,12 @@ nodeStateInitialize(bool privileged ATTRIBUTE_UNUSED,
|
|||||||
cmpstringp);
|
cmpstringp);
|
||||||
|
|
||||||
if (VIR_ALLOC(driver) < 0)
|
if (VIR_ALLOC(driver) < 0)
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
|
|
||||||
driver->lockFD = -1;
|
driver->lockFD = -1;
|
||||||
if (virMutexInit(&driver->lock) < 0) {
|
if (virMutexInit(&driver->lock) < 0) {
|
||||||
VIR_FREE(driver);
|
VIR_FREE(driver);
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
}
|
}
|
||||||
nodeDeviceLock();
|
nodeDeviceLock();
|
||||||
|
|
||||||
@ -648,7 +648,7 @@ nodeStateInitialize(bool privileged ATTRIBUTE_UNUSED,
|
|||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("DBus not available, disabling HAL driver: %s"),
|
_("DBus not available, disabling HAL driver: %s"),
|
||||||
virGetLastErrorMessage());
|
virGetLastErrorMessage());
|
||||||
ret = 0;
|
ret = VIR_DRV_STATE_INIT_SKIPPED;
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -671,7 +671,7 @@ nodeStateInitialize(bool privileged ATTRIBUTE_UNUSED,
|
|||||||
/* We don't want to show a fatal error here,
|
/* We don't want to show a fatal error here,
|
||||||
otherwise entire libvirtd shuts down when
|
otherwise entire libvirtd shuts down when
|
||||||
hald isn't running */
|
hald isn't running */
|
||||||
ret = 0;
|
ret = VIR_DRV_STATE_INIT_SKIPPED;
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -709,7 +709,7 @@ nodeStateInitialize(bool privileged ATTRIBUTE_UNUSED,
|
|||||||
}
|
}
|
||||||
VIR_FREE(udi);
|
VIR_FREE(udi);
|
||||||
|
|
||||||
return 0;
|
return VIR_DRV_STATE_INIT_COMPLETE;
|
||||||
|
|
||||||
failure:
|
failure:
|
||||||
if (dbus_error_is_set(&err)) {
|
if (dbus_error_is_set(&err)) {
|
||||||
|
@ -1816,14 +1816,14 @@ nodeStateInitialize(bool privileged,
|
|||||||
virThread enumThread;
|
virThread enumThread;
|
||||||
|
|
||||||
if (VIR_ALLOC(driver) < 0)
|
if (VIR_ALLOC(driver) < 0)
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
|
|
||||||
driver->lockFD = -1;
|
driver->lockFD = -1;
|
||||||
if (virMutexInit(&driver->lock) < 0) {
|
if (virMutexInit(&driver->lock) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Unable to initialize mutex"));
|
_("Unable to initialize mutex"));
|
||||||
VIR_FREE(driver);
|
VIR_FREE(driver);
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
driver->privileged = privileged;
|
driver->privileged = privileged;
|
||||||
@ -1919,11 +1919,11 @@ nodeStateInitialize(bool privileged,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return VIR_DRV_STATE_INIT_COMPLETE;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
nodeStateCleanup();
|
nodeStateCleanup();
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
|
|
||||||
unlock:
|
unlock:
|
||||||
virObjectUnlock(priv);
|
virObjectUnlock(priv);
|
||||||
|
@ -184,10 +184,10 @@ nwfilterStateInitialize(bool privileged,
|
|||||||
|
|
||||||
if (virDBusHasSystemBus() &&
|
if (virDBusHasSystemBus() &&
|
||||||
!(sysbus = virDBusGetSystemBus()))
|
!(sysbus = virDBusGetSystemBus()))
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
|
|
||||||
if (VIR_ALLOC(driver) < 0)
|
if (VIR_ALLOC(driver) < 0)
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
|
|
||||||
driver->lockFD = -1;
|
driver->lockFD = -1;
|
||||||
if (virMutexInit(&driver->lock) < 0)
|
if (virMutexInit(&driver->lock) < 0)
|
||||||
@ -201,7 +201,7 @@ nwfilterStateInitialize(bool privileged,
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (!privileged)
|
if (!privileged)
|
||||||
return 0;
|
return VIR_DRV_STATE_INIT_SKIPPED;
|
||||||
|
|
||||||
nwfilterDriverLock();
|
nwfilterDriverLock();
|
||||||
|
|
||||||
@ -281,13 +281,13 @@ nwfilterStateInitialize(bool privileged,
|
|||||||
|
|
||||||
nwfilterDriverUnlock();
|
nwfilterDriverUnlock();
|
||||||
|
|
||||||
return 0;
|
return VIR_DRV_STATE_INIT_COMPLETE;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
nwfilterDriverUnlock();
|
nwfilterDriverUnlock();
|
||||||
nwfilterStateCleanup();
|
nwfilterStateCleanup();
|
||||||
|
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
|
|
||||||
err_techdrivers_shutdown:
|
err_techdrivers_shutdown:
|
||||||
virNWFilterTechDriversShutdown();
|
virNWFilterTechDriversShutdown();
|
||||||
@ -302,7 +302,7 @@ nwfilterStateInitialize(bool privileged,
|
|||||||
virNWFilterObjListFree(driver->nwfilters);
|
virNWFilterObjListFree(driver->nwfilters);
|
||||||
VIR_FREE(driver);
|
VIR_FREE(driver);
|
||||||
|
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -738,7 +738,7 @@ qemuStateInitialize(bool privileged,
|
|||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (VIR_ALLOC(qemu_driver) < 0)
|
if (VIR_ALLOC(qemu_driver) < 0)
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
|
|
||||||
qemu_driver->lockFD = -1;
|
qemu_driver->lockFD = -1;
|
||||||
|
|
||||||
@ -746,7 +746,7 @@ qemuStateInitialize(bool privileged,
|
|||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("cannot initialize mutex"));
|
_("cannot initialize mutex"));
|
||||||
VIR_FREE(qemu_driver);
|
VIR_FREE(qemu_driver);
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
qemu_driver->inhibitCallback = callback;
|
qemu_driver->inhibitCallback = callback;
|
||||||
@ -1082,14 +1082,14 @@ qemuStateInitialize(bool privileged,
|
|||||||
|
|
||||||
qemuAutostartDomains(qemu_driver);
|
qemuAutostartDomains(qemu_driver);
|
||||||
|
|
||||||
return 0;
|
return VIR_DRV_STATE_INIT_COMPLETE;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
VIR_FREE(driverConf);
|
VIR_FREE(driverConf);
|
||||||
VIR_FREE(hugepagePath);
|
VIR_FREE(hugepagePath);
|
||||||
VIR_FREE(memoryBackingPath);
|
VIR_FREE(memoryBackingPath);
|
||||||
qemuStateCleanup();
|
qemuStateCleanup();
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qemuNotifyLoadDomain(virDomainObjPtr vm, int newVM, void *opaque)
|
static void qemuNotifyLoadDomain(virDomainObjPtr vm, int newVM, void *opaque)
|
||||||
|
@ -792,6 +792,11 @@ static void daemonRunStateInit(void *opaque)
|
|||||||
{
|
{
|
||||||
virNetDaemonPtr dmn = opaque;
|
virNetDaemonPtr dmn = opaque;
|
||||||
virIdentityPtr sysident = virIdentityGetSystem();
|
virIdentityPtr sysident = virIdentityGetSystem();
|
||||||
|
#ifdef MODULE_NAME
|
||||||
|
bool mandatory = true;
|
||||||
|
#else /* ! MODULE_NAME */
|
||||||
|
bool mandatory = false;
|
||||||
|
#endif /* ! MODULE_NAME */
|
||||||
|
|
||||||
virIdentitySetCurrent(sysident);
|
virIdentitySetCurrent(sysident);
|
||||||
|
|
||||||
@ -804,6 +809,7 @@ static void daemonRunStateInit(void *opaque)
|
|||||||
* we're ready, since it can take a long time and this will
|
* we're ready, since it can take a long time and this will
|
||||||
* seriously delay OS bootup process */
|
* seriously delay OS bootup process */
|
||||||
if (virStateInitialize(virNetDaemonIsPrivileged(dmn),
|
if (virStateInitialize(virNetDaemonIsPrivileged(dmn),
|
||||||
|
mandatory,
|
||||||
daemonInhibitCallback,
|
daemonInhibitCallback,
|
||||||
dmn) < 0) {
|
dmn) < 0) {
|
||||||
VIR_ERROR(_("Driver state initialization failed"));
|
VIR_ERROR(_("Driver state initialization failed"));
|
||||||
|
@ -195,7 +195,7 @@ remoteStateInitialize(bool privileged ATTRIBUTE_UNUSED,
|
|||||||
* re-entering ourselves
|
* re-entering ourselves
|
||||||
*/
|
*/
|
||||||
inside_daemon = true;
|
inside_daemon = true;
|
||||||
return 0;
|
return VIR_DRV_STATE_INIT_COMPLETE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -457,12 +457,12 @@ secretStateInitialize(bool privileged,
|
|||||||
void *opaque ATTRIBUTE_UNUSED)
|
void *opaque ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
if (VIR_ALLOC(driver) < 0)
|
if (VIR_ALLOC(driver) < 0)
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
|
|
||||||
driver->lockFD = -1;
|
driver->lockFD = -1;
|
||||||
if (virMutexInit(&driver->lock) < 0) {
|
if (virMutexInit(&driver->lock) < 0) {
|
||||||
VIR_FREE(driver);
|
VIR_FREE(driver);
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
}
|
}
|
||||||
secretDriverLock();
|
secretDriverLock();
|
||||||
|
|
||||||
@ -514,12 +514,12 @@ secretStateInitialize(bool privileged,
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
secretDriverUnlock();
|
secretDriverUnlock();
|
||||||
return 0;
|
return VIR_DRV_STATE_INIT_COMPLETE;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
secretDriverUnlock();
|
secretDriverUnlock();
|
||||||
secretStateCleanup();
|
secretStateCleanup();
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -255,12 +255,12 @@ storageStateInitialize(bool privileged,
|
|||||||
VIR_AUTOFREE(char *) rundir = NULL;
|
VIR_AUTOFREE(char *) rundir = NULL;
|
||||||
|
|
||||||
if (VIR_ALLOC(driver) < 0)
|
if (VIR_ALLOC(driver) < 0)
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
|
|
||||||
driver->lockFD = -1;
|
driver->lockFD = -1;
|
||||||
if (virMutexInit(&driver->lock) < 0) {
|
if (virMutexInit(&driver->lock) < 0) {
|
||||||
VIR_FREE(driver);
|
VIR_FREE(driver);
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
}
|
}
|
||||||
storageDriverLock();
|
storageDriverLock();
|
||||||
|
|
||||||
@ -326,12 +326,12 @@ storageStateInitialize(bool privileged,
|
|||||||
|
|
||||||
storageDriverUnlock();
|
storageDriverUnlock();
|
||||||
|
|
||||||
return 0;
|
return VIR_DRV_STATE_INIT_COMPLETE;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
storageDriverUnlock();
|
storageDriverUnlock();
|
||||||
storageStateCleanup();
|
storageStateCleanup();
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4118,36 +4118,36 @@ vzStateInitialize(bool privileged,
|
|||||||
void *opaque ATTRIBUTE_UNUSED)
|
void *opaque ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
if (!privileged)
|
if (!privileged)
|
||||||
return 0;
|
return VIR_DRV_STATE_INIT_SKIPPED;
|
||||||
|
|
||||||
vz_driver_privileged = privileged;
|
vz_driver_privileged = privileged;
|
||||||
|
|
||||||
if (virFileMakePathWithMode(VZ_STATEDIR, S_IRWXU) < 0) {
|
if (virFileMakePathWithMode(VZ_STATEDIR, S_IRWXU) < 0) {
|
||||||
virReportSystemError(errno, _("cannot create state directory '%s'"),
|
virReportSystemError(errno, _("cannot create state directory '%s'"),
|
||||||
VZ_STATEDIR);
|
VZ_STATEDIR);
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((vz_driver_lock_fd =
|
if ((vz_driver_lock_fd =
|
||||||
virPidFileAcquire(VZ_STATEDIR, "driver", false, getpid())) < 0)
|
virPidFileAcquire(VZ_STATEDIR, "driver", false, getpid())) < 0)
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
|
|
||||||
if (prlsdkInit() < 0) {
|
if (prlsdkInit() < 0) {
|
||||||
VIR_DEBUG("%s", _("Can't initialize Parallels SDK"));
|
VIR_DEBUG("%s", _("Can't initialize Parallels SDK"));
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virMutexInit(&vz_driver_lock) < 0)
|
if (virMutexInit(&vz_driver_lock) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
/* Failing to create driver here is not fatal and only means
|
/* Failing to create driver here is not fatal and only means
|
||||||
* that next driver client will try once more when connecting */
|
* that next driver client will try once more when connecting */
|
||||||
vz_driver = vzDriverObjNew();
|
vz_driver = vzDriverObjNew();
|
||||||
return 0;
|
return VIR_DRV_STATE_INIT_COMPLETE;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
vzStateCleanup();
|
vzStateCleanup();
|
||||||
return -1;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static virStateDriver vzStateDriver = {
|
static virStateDriver vzStateDriver = {
|
||||||
|
Loading…
Reference in New Issue
Block a user