From nobody Mon Feb 9 12:26:48 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1604404934; cv=none; d=zohomail.com; s=zohoarc; b=VYtmy4Kd6oGyDu8ABYYj3CJpzch5r7Ltcnqmbr+/p02AeMIeQ7DpCLDEuizyU+TlJqNmibAlknmi4arBAMKwaLGlahhVXzbbOdF+ldZg19r1wrW2NIGUgxvwbIvDmTYGBEngQjO/d6VLLacbodbVe3UuvHoTxDd03QfA1ZehE4w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604404934; h=Content-Type:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=YMMuu4QeCwKDaHQ0LnB6jPSXJb8xnuLFsAHz4ywdfUw=; b=k1cSHprnHvPvto+i0f5q3eG5D//zlUwKXL42sbNdpLijdcD//vOzvG5j0hlzTcLRm8L9p++veJRkGsGoaVV+DpMEuRr101I03uq6fYtBvDpeg66NaU+I9/sTF/4R6dJUg+UJHUIT/rK+jnUi7L0f6IUOA2DpGslAuUkiDdO6a4U= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=quarantine dis=quarantine) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1604404934359789.1438951941011; Tue, 3 Nov 2020 04:02:14 -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-3-cbe8H7VKOfq-9B19EMnQtg-1; Tue, 03 Nov 2020 07:02:08 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id C25441868412; Tue, 3 Nov 2020 12:02:02 +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 95A121002D49; Tue, 3 Nov 2020 12:02:02 +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 5C7C0181A06B; Tue, 3 Nov 2020 12:02:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0A3C21AP011717 for ; Tue, 3 Nov 2020 07:02:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id 221C721568B0; Tue, 3 Nov 2020 12:02:01 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1CD3A215688E for ; Tue, 3 Nov 2020 12:01:56 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 838D1803531 for ; Tue, 3 Nov 2020 12:01:56 +0000 (UTC) Received: from relay3.sw.ru (relay.sw.ru [185.231.240.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-162--TN7hLLrNOuQIj0EuA35eg-1; Tue, 03 Nov 2020 07:01:54 -0500 Received: from [10.28.15.159] (helo=vz7.sw.ru) by relay3.sw.ru with esmtp (Exim 4.94) (envelope-from ) id 1kZv0F-007EMR-LE for libvir-list@redhat.com; Tue, 03 Nov 2020 15:01:31 +0300 X-MC-Unique: cbe8H7VKOfq-9B19EMnQtg-1 X-MC-Unique: -TN7hLLrNOuQIj0EuA35eg-1 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH v2 06/10] qemu: rename: support renaming checkpoints directory Date: Tue, 3 Nov 2020 15:00:04 +0300 Message-Id: <1604404808-825155-7-git-send-email-nshirokovskiy@virtuozzo.com> In-Reply-To: <1604404808-825155-1-git-send-email-nshirokovskiy@virtuozzo.com> References: <1604404808-825155-1-git-send-email-nshirokovskiy@virtuozzo.com> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 2 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This is basically just saves checkpoints metadata on disk after name is cha= nged in memory as path to domain checkpoints directory depends on name. After th= at old checkpoint directory is deleted with checkpoint metadata files. Signed-off-by: Nikolay Shirokovskiy --- src/qemu/qemu_checkpoint.c | 2 +- src/qemu/qemu_checkpoint.h | 6 ++++++ src/qemu/qemu_domain.c | 7 +++++++ src/qemu/qemu_driver.c | 23 +++++++++++++++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c index fb76c21..4a496d5 100644 --- a/src/qemu/qemu_checkpoint.c +++ b/src/qemu/qemu_checkpoint.c @@ -76,7 +76,7 @@ qemuCheckpointObjFromCheckpoint(virDomainObjPtr vm, } =20 =20 -static int +int qemuCheckpointWriteMetadata(virDomainObjPtr vm, virDomainMomentObjPtr checkpoint, virDomainXMLOptionPtr xmlopt, diff --git a/src/qemu/qemu_checkpoint.h b/src/qemu/qemu_checkpoint.h index 0d267a1..d58657e 100644 --- a/src/qemu/qemu_checkpoint.h +++ b/src/qemu/qemu_checkpoint.h @@ -79,3 +79,9 @@ qemuCheckpointDiscardDiskBitmaps(virStorageSourcePtr src, virJSONValuePtr actions, const char *diskdst, GSList **reopenimages); + +int +qemuCheckpointWriteMetadata(virDomainObjPtr vm, + virDomainMomentObjPtr checkpoint, + virDomainXMLOptionPtr xmlopt, + const char *checkpointDir); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 258c8c5..422b534 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11104,10 +11104,12 @@ qemuDomainNamePathsCleanup(virQEMUDriverConfigPtr= cfg, g_autofree char *cfg_file =3D NULL; g_autofree char *autostart_link =3D NULL; g_autofree char *snap_dir =3D NULL; + g_autofree char *chk_dir =3D NULL; =20 cfg_file =3D virDomainConfigFile(cfg->configDir, name); autostart_link =3D virDomainConfigFile(cfg->autostartDir, name); snap_dir =3D g_strdup_printf("%s/%s", cfg->snapshotDir, name); + chk_dir =3D g_strdup_printf("%s/%s", cfg->checkpointDir, name); =20 if (virFileExists(cfg_file) && unlink(cfg_file) < 0) { @@ -11128,5 +11130,10 @@ qemuDomainNamePathsCleanup(virQEMUDriverConfigPtr = cfg, !bestEffort) return -1; =20 + if (virFileIsDir(chk_dir) && + virFileDeleteTree(chk_dir) < 0 && + !bestEffort) + return -1; + return 0; } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 2664603..4e0186b 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -19126,6 +19126,24 @@ qemuDomainSnapshotWriteMetadataIter(void *payload, =20 =20 static int +qemuDomainCheckpointWriteMetadataIter(void *payload, + const char *name G_GNUC_UNUSED, + void *opaque) +{ + struct qemuDomainMomentWriteMetadataData *data =3D opaque; + virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(data->driver); + int ret; + + ret =3D qemuCheckpointWriteMetadata(data->vm, payload, + data->driver->xmlopt, + cfg->snapshotDir); + + virObjectUnref(cfg); + return ret; +} + + +static int qemuDomainRenameCallback(virDomainObjPtr vm, const char *new_name, unsigned int flags, @@ -19191,6 +19209,11 @@ qemuDomainRenameCallback(virDomainObjPtr vm, &data) < 0) goto cleanup; =20 + if (virDomainCheckpointForEach(vm->checkpoints, + qemuDomainCheckpointWriteMetadataIter, + &data) < 0) + goto cleanup; + if (virDomainDefSave(vm->def, driver->xmlopt, cfg->configDir) < 0) goto cleanup; =20 --=20 1.8.3.1