[PATCH 3/3] *** DO NOT MERGE ***

Michal Privoznik mprivozn at redhat.com
Tue Oct 26 10:17:08 UTC 2021


One problem with qemuProcessStop() is that it may run from
"qemu-event" thread. This thread processes events from all
guests, meaning there's just one thread that serves all running
guests. But as such has no virIdentity set, which looks correct
on the first glance - there's no identity to associate it with
anyway.

But, the problem arises when we need to connect to other daemons
(e.g. virtnetworkd) to call APIs (e.g. delete a port). Here we
want the thread to have the identity that of the guest. But since
we haven't set any identity, opening connection to secondary
drivers fails (because virIdentityGetCurrent() returns NULL which
is treated by virGetConnectGeneric() as an error).

As a terrible hack we can set the system identity.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2013573
Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/qemu/qemu_process.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index d5f8a47ac2..7ae1974710 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -7888,6 +7888,7 @@ void qemuProcessStop(virQEMUDriver *driver,
     g_autofree char *timestamp = NULL;
     g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
     g_autoptr(virConnect) conn = NULL;
+    g_autoptr(virIdentity) ident = NULL;
 
     VIR_DEBUG("Shutting down vm=%p name=%s id=%d pid=%lld, "
               "reason=%s, asyncJob=%s, flags=0x%x",
@@ -7901,6 +7902,9 @@ void qemuProcessStop(virQEMUDriver *driver,
      * reporting so we don't squash a legit error. */
     virErrorPreserveLast(&orig_err);
 
+    ident = virIdentityGetSystem();
+    virIdentitySetCurrent(ident);
+
     if (asyncJob != QEMU_ASYNC_JOB_NONE) {
         if (qemuDomainObjBeginNestedJob(driver, vm, asyncJob) < 0)
             goto cleanup;
-- 
2.32.0




More information about the libvir-list mailing list