[libvirt PATCH] virgdbus: fix getting non-shared DBus connection

Pavel Hrdina posted 1 patch 3 years, 5 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/db20be3d79c7d0b82d955f773996828970747ab1.1604939975.git.phrdina@redhat.com
src/util/virgdbus.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
[libvirt PATCH] virgdbus: fix getting non-shared DBus connection
Posted by Pavel Hrdina 3 years, 5 months ago
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>
---
 src/util/virgdbus.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/util/virgdbus.c b/src/util/virgdbus.c
index 19fd7e2fe4..4ad1a5c842 100644
--- a/src/util/virgdbus.c
+++ b/src/util/virgdbus.c
@@ -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);
-- 
2.26.2

Re: [libvirt PATCH] virgdbus: fix getting non-shared DBus connection
Posted by Ján Tomko 3 years, 5 months ago
On a Monday in 2020, Pavel Hrdina wrote:
>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>
>---
> src/util/virgdbus.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano