From nobody Wed May 6 08:22:21 2026 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=1743153007; cv=none; d=zohomail.com; s=zohoarc; b=CnneWzzPVP1pIRBWG1Zdn8USeZFAzXoAgUxgNKdRGDoni8ijKEgBKEiXij9oKNED0jQS+SxcIj2f9gzlllNwFg6HQ7X1w97WcaMDrCEhy5SEOYJMv0Rkpc4TWagpL7tRQMNu4lRa8sj7uRGlKbUxBpwjxcsnwZT0opckbNtCzMQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1743153007; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Subject:Subject:To:To:Message-Id; bh=fXrcxQeCcDAIps89/Pw7HR5P6+t/6qFCKA0NXzHPR8w=; b=GhJruWOd/dmaBNMDFH6hjHXepe31krXrwyBumLHPqft1q/CX3IyJ9V4fgitOrTfB8N6LM9Z5z32M0KvgujkDHB6btt157J/qW7NohyPTGZZmlnTDYMeCRFT+Y5p3L7mZdVEJB0ixY3d3cS3LDnsuLwdsrZZMRSVa69RSObB6fJw= 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 174315300752149.68803646352603; Fri, 28 Mar 2025 02:10:07 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 791D8127E; Fri, 28 Mar 2025 05:10:06 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id E71AF1246; Fri, 28 Mar 2025 05:09:27 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 6FD4811AA; Fri, 28 Mar 2025 05:09:24 -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 58DE81185 for ; Fri, 28 Mar 2025 05:09:23 -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-396-5o8Mu6-EN-mD6fzs8LY6mQ-1; Fri, 28 Mar 2025 05:09:21 -0400 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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C591E180AF53 for ; Fri, 28 Mar 2025 09:09:20 +0000 (UTC) Received: from speedmetal.lan (unknown [10.44.22.8]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B56D41956095; Fri, 28 Mar 2025 09:09:19 +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_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=1743152963; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=d/3Xr77P5xV/4d1XDPFpkFGvZzsb+2HFlihpdFPEfoI=; b=clEJ7/UxixSJCNolwEbWpZnsObOnlOWXgsUgOCtv2w6bamWcjB2vGg/Cm/PFW7K5+YIkmA KND3ZBXOgpMfA9lFZzQrFStFhOLEhDRs0+11XS1isk2dsZDBxJrYqHXbCo9HxjMiZbkfsY j8OyMB5AtlP3bGOIPeoMic4XsctU8No= X-MC-Unique: 5o8Mu6-EN-mD6fzs8LY6mQ-1 X-Mimecast-MFC-AGG-ID: 5o8Mu6-EN-mD6fzs8LY6mQ_1743152960 To: devel@lists.libvirt.org Subject: [PATCH] virDomainDiskDefValidateSourceChainOne: Fix validation of 'data-file' nesting Date: Fri, 28 Mar 2025 10:09:17 +0100 Message-ID: <9101a2ea0f46088fa5f2660b7477942bf95b09e0.1743152957.git.pkrempa@redhat.com> 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: E2gzGSWm4wxs5Y1tyXMah6q4BqRGzRpfvFoe-O-tlJ0_1743152960 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: XVGJCW7TNOGYZM64CRD5MR32D4VHBKGG X-Message-ID-Hash: XVGJCW7TNOGYZM64CRD5MR32D4VHBKGG 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 CC: Peter Krempa 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: 1743153009602019100 Content-Type: text/plain; charset="utf-8" From: Peter Krempa As the 'dataStore' is internally represented as a virStorageSource object it has provisions for nesting which is not supported. When I've reviewed and modified the commit adding data file parsing support I've added code that was supposed to reject any 'backingStore' and 'dataStore' structures nested in a source of a 'dataStore'. Unfortunately the check was broken as one of the terms checked the presence of parent's 'backingStore' instead of the nesting. Fix it and add tests. Fixes: b3171cf8da3 Resolves: https://issues.redhat.com/browse/RHEL-85320 Signed-off-by: Peter Krempa Reviewed-by: Jiri Denemark --- src/conf/domain_validate.c | 2 +- ...sk-qcow2-datafile-store.x86_64-latest.args | 43 +++++++++++-------- ...isk-qcow2-datafile-store.x86_64-latest.xml | 22 +++++++++- .../disk-qcow2-datafile-store.xml | 19 ++++++++ 4 files changed, 66 insertions(+), 20 deletions(-) diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 396d1e400a..d0d4bc0bf4 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -562,7 +562,7 @@ virDomainDiskDefValidateSourceChainOne(const virStorage= Source *src) return -1; } - if (src->dataFileStore->dataFileStore || src->backingStore) { + if (src->dataFileStore->dataFileStore || src->dataFileStore->backi= ngStore) { virReportError(VIR_ERR_XML_ERROR, "%s", _("The of can't have anoth= er nested or element")); return -1; diff --git a/tests/qemuxmlconfdata/disk-qcow2-datafile-store.x86_64-latest.= args b/tests/qemuxmlconfdata/disk-qcow2-datafile-store.x86_64-latest.args index 5a64246af6..74f2d1a090 100644 --- a/tests/qemuxmlconfdata/disk-qcow2-datafile-store.x86_64-latest.args +++ b/tests/qemuxmlconfdata/disk-qcow2-datafile-store.x86_64-latest.args @@ -27,25 +27,32 @@ XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUG= uest1/.config \ -no-shutdown \ -boot strict=3Don \ -device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ --blockdev '{"driver":"file","filename":"/tmp/data-file-store","node-name":= "libvirt-9-storage","read-only":false}' \ --blockdev '{"driver":"nbd","server":{"type":"unix","path":"/path/to/sock"}= ,"export":"Volume2/Image","node-name":"libvirt-8-storage","auto-read-only":= true,"discard":"unmap"}' \ +-blockdev '{"driver":"file","filename":"/tmp/data-file-store","node-name":= "libvirt-13-storage","read-only":false}' \ +-blockdev '{"driver":"nbd","server":{"type":"unix","path":"/path/to/sock"}= ,"export":"Volume2/Image","node-name":"libvirt-12-storage","auto-read-only"= :true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-12-format","read-only":false,"driver":"qc= ow2","data-file":"libvirt-13-storage","file":"libvirt-12-storage"}' \ +-device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x2","drive":"li= bvirt-12-format","id":"virtio-disk0","bootindex":1}' \ +-blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","no= de-name":"libvirt-11-storage","read-only":false}' \ +-blockdev '{"driver":"nbd","server":{"type":"unix","path":"/var/run/nbdsoc= k"},"export":"bar","node-name":"libvirt-10-storage","auto-read-only":true,"= discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-10-format","read-only":false,"driver":"qc= ow2","data-file":"libvirt-11-storage","file":"libvirt-10-storage"}' \ +-device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x3","drive":"li= bvirt-10-format","id":"virtio-disk1"}' \ +-blockdev '{"driver":"nbd","server":{"type":"unix","path":"/path/to/sock/d= atafile"},"export":"Volume2/ImageDataFile","node-name":"libvirt-9-storage",= "read-only":false}' \ +-blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/rhel7.1484= 071879","node-name":"libvirt-8-storage","auto-read-only":true,"discard":"un= map"}' \ -blockdev '{"node-name":"libvirt-8-format","read-only":false,"driver":"qco= w2","data-file":"libvirt-9-storage","file":"libvirt-8-storage"}' \ --device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x2","drive":"li= bvirt-8-format","id":"virtio-disk0","bootindex":1}' \ --blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","no= de-name":"libvirt-7-storage","read-only":false}' \ --blockdev '{"driver":"nbd","server":{"type":"unix","path":"/var/run/nbdsoc= k"},"export":"bar","node-name":"libvirt-6-storage","auto-read-only":true,"d= iscard":"unmap"}' \ --blockdev '{"node-name":"libvirt-6-format","read-only":false,"driver":"qco= w2","data-file":"libvirt-7-storage","file":"libvirt-6-storage"}' \ --device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x3","drive":"li= bvirt-6-format","id":"virtio-disk1"}' \ --blockdev '{"driver":"nbd","server":{"type":"unix","path":"/path/to/sock/d= atafile"},"export":"Volume2/ImageDataFile","node-name":"libvirt-5-storage",= "read-only":false}' \ --blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/rhel7.1484= 071879","node-name":"libvirt-4-storage","auto-read-only":true,"discard":"un= map"}' \ --blockdev '{"node-name":"libvirt-4-format","read-only":false,"driver":"qco= w2","data-file":"libvirt-5-storage","file":"libvirt-4-storage"}' \ --device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x4","drive":"li= bvirt-4-format","id":"virtio-disk2"}' \ --blockdev '{"driver":"file","filename":"/tmp/data-file-store-2","node-name= ":"libvirt-3-storage","read-only":true}' \ --blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/rhel7.1484= 071877","node-name":"libvirt-2-storage","auto-read-only":true,"discard":"un= map"}' \ --blockdev '{"node-name":"libvirt-2-format","read-only":true,"driver":"qcow= 2","data-file":"libvirt-3-storage","file":"libvirt-2-storage"}' \ --blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/rhel7.1484= 071880","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"un= map"}' \ --blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"qco= w2","file":"libvirt-1-storage","backing":"libvirt-2-format"}' \ --device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x5","drive":"li= bvirt-1-format","id":"virtio-disk3"}' \ +-device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x4","drive":"li= bvirt-8-format","id":"virtio-disk2"}' \ +-blockdev '{"driver":"file","filename":"/tmp/data-file-store-2","node-name= ":"libvirt-7-storage","read-only":true}' \ +-blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/rhel7.1484= 071877","node-name":"libvirt-6-storage","auto-read-only":true,"discard":"un= map"}' \ +-blockdev '{"node-name":"libvirt-6-format","read-only":true,"driver":"qcow= 2","data-file":"libvirt-7-storage","file":"libvirt-6-storage"}' \ +-blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/rhel7.1484= 071880","node-name":"libvirt-5-storage","auto-read-only":true,"discard":"un= map"}' \ +-blockdev '{"node-name":"libvirt-5-format","read-only":false,"driver":"qco= w2","file":"libvirt-5-storage","backing":"libvirt-6-format"}' \ +-device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x5","drive":"li= bvirt-5-format","id":"virtio-disk3"}' \ +-blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/datastore_= 1","aio":"native","node-name":"libvirt-4-storage","read-only":true,"discard= ":"unmap","cache":{"direct":true,"no-flush":false}}' \ +-blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/base-with-= data-file.qcow","aio":"native","node-name":"libvirt-3-storage","auto-read-o= nly":true,"discard":"unmap","cache":{"direct":true,"no-flush":false}}' \ +-blockdev '{"node-name":"libvirt-3-format","read-only":true,"discard":"unm= ap","cache":{"direct":true,"no-flush":false},"driver":"qcow2","data-file":"= libvirt-4-storage","file":"libvirt-3-storage"}' \ +-blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/datastore_= 2","aio":"native","node-name":"libvirt-2-storage","read-only":false,"discar= d":"unmap","cache":{"direct":true,"no-flush":false}}' \ +-blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/datastore.= qcow2","aio":"native","node-name":"libvirt-1-storage","auto-read-only":true= ,"discard":"unmap","cache":{"direct":true,"no-flush":false}}' \ +-blockdev '{"node-name":"libvirt-1-format","read-only":false,"discard":"un= map","cache":{"direct":true,"no-flush":false},"driver":"qcow2","data-file":= "libvirt-2-storage","file":"libvirt-1-storage","backing":"libvirt-3-format"= }' \ +-device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x6","drive":"li= bvirt-1-format","id":"virtio-disk4","write-cache":"on"}' \ -audiodev '{"id":"audio1","driver":"none"}' \ --device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x6"}' \ +-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x7"}' \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ -msg timestamp=3Don diff --git a/tests/qemuxmlconfdata/disk-qcow2-datafile-store.x86_64-latest.= xml b/tests/qemuxmlconfdata/disk-qcow2-datafile-store.x86_64-latest.xml index a026749faf..a4bfcb29e0 100644 --- a/tests/qemuxmlconfdata/disk-qcow2-datafile-store.x86_64-latest.xml +++ b/tests/qemuxmlconfdata/disk-qcow2-datafile-store.x86_64-latest.xml @@ -69,6 +69,26 @@
+ + + + + + + + + + + + + + + + + + +
+
@@ -77,7 +97,7 @@