From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 81A996B996 for ; Thu, 5 Aug 2021 09:20:56 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 61FD126A2C for ; Thu, 5 Aug 2021 09:20:36 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 819D7269A1 for ; Thu, 5 Aug 2021 09:20:17 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id BE37842E22 for ; Thu, 5 Aug 2021 09:20:02 +0200 (CEST) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Thu, 5 Aug 2021 09:19:54 +0200 Message-Id: <20210805071958.4402-3-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210805071958.4402-1-f.ebner@proxmox.com> References: <20210805071958.4402-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.420 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment T_SPF_HELO_TEMPERROR 0.01 SPF: test of HELO record failed (temperror) T_SPF_TEMPERROR 0.01 SPF: test of record failed (temperror) Subject: [pve-devel] [PATCH guest-common 2/2] config: activate affected storages for snapshot operations X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Aug 2021 07:20:56 -0000 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. when iterating over the volumes. Signed-off-by: Fabian Ebner --- src/PVE/AbstractConfig.pm | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/PVE/AbstractConfig.pm b/src/PVE/AbstractConfig.pm index b3f70f2..d4f3d44 100644 --- a/src/PVE/AbstractConfig.pm +++ b/src/PVE/AbstractConfig.pm @@ -776,6 +776,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) = @_; @@ -791,6 +798,8 @@ sub snapshot_create { my $drivehash = {}; eval { + $class->__snapshot_activate_storages($conf, 0); + if ($freezefs) { $class->__snapshot_freeze($vmid, 0); } @@ -836,6 +845,8 @@ sub snapshot_delete { die "snapshot '$snapname' does not exist\n" if !defined($snap); + $class->__snapshot_activate_storages($snap, 1) if !$drivehash; + $class->set_lock($vmid, 'snapshot-delete') if (!$drivehash); # doesn't already have a 'snapshot' lock @@ -970,6 +981,8 @@ sub snapshot_rollback { $snap = $get_snapshot_config->($conf); if ($prepare) { + $class->__snapshot_activate_storages($snap, 1); + my $repl_conf = PVE::ReplicationConfig->new(); if ($repl_conf->check_for_existing_jobs($vmid, 1)) { # remove all replication snapshots -- 2.30.2