[pve-devel] [PATCH v2 qemu-server 7/9] ipam : add snaphot delete support

Alexandre Derumier aderumier at odiso.com
Mon Jul 12 00:47:05 CEST 2021


This should be move to abstract config with a new hook

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/API2/Qemu.pm | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index e2a6a0a..aaefcec 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -4308,7 +4308,15 @@ __PACKAGE__->register_method({
 
 	my $realcmd = sub {
 	    PVE::Cluster::log_msg('info', $authuser, "delete snapshot VM $vmid: $snapname");
+	    my $conf = PVE::QemuConfig->load_config($vmid);
+	    my $checkcurrent = 1;
+	    foreach my $opt (keys %{$conf->{snapshots}->{$snapname}}) {
+		next if $opt !~ m/^net(\d+)$/;
+                my $net = PVE::QemuServer::parse_net($conf->{snapshots}->{$snapname}->{$opt});
+                PVE::QemuServer::vmconfig_delete_net_ip($conf, $net, $snapname, $checkcurrent);
+	    }
 	    PVE::QemuConfig->snapshot_delete($vmid, $snapname, $param->{force});
+
 	};
 
 	return $rpcenv->fork_worker('qmdelsnapshot', $vmid, $authuser, $realcmd);
-- 
2.30.2





More information about the pve-devel mailing list