|
|
43fe83 |
From 07efc2e98d4bd8796e4003f81baee53d3f83a06b Mon Sep 17 00:00:00 2001
|
|
|
43fe83 |
Message-Id: <07efc2e98d4bd8796e4003f81baee53d3f83a06b.1381871412.git.jdenemar@redhat.com>
|
|
|
43fe83 |
From: "Daniel P. Berrange" <berrange@redhat.com>
|
|
|
43fe83 |
Date: Mon, 14 Oct 2013 16:45:24 +0100
|
|
|
43fe83 |
Subject: [PATCH] Don't ignore all dbus connection errors
|
|
|
43fe83 |
|
|
|
43fe83 |
For
|
|
|
43fe83 |
|
|
|
43fe83 |
https://bugzilla.redhat.com/show_bug.cgi?id=927072
|
|
|
43fe83 |
|
|
|
43fe83 |
Previous commit
|
|
|
43fe83 |
|
|
|
43fe83 |
commit 7ada155cdf2bbfac16ce08f64abb455a940e2cf7
|
|
|
43fe83 |
Author: Gao feng <gaofeng@cn.fujitsu.com>
|
|
|
43fe83 |
Date: Wed Sep 11 11:15:02 2013 +0800
|
|
|
43fe83 |
|
|
|
43fe83 |
DBus: introduce virDBusIsServiceEnabled
|
|
|
43fe83 |
|
|
|
43fe83 |
Made the cgroups code fallback to non-systemd based setup
|
|
|
43fe83 |
when dbus is not running. It was too big a hammer though,
|
|
|
43fe83 |
as it did not check what error code was received when the
|
|
|
43fe83 |
dbus connection failed. Thus it silently ignored serious
|
|
|
43fe83 |
errors from dbus such as "too many client connections",
|
|
|
43fe83 |
which should always be treated as fatal.
|
|
|
43fe83 |
|
|
|
43fe83 |
We only want to ignore errors if the dbus unix socket does
|
|
|
43fe83 |
not exist, or if nothing is listening on it.
|
|
|
43fe83 |
|
|
|
43fe83 |
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
|
|
|
43fe83 |
(cherry picked from commit 6bd886000100be2adce8650d0579a2303a7bf85b)
|
|
|
43fe83 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
43fe83 |
---
|
|
|
43fe83 |
src/nwfilter/nwfilter_driver.c | 5 +++--
|
|
|
43fe83 |
src/util/virdbus.c | 22 +++++++++++++++++++---
|
|
|
43fe83 |
src/util/virsystemd.c | 6 ++++--
|
|
|
43fe83 |
3 files changed, 26 insertions(+), 7 deletions(-)
|
|
|
43fe83 |
|
|
|
43fe83 |
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
|
|
|
43fe83 |
index d25c6f2..6602d73 100644
|
|
|
43fe83 |
--- a/src/nwfilter/nwfilter_driver.c
|
|
|
43fe83 |
+++ b/src/nwfilter/nwfilter_driver.c
|
|
|
43fe83 |
@@ -175,8 +175,9 @@ nwfilterStateInitialize(bool privileged,
|
|
|
43fe83 |
DBusConnection *sysbus = NULL;
|
|
|
43fe83 |
|
|
|
43fe83 |
#if WITH_DBUS
|
|
|
43fe83 |
- if (virDBusHasSystemBus())
|
|
|
43fe83 |
- sysbus = virDBusGetSystemBus();
|
|
|
43fe83 |
+ if (virDBusHasSystemBus() &&
|
|
|
43fe83 |
+ !(sysbus = virDBusGetSystemBus()))
|
|
|
43fe83 |
+ return -1;
|
|
|
43fe83 |
#endif /* WITH_DBUS */
|
|
|
43fe83 |
|
|
|
43fe83 |
if (VIR_ALLOC(driverState) < 0)
|
|
|
43fe83 |
diff --git a/src/util/virdbus.c b/src/util/virdbus.c
|
|
|
43fe83 |
index da69430..94f3f47 100644
|
|
|
43fe83 |
--- a/src/util/virdbus.c
|
|
|
43fe83 |
+++ b/src/util/virdbus.c
|
|
|
43fe83 |
@@ -111,14 +111,29 @@ virDBusGetSystemBus(void)
|
|
|
43fe83 |
}
|
|
|
43fe83 |
|
|
|
43fe83 |
|
|
|
43fe83 |
+/**
|
|
|
43fe83 |
+ * virDBusHasSystemBus:
|
|
|
43fe83 |
+ *
|
|
|
43fe83 |
+ * Check if dbus system bus is running. This does not
|
|
|
43fe83 |
+ * imply that we have a connection. DBus might be running
|
|
|
43fe83 |
+ * and refusing connections due to its client limit. The
|
|
|
43fe83 |
+ * latter must be treated as a fatal error.
|
|
|
43fe83 |
+ *
|
|
|
43fe83 |
+ * Return false if dbus is not available, true if probably available.
|
|
|
43fe83 |
+ */
|
|
|
43fe83 |
bool
|
|
|
43fe83 |
virDBusHasSystemBus(void)
|
|
|
43fe83 |
{
|
|
|
43fe83 |
if (virDBusGetSystemBusInternal())
|
|
|
43fe83 |
return true;
|
|
|
43fe83 |
|
|
|
43fe83 |
- VIR_DEBUG("System DBus not available: %s", NULLSTR(systemdbuserr.message));
|
|
|
43fe83 |
- return false;
|
|
|
43fe83 |
+ if (systemdbuserr.name &&
|
|
|
43fe83 |
+ (STREQ(systemdbuserr.name, "org.freedesktop.DBus.Error.FileNotFound") ||
|
|
|
43fe83 |
+ STREQ(systemdbuserr.name, "org.freedesktop.DBus.Error.NoServer"))) {
|
|
|
43fe83 |
+ VIR_DEBUG("System DBus not available: %s", NULLSTR(systemdbuserr.message));
|
|
|
43fe83 |
+ return false;
|
|
|
43fe83 |
+ }
|
|
|
43fe83 |
+ return true;
|
|
|
43fe83 |
}
|
|
|
43fe83 |
|
|
|
43fe83 |
|
|
|
43fe83 |
@@ -1240,7 +1255,8 @@ int virDBusIsServiceEnabled(const char *name)
|
|
|
43fe83 |
if (!virDBusHasSystemBus())
|
|
|
43fe83 |
return -2;
|
|
|
43fe83 |
|
|
|
43fe83 |
- conn = virDBusGetSystemBus();
|
|
|
43fe83 |
+ if (!(conn = virDBusGetSystemBus()))
|
|
|
43fe83 |
+ return -1;
|
|
|
43fe83 |
|
|
|
43fe83 |
if (virDBusCallMethod(conn,
|
|
|
43fe83 |
&reply,
|
|
|
43fe83 |
diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c
|
|
|
43fe83 |
index 1ba37cc..503fff7 100644
|
|
|
43fe83 |
--- a/src/util/virsystemd.c
|
|
|
43fe83 |
+++ b/src/util/virsystemd.c
|
|
|
43fe83 |
@@ -169,7 +169,8 @@ int virSystemdCreateMachine(const char *name,
|
|
|
43fe83 |
if (ret < 0)
|
|
|
43fe83 |
return ret;
|
|
|
43fe83 |
|
|
|
43fe83 |
- conn = virDBusGetSystemBus();
|
|
|
43fe83 |
+ if (!(conn = virDBusGetSystemBus()))
|
|
|
43fe83 |
+ return -1;
|
|
|
43fe83 |
|
|
|
43fe83 |
ret = -1;
|
|
|
43fe83 |
if (!(machinename = virSystemdMakeMachineName(name, drivername, privileged)))
|
|
|
43fe83 |
@@ -267,7 +268,8 @@ int virSystemdTerminateMachine(const char *name,
|
|
|
43fe83 |
if (ret < 0)
|
|
|
43fe83 |
return ret;
|
|
|
43fe83 |
|
|
|
43fe83 |
- conn = virDBusGetSystemBus();
|
|
|
43fe83 |
+ if (!(conn = virDBusGetSystemBus()))
|
|
|
43fe83 |
+ return -1;
|
|
|
43fe83 |
|
|
|
43fe83 |
ret = -1;
|
|
|
43fe83 |
if (!(machinename = virSystemdMakeMachineName(name, drivername, privileged)))
|
|
|
43fe83 |
--
|
|
|
43fe83 |
1.8.3.2
|
|
|
43fe83 |
|