Blob Blame History Raw
From bc84df329033b0162efd5e4fd2753666d44be3ee Mon Sep 17 00:00:00 2001
Message-Id: <bc84df329033b0162efd5e4fd2753666d44be3ee.1381871412.git.jdenemar@redhat.com>
From: "Daniel P. Berrange" <berrange@redhat.com>
Date: Mon, 14 Oct 2013 16:45:18 +0100
Subject: [PATCH] Add a method for closing the dbus system bus connection

For

  https://bugzilla.redhat.com/show_bug.cgi?id=998365

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

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 489beb0aba5aad0e5423e123db9a7ab67421ca48)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 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 c91a9f9..5e4de67 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1292,6 +1292,7 @@ virConfWriteMem;
 
 # util/virdbus.h
 virDBusCallMethod;
+virDBusCloseSystemBus;
 virDBusGetSessionBus;
 virDBusGetSystemBus;
 virDBusHasSystemBus;
diff --git a/src/util/virdbus.c b/src/util/virdbus.c
index bcc5b1c..da69430 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);
@@ -1293,6 +1301,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.2