From nobody Tue Feb 10 04:13:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1583223599; cv=none; d=zohomail.com; s=zohoarc; b=dnLTLmlb8wbfceQILr753uuJXgPOWZeYEpU8CurdRsqbQnotkcfiF9ymclHZ40uUSP9gGqpd8sp5FPFnRmRUafL1P9d+WGQxmIkRCpJcCOKcwxbP5vZDzKCCLvcSd0E2mFGyN2Bysf2vPFVMtTaLpxOVs/wSxjvaVBR/C7QA18Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583223599; h=Content-Type:Content-Transfer-Encoding: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; bh=RqvALcjV7Pvx1DdHlCR2fAZLcm8OSs1bf9SADpNMXi4=; b=UALn3L9wPn+jmsKMfZmgTkYEwiS+RipMGv/sTDyI7J3VICC9IO9Q6hwosOcC3+CdpGrKtCsf0TrGS8GXIo3TtV6OH59Lzh8UBDCIf5kNyFbvD2b39nqZYBuFtvsVnwZnIAoTfJ/6XRT5tQwptWeOTJlZFz7sJFERoujmU06XKMw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1583223599001121.76924090759007; Tue, 3 Mar 2020 00:19:59 -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-191-NPbvTnArPbyTniI15anVHQ-1; Tue, 03 Mar 2020 03:19:56 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5363E19067E0; Tue, 3 Mar 2020 08:19:50 +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 14AD78D56B; Tue, 3 Mar 2020 08:19:50 +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 0923684479; Tue, 3 Mar 2020 08:19:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0238JkXe003628 for ; Tue, 3 Mar 2020 03:19:47 -0500 Received: by smtp.corp.redhat.com (Postfix) id A560310EE6D4; Tue, 3 Mar 2020 08:19:46 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9FCAB10E60F6 for ; Tue, 3 Mar 2020 08:19:44 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (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 A6CC486D723 for ; Tue, 3 Mar 2020 08:19:44 +0000 (UTC) Received: from relay.sw.ru (relay.sw.ru [185.231.240.75]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-61-GocNcu0ANN2uW06k4NZsyg-1; Tue, 03 Mar 2020 03:19:42 -0500 Received: from dhcp-172-16-24-106.sw.ru ([172.16.24.106] helo=shiny.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1j92mB-0002uR-4v for libvir-list@redhat.com; Tue, 03 Mar 2020 11:19:39 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583223598; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=RqvALcjV7Pvx1DdHlCR2fAZLcm8OSs1bf9SADpNMXi4=; b=Kk46x+7jl/5C6l6GRenDLv2ldFmsRbTvatZpED39iQhGWUO/smov0vsMEw3nzLi80iwWyA WJXVQ5o1E6lZPp2rZfLvDrZ/IMpk3OvJgNOj38obaXzSdSHSuSl3aJ4t9rf94C2IZ8bZjV trtoquBU0JcS6hxPgKZgdRD0p5eVHcc= X-MC-Unique: NPbvTnArPbyTniI15anVHQ-1 X-MC-Unique: GocNcu0ANN2uW06k4NZsyg-1 From: Nikolay Shirokovskiy To: libvir-list@redhat.com Subject: [PATCH 3/8] qemu: rename: support renaming snapshots directory Date: Tue, 3 Mar 2020 11:19:17 +0300 Message-Id: <20200303081922.9157-4-nshirokovskiy@virtuozzo.com> In-Reply-To: <20200303081922.9157-1-nshirokovskiy@virtuozzo.com> References: <20200303081922.9157-1-nshirokovskiy@virtuozzo.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 0238JkXe003628 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.11 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" Signed-off-by: Nikolay Shirokovskiy --- src/qemu/qemu_domain.c | 7 +++++++ src/qemu/qemu_driver.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index ff48744f39..0c4cb09158 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -16731,9 +16731,11 @@ qemuDomainNamePathsCleanup(virQEMUDriverConfigPtr = cfg, { g_autofree char *cfg_file =3D NULL; g_autofree char *autostart_link =3D NULL; + g_autofree char *snap_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); =20 if (virFileExists(cfg_file) && unlink(cfg_file) < 0) @@ -16747,5 +16749,10 @@ qemuDomainNamePathsCleanup(virQEMUDriverConfigPtr = cfg, } } =20 + if (virFileIsDir(snap_dir) && virFileDeleteTree(snap_dir) < 0) { + if (reportError) + return -1; + } + return 0; } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 70cad837f2..6bde4d3de0 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -21938,6 +21938,30 @@ qemuDomainSetUserPassword(virDomainPtr dom, } =20 =20 +struct qemuDomainMomentWriteMetadataData { + virQEMUDriverPtr driver; + virDomainObjPtr vm; +}; + + +static int +qemuDomainSnapshotWriteMetadataIter(void *payload, + const void *name G_GNUC_UNUSED, + void *opaque) +{ + struct qemuDomainMomentWriteMetadataData *data =3D opaque; + virQEMUDriverConfigPtr cfg =3D virQEMUDriverGetConfig(data->driver); + int ret; + + ret =3D qemuDomainSnapshotWriteMetadata(data->vm, payload, + data->driver->xmlopt, + cfg->snapshotDir); + + virObjectUnref(cfg); + return ret; +} + + static int qemuDomainRenameCallback(virDomainObjPtr vm, const char *new_name, @@ -21955,6 +21979,10 @@ qemuDomainRenameCallback(virDomainObjPtr vm, g_autofree char *old_dom_cfg_file =3D NULL; g_autofree char *new_dom_autostart_link =3D NULL; g_autofree char *old_dom_autostart_link =3D NULL; + struct qemuDomainMomentWriteMetadataData data =3D { + .driver =3D driver, + .vm =3D vm, + }; =20 virCheckFlags(0, ret); =20 @@ -21994,6 +22022,11 @@ qemuDomainRenameCallback(virDomainObjPtr vm, vm->def->name =3D new_dom_name; new_dom_name =3D NULL; =20 + if (virDomainSnapshotForEach(vm->snapshots, + qemuDomainSnapshotWriteMetadataIter, + &data) < 0) + goto cleanup; + if (virDomainDefSave(vm->def, driver->xmlopt, cfg->configDir) < 0) goto cleanup; =20 --=20 2.23.0