[pve-devel] r5193 - in qemu-server/pve2/PVE: . VZDump

svn-commits at proxmox.com svn-commits at proxmox.com
Tue Sep 21 11:44:27 CEST 2010


Author: dietmar
Date: 2010-09-21 09:44:27 +0000 (Tue, 21 Sep 2010)
New Revision: 5193

Modified:
   qemu-server/pve2/PVE/QemuServer.pm
   qemu-server/pve2/PVE/VZDump/QemuServer.pm
Log:


Modified: qemu-server/pve2/PVE/QemuServer.pm
===================================================================
--- qemu-server/pve2/PVE/QemuServer.pm	2010-09-21 09:42:15 UTC (rev 5192)
+++ qemu-server/pve2/PVE/QemuServer.pm	2010-09-21 09:44:27 UTC (rev 5193)
@@ -1154,13 +1154,11 @@
     my $vollist = [];
 
     eval {
-	foreach my $ds (keys %$settings) {
-	    next if !valid_drivename($ds); # only drives
+	foreach_drive($settings, sub {
+	    my ($ds, $disk) = @_;
 
-	    my $disk = parse_drive ($ds, $settings->{$ds});
+	    return if drive_is_cdrom ($disk);
 
-	    next if drive_is_cdrom ($disk);
-
 	    my $file = $disk->{file};
 
 	    if ($file =~ m/^(([^:\s]+):)?(\d+(\.\d+)?)$/) {
@@ -1188,7 +1186,7 @@
 		    die "image '$path' does not exists\n";
 		}
 	    }
-	}
+	});
     };
 
     my $err = $@;
@@ -1233,14 +1231,11 @@
     check_lock ($conf);
 
     # only remove disks owned by this VM 
-    foreach my $ds (keys %$conf) {
-	next if !valid_drivename($ds);
+    foreach_drive($conf, sub {
+	my ($ds, $drive) = @_;
 
-	my $drive = parse_drive ($ds, $conf->{$ds});
-	next if !$drive;
+ 	return if drive_is_cdrom ($drive);
 
-	next if drive_is_cdrom ($drive);
-
 	my $volid = $drive->{file};
 	next if !$volid || $volid =~ m|^/|;
 
@@ -1248,7 +1243,7 @@
 	next if !$path || !$owner || ($owner != $vmid);
 
 	PVE::Storage::vdisk_free ($storecfg, $volid);
-    }
+    });
     
     unlink $conffile;
 
@@ -1276,22 +1271,19 @@
     my $res = {};
     my $vollist;
 
-    foreach my $ds (keys %$conf) {
-	next if !valid_drivename($ds);
+    foreach_drive($conf, sub {
+	my ($ds, $di) = @_;
 
-	my $di = parse_drive ($ds, $conf->{$ds});
-	next if !$di;
-
 	$res->{$ds} = $di;
 
-	next if drive_is_cdrom ($di);
+	return if drive_is_cdrom ($di);
 
 	if ($di->{file} =~ m|^/dev/.+|) {
 	    $info->{$di->{file}}->{size} = PVE::Storage::file_size_info ($di->{file});
 	} else {
 	    push @$vollist, $di->{file};
 	}
-    }
+    });
 
     eval {
 	my $dl = PVE::Storage::vdisk_list ($storecfg, undef, $vmid, $vollist);

Modified: qemu-server/pve2/PVE/VZDump/QemuServer.pm
===================================================================
--- qemu-server/pve2/PVE/VZDump/QemuServer.pm	2010-09-21 09:42:15 UTC (rev 5192)
+++ qemu-server/pve2/PVE/VZDump/QemuServer.pm	2010-09-21 09:44:27 UTC (rev 5193)
@@ -76,11 +76,10 @@
 
     my $snapshot_count = 0;
 
-    foreach my $ds (keys %$conf) {
-	next if ! PVE::QemuServer::valid_drivename($ds); # only drives
+    PVE::QemuServer::foreach_drive($conf, sub {
+	my ($ds, $drive) = @_;
 
-	my $drive = PVE::QemuServer::parse_drive ($ds, $conf->{$ds});
-	next if PVE::QemuServer::drive_is_cdrom ($drive);
+	return if PVE::QemuServer::drive_is_cdrom ($drive);
 
 	my $volid = $drive->{file};
 
@@ -94,6 +93,8 @@
 	    $path = $volid;
 	}
 
+	return if !$path;
+
 	die "no such volume '$volid'\n" if ! -e $path;
 
 	my $diskinfo = { path => $path , volid => $volid, storeid => $storeid, 
@@ -174,7 +175,7 @@
 
 	push @{$task->{disks}}, $diskinfo;
 
-    }
+    });
 
     $task->{snapshot_count} = $snapshot_count;
 }




More information about the pve-devel mailing list