From nobody Mon Dec 15 14:42:38 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=1742232509; cv=none; d=zohomail.com; s=zohoarc; b=NAZa9B/AAN7n5DBEt8d8fXWmjK1klLyP49NwIZOmSx0eJhZyNGt3O36MzuRDUTGSFf8StVZWhqSMQuEnuWEGnZ3taePxktsKIebSYgl5u0VDVjWOi5K80CSErK7BuGuQG5OYYhViluaRS5rXTmvUgqkkJKT/rb1QrCTu2AgO4jM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742232509; 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=bD0/kb3gdnV7KybML3wwE3L8PibSwyVVWnPMxAKRHdk=; b=YpyrfMrmVylBYLqPyJXSeOUq0rsxczd0UraJfb3MXKwRCRXsInj5NqRsBp9EwhOzRglelZ8qmh8yIojYpGECnYh7x8zuZsNd3b3VvKnCtsRv7B0l7VurVA0bsLQx7k0DsmAVMM1LcmaKnQEyWh1ib3ms6fZklpB1rxjctTg4OIU= 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 1742232509758201.97850661761993; Mon, 17 Mar 2025 10:28:29 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 076822335; Mon, 17 Mar 2025 13:28:29 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 0819A229E; Mon, 17 Mar 2025 13:27:43 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 55AB1223C; Mon, 17 Mar 2025 13:27:40 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 C498C1C79 for ; Mon, 17 Mar 2025 13:27:39 -0400 (EDT) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-284-Ix6aYvjjNoGFScPsp-jVLA-1; Mon, 17 Mar 2025 13:27:37 -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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E169B1800258 for ; Mon, 17 Mar 2025 17:27:36 +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 E569118001F6 for ; Mon, 17 Mar 2025 17:27:35 +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_H2, 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=1742232459; 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=sQLF01iudQrE/fmjJJvIfMJFDE+IpE5y2rlF2TP4nT0=; b=FFcQcTZtQWDPc3Pb2jiHNqJlqi9OjLytytPeUQ3h60Wj9X72Q431UL2hAR5xqeDeh/Gwhv YW7LzlVwizii8jRKy6TeN/hR6filFLMN1VQS9JW00/6KFZf7dXkW/zqhk2w7tpWo4I3fq6 G2tU75oOrajSVCTg+TRHlu2snnT5Uc0= X-MC-Unique: Ix6aYvjjNoGFScPsp-jVLA-1 X-Mimecast-MFC-AGG-ID: Ix6aYvjjNoGFScPsp-jVLA_1742232457 To: devel@lists.libvirt.org Subject: [PATCH 1/5] qemu: monitor: Wire up 'replaces' attribute for 'blockdev-mirror' Date: Mon, 17 Mar 2025 18:27:28 +0100 Message-ID: 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: L9u-zBUiKOSVVp8-2VtAXP-KJ9cz1hGSsr8DGT67B9k_1742232457 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: QEWP5NDTOVF4V5ZIYBMKWQ5IM5JNJYI5 X-Message-ID-Hash: QEWP5NDTOVF4V5ZIYBMKWQ5IM5JNJYI5 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: 1742232512633019000 Content-Type: text/plain; charset="utf-8" From: Peter Krempa The 'replaces' field controls which node will be replaced by the job. This can be used to e.g. keep filter nodes in place after the copy finishes. This will be used to keep the 'copy-on-read' and 'throttle' layers in place after a copy. This patch wires up the monitor and test, but the real callers pass NULL for now. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/qemu/qemu_driver.c | 1 + src/qemu/qemu_migration.c | 1 + src/qemu/qemu_monitor.c | 9 +++++---- src/qemu/qemu_monitor.h | 1 + src/qemu/qemu_monitor_json.c | 2 ++ src/qemu/qemu_monitor_json.h | 1 + tests/qemumonitorjsontest.c | 2 +- 7 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f0e9681161..84564b0658 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14363,6 +14363,7 @@ qemuDomainBlockCopyCommon(virDomainObj *vm, ret =3D qemuMonitorBlockdevMirror(priv->mon, job->name, true, qemuDomainDiskGetTopNodename(disk), qemuBlockStorageSourceGetEffectiveNode= name(mirror), + NULL, bandwidth, granularity, buf_size, mirror_shallow, syncWrites); diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 02ba35dc59..75f5b0fa95 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1213,6 +1213,7 @@ qemuMigrationSrcNBDStorageCopyBlockdev(virDomainObj *= vm, mon_ret =3D qemuMonitorBlockdevMirror(qemuDomainGetMonitor(vm), di= skAlias, true, qemuDomainDiskGetTopNodename(d= isk), qemuBlockStorageSourceGetEffec= tiveNodename(copysrc), + NULL, mirror_speed, 0, 0, mirror_sha= llow, syncWrites); diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 8d8e73d38d..a903e4ac7d 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2784,20 +2784,21 @@ qemuMonitorBlockdevMirror(qemuMonitor *mon, bool persistjob, const char *device, const char *target, + const char *replaces, unsigned long long bandwidth, unsigned int granularity, unsigned long long buf_size, bool shallow, bool syncWrite) { - VIR_DEBUG("jobname=3D%s, persistjob=3D%d, device=3D%s, target=3D%s, ba= ndwidth=3D%lld, " + VIR_DEBUG("jobname=3D%s, persistjob=3D%d, device=3D%s, target=3D%s, re= places=3D%s, bandwidth=3D%lld, " "granularity=3D%#x, buf_size=3D%lld, shallow=3D%d syncWrite= =3D%d", - NULLSTR(jobname), persistjob, device, target, bandwidth, gra= nularity, - buf_size, shallow, syncWrite); + NULLSTR(jobname), persistjob, device, target, NULLSTR(replac= es), + bandwidth, granularity, buf_size, shallow, syncWrite); QEMU_CHECK_MONITOR(mon); - return qemuMonitorJSONBlockdevMirror(mon, jobname, persistjob, device,= target, + return qemuMonitorJSONBlockdevMirror(mon, jobname, persistjob, device,= target, replaces, bandwidth, granularity, buf_size,= shallow, syncWrite); } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index f7b9263b64..8c3fb5e131 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -981,6 +981,7 @@ int qemuMonitorBlockdevMirror(qemuMonitor *mon, bool persistjob, const char *device, const char *target, + const char *replaces, unsigned long long bandwidth, unsigned int granularity, unsigned long long buf_size, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 9c60807926..646d8df242 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4004,6 +4004,7 @@ qemuMonitorJSONBlockdevMirror(qemuMonitor *mon, bool persistjob, const char *device, const char *target, + const char *replaces, unsigned long long speed, unsigned int granularity, unsigned long long buf_size, @@ -4032,6 +4033,7 @@ qemuMonitorJSONBlockdevMirror(qemuMonitor *mon, "S:job-id", jobname, "s:device", device, "s:target", target, + "S:replaces", replaces, "Y:speed", speed, "z:granularity", granularity, "P:buf-size", buf_size, diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 25e3ae2cbb..77b8bf4a1b 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -272,6 +272,7 @@ qemuMonitorJSONBlockdevMirror(qemuMonitor *mon, bool persistjob, const char *device, const char *target, + const char *replaces, unsigned long long speed, unsigned int granularity, unsigned long long buf_size, diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index f0f6a329c8..afc2e54fd0 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1155,7 +1155,7 @@ GEN_TEST_FUNC(qemuMonitorJSONGraphicsRelocate, VIR_DO= MAIN_GRAPHICS_TYPE_SPICE, "localhost", 12345, 12346, "certsubjectval") GEN_TEST_FUNC(qemuMonitorJSONRemoveNetdev, "net0") GEN_TEST_FUNC(qemuMonitorJSONDelDevice, "ide0") -GEN_TEST_FUNC(qemuMonitorJSONBlockdevMirror, "jobname", true, "vdb", "targ= etnode", 1024, 1234, 31234, true, true) +GEN_TEST_FUNC(qemuMonitorJSONBlockdevMirror, "jobname", true, "vdb", "targ= etnode", "replacenode", 1024, 1234, 31234, true, true) GEN_TEST_FUNC(qemuMonitorJSONBlockStream, "vdb", "jobname", "backingnode",= "backingfilename", 1024) GEN_TEST_FUNC(qemuMonitorJSONBlockCommit, "vdb", "jobname", "topnode", "ba= senode", "backingfilename", 1024, VIR_TRISTATE_BOOL_YES) GEN_TEST_FUNC(qemuMonitorJSONScreendump, "devicename", 1, NULL, "/foo/bar") --=20 2.48.1 From nobody Mon Dec 15 14:42:38 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=1742232528; cv=none; d=zohomail.com; s=zohoarc; b=lZRkGHCSD1yTaqIZHvvikz2KEF/ubhJi3aSyd5iZN2LTwZSqUFZdziO2BI02C68qzFp1Q8f5wA6S0ttRs7E7+zETwV8J6X1jh4bxMB+vLYHWTYoL1GEpX0CD4K6vWbkF2V6vbO6Sc6kGBFx65aoE+wcvePfPWHXguj7Sb+45zDU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742232528; 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=evTT+TFTFYvwTbEz+FG85YUqvhdTqpJL0TIlYCFL/DU=; b=XQznzEfEy5k9QCkU4E/9BWGKN9Fq/0DzTP9MLSf0ItSMfQm1bEdWrffaeESa7zwSMPpC47dFYzl4yVmlBlOL5jJhSDJrrkmHVgNnkjR3PHaodNt4RDX1agym1Y/yKVKVOMuONNxdYVRTVMxrPlG3ZJbOa4B1rsblC5d2CQ/0Vpw= 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 1742232528399575.8044689154327; Mon, 17 Mar 2025 10:28:48 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id C16DA22C9; Mon, 17 Mar 2025 13:28:47 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 7332823A8; Mon, 17 Mar 2025 13:27:46 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 041B8223C; Mon, 17 Mar 2025 13:27:41 -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 8038B1C79 for ; Mon, 17 Mar 2025 13:27:41 -0400 (EDT) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-235-DkKN-Fl1OPW0sf6KXLI0ew-1; Mon, 17 Mar 2025 13:27:39 -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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 39EB91801A00 for ; Mon, 17 Mar 2025 17:27:38 +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 61C9018001F6 for ; Mon, 17 Mar 2025 17:27:37 +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=1742232461; 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=99WuTB0fNPUyX7y/p8RxTNE5LMZKAtUDrEJBvgWlFQ0=; b=NyT2ubILEjIQosmeCYREefgcQuG5HK5/4BwW7tc26fAoxqjjeu/o7jZSlGTF8/ctXs8m9I i0T17cCArngyysfqTkjyxpfNwlbSyt7/UXIFxM0kedG5hhkmuI1ujNEBT2iYeiQ+1pHHoD r4B4BAymnciKtbGbRFgTDUEdvFghQR4= X-MC-Unique: DkKN-Fl1OPW0sf6KXLI0ew-1 X-Mimecast-MFC-AGG-ID: DkKN-Fl1OPW0sf6KXLI0ew_1742232458 To: devel@lists.libvirt.org Subject: [PATCH 2/5] qemu: Do not replace filter nodes with virDomainBlockCopy Date: Mon, 17 Mar 2025 18:27:29 +0100 Message-ID: <0c07341e46129136018081b2a56108d1e07a0fca.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: B03HdVG7Pjuc4OJ37Yog1t_kiaLeVO6FisrS88i0QQ0_1742232458 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: ZLUL7YDAXK6PEO5ZC7GP7IHJZK4FAATT X-Message-ID-Hash: ZLUL7YDAXK6PEO5ZC7GP7IHJZK4FAATT 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: 1742232529807019000 Content-Type: text/plain; charset="utf-8" From: Peter Krempa The block copy operation is supposed to just move the disk to a new destination. While in certain scenarios it'd make sense to drop the copy-on-read layer, the definition would not correspond to it. This was caused by a fix to the behaviour of the block job after conversion to -blockdev as 'blockdev-mirror' requires the top node of the disk to be selected. This also causes that the 'copy-on-read' filter is ejected but libvirt doesn't unplug it. Instead we need to use the 'replaces' argument of 'blockdev-mirror' which allows to keep filters in place. This will preserve the configuration (which can be optimized later) and also fixes a spurious error logged when trying to unplug the first real file node after copy-on-read which still looks used to qemu. This is also needed for the upcoming feature which adds 'throttle' filter layers as we need to keep those in place too to facilitate the throttling. Resolves: https://issues.redhat.com/browse/RHEL-40077 Fixes: e3137539a9c4af25ab085506d5467ec0847b0ecc Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/qemu/qemu_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 84564b0658..cf7069a34a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14363,7 +14363,7 @@ qemuDomainBlockCopyCommon(virDomainObj *vm, ret =3D qemuMonitorBlockdevMirror(priv->mon, job->name, true, qemuDomainDiskGetTopNodename(disk), qemuBlockStorageSourceGetEffectiveNode= name(mirror), - NULL, + qemuBlockStorageSourceGetEffectiveNode= name(disk->src), bandwidth, granularity, buf_size, mirror_shallow, syncWrites); --=20 2.48.1 From nobody Mon Dec 15 14:42:38 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=1742232550; cv=none; d=zohomail.com; s=zohoarc; b=hClPRCtpiIvdz6+JvW9c2iz74Cey/yj+GvYiyKy3w3M55WQ1U3Z7V04Rgis6CnwyaG6KefuRrLw0pgZn8yyYr7SSRu3qtYOG/EoXjhKR+4hfggXkloRpTmWYhVf8nTtI/bTH/seJAz0trN96sIfjkg0/T+OQWtRBfYeW07nrxrI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742232550; 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=iG/A8mn+Kz3kREWvgLiIwgka3zLMZgLXLAh+s8Du2oI=; b=malwtRkOaVPYd4jiT/gWeDSFyAFtVCt8Q3zTUnijkeRw9IgodoGSat/yCmOX6RBO/AhEmFl+kg2UFNJ0QYYRCn5AfQ+6p10bUo/x7atqDejnNSzfdvm6L/d8PwNzIP9J+xnB1tt2d/spAIOKjg9lViLdKQug7i/CAhK9g8yS5I8= 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 1742232550142448.92494031758145; Mon, 17 Mar 2025 10:29:10 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 39187241B; Mon, 17 Mar 2025 13:29:09 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 6603223AD; Mon, 17 Mar 2025 13:27:49 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id D23C62108; Mon, 17 Mar 2025 13:27:42 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 270692108 for ; Mon, 17 Mar 2025 13:27:42 -0400 (EDT) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-292-bWXX1uXPMkWCV4y2Lbvl1A-1; Mon, 17 Mar 2025 13:27:40 -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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 86EFF180AF50 for ; Mon, 17 Mar 2025 17:27:39 +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 B65231828A80 for ; Mon, 17 Mar 2025 17:27:38 +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_H2, 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=1742232461; 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=Aq/1uTO+5azpN03vrZGccO0BFKKBuKzWDJMzO7isFPs=; b=WnJxxbyMp0QOxarjeFb+bbibN8s01StNyhIdoJJrAirKBtamjjTrtrmJKVQN2Ow4GGON71 a4NMne9obQQiks/xhnG7QImtHC8IAkFF8M11bGXkAYgNgrejgd7XpWw7YuFZNgqZ7CcjKE MpTSueWNpVfKGPfId/sK6RrVr9j+Nno= X-MC-Unique: bWXX1uXPMkWCV4y2Lbvl1A-1 X-Mimecast-MFC-AGG-ID: bWXX1uXPMkWCV4y2Lbvl1A_1742232459 To: devel@lists.libvirt.org Subject: [PATCH 3/5] qemu: Remove return value from 'qemuHotplugRemoveManagedPR' Date: Mon, 17 Mar 2025 18:27:30 +0100 Message-ID: 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: FCnYswY6LWwklxWsip22qBn3N8zbL1ZJD1tAN12s4xQ_1742232459 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: I4MXUBZ6DQCG4L5BO47WFSVOWBWZVSEE X-Message-ID-Hash: I4MXUBZ6DQCG4L5BO47WFSVOWBWZVSEE 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: 1742232552720019100 Content-Type: text/plain; charset="utf-8" From: Peter Krempa The only place which actually checked the return value would skip code e.g. to delete unused files or stop no longer used services. The rest of the callers ignored the value. As this is expected to be used on cleanup code paths which have no possibility to report errors we should remove the return value completely. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/qemu/qemu_blockjob.c | 2 +- src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_hotplug.c | 17 +++++++---------- src/qemu/qemu_hotplug.h | 2 +- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index 7b7d54fdca..c1b29f2fde 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); - ignore_value(qemuHotplugRemoveManagedPR(vm, asyncJob)); + qemuHotplugRemoveManagedPR(vm, asyncJob); } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index cf7069a34a..37cd3a8b7b 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); - ignore_value(qemuHotplugRemoveManagedPR(vm, VIR_ASYNC_JOB_NONE)); + qemuHotplugRemoveManagedPR(vm, 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 b6ef10edf9..bb599d1505 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -469,31 +469,29 @@ qemuHotplugAttachManagedPR(virDomainObj *vm, * Removes the managed PR object from @vm if the configuration does not re= quire * it any more. */ -int +void qemuHotplugRemoveManagedPR(virDomainObj *vm, virDomainAsyncJob asyncJob) { qemuDomainObjPrivate *priv =3D vm->privateData; virErrorPtr orig_err; - int ret =3D -1; if (qemuDomainDefHasManagedPR(vm)) - return 0; + return; virErrorPreserveLast(&orig_err); if (qemuDomainObjEnterMonitorAsync(vm, asyncJob) < 0) goto cleanup; + ignore_value(qemuMonitorDelObject(priv->mon, qemuDomainGetManagedPRAli= as(), false)); qemuDomainObjExitMonitor(vm); qemuProcessKillManagedPRDaemon(vm); - ret =3D 0; cleanup: virErrorRestore(&orig_err); - return ret; } @@ -665,7 +663,7 @@ qemuDomainChangeEjectableMedia(virQEMUDriver *driver, /* remove PR manager object if unneeded */ if (managedpr) - ignore_value(qemuHotplugRemoveManagedPR(vm, VIR_ASYNC_JOB_NONE)); + qemuHotplugRemoveManagedPR(vm, VIR_ASYNC_JOB_NONE); /* revert old image do the disk definition */ if (oldsrc) @@ -1099,7 +1097,7 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver = *driver, ignore_value(qemuDomainStorageSourceChainAccessRevoke(driver, = vm, disk->src)); if (virStorageSourceChainHasManagedPR(disk->src)) - ignore_value(qemuHotplugRemoveManagedPR(vm, VIR_ASYNC_JOB_NONE= )); + qemuHotplugRemoveManagedPR(vm, VIR_ASYNC_JOB_NONE); } qemuDomainSecretDiskDestroy(disk); qemuDomainCleanupStorageSourceFD(disk->src); @@ -4739,9 +4737,8 @@ qemuDomainRemoveDiskDevice(virQEMUDriver *driver, if (diskBackend) qemuDomainStorageSourceChainAccessRevoke(driver, vm, disk->src); - if (virStorageSourceChainHasManagedPR(disk->src) && - qemuHotplugRemoveManagedPR(vm, VIR_ASYNC_JOB_NONE) < 0) - goto cleanup; + if (virStorageSourceChainHasManagedPR(disk->src)) + qemuHotplugRemoveManagedPR(vm, VIR_ASYNC_JOB_NONE); qemuNbdkitStopStorageSource(disk->src, vm, true); diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h index d51f649bac..6a94dbd0cb 100644 --- a/src/qemu/qemu_hotplug.h +++ b/src/qemu/qemu_hotplug.h @@ -130,6 +130,6 @@ int qemuHotplugAttachManagedPR(virDomainObj *vm, virStorageSource *src, virDomainAsyncJob asyncJob); -int +void qemuHotplugRemoveManagedPR(virDomainObj *vm, virDomainAsyncJob asyncJob); --=20 2.48.1 From nobody Mon Dec 15 14:42:38 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=1742232574; cv=none; d=zohomail.com; s=zohoarc; b=AhMg9kx5c7D2SX6umv3LfRqpF1SA/lhgDu54BgCm0exgw1t0TAwhMF5H94Rvpo1RjAZMpPInvJxiTVRjUzXInmdQOSAdqyVvK1QFfcsbaYPJ6SxFfE5J3AC85bsvzz9CRMBaLgfzoENa+Fmn9mjt6qcuW0RSMCOUHFlUq2GjjNE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742232574; 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=y08TrRMA/tWFI/OyaSmLohNx6bJiBALH8fNyMfJ8EH8=; b=BEvzi616qCd2DpBQhuU2wrfj8dDS6RvNhK0qtXu+j9/srza1IsDIxSyLj4D0ASYe65HA3FlbiIJbCujTsgS5koWXqEEg+YrIzdDkFZT8XrWmIpLHVyAv4HppA9dJ48Rtfo3qOIPSBvsx8YvbTT5e/I3gm2hTL66pLeTYDmf6xMc= 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 1742232574503626.0713790089891; Mon, 17 Mar 2025 10:29:34 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 7929023CD; Mon, 17 Mar 2025 13:29:33 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id DEA1223A3; Mon, 17 Mar 2025 13:27:55 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 677C222C9; Mon, 17 Mar 2025 13:27:50 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 9AE9222EC for ; Mon, 17 Mar 2025 13:27:43 -0400 (EDT) Received: from mx-prod-mc-03.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-416-PcoulVe9Nw6VTey9gq9U9g-1; Mon, 17 Mar 2025 13:27:41 -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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D5BFD1956051 for ; Mon, 17 Mar 2025 17:27:40 +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 0E7A1180174E for ; Mon, 17 Mar 2025 17:27:39 +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_H2, 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=1742232463; 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=9tMNQPZLAGD4sEEkXE1A2gMCb+XjaWoHUc9cKSfxtzs=; b=fMQStgpOB+HNPGV57jzrqxlmTydj0+uISaa3uYnb/EXR7MxzoYYeArCuID2aKpOpZUN6Mn V/KirXvANNL/Du4tEdeWctQAQlxbfeOkZGW9ueCBNuD8r0ke+KH+db/ut/8ouyG4e+T6j2 pc7uIawFZu190CblmnerVnGDQLwsJMY= X-MC-Unique: PcoulVe9Nw6VTey9gq9U9g-1 X-Mimecast-MFC-AGG-ID: PcoulVe9Nw6VTey9gq9U9g_1742232461 To: devel@lists.libvirt.org Subject: [PATCH 4/5] qemuDomainChangeEjectableMedia: Separate rollback and success code paths Date: Mon, 17 Mar 2025 18:27:31 +0100 Message-ID: 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: Ug9wXiEv3wIi3ZMy8BYnCICXz5IcH3m6HdLlfUrw7nI_1742232461 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: IUNAPSZFQSA6NG6WOXRKEFAT2TJZOURD X-Message-ID-Hash: IUNAPSZFQSA6NG6WOXRKEFAT2TJZOURD 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: 1742232576509019100 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Do not use the rollback code path on success just to avoid extra call to qemuHotplugRemoveManagedPR. Rename the label and use it only when rolling back. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/qemu/qemu_hotplug.c | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index bb599d1505..d6de9afccd 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -613,9 +613,6 @@ qemuDomainChangeEjectableMedia(virQEMUDriver *driver, qemuDomainObjPrivate *priv =3D vm->privateData; virStorageSource *oldsrc =3D disk->src; qemuDomainDiskPrivate *diskPriv =3D QEMU_DOMAIN_DISK_PRIVATE(disk); - bool managedpr =3D virStorageSourceChainHasManagedPR(oldsrc) || - virStorageSourceChainHasManagedPR(newsrc); - int ret =3D -1; int rc; if (diskPriv->blockjob && qemuBlockJobIsRunning(diskPriv->blockjob)) { @@ -627,49 +624,45 @@ qemuDomainChangeEjectableMedia(virQEMUDriver *driver, disk->src =3D newsrc; if (virDomainDiskTranslateSourcePool(disk) < 0) - goto cleanup; + goto rollback; if (qemuDomainDetermineDiskChain(driver, vm, disk, NULL) < 0) - goto cleanup; + goto rollback; if (qemuDomainPrepareDiskSource(disk, priv, cfg) < 0) - goto cleanup; + goto rollback; if (qemuDomainStorageSourceChainAccessAllow(driver, vm, newsrc) < 0) - goto cleanup; + goto rollback; if (qemuHotplugAttachManagedPR(vm, newsrc, VIR_ASYNC_JOB_NONE) < 0) - goto cleanup; + goto rollback; rc =3D qemuDomainChangeMediaBlockdev(vm, disk, oldsrc, newsrc, force); virDomainAuditDisk(vm, oldsrc, newsrc, "update", rc >=3D 0); if (rc < 0) - goto cleanup; + goto rollback; ignore_value(qemuDomainStorageSourceChainAccessRevoke(driver, vm, olds= rc)); + if (virStorageSourceChainHasManagedPR(oldsrc)) + qemuHotplugRemoveManagedPR(vm, VIR_ASYNC_JOB_NONE); + /* media was changed, so we can remove the old media definition now */ g_clear_pointer(&oldsrc, virObjectUnref); + return 0; - ret =3D 0; - - cleanup: - /* undo changes to the new disk */ - if (ret < 0) { - ignore_value(qemuDomainStorageSourceChainAccessRevoke(driver, vm, = newsrc)); - } + rollback: + ignore_value(qemuDomainStorageSourceChainAccessRevoke(driver, vm, news= rc)); - /* remove PR manager object if unneeded */ - if (managedpr) + if (virStorageSourceChainHasManagedPR(newsrc)) qemuHotplugRemoveManagedPR(vm, VIR_ASYNC_JOB_NONE); /* revert old image do the disk definition */ - if (oldsrc) - disk->src =3D oldsrc; - - return ret; + disk->src =3D oldsrc; + return -1; } --=20 2.48.1 From nobody Mon Dec 15 14:42:38 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 Reviewed-by: Pavel Hrdina --- 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