[lxc-devel] [lxd/master] container/lxc: Fixes showing host_name of veth pair in lxc info

tomponline on Github lxc-bot at linuxcontainers.org
Mon Jul 8 13:33:27 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 428 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190708/3c724868/attachment.bin>
-------------- next part --------------
From 574647277a1874cb08033cd8cb837eb6dcfd268c Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Mon, 8 Jul 2019 14:31:16 +0100
Subject: [PATCH] container/lxc: Fixes showing host_name of veth pair in lxc
 info

This now reads from volatile data if not available from kernel.

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxd/container_lxc.go | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index 86a03fc85d..43d053e823 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -7173,6 +7173,14 @@ func (c *containerLXC) networkState() map[string]api.ContainerStateNetwork {
 		result = nw
 	}
 
+	// Get host_name from volatile data if not set already.
+	for name, dev := range result {
+		if dev.HostName == "" {
+			dev.HostName = c.localConfig[fmt.Sprintf("volatile.%s.host_name", name)]
+			result[name] = dev
+		}
+	}
+
 	return result
 }
 


More information about the lxc-devel mailing list