From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 1CF0D1FF183 for ; Wed, 16 Jul 2025 08:32:55 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5E1E31660A; Wed, 16 Jul 2025 08:32:44 +0200 (CEST) To: pve-devel@lists.proxmox.com Date: Wed, 16 Jul 2025 08:31:42 +0200 In-Reply-To: <20250716063153.1647681-1-alexandre.derumier@groupe-cyllene.com> References: <20250716063153.1647681-1-alexandre.derumier@groupe-cyllene.com> MIME-Version: 1.0 Message-ID: List-Id: Proxmox VE development discussion List-Post: From: Alexandre Derumier via pve-devel Precedence: list Cc: Alexandre Derumier X-Mailman-Version: 2.1.29 X-BeenThere: pve-devel@lists.proxmox.com List-Subscribe: , List-Unsubscribe: , List-Archive: Reply-To: Proxmox VE development discussion List-Help: Subject: [pve-devel] [PATCH FOLLOW-UP qemu-server 4/4] blockdev_external_snapshot: rework to avoid $running param Content-Type: multipart/mixed; boundary="===============3916269408656950056==" Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" --===============3916269408656950056== Content-Type: message/rfc822 Content-Disposition: inline Return-Path: X-Original-To: pve-devel@lists.proxmox.com Delivered-To: pve-devel@lists.proxmox.com 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 83C64DAD6D for ; Wed, 16 Jul 2025 08:32:41 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 60EB715A82 for ; Wed, 16 Jul 2025 08:32:08 +0200 (CEST) Received: from bastiontest.odiso.net (unknown [185.151.190.228]) (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 firstgate.proxmox.com (Proxmox) with ESMTPS for ; Wed, 16 Jul 2025 08:32:05 +0200 (CEST) Received: from formationkvm1.odiso.net (unknown [10.11.201.57]) by bastiontest.odiso.net (Postfix) with ESMTP id 3277F862E4D; Wed, 16 Jul 2025 08:31:56 +0200 (CEST) Received: by formationkvm1.odiso.net (Postfix, from userid 0) id 3030B104D614; Wed, 16 Jul 2025 08:31:56 +0200 (CEST) From: Alexandre Derumier To: pve-devel@lists.proxmox.com Subject: [PATCH FOLLOW-UP qemu-server 4/4] blockdev_external_snapshot: rework to avoid $running param Date: Wed, 16 Jul 2025 08:31:42 +0200 Message-Id: <20250716063153.1647681-8-alexandre.derumier@groupe-cyllene.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250716063153.1647681-1-alexandre.derumier@groupe-cyllene.com> References: <20250716063153.1647681-1-alexandre.derumier@groupe-cyllene.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.042 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_NONE 0.1 DMARC none policy HEADER_FROM_DIFFERENT_DOMAINS 0.001 From and EnvelopeFrom 2nd level mail domains are different KAM_DMARC_NONE 0.25 DKIM has Failed or SPF has failed on the message and the domain has no DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record the new workflow is: 1) PVE::Storage::volume_snapshot: rename the current to snap + allocate the new current with snap backing (the qemu process have still the inode opened) 2) replace the current to snap in the blockdev graph with reopen 3) add a new current blockdev 3) use block-snapshot to replace the active image with the new current blockdev with the qemu also: move PVE::Storage::volume_rename outside blockdev_replace, and rename 'blockdev_rename()' to 'blockdev_replace()'. as we only replace/reopen the blockdev nodes now. Signed-off-by: Alexandre Derumier --- src/PVE/QemuServer.pm | 38 ++++++---------------------------- src/PVE/QemuServer/Blockdev.pm | 26 ++++++++++++++++------- 2 files changed, 24 insertions(+), 40 deletions(-) diff --git a/src/PVE/QemuServer.pm b/src/PVE/QemuServer.pm index c1e15675..eec887b3 100644 --- a/src/PVE/QemuServer.pm +++ b/src/PVE/QemuServer.pm @@ -4357,38 +4357,9 @@ sub qemu_volume_snapshot { my $snapshots = PVE::Storage::volume_snapshot_info($storecfg, $volid); my $parent_snap = $snapshots->{'current'}->{parent}; my $machine_version = PVE::QemuServer::Machine::get_current_qemu_machine($vmid); - - PVE::QemuServer::Blockdev::blockdev_rename( - $storecfg, - $vmid, - $machine_version, - $deviceid, - $drive, - 'current', - $snap, - $parent_snap, + PVE::QemuServer::Blockdev::blockdev_external_snapshot( + $storecfg, $vmid, $machine_version, $deviceid, $drive, $snap, $parent_snap, ); - eval { - PVE::QemuServer::Blockdev::blockdev_external_snapshot( - $storecfg, $vmid, $machine_version, $deviceid, $drive, $snap, - ); - }; - if ($@) { - warn $@ if $@; - print "Error creating snapshot. Revert rename\n"; - eval { - PVE::QemuServer::Blockdev::blockdev_rename( - $storecfg, - $vmid, - $machine_version, - $deviceid, - $drive, - $snap, - 'current', - $parent_snap, - ); - }; - } } elsif ($do_snapshots_type eq 'storage') { PVE::Storage::volume_snapshot($storecfg, $volid, $snap); } @@ -4443,7 +4414,10 @@ sub qemu_volume_snapshot_delete { $childsnap, $snap, ); - PVE::QemuServer::Blockdev::blockdev_rename( + + PVE::Storage::rename_snapshot($storecfg, $volid, $snap, $childsnap); + + PVE::QemuServer::Blockdev::blockdev_replace( $storecfg, $vmid, $machine_version, diff --git a/src/PVE/QemuServer/Blockdev.pm b/src/PVE/QemuServer/Blockdev.pm index 73eb7c1e..1a87a2a3 100644 --- a/src/PVE/QemuServer/Blockdev.pm +++ b/src/PVE/QemuServer/Blockdev.pm @@ -798,14 +798,26 @@ sub set_io_throttle { } sub blockdev_external_snapshot { - my ($storecfg, $vmid, $machine_version, $deviceid, $drive, $snap, $size) = @_; + my ($storecfg, $vmid, $machine_version, $deviceid, $drive, $snap, $parent_snap) = @_; print "Creating a new current volume with $snap as backing snap\n"; my $volid = $drive->{file}; - #preallocate add a new current file with reference to backing-file - PVE::Storage::volume_snapshot($storecfg, $volid, $snap, 1); + #rename current to snap && preallocate add a new current file with reference to snap1 backing-file + PVE::Storage::volume_snapshot($storecfg, $volid, $snap); + + #reopen current to snap + blockdev_replace( + $storecfg, + $vmid, + $machine_version, + $deviceid, + $drive, + 'current', + $snap, + $parent_snap, + ); #be sure to add drive in write mode delete($drive->{ro}); @@ -826,6 +838,7 @@ sub blockdev_external_snapshot { mon_cmd($vmid, 'blockdev-add', %$new_fmt_blockdev); + print "blockdev-snapshot: reopen current with $snap backing image\n"; mon_cmd( $vmid, 'blockdev-snapshot', node => $snap_fmt_blockdev->{'node-name'}, @@ -849,7 +862,7 @@ sub blockdev_delete { PVE::Storage::volume_snapshot_delete($storecfg, $volid, $snap, 1); } -sub blockdev_rename { +sub blockdev_replace { my ( $storecfg, $vmid, @@ -861,7 +874,7 @@ sub blockdev_rename { $parent_snap, ) = @_; - print "rename $src_snap to $target_snap\n"; + print "blockdev replace $src_snap by $target_snap\n"; my $volid = $drive->{file}; @@ -878,9 +891,6 @@ sub blockdev_rename { { 'snapshot-name' => $src_snap }, ); - #rename the snapshot - PVE::Storage::rename_snapshot($storecfg, $volid, $src_snap, $target_snap); - my $target_file_blockdev = generate_file_blockdev( $storecfg, $drive, -- 2.39.5 --===============3916269408656950056== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel --===============3916269408656950056==--