From nobody Tue Apr 23 09:49:27 2024 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=1565963694; cv=none; d=zoho.com; s=zohoarc; b=cY9YG1MNLPI/QmWxG7XOzC/XawKkSBvVfncxofE4vl3dDm40o3F3xF9LiiS6CbnT/n9H+yDJ2rkspXl9A9frmV2VGfDC4WSBrUbJntrv/uoaAnZlFDplCfLvNEdAemRCcEG0ueWb2MS3oBf8vKFKOSeWDsZAsUMus0U1fc7ZE2g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565963694; 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=8uBjpu3X9EXwWNPAtxQS5w5qnbN7Rukb3KBtLaq7+EM=; b=CisdWGqH/lxGq67geITnP7PfBhT3RS5UxUjs1/I1MKMAhRFD6dyDBVC4o8eyKSThTHzLOYY1YnmO86VVQg6yhoz9BRtGXX75bxVCttWxXS5zu3TwNsZ/3ZQoFvEuOmkgAO4e5rN46uTubhpRjPoGZS6hfCySn2eIirar/3CWXls= 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 1565963694029134.8507320430465; Fri, 16 Aug 2019 06:54:54 -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 BDD5C12BB; Fri, 16 Aug 2019 13:54:52 +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 998381001B02; Fri, 16 Aug 2019 13:54:52 +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 5E45D24F33; Fri, 16 Aug 2019 13:54:52 +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 x7GDsncJ029080 for ; Fri, 16 Aug 2019 09:54:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id DDDC61001B03; Fri, 16 Aug 2019 13:54:49 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4395110013A7; Fri, 16 Aug 2019 13:54:49 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 16 Aug 2019 15:54:35 +0200 Message-Id: <60b2450d021ba056bb000427b818772cf3645933.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 01/10] qemu: snapshot: Don't modify persistent XML if disk source is different 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:53 +0000 (UTC) Content-Type: text/plain; charset="utf-8" While the VM is running the persistent source of a disk might differ e.g. as the 'newDef' was redefined. Our snapshot code would blindly rewrite the source of such disk if it shared the 'target'. Fix this by checking whether the source is the same in the first place. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 11f97dbc65..b6fbb197b8 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15332,6 +15332,7 @@ qemuDomainSnapshotDiskDataCollect(virQEMUDriverPtr = driver, qemuDomainSnapshotDiskDataPtr dd; char *backingStoreStr; virDomainSnapshotDefPtr snapdef =3D virDomainSnapshotObjGetDef(snap); + virDomainDiskDefPtr persistdisk; int ret =3D -1; if (VIR_ALLOC_N(data, snapdef->ndisks) < 0) @@ -15352,13 +15353,12 @@ qemuDomainSnapshotDiskDataCollect(virQEMUDriverPt= r driver, if (virStorageSourceInitChainElement(dd->src, dd->disk->src, false= ) < 0) goto cleanup; - /* Note that it's unsafe to assume that the disks in the persistent - * definition match up with the disks in the live definition just = by - * checking that the target name is the same. We've done that - * historically this way though. */ + /* modify disk in persistent definition only when the source is th= e same */ if (vm->newDef && - (dd->persistdisk =3D virDomainDiskByName(vm->newDef, dd->disk-= >dst, - false))) { + (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; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 09:49:27 2024 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=1565963697; cv=none; d=zoho.com; s=zohoarc; b=akTd4H4yLfFfWm4GNv5GamEAPkmybe9kz6X8lujeTI3pCsBH0DwqeYuJQcIY+aSJpf+jkkve7NkBwOyFZ18rJQbDZrauVtwN8GACmHpa2ZDovGGuKlbaT4ZrQdAERwx/0idS/W/aECqVx4YXtJ4+GFu66Qf3jdCFcYLUJwc1058= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565963697; 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=u0eNsfeVlM2PP+GULPD43h6OmjizV/pE91vLHx5UJto=; b=bS2QcAPn3/fOFh14sr9lsuDYQO/2XjBfJ09RUy/Jygbi94zdbYNqP2x4l3NwwpNYW1Shp/z0y2nx3UnwJEUpRaHbEwSDLZo7HRF/o3iGEWQoOuEYXCsWvm3bAo7Is/em5PvId4PfLQK3LXdbuWqKTIDU/D/AN4ufx65PcOmnDLY= 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 1565963697511908.5570246257352; Fri, 16 Aug 2019 06:54:57 -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 57FCB80F91; Fri, 16 Aug 2019 13:54:56 +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 35A751001B0F; Fri, 16 Aug 2019 13:54:56 +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 F3357180B536; Fri, 16 Aug 2019 13:54:55 +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 x7GDsoRD029095 for ; Fri, 16 Aug 2019 09:54:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id D16351001B03; Fri, 16 Aug 2019 13:54:50 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 36ABF10013A7; Fri, 16 Aug 2019 13:54:50 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 16 Aug 2019 15:54:36 +0200 Message-Id: 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 02/10] qemu: driver: Remove dead code from qemuDomainSnapshotUpdateDiskSources 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.27]); Fri, 16 Aug 2019 13:54:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" dd->src is always allocated in this function as it contains the new source for the snapshot which is meant to replace the disk source. The label handling code executed if that source was not present thus is dead code. Remove it. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b6fbb197b8..913b57855c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15421,13 +15421,6 @@ qemuDomainSnapshotUpdateDiskSources(virQEMUDriverP= tr driver, virDomainObjPtr vm, qemuDomainSnapshotDiskDataPtr dd) { - if (!dd->src) { - /* Remove old metadata */ - if (qemuSecurityMoveImageMetadata(driver, vm, dd->disk->src, NULL)= < 0) - VIR_WARN("Unable to remove disk metadata on vm %s", vm->def->n= ame); - return; - } - /* storage driver access won'd be needed */ if (dd->initialized) virStorageFileDeinit(dd->src); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 09:49:27 2024 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=1565963701; cv=none; d=zoho.com; s=zohoarc; b=LHmjE1v0AiVaPSM/TIxReAu3eEfjka9cWv2yx9+uEkAFLaZrmoyYf3ArPMNMH3w/ec5iwuvZ8KtekBxx2XodOTQyoY6jbvd6HeYXaqmzlYMmAL5ra40Z5nENBcBgD2mHE5uLD6Uz1kVi4RnZxfvN67igTE/YhQDksE9yt85/+bg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565963701; 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=vfmci8JR+DvSPF5a4rP/TUbWwAv14jeF0Ls0Fk1Ci4Q=; b=B7XT8kdTtkbSroMa+INLUEVmHnxTqRJiG6sk/lyl1Hl8Qd/fby/NtK5zAfyxkMkcMQjMzI6GDW6z21GEIwo1aXM2ofq1KpO7cfv25vi7dwXP932MGDgRl5wdpjW980a3lKU5WzIQLBid9Fpg5UTVJEpEkAA5qquLbBlN3fVQ7ts= 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 1565963701164415.50128506394867; Fri, 16 Aug 2019 06:55:01 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C888D3090FD5; 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 A3E908F6DE; Fri, 16 Aug 2019 13:54:59 +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 69D5C180B536; Fri, 16 Aug 2019 13:54:59 +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 x7GDspqv029101 for ; Fri, 16 Aug 2019 09:54:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id C4F0A1001B02; Fri, 16 Aug 2019 13:54:51 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A11210013A7; Fri, 16 Aug 2019 13:54:51 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 16 Aug 2019 15:54:37 +0200 Message-Id: <237d5c8c94fd5872a4396c4b4340da9cf02979de.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 03/10] qemu: Remove cleanup label in qemuDomainSnapshotPrepareDiskExternal 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.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Fri, 16 Aug 2019 13:55:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Refactor the code to avoid having a cleanup label. This will simplify the change necessary when restricting this check in an upcoming patch. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 913b57855c..29a47af0a2 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14997,8 +14997,9 @@ qemuDomainSnapshotPrepareDiskExternal(virDomainDisk= DefPtr disk, bool active, bool reuse) { - int ret =3D -1; struct stat st; + int err; + int rc; if (disk->src->readonly) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -15024,31 +15025,32 @@ qemuDomainSnapshotPrepareDiskExternal(virDomainDi= skDefPtr disk, if (virStorageFileInit(snapdisk->src) < 0) return -1; - if (virStorageFileStat(snapdisk->src, &st) < 0) { - if (errno !=3D ENOENT) { - virReportSystemError(errno, + rc =3D virStorageFileStat(snapdisk->src, &st); + err =3D errno; + + virStorageFileDeinit(snapdisk->src); + + if (rc < 0) { + if (err !=3D ENOENT) { + virReportSystemError(err, _("unable to stat for disk %s: %s"), snapdisk->name, snapdisk->src->path); - goto cleanup; + return -1; } else if (reuse) { - virReportSystemError(errno, + virReportSystemError(err, _("missing existing file for disk %s: %s"= ), snapdisk->name, snapdisk->src->path); - goto cleanup; + return -1; } } else if (!S_ISBLK(st.st_mode) && st.st_size && !reuse) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("external snapshot file for disk %s already " "exists and is not a block device: %s"), snapdisk->name, snapdisk->src->path); - goto cleanup; + return -1; } - ret =3D 0; - - cleanup: - virStorageFileDeinit(snapdisk->src); - return ret; + return 0; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 09:49:27 2024 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=1565963696; cv=none; d=zoho.com; s=zohoarc; b=kPJ5GdLJkkM06e1srBeAEQdAcPzSdAYLv41+adYieF3dOkj+5gltWJ/9o3SYpTFHZI1qHvRZhbe+MbSXyn0S3hLjBTEOoMVMNXtN8p8BaoqW+yl7eyKrtgXt0Sj7V2eqPFMYSh2LkRC5WiymY8h43Lm83y/YJghLWEZoPe39czo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565963696; 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=ctL3USQGgwxNHfaTC8YuGJoXLl8b8XBjDklEb6YlZzM=; b=jAsdecNzxjUqB9ev82uQk7CuANxRzxDrekVquVWIAGiJPOJUkjdbTtqeaTz8MjV43HPZMQeyuyVi+UxZxPArXkVyzhg+LBC/rLRiZHF76vey9KOW6bd7Bajvj/IjE5mXxPtli789XI55St0yRQrnfbv+GeOp3yJxew5uSLqC5vU= 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 1565963696860478.08144492545546; Fri, 16 Aug 2019 06:54:56 -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 7DD60C08E284; Fri, 16 Aug 2019 13:54:55 +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 56F671001B0F; Fri, 16 Aug 2019 13:54:55 +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 1D49E4A486; Fri, 16 Aug 2019 13:54:55 +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 x7GDsqZx029113 for ; Fri, 16 Aug 2019 09:54:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id B77211001B0F; Fri, 16 Aug 2019 13:54:52 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D41110013A7; Fri, 16 Aug 2019 13:54:51 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 16 Aug 2019 15:54:38 +0200 Message-Id: <00e87cf12ef9337f3f5dc7bf3d11fe16792514dd.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 04/10] qemu: snapshot: Restrict file existance check only for local storage 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.31]); Fri, 16 Aug 2019 13:54:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Soon we'll allow more protocols and storage types with snapshots where we in some cases can't check whether the storage already exists. Restrict the sanity checks whether the destination images exist or not for local storage where it's easy. For any other case we will fail later. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 44 ++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 29a47af0a2..52540eb77d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15022,32 +15022,34 @@ qemuDomainSnapshotPrepareDiskExternal(virDomainDi= skDefPtr disk, return -1; } - if (virStorageFileInit(snapdisk->src) < 0) - return -1; + if (virStorageSourceIsLocalStorage(snapdisk->src)) { + if (virStorageFileInit(snapdisk->src) < 0) + return -1; - rc =3D virStorageFileStat(snapdisk->src, &st); - err =3D errno; + rc =3D virStorageFileStat(snapdisk->src, &st); + err =3D errno; - virStorageFileDeinit(snapdisk->src); + virStorageFileDeinit(snapdisk->src); - if (rc < 0) { - if (err !=3D ENOENT) { - virReportSystemError(err, - _("unable to stat for disk %s: %s"), - snapdisk->name, snapdisk->src->path); - return -1; - } else if (reuse) { - virReportSystemError(err, - _("missing existing file for disk %s: %s"= ), - snapdisk->name, snapdisk->src->path); + if (rc < 0) { + if (err !=3D ENOENT) { + virReportSystemError(err, + _("unable to stat for disk %s: %s"), + snapdisk->name, snapdisk->src->path); + return -1; + } else if (reuse) { + virReportSystemError(err, + _("missing existing file for disk %s:= %s"), + snapdisk->name, snapdisk->src->path); + return -1; + } + } else if (!S_ISBLK(st.st_mode) && st.st_size && !reuse) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("external snapshot file for disk %s already " + "exists and is not a block device: %s"), + snapdisk->name, snapdisk->src->path); return -1; } - } else if (!S_ISBLK(st.st_mode) && st.st_size && !reuse) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("external snapshot file for disk %s already " - "exists and is not a block device: %s"), - snapdisk->name, snapdisk->src->path); - return -1; } return 0; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 09:49:27 2024 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 From nobody Tue Apr 23 09:49:27 2024 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=1565963705; cv=none; d=zoho.com; s=zohoarc; b=j1FjhsZu+wPCKskVx5TqUSNLDZ012YbfviYLcyRMklJ0Iu7RvJS1uzixyR0jGfcyiywXkopMXgCmHmGZWwdFLa1VpxQG/SghLb4suyd9CPCcdWRtBE7lZ9KJLIUzO3bZozmBjdP6Y0xcYnBDRXWjxF5/AKaStrLNAuWvCv8ekjk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565963705; 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=sChjNiCBAM12KDq3224yaUdgy4NVdjNgvrY131BjMpI=; b=DgKlx93ug6bSgWyzW9IbJ2ZmdBgYOBoXOtUt3dnMnVkAliTa/8ZabFTB+LMQT0yPvLX7lz6hGQmaMfLg2AaKpvV4K17Tl4bNjQmGVWDaESC1OCtcbWxozF+OtXydhf9podF379KSOHMWzdEFIRem8mnyJPgNLBl9TKXjVRJnkQw= 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 156596370549327.974211365314886; Fri, 16 Aug 2019 06:55:05 -0700 (PDT) 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 DD52588309; Fri, 16 Aug 2019 13:55:03 +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 ABDF483E81; Fri, 16 Aug 2019 13:55:03 +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 56AC51C93; Fri, 16 Aug 2019 13:55:03 +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 x7GDsshh029125 for ; Fri, 16 Aug 2019 09:54:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9DA771001B17; Fri, 16 Aug 2019 13:54:54 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 037FE10013A7; Fri, 16 Aug 2019 13:54:53 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 16 Aug 2019 15:54:40 +0200 Message-Id: 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 06/10] qemu: Disband qemuDomainSnapshotCreateSingleDiskActive 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.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]); Fri, 16 Aug 2019 13:55:04 +0000 (UTC) Content-Type: text/plain; charset="utf-8" After we always assume support for the 'transaction' command (c358adc57113b) and follow-up cleanups qemuDomainSnapshotCreateSingleDiskActive lost it's value. Move the code into appropriate helpers and remove the function. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 53 ++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 33 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 57d864cdd2..9248f912d0 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15368,6 +15368,22 @@ qemuDomainSnapshotDiskDataCollectOne(virQEMUDriver= Ptr driver, } } + /* pre-create the image file so that we can label it before handing it= to qemu */ + if (!reuse && dd->src->type !=3D VIR_STORAGE_TYPE_BLOCK) { + if (virStorageFileCreate(dd->src) < 0) { + virReportSystemError(errno, _("failed to create image file '%s= '"), + NULLSTR(dd->src->path)); + return -1; + } + dd->created =3D true; + } + + /* set correct security, cgroup and locking options on the new image */ + if (qemuDomainStorageSourceAccessAllow(driver, vm, dd->src, false, tru= e) < 0) + return -1; + + dd->prepared =3D true; + return 0; } @@ -15463,36 +15479,6 @@ qemuDomainSnapshotUpdateDiskSources(virQEMUDriverP= tr driver, } -static int -qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver, - virDomainObjPtr vm, - qemuDomainSnapshotDiskDataPtr dd, - virJSONValuePtr actions, - bool reuse) -{ - if (qemuBlockSnapshotAddLegacy(actions, dd->disk, dd->src, reuse) < 0) - return -1; - - /* pre-create the image file so that we can label it before handing it= to qemu */ - if (!reuse && dd->src->type !=3D VIR_STORAGE_TYPE_BLOCK) { - if (virStorageFileCreate(dd->src) < 0) { - virReportSystemError(errno, _("failed to create image file '%s= '"), - NULLSTR(dd->src->path)); - return -1; - } - dd->created =3D true; - } - - /* set correct security, cgroup and locking options on the new image */ - if (qemuDomainStorageSourceAccessAllow(driver, vm, dd->src, false, tru= e) < 0) - return -1; - - dd->prepared =3D true; - - return 0; -} - - /* The domain is expected to be locked and active. */ static int qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver, @@ -15535,9 +15521,10 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPt= r driver, * VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL with a valid file name and * qcow2 format. */ for (i =3D 0; i < ndiskdata; i++) { - if (qemuDomainSnapshotCreateSingleDiskActive(driver, vm, - &diskdata[i], - actions, reuse) < 0) + if (qemuBlockSnapshotAddLegacy(actions, + diskdata[i].disk, + diskdata[i].src, + reuse) < 0) goto cleanup; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 09:49:27 2024 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=1565963709; cv=none; d=zoho.com; s=zohoarc; b=MtGMUGeVbUKW487O1poIc/TvoLL/lQEXmSXod2Mlj+z5GkFEd6UVwio2VEVxsVKtExAcQJ0H1JEJfniy96RuY0XyryU9FwDDE8G+Q5KcXlkwhli6aT0Kl1Ywht+SvN/Z7PcFr/J/SJSxB/nPg+guzbuwnpgduseRds/9kLshpHk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565963709; 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=obEtbxX/ypBMJv5Ntq1GeLtrQv0aQ3P53K7ZD6dy0hk=; b=B4dZLhst7UCq4pvLFOPiA/sR+UO6ulOlwSyl1ihCXX2SHTcP8tEmJZj+zIOfgAfk16aP2J47afrj1EJrZymW4pXuOJHupneq8Z3NUIACyMt+EqUV0tqZMb6gOyKQx5WPSgKQN2zZkZQ9pX/EMqdhcWOZjxJsOBPM8cnvC3qI1a0= 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 1565963709475512.4457564302545; Fri, 16 Aug 2019 06:55:09 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3EB88882EA; Fri, 16 Aug 2019 13:55:08 +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 0ECA48F6E0; Fri, 16 Aug 2019 13:55:08 +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 B1D3D25540; Fri, 16 Aug 2019 13:55:07 +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 x7GDstVb029139 for ; Fri, 16 Aug 2019 09:54:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 90F341001B03; Fri, 16 Aug 2019 13:54:55 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id EB12B10013A7; Fri, 16 Aug 2019 13:54:54 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 16 Aug 2019 15:54:41 +0200 Message-Id: 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 07/10] qemu: Merge conditions depending on the 'reuse' flag in qemuDomainSnapshotDiskDataCollectOne 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.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 16 Aug 2019 13:55:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 9248f912d0..0bbde4b52d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15366,16 +15366,16 @@ qemuDomainSnapshotDiskDataCollectOne(virQEMUDrive= rPtr driver, else VIR_FREE(backingStoreStr); } - } - - /* pre-create the image file so that we can label it before handing it= to qemu */ - if (!reuse && dd->src->type !=3D VIR_STORAGE_TYPE_BLOCK) { - if (virStorageFileCreate(dd->src) < 0) { - virReportSystemError(errno, _("failed to create image file '%s= '"), - NULLSTR(dd->src->path)); - return -1; + } else { + /* pre-create the image file so that we can label it before handin= g it to qemu */ + if (dd->src->type !=3D VIR_STORAGE_TYPE_BLOCK) { + if (virStorageFileCreate(dd->src) < 0) { + virReportSystemError(errno, _("failed to create image file= '%s'"), + NULLSTR(dd->src->path)); + return -1; + } + dd->created =3D true; } - dd->created =3D true; } /* set correct security, cgroup and locking options on the new image */ --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 09:49:27 2024 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=1565963714; cv=none; d=zoho.com; s=zohoarc; b=J4NrsMYDV5jyulZdDnttAz9XwIYgIPgiZLmajypJpGYcvd+IcvH8Cw+9LWj5WLQ5hZTqgLplUTlTRHoe+cQOSUKt4QEYOqzCP91JVPFHkVUE6bBLZqkB2aWyYDGbCqo8UptREazH0Y+6xX0MO85W0+tq1bJUbbf+PM5JDK9ygMY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565963714; 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=sN0dyKLuTWCIZWZMZ+wiPH7GbrXy4+cUwMiozkFdsuo=; b=UU7qQVSK0mQGEhTPYd6/k+lMjLJB1BZVC6MeHwEhPIJy21pIRF7bi5+oWhj5P0P14e63obwespXuubf2qAEIujEC+1iQT3URFqpxaLqFMaE5zOYZinK/NZjZLaqURZK9BU0pGoF5lvsoB1QNIa93B0mxmRxSBnbTsKlHFXBfj0Y= 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 1565963714025353.6436560397416; Fri, 16 Aug 2019 06:55:14 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id B179F300CB2B; Fri, 16 Aug 2019 13:55:12 +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 7C1D217996; Fri, 16 Aug 2019 13:55:12 +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 2F9912551F; Fri, 16 Aug 2019 13:55:12 +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 x7GDsuSK029151 for ; Fri, 16 Aug 2019 09:54:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 831281001B03; Fri, 16 Aug 2019 13:54:56 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id DDA681001B12; Fri, 16 Aug 2019 13:54:55 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 16 Aug 2019 15:54:42 +0200 Message-Id: <6cf96fe36fc890a3ab2b3b0d6c3306785dcdb373.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 08/10] qemu: snapshot: Skip overlay file creation/interogation if unsupported 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.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Fri, 16 Aug 2019 13:55:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" With blockdev we'll be able to support protocols which are not supported by the storage backends in libvirt. This means that we have to be able to skip the creation and relative storage path reading if it's not supported. This will make it impossible to use relative backing for network protocols but that would be almost insane anyways. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 53 ++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 0bbde4b52d..6e10b691e9 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15326,6 +15326,8 @@ qemuDomainSnapshotDiskDataCollectOne(virQEMUDriverP= tr driver, { char *backingStoreStr; virDomainDiskDefPtr persistdisk; + bool supportsCreate; + bool supportsBacking; dd->disk =3D disk; @@ -15350,31 +15352,38 @@ qemuDomainSnapshotDiskDataCollectOne(virQEMUDrive= rPtr driver, return -1; } - if (qemuDomainStorageFileInit(driver, vm, dd->src, NULL) < 0) - return -1; - - dd->initialized =3D true; + supportsCreate =3D virStorageFileSupportsCreate(dd->src); + supportsBacking =3D virStorageFileSupportsBackingChainTraversal(dd->sr= c); - /* relative backing store paths need to be updated so that relative - * block commit still works */ - if (reuse) { - if (virStorageFileGetBackingStoreStr(dd->src, &backingStoreStr) < = 0) + if (supportsCreate || supportsBacking) { + if (qemuDomainStorageFileInit(driver, vm, dd->src, NULL) < 0) return -1; - if (backingStoreStr !=3D NULL) { - if (virStorageIsRelative(backingStoreStr)) - VIR_STEAL_PTR(dd->relPath, backingStoreStr); - else - VIR_FREE(backingStoreStr); - } - } else { - /* pre-create the image file so that we can label it before handin= g it to qemu */ - if (dd->src->type !=3D VIR_STORAGE_TYPE_BLOCK) { - if (virStorageFileCreate(dd->src) < 0) { - virReportSystemError(errno, _("failed to create image file= '%s'"), - NULLSTR(dd->src->path)); - return -1; + + dd->initialized =3D true; + + /* relative backing store paths need to be updated so that relative + * block commit still works */ + if (reuse) { + if (supportsBacking) { + if (virStorageFileGetBackingStoreStr(dd->src, &backingStor= eStr) < 0) + return -1; + if (backingStoreStr !=3D NULL) { + if (virStorageIsRelative(backingStoreStr)) + VIR_STEAL_PTR(dd->relPath, backingStoreStr); + else + VIR_FREE(backingStoreStr); + } + } + } else { + /* pre-create the image file so that we can label it before ha= nding it to qemu */ + if (supportsCreate && dd->src->type !=3D VIR_STORAGE_TYPE_BLOC= K) { + if (virStorageFileCreate(dd->src) < 0) { + virReportSystemError(errno, _("failed to create image = file '%s'"), + NULLSTR(dd->src->path)); + return -1; + } + dd->created =3D true; } - dd->created =3D true; } } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 09:49:27 2024 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=1565963718; cv=none; d=zoho.com; s=zohoarc; b=g2XiG/YU/OeEDhP3NWGpigFt/Ov2R3FiOms4s6smKgSiMmtw1gidSXFhPXBhOcmQK8beRUHt8jtcQMErpQl79vx/hQLT/Ki30faf9uiMhXgR6O7m2REDpgQowhuaVPu/6WwgBnk/WOazVLA1VYNpUqOr5s8QDQssmZHU0gXECp8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565963718; 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=s2JI17zc3cz9W+rlQBDH1e9jPrGulxkjzI8EaGiE0pg=; b=Ui1D5LsGm09hhbbQpXIHBUg1pXjgEq3hObHfeBB9pTFwC3h1IhxL2ORSmC5icbtS9lxS71dHskTsv0OBHCz8SiW8BXjytrvAGdAvUqwqc/ko1jfHCJGjBR+Tyq+dcolWJm1I+r24leT8sb0MpTeGLC2GnLoghjvfzCrc+q27Uu4= 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 1565963718314344.1108445093921; Fri, 16 Aug 2019 06:55:18 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 223CAEC520; Fri, 16 Aug 2019 13:55: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 ECF4C1822C; Fri, 16 Aug 2019 13:55:16 +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 AE2C21800202; Fri, 16 Aug 2019 13:55:16 +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 x7GDsvLf029157 for ; Fri, 16 Aug 2019 09:54:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 76C641001B17; Fri, 16 Aug 2019 13:54:57 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id D0CD31001B03; Fri, 16 Aug 2019 13:54:56 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 16 Aug 2019 15:54:43 +0200 Message-Id: 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 09/10] qemu: Add -blockdev support for external snapshots 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.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 16 Aug 2019 13:55:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Use the code for creating or attaching new storage source in the snapshot code and switch to 'blockdev-snapshot' for creating the snapshot itself. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 104 ++++++++++++++++++++++++++++++++++------- 1 file changed, 88 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6e10b691e9..c22f74adaa 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15270,6 +15270,8 @@ struct _qemuDomainSnapshotDiskData { bool prepared; /* @src was prepared using qemuDomainStorageSourceAcces= sAllow */ virDomainDiskDefPtr disk; char *relPath; /* relative path component to fill into original disk */ + qemuBlockStorageSourceChainDataPtr crdata; + bool blockdevadded; virStorageSourcePtr persistsrc; virDomainDiskDefPtr persistdisk; @@ -15283,7 +15285,8 @@ static void qemuDomainSnapshotDiskDataCleanup(qemuDomainSnapshotDiskDataPtr data, size_t ndata, virQEMUDriverPtr driver, - virDomainObjPtr vm) + virDomainObjPtr vm, + qemuDomainAsyncJob asyncJob) { size_t i; @@ -15294,6 +15297,15 @@ qemuDomainSnapshotDiskDataCleanup(qemuDomainSnapsh= otDiskDataPtr data, /* on success of the snapshot the 'src' and 'persistsrc' propertie= s will * be set to NULL by qemuDomainSnapshotUpdateDiskSources */ if (data[i].src) { + if (data[i].blockdevadded) { + if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) = =3D=3D 0) { + + qemuBlockStorageSourceAttachRollback(qemuDomainGetMoni= tor(vm), + data[i].crdata->s= rcdata[0]); + ignore_value(qemuDomainObjExitMonitor(driver, vm)); + } + } + if (data[i].created && virStorageFileUnlink(data[i].src) < 0) { VIR_WARN("Unable to remove just-created %s", @@ -15312,6 +15324,7 @@ qemuDomainSnapshotDiskDataCleanup(qemuDomainSnapsho= tDiskDataPtr data, VIR_FREE(data[i].relPath); } + qemuBlockStorageSourceChainDataFree(data[i].crdata); VIR_FREE(data); } @@ -15319,15 +15332,20 @@ qemuDomainSnapshotDiskDataCleanup(qemuDomainSnaps= hotDiskDataPtr data, static int qemuDomainSnapshotDiskDataCollectOne(virQEMUDriverPtr driver, virDomainObjPtr vm, + virQEMUDriverConfigPtr cfg, virDomainDiskDefPtr disk, virDomainSnapshotDiskDefPtr snapdisk, qemuDomainSnapshotDiskDataPtr dd, - bool reuse) + bool reuse, + bool blockdev, + qemuDomainAsyncJob asyncJob) { + qemuDomainObjPrivatePtr priv =3D vm->privateData; char *backingStoreStr; virDomainDiskDefPtr persistdisk; bool supportsCreate; bool supportsBacking; + int rc; dd->disk =3D disk; @@ -15393,6 +15411,44 @@ qemuDomainSnapshotDiskDataCollectOne(virQEMUDriver= Ptr driver, dd->prepared =3D true; + if (blockdev) { + /* create a terminator for the snapsot disks so that qemu does not= try + * to open them at first */ + virObjectUnref(dd->src->backingStore); + if (!(dd->src->backingStore =3D virStorageSourceNew())) + return -1; + + if (qemuDomainPrepareStorageSourceBlockdev(dd->disk, dd->src, + priv, cfg) < 0) + return -1; + + if (!(dd->crdata =3D qemuBuildStorageSourceChainAttachPrepareBlock= devTop(dd->src, + = priv->qemuCaps))) + return -1; + + if (reuse) { + if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) + return -1; + + rc =3D qemuBlockStorageSourceAttachApply(qemuDomainGetMonitor(= vm), + dd->crdata->srcdata[0]); + + if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + return -1; + } else { + if (qemuBlockStorageSourceCreateDetectSize(vm, dd->src, dd->di= sk->src, + asyncJob) < 0) + return -1; + + if (qemuBlockStorageSourceCreate(vm, dd->src, dd->disk->src, + NULL, dd->crdata->srcdata[0], + asyncJob) < 0) + return -1; + } + + dd->blockdevadded =3D true; + } + return 0; } @@ -15407,7 +15463,10 @@ static int qemuDomainSnapshotDiskDataCollect(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainMomentObjPtr snap, + virQEMUDriverConfigPtr cfg, bool reuse, + bool blockdev, + qemuDomainAsyncJob asyncJob, qemuDomainSnapshotDiskDataPtr *rdata, size_t *rndata) { @@ -15424,9 +15483,10 @@ qemuDomainSnapshotDiskDataCollect(virQEMUDriverPtr= driver, if (snapdef->disks[i].snapshot =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION= _NONE) continue; - if (qemuDomainSnapshotDiskDataCollectOne(driver, vm, vm->def->disk= s[i], + if (qemuDomainSnapshotDiskDataCollectOne(driver, vm, cfg, vm->def-= >disks[i], snapdef->disks + i, - data + ndata++, reuse) < = 0) + data + ndata++, reuse, bl= ockdev, + asyncJob) < 0) goto cleanup; } @@ -15435,7 +15495,7 @@ qemuDomainSnapshotDiskDataCollect(virQEMUDriverPtr = driver, ret =3D 0; cleanup: - qemuDomainSnapshotDiskDataCleanup(data, ndata, driver, vm); + qemuDomainSnapshotDiskDataCleanup(data, ndata, driver, vm, asyncJob); return ret; } @@ -15456,13 +15516,15 @@ qemuDomainSnapshotUpdateDiskSourcesRenumber(virSt= orageSourcePtr src) * @driver: QEMU driver * @vm: domain object * @dd: snapshot disk data object + * @blockdev: -blockdev is in use for the VM * * Updates disk definition after a successful snapshot. */ static void qemuDomainSnapshotUpdateDiskSources(virQEMUDriverPtr driver, virDomainObjPtr vm, - qemuDomainSnapshotDiskDataPtr dd) + qemuDomainSnapshotDiskDataPtr dd, + bool blockdev) { /* storage driver access won'd be needed */ if (dd->initialized) @@ -15475,11 +15537,13 @@ qemuDomainSnapshotUpdateDiskSources(virQEMUDriver= Ptr driver, dd->disk->src->readonly =3D true; VIR_STEAL_PTR(dd->disk->src->relPath, dd->relPath); + virObjectUnref(dd->src->backingStore); VIR_STEAL_PTR(dd->src->backingStore, dd->disk->src); VIR_STEAL_PTR(dd->disk->src, dd->src); /* fix numbering of disks */ - qemuDomainSnapshotUpdateDiskSourcesRenumber(dd->disk->src); + if (!blockdev) + qemuDomainSnapshotUpdateDiskSourcesRenumber(dd->disk->src); if (dd->persistdisk) { VIR_STEAL_PTR(dd->persistsrc->backingStore, dd->persistdisk->src); @@ -15506,6 +15570,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr= driver, qemuDomainSnapshotDiskDataPtr diskdata =3D NULL; size_t ndiskdata =3D 0; virErrorPtr orig_err =3D NULL; + bool blockdev =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); if (virDomainObjCheckActive(vm) < 0) return -1; @@ -15515,8 +15580,8 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr= driver, /* prepare a list of objects to use in the vm definition so that we do= n't * have to roll back later */ - if (qemuDomainSnapshotDiskDataCollect(driver, vm, snap, reuse, - &diskdata, &ndiskdata) < 0) + if (qemuDomainSnapshotDiskDataCollect(driver, vm, snap, cfg, reuse, bl= ockdev, + asyncJob, &diskdata, &ndiskdata)= < 0) goto cleanup; /* check whether there's anything to do */ @@ -15530,11 +15595,18 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverP= tr driver, * VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL with a valid file name and * qcow2 format. */ for (i =3D 0; i < ndiskdata; i++) { - if (qemuBlockSnapshotAddLegacy(actions, - diskdata[i].disk, - diskdata[i].src, - reuse) < 0) - goto cleanup; + if (blockdev) { + if (qemuBlockSnapshotAddBlockdev(actions, + diskdata[i].disk, + diskdata[i].src)) + goto cleanup; + } else { + if (qemuBlockSnapshotAddLegacy(actions, + diskdata[i].disk, + diskdata[i].src, + reuse) < 0) + goto cleanup; + } } if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) @@ -15551,7 +15623,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr= driver, virDomainAuditDisk(vm, dd->disk->src, dd->src, "snapshot", rc >=3D= 0); if (rc =3D=3D 0) - qemuDomainSnapshotUpdateDiskSources(driver, vm, dd); + qemuDomainSnapshotUpdateDiskSources(driver, vm, dd, blockdev); } if (rc < 0) @@ -15583,7 +15655,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr= driver, vm->newDef) < 0)) ret =3D -1; - qemuDomainSnapshotDiskDataCleanup(diskdata, ndiskdata, driver, vm); + qemuDomainSnapshotDiskDataCleanup(diskdata, ndiskdata, driver, vm, asy= ncJob); virErrorRestore(&orig_err); return ret; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Apr 23 09:49:27 2024 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=1565963721; cv=none; d=zoho.com; s=zohoarc; b=TEipqbjwnqputnIFQ11C6A78i/ItXgSHvsJe8+v4sPKTV3qVrvjKK9HECd5XlAYmBhgRIpf8clZkdiURdTZFgeXA9HIFD7AEJV3jLNbl1uIVSYtuPM15Eu+3waoK6WfhFiRwiey4EJrcy9DeYNKiVI+Mg1ubrDruq7sTqpzVVlQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565963721; 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=mu/pxLS0TiEAqD5L/ZHBGwZT7SHl3HXeV6jDMy51VwA=; b=ZgpxKvcGndfgowgz+npLMubpTSE8X6Xxq9KyTJk/FMtTgxddRhTXrgUzYzGMNJial6C2uCL+3KNAZ6RUcGUZ5hjeQ90P7U0EMMLn90OIGtccIn11Nozoj2drVYD2aC/McV8Vdt+wd8jV6yCyvRaJJ6eHAq8KYuW0Kzau6hKJSk0= 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 156596372189521.746687123169863; Fri, 16 Aug 2019 06:55:21 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D5A49C051673; Fri, 16 Aug 2019 13:55:20 +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 B214DA4FB5; Fri, 16 Aug 2019 13:55:20 +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 6ED7B1802215; Fri, 16 Aug 2019 13:55:20 +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 x7GDswT0029169 for ; Fri, 16 Aug 2019 09:54:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6B6351001B20; Fri, 16 Aug 2019 13:54:58 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id C426E1001B03; Fri, 16 Aug 2019 13:54:57 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Fri, 16 Aug 2019 15:54:44 +0200 Message-Id: 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 10/10] qemu: Defer support checks for external active snapshots to blockdev code or qemu 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.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 16 Aug 2019 13:55:21 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Remove libvit's support check for the target of an external snapshot to the blockdev code or qemu. This will potentially require a more complex cleanup but removes a level of hardcoded feature checks. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c22f74adaa..d9315e0df4 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14931,7 +14931,8 @@ qemuDomainSnapshotPrepareDiskExternalInactive(virDo= mainSnapshotDiskDefPtr snapdi static int qemuDomainSnapshotPrepareDiskExternalActive(virDomainSnapshotDiskDefPtr sn= apdisk, - virDomainDiskDefPtr domdisk) + virDomainDiskDefPtr domdisk, + bool blockdev) { int actualType =3D virStorageSourceGetActualType(snapdisk->src); @@ -14948,6 +14949,10 @@ qemuDomainSnapshotPrepareDiskExternalActive(virDom= ainSnapshotDiskDefPtr snapdisk break; case VIR_STORAGE_TYPE_NETWORK: + /* defer all of the checking to either qemu or libvirt's blockdev = code */ + if (blockdev) + break; + switch ((virStorageNetProtocol) snapdisk->src->protocol) { case VIR_STORAGE_NET_PROTOCOL_GLUSTER: break; @@ -14995,7 +15000,8 @@ static int qemuDomainSnapshotPrepareDiskExternal(virDomainDiskDefPtr disk, virDomainSnapshotDiskDefPtr snapdisk, bool active, - bool reuse) + bool reuse, + bool blockdev) { struct stat st; int err; @@ -15018,7 +15024,7 @@ qemuDomainSnapshotPrepareDiskExternal(virDomainDisk= DefPtr disk, if (qemuDomainSnapshotPrepareDiskExternalInactive(snapdisk, disk) = < 0) return -1; } else { - if (qemuDomainSnapshotPrepareDiskExternalActive(snapdisk, disk) < = 0) + if (qemuDomainSnapshotPrepareDiskExternalActive(snapdisk, disk, bl= ockdev) < 0) return -1; } @@ -15119,6 +15125,8 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm, virDomainSnapshotDefPtr def, unsigned int *flags) { + qemuDomainObjPrivatePtr priv =3D vm->privateData; + bool blockdev =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); int ret =3D -1; size_t i; bool active =3D virDomainObjIsActive(vm); @@ -15177,7 +15185,7 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm, } if (qemuDomainSnapshotPrepareDiskExternal(dom_disk, disk, - active, reuse) < 0) + active, reuse, block= dev) < 0) goto cleanup; external++; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list