[pve-devel] r5671 - qemu-server/pve2/PVE

svn-commits at proxmox.com svn-commits at proxmox.com
Thu Mar 10 06:55:39 CET 2011


Author: dietmar
Date: 2011-03-10 06:55:39 +0100 (Thu, 10 Mar 2011)
New Revision: 5671

Modified:
   qemu-server/pve2/PVE/QemuServer.pm
Log:
improve clumsy code


Modified: qemu-server/pve2/PVE/QemuServer.pm
===================================================================
--- qemu-server/pve2/PVE/QemuServer.pm	2011-03-10 05:52:02 UTC (rev 5670)
+++ qemu-server/pve2/PVE/QemuServer.pm	2011-03-10 05:55:39 UTC (rev 5671)
@@ -1642,8 +1642,6 @@
     my $list =  vzlist();
     my ($uptime) = PVE::ProcFSTools::read_proc_uptime();
 
-    my $netdev = PVE::ProcFSTools::read_proc_net_dev();
-
     foreach my $vmid (keys %$list) {
 	my $cfspath = cfs_config_path($vmid);
 	my $conf = PVE::Cluster::cfs_read_file($cfspath) || {};
@@ -1678,6 +1676,17 @@
 	$res->{$vmid} = $d;
     }
 
+    my $netdev = PVE::ProcFSTools::read_proc_net_dev();
+    foreach my $dev (keys %$netdev) {
+	next if $dev !~ m/^tap([1-9]\d*)i/;
+	my $vmid = $1;
+	my $d = $res->{$vmid};
+	next if !$d;
+	
+	$d->{netout} += $netdev->{$dev}->{receive};
+	$d->{netin} += $netdev->{$dev}->{transmit};
+    }
+
     my $cpuinfo = PVE::ProcFSTools::read_cpuinfo();
     my $cpucount = $cpuinfo->{cpus} || 1;
     my $ctime = gettimeofday;
@@ -1708,12 +1717,6 @@
 	    $d->{mem} = int (($rss/$vsize)*$d->{maxmem});
 	}
 
-	foreach my $dev (keys %$netdev) {
-	    next if $dev !~ m/^tap\Q${vmid}\Ei/;
-	    $d->{netout} += $netdev->{$dev}->{receive};
-	    $d->{netin} += $netdev->{$dev}->{transmit};
-	}
-
 	my $old = $last_proc_pid_stat->{$pid};
 	if (!$old) {
 	    $last_proc_pid_stat->{$pid} = { 




More information about the pve-devel mailing list