]> xenbits.xensource.com Git - libvirt.git/commitdiff
virGetConnectGeneric: Only delegate existing identities
authorMartin Kletzander <mkletzan@redhat.com>
Fri, 11 Nov 2022 13:19:50 +0000 (14:19 +0100)
committerMartin Kletzander <mkletzan@redhat.com>
Tue, 15 Nov 2022 10:04:33 +0000 (11:04 +0100)
Inside virt-qemu-run, just like in virsh for example, there is no
identity set in the current thread, so we should not try to set it,
otherwise things like connecting to other drivers might fail and on
top of that there is no error set so the user can't even see what's
wrong.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2000075
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/driver.c

index cea74bdf95c6c3dbc4df5a741f809ada793b8e7e..04cbbcd3ef83c60c9c6815a5e9416cb87c4d8ede 100644 (file)
@@ -160,17 +160,15 @@ virGetConnectGeneric(virThreadLocal *threadPtr, const char *name)
 
         if (conn->driver->connectSetIdentity != NULL) {
             g_autoptr(virIdentity) ident = NULL;
-            g_autoptr(virTypedParamList) identparams = NULL;
 
             VIR_DEBUG("Attempting to delegate current identity");
-            if (!(ident = virIdentityGetCurrent()))
-                goto error;
+            ident = virIdentityGetCurrent();
+            if (ident) {
+                g_autoptr(virTypedParamList) tmp = virIdentityGetParameters(ident);
 
-            if (!(identparams = virIdentityGetParameters(ident)))
-                goto error;
-
-            if (virConnectSetIdentity(conn, identparams->par, identparams->npar, 0) < 0)
-                goto error;
+                if (virConnectSetIdentity(conn, tmp->par, tmp->npar, 0) < 0)
+                    goto error;
+            }
         }
     }
     return conn;