[pve-devel] [PATCH qemu-server 4/5] use foreach_drive instead of foreach_volid

Fabian Grünbichler f.gruenbichler at proxmox.com
Fri Jun 17 16:12:28 CEST 2016


foreach_volid recurses over snapshots as well, resulting in
lots of repeated checks (especially for VMs with lots of
snapshots and disks).

a potential vmstate volume must be checked explicitly,
because foreach_drive does not care about those.
---
 PVE/QemuMigrate.pm | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
index 5bfdc05..e7a1d8a 100644
--- a/PVE/QemuMigrate.pm
+++ b/PVE/QemuMigrate.pm
@@ -299,9 +299,17 @@ sub sync_disks {
 	    }
 	};
 
-	PVE::QemuServer::foreach_volid($conf, $test_volid);
+	my $test_drive = sub {
+	    my ($ds, $drive, $snapname) = @_;
+
+	    &$test_volid($drive->{file}, PVE::QemuServer::drive_is_cdrom($drive), $snapname);
+	};
+
+	PVE::QemuServer::foreach_drive($conf, $test_drive);
 	foreach my $snapname (keys %{$conf->{snapshots}}) {
-	    PVE::QemuServer::foreach_volid($conf->{snapshots}->{$snapname}, $test_volid, $snapname);
+	    &$test_volid($conf->{snapshots}->{$snapname}->{'vmstate'}, 0, undef)
+		if defined($conf->{snapshots}->{$snapname}->{'vmstate'});
+	    PVE::QemuServer::foreach_drive($conf->{snapshots}->{$snapname}, $test_drive, $snapname);
 	}
 
 	if ($self->{running} && !$sharedvm) {
-- 
2.1.4




More information about the pve-devel mailing list