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

Wolfgang Link w.link at proxmox.com
Thu Feb 12 08:41:34 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..3fc742c 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_possible($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