mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 01:43:23 +00:00
Don't ignore all dbus connection errors
Previous commit
commit 7ada155cdf
Author: Gao feng <gaofeng@cn.fujitsu.com>
Date: Wed Sep 11 11:15:02 2013 +0800
DBus: introduce virDBusIsServiceEnabled
Made the cgroups code fallback to non-systemd based setup
when dbus is not running. It was too big a hammer though,
as it did not check what error code was received when the
dbus connection failed. Thus it silently ignored serious
errors from dbus such as "too many client connections",
which should always be treated as fatal.
We only want to ignore errors if the dbus unix socket does
not exist, or if nothing is listening on it.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
1815e2d081
commit
6bd8860001
@ -175,8 +175,9 @@ nwfilterStateInitialize(bool privileged,
|
|||||||
DBusConnection *sysbus = NULL;
|
DBusConnection *sysbus = NULL;
|
||||||
|
|
||||||
#if WITH_DBUS
|
#if WITH_DBUS
|
||||||
if (virDBusHasSystemBus())
|
if (virDBusHasSystemBus() &&
|
||||||
sysbus = virDBusGetSystemBus();
|
!(sysbus = virDBusGetSystemBus()))
|
||||||
|
return -1;
|
||||||
#endif /* WITH_DBUS */
|
#endif /* WITH_DBUS */
|
||||||
|
|
||||||
if (VIR_ALLOC(driverState) < 0)
|
if (VIR_ALLOC(driverState) < 0)
|
||||||
|
@ -111,14 +111,29 @@ virDBusGetSystemBus(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virDBusHasSystemBus:
|
||||||
|
*
|
||||||
|
* Check if dbus system bus is running. This does not
|
||||||
|
* imply that we have a connection. DBus might be running
|
||||||
|
* and refusing connections due to its client limit. The
|
||||||
|
* latter must be treated as a fatal error.
|
||||||
|
*
|
||||||
|
* Return false if dbus is not available, true if probably available.
|
||||||
|
*/
|
||||||
bool
|
bool
|
||||||
virDBusHasSystemBus(void)
|
virDBusHasSystemBus(void)
|
||||||
{
|
{
|
||||||
if (virDBusGetSystemBusInternal())
|
if (virDBusGetSystemBusInternal())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
VIR_DEBUG("System DBus not available: %s", NULLSTR(systemdbuserr.message));
|
if (systemdbuserr.name &&
|
||||||
return false;
|
(STREQ(systemdbuserr.name, "org.freedesktop.DBus.Error.FileNotFound") ||
|
||||||
|
STREQ(systemdbuserr.name, "org.freedesktop.DBus.Error.NoServer"))) {
|
||||||
|
VIR_DEBUG("System DBus not available: %s", NULLSTR(systemdbuserr.message));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1257,7 +1272,8 @@ int virDBusIsServiceEnabled(const char *name)
|
|||||||
if (!virDBusHasSystemBus())
|
if (!virDBusHasSystemBus())
|
||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
conn = virDBusGetSystemBus();
|
if (!(conn = virDBusGetSystemBus()))
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (virDBusCallMethod(conn,
|
if (virDBusCallMethod(conn,
|
||||||
&reply,
|
&reply,
|
||||||
|
@ -169,7 +169,8 @@ int virSystemdCreateMachine(const char *name,
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
conn = virDBusGetSystemBus();
|
if (!(conn = virDBusGetSystemBus()))
|
||||||
|
return -1;
|
||||||
|
|
||||||
ret = -1;
|
ret = -1;
|
||||||
if (!(machinename = virSystemdMakeMachineName(name, drivername, privileged)))
|
if (!(machinename = virSystemdMakeMachineName(name, drivername, privileged)))
|
||||||
@ -267,7 +268,8 @@ int virSystemdTerminateMachine(const char *name,
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
conn = virDBusGetSystemBus();
|
if (!(conn = virDBusGetSystemBus()))
|
||||||
|
return -1;
|
||||||
|
|
||||||
ret = -1;
|
ret = -1;
|
||||||
if (!(machinename = virSystemdMakeMachineName(name, drivername, privileged)))
|
if (!(machinename = virSystemdMakeMachineName(name, drivername, privileged)))
|
||||||
|
Loading…
Reference in New Issue
Block a user