[lxc-devel] [lxd/master] lxd/vm: Reverse interface counters

stgraber on Github lxc-bot at linuxcontainers.org
Thu Nov 21 14:17:48 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20191121/7569a000/attachment.bin>
-------------- next part --------------
From 3c5f3b9f248258a5998ba7cf3e7d7ec745ec042f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 21 Nov 2019 09:17:31 -0500
Subject: [PATCH] lxd/vm: Reverse interface counters
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/vm_qemu.go | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/lxd/vm_qemu.go b/lxd/vm_qemu.go
index 19781a3d2f..e4d2524525 100644
--- a/lxd/vm_qemu.go
+++ b/lxd/vm_qemu.go
@@ -2413,14 +2413,21 @@ func (vm *vmQemu) RenderState() (*api.InstanceState, error) {
 					m["host_name"] = vm.localConfig[fmt.Sprintf("volatile.%s.host_name", k)]
 				}
 
+				hostCounters := shared.NetworkGetCounters(m["host_name"])
+
 				networks[k] = api.InstanceStateNetwork{
 					Addresses: addresses,
-					Counters:  api.InstanceStateNetworkCounters(shared.NetworkGetCounters(m["host_name"])),
-					Hwaddr:    m["hwaddr"],
-					HostName:  m["host_name"],
-					Mtu:       iface.MTU,
-					State:     "up",
-					Type:      "broadcast",
+					Counters: api.InstanceStateNetworkCounters{
+						BytesReceived:   hostCounters.BytesSent,
+						BytesSent:       hostCounters.BytesReceived,
+						PacketsReceived: hostCounters.PacketsSent,
+						PacketsSent:     hostCounters.PacketsReceived,
+					},
+					Hwaddr:   m["hwaddr"],
+					HostName: m["host_name"],
+					Mtu:      iface.MTU,
+					State:    "up",
+					Type:     "broadcast",
 				}
 			}
 


More information about the lxc-devel mailing list