summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2026-09-01 09:39:44 +0200
committerChristian Breunig <christian@breunig.cc>2026-09-01 17:28:52 +0200
commit322db61ed0b8c2fa69a178a4ecc14a8d356cb09c (patch)
tree85adb6ba4371b7b5645eec9323b4749a762838df
parente94f0e47d742f3c8f228bf21907954008ade7ba0 (diff)
downloadvyos-1x-322db61ed0b8c2fa69a178a4ecc14a8d356cb09c.tar.gz
vyos-1x-322db61ed0b8c2fa69a178a4ecc14a8d356cb09c.zip
version: T9269: report "container" as system type
A container shares the Kernel with its host and inherits its DMI and CPUID data, thus hvinfo reports the hypervisor of the host system - a VyOS container on a KVM host was described as "KVM guest". Check is_running_as_container() first and report "container", otherwise fall back to hvinfo as before. Note that boot_via and the hardware vendor, model, serial and UUID fields are still derived from the host.
-rw-r--r--python/vyos/version.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/python/vyos/version.py b/python/vyos/version.py
index 4288a26ff..f949d588a 100644
--- a/python/vyos/version.py
+++ b/python/vyos/version.py
@@ -71,18 +71,24 @@ def get_full_version_data(fname=version_file):
# vyos.system.grub -> vyos.template -> jinja2, which every consumer of
# vyos.version would otherwise pay for on import.
from vyos.system.image import is_live_boot
+ from vyos.system.image import is_running_as_container
version_data = get_version_data(fname)
# Get system architecture (well, kernel architecture rather)
version_data['system_arch'], _ = popen('uname -m', stderr=DEVNULL)
- hypervisor,code = popen('hvinfo', stderr=DEVNULL)
- if code == 1:
- # hvinfo returns 1 if it cannot detect any hypervisor
- version_data['system_type'] = 'bare metal'
+ # A container shares the Kernel with - and inherits the DMI/CPUID data of -
+ # its host, thus hvinfo would report the hypervisor of the host system
+ if is_running_as_container():
+ version_data['system_type'] = 'container'
else:
- version_data['system_type'] = f"{hypervisor} guest"
+ hypervisor,code = popen('hvinfo', stderr=DEVNULL)
+ if code == 1:
+ # hvinfo returns 1 if it cannot detect any hypervisor
+ version_data['system_type'] = 'bare metal'
+ else:
+ version_data['system_type'] = f"{hypervisor} guest"
# Get boot type, it can be livecd or installed image
# In installed images, the squashfs image file is named after its image version,