From nobody Fri Dec 19 22:07:52 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1742232595; cv=none; d=zohomail.com; s=zohoarc; b=lJtcP4BZ+GePgm2fzIj1XFRHoo5FwePaGYCXGmZwgiAcaJ11EBkXr9dIzYbVMlop4EvC1frX4xXWzi2u9bwZAHNG1Yg0oN2TB4Y7QM608VUB+duDALkDwG82n7zlOoV0XnF0DAVTbX30JXpUiYm2lMfRPyuXJMXcsWYJejPqcDs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742232595; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=5vFQ+EsN4W53LGD+pnN0sucP+muEIop6/zQgPB6SCJ0=; b=im8zOOlxcvejRuXhBlRNzKMDRhZwWsX+AoyNAEx8gckMSFwRS8anPz6ucoFZz9f0U4GzBGPNomobx+49x+dhT9jrA75Do61xVQfl5XVwV7BbkRvbxMGzsFPJef7gvHsfuQDyYzDZKENFaF6JWW5sVP0RQhcLtliGvBR4y1tTwoE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1742232595312993.670809161358; Mon, 17 Mar 2025 10:29:55 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B33A122C8; Mon, 17 Mar 2025 13:29:54 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 1536922AE; Mon, 17 Mar 2025 13:28:02 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id C21DD22A8; Mon, 17 Mar 2025 13:27:57 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 4F222238C for ; Mon, 17 Mar 2025 13:27:45 -0400 (EDT) Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-325-b0sR1rihNXSXjc3h1PjLKw-1; Mon, 17 Mar 2025 13:27:43 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8A7461955DC5 for ; Mon, 17 Mar 2025 17:27:42 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.6]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 77ACB180174E for ; Mon, 17 Mar 2025 17:27:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742232465; h=from:from: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; bh=2uGIMVYmiJY77JVHE3K+WCetUTpji0M+ydjPY3rgnY4=; b=NzQQDyeyY8TID15wvHzsHAobT/12B+JRZXfqUnD0CVbb1GyAvkCK15Kxrov3kfcYrbuA8W Ue2uan6aRPT52QfwqUd0HHvdeheIe5Ji/3bkaNxPPgAtbiBzLdokzuHD0b/Vss9UQFt+Ad b2FB5LNvCs2Lj9nouEyNxfL9721PQiI= X-MC-Unique: b0sR1rihNXSXjc3h1PjLKw-1 X-Mimecast-MFC-AGG-ID: b0sR1rihNXSXjc3h1PjLKw_1742232462 To: devel@lists.libvirt.org Subject: [PATCH 5/5] qemuHotplugRemoveManagedPR: Integrate check whether removal is needed Date: Mon, 17 Mar 2025 18:27:32 +0100 Message-ID: <182950ffb083f3c3070385a916e7db2f0985f6bd.1742232359.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: rL3HfoMbY4DOEzJukQmp-WUwJZ51Jp5YTI1lVEm-K3w_1742232462 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: KKKDLAHJALLBPMAG5Q3EQL4RY5FY32AY X-Message-ID-Hash: KKKDLAHJALLBPMAG5Q3EQL4RY5FY32AY X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1742232600451019000 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Calls to 'qemuHotplugRemoveManagedPR' needed to be guarded by a check if the removed elements actually caused us to add the manager in the first place. The two new calls added in commit 1697323bfe6000c2f5a2519c06f0ba81 were not guarded by such check and thus would spam the debug log with: [{"id": "libvirt-59", "error": {"class": "GenericError", "desc": "object = 'pr-helper0' not found"}}] Luckily 'qemuHotplugRemoveManagedPR' didn't request the error to be reported as a proper error. Don't attempt the removal unless needed. Fixes: 1697323bfe6000c2f5a2519c06f0ba81f7b792eb Signed-off-by: Peter Krempa --- src/qemu/qemu_blockjob.c | 2 +- src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_hotplug.c | 18 +++++++++--------- src/qemu/qemu_hotplug.h | 1 + 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index c1b29f2fde..c7462e2838 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -709,7 +709,7 @@ qemuBlockJobEventProcessConcludedRemoveChain(virQEMUDri= ver *driver, qemuDomainStorageSourceChainAccessRevoke(driver, vm, chain); - qemuHotplugRemoveManagedPR(vm, asyncJob); + qemuHotplugRemoveManagedPR(vm, chain, asyncJob); } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 37cd3a8b7b..4594a201c0 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14396,7 +14396,7 @@ qemuDomainBlockCopyCommon(virDomainObj *vm, if (need_revoke) qemuDomainStorageSourceChainAccessRevoke(driver, vm, mirror); - qemuHotplugRemoveManagedPR(vm, VIR_ASYNC_JOB_NONE); + qemuHotplugRemoveManagedPR(vm, mirror, VIR_ASYNC_JOB_NONE); } if (need_unlink && virStorageSourceUnlink(mirror) < 0) VIR_WARN("%s", _("unable to remove just-created copy target")); diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index d6de9afccd..db0d888194 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -462,8 +462,8 @@ qemuHotplugAttachManagedPR(virDomainObj *vm, /** * qemuHotplugRemoveManagedPR: - * @driver: QEMU driver object * @vm: domain object + * @src: storage source that is being removed * @asyncJob: asynchronous job identifier * * Removes the managed PR object from @vm if the configuration does not re= quire @@ -471,11 +471,15 @@ qemuHotplugAttachManagedPR(virDomainObj *vm, */ void qemuHotplugRemoveManagedPR(virDomainObj *vm, + virStorageSource *src, virDomainAsyncJob asyncJob) { qemuDomainObjPrivate *priv =3D vm->privateData; virErrorPtr orig_err; + if (!virStorageSourceChainHasManagedPR(src)) + return; + if (qemuDomainDefHasManagedPR(vm)) return; @@ -647,8 +651,7 @@ qemuDomainChangeEjectableMedia(virQEMUDriver *driver, ignore_value(qemuDomainStorageSourceChainAccessRevoke(driver, vm, olds= rc)); - if (virStorageSourceChainHasManagedPR(oldsrc)) - qemuHotplugRemoveManagedPR(vm, VIR_ASYNC_JOB_NONE); + qemuHotplugRemoveManagedPR(vm, oldsrc, VIR_ASYNC_JOB_NONE); /* media was changed, so we can remove the old media definition now */ g_clear_pointer(&oldsrc, virObjectUnref); @@ -657,8 +660,7 @@ qemuDomainChangeEjectableMedia(virQEMUDriver *driver, rollback: ignore_value(qemuDomainStorageSourceChainAccessRevoke(driver, vm, news= rc)); - if (virStorageSourceChainHasManagedPR(newsrc)) - qemuHotplugRemoveManagedPR(vm, VIR_ASYNC_JOB_NONE); + qemuHotplugRemoveManagedPR(vm, newsrc, VIR_ASYNC_JOB_NONE); /* revert old image do the disk definition */ disk->src =3D oldsrc; @@ -1089,8 +1091,7 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver = *driver, if (releaseSeclabel) ignore_value(qemuDomainStorageSourceChainAccessRevoke(driver, = vm, disk->src)); - if (virStorageSourceChainHasManagedPR(disk->src)) - qemuHotplugRemoveManagedPR(vm, VIR_ASYNC_JOB_NONE); + qemuHotplugRemoveManagedPR(vm, disk->src, VIR_ASYNC_JOB_NONE); } qemuDomainSecretDiskDestroy(disk); qemuDomainCleanupStorageSourceFD(disk->src); @@ -4730,8 +4731,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriver *driver, if (diskBackend) qemuDomainStorageSourceChainAccessRevoke(driver, vm, disk->src); - if (virStorageSourceChainHasManagedPR(disk->src)) - qemuHotplugRemoveManagedPR(vm, VIR_ASYNC_JOB_NONE); + qemuHotplugRemoveManagedPR(vm, disk->src, VIR_ASYNC_JOB_NONE); qemuNbdkitStopStorageSource(disk->src, vm, true); diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h index 6a94dbd0cb..d3c0b45a5f 100644 --- a/src/qemu/qemu_hotplug.h +++ b/src/qemu/qemu_hotplug.h @@ -132,4 +132,5 @@ qemuHotplugAttachManagedPR(virDomainObj *vm, virDomainAsyncJob asyncJob); void qemuHotplugRemoveManagedPR(virDomainObj *vm, + virStorageSource *src, virDomainAsyncJob asyncJob); --=20 2.48.1