From nobody Mon Feb 9 08:31:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1565963700; cv=none; d=zoho.com; s=zohoarc; b=VE26KbbVmtcsflim8E0zo+DTNnz9PKG2IkwCEKkietgksLTTdMv5aFaI2nhi3emn+Sl0ri3sSSYi4b7/6JlO0xIgWU+rs9TCygnc/D+CvJH6cHFjxWKV0CYNd0OoQRzISq/yR993g4WbEFlvMUsPmVDU8oTqZFjmeryN66i13Uc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565963700; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=zSPoCFzbo5RUmd5y13a5t4NEHiSQFQxhGm9ilFFfmlY=; b=Yrt80CPdTM7qPnGnEVvE1UVnbYIjQmUM8Vgk7Jz1na0VRsrk+quovNsFcOuM5yslDD6BZby433UggWSV4/q1SOM9+UZKtPej6p2OLTZVeme3EuOMjT3vBQs4eSega+YteXXXMU1vP6X8qS/ViKiC0cwUUghXgE8nWdtCyAxnsOw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 156596370052044.14522417682258; Fri, 16 Aug 2019 06:55:00 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2AC4C1108; Fri, 16 Aug 2019 13:54:59 +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 E226D1001B03; Fri, 16 Aug 2019 13:54:58 +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 A4131180B536; Fri, 16 Aug 2019 13:54:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x7GDsrsO029120 for ; Fri, 16 Aug 2019 09:54:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id AB6121001B12; Fri, 16 Aug 2019 13:54:53 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 10C6910013A7; Fri, 16 Aug 2019 13:54:52 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 16 Aug 2019 15:54:39 +0200 Message-Id: <91dab78b3b982c68c6a75203b9f077a1ff332618.1565963616.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 05/10] qemu: Split out preparing of single snapshot from qemuDomainSnapshotDiskDataCollect 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 16 Aug 2019 13:54:59 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Move the internals into qemuDomainSnapshotDiskDataCollectOne to make it obvious what's happening after moving more code here. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 104 +++++++++++++++++++++++------------------ 1 file changed, 59 insertions(+), 45 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 52540eb77d..57d864cdd2 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15316,6 +15316,62 @@ qemuDomainSnapshotDiskDataCleanup(qemuDomainSnapsh= otDiskDataPtr data, } +static int +qemuDomainSnapshotDiskDataCollectOne(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virDomainDiskDefPtr disk, + virDomainSnapshotDiskDefPtr snapdisk, + qemuDomainSnapshotDiskDataPtr dd, + bool reuse) +{ + char *backingStoreStr; + virDomainDiskDefPtr persistdisk; + + dd->disk =3D disk; + + if (!(dd->src =3D virStorageSourceCopy(snapdisk->src, false))) + return -1; + + if (virStorageSourceInitChainElement(dd->src, dd->disk->src, false) < = 0) + return -1; + + /* modify disk in persistent definition only when the source is the sa= me */ + if (vm->newDef && + (persistdisk =3D virDomainDiskByName(vm->newDef, dd->disk->dst, fa= lse)) && + virStorageSourceIsSameLocation(dd->disk->src, persistdisk->src)) { + + dd->persistdisk =3D persistdisk; + + if (!(dd->persistsrc =3D virStorageSourceCopy(dd->src, false))) + return -1; + + if (virStorageSourceInitChainElement(dd->persistsrc, + dd->persistdisk->src, false) = < 0) + return -1; + } + + if (qemuDomainStorageFileInit(driver, vm, dd->src, NULL) < 0) + return -1; + + dd->initialized =3D true; + + /* relative backing store paths need to be updated so that relative + * block commit still works */ + if (reuse) { + if (virStorageFileGetBackingStoreStr(dd->src, &backingStoreStr) < = 0) + return -1; + if (backingStoreStr !=3D NULL) { + if (virStorageIsRelative(backingStoreStr)) + VIR_STEAL_PTR(dd->relPath, backingStoreStr); + else + VIR_FREE(backingStoreStr); + } + } + + return 0; +} + + /** * qemuDomainSnapshotDiskDataCollect: * @@ -15333,10 +15389,7 @@ qemuDomainSnapshotDiskDataCollect(virQEMUDriverPtr= driver, size_t i; qemuDomainSnapshotDiskDataPtr data; size_t ndata =3D 0; - qemuDomainSnapshotDiskDataPtr dd; - char *backingStoreStr; virDomainSnapshotDefPtr snapdef =3D virDomainSnapshotObjGetDef(snap); - virDomainDiskDefPtr persistdisk; int ret =3D -1; if (VIR_ALLOC_N(data, snapdef->ndisks) < 0) @@ -15346,49 +15399,10 @@ qemuDomainSnapshotDiskDataCollect(virQEMUDriverPt= r driver, if (snapdef->disks[i].snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION= _NONE) continue; - dd =3D data + ndata; - ndata++; - - dd->disk =3D vm->def->disks[i]; - - if (!(dd->src =3D virStorageSourceCopy(snapdef->disks[i].src, fals= e))) - goto cleanup; - - if (virStorageSourceInitChainElement(dd->src, dd->disk->src, false= ) < 0) + if (qemuDomainSnapshotDiskDataCollectOne(driver, vm, vm->def->disk= s[i], + snapdef->disks + i, + data + ndata++, reuse) < = 0) goto cleanup; - - /* modify disk in persistent definition only when the source is th= e same */ - if (vm->newDef && - (persistdisk =3D virDomainDiskByName(vm->newDef, dd->disk->dst= , false)) && - virStorageSourceIsSameLocation(dd->disk->src, persistdisk->src= )) { - - dd->persistdisk =3D persistdisk; - - if (!(dd->persistsrc =3D virStorageSourceCopy(dd->src, false))) - goto cleanup; - - if (virStorageSourceInitChainElement(dd->persistsrc, - dd->persistdisk->src, fal= se) < 0) - goto cleanup; - } - - if (qemuDomainStorageFileInit(driver, vm, dd->src, NULL) < 0) - goto cleanup; - - dd->initialized =3D true; - - /* relative backing store paths need to be updated so that relative - * block commit still works */ - if (reuse) { - if (virStorageFileGetBackingStoreStr(dd->src, &backingStoreStr= ) < 0) - goto cleanup; - if (backingStoreStr !=3D NULL) { - if (virStorageIsRelative(backingStoreStr)) - VIR_STEAL_PTR(dd->relPath, backingStoreStr); - else - VIR_FREE(backingStoreStr); - } - } } VIR_STEAL_PTR(*rdata, data); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list