render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
edecca
From 4df55f75bf523e3c1964198299713bdfa85fbad2 Mon Sep 17 00:00:00 2001
edecca
Message-Id: <4df55f75bf523e3c1964198299713bdfa85fbad2@dist-git>
edecca
From: John Ferlan <jferlan@redhat.com>
edecca
Date: Wed, 14 Nov 2018 14:41:31 -0500
edecca
Subject: [PATCH] qemu: Set identity for the reconnect all thread
edecca
edecca
https://bugzilla.redhat.com/show_bug.cgi?id=1648546 (RHEL8)
edecca
https://bugzilla.redhat.com/show_bug.cgi?id=1631622 (RHEL7)
edecca
edecca
If polkit authentication is enabled, an attempt to open
edecca
the connection failed during virAccessDriverPolkitGetCaller
edecca
when the call to virIdentityGetCurrent returned NULL resulting
edecca
in the errors:
edecca
edecca
  virAccessDriverPolkitGetCaller:87 : access denied:
edecca
  Policy kit denied action org.libvirt.api.connect.getattr from <anonymous>
edecca
edecca
Because qemuProcessReconnect runs in a thread during
edecca
daemonRunStateInit processing it doesn't have the thread
edecca
local identity. Thus when the virGetConnectNWFilter is
edecca
called as part of the qemuProcessFiltersInstantiate when
edecca
virDomainConfNWFilterInstantiate is run the attempt to get
edecca
the idenity fails and results in the anonymous error above.
edecca
edecca
To fix this, let's grab/use the virIdenityPtr of the process
edecca
that will be creating the thread, e.g. what daemonRunStateInit
edecca
has set and use that for our thread. That way any other similar
edecca
processing that uses/requires an identity for any other call
edecca
that would have previously been successfully run won't fail in
edecca
a similar manner.
edecca
edecca
Signed-off-by: John Ferlan <jferlan@redhat.com>
edecca
(cherry picked from commit b04b82f8cb671f067bad2d5e922acf88f13f0934)
edecca
Reviewed-by: Erik Skultety <eskultet@redhat.com>
edecca
---
edecca
 src/qemu/qemu_process.c | 7 +++++++
edecca
 1 file changed, 7 insertions(+)
edecca
edecca
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
edecca
index 8ba14abfa4..4b99fbd835 100644
edecca
--- a/src/qemu/qemu_process.c
edecca
+++ b/src/qemu/qemu_process.c
edecca
@@ -81,6 +81,7 @@
edecca
 #include "netdev_bandwidth_conf.h"
edecca
 #include "virresctrl.h"
edecca
 #include "virvsock.h"
edecca
+#include "viridentity.h"
edecca
 
edecca
 #define VIR_FROM_THIS VIR_FROM_QEMU
edecca
 
edecca
@@ -7609,6 +7610,7 @@ qemuProcessRefreshCPU(virQEMUDriverPtr driver,
edecca
 struct qemuProcessReconnectData {
edecca
     virQEMUDriverPtr driver;
edecca
     virDomainObjPtr obj;
edecca
+    virIdentityPtr identity;
edecca
 };
edecca
 /*
edecca
  * Open an existing VM's monitor, re-detect VCPU threads
edecca
@@ -7645,6 +7647,8 @@ qemuProcessReconnect(void *opaque)
edecca
     virCapsPtr caps = NULL;
edecca
     bool retry = true;
edecca
 
edecca
+    virIdentitySetCurrent(data->identity);
edecca
+    virObjectUnref(data->identity);
edecca
     VIR_FREE(data);
edecca
 
edecca
     qemuDomainObjRestoreJob(obj, &oldjob);
edecca
@@ -7865,6 +7869,7 @@ qemuProcessReconnect(void *opaque)
edecca
     virObjectUnref(cfg);
edecca
     virObjectUnref(caps);
edecca
     virNWFilterUnlockFilterUpdates();
edecca
+    virIdentitySetCurrent(NULL);
edecca
     return;
edecca
 
edecca
  error:
edecca
@@ -7902,6 +7907,7 @@ qemuProcessReconnectHelper(virDomainObjPtr obj,
edecca
 
edecca
     memcpy(data, src, sizeof(*data));
edecca
     data->obj = obj;
edecca
+    data->identity = virIdentityGetCurrent();
edecca
 
edecca
     virNWFilterReadLockFilterUpdates();
edecca
 
edecca
@@ -7925,6 +7931,7 @@ qemuProcessReconnectHelper(virDomainObjPtr obj,
edecca
 
edecca
         virDomainObjEndAPI(&obj);
edecca
         virNWFilterUnlockFilterUpdates();
edecca
+        virObjectUnref(data->identity);
edecca
         VIR_FREE(data);
edecca
         return -1;
edecca
     }
edecca
-- 
edecca
2.19.2
edecca