SWDEV-457854 - Unified BM error codes
Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>
Change-Id: I5b232de3b598bd3146eb0528f61c628da93278d9
[ROCm/amdsmi commit: a3758f82dc]
Этот коммит содержится в:
@@ -40,6 +40,13 @@ Added `AMDSMI_EVT_NOTIF_RING_HANG` to the possible events in the `amdsmi_evt_not
|
||||
|
||||
### Optimizations
|
||||
|
||||
- **Updated CLI error strings to specify invalid device type queried**
|
||||
|
||||
```shell
|
||||
$ amd-smi static --asic --gpu 123123
|
||||
Can not find a device: GPU '123123' Error code: -3
|
||||
```
|
||||
|
||||
- **Removed elevated permission requirements for `amdsmi_get_gpu_process_list()`**.
|
||||
Previously if a processes with elevated permissions was running amd-smi would required sudo to display all output. Now amd-smi will populate all process data and return N/A for elevated process names instead. However if ran with sudo you will be able to see the name like so:
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ class AmdSmiException(Exception):
|
||||
self.stdout_message = ''
|
||||
self.message = ''
|
||||
self.output_format = ''
|
||||
self.device_type = ''
|
||||
|
||||
def __str__(self):
|
||||
# Return message according to the current output format
|
||||
@@ -83,7 +84,7 @@ class AmdSmiException(Exception):
|
||||
|
||||
|
||||
class AmdSmiInvalidCommandException(AmdSmiException):
|
||||
def __init__(self, command, outputformat):
|
||||
def __init__(self, command, outputformat: str):
|
||||
super().__init__()
|
||||
self.value = -1
|
||||
self.command = command
|
||||
@@ -98,7 +99,7 @@ class AmdSmiInvalidCommandException(AmdSmiException):
|
||||
|
||||
|
||||
class AmdSmiInvalidParameterException(AmdSmiException):
|
||||
def __init__(self, command, outputformat):
|
||||
def __init__(self, command, outputformat: str):
|
||||
super().__init__()
|
||||
self.value = -2
|
||||
self.command = command
|
||||
@@ -113,13 +114,22 @@ class AmdSmiInvalidParameterException(AmdSmiException):
|
||||
|
||||
|
||||
class AmdSmiDeviceNotFoundException(AmdSmiException):
|
||||
def __init__(self, command, outputformat):
|
||||
def __init__(self, command, outputformat: str, gpu: bool, cpu: bool, core: bool):
|
||||
super().__init__()
|
||||
self.value = -3
|
||||
self.command = command
|
||||
self.output_format = outputformat
|
||||
|
||||
common_message = f"Can not find a device with the corresponding identifier: '{self.command}'"
|
||||
# Handle different devices
|
||||
self.device_type = ""
|
||||
if gpu:
|
||||
self.device_type = "GPU"
|
||||
elif cpu:
|
||||
self.device_type = "CPU"
|
||||
elif core:
|
||||
self.device_type = "CPU CORE"
|
||||
|
||||
common_message = f"Can not find a device: {self.device_type} '{self.command}'"
|
||||
|
||||
self.json_message["error"] = common_message
|
||||
self.json_message["code"] = self.value
|
||||
@@ -128,7 +138,7 @@ class AmdSmiDeviceNotFoundException(AmdSmiException):
|
||||
|
||||
|
||||
class AmdSmiInvalidFilePathException(AmdSmiException):
|
||||
def __init__(self, command, outputformat):
|
||||
def __init__(self, command, outputformat: str):
|
||||
super().__init__()
|
||||
self.value = -4
|
||||
self.command = command
|
||||
@@ -143,7 +153,7 @@ class AmdSmiInvalidFilePathException(AmdSmiException):
|
||||
|
||||
|
||||
class AmdSmiInvalidParameterValueException(AmdSmiException):
|
||||
def __init__(self, command, outputformat):
|
||||
def __init__(self, command, outputformat: str):
|
||||
super().__init__()
|
||||
self.value = -5
|
||||
self.command = command
|
||||
@@ -158,7 +168,7 @@ class AmdSmiInvalidParameterValueException(AmdSmiException):
|
||||
|
||||
|
||||
class AmdSmiMissingParameterValueException(AmdSmiException):
|
||||
def __init__(self, command, outputformat):
|
||||
def __init__(self, command, outputformat: str):
|
||||
super().__init__()
|
||||
self.value = -6
|
||||
self.command = command
|
||||
@@ -172,8 +182,23 @@ class AmdSmiMissingParameterValueException(AmdSmiException):
|
||||
self.stdout_message = f"{common_message} Error code: {self.value}"
|
||||
|
||||
|
||||
class AmdSmiNotSupportedCommandException(AmdSmiException):
|
||||
def __init__(self, command, outputformat: str):
|
||||
super().__init__()
|
||||
self.value = -7
|
||||
self.command = command
|
||||
self.output_format = outputformat
|
||||
|
||||
common_message = f"Command '{self.command}' is not supported on the system. Run '--help' for more info."
|
||||
|
||||
self.json_message["error"] = common_message
|
||||
self.json_message["code"] = self.value
|
||||
self.csv_message = f"error,code\n{common_message}, {self.value}"
|
||||
self.stdout_message = f"{common_message} Error code: {self.value}"
|
||||
|
||||
|
||||
class AmdSmiParameterNotSupportedException(AmdSmiException):
|
||||
def __init__(self, command, outputformat):
|
||||
def __init__(self, command, outputformat: str):
|
||||
super().__init__()
|
||||
self.value = -8
|
||||
self.command = command
|
||||
@@ -188,7 +213,7 @@ class AmdSmiParameterNotSupportedException(AmdSmiException):
|
||||
|
||||
|
||||
class AmdSmiRequiredCommandException(AmdSmiException):
|
||||
def __init__(self, command, outputformat):
|
||||
def __init__(self, command, outputformat: str):
|
||||
super().__init__()
|
||||
self.value = -9
|
||||
self.command = command
|
||||
@@ -203,7 +228,7 @@ class AmdSmiRequiredCommandException(AmdSmiException):
|
||||
|
||||
|
||||
class AmdSmiUnknownErrorException(AmdSmiException):
|
||||
def __init__(self, command, outputformat):
|
||||
def __init__(self, command, outputformat: str):
|
||||
super().__init__()
|
||||
self.value = -100
|
||||
self.command = command
|
||||
@@ -218,7 +243,7 @@ class AmdSmiUnknownErrorException(AmdSmiException):
|
||||
|
||||
|
||||
class AmdSmiAMDSMIErrorException(AmdSmiException):
|
||||
def __init__(self, outputformat, error_code):
|
||||
def __init__(self, outputformat: str, error_code):
|
||||
super().__init__()
|
||||
self.value = -1000 - abs(error_code)
|
||||
self.smilibcode = error_code
|
||||
|
||||
@@ -111,6 +111,11 @@ class AMDSMIParser(argparse.ArgumentParser):
|
||||
help="Descriptions:",
|
||||
metavar='')
|
||||
|
||||
# Store possible subcommands for later errors
|
||||
self.possible_commands = ['version', 'list', 'static', 'firmware', 'ucode', 'bad-pages',
|
||||
'metric', 'process', 'profile', 'event', 'topology', 'set',
|
||||
'reset', 'monitor', 'xgmi']
|
||||
|
||||
# Add all subparsers
|
||||
self._add_version_parser(self.subparsers, version)
|
||||
self._add_list_parser(self.subparsers, list)
|
||||
@@ -257,7 +262,9 @@ class AMDSMIParser(argparse.ArgumentParser):
|
||||
if selected_device_handles == '':
|
||||
raise amdsmi_cli_exceptions.AmdSmiMissingParameterValueException("--gpu", _GPUSelectAction.ouputformat)
|
||||
else:
|
||||
raise amdsmi_cli_exceptions.AmdSmiDeviceNotFoundException(selected_device_handles, _GPUSelectAction.ouputformat)
|
||||
raise amdsmi_cli_exceptions.AmdSmiDeviceNotFoundException(selected_device_handles,
|
||||
_GPUSelectAction.ouputformat,
|
||||
True, False, False)
|
||||
|
||||
return _GPUSelectAction
|
||||
|
||||
@@ -283,7 +290,8 @@ class AMDSMIParser(argparse.ArgumentParser):
|
||||
raise amdsmi_cli_exceptions.AmdSmiMissingParameterValueException("--cpu", _CPUSelectAction.ouputformat)
|
||||
else:
|
||||
raise amdsmi_cli_exceptions.AmdSmiDeviceNotFoundException(selected_device_handles,
|
||||
_CPUSelectAction.ouputformat)
|
||||
_CPUSelectAction.ouputformat,
|
||||
False, True, False)
|
||||
return _CPUSelectAction
|
||||
|
||||
|
||||
@@ -308,7 +316,8 @@ class AMDSMIParser(argparse.ArgumentParser):
|
||||
raise amdsmi_cli_exceptions.AmdSmiMissingParameterValueException("--core", _CoreSelectAction.ouputformat)
|
||||
else:
|
||||
raise amdsmi_cli_exceptions.AmdSmiDeviceNotFoundException(selected_device_handles,
|
||||
_CoreSelectAction.ouputformat)
|
||||
_CoreSelectAction.ouputformat,
|
||||
False, False, True)
|
||||
return _CoreSelectAction
|
||||
|
||||
|
||||
@@ -1232,6 +1241,9 @@ class AMDSMIParser(argparse.ArgumentParser):
|
||||
l = len("argument : invalid choice: ") + 1
|
||||
message = message[l:]
|
||||
message = message.split("'")[0]
|
||||
# Check if the command is possible in other system configurations and error accordingly
|
||||
if message in self.possible_commands:
|
||||
raise amdsmi_cli_exceptions.AmdSmiNotSupportedCommandException(message, outputformat)
|
||||
raise amdsmi_cli_exceptions.AmdSmiInvalidCommandException(message, outputformat)
|
||||
elif "unrecognized arguments: " in message:
|
||||
l = len("unrecognized arguments: ")
|
||||
|
||||
Ссылка в новой задаче
Block a user