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 1263BBFC30 for ; Tue, 9 Jan 2024 10:27:50 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E81F0150C1 for ; Tue, 9 Jan 2024 10:27:49 +0100 (CET) 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)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Tue, 9 Jan 2024 10:27:49 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 005B249026 for ; Tue, 9 Jan 2024 10:27:49 +0100 (CET) Date: Tue, 09 Jan 2024 10:27:42 +0100 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox VE development discussion References: <20240103134149.86608-1-f.ebner@proxmox.com> In-Reply-To: <20240103134149.86608-1-f.ebner@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.16.0 (https://github.com/astroidmail/astroid) Message-Id: <1704792441.ltw5gkgfsj.astroid@yuna.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.064 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [plugin.pm, qemuserver.pm, proxmox.com] Subject: [pve-devel] applied: [PATCH qemu-server] fix #2258: select correct device when removing drive snapshot via QEMU 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: Tue, 09 Jan 2024 09:27:50 -0000 with a small cleanup as follow-up, as discussed off-list. thanks! On January 3, 2024 2:41 pm, Fiona Ebner wrote: > The QMP command needs to be issued for the device where the disk is > currently attached, not for the device where the disk was attached at > the time the snapshot was taken. >=20 > Fixes the following scenario with a disk image for which > do_snapshots_with_qemu() is true (i.e. qcow2 or RBD+krbd=3D0): > 1. Take snapshot while disk image is attached to a given bus+ID. > 2. Detach disk image. > 3. Attach disk image to a different bus+ID. > 4. Remove snapshot. >=20 > Previously, this would result in an error like: >> blockdev-snapshot-delete-internal-sync' failed - Cannot find device=3Ddr= ive-scsi1 nor node_name=3Ddrive-scsi1 >=20 > While the $running parameter for volume_snapshot_delete() is planned > to be removed on the next storage plugin APIAGE reset, it currently > causes an immediate return in Storage/Plugin.pm. So passing a truthy > value would prevent removing a snapshot from an unused qcow2 disk that > was still used at the time the snapshot was taken. Thus, and because > some exotic third party plugin might be using it for whatever reason, > it's necessary to keep passing the same value as before. >=20 > Signed-off-by: Fiona Ebner > --- >=20 > Nicer to read with a word-based diff e.g.: > git log -p -w --word-diff=3Dcolor --word-diff-regex=3D'\w+' >=20 > PVE/QemuServer.pm | 19 ++++++++++++------- > 1 file changed, 12 insertions(+), 7 deletions(-) >=20 > diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm > index 3b1540b6..82b78fa5 100644 > --- a/PVE/QemuServer.pm > +++ b/PVE/QemuServer.pm > @@ -4754,21 +4754,26 @@ sub qemu_volume_snapshot_delete { > my ($vmid, $deviceid, $storecfg, $volid, $snap) =3D @_; > =20 > my $running =3D check_running($vmid); > + my $attached_deviceid; > =20 > - if($running) { > - > - $running =3D undef; > + if ($running) { > my $conf =3D PVE::QemuConfig->load_config($vmid); > PVE::QemuConfig->foreach_volume($conf, sub { > my ($ds, $drive) =3D @_; > - $running =3D 1 if $drive->{file} eq $volid; > + $attached_deviceid =3D "drive-$ds" if $drive->{file} eq $volid; > }); > } > =20 > - if ($running && do_snapshots_with_qemu($storecfg, $volid, $deviceid)= ) { > - mon_cmd($vmid, 'blockdev-snapshot-delete-internal-sync', device =3D> $d= eviceid, name =3D> $snap); > + if ($attached_deviceid && do_snapshots_with_qemu($storecfg, $volid, = $attached_deviceid)) { > + mon_cmd( > + $vmid, > + 'blockdev-snapshot-delete-internal-sync', > + device =3D> $attached_deviceid, > + name =3D> $snap, > + ); > } else { > - PVE::Storage::volume_snapshot_delete($storecfg, $volid, $snap, $running= ); > + PVE::Storage::volume_snapshot_delete( > + $storecfg, $volid, $snap, $attached_deviceid ? 1 : undef); > } > } > =20 > --=20 > 2.39.2 >=20 >=20 >=20 > _______________________________________________ > pve-devel mailing list > pve-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel >=20 >=20 >=20