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

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


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

 PVE/QemuConfig.pm | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/PVE/QemuConfig.pm b/PVE/QemuConfig.pm
index c9c5e60..3ce95ac 100644
--- a/PVE/QemuConfig.pm
+++ b/PVE/QemuConfig.pm
@@ -264,6 +264,35 @@ sub __snapshot_rollback_vm_start {
     PVE::QemuServer::vm_start($storecfg, $vmid, $statefile, undef, undef, undef, $forcemachine);
 }
 
+sub __snapshot_rollback_get_unused {
+    my ($class, $conf, $snap) = @_;
+
+    my $unused = [];
+
+    $class->__snapshot_foreach_volume($conf, sub {
+	my ($vs, $volume) = @_;
+
+	return if PVE::QemuServer::drive_is_cdrom($volume);
+
+	my $found = 0;
+	my $volid = $volume->{file};
+
+	$class->__snapshot_foreach_volume($snap, sub {
+	    my ($ds, $drive) = @_;
+
+	    return if $found;
+	    return if PVE::QemuServer::drive_is_cdrom($drive);
+
+	    $found = 1
+		if ($drive->{file} && $drive->{file} 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