[pve-devel] [PATCH] add possibility to restore backup on rbd in krbd mode

Wolfgang Link w.link at proxmox.com
Tue Sep 8 16:05:21 CEST 2015


---
 PVE/QemuServer.pm | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 50b3dd6..93c5c4c 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -5363,6 +5363,8 @@ sub restore_vma_archive {
 	    $d->{volid} = $volid;
 	    my $path = PVE::Storage::path($cfg, $volid);
 
+	    PVE::Storage::activate_volumes($cfg,[$volid]);
+
 	    my $write_zeros = 1;
 	    # fixme: what other storages types initialize volumes with zero?
 	    if ($scfg->{type} eq 'dir' || $scfg->{type} eq 'nfs' || $scfg->{type} eq 'glusterfs' ||
@@ -5428,13 +5430,20 @@ sub restore_vma_archive {
 
     alarm($oldtimeout) if $oldtimeout;
 
+    my $vollist = [];
+    foreach my $devname (keys %$devinfo) {
+	push @$vollist, $devinfo->{$devname}->{volid};
+    }
+
+    my $cfg = cfs_read_file('storage.cfg');
+    PVE::Storage::deactivate_volumes($cfg, $vollist);
+
     unlink $mapfifo;
 
     if ($err) {
 	rmtree $tmpdir;
 	unlink $tmpfn;
 
-	my $cfg = cfs_read_file('storage.cfg');
 	foreach my $devname (keys %$devinfo) {
 	    my $volid = $devinfo->{$devname}->{volid};
 	    next if !$volid;
-- 
2.1.4




More information about the pve-devel mailing list