From 322db61ed0b8c2fa69a178a4ecc14a8d356cb09c Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Tue, 1 Sep 2026 09:39:44 +0200 Subject: 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. --- python/vyos/version.py | 16 +++++++++++----- 1 file 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, -- cgit v1.2.3