[PATCH] TX/RX network stats are swapped

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I noticed that the stats reported by virDomainInterfaceStats appeared to be swapped around. If the domain was downloading a lot of information, then tx_bytes would increase quickly (I'd expect rx_bytes to increase more if the domain was downloading).

The problem is that xen_internal.c measures the TX/RX from the point of view of dom0. So that if dom0 is TRANSMITTING a lot of data up to the domain, then that domain is really RECEIVING it.

Yes, I feel like an idiot ...

Fix attached.

Rich.

--
Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod
Street, Windsor, Berkshire, SL4 1TE, United Kingdom.  Registered in
England and Wales under Company Registration No. 03798903
Index: src/xen_internal.c
===================================================================
RCS file: /data/cvs/libvirt/src/xen_internal.c,v
retrieving revision 1.93
diff -u -r1.93 xen_internal.c
--- src/xen_internal.c	21 Aug 2007 10:08:12 -0000	1.93
+++ src/xen_internal.c	29 Aug 2007 13:10:02 -0000
@@ -1424,11 +1424,17 @@
         long long tx_errs;
         long long tx_drop;
 
+        /* IMPORTANT NOTE!
+         * /proc/net/dev vif<domid>.nn sees the network from the point
+         * of view of dom0 / hypervisor.  So bytes TRANSMITTED by dom0
+         * are bytes RECEIVED by the domain.  That's why the TX/RX fields
+         * appear to be swapped here.
+         */
         if (sscanf (line, "vif%d.%d: %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld",
                     &domid, &port,
-                    &rx_bytes, &rx_packets, &rx_errs, &rx_drop,
-                    &dummy, &dummy, &dummy, &dummy,
                     &tx_bytes, &tx_packets, &tx_errs, &tx_drop,
+                    &dummy, &dummy, &dummy, &dummy,
+                    &rx_bytes, &rx_packets, &rx_errs, &rx_drop,
                     &dummy, &dummy, &dummy, &dummy) != 18)
             continue;
 

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]