[pve-devel] [PATCH v2 qemu-server 11/28] Extend snapshot_foreach_volume to allow different selections of volumes

Fabian Ebner f.ebner at proxmox.com
Mon Feb 24 13:44:01 CET 2020


Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
 PVE/QemuConfig.pm | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/PVE/QemuConfig.pm b/PVE/QemuConfig.pm
index b0dc3b9..b6a465e 100644
--- a/PVE/QemuConfig.pm
+++ b/PVE/QemuConfig.pm
@@ -394,7 +394,7 @@ sub __snapshot_rollback_get_unused {
 
     my $unused = [];
 
-    $class->__snapshot_foreach_volume($conf, sub {
+    $class->snapshot_foreach_volume($conf, undef, sub {
 	my ($vs, $volume) = @_;
 
 	return if PVE::QemuServer::drive_is_cdrom($volume);
@@ -402,7 +402,7 @@ sub __snapshot_rollback_get_unused {
 	my $found = 0;
 	my $volid = $volume->{file};
 
-	$class->__snapshot_foreach_volume($snap, sub {
+	$class->snapshot_foreach_volume($snap, undef, sub {
 	    my ($ds, $drive) = @_;
 
 	    return if $found;
@@ -418,10 +418,19 @@ sub __snapshot_rollback_get_unused {
     return $unused;
 }
 
-sub __snapshot_foreach_volume {
-    my ($class, $conf, $func) = @_;
+sub snapshot_foreach_volume {
+    my ($class, $conf, $opts, $func, @param) = @_;
 
-    PVE::QemuServer::foreach_drive($conf, $func);
+    PVE::QemuServer::foreach_drive($conf, $func, @param);
+
+    if ($opts->{include_unused}) {
+	$class->snapshot_foreach_unused_volume($conf, $func, @param);
+    }
+
+    if ($opts->{include_vmstate} && defined($conf->{vmstate})) {
+	my $volume = $class->parse_volume('vmstate', $conf->{vmstate}, 1);
+	$func->('vmstate', $volume, @param);
+    }
 }
 # END implemented abstract methods from PVE::AbstractConfig
 
-- 
2.20.1




More information about the pve-devel mailing list