Skip to content
Open
53 changes: 53 additions & 0 deletions lib/vdsm/aarch64HardwareInfo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# SPDX-FileCopyrightText: Red Hat, Inc.
# SPDX-License-Identifier: GPL-2.0-or-later

from __future__ import absolute_import
Comment thread
dupondje marked this conversation as resolved.
Outdated

import os.path
import subprocess

from vdsm import cpuinfo
from vdsm.common import cache



def get_sys_info():

cmd = 'dmidecode -t system'
Comment thread
shubhaOracle marked this conversation as resolved.
sys_info = {}
try:
output = subprocess.check_output(cmd, shell=True, universal_newlines=True)
for item in output.split("\n"):
if 'Manufacturer' in item or \
'Product Name' in item or \
'Version' in item or \
'Serial Number' in item or \
'UUID' in item or \
'Family' in item :
item = item.strip()
key = item.split(":")[0].strip()
value = item.split(":")[1].strip()
sys_info[key]=value

except:
print("ERROR")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs more info

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated


return sys_info




@cache.memoized
def getHardwareInfoStructure():
sys_info_dict=get_sys_info()


return {
'systemSerialNumber': sys_info_dict.get('Serial Number', 'unavailable'),
'systemFamily': sys_info_dict.get('Family', 'unavailable'),
'systemVersion': sys_info_dict.get('Version', 'unavailable'),
'systemUUID': sys_info_dict.get('UUID', 'unavailable'),
'systemProductName': sys_info_dict.get('Product Name', 'unavailable'),
'systemManufacturer': sys_info_dict.get('Manufacturer', 'unavailable'),
}

4 changes: 4 additions & 0 deletions lib/vdsm/machinetype.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from vdsm.common import cpuarch
from vdsm.common import libvirtconnection
from vdsm.common.config import config
from vdsm.validatehost import is_valid_virt_host


class _CpuMode:
Expand Down Expand Up @@ -146,12 +147,15 @@ def compatible_cpu_models():
compatible_models = [model for (model, usable)
in all_models.items()
if usable == 'yes']
logging.debug(Compatible CPU models: %s', compatible_models)
Comment thread
shubhaOracle marked this conversation as resolved.
Outdated
# Current QEMU doesn't report POWER compatibility modes, so we
# must add them ourselves.
if cpuarch.is_ppc(arch) and \
'POWER9' in compatible_models and \
'POWER8' not in compatible_models:
compatible_models.append('POWER8')
if cpuarch.is_arm(arch) and is_valid_virt_host():
Comment thread
dupondje marked this conversation as resolved.
compatible_models.append('virt_aarch64')
return list(set(["model_" + model for model in compatible_models]))


Expand Down
3 changes: 3 additions & 0 deletions lib/vdsm/supervdsm_api/hwinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def getHardwareInfo(*args, **kwargs):
elif cpuarch.is_ppc(arch):
from vdsm.ppc64HardwareInfo import getHardwareInfoStructure
return getHardwareInfoStructure()
elif cpuarch.is_arm(arch):
from vdsm.aarch64HardwareInfo import getHardwareInfoStructure
return getHardwareInfoStructure()
Comment thread
shubhaOracle marked this conversation as resolved.
else:
# not implemented over other architecture
return {}
Expand Down
55 changes: 55 additions & 0 deletions lib/vdsm/validatehost.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# SPDX-FileCopyrightText: Red Hat, Inc.
# SPDX-License-Identifier: GPL-2.0-or-later

import logging
import subprocess

VIRT_HOST_VALIDATE_CMD = "virt-host-validate"
CMD="date"
Comment thread
shubhaOracle marked this conversation as resolved.
Outdated



def exec_validate_cmd(cmd):
"""Execute a command and convert returned values to native string.

Note that this function should not be used if output data could be
undecodable bytes.
"""
try:
out = subprocess.check_output(cmd).decode("utf-8")
except Exception as err:
logging.exception(f"Unexpected {err}, {type(err)}")

logging.info(f"output {out}")
return out




def is_valid_virt_host():
""" Validate host is valid for virtualization
Below is the command and output
If host is not valid, the failure will be logged
# virt-host-validate
QEMU: Checking if device /dev/kvm exists : PASS
QEMU: Checking if device /dev/kvm is accessible : PASS
QEMU: Checking if device /dev/vhost-net exists : PASS
QEMU: Checking if device /dev/net/tun exists : PASS
QEMU: Checking for cgroup 'cpu' controller support : PASS
QEMU: Checking for cgroup 'cpuacct' controller support : PASS
QEMU: Checking for cgroup 'cpuset' controller support : PASS
QEMU: Checking for cgroup 'memory' controller support : PASS
QEMU: Checking for cgroup 'devices' controller support : PASS
QEMU: Checking for cgroup 'blkio' controller support : PASS
QEMU: Checking for device assignment IOMMU support : WARN (Unknown if this platform has IOMMU support)
QEMU: Checking for secure guest support : WARN (Unknown if this platform has Secure Guest support)

"""

out = exec_validate_cmd(VIRT_HOST_VALIDATE_CMD)

if (not 'fail' in out.lower()) :

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just check exit code?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to verify that there are no failures are reported in the output

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is exactly what the exit code does?
Upon successful validation, an exit status of 0 will be set. Upon failure a non-zero status will be set.

valid_host = True


return valid_host
Loading