--- Begin Message ---
Allows picking between atomic and sequential snapshots

Default sequential

Signed-off-by: Demayl <denis.kanc...@storpool.com>
---
 PVE/API2/Qemu.pm  |  7 ++++++-
 PVE/QemuConfig.pm | 13 +++++++++++++
 PVE/QemuServer.pm | 10 ++++++++++
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 626cce45..27d86438 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -5488,6 +5488,11 @@ __PACKAGE__->register_method({
                type => 'string',
                description => "A textual description or comment.",
            },
+           type => {
+               optional => 1,
+               type => 'string',
+               description => "Sequential or atomic snapshot of VM volumes (if 
supported by storage)",
+           },
        },
     },
     returns => {
@@ -5519,7 +5524,7 @@ __PACKAGE__->register_method({
        my $realcmd = sub {
            PVE::Cluster::log_msg('info', $authuser, "snapshot VM $vmid: 
$snapname");
            PVE::QemuConfig->snapshot_create($vmid, $snapname, 
$param->{vmstate},
-                                            $param->{description});
+                                            $param->{description}, 
$param->{type});
        };
 
        return $rpcenv->fork_worker('qmsnapshot', $vmid, $authuser, $realcmd);
diff --git a/PVE/QemuConfig.pm b/PVE/QemuConfig.pm
index 2609542c..7f6399c7 100644
--- a/PVE/QemuConfig.pm
+++ b/PVE/QemuConfig.pm
@@ -367,6 +367,19 @@ sub __snapshot_create_vol_snapshots_hook {
     }
 }
 
+sub get_atomic_snapshot_volumes {
+    my ($class, $conf) = @_;
+
+    my $volumes = $class->SUPER::get_atomic_snapshot_volumes($conf);
+    my $filtered = {};
+    for my $vol_name (keys %{$volumes}) {
+       if (! PVE::QemuServer::drive_is_cdrom($volumes->{$vol_name})) {
+               $filtered->{$vol_name} = $volumes->{$vol_name};
+       }
+    }
+    return $filtered;
+}
+
 sub __snapshot_create_vol_snapshot {
     my ($class, $vmid, $ds, $drive, $snapname) = @_;
 
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 577959a4..5c14ce49 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2809,6 +2809,10 @@ our $vmstatus_return_properties = {
        type => 'boolean',
        optional => 1,
     },
+    snapshots => {
+       description => "Snapshot info.",
+       type => 'object',
+    },
 };
 
 my $last_proc_pid_stat;
@@ -2881,6 +2885,12 @@ sub vmstatus {
        $d->{tags} = $conf->{tags} if defined($conf->{tags});
 
        $res->{$vmid} = $d;
+
+       my ($can_atomic, $pref_atomic, undef) = 
PVE::QemuConfig->check_atomic_snapshots($conf);
+       $res->{$vmid}->{snapshots} = {
+           atomic_possible => $can_atomic,
+           atomic_preferred => $pref_atomic,
+       };
     }
 
     my $netdev = PVE::ProcFSTools::read_proc_net_dev();
-- 
2.43.0



--- End Message ---
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to