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

svn-commits at proxmox.com svn-commits at proxmox.com
Tue Sep 21 11:42:15 CEST 2010


Author: dietmar
Date: 2010-09-21 09:42:15 +0000 (Tue, 21 Sep 2010)
New Revision: 5192

Modified:
   qemu-server/pve2/ChangeLog
   qemu-server/pve2/PVE/QemuServer.pm
   qemu-server/pve2/qmigrate
Log:
	* PVE/VZDump/QemuServer.pm: use PVE::QemuServer::foreach_drive()

	* qmigrate: use PVE::QemuServer::foreach_drive()

	* PVE/QemuServer.pm (foreach_drive): new helper.



Modified: qemu-server/pve2/ChangeLog
===================================================================
--- qemu-server/pve2/ChangeLog	2010-09-21 09:23:52 UTC (rev 5191)
+++ qemu-server/pve2/ChangeLog	2010-09-21 09:42:15 UTC (rev 5192)
@@ -1,5 +1,11 @@
 2010-09-21  Proxmox Support Team  <support at proxmox.com>
 
+	* PVE/VZDump/QemuServer.pm: use PVE::QemuServer::foreach_drive()
+
+	* qmigrate: use PVE::QemuServer::foreach_drive()
+
+	* PVE/QemuServer.pm (foreach_drive): new helper.
+
 	* qmigrate (logmsg): remove PVE::QemuServer->new() call.
 
 	* PVE/VZDump/QemuServer.pm (prepare): remove PVE::QemuServer->new() call.

Modified: qemu-server/pve2/PVE/QemuServer.pm
===================================================================
--- qemu-server/pve2/PVE/QemuServer.pm	2010-09-21 09:23:52 UTC (rev 5191)
+++ qemu-server/pve2/PVE/QemuServer.pm	2010-09-21 09:42:15 UTC (rev 5192)
@@ -1739,6 +1739,19 @@
     return $res;
 }
 
+sub foreach_drive {
+    my ($conf, $func) = @_;
+
+    foreach my $ds (keys %$conf) {
+	next if !valid_drivename($ds);
+
+	my $drive = parse_drive ($ds, $conf->{$ds});
+	next if !$drive;
+
+	&$func($ds, $drive);
+    }
+}
+
 sub config_to_command {
     my ($storecfg, $vmid, $conf, $defaults, $migrate_uri) = @_;
 
@@ -1891,11 +1904,9 @@
     #push @$cmd, '-soundhw', $soundhw if $soundhw;
 
     my $vollist = [];
-    foreach my $ds (keys %$conf) {
-	next if !valid_drivename($ds);
 
-	my $drive = parse_drive ($ds, $conf->{$ds});
-	next if !$drive;
+    foreach_drive($conf, sub {
+	my ($ds, $drive) = @_;
 
 	eval { 
 	    PVE::Storage::parse_volume_id ($drive->{file});
@@ -1906,7 +1917,7 @@
 	my $tmp = print_drive_full ($storecfg, $vmid, $drive);
 	$tmp .= ",boot=on" if $conf->{bootdisk} && ($conf->{bootdisk} eq $ds);
 	push @$cmd, '-drive', $tmp;
-    }
+    });
 
     if ($conf->{memory}) {
 	push @$cmd, '-m', $conf->{memory};

Modified: qemu-server/pve2/qmigrate
===================================================================
--- qemu-server/pve2/qmigrate	2010-09-21 09:23:52 UTC (rev 5191)
+++ qemu-server/pve2/qmigrate	2010-09-21 09:42:15 UTC (rev 5192)
@@ -151,22 +151,21 @@
 	# and add used,owned/non-shared disks (just to be sure we have all)  
 
 	my $sharedvm = 1;
-	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};
 
-	    next if !$volid;
+	    return if !$volid;
 	    die "cant migrate local file/device '$volid'\n" if $volid =~ m|^/|;
 
 	    my ($sid, $volname) = PVE::Storage::parse_volume_id ($volid);
-
+	    
 	    my $scfg =  PVE::Storage::storage_config ($storecfg, $sid);
 
-	    next if $scfg->{shared};
+	    return if $scfg->{shared};
 
 	    $sharedvm = 0;
 
@@ -176,7 +175,7 @@
 		if !$owner || ($owner != $vmid);
 
 	    $volhash->{$volid} = 1;
-	}
+	});
 
 	if ($running && !$sharedvm) {
 	    die "can't do online migration - VM uses local disks\n";



More information about the pve-devel mailing list