From nobody Mon Apr 29 18:26:39 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=1635493241; cv=none; d=zohomail.com; s=zohoarc; b=OL+XU+jSzl5WG+nYJfrwWBgOAmSHkeT2b5Gumit7bVmWHfOyKQcE+I8aZ/eITS+ZS867NNjY+vhPqhZN9Q3gbr6UBGkAm142iJ5QaRNpqGudGfsQum5kP6oPZpT4EuBcr9e0kUkZ5p8k6S231Ne16psubD5562l2pWU+mWlEX54= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635493241; 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=ArPUouMv6ut1wI6OQGbWAxSp0xbFf0jYXCsx3xJoDuI=; b=RtN+CYDGI5E41Ga0v95E5Aot1L4SJNhJkOUstU6vEI+SmvenxB9BS2k5q5ttG4dudDjJl363oA2gRiMJqd9uCli+TsUSUQq4MRxuifqCNnf/Sb0ZSKtSHm7gbY5oXzxxH1uqGOfxJoMMC7t0HJzwLM0UtkYk94xCOXrDuq2JT58= 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 1635493241475889.3018973269891; Fri, 29 Oct 2021 00:40:41 -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-476-MtBuQ8WYN0Ka5Hg0RIrHig-1; Fri, 29 Oct 2021 03:40:38 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 83BF610A8E07; Fri, 29 Oct 2021 07:40:33 +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 5FDAE60BF1; Fri, 29 Oct 2021 07:40:33 +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 EE1FB1806D04; Fri, 29 Oct 2021 07:40:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19T7eUX7011000 for ; Fri, 29 Oct 2021 03:40:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9A171652AC; Fri, 29 Oct 2021 07:40:30 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id EBFE51981F for ; Fri, 29 Oct 2021 07:40:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635493240; 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=ArPUouMv6ut1wI6OQGbWAxSp0xbFf0jYXCsx3xJoDuI=; b=EraV1LvpELhzhS6G4p/hF6CxaVXOhgsGZZ/AxgHbfuufLlOAGOg7c8te66dz8pMA1K7SKJ 5Xf7XwJYtJpt5alLIRb61lvXhlfcpOyFKJH/J6MoYtblH0xwPL0I6p4bPGTfCCdUhKnPiD LCrnjsii4wbi+z/WOL8WaYLPlz/aQVI= X-MC-Unique: MtBuQ8WYN0Ka5Hg0RIrHig-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/4] qemu_agent: Rework domain object locking when opening agent Date: Fri, 29 Oct 2021 09:40:20 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.12 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: 1635493242286100003 Content-Type: text/plain; charset="utf-8" Just like qemuMonitorOpen(), hold the domain object locked throughout the whole time of qemuConnectAgent() and unlock it only for a brief time of actual connect() (because this is the only part that has a potential of blocking). The reason is that qemuAgentOpen() does access domain object (well, its privateData) AND also at least one argument (@context) depends on domain object. Accessing these without the lock is potentially dangerous. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1845468#c12 Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_agent.c | 3 +++ src/qemu/qemu_process.c | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 5f421be6f6..166cfaf485 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -704,7 +704,10 @@ qemuAgentOpen(virDomainObj *vm, goto cleanup; } =20 + virObjectUnlock(vm); agent->fd =3D qemuAgentOpenUnix(config->data.nix.path); + virObjectLock(vm); + if (agent->fd =3D=3D -1) goto cleanup; =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index d5f8a47ac2..d2ea9b55fe 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -238,16 +238,12 @@ qemuConnectAgent(virQEMUDriver *driver, virDomainObj = *vm) * deleted while the agent is active */ virObjectRef(vm); =20 - virObjectUnlock(vm); - agent =3D qemuAgentOpen(vm, config->source, virEventThreadGetContext(priv->eventThread), &agentCallbacks, virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VSERPOR= T_CHANGE)); =20 - virObjectLock(vm); - if (agent =3D=3D NULL) virObjectUnref(vm); =20 --=20 2.32.0 From nobody Mon Apr 29 18:26:39 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=1635493246; cv=none; d=zohomail.com; s=zohoarc; b=DaVPMcWyYKG2A345l004cm0iS/cHBsOTptisZF/uaA/3ZMfS/qD3cL0vWrFoNZ7k9GAAOK8+NI9A86J7SwtEe6DOSgg2emr14iR2lBcjccH3oOQUGlY2O8yXsel0GzmuMhzFknPacT7BFAGM6Fdjlf74yAVDrJMo/+VJPACsgfc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635493246; 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=TPoRYGidHZFiCQvWUhP45vF1N8pM9Ny2jYCUeUPWzCs=; b=A7HIvY4gpltQQ6WDI1Y4wLbIcl4V2Sm+eTEhmdHjiHMNJQsiw4WoHim0rDoII+4k8tUcI/7Se10kiUHXHCIXK1pu7K4rWK4iR8gJoFY4lAHLblbB6h7DMUGJWrYZZ+592dobrIjnCBlVaUyMa8xOMdLoW1PuTKjOKUNENz7TPV0= 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 1635493246268509.9108957284792; Fri, 29 Oct 2021 00:40: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-51-lcW3dVKNOsyDnkZca2VtfA-1; Fri, 29 Oct 2021 03:40:41 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A812210A8E05; Fri, 29 Oct 2021 07:40:36 +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 7F4D226E73; Fri, 29 Oct 2021 07:40:36 +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 4F50A181A1CF; Fri, 29 Oct 2021 07:40:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19T7eWqr011015 for ; Fri, 29 Oct 2021 03:40:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id D3C181981F; Fri, 29 Oct 2021 07:40:31 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id E7AED6911D for ; Fri, 29 Oct 2021 07:40:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635493245; 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=TPoRYGidHZFiCQvWUhP45vF1N8pM9Ny2jYCUeUPWzCs=; b=aEVkGAthb6HgYEDzi5BhEh+Gj1Lz9iGoqihHhH8b2UHhpMffuCBq8x2wI2Nk+YZbE8a0pu 0V4hqTSNAfWX3FNoenGZ08USGYSLTLoSjpghd5JpQEoKavHD+kviL5JB0YV21RuAgTCebD fORZLSXK6KmRw4IHf/6nZhrA6ixbxxM= X-MC-Unique: lcW3dVKNOsyDnkZca2VtfA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/4] qemuAgentOpen: Rework domain object refcounting Date: Fri, 29 Oct 2021 09:40:21 +0200 Message-Id: <62fc385c9661892d9090ea2c9b56c2984427fae4.1635493104.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.84 on 10.5.11.23 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: 1635493246483100001 Content-Type: text/plain; charset="utf-8" Currently, when opening an agent socket the qemuConnectAgent() increments domain object refcounter and calls qemuAgentOpen() where the domain object pointer is simply stored inside _qemuAgent struct. If qemuAgentOpen() fails, then it clears @cb member only to avoid qemuProcessHandleAgentDestroy() being called (which decrements the domain object refcounter) and the domain object refcounter is then decreased explicitly in qemuConnectAgent(). The same result can be achieved with much cleaner code: increment the refcounter inside qemuAgentOpen() and drop the dance around @cb. Also, the comment in qemuConnectAgent() about holding an extra reference is not correct. The thread that called qemuConnectAgent() already holds a reference to the domain object. No matter how many time the object is locked and unlocked the reference counter can't be decreased. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_agent.c | 14 +++++--------- src/qemu/qemu_process.c | 7 ------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 166cfaf485..8bbaa127d4 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -171,9 +171,11 @@ qemuAgentEscapeNonPrintable(const char *text) static void qemuAgentDispose(void *obj) { qemuAgent *agent =3D obj; + VIR_DEBUG("agent=3D%p", agent); - if (agent->cb && agent->cb->destroy) - (agent->cb->destroy)(agent, agent->vm); + + if (agent->vm) + virObjectUnref(agent->vm); virCondDestroy(&agent->notify); g_free(agent->buffer); g_main_context_unref(agent->context); @@ -693,7 +695,7 @@ qemuAgentOpen(virDomainObj *vm, virObjectUnref(agent); return NULL; } - agent->vm =3D vm; + agent->vm =3D virObjectRef(vm); agent->cb =3D cb; agent->singleSync =3D singleSync; =20 @@ -729,12 +731,6 @@ qemuAgentOpen(virDomainObj *vm, return agent; =20 cleanup: - /* We don't want the 'destroy' callback invoked during - * cleanup from construction failure, because that can - * give a double-unref on virDomainObj *in the caller, - * so kill the callbacks now. - */ - agent->cb =3D NULL; qemuAgentClose(agent); return NULL; } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index d2ea9b55fe..b1fd72d269 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -234,19 +234,12 @@ qemuConnectAgent(virQEMUDriver *driver, virDomainObj = *vm) goto cleanup; } =20 - /* Hold an extra reference because we can't allow 'vm' to be - * deleted while the agent is active */ - virObjectRef(vm); - agent =3D qemuAgentOpen(vm, config->source, virEventThreadGetContext(priv->eventThread), &agentCallbacks, virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VSERPOR= T_CHANGE)); =20 - if (agent =3D=3D NULL) - virObjectUnref(vm); - if (!virDomainObjIsActive(vm)) { qemuAgentClose(agent); virReportError(VIR_ERR_INTERNAL_ERROR, "%s", --=20 2.32.0 From nobody Mon Apr 29 18:26:39 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=1635493249; cv=none; d=zohomail.com; s=zohoarc; b=fi0ZhZ8fMH/hUfC0SBL0FYZHhcT08INCxaLTqvNcYkF6kghDIYPzixv2/bickJ629UIvLJdDwzjbzSi1rlk1MYA+wP4NEtPUYppEKLkucmreqNBVawW/ofG+8+zwhpH9k2xSJgQcdaESJ4MxwP8Bbimpc5zeqog4i/zV/IjhToE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635493249; 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=FoVghXVkm8/Ag8OM8vyMgGLJpsmnraSzV5TMK6LatEE=; b=gtg1+cSweFviOPlr4T3fGUeo8OQ8mv2FxhzHDiYXWm8/nOvTML3drvfI9NC7IpWXX+rzzgr3E0G+x9uJw7CFIk0LveY3PhoiluNVkhON5DqNbCa2eWY9sAyLXeYBMly9mskWnqSs4E81pG4ZPzDy3TqVlnrMD6XL6K9MMKlsMAk= 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 1635493249452211.4848255316989; Fri, 29 Oct 2021 00:40:49 -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-262-4ivgzqFmOWaPGPgmjNbExA-1; Fri, 29 Oct 2021 03:40:44 -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 E6FF8802B61; Fri, 29 Oct 2021 07:40:39 +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 C80905DF5F; Fri, 29 Oct 2021 07:40:39 +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 957D74E58E; Fri, 29 Oct 2021 07:40:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19T7eXZA011028 for ; Fri, 29 Oct 2021 03:40:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id 650C26911C; Fri, 29 Oct 2021 07:40:33 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2C35E1981F for ; Fri, 29 Oct 2021 07:40:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635493248; 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=FoVghXVkm8/Ag8OM8vyMgGLJpsmnraSzV5TMK6LatEE=; b=da3SCnlf1RlOxtJPJl+dC/MdfF7eErVO0l3R1rc1oVQZws9iH5HX2X29G10bUUr9E/VS5h d2WUMDodthD4xcmCn1QV+hGJ0lDbJK071Qx0ywz0X7L8Elgd/vcRETYPp+sKPdl2doHIFm 9KwXlkoXb9Z+njhBs/VPVsMF77DcF+s= X-MC-Unique: 4ivgzqFmOWaPGPgmjNbExA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/4] qemu_agent: Drop destroy callback Date: Fri, 29 Oct 2021 09:40:22 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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: 1635493250689100001 Content-Type: text/plain; charset="utf-8" After previous cleanups this callback is unused. Remove it. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_agent.h | 2 -- src/qemu/qemu_process.c | 9 --------- 2 files changed, 11 deletions(-) diff --git a/src/qemu/qemu_agent.h b/src/qemu/qemu_agent.h index 81b45b8e5d..b5954e76e7 100644 --- a/src/qemu/qemu_agent.h +++ b/src/qemu/qemu_agent.h @@ -28,8 +28,6 @@ typedef struct _qemuAgent qemuAgent; =20 typedef struct _qemuAgentCallbacks qemuAgentCallbacks; struct _qemuAgentCallbacks { - void (*destroy)(qemuAgent *mon, - virDomainObj *vm); void (*eofNotify)(qemuAgent *mon, virDomainObj *vm); void (*errorNotify)(qemuAgent *mon, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index b1fd72d269..ba9e9a5aa0 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -193,17 +193,8 @@ qemuProcessHandleAgentError(qemuAgent *agent G_GNUC_UN= USED, virObjectUnlock(vm); } =20 -static void qemuProcessHandleAgentDestroy(qemuAgent *agent, - virDomainObj *vm) -{ - VIR_DEBUG("Received destroy agent=3D%p vm=3D%p", agent, vm); - - virObjectUnref(vm); -} - =20 static qemuAgentCallbacks agentCallbacks =3D { - .destroy =3D qemuProcessHandleAgentDestroy, .eofNotify =3D qemuProcessHandleAgentEOF, .errorNotify =3D qemuProcessHandleAgentError, }; --=20 2.32.0 From nobody Mon Apr 29 18:26:39 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=1635493264; cv=none; d=zohomail.com; s=zohoarc; b=e8qvMBhPlKZ1J5AzSpf6w0CcIuMP7ipVvy034DaQ5YPOI3YlkK0rB+8hrQcrJYotaNPiRB5N5HSaYGYMO9y0ABB/S4eUdnGgArE/SZt0AhaH2msDjxxCtWM1x9+ccKMHU+rEhtyjCKWMfK3C9GJ5srJvHttMokpFa93b4BPgvfQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635493264; 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=yWeEBH9b0KXaFblgDyKfmA47Jg1IDqQAdxgJyE2Fags=; b=DiX4cwDGLMtfUf8A2cQ7fdzUzu4njPetBJQbpNr8HBgBFAd3XM1W4XJwpw2OCOiElqSSeMULdngXnUfg4aPI7VKCGiAAbfC2ovGf7m9C21OqalQyRaSrsFwCdWwAb8n3zdHZjrYtzVT+DzH0sxHmC+KgVnCgAkWI8ZVT3hjx6yI= 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 1635493264213524.6362280055129; Fri, 29 Oct 2021 00:41:04 -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-471-WkOP91AnNsmS-D7lLXyzUA-1; Fri, 29 Oct 2021 03:40:42 -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 4724118125C2; Fri, 29 Oct 2021 07:40:37 +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 2C5C61981F; Fri, 29 Oct 2021 07:40:37 +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 DB29F181A1D1; Fri, 29 Oct 2021 07:40:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19T7eYop011035 for ; Fri, 29 Oct 2021 03:40:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 937D71981F; Fri, 29 Oct 2021 07:40:34 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id B2ABE652AC for ; Fri, 29 Oct 2021 07:40:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635493263; 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=yWeEBH9b0KXaFblgDyKfmA47Jg1IDqQAdxgJyE2Fags=; b=ZJBrAwXMmp8kPl+jBJ98WpLtjfSSt2bcwh1uSMEBcM8tq2taSywgF+3OB2k+9NjXpy9x/W l3R8/CDW8DE9qvCbhpl+N6iedwHKA+bN3MA/I3u021Qs3xtnKecgLUejOsETUt/OO2Gzfl o9INoZ8SDZ5rimELF9YfYrQgKxFyj3g= X-MC-Unique: WkOP91AnNsmS-D7lLXyzUA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/4] qemuMonitorOpen: Rework domain object refcounting Date: Fri, 29 Oct 2021 09:40:23 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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: 1635493265583100001 Content-Type: text/plain; charset="utf-8" Similarly to one of previous commits, there's no need to increment domain object refcounter before unlocking it. Any number of lock and unlock calls over domain object has no effect on the refcounter. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_monitor.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 908ee0d302..7559020001 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -769,10 +769,6 @@ qemuMonitorOpen(virDomainObj *vm, =20 timeout +=3D QEMU_DEFAULT_MONITOR_WAIT; =20 - /* Hold an extra reference because we can't allow 'vm' to be - * deleted until the monitor gets its own reference. */ - virObjectRef(vm); - if (config->type !=3D VIR_DOMAIN_CHR_TYPE_UNIX) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unable to handle monitor type: %s"), @@ -798,7 +794,6 @@ qemuMonitorOpen(virDomainObj *vm, cleanup: if (!ret) VIR_FORCE_CLOSE(fd); - virObjectUnref(vm); return ret; } =20 --=20 2.32.0