From nobody Mon Apr 29 15:41:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1635243449; cv=none; d=zohomail.com; s=zohoarc; b=JyBvlEjPLdHTLZcZ4GkSN61n9lReioIfQ2IB0Ef41smT6XkeLcpaCyV304+YAn/5CZXxdRfTsN++PhAfCJVVWAXMwVdmMH2ghveczZBlQteoMT0w+lzAq0Irs8GIOnhVY/dmk/AoD7ugHtEC+O2hPZQYAYZFaP9cNYtZBrt6GOQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635243449; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vXngTMeBW2HjcmIZCIGOxQPNZ+5xb1axHbjM8GI6QKc=; b=QLGB/E91FbD2EnSqDCYT2b2fjyMpjntnEmt6e+fVzC8ilfXx5NN8BXG+7xOqB3o4/X9sjpEq0dtB6T3yFcanT3SshbznhS2ERuWfA1FlSJvxcvYU+uGZd2r8UHiZWAOf6w8T0BACWLZA+WsyMXYrnKRSSX2T2RzjuVE12lW6RlE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1635243449070236.28996949249188; Tue, 26 Oct 2021 03:17:29 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-213-iHmbFIQFNYqkA_NcaeFdgw-1; Tue, 26 Oct 2021 06:17:26 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3CCBE8066F4; Tue, 26 Oct 2021 10:17:21 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D0D1E57CA4; Tue, 26 Oct 2021 10:17:20 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 810FE4EA2A; Tue, 26 Oct 2021 10:17:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19QAHHHJ008329 for ; Tue, 26 Oct 2021 06:17:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6B1E85C1CF; Tue, 26 Oct 2021 10:17:17 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id E6E1D2C6ED for ; Tue, 26 Oct 2021 10:17:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635243448; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=vXngTMeBW2HjcmIZCIGOxQPNZ+5xb1axHbjM8GI6QKc=; b=F4BQr0KwkU0WF49C+H3Okb9EsQ5jv21fD3hmF7tQ9cdHxfE4IC9Rgoz0zWFM0HY1OD65qo CP90SlXHE1IUI5XQN6Cb3giG5Jf1LYxoVS+ZU8OEStOM9CuFE+o1eKJN+suvNwnL3vRfYe SdwuBwStuerGQYTQdvKlRL0xJJyeT1Y= X-MC-Unique: iHmbFIQFNYqkA_NcaeFdgw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/3] virthreadpool: Allow setting identity for workers Date: Tue, 26 Oct 2021 12:17:06 +0200 Message-Id: <9835e19e43eaf60472d962dce0b3bfd112f7b9b1.1635243314.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1635243450645100001 Content-Type: text/plain; charset="utf-8" In some cases the worker func running inside the pool may rely on virIdentity. While worker func could check for identity and set one it is not optimal - it may not have access to the identity of the thread creating the pool and thus would have to call virIdentityGetSystem(). Allow passing identity when creating the pool. Signed-off-by: Michal Privoznik --- src/nwfilter/nwfilter_dhcpsnoop.c | 1 + src/qemu/qemu_driver.c | 4 +++- src/rpc/virnetserver.c | 1 + src/util/virthreadpool.c | 12 ++++++++++++ src/util/virthreadpool.h | 12 +++++++----- 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcp= snoop.c index 4b62a7b661..b0297f0741 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -1333,6 +1333,7 @@ virNWFilterDHCPSnoopThread(void *req0) worker =3D virThreadPoolNewFull(1, 1, 0, virNWFilterDHCPDecodeWorker, "dhcp-decode", + NULL, req); } =20 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6997dc7dea..a8bf0ecc6f 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -914,7 +914,9 @@ qemuStateInitialize(bool privileged, * running domains since there might occur some QEMU monitor * events that will be dispatched to the worker pool */ qemu_driver->workerPool =3D virThreadPoolNewFull(0, 1, 0, qemuProcessE= ventHandler, - "qemu-event", qemu_driv= er); + "qemu-event", + NULL, + qemu_driver); if (!qemu_driver->workerPool) goto error; =20 diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c index dc8f32b095..c7b4939398 100644 --- a/src/rpc/virnetserver.c +++ b/src/rpc/virnetserver.c @@ -378,6 +378,7 @@ virNetServer *virNetServerNew(const char *name, priority_workers, virNetServerHandleJob, "rpc-worker", + NULL, srv))) goto error; =20 diff --git a/src/util/virthreadpool.c b/src/util/virthreadpool.c index 92b7cac286..7bf4333885 100644 --- a/src/util/virthreadpool.c +++ b/src/util/virthreadpool.c @@ -55,6 +55,8 @@ struct _virThreadPool { virThreadPoolJobList jobList; size_t jobQueueDepth; =20 + virIdentity *identity; + virMutex mutex; virCond cond; virCond quit_cond; @@ -99,6 +101,9 @@ static void virThreadPoolWorker(void *opaque) =20 virMutexLock(&pool->mutex); =20 + if (pool->identity) + virIdentitySetCurrent(pool->identity); + while (1) { /* In order to support async worker termination, we need ensure th= at * both busy and free workers know if they need to terminated. Thu= s, @@ -219,6 +224,7 @@ virThreadPoolNewFull(size_t minWorkers, size_t prioWorkers, virThreadPoolJobFunc func, const char *name, + virIdentity *identity, void *opaque) { virThreadPool *pool; @@ -234,6 +240,9 @@ virThreadPoolNewFull(size_t minWorkers, pool->jobName =3D name; pool->jobOpaque =3D opaque; =20 + if (identity) + pool->identity =3D g_object_ref(identity); + if (virMutexInit(&pool->mutex) < 0) goto error; if (virCondInit(&pool->cond) < 0) @@ -300,6 +309,9 @@ void virThreadPoolFree(virThreadPool *pool) virMutexLock(&pool->mutex); virThreadPoolDrainLocked(pool); =20 + if (pool->identity) + g_object_unref(pool->identity); + g_free(pool->workers); virMutexUnlock(&pool->mutex); virMutexDestroy(&pool->mutex); diff --git a/src/util/virthreadpool.h b/src/util/virthreadpool.h index 619d128e9a..c6b9f31916 100644 --- a/src/util/virthreadpool.h +++ b/src/util/virthreadpool.h @@ -22,17 +22,19 @@ #pragma once =20 #include "internal.h" +#include "viridentity.h" =20 typedef struct _virThreadPool virThreadPool; =20 typedef void (*virThreadPoolJobFunc)(void *jobdata, void *opaque); =20 virThreadPool *virThreadPoolNewFull(size_t minWorkers, - size_t maxWorkers, - size_t prioWorkers, - virThreadPoolJobFunc func, - const char *name, - void *opaque) ATTRIBUTE_NONNULL(4); + size_t maxWorkers, + size_t prioWorkers, + virThreadPoolJobFunc func, + const char *name, + virIdentity *identity, + void *opaque) ATTRIBUTE_NONNULL(4); =20 size_t virThreadPoolGetMinWorkers(virThreadPool *pool); size_t virThreadPoolGetMaxWorkers(virThreadPool *pool); --=20 2.32.0 From nobody Mon Apr 29 15:41:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1635243462; cv=none; d=zohomail.com; s=zohoarc; b=SWzGZKkQLRa3FGhcy+YHaD3TLzxsn91IQXjOWj5EUvPg5ZyTKhAWZ9qx81d/gJSCOJwC4c8R3W2F9i7dwCfBZhunlfl/v4cRLcO0xOGQgz1X+JLFVipaiu9JBGJQvXNSVsrabDaIcE/RI15V0SbgzgOewTef7Y+CvE+Irzb9x/U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635243462; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yXitFVFwMPI1hn1PUNWwuJqpY4ULDdENDYJDnq7IR3E=; b=nUMw2UWh2VAtwKQszga4IbRp7G8BRF5/CruIrP4ksonc4u8ZdRG+BLHzP3zXuzNkjjtsyC/IiCJNsUKa1U4unWUJdFIrspgrMfbu1ylgUsCCkJT8J910+NGOnhl6lUYBEB9m1w3vaBJYzsaw4nDI9EEHh+V2YEhtvKkGa8BGQf8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1635243462642698.8159890457727; Tue, 26 Oct 2021 03:17:42 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-81-Dxb6svF3MJWBeSCKhDm1lA-1; Tue, 26 Oct 2021 06:17:39 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E9AF7101B4A0; Tue, 26 Oct 2021 10:17:34 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CD1336FEED; Tue, 26 Oct 2021 10:17:34 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9C8174EA31; Tue, 26 Oct 2021 10:17:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19QAHIr0008334 for ; Tue, 26 Oct 2021 06:17:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3CCAB171FF; Tue, 26 Oct 2021 10:17:18 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id B8BFB5C1CF for ; Tue, 26 Oct 2021 10:17:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635243461; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=yXitFVFwMPI1hn1PUNWwuJqpY4ULDdENDYJDnq7IR3E=; b=UYAHgUcvvO4Dw89MGAdOpF6PH5kNjB/zWh2wK3kWMu7uDThrSNVeLBX/UD4GAJBCg0F3Gi Ka8Oory1k9h4BTlGoijoDM3HpIxxBYb5GC91PxGSkD0f83CKdzqDykOZHkj83nTayE586l nd3T08GoT5Yk8h+ETPx0lxvm9nFVSWE= X-MC-Unique: Dxb6svF3MJWBeSCKhDm1lA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/3] qemu: Set "qemu-event" thread identity Date: Tue, 26 Oct 2021 12:17:07 +0200 Message-Id: <82ecb3204297517a8a4a00c5c747730a8ae8297d.1635243314.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1635243463848100001 Content-Type: text/plain; charset="utf-8" It may happen that qemuProcessStop() is called from "qemu-event" thread. But this thread doesn't have any virIdentity set (virIdentity being thread local) and therefore it may be unable to open connection to secondary drivers. It is unable to do so in split daemon scenario, because in there opening a connection is coupled with copying current thread identity onto the connection. Code-wise, virIdentityGetCurrent() returns NULL which in turn makes virGetConnectGeneric() fail. This problem does not occur in monolithic daemon scenario, because no identity copying is done there. Long story short, inability to open secondary driver connection can lead to unwanted results. Therefore, do what qemuProcessReconnectHelper() does - set the new thread identity to be the one of the caller. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D2013573 Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_driver.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a8bf0ecc6f..70b5f37e6b 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -571,6 +571,7 @@ qemuStateInitialize(bool privileged, size_t i; const char *defsecmodel =3D NULL; g_autofree virSecurityManager **sec_managers =3D NULL; + g_autoptr(virIdentity) identity =3D virIdentityGetCurrent(); =20 qemu_driver =3D g_new0(virQEMUDriver, 1); =20 @@ -915,7 +916,7 @@ qemuStateInitialize(bool privileged, * events that will be dispatched to the worker pool */ qemu_driver->workerPool =3D virThreadPoolNewFull(0, 1, 0, qemuProcessE= ventHandler, "qemu-event", - NULL, + identity, qemu_driver); if (!qemu_driver->workerPool) goto error; --=20 2.32.0 From nobody Mon Apr 29 15:41:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1635243466; cv=none; d=zohomail.com; s=zohoarc; b=HPUlLTxqxsCYf18MJucYwu9bjrPAXxnTmbTfgnVWXH1D/9RU2NcvgIl3goktMpX6rbYrvmceA484otPtpq3FotiJ3hGxWYqj5wWQtsg3ZrfX4N/vUt6Ep8dYp7LUOXbEzNVGlpbpSVPSYsro3354rG992rYHgg8ivMH0p/Ac7fs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635243466; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zind/yUgkR9PN7oyE+F2CjTWfb1JpYR+dPTbQfsbPrg=; b=C1Fh54F2Pvq2xzX18PAe+50yLfkClzSvCaAYQLia4uP35S/bEG9b8zKBy1jtl+v6kWN7Q7WyKzMAp9fb9OLOznPVwUnnuk1cd9l3deZMdGBESK7OdZFCXNrgluP2fJEFGnFKwE1xGdTVuwzU2M1eeJAY9FARU81Q0EsTiiVoMz8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1635243466424279.912043425315; Tue, 26 Oct 2021 03:17:46 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-192-UXFdLzgzN16FYPKnmfdb5w-1; Tue, 26 Oct 2021 06:17:43 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 34499101B4A5; Tue, 26 Oct 2021 10:17:38 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 14A9C5DD68; Tue, 26 Oct 2021 10:17:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D53811818480; Tue, 26 Oct 2021 10:17:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19QAHMGO008351 for ; Tue, 26 Oct 2021 06:17:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8AACF171FF; Tue, 26 Oct 2021 10:17:22 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1220D5C1CF for ; Tue, 26 Oct 2021 10:17:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635243465; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=zind/yUgkR9PN7oyE+F2CjTWfb1JpYR+dPTbQfsbPrg=; b=CLq181wPFfihEbOHNdlNVL3alTKxivnHusevS9KZSPQ29Q2Obd9xAMPPaF2NmeK0jbGtdR Yul8Hs1thPeVR7uxISjbQsjrx7yZjSn21rGcGMsJwRkb5g951jisFHKRONPJ2tLPiivE4v RsKaMhvymlPwS2fbS6Lqz0dbSmie9Qc= X-MC-Unique: UXFdLzgzN16FYPKnmfdb5w-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/3] *** DO NOT MERGE *** Date: Tue, 26 Oct 2021 12:17:08 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1635243468098100001 Content-Type: text/plain; charset="utf-8" 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=3D2013573 Signed-off-by: Michal Privoznik --- 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 =3D NULL; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); g_autoptr(virConnect) conn =3D NULL; + g_autoptr(virIdentity) ident =3D NULL; =20 VIR_DEBUG("Shutting down vm=3D%p name=3D%s id=3D%d pid=3D%lld, " "reason=3D%s, asyncJob=3D%s, flags=3D0x%x", @@ -7901,6 +7902,9 @@ void qemuProcessStop(virQEMUDriver *driver, * reporting so we don't squash a legit error. */ virErrorPreserveLast(&orig_err); =20 + ident =3D virIdentityGetSystem(); + virIdentitySetCurrent(ident); + if (asyncJob !=3D QEMU_ASYNC_JOB_NONE) { if (qemuDomainObjBeginNestedJob(driver, vm, asyncJob) < 0) goto cleanup; --=20 2.32.0