From nobody Thu Dec 26 19:55:25 2024 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1732634276889261.1520101401584; Tue, 26 Nov 2024 07:17:56 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 425C91BF0; Tue, 26 Nov 2024 10:17:56 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id AAAC11BF6; Tue, 26 Nov 2024 10:16:56 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id A1B9618C6; Tue, 26 Nov 2024 10:16:50 -0500 (EST) 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 221FF1397 for ; Tue, 26 Nov 2024 10:16:50 -0500 (EST) 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-479-3Pn9NakhP6ybe5c0lDNNyg-1; Tue, 26 Nov 2024 10:16:48 -0500 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 33D871901FBB for ; Tue, 26 Nov 2024 15:16:25 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7272D19776DE for ; Tue, 26 Nov 2024 15:16:23 +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=-1.7 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,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=1732634209; 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=GmzXwtxbHUpDIOSMASiSgoxjPZd96AoRcPVuT5hp7VA=; b=BpzxoHF7QB4hwxkaYtTgzEMf43hLzhD/J/Oxqevcl4aXuP/doe/pKhEWqW11KeDJRa+IWy ondys0xzdstL9p409kIPgaZC+JstC3RBpZRKyhEjZ++n1aqyu+DNq48/8nlMN1pE77gZHe 3tUdQL54NbTDSPYPfZspP2VJfxD2g4g= X-MC-Unique: 3Pn9NakhP6ybe5c0lDNNyg-1 X-Mimecast-MFC-AGG-ID: 3Pn9NakhP6ybe5c0lDNNyg From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 1/8] qemuBlockReopenAccess: Add debug log entry about state of the image Date: Tue, 26 Nov 2024 16:16:12 +0100 Message-ID: <2d0f2ec06b0d989e718e4119861d6bc061751168.1732633990.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 7RpGrYV6i9_p9OnCaXB1e9DKsBYCnVzoE67Hb0jKmgo_1732634207 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 6CYOF5FOD5B4IHB6JAYBUZ2RQ7W24X36 X-Message-ID-Hash: 6CYOF5FOD5B4IHB6JAYBUZ2RQ7W24X36 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: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1732634278953019100 Content-Type: text/plain; charset="utf-8" Log the node name and current and expected state to simplify debugging. Signed-off-by: Peter Krempa Reviewed-by: Jiri Denemark --- src/qemu/qemu_block.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index dab9ce4dc2..088c128424 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -3174,6 +3174,10 @@ qemuBlockReopenAccess(virDomainObj *vm, int rc; int ret =3D -1; + VIR_DEBUG("nodename:'%s' current-ro:'%d requested-ro=3D'%d'", + qemuBlockStorageSourceGetEffectiveNodename(src), + src->readonly, readonly); + if (src->readonly =3D=3D readonly) return 0; --=20 2.47.0 From nobody Thu Dec 26 19:55:25 2024 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1732634233600650.6609925611604; Tue, 26 Nov 2024 07:17:13 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 94AB81C0C; Tue, 26 Nov 2024 10:17:12 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 9433618BC; Tue, 26 Nov 2024 10:16:50 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 123DC181C; Tue, 26 Nov 2024 10:16:48 -0500 (EST) 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 8153D1397 for ; Tue, 26 Nov 2024 10:16:47 -0500 (EST) Received: from mx-prod-mc-05.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-79-m-W5FiU-P3adU5ho-raHEA-1; Tue, 26 Nov 2024 10:16:45 -0500 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 27F491833851 for ; Tue, 26 Nov 2024 15:16:27 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0485919772CF for ; Tue, 26 Nov 2024 15:16:24 +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=-1.7 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,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=1732634207; 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=f+EoNKOZXMTkirp/bIomlX81DUySFXp3n5Mb2Z2sLRY=; b=V8IEJ5N6pyLHUhj+zvzqoXgHHgPdu++WJRtXtLvR0Lb9uWKcfmVOOSC4n8T4xnSMJyFHBo B2Dr+UCc+mPxr2VhDNIrTtF3aviqD0KxX8fVEesJ334AS9q1mqitrCJveEDtEDpwbvCTSs Rf0EYTaW9/rPuWGzRc+oTmPEsbSgxXA= X-MC-Unique: m-W5FiU-P3adU5ho-raHEA-1 X-Mimecast-MFC-AGG-ID: m-W5FiU-P3adU5ho-raHEA From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 2/8] qemuBlockReopenAccess: Fix update of 'readonly' state Date: Tue, 26 Nov 2024 16:16:13 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: MBoVyt_dLVnZ4Xh-31_0JmjcqskFaT8xkvtOzwIFQC0_1732634204 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: ZLIGEWE7FH3OFFJ3JJAJPZW7CACRET5V X-Message-ID-Hash: ZLIGEWE7FH3OFFJ3JJAJPZW7CACRET5V 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: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1732634235977019100 Content-Type: text/plain; charset="utf-8" Refactors done in 24b667eeed78d2df (and also 9ec0e28e876b17df9) broke the expected handling of the update of 'readonly' flag of a virStorage. The source is actually set to the proper state but rolled back to the previous state as the 'cleanup' label should have been 'error' and thus not reached on success. Additionally some of the code paths violate the statement in the comment after updating 'readonly' that only 'goto error' must be used. Fixes: 24b667eeed78d2df0376a38a592ed9d8c2744bdc Signed-off-by: Peter Krempa Reviewed-by: Jiri Denemark --- src/qemu/qemu_block.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 088c128424..a7c8be8d8b 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -3172,7 +3172,6 @@ qemuBlockReopenAccess(virDomainObj *vm, g_autoptr(virJSONValue) reopenoptions =3D virJSONValueNewArray(); g_autoptr(virJSONValue) srcprops =3D NULL; int rc; - int ret =3D -1; VIR_DEBUG("nodename:'%s' current-ro:'%d requested-ro=3D'%d'", qemuBlockStorageSourceGetEffectiveNodename(src), @@ -3190,39 +3189,39 @@ qemuBlockReopenAccess(virDomainObj *vm, } src->readonly =3D readonly; - /* from now on all error paths must use 'goto cleanup' */ + /* from now on all error paths must use 'goto error' which restores th= e original state */ /* based on which is the current 'effecitve' layer we must reopen the * appropriate blockdev */ if (qemuBlockStorageSourceGetFormatNodename(src)) { if (!(srcprops =3D qemuBlockStorageSourceGetFormatProps(src, src->= backingStore))) - return -1; + goto error; } else if (qemuBlockStorageSourceGetSliceNodename(src)) { if (!(srcprops =3D qemuBlockStorageSourceGetBlockdevStorageSlicePr= ops(src, true, false))) - return -1; + goto error; } else { if (!(srcprops =3D qemuBlockStorageSourceGetBackendProps(src, QEMU_BLOCK_= STORAGE_SOURCE_BACKEND_PROPS_EFFECTIVE_NODE))) - return -1; + goto error; } if (virJSONValueArrayAppend(reopenoptions, &srcprops) < 0) - return -1; + goto error; if (qemuDomainObjEnterMonitorAsync(vm, asyncJob) < 0) - goto cleanup; + goto error; rc =3D qemuMonitorBlockdevReopen(qemuDomainGetMonitor(vm), &reopenopti= ons); qemuDomainObjExitMonitor(vm); if (rc < 0) - goto cleanup; + goto error; - ret =3D 0; + return 0; - cleanup: + error: src->readonly =3D !readonly; - return ret; + return -1; } --=20 2.47.0 From nobody Thu Dec 26 19:55:25 2024 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1732634358737439.9148042023312; Tue, 26 Nov 2024 07:19:18 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id A59AA1C4C; Tue, 26 Nov 2024 10:19:16 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 2D0081900; Tue, 26 Nov 2024 10:17:19 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 554BF1B52; Tue, 26 Nov 2024 10:17:11 -0500 (EST) 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 9B14E18E2 for ; Tue, 26 Nov 2024 10:16:57 -0500 (EST) 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-313-Tp5xIgBTOGWA2BGImDyWVg-1; Tue, 26 Nov 2024 10:16:53 -0500 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 CFC5A188EFFD for ; Tue, 26 Nov 2024 15:16:29 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 739D219776DB for ; Tue, 26 Nov 2024 15:16:26 +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=-1.7 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,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=1732634216; 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=wiozSt15D4sGwmBbutTGgSae0vTbxLTa0a+aJb5UcM4=; b=Auau35bYzaeS0ri2fSUQNTgN3qGG0q04p/Px+IQH+5EubCKUazpyIOR8qw2IIIFgxilSvj 6R6aSh2cp3F8N6rc5P8GC9dtreZobY9af5ybQYmEjrC+51KCIoyQO6/IzmYF66CFjCfsf5 lPwO5bUh8d0c6HC1rEds5rBPZDl7M1o= X-MC-Unique: Tp5xIgBTOGWA2BGImDyWVg-1 X-Mimecast-MFC-AGG-ID: Tp5xIgBTOGWA2BGImDyWVg From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 3/8] qemuBlockReopenAccess: Don't require backing chain terminator for non-chained images Date: Tue, 26 Nov 2024 16:16:14 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: Q33JXCJ2GoEE4zJAL9QTbLfjuwgqSdFY2ott48YRHSE_1732634212 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 7U6PKUUG6HK7DH5JEI7UVO4MNIWQCUYS X-Message-ID-Hash: 7U6PKUUG6HK7DH5JEI7UVO4MNIWQCUYS 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: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1732634360269019100 Content-Type: text/plain; charset="utf-8" Add an exception for image formats not supporting backing images so that they can be reopened RW/RO without the need for adding a terminating virStorageSource as they simply can't have a backing image. Signed-off-by: Peter Krempa Reviewed-by: Jiri Denemark --- src/qemu/qemu_block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index a7c8be8d8b..af317a1f1f 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -3182,7 +3182,7 @@ qemuBlockReopenAccess(virDomainObj *vm, /* If we are lacking the object here, qemu might have opened an image = with * a node name unknown to us */ - if (!src->backingStore) { + if (src->format >=3D VIR_STORAGE_FILE_BACKING && !src->backingStore) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("can't reopen image with unknown presence of back= ing store")); return -1; --=20 2.47.0 From nobody Thu Dec 26 19:55:25 2024 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1732634321352180.55827222532605; Tue, 26 Nov 2024 07:18:41 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id BE1B3C84; Tue, 26 Nov 2024 10:18:40 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 27D7A1C2A; Tue, 26 Nov 2024 10:17:14 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 6472A18BF; Tue, 26 Nov 2024 10:17:09 -0500 (EST) 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 62AB218F0 for ; Tue, 26 Nov 2024 10:16:55 -0500 (EST) Received: from mx-prod-mc-01.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-553-k5uLpcuFM3uYN0-le5eZfg-1; Tue, 26 Nov 2024 10:16:52 -0500 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A7173196EC3B for ; Tue, 26 Nov 2024 15:16:29 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D5BB61979041 for ; Tue, 26 Nov 2024 15:16:27 +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=-1.7 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,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=1732634215; 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=xk1IrGnBEw1qDiS+HsstfrPiUj9FaQUSMYyO5J+6wF4=; b=CXkKbRgN281D8Zn6ktmHZNd592n8z7Hdq288I3UBMTXUJ4fugSCzDuaFLaW9Z3EjoMv1tn /PbXp5oyT7NSzir4C7oNLWhpjGAYn0AmRyhOtKn7kEJj3+6WmSkUF9ctLBDCMWLxpmQciU u8agbCCS1uDHn0EVd+lnb2MuHsqk3UI= X-MC-Unique: k5uLpcuFM3uYN0-le5eZfg-1 X-Mimecast-MFC-AGG-ID: k5uLpcuFM3uYN0-le5eZfg From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 4/8] qemu: block: Ensure that is in appropriate state Date: Tue, 26 Nov 2024 16:16:15 +0100 Message-ID: <5fce28c19e492ee64eed32c218737d54254581ab.1732633990.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: QIhuEpqe06m2bcN6GidCBRTxNXVeYS-al4BQR-FQLoE_1732634212 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: OU4N64C4G4ERVXSLJOZVFZIYPGFFUPRV X-Message-ID-Hash: OU4N64C4G4ERVXSLJOZVFZIYPGFFUPRV 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: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1732634322257019100 Content-Type: text/plain; charset="utf-8" In contrast to normal backing chain members where qemu does honour the 'auto-read-only' property the 'data-file' nodes are not automatically reopened by qemu. Libvirt now has the infrastructure to reopen them explicitly so use it for all transitions of the 'commit' block job. Signed-off-by: Peter Krempa Reviewed-by: Jiri Denemark --- src/qemu/qemu_block.c | 33 ++++++++++++++++++++++++++++++++- src/qemu/qemu_blockjob.c | 16 +++++++++++++++- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index af317a1f1f..35dca8ee7b 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -3696,6 +3696,15 @@ qemuBlockCommit(virDomainObj *vm, false, false, false) < 0) goto cleanup; + if (baseSource->dataFileStore) { + if (qemuDomainStorageSourceAccessAllow(driver, vm, baseSource->dat= aFileStore, + false, false, false) < 0) + goto cleanup; + + if (qemuBlockReopenReadWrite(vm, baseSource->dataFileStore, asyncJ= ob) < 0) + goto cleanup; + } + if (top_parent && top_parent !=3D disk->src) { /* While top_parent is topmost image, we don't need to remember its * owner as it will be overwritten upon finishing the commit. Henc= e, @@ -3703,6 +3712,15 @@ qemuBlockCommit(virDomainObj *vm, if (qemuDomainStorageSourceAccessAllow(driver, vm, top_parent, false, false, false) < 0) goto cleanup; + + if (top_parent->dataFileStore) { + if (qemuDomainStorageSourceAccessAllow(driver, vm, top_parent-= >dataFileStore, + false, false, false) < = 0) + goto cleanup; + + if (qemuBlockReopenReadWrite(vm, top_parent->dataFileStore, as= yncJob) < 0) + goto cleanup; + } } if (!(job =3D qemuBlockJobDiskNewCommit(vm, disk, top_parent, topSourc= e, @@ -3748,12 +3766,25 @@ qemuBlockCommit(virDomainObj *vm, if (rc < 0 && clean_access) { virErrorPtr orig_err; virErrorPreserveLast(&orig_err); + /* Revert access to read-only, if possible. */ + if (baseSource->dataFileStore) { + qemuDomainStorageSourceAccessAllow(driver, vm, baseSource->dat= aFileStore, + true, false, false); + qemuBlockReopenReadOnly(vm, baseSource->dataFileStore, asyncJo= b); + } qemuDomainStorageSourceAccessAllow(driver, vm, baseSource, true, false, false); - if (top_parent && top_parent !=3D disk->src) + if (top_parent && top_parent !=3D disk->src) { + if (top_parent->dataFileStore) { + qemuDomainStorageSourceAccessAllow(driver, vm, top_parent-= >dataFileStore, + true, false, false); + + qemuBlockReopenReadWrite(vm, top_parent->dataFileStore, as= yncJob); + } qemuDomainStorageSourceAccessAllow(driver, vm, top_parent, true, false, false); + } virErrorRestore(&orig_err); } diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index c35321790e..4e77543fa8 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -1064,11 +1064,25 @@ qemuBlockJobProcessEventCompletedCommit(virQEMUDriv= er *driver, return; /* revert access to images */ + if (job->data.commit.base->dataFileStore) { + qemuDomainStorageSourceAccessAllow(driver, vm, job->data.commit.ba= se->dataFileStore, + true, false, false); + qemuBlockReopenReadOnly(vm, job->data.commit.base->dataFileStore, = asyncJob); + } qemuDomainStorageSourceAccessAllow(driver, vm, job->data.commit.base, true, false, false); - if (job->data.commit.topparent !=3D job->disk->src) + + if (job->data.commit.topparent !=3D job->disk->src) { + if (job->data.commit.topparent->dataFileStore) { + qemuDomainStorageSourceAccessAllow(driver, vm, job->data.commi= t.topparent->dataFileStore, + true, false, false); + + qemuBlockReopenReadWrite(vm, job->data.commit.topparent->dataF= ileStore, asyncJob); + } qemuDomainStorageSourceAccessAllow(driver, vm, job->data.commit.to= pparent, true, false, true); + } + baseparent->backingStore =3D NULL; job->data.commit.topparent->backingStore =3D job->data.commit.base; --=20 2.47.0 From nobody Thu Dec 26 19:55:25 2024 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1732634309410564.1294756955995; Tue, 26 Nov 2024 07:18:29 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 369E51BF6; Tue, 26 Nov 2024 10:18:16 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 7DD4518B5; Tue, 26 Nov 2024 10:17:11 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id E25161C28; Tue, 26 Nov 2024 10:17:06 -0500 (EST) 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 2C0071BFA for ; Tue, 26 Nov 2024 10:16:54 -0500 (EST) Received: from mx-prod-mc-05.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-321-_jk0BmqBMySdSE_QOcM1DA-1; Tue, 26 Nov 2024 10:16:52 -0500 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8171E1944EBE for ; Tue, 26 Nov 2024 15:16:30 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 52FB3196BE85 for ; Tue, 26 Nov 2024 15:16:29 +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=-1.7 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,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=1732634213; 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=xggZ4LTbYJ+M/sj3iZYiG2FO14Hn8Jtvr9P2jVjwakg=; b=FIa0tTEECkZAzyRmFWGqOwIwZz9I+E13rbk2MpjXXL+/lPJrENm1HZCNUH79Gd3/J+ep+Q rhQpjjkSDtkOLXV+oA08UYFQrAmYxsQij+G/vUjDbbdFx2cc1MrQIv6e1malZ1hh7yF0JA mfKkUrnFB/hrKcbh3DWLBLYzTBs2s/o= X-MC-Unique: _jk0BmqBMySdSE_QOcM1DA-1 X-Mimecast-MFC-AGG-ID: _jk0BmqBMySdSE_QOcM1DA From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 5/8] qemu: snapshot: Change 'data-file' to read-only after snapshot Date: Tue, 26 Nov 2024 16:16:16 +0100 Message-ID: <0894fcc76e85f22211f6c76497e6d99065c3d4ad.1732633990.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: _DJvzVQeeL56dZKJvzWfFhkncBAs7z_np-lkX56uLFE_1732634210 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: B4NGSIQP2TNMI7K6QKAFCG4X3BLEADE3 X-Message-ID-Hash: B4NGSIQP2TNMI7K6QKAFCG4X3BLEADE3 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: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1732634310298019100 Content-Type: text/plain; charset="utf-8" For the reason outlined in previous commit qemu doesn't do this automatically. Handle it manually after the snapshot. Signed-off-by: Peter Krempa Reviewed-by: Jiri Denemark --- src/qemu/qemu_snapshot.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 5b3aadcbf0..f880d1eeec 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1434,12 +1434,14 @@ qemuSnapshotGetTransientDiskDef(virDomainDiskDef *d= omdisk, * qemuSnapshotDiskUpdateSource: * @vm: domain object * @dd: snapshot disk data object + * @asyncJob: async job type * * Updates disk definition after a successful snapshot. */ static void qemuSnapshotDiskUpdateSource(virDomainObj *vm, - qemuSnapshotDiskData *dd) + qemuSnapshotDiskData *dd, + virDomainAsyncJob asyncJob) { qemuDomainObjPrivate *priv =3D vm->privateData; virQEMUDriver *driver =3D priv->driver; @@ -1451,6 +1453,11 @@ qemuSnapshotDiskUpdateSource(virDomainObj *vm, if (qemuSecurityMoveImageMetadata(driver, vm, dd->disk->src, dd->src) = < 0) VIR_WARN("Unable to move disk metadata on vm %s", vm->def->name); + /* if the original image has a data-file turn it read-only */ + if (dd->disk->src->dataFileStore) { + ignore_value(qemuBlockReopenReadOnly(vm, dd->disk->src->dataFileSt= ore, asyncJob)); + } + /* unlock the write lock on the original image as qemu will no longer = write to it */ virDomainLockImageDetach(driver->lockManager, vm, dd->disk->src); @@ -1470,6 +1477,7 @@ qemuSnapshotDiskUpdateSource(virDomainObj *vm, dd->persistsrc->backingStore =3D g_steal_pointer(&dd->persistdisk-= >src); dd->persistdisk->src =3D g_steal_pointer(&dd->persistsrc); } + } @@ -1498,7 +1506,7 @@ qemuSnapshotDiskCreate(qemuSnapshotDiskContext *snapc= txt) virDomainAuditDisk(snapctxt->vm, dd->disk->src, dd->src, "snapshot= ", rc >=3D 0); if (rc =3D=3D 0) - qemuSnapshotDiskUpdateSource(snapctxt->vm, dd); + qemuSnapshotDiskUpdateSource(snapctxt->vm, dd, snapctxt->async= Job); } if (rc < 0) --=20 2.47.0 From nobody Thu Dec 26 19:55:25 2024 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1732634379682189.93782956624113; Tue, 26 Nov 2024 07:19:39 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 14E8817E9; Tue, 26 Nov 2024 10:19:39 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 7FBA11C54; Tue, 26 Nov 2024 10:17:24 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id B064F18B9; Tue, 26 Nov 2024 10:17:19 -0500 (EST) 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 C4BE11C29 for ; Tue, 26 Nov 2024 10:16:57 -0500 (EST) Received: from mx-prod-mc-01.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-613-cZnKU7a4MqKnyV0LpwuWyA-1; Tue, 26 Nov 2024 10:16:55 -0500 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B26D91877A7B for ; Tue, 26 Nov 2024 15:16:31 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A2214196BC05 for ; Tue, 26 Nov 2024 15:16:30 +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=-1.7 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,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=1732634217; 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=2eHMMzkxnmS3FDyIFwEX9eyz0CYSlPywpZYCqGHdcLQ=; b=b8/o3JgT10jSe/sSmc2M8OUgXenMtpmycDe8CbQz5Sd0noU269c6heoycNGDmGgb5GlOAo WUzDp1ZAhsT8A8sUvWnjY0J2dV7+1NLWMcq7H0TeA3aTrxi72nawIhDW9Xqlrvd7suachB wqeYy1pegdw6T1OEUD34xS3OxFcUt0w= X-MC-Unique: cZnKU7a4MqKnyV0LpwuWyA-1 X-Mimecast-MFC-AGG-ID: cZnKU7a4MqKnyV0LpwuWyA From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 6/8] qemuDomainVirStorageSourceFindByNodeName: Extract nodename matching Date: Tue, 26 Nov 2024 16:16:17 +0100 Message-ID: <0560a24ab6dca627530ec8130f3266d202ca8869.1732633990.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: dDkcQbZijwJIXyU5agAPuNhhZ6NRO-SWZkWua0KX7h0_1732634215 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: E77AMD5M6CWGV26UNTYA5OF6O5ZS2MOY X-Message-ID-Hash: E77AMD5M6CWGV26UNTYA5OF6O5ZS2MOY 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: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1732634380383019100 Content-Type: text/plain; charset="utf-8" Extract the matching of the node name of a single virStorage source so that the logic can be extended in the upcoming patch. Signed-off-by: Peter Krempa Reviewed-by: Jiri Denemark --- src/qemu/qemu_domain.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index d28ff0cd22..150f0736f3 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2884,6 +2884,25 @@ qemuDomainObjPrivateXMLParseBlockjobChain(xmlNodePtr= node, } +/** + * qemuDomainVirStorageSourceMatchNodename: + * @src: storage source to match + * @nodeName to match + * + * Returns true if any of the nodenames of @src matches @nodeName. + */ +static bool +qemuDomainVirStorageSourceMatchNodename(virStorageSource *src, + const char *nodeName) +{ + const char *nodestorage =3D qemuBlockStorageSourceGetStorageNodename(s= rc); + const char *nodeformat =3D qemuBlockStorageSourceGetFormatNodename(src= ); + + return (nodeformat && STREQ(nodeformat, nodeName)) || + (nodestorage && STREQ(nodestorage, nodeName)); +} + + /** * qemuDomainVirStorageSourceFindByNodeName: * @top: backing chain top @@ -2900,11 +2919,7 @@ qemuDomainVirStorageSourceFindByNodeName(virStorageS= ource *top, virStorageSource *tmp; for (tmp =3D top; virStorageSourceIsBacking(tmp); tmp =3D tmp->backing= Store) { - const char *nodestorage =3D qemuBlockStorageSourceGetStorageNodena= me(tmp); - const char *nodeformat =3D qemuBlockStorageSourceGetFormatNodename= (tmp); - - if ((nodeformat && STREQ(nodeformat, nodeName)) || - (nodestorage && STREQ(nodestorage, nodeName))) + if (qemuDomainVirStorageSourceMatchNodename(tmp, nodeName)) return tmp; } --=20 2.47.0 From nobody Thu Dec 26 19:55:25 2024 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1732634339735426.5564010089711; Tue, 26 Nov 2024 07:18:59 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 9D6E51B7A; Tue, 26 Nov 2024 10:18:58 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id D3C721C4A; Tue, 26 Nov 2024 10:17:16 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 6DA4F1B3D; Tue, 26 Nov 2024 10:17:10 -0500 (EST) 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 61BCE1BFB for ; Tue, 26 Nov 2024 10:16:57 -0500 (EST) Received: from mx-prod-mc-05.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-198-2SLQSpcvNsqRa7KHraPQtQ-1; Tue, 26 Nov 2024 10:16:54 -0500 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7837918F0F9C for ; Tue, 26 Nov 2024 15:16:33 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id F3043196BC2B for ; Tue, 26 Nov 2024 15:16:31 +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, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,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=1732634217; 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=0uFDLQaoOMINUThk5p0+4uodTeMPSrYpekWQy/o8B5I=; b=ZN1KMJ/SI2S8jB9RQh7z9tU4liIKndFKqN2gcgyL0vCPmQy0efswg/kebKGXMtuT0/X640 bWKwnGcf9XQvjlOV0qgbH8+veDwKvO7tSRx8JtGNY70w4vmaQtHTFwZeb9xagWKRS0DVrb jp6n5gGu6ggIjfHeQW1zgIuiuwqyX2w= X-MC-Unique: 2SLQSpcvNsqRa7KHraPQtQ-1 X-Mimecast-MFC-AGG-ID: 2SLQSpcvNsqRa7KHraPQtQ From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 7/8] qemuDomainVirStorageSourceFindByNodeName: Match also '' sources Date: Tue, 26 Nov 2024 16:16:18 +0100 Message-ID: <89950b54ac19a3639e8caa1d8ac2b59204cdb8c2.1732633990.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 7OfyQCKqWnnMbVgAT3MrcTQWCsQb-LDgmzkmfbl8qaw_1732634213 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: NZMRPNC5KVY2F7QR3IFPEG43IY32R6FX X-Message-ID-Hash: NZMRPNC5KVY2F7QR3IFPEG43IY32R6FX 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: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1732634342197019100 Content-Type: text/plain; charset="utf-8" As the source for the data file is a completely separate virStorageSource including it's own index we need to match it explicitly, so that code such as storage threshold events work properly and separately for the data file. Signed-off-by: Peter Krempa Reviewed-by: Jiri Denemark --- src/qemu/qemu_domain.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 150f0736f3..4499fed6bc 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2921,6 +2921,10 @@ qemuDomainVirStorageSourceFindByNodeName(virStorageS= ource *top, for (tmp =3D top; virStorageSourceIsBacking(tmp); tmp =3D tmp->backing= Store) { if (qemuDomainVirStorageSourceMatchNodename(tmp, nodeName)) return tmp; + + if (tmp->dataFileStore && + qemuDomainVirStorageSourceMatchNodename(tmp->dataFileStore, no= deName)) + return tmp->dataFileStore; } return NULL; --=20 2.47.0 From nobody Thu Dec 26 19:55:25 2024 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1732634394850823.4296853273094; Tue, 26 Nov 2024 07:19:54 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 2794DB14; Tue, 26 Nov 2024 10:19:54 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 17F711C73; Tue, 26 Nov 2024 10:17:27 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id BEB0E1910; Tue, 26 Nov 2024 10:17:19 -0500 (EST) 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 EE24F1BCB for ; Tue, 26 Nov 2024 10:17:02 -0500 (EST) 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-677-jMAEMcrjOa6UBWD-KCFr9w-1; Tue, 26 Nov 2024 10:17:01 -0500 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 E472518DB7C1 for ; Tue, 26 Nov 2024 15:16:35 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.6]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6DD96196BEA9 for ; Tue, 26 Nov 2024 15:16:33 +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=-1.7 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,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=1732634222; 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=N8V04PmiLWxGG52+ywmRs9DG0m36edSg+M/3dHrWyJo=; b=E7wOdVOg5KFHwvr7/3ppt2XSjG2/UNlxBJlbFNdYd8SOWoamnxdEpr9nyYY6JNKmqR2SmI SNKfbXvv9ErXnlIPftpJtP/KUh7Kji2GjuM3gTsPTUbvvppSVRAIiocz8Rn8myZPWURnjC Zs6k5YIkYU1kwfuwQErTif4ci/xPwrk= X-MC-Unique: jMAEMcrjOa6UBWD-KCFr9w-1 X-Mimecast-MFC-AGG-ID: jMAEMcrjOa6UBWD-KCFr9w From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 8/8] qemuDomainGetStorageSourceByDevstr: Lookup also '' Date: Tue, 26 Nov 2024 16:16:19 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: mYdqfYo81Qs9Qdo6CU87jdSeR7PAXMctvZDKmCJRVeA_1732634220 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: LAAQOWIVVK7JHEQQE53MGNUQ3QGCUVJC X-Message-ID-Hash: LAAQOWIVVK7JHEQQE53MGNUQ3QGCUVJC 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: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1732634396569019100 Content-Type: text/plain; charset="utf-8" The volumes have their own 'id' so we need to be able to look them up for the given image chain. Signed-off-by: Peter Krempa Reviewed-by: Jiri Denemark --- src/qemu/qemu_domain.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 4499fed6bc..1fc4e2f33f 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9260,12 +9260,18 @@ qemuDomainGetStorageSourceByDevstr(const char *devs= tr, for (n =3D disk->src; virStorageSourceIsBacking(n); n =3D n->backingSt= ore) { if (n->id =3D=3D idx) return n; + + if (n->dataFileStore && n->dataFileStore->id =3D=3D idx) + return n->dataFileStore; } if (disk->mirror) { for (n =3D disk->mirror; virStorageSourceIsBacking(n); n =3D n->ba= ckingStore) { if (n->id =3D=3D idx) return n; + + if (n->dataFileStore && n->dataFileStore->id =3D=3D idx) + return n->dataFileStore; } } @@ -9281,6 +9287,9 @@ qemuDomainGetStorageSourceByDevstr(const char *devstr, for (n =3D backupdisk->store; virStorageSourceIsBacking(n); n = =3D n->backingStore) { if (n->id =3D=3D idx) return n; + + if (n->dataFileStore && n->dataFileStore->id =3D=3D idx) + return n->dataFileStore; } } } --=20 2.47.0