[PATCH 2/3] Add a method for closing the dbus system bus connection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

If the dbus system bus connection is marked as private, then
allow it to be closed.

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 src/libvirt_private.syms |  1 +
 src/util/virdbus.c       | 12 ++++++++++++
 src/util/virdbus.h       |  1 +
 3 files changed, 14 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index b2b1fa8..7ee538c 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1102,6 +1102,7 @@ virConfWriteMem;
 
 # util/virdbus.h
 virDBusCallMethod;
+virDBusCloseSystemBus;
 virDBusGetSessionBus;
 virDBusGetSystemBus;
 virDBusHasSystemBus;
diff --git a/src/util/virdbus.c b/src/util/virdbus.c
index 3c6007e..dc4ace0 100644
--- a/src/util/virdbus.c
+++ b/src/util/virdbus.c
@@ -122,6 +122,14 @@ virDBusHasSystemBus(void)
 }
 
 
+void virDBusCloseSystemBus(void)
+{
+    if (systembus && !sharedBus) {
+        dbus_connection_close(systembus);
+        systembus = NULL;
+    }
+}
+
 static void virDBusSessionBusInit(void)
 {
     sessionbus = virDBusBusInit(DBUS_BUS_SESSION, &sessiondbuserr);
@@ -1310,6 +1318,10 @@ virDBusHasSystemBus(void)
     return false;
 }
 
+void virDBusCloseSystemBus(void)
+{
+    /* nothing */
+}
 
 DBusConnection *virDBusGetSessionBus(void)
 {
diff --git a/src/util/virdbus.h b/src/util/virdbus.h
index 125a405..979c566 100644
--- a/src/util/virdbus.h
+++ b/src/util/virdbus.h
@@ -35,6 +35,7 @@ void virDBusSetSharedBus(bool shared);
 
 DBusConnection *virDBusGetSystemBus(void);
 bool virDBusHasSystemBus(void);
+void virDBusCloseSystemBus(void);
 DBusConnection *virDBusGetSessionBus(void);
 
 int virDBusCallMethod(DBusConnection *conn,
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]