From nobody Thu May 15 10:02:46 2025 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1511348247760961.8739704443153; Wed, 22 Nov 2017 02:57:27 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3C4348553E; Wed, 22 Nov 2017 10:57:25 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3B515620A2; Wed, 22 Nov 2017 10:57:24 +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 4747F4BB79; Wed, 22 Nov 2017 10:57:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vAMAvMOu013020 for ; Wed, 22 Nov 2017 05:57:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id 390005D973; Wed, 22 Nov 2017 10:57:22 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 735445D970; Wed, 22 Nov 2017 10:57:21 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 22 Nov 2017 11:56:44 +0100 Message-Id: <8e4def0326295efb672aafa0ee290ecff7db691c.1511348086.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH v2 01/11] qemu: Move snapshot disk validation functions into one 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 22 Nov 2017 10:57:26 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Move the code so that both the new image and old image can be verified in the same function. --- src/qemu/qemu_driver.c | 91 ++++++++++++++++++++--------------------------= ---- 1 file changed, 36 insertions(+), 55 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 3a0e3b6cec..f830384a72 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -13945,17 +13945,19 @@ qemuDomainSnapshotCreateActiveInternal(virConnect= Ptr conn, static int -qemuDomainSnapshotPrepareDiskExternalBackingInactive(virDomainDiskDefPtr d= isk) +qemuDomainSnapshotPrepareDiskExternalInactive(virDomainSnapshotDiskDefPtr = snapdisk, + virDomainDiskDefPtr domdisk) { - int actualType =3D virStorageSourceGetActualType(disk->src); + int domDiskType =3D virStorageSourceGetActualType(domdisk->src); + int snapDiskType =3D virStorageSourceGetActualType(snapdisk->src); - switch ((virStorageType) actualType) { + switch ((virStorageType) domDiskType) { case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_FILE: - return 0; + break; case VIR_STORAGE_TYPE_NETWORK: - switch ((virStorageNetProtocol) disk->src->protocol) { + switch ((virStorageNetProtocol) domdisk->src->protocol) { case VIR_STORAGE_NET_PROTOCOL_NONE: case VIR_STORAGE_NET_PROTOCOL_NBD: case VIR_STORAGE_NET_PROTOCOL_RBD: @@ -13973,7 +13975,7 @@ qemuDomainSnapshotPrepareDiskExternalBackingInactiv= e(virDomainDiskDefPtr disk) virReportError(VIR_ERR_INTERNAL_ERROR, _("external inactive snapshots are not supporte= d on " "'network' disks using '%s' protocol"), - virStorageNetProtocolTypeToString(disk->src->pr= otocol)); + virStorageNetProtocolTypeToString(domdisk->src-= >protocol)); return -1; } break; @@ -13984,7 +13986,23 @@ qemuDomainSnapshotPrepareDiskExternalBackingInacti= ve(virDomainDiskDefPtr disk) case VIR_STORAGE_TYPE_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, _("external inactive snapshots are not supported on= " - "'%s' disks"), virStorageTypeToString(actualType)= ); + "'%s' disks"), virStorageTypeToString(domDiskType= )); + return -1; + } + + switch ((virStorageType) snapDiskType) { + case VIR_STORAGE_TYPE_BLOCK: + case VIR_STORAGE_TYPE_FILE: + break; + + case VIR_STORAGE_TYPE_NETWORK: + case VIR_STORAGE_TYPE_DIR: + case VIR_STORAGE_TYPE_VOLUME: + case VIR_STORAGE_TYPE_NONE: + case VIR_STORAGE_TYPE_LAST: + virReportError(VIR_ERR_INTERNAL_ERROR, + _("external inactive snapshots are not supported on= " + "'%s' disks"), virStorageTypeToString(snapDiskTyp= e)); return -1; } @@ -13993,33 +14011,27 @@ qemuDomainSnapshotPrepareDiskExternalBackingInact= ive(virDomainDiskDefPtr disk) static int -qemuDomainSnapshotPrepareDiskExternalBackingActive(virDomainDiskDefPtr dis= k) +qemuDomainSnapshotPrepareDiskExternalActive(virDomainSnapshotDiskDefPtr sn= apdisk, + virDomainDiskDefPtr domdisk) { - if (disk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_LUN) { + int actualType =3D virStorageSourceGetActualType(snapdisk->src); + + if (domdisk->device =3D=3D VIR_DOMAIN_DISK_DEVICE_LUN) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("external active snapshots are not supported on s= csi " "passthrough devices")); return -1; } - return 0; -} - - -static int -qemuDomainSnapshotPrepareDiskExternalOverlayActive(virDomainSnapshotDiskDe= fPtr disk) -{ - int actualType =3D virStorageSourceGetActualType(disk->src); - switch ((virStorageType) actualType) { case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_FILE: - return 0; + break; case VIR_STORAGE_TYPE_NETWORK: - switch ((virStorageNetProtocol) disk->src->protocol) { + switch ((virStorageNetProtocol) snapdisk->src->protocol) { case VIR_STORAGE_NET_PROTOCOL_GLUSTER: - return 0; + break; case VIR_STORAGE_NET_PROTOCOL_NONE: case VIR_STORAGE_NET_PROTOCOL_NBD: @@ -14037,7 +14049,7 @@ qemuDomainSnapshotPrepareDiskExternalOverlayActive(= virDomainSnapshotDiskDefPtr d virReportError(VIR_ERR_INTERNAL_ERROR, _("external active snapshots are not supported = on " "'network' disks using '%s' protocol"), - virStorageNetProtocolTypeToString(disk->src->pr= otocol)); + virStorageNetProtocolTypeToString(snapdisk->src= ->protocol)); return -1; } @@ -14057,31 +14069,6 @@ qemuDomainSnapshotPrepareDiskExternalOverlayActive= (virDomainSnapshotDiskDefPtr d } -static int -qemuDomainSnapshotPrepareDiskExternalOverlayInactive(virDomainSnapshotDisk= DefPtr disk) -{ - int actualType =3D virStorageSourceGetActualType(disk->src); - - switch ((virStorageType) actualType) { - case VIR_STORAGE_TYPE_BLOCK: - case VIR_STORAGE_TYPE_FILE: - return 0; - - case VIR_STORAGE_TYPE_NETWORK: - case VIR_STORAGE_TYPE_DIR: - case VIR_STORAGE_TYPE_VOLUME: - case VIR_STORAGE_TYPE_NONE: - case VIR_STORAGE_TYPE_LAST: - virReportError(VIR_ERR_INTERNAL_ERROR, - _("external inactive snapshots are not supported on= " - "'%s' disks"), virStorageTypeToString(actualType)= ); - return -1; - } - - return 0; -} - - static int qemuDomainSnapshotPrepareDiskExternal(virConnectPtr conn, virDomainDiskDefPtr disk, @@ -14099,16 +14086,10 @@ qemuDomainSnapshotPrepareDiskExternal(virConnectP= tr conn, if (virStorageTranslateDiskSourcePool(conn, disk) < 0) return -1; - if (qemuDomainSnapshotPrepareDiskExternalBackingInactive(disk) < 0) - return -1; - - if (qemuDomainSnapshotPrepareDiskExternalOverlayInactive(snapdisk)= < 0) + if (qemuDomainSnapshotPrepareDiskExternalInactive(snapdisk, disk) = < 0) return -1; } else { - if (qemuDomainSnapshotPrepareDiskExternalBackingActive(disk) < 0) - return -1; - - if (qemuDomainSnapshotPrepareDiskExternalOverlayActive(snapdisk) <= 0) + if (qemuDomainSnapshotPrepareDiskExternalActive(snapdisk, disk) < = 0) return -1; } --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list