From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [RFC qemu-server 1/6] restore: cleanup oldconf: also clean up snapshots from kept volumes
Date: Fri, 15 Apr 2022 14:31:25 +0200 [thread overview]
Message-ID: <20220415123130.49099-2-f.ebner@proxmox.com> (raw)
In-Reply-To: <20220415123130.49099-1-f.ebner@proxmox.com>
---
PVE/QemuServer.pm | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 0be6be90..f221d93c 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -6228,6 +6228,8 @@ sub restore_file_archive {
my $restore_cleanup_oldconf = sub {
my ($storecfg, $vmid, $oldconf, $virtdev_hash) = @_;
+ my $kept_disks = {};
+
PVE::QemuConfig->foreach_volume($oldconf, sub {
my ($ds, $drive) = @_;
@@ -6246,11 +6248,13 @@ my $restore_cleanup_oldconf = sub {
if (my $err = $@) {
warn $err;
}
+ } else {
+ $kept_disks->{$volid} = 1;
}
});
- # delete vmstate files, after the restore we have no snapshots anymore
- foreach my $snapname (keys %{$oldconf->{snapshots}}) {
+ # after the restore we have no snapshots anymore
+ for my $snapname (keys $oldconf->{snapshots}->%*) {
my $snap = $oldconf->{snapshots}->{$snapname};
if ($snap->{vmstate}) {
eval { PVE::Storage::vdisk_free($storecfg, $snap->{vmstate}); };
@@ -6258,6 +6262,11 @@ my $restore_cleanup_oldconf = sub {
warn $err;
}
}
+
+ for my $volid (keys $kept_disks->%*) {
+ eval { PVE::Storage::volume_snapshot_delete($storecfg, $volid, $snapname); };
+ warn $@ if $@;
+ }
}
};
--
2.30.2
next prev parent reply other threads:[~2022-04-15 12:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-15 12:31 [pve-devel] [RFC qemu-server] more flexible restore Fabian Ebner
2022-04-15 12:31 ` Fabian Ebner [this message]
2022-04-15 12:31 ` [pve-devel] [RFC qemu-server 2/6] restore destroy volumes: remove check for absolute path Fabian Ebner
2022-04-15 12:31 ` [pve-devel] [RFC qemu-server 3/6] restore deactivate volumes: never die Fabian Ebner
2022-04-15 12:31 ` [pve-devel] [RFC qemu-server 4/6] restore: also deactivate/destroy cloud-init disk upon error Fabian Ebner
2022-04-15 12:31 ` [pve-devel] [RFC qemu-server 5/6] api: create: refactor parameter check logic Fabian Ebner
2022-04-15 12:31 ` [pve-devel] [RFC qemu-server 6/6] restore: allow overriding settings upon restore Fabian Ebner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220415123130.49099-2-f.ebner@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox