[pve-devel] [PATCH 1/2] QemuServer: check snapshot befor rollback

Wolfgang Link w.link at proxmox.com
Wed Feb 11 13:33:14 CET 2015


this will check, if it is possibel to rollback a snapshot befor VM will shutdown and get locked.

Signed-off-by: Wolfgang Link <w.link at proxmox.com>
---
 PVE/QemuServer.pm |   18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 5d7f9d7..6df375e 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -5550,13 +5550,23 @@ sub snapshot_rollback {
 
     my $storecfg = PVE::Storage::config();
 
-    my $updatefn = sub {
+    my $conf = load_config($vmid);
 
-	my $conf = load_config($vmid);
+    die "you can't rollback if vm is a template\n" if is_template($conf);
 
-	die "you can't rollback if vm is a template\n" if is_template($conf);
+    $snap = $conf->{snapshots}->{$snapname};
 
-	$snap = $conf->{snapshots}->{$snapname};
+    foreach_drive($snap, sub {
+	my ($ds, $drive) = @_;
+
+	return if drive_is_cdrom($drive);
+
+	my $volid = $drive->{file};
+
+	PVE::Storage::volume_rollback_is_possibel($storecfg, $volid, $snapname);
+});
+
+    my $updatefn = sub {
 
 	die "snapshot '$snapname' does not exist\n" if !defined($snap);
 
-- 
1.7.10.4





More information about the pve-devel mailing list