public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH guest-common] abstract config: snapshot create/rollback/remove: print more log statements
Date: Wed, 29 May 2024 13:45:19 +0200	[thread overview]
Message-ID: <20240529114519.2419494-1-d.csapak@proxmox.com> (raw)

this increases verbosity of the actions, especially when including the
snapshot name, since that will appear in the task logs wereas before
there was no mention of any action, just the storage specific output for
creating/rollback/removal.

Logs are printed at all main actions that can fail or take potentially
long, so that it's clear what started/finished.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
replaces https://lists.proxmox.com/pipermail/pve-devel/2024-May/064010.html

 src/PVE/AbstractConfig.pm | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/src/PVE/AbstractConfig.pm b/src/PVE/AbstractConfig.pm
index 5d5f9b4..b685b7f 100644
--- a/src/PVE/AbstractConfig.pm
+++ b/src/PVE/AbstractConfig.pm
@@ -806,6 +806,8 @@ sub __snapshot_activate_storages {
 sub snapshot_create {
     my ($class, $vmid, $snapname, $save_vmstate, $comment) = @_;
 
+    print "Creating snapshot '$snapname'\n";
+
     my $snap = $class->__snapshot_prepare($vmid, $snapname, $save_vmstate, $comment);
 
     $save_vmstate = 0 if !$snap->{vmstate};
@@ -820,24 +822,30 @@ sub snapshot_create {
 	$class->__snapshot_activate_storages($conf, 0);
 
 	if ($freezefs) {
+	    print "Trying to freeze guest filesystems\n";
 	    $class->__snapshot_freeze($vmid, 0);
+	    print "Succesfully frozen guest filesystems\n";
 	}
 
 	$class->__snapshot_create_vol_snapshots_hook($vmid, $snap, $running, "before");
 
+	print "Creating volume snapshots\n";
 	$class->foreach_volume($snap, sub {
 	    my ($vs, $volume) = @_;
 
 	    $class->__snapshot_create_vol_snapshot($vmid, $vs, $volume, $snapname);
 	    $drivehash->{$vs} = 1;
 	});
+	print "Succesfully created volume snapshots\n";
     };
     my $err = $@;
 
     if ($running) {
 	$class->__snapshot_create_vol_snapshots_hook($vmid, $snap, $running, "after");
 	if ($freezefs) {
+	    print "Trying to thaw guest filesystems\n";
 	    $class->__snapshot_freeze($vmid, 1);
+	    print "Succesfully thawed guest filesystems\n";
 	}
 	$class->__snapshot_create_vol_snapshots_hook($vmid, $snap, $running, "after-unfreeze");
     }
@@ -850,6 +858,8 @@ sub snapshot_create {
     }
 
     $class->__snapshot_commit($vmid, $snapname);
+
+    print "Succesfully created snapshot '$snapname'\n";
 }
 
 # Check if the snapshot might still be needed by a replication job.
@@ -895,6 +905,8 @@ my $snapshot_delete_assert_not_needed_by_replication = sub {
 sub snapshot_delete {
     my ($class, $vmid, $snapname, $force, $drivehash) = @_;
 
+    print "Removing snapshot '$snapname'\n";
+
     my $unused = [];
 
     my $conf = $class->load_config($vmid);
@@ -963,12 +975,15 @@ sub snapshot_delete {
 
     # now remove vmstate file
     if ($snap->{vmstate}) {
+	print "Removing vmstate file\n";
 	$class->__snapshot_delete_vmstate_file($snap, $force);
 
 	# save changes (remove vmstate from snapshot)
 	$class->lock_config($vmid, $remove_drive, 'vmstate') if !$force;
+	print "Succesfully removed vmstate file\n";
     };
 
+    print "Removing volume snapshots\n";
     # now remove all volume snapshots
     $class->foreach_volume($snap, sub {
 	my ($vs, $volume) = @_;
@@ -985,6 +1000,7 @@ sub snapshot_delete {
 	# save changes (remove drive from snapshot)
 	$class->lock_config($vmid, $remove_drive, $vs) if !$force;
     });
+    print "Succesfully removed volume snapshots\n";
 
     # now cleanup config
     $class->lock_config($vmid, sub {
@@ -1010,6 +1026,8 @@ sub snapshot_delete {
 
 	$class->write_config($vmid, $conf);
     });
+
+    print "Succesfully removed snapshot '$snapname'\n";
 }
 
 # Remove replication snapshots to make a rollback possible.
@@ -1082,6 +1100,8 @@ my $rollback_remove_replication_snapshots = sub {
 sub snapshot_rollback {
     my ($class, $vmid, $snapname) = @_;
 
+    print "Rolling back to snapshot '$snapname'\n";
+
     my $prepare = 1;
 
     my $data = {};
@@ -1121,6 +1141,7 @@ sub snapshot_rollback {
 
 	if ($prepare) {
 	    $class->check_lock($conf);
+	    print "Stopping guest\n";
 	    $class->__snapshot_rollback_vm_stop($vmid);
 	}
 
@@ -1149,20 +1170,25 @@ sub snapshot_rollback {
 	$class->write_config($vmid, $conf);
 
 	if (!$prepare && $snap->{vmstate}) {
+	    print "Starting guest\n";
 	    $class->__snapshot_rollback_vm_start($vmid, $snap->{vmstate}, $data);
 	}
     };
 
     $class->lock_config($vmid, $updatefn);
 
+    print "Rolling back volume snapshots\n";
     $class->foreach_volume($snap, sub {
 	my ($vs, $volume) = @_;
 
 	$class->__snapshot_rollback_vol_rollback($volume, $snapname);
     });
+    print "Succesfully rolled back volume snapshots\n";
 
     $prepare = 0;
     $class->lock_config($vmid, $updatefn);
+
+    print "Succesfully rolled back to snapshot '$snapname'\n";
 }
 
 # Calculate a derived property from a configuration. Derived properties are:
-- 
2.39.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


             reply	other threads:[~2024-05-29 11:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-29 11:45 Dominik Csapak [this message]
2024-07-04 10:15 ` Fabian Grünbichler

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=20240529114519.2419494-1-d.csapak@proxmox.com \
    --to=d.csapak@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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal