From nobody Mon Feb 9 02:55:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1579533145; cv=none; d=zohomail.com; s=zohoarc; b=f7rUzn9gz+/a1wRgDZFDgPAawW1WdM5gaIQw2Vc4gioT9D5AVM/kv++LbRbHfAovluxwhEr5ai6d3LoPiPM0P5SS0u7bNEkYO8VxD2DM+Im8OUxpPChkD7HENcLVq6b5DlNEtiSITqziOQV+yjtWImJewqhutUznLTtqPKMaqNw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579533145; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=mnOsD/nOvWaEZyKtp/+cgvtE1bBOJ47p/vEeQDfiSik=; b=a2oYrY0csNx2VuJ9jFipxH+1ftVek269Jv502YOYZ3Ulns0KwvIpGirki9p3FCSVSn7u7kP6jo51RbbVP/qXnMXi3pAvyFqszXFGQJnm9q6/mX4t823JsoFh28nG2RT3KsQyH+qsea96D1j7ACr4YZvDwhaN97Fq5Dsd85mlLao= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1579533145349120.91606554767361; Mon, 20 Jan 2020 07:12:25 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-234-EePVmq_gNKivvCw6z3Tuzg-1; Mon, 20 Jan 2020 10:12:22 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 512DF8010D7; Mon, 20 Jan 2020 15:12:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 23FC58CCC0; Mon, 20 Jan 2020 15:12:17 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B5E7018089CF; Mon, 20 Jan 2020 15:12:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00KFC8Pv019755 for ; Mon, 20 Jan 2020 10:12:08 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2905A48; Mon, 20 Jan 2020 15:12:08 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id A512E858BE for ; Mon, 20 Jan 2020 15:12:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579533144; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=mnOsD/nOvWaEZyKtp/+cgvtE1bBOJ47p/vEeQDfiSik=; b=e51r0+Dx+O+rV0pdL5ZPEDMTYpfa2OJiF4jEpl9op8FR0YiDEuVmp93BDc/ZD+GQCZ9wYL pBnxGovDo/jJ2DmKuEqA4S2ZD4SiW6HQEihBQBLux7z3LLQR1ylSKSv0prRaq9BrwYAc7G n7VjFdFE/5p9X2o9qp1QyaOHeqjebsw= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH] qemu: snapshot: Prevent too-nested domain XML when doing inactive snapshot Date: Mon, 20 Jan 2020 16:12:06 +0100 Message-Id: <1ea227fdc5d54286e7a7bc52c6ad384628088afe.1579533126.git.pkrempa@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: EePVmq_gNKivvCw6z3Tuzg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Similarly to 510d154a0b41aa70aadabc0918d16dee22882394 we need to prevent doing too deeply nested backing chains and reject them with a sane error message. Add a loop to go through the snapshots prior to attempting actually creating them to prevent some possible inconsistent scenarios. Signed-off-by: Peter Krempa --- src/qemu/qemu_driver.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 2f66d7cd9a..4cebb54913 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14618,6 +14618,16 @@ qemuDomainSnapshotCreateInactiveExternal(virQEMUDr= iverPtr driver, if (!(created =3D virBitmapNew(snapdef->ndisks))) goto cleanup; + for (i =3D 0; i < snapdef->ndisks && !reuse; i++) { + snapdisk =3D &(snapdef->disks[i]); + defdisk =3D snapdef->parent.dom->disks[snapdisk->idx]; + if (snapdisk->snapshot !=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) + continue; + + if (qemuDomainStorageSourceValidateDepth(defdisk->src, 1, defdisk-= >dst) < 0) + return -1; + } + /* If reuse is true, then qemuDomainSnapshotPrepare already * ensured that the new files exist, and it was up to the user to * create them correctly. */ --=20 2.24.1