From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH qemu-server 14/14] qcow2: add external snapshot support
Date: Tue, 13 May 2025 12:48:07 +0200 (CEST) [thread overview]
Message-ID: <1379246505.14356.1747133287907@webmail.proxmox.com> (raw)
In-Reply-To: <mailman.30.1745322744.394.pve-devel@lists.proxmox.com>
> Alexandre Derumier via pve-devel <pve-devel@lists.proxmox.com> hat am 22.04.2025 13:51 CEST geschrieben:
> Signed-off-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
> ---
> PVE/QemuConfig.pm | 4 +-
> PVE/QemuServer.pm | 237 +++++++++++++++++++++++++++++++++++-----
> PVE/QemuServer/Drive.pm | 39 ++++---
> 3 files changed, 239 insertions(+), 41 deletions(-)
>
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index 5cce7094..aff430df 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
[..]
> @@ -4543,13 +4716,36 @@ sub qemu_volume_snapshot_delete {
> });
> }
>
> + my $do_snapshots_with_qemu = do_snapshots_with_qemu($storecfg, $volid, $attached_deviceid);
> +
> if ($attached_deviceid && do_snapshots_with_qemu($storecfg, $volid, $attached_deviceid)) {
> - mon_cmd(
> - $vmid,
> - 'blockdev-snapshot-delete-internal-sync',
> - device => $attached_deviceid,
> - name => $snap,
> - );
> + if ($do_snapshots_with_qemu == 2) {
> + mon_cmd(
> + $vmid,
> + 'blockdev-snapshot-delete-internal-sync',
> + device => $attached_deviceid,
> + name => $snap,
> + );
> + } elsif ($do_snapshots_with_qemu == 3) {
> + print "delete qemu external snapshot\n";
> +
> + my $path = PVE::Storage::path($storecfg, $volid);
> + my $snapshots = PVE::Storage::volume_snapshot_info($storecfg, $volid);
> + my $parentsnap = $snapshots->{$snap}->{parent};
> + my $childsnap = $snapshots->{$snap}->{child};
> +
> + # if we delete the first snasphot, we commit because the first snapshot original base image, it should be big.
> + # improve-me: if firstsnap > child : commit, if firstsnap < child do a stream.
> + if(!$parentsnap) {
> + print"delete first snapshot $snap\n";
> + blockdev_commit($storecfg, $vmid, $attached_deviceid, $drive, $childsnap, $snap);
> + blockdev_rename($storecfg, $vmid, $attached_deviceid, $drive, $snap, $childsnap, $snapshots->{$childsnap}->{child});
> + } else {
> + #intermediate snapshot, we always stream the snapshot to child snapshot
> + print"stream intermediate snapshot $snap to $childsnap\n";
> + blockdev_stream($storecfg, $vmid, $attached_deviceid, $drive, $snap, $parentsnap, $childsnap);
> + }
> + }
something here seems also broken, I did the following:
start VM
add disk on extsnap storage
create snapshot test
create snapshot test2
output of "qm listsnapshot 106":
qm listsnapshot 106
`-> test 2025-05-13 11:59:11 no-description
`-> test2 2025-05-13 12:09:35 no-description
`-> current You are here!
outout of "lvs extsnap"
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
snap-test-vm-106-disk-0.qcow2 extsnap -wi-a----- 36.00g
snap-test2-vm-106-disk-0.qcow2 extsnap -wi-a----- 36.00g
vm-106-disk-0.qcow2 extsnap -wi-a----- 36.00g
output of perl -e 'use PVE::Storage; use Data::Dumper; $Data::Dumper::Sortkeys = 1; print Dumper(PVE::Storage::volume_snapshot_info(PVE::Storage::config(), "extsnap:vm-106-disk-0.qcow2"));'
$VAR1 = {
'current' => {
'ext' => 1,
'file' => '/dev/extsnap/vm-106-disk-0.qcow2',
'order' => 0,
'parent' => 'test2',
'volid' => 'extsnap:vm-106-disk-0.qcow2',
'volname' => 'vm-106-disk-0.qcow2'
},
'test' => {
'child' => 'test2',
'ext' => 1,
'file' => '/dev/extsnap/snap-test-vm-106-disk-0.qcow2',
'order' => 2,
'volid' => 'extsnap:snap-test-vm-106-disk-0.qcow2',
'volname' => 'snap-test-vm-106-disk-0.qcow2'
},
'test2' => {
'child' => 'current',
'ext' => 1,
'file' => '/dev/extsnap/snap-test2-vm-106-disk-0.qcow2',
'order' => 1,
'parent' => 'test',
'volid' => 'extsnap:snap-test2-vm-106-disk-0.qcow2',
'volname' => 'snap-test2-vm-106-disk-0.qcow2'
}
};
removed snapshot test2 while VM is running:
delete qemu external snapshot
stream intermediate snapshot test2 to current
stream-drive-scsi1: transferred 309.0 MiB of 32.0 GiB (0.94%) in 0s
stream-drive-scsi1: stream-job finished
delete old /dev/extsnap/snap-test2-vm-106-disk-0.qcow2
TASK ERROR: error deleting snapshot test2
from journal:
May 13 12:36:29 pve74test01 pvedaemon[68741]: <root@pam> starting task UPID:pve74test01:00013D6E:0010F721:682320AD:qmdelsnapshot:106:root@pam:
May 13 12:36:29 pve74test01 pvedaemon[81262]: <root@pam> delete snapshot VM 106: test2
May 13 12:36:31 pve74test01 pvedaemon[81262]: VM 106 qmp command failed - VM 106 qmp command 'blockdev-del' failed - Failed to find node with node-name='e-VgFpR5u0cSSgGcquQm4semoCyWK'
May 13 12:36:31 pve74test01 pvedaemon[81262]: VM 106 qmp command failed - VM 106 qmp command 'blockdev-del' failed - Failed to find node with node-name='f-VgFpR5u0cSSgGcquQm4semoCyWK'
May 13 12:36:31 pve74test01 pvedaemon[81262]: error deleting snapshot test2
May 13 12:36:31 pve74test01 pvedaemon[68741]: <root@pam> end task UPID:pve74test01:00013D6E:0010F721:682320AD:qmdelsnapshot:106:root@pam: error deleting snapshot test2
starting over, VM not running, all traces of snapshots and old volumes removed.
add new disk on extsnap storage
create snapshot test
create snapshot test2
remove snapshot test:
commit: merge content of /dev/extsnap/snap-test2-vm-106-disk-0.qcow2 into /dev/extsnap/snap-test-vm-106-disk-0.qcow2
Image committed.
delete snap-test2-vm-106-disk-0.qcow2
TASK ERROR: error delete old snapshot volume snap-test2-vm-106-disk-0.qcow2: unable to parse lvm volume name 'snap-test2-vm-106-disk-0.qcow2'
starting over, VM not running, all traces of snapshots and old volumes removed.
add new disk on extsnap storage
create snapshot test
create snapshot test2
remove snapshot test2:
rebase: merge diff content between /dev/extsnap/snap-test-vm-106-disk-0.qcow2 and /dev/extsnap/vm-106-disk-0.qcow2 into /dev/extsnap/vm-106-disk-0.qcow2
error delete old snapshot volume snap-test2-vm-106-disk-0.qcow2
what??
it seems to me you didn't really test the version you sent w.r.t. basic snapshot actions?
> } else {
> PVE::Storage::volume_snapshot_delete(
> $storecfg, $volid, $snap, $attached_deviceid ? 1 : undef);
> @@ -7778,27 +7974,16 @@ sub foreach_storage_used_by_vm {
> }
> }
>
> -my $qemu_snap_storage = {
> - rbd => 1,
> -};
> sub do_snapshots_with_qemu {
> my ($storecfg, $volid, $deviceid) = @_;
>
> - return if $deviceid =~ m/tpmstate0/;
> + return if $deviceid && $deviceid =~ m/tpmstate0/;
>
> - my $storage_name = PVE::Storage::parse_volume_id($volid);
> - my $scfg = $storecfg->{ids}->{$storage_name};
> - die "could not find storage '$storage_name'\n" if !defined($scfg);
> + my $snapshot_type = PVE::Storage::volume_has_feature($storecfg, 'snapshot', $volid);
>
> - if ($qemu_snap_storage->{$scfg->{type}} && !$scfg->{krbd}){
> - return 1;
> - }
> + return $snapshot_type if $snapshot_type == 2 || $snapshot_type == 3;
>
> - if ($volid =~ m/\.(qcow2|qed)$/){
> - return 1;
> - }
> -
> - return;
> + return undef;
> }
>
> sub qga_check_running {
> diff --git a/PVE/QemuServer/Drive.pm b/PVE/QemuServer/Drive.pm
> index 0737034d..93903a59 100644
> --- a/PVE/QemuServer/Drive.pm
> +++ b/PVE/QemuServer/Drive.pm
> @@ -27,6 +27,9 @@ print_drive
> print_drive_throttle_group
> generate_drive_blockdev
> generate_throttle_group
> +generate_blockdev_throttle
> +generate_format_blockdev
> +generate_file_blockdev
> );
>
> our $QEMU_FORMAT_RE = qr/raw|qcow|qcow2|qed|vmdk|cloop/;
> @@ -1074,6 +1077,8 @@ sub print_drive_throttle_group {
> sub generate_file_blockdev {
> my ($storecfg, $drive, $snap, $nodename) = @_;
>
> + $snap = undef if $snap && $snap eq 'current';
> +
> my $volid = $drive->{file};
> my $driveid = get_drive_id($drive);
>
> @@ -1209,6 +1214,8 @@ sub generate_file_blockdev {
> sub generate_format_blockdev {
> my ($storecfg, $drive, $file, $snap, $nodename) = @_;
>
> + $snap = undef if $snap && $snap eq 'current';
> +
> my $volid = $drive->{file};
> #nbd don't support format blockdev, return the fileblockdev
> return $file if $volid =~ /^nbd:/;
> @@ -1280,6 +1287,15 @@ sub generate_backing_chain_blockdev {
> return $chain_blockdev;
> }
>
> +sub generate_blockdev_throttle {
> + my ($drive, $blockdev_file) = @_;
> +
> + my $drive_id = get_drive_id($drive);
> + #this is the topfilter entry point, use $drive-drive_id as nodename
> + my $blockdev_throttle = { driver => "throttle", 'node-name' => "drive-$drive_id", 'throttle-group' => "throttle-drive-$drive_id", 'file' => $blockdev_file };
> + return $blockdev_throttle;
> +}
> +
> sub generate_drive_blockdev {
> my ($storecfg, $drive, $live_restore_name) = @_;
>
> @@ -1303,22 +1319,19 @@ sub generate_drive_blockdev {
> #pflash0 don't support throttle-filter
> return $blockdev_format if $drive_id eq 'pflash0';
>
> - my $blockdev_live_restore = undef;
> - if ($live_restore_name) {
> - die "$drive_id: Proxmox Backup Server backed drive cannot auto-detect the format\n"
> - if !$drive->{format};
> + return generate_blockdev_throttle($drive, $blockdev_format) if !$live_restore_name;
>
> - $blockdev_live_restore = { 'node-name' => "liverestore-drive-$drive_id",
> - backing => $live_restore_name,
> - 'auto-remove' => 'on', format => "alloc-track",
> - file => $blockdev_format };
> - }
> + die "$drive_id: Proxmox Backup Server backed drive cannot auto-detect the format\n"
> + if !$drive->{format};
>
> - #this is the topfilter entry point, use $drive-drive_id as nodename
> - my $blockdev_throttle = { driver => "throttle", 'node-name' => "drive-$drive_id", 'throttle-group' => "throttle-drive-$drive_id" };
> #put liverestore filter between throttle && format filter
> - $blockdev_throttle->{file} = $live_restore_name ? $blockdev_live_restore : $blockdev_format;
> - return $blockdev_throttle,
> + my $blockdev_live_restore = { 'node-name' => "liverestore-drive-$drive_id",
> + backing => $live_restore_name,
> + 'auto-remove' => 'on', format => "alloc-track",
> + file => $blockdev_format };
> +
> + return generate_blockdev_throttle($drive, $blockdev_live_restore);
> +
> }
>
> sub encode_base62 {
> --
> 2.39.5
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2025-05-13 10:47 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20250422115141.808427-1-alexandre.derumier@groupe-cyllene.com>
2025-04-22 11:51 ` [pve-devel] [PATCH pve-qemu 1/1] add block-commit-replaces option patch Alexandre Derumier via pve-devel
2025-05-06 9:00 ` Fiona Ebner
2025-05-06 9:19 ` DERUMIER, Alexandre via pve-devel
2025-05-06 13:35 ` DERUMIER, Alexandre via pve-devel
2025-04-22 11:51 ` [pve-devel] [PATCH pve-storage 1/5] rename_volume: add source && target snap Alexandre Derumier via pve-devel
2025-04-22 11:51 ` [pve-devel] [PATCH qemu-server 01/14] tests: add cfg2cmd for disk passthrough, rbd, krbd && zfs-over-scsi Alexandre Derumier via pve-devel
2025-05-06 9:40 ` [pve-devel] applied: " Fiona Ebner
2025-04-22 11:51 ` [pve-devel] [PATCH qemu-server 02/14] blockdev: cmdline: convert drive to blockdev syntax Alexandre Derumier via pve-devel
2025-05-06 11:12 ` Fiona Ebner
2025-05-06 14:20 ` DERUMIER, Alexandre via pve-devel
[not found] ` <c41fa01bb76db97a0e496255992abb33c292db78.camel@groupe-cyllene.com>
2025-05-08 11:27 ` Fiona Ebner
2025-05-06 12:57 ` Fiona Ebner
2025-05-06 14:48 ` DERUMIER, Alexandre via pve-devel
2025-05-06 15:40 ` DERUMIER, Alexandre via pve-devel
[not found] ` <3534d9cd994e60ca891cb5ad443ff572e387c33c.camel@groupe-cyllene.com>
2025-05-08 11:21 ` Fiona Ebner
2025-05-09 8:20 ` DERUMIER, Alexandre via pve-devel
[not found] ` <0e129451ee74c8e13d8f3087ff3edf52efb1c220.camel@groupe-cyllene.com>
2025-05-09 9:24 ` Fiona Ebner
2025-05-12 15:33 ` DERUMIER, Alexandre via pve-devel
[not found] ` <3f363e6e281acb4abadee5cc521a313c4c815a1f.camel@groupe-cyllene.com>
2025-05-13 7:17 ` Fiona Ebner
2025-05-07 8:41 ` Fabian Grünbichler
2025-05-08 11:09 ` Fiona Ebner
2025-04-22 11:51 ` [pve-devel] [PATCH pve-storage 2/5] qcow2: add external snapshot support Alexandre Derumier via pve-devel
2025-05-09 10:30 ` Fabian Grünbichler
2025-05-19 12:08 ` DERUMIER, Alexandre via pve-devel
2025-05-19 13:01 ` DERUMIER, Alexandre via pve-devel
[not found] ` <f3e3b85180f5c09410cb33fe9bac2fac216cbf67.camel@groupe-cyllene.com>
2025-05-20 8:58 ` Fabian Grünbichler
2025-05-21 7:02 ` DERUMIER, Alexandre via pve-devel
[not found] ` <c5c69c923d03a512b85067473c1f65f4eefb9a0d.camel@groupe-cyllene.com>
2025-05-20 9:01 ` Fabian Grünbichler
2025-05-14 13:01 ` Fabian Grünbichler
2025-04-22 11:51 ` [pve-devel] [PATCH qemu-server 03/14] blockdev: convert ovmf && efidisk to blockdev Alexandre Derumier via pve-devel
2025-04-22 11:51 ` [pve-devel] [PATCH pve-storage 3/5] lvmplugin: add qcow2 snapshot Alexandre Derumier via pve-devel
2025-05-09 10:30 ` Fabian Grünbichler
2025-05-13 9:54 ` Fabian Grünbichler
2025-05-13 18:13 ` DERUMIER, Alexandre via pve-devel
[not found] ` <60d45a0673902097185cbb909a47ac7f8868016d.camel@groupe-cyllene.com>
2025-05-13 18:37 ` DERUMIER, Alexandre via pve-devel
[not found] ` <3f47953b87cda70c49c1c33104c0aa8e966173ff.camel@groupe-cyllene.com>
2025-05-14 7:05 ` DERUMIER, Alexandre via pve-devel
2025-04-22 11:51 ` [pve-devel] [PATCH qemu-server 04/14] blockdev : convert qemu_driveadd && qemu_drivedel Alexandre Derumier via pve-devel
2025-04-22 11:51 ` [pve-devel] [PATCH pve-storage 4/5] storage: vdisk_free: remove external snapshots Alexandre Derumier via pve-devel
2025-05-09 10:29 ` Fabian Grünbichler
2025-05-10 12:28 ` DERUMIER, Alexandre via pve-devel
[not found] ` <5ce9a098f67adeb61244c597d610802e318494bf.camel@groupe-cyllene.com>
2025-05-13 12:06 ` Fabian Grünbichler
2025-05-13 17:57 ` DERUMIER, Alexandre via pve-devel
2025-04-22 11:51 ` [pve-devel] [PATCH qemu-server 05/14] replace qemu_block_set_io_throttle with qom-set throttlegroup limits Alexandre Derumier via pve-devel
2025-04-22 11:51 ` [pve-devel] [PATCH pve-storage 5/5] volume_has_feature: return storage|qemu_internal|qemu_external snapshot_type Alexandre Derumier via pve-devel
2025-04-22 11:51 ` [pve-devel] [PATCH qemu-server 06/14] blockdev: vm_devices_list : fix block-query Alexandre Derumier via pve-devel
2025-04-22 11:51 ` [pve-devel] [PATCH qemu-server 07/14] blockdev: convert cdrom media eject/insert Alexandre Derumier via pve-devel
2025-04-22 11:51 ` [pve-devel] [PATCH qemu-server 08/14] blockdev: block_resize: convert to blockdev Alexandre Derumier via pve-devel
2025-04-22 11:51 ` [pve-devel] [PATCH qemu-server 09/14] blockdev: nbd_export: block-export-add : use drive-$id for nodename Alexandre Derumier via pve-devel
2025-04-22 11:51 ` [pve-devel] [PATCH qemu-server 10/14] blockdev: convert drive_mirror to blockdev_mirror Alexandre Derumier via pve-devel
2025-04-22 11:51 ` [pve-devel] [PATCH qemu-server 11/14] blockdev: change aio on target if io_uring is not default Alexandre Derumier via pve-devel
2025-04-22 11:51 ` [pve-devel] [PATCH qemu-server 12/14] qemu_img convert : add external snapshot support Alexandre Derumier via pve-devel
2025-05-09 10:30 ` Fabian Grünbichler
2025-05-27 13:48 ` DERUMIER, Alexandre via pve-devel
[not found] ` <fe6ff7f68a7bd2aae347e6c7630617495b6ae365.camel@groupe-cyllene.com>
2025-05-27 14:49 ` DERUMIER, Alexandre via pve-devel
2025-04-22 11:51 ` [pve-devel] [PATCH qemu-server 13/14] blockdev: add backing_chain support Alexandre Derumier via pve-devel
2025-05-09 10:30 ` Fabian Grünbichler
2025-05-28 9:08 ` DERUMIER, Alexandre via pve-devel
2025-05-28 10:07 ` Fiona Ebner
2025-05-28 14:30 ` DERUMIER, Alexandre via pve-devel
2025-04-22 11:51 ` [pve-devel] [PATCH qemu-server 14/14] qcow2: add external snapshot support Alexandre Derumier via pve-devel
2025-05-09 10:30 ` Fabian Grünbichler
2025-05-13 10:11 ` Fabian Grünbichler
2025-05-13 10:48 ` Fabian Grünbichler [this message]
2025-05-13 18:02 ` DERUMIER, Alexandre via pve-devel
2025-05-14 10:45 ` DERUMIER, Alexandre via pve-devel
[not found] ` <7a7870acf85fdab270549692e05bf436a74c6f3c.camel@groupe-cyllene.com>
2025-05-14 12:14 ` Fabian Grünbichler
2025-05-14 12:56 ` DERUMIER, Alexandre via pve-devel
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=1379246505.14356.1747133287907@webmail.proxmox.com \
--to=f.gruenbichler@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal