[pve-devel] [PATCH container] fix 1046: add non-snapshotted disks as unused

Fabian Grünbichler f.gruenbichler at proxmox.com
Mon Jul 4 13:04:13 CEST 2016


---
Note: container part, apply together with common and qemu-server part

 src/PVE/LXC/Config.pm | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm
index 0ad32f4..6b0ed4f 100644
--- a/src/PVE/LXC/Config.pm
+++ b/src/PVE/LXC/Config.pm
@@ -174,6 +174,35 @@ sub __snapshot_rollback_vm_start {
     die "implement me - save vmstate\n";
 }
 
+sub __snapshot_rollback_get_unused {
+    my ($class, $conf, $snap) = @_;
+
+    my $unused = [];
+
+    $class->__snapshot_foreach_volume($conf, sub {
+	my ($vs, $volume) = @_;
+
+	return if $volume->{type} ne 'volume';
+
+	my $found = 0;
+	my $volid = $volume->{volume};
+
+	$class->__snapshot_foreach_volume($snap, sub {
+	    my ($ms, $mountpoint) = @_;
+
+	    return if $found;
+	    return if ($mountpoint->{type} ne 'volume');
+
+	    $found = 1
+		if ($mountpoint->{volume} && $mountpoint->{volume} eq $volid);
+	});
+
+	push @$unused, $volid if !$found;
+    });
+
+    return $unused;
+}
+
 sub __snapshot_foreach_volume {
     my ($class, $conf, $func) = @_;
 
-- 
2.1.4





More information about the pve-devel mailing list