public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v2 guest-common 2/2] config: activate affected storages for snapshot operations
Date: Thu, 13 Jan 2022 12:04:01 +0100	[thread overview]
Message-ID: <20220113110405.67232-3-f.ebner@proxmox.com> (raw)
In-Reply-To: <20220113110405.67232-1-f.ebner@proxmox.com>

For snapshot creation, the storage for the vmstate file is activated
via vdisk_alloc when the state file is created.

Do not activate the volumes themselves, as that has unnecessary side
effects (e.g. waiting for zvol device link for ZFS, mapping the volume
for RBD). If a storage can only do snapshot operations on a volume
that has been activated, it needs to activate the volume itself.

The actual implementation will be in the plugins to be able to skip
CD ROM drives and bind-mounts, etc.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
 src/PVE/AbstractConfig.pm | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/PVE/AbstractConfig.pm b/src/PVE/AbstractConfig.pm
index 0c40062..2d15388 100644
--- a/src/PVE/AbstractConfig.pm
+++ b/src/PVE/AbstractConfig.pm
@@ -786,6 +786,13 @@ sub __snapshot_commit {
     $class->lock_config($vmid, $updatefn);
 }
 
+# Activates the storages affected by the snapshot operations.
+sub __snapshot_activate_storages {
+    my ($class, $conf, $include_vmstate) = @_;
+
+    return; # FIXME PVE 8.x change to die 'implement me' and bump Breaks for older plugins
+}
+
 # Creates a snapshot for the VM/CT.
 sub snapshot_create {
     my ($class, $vmid, $snapname, $save_vmstate, $comment) = @_;
@@ -801,6 +808,8 @@ sub snapshot_create {
     my $drivehash = {};
 
     eval {
+	$class->__snapshot_activate_storages($conf, 0);
+
 	if ($freezefs) {
 	    $class->__snapshot_freeze($vmid, 0);
 	}
@@ -884,6 +893,8 @@ sub snapshot_delete {
 
     die "snapshot '$snapname' does not exist\n" if !defined($snap);
 
+    $class->__snapshot_activate_storages($snap, 1) if !$drivehash;
+
     $snapshot_delete_assert_not_needed_by_replication->($class, $vmid, $conf, $snap, $snapname)
 	if !$drivehash && !$force;
 
@@ -1085,6 +1096,8 @@ sub snapshot_rollback {
 	$snap = $get_snapshot_config->($conf);
 
 	if ($prepare) {
+	    $class->__snapshot_activate_storages($snap, 1);
+
 	    $rollback_remove_replication_snapshots->($class, $vmid, $snap, $snapname);
 
 	    $class->foreach_volume($snap, sub {
-- 
2.30.2





  parent reply	other threads:[~2022-01-13 11:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-13 11:03 [pve-devel] [PATCH-SERIES v2 guest-common/qemu-server/container] activate " Fabian Ebner
2022-01-13 11:04 ` [pve-devel] [PATCH v2 guest-common 1/2] config: remove unused variable Fabian Ebner
2022-02-04 16:37   ` [pve-devel] applied: " Thomas Lamprecht
2022-01-13 11:04 ` Fabian Ebner [this message]
2022-02-04 16:38   ` [pve-devel] applied: [PATCH v2 guest-common 2/2] config: activate affected storages for snapshot operations Thomas Lamprecht
2022-01-13 11:04 ` [pve-devel] [PATCH v2 qemu-server 1/1] snapshot: implement __snapshot_activate_storages Fabian Ebner
2022-01-13 11:04 ` [pve-devel] [PATCH v2 container 1/3] config: snapshot_delete_remove_drive: check for parsed value Fabian Ebner
2022-01-13 11:04 ` [pve-devel] [PATCH v2 container 2/3] config: parse_volume: don't die when noerr is set Fabian Ebner
2022-01-13 11:04 ` [pve-devel] [PATCH v2 container 3/3] snapshot: implement __snapshot_activate_storages Fabian Ebner
2022-04-28 12:38 ` [pve-devel] applied-series: [PATCH-SERIES v2 guest-common/qemu-server/container] activate storages for snapshot operations Thomas Lamprecht

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=20220113110405.67232-3-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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal