]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virgdbus: fix getting non-shared DBus connection
authorPavel Hrdina <phrdina@redhat.com>
Mon, 9 Nov 2020 16:10:56 +0000 (17:10 +0100)
committerPavel Hrdina <phrdina@redhat.com>
Mon, 9 Nov 2020 22:42:33 +0000 (23:42 +0100)
We need to pass some flags in order to properly initialize the
connection otherwise it will not work. This copies what GLib does
for g_bus_get_sync() internally.

This fixes an issue with LXC driver where libvirt was not able to
register any VM with machined.

Reported-by: Matthias Maier <tamiko@gentoo.org>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virgdbus.c

index 19fd7e2fe486f348efbf900aced52ad729da5619..4ad1a5c8424c60b7649f6cff3147fb2ff7d9ee59 100644 (file)
@@ -54,11 +54,15 @@ virGDBusBusInit(GBusType type, GError **error)
     if (sharedBus) {
         return g_bus_get_sync(type, NULL, error);
     } else {
+        GDBusConnectionFlags dbusFlags =
+                G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT |
+                G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION;
+
         address = g_dbus_address_get_for_bus_sync(type, NULL, error);
         if (*error)
             return NULL;
         return g_dbus_connection_new_for_address_sync(address,
-                                                      G_DBUS_CONNECTION_FLAGS_NONE,
+                                                      dbusFlags,
                                                       NULL,
                                                       NULL,
                                                       error);