virStateInitialize: Propagate whether running in monolithic daemon mode to stateful driver init

Upcoming patch which is fixing the opening of drivers in monolithic mode
needs to know whether we are inside 'libvirtd' but the code where the
decision needs to happen is not re-compiled per daemon. Thus we need to
pass this information to the stateful driver init function so that it
can be remebered.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2022-09-09 13:16:42 +02:00
parent 03f924f2b2
commit 4b70a0519c
18 changed files with 26 additions and 1 deletions

View File

@ -1178,6 +1178,7 @@ bhyveStateCleanup(void)
static int
bhyveStateInitialize(bool privileged,
const char *root,
bool monolithic G_GNUC_UNUSED,
virStateInhibitCallback callback G_GNUC_UNUSED,
void *opaque G_GNUC_UNUSED)
{

View File

@ -861,6 +861,7 @@ static int chStateCleanup(void)
static int chStateInitialize(bool privileged,
const char *root,
bool monolithic G_GNUC_UNUSED,
virStateInhibitCallback callback G_GNUC_UNUSED,
void *opaque G_GNUC_UNUSED)
{

View File

@ -33,6 +33,7 @@ typedef enum {
typedef virDrvStateInitResult
(*virDrvStateInitialize)(bool privileged,
const char *root,
bool monolithic,
virStateInhibitCallback callback,
void *opaque);

View File

@ -89,6 +89,7 @@ virNetcfDriverStateDispose(void *obj)
static int
netcfStateInitialize(bool privileged,
const char *root,
bool monolithic G_GNUC_UNUSED,
virStateInhibitCallback callback G_GNUC_UNUSED,
void *opaque G_GNUC_UNUSED)
{

View File

@ -1110,6 +1110,7 @@ udevStateCleanup(void);
static int
udevStateInitialize(bool privileged,
const char *root,
bool monolithic G_GNUC_UNUSED,
virStateInhibitCallback callback G_GNUC_UNUSED,
void *opaque G_GNUC_UNUSED)
{

View File

@ -604,6 +604,7 @@ virRegisterStateDriver(virStateDriver *driver)
* @privileged: set to true if running with root privilege, false otherwise
* @mandatory: set to true if all drivers must report success, not skipped
* @root: directory to use for embedded mode
* @monolithic: set to true if running in monolithic mode (daemon is libvirtd)
* @callback: callback to invoke to inhibit shutdown of the daemon
* @opaque: data to pass to @callback
*
@ -633,6 +634,7 @@ int
virStateInitialize(bool privileged,
bool mandatory,
const char *root,
bool monolithic,
virStateInhibitCallback callback,
void *opaque)
{
@ -650,6 +652,7 @@ virStateInitialize(bool privileged,
virStateDriverTab[i]->initialized = true;
ret = virStateDriverTab[i]->stateInitialize(privileged,
root,
monolithic,
callback,
opaque);
VIR_DEBUG("State init result %d (mandatory=%d)", ret, mandatory);
@ -1016,7 +1019,7 @@ virConnectOpenInternal(const char *name,
virAccessManagerSetDefault(acl);
}
if (virStateInitialize(geteuid() == 0, true, root, NULL, NULL) < 0)
if (virStateInitialize(geteuid() == 0, true, root, false, NULL, NULL) < 0)
return NULL;
embed = true;

View File

@ -32,6 +32,7 @@ typedef void (*virStateInhibitCallback)(bool inhibit,
int virStateInitialize(bool privileged,
bool mandatory,
const char *root,
bool monolithic,
virStateInhibitCallback inhibit,
void *opaque);
int virStateShutdownPrepare(void);

View File

@ -648,6 +648,7 @@ libxlAddDom0(libxlDriverPrivate *driver)
static int
libxlStateInitialize(bool privileged,
const char *root,
bool monolithic G_GNUC_UNUSED,
virStateInhibitCallback callback,
void *opaque)
{

View File

@ -1430,6 +1430,7 @@ lxcSecurityInit(virLXCDriverConfig *cfg)
static int lxcStateInitialize(bool privileged,
const char *root,
bool monolithic G_GNUC_UNUSED,
virStateInhibitCallback callback G_GNUC_UNUSED,
void *opaque G_GNUC_UNUSED)
{

View File

@ -575,6 +575,7 @@ firewalld_dbus_signal_callback(GDBusConnection *connection G_GNUC_UNUSED,
static int
networkStateInitialize(bool privileged,
const char *root,
bool monolithic G_GNUC_UNUSED,
virStateInhibitCallback callback G_GNUC_UNUSED,
void *opaque G_GNUC_UNUSED)
{

View File

@ -2226,6 +2226,7 @@ mdevctlEventHandleCallback(GFileMonitor *monitor G_GNUC_UNUSED,
static int
nodeStateInitialize(bool privileged,
const char *root,
bool monolithic G_GNUC_UNUSED,
virStateInhibitCallback callback G_GNUC_UNUSED,
void *opaque G_GNUC_UNUSED)
{

View File

@ -211,6 +211,7 @@ nwfilterStateCleanup(void)
static int
nwfilterStateInitialize(bool privileged,
const char *root,
bool monolithic G_GNUC_UNUSED,
virStateInhibitCallback callback G_GNUC_UNUSED,
void *opaque G_GNUC_UNUSED)
{

View File

@ -549,6 +549,7 @@ qemuDomainFindMaxID(virDomainObj *vm,
static int
qemuStateInitialize(bool privileged,
const char *root,
bool monolithic G_GNUC_UNUSED,
virStateInhibitCallback callback,
void *opaque)
{

View File

@ -591,6 +591,11 @@ static void daemonRunStateInit(void *opaque)
#else /* ! MODULE_NAME */
bool mandatory = false;
#endif /* ! MODULE_NAME */
#ifdef LIBVIRTD
bool monolithic = true;
#else /* ! LIBVIRTD */
bool monolithic = false;
#endif /* ! LIBVIRTD */
virIdentitySetCurrent(sysident);
@ -605,6 +610,7 @@ static void daemonRunStateInit(void *opaque)
if (virStateInitialize(virNetDaemonIsPrivileged(dmn),
mandatory,
NULL,
monolithic,
daemonInhibitCallback,
dmn) < 0) {
VIR_ERROR(_("Driver state initialization failed"));

View File

@ -168,6 +168,7 @@ static void make_nonnull_domain_snapshot(remote_nonnull_domain_snapshot *snapsho
static int
remoteStateInitialize(bool privileged G_GNUC_UNUSED,
const char *root G_GNUC_UNUSED,
bool monolithic G_GNUC_UNUSED,
virStateInhibitCallback callback G_GNUC_UNUSED,
void *opaque G_GNUC_UNUSED)
{

View File

@ -462,6 +462,7 @@ secretStateCleanup(void)
static int
secretStateInitialize(bool privileged,
const char *root,
bool monolithic G_GNUC_UNUSED,
virStateInhibitCallback callback G_GNUC_UNUSED,
void *opaque G_GNUC_UNUSED)
{

View File

@ -242,6 +242,7 @@ storageDriverAutostart(void)
static int
storageStateInitialize(bool privileged,
const char *root,
bool monolithic G_GNUC_UNUSED,
virStateInhibitCallback callback G_GNUC_UNUSED,
void *opaque G_GNUC_UNUSED)
{

View File

@ -4077,6 +4077,7 @@ vzStateCleanup(void)
static int
vzStateInitialize(bool privileged,
const char *root,
bool monolithic G_GNUC_UNUSED,
virStateInhibitCallback callback G_GNUC_UNUSED,
void *opaque G_GNUC_UNUSED)
{