aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeongJae Park <sj@kernel.org>2024-04-14 08:14:32 -0700
committerSeongJae Park <sj@kernel.org>2024-04-14 08:14:32 -0700
commit6b2d08b05df4e2df36df93d38af59b60fdfe7050 (patch)
tree767d67b9aee5dc04784e097a86ac7044b8f73709
parent0e657bbb415d962e1954d62c1f5a9f73ece0c715 (diff)
downloaddamo-6b2d08b05df4e2df36df93d38af59b60fdfe7050.tar.gz
_damon_args: Check if arguments are correct from kdamonds_for()
Wrong arguments input that recently fixed for 'damo tune' via last two commits can again be problematic on other commands such as 'damo start'. Do the check from _damon_args.kdamonds_for(). Signed-off-by: SeongJae Park <sj@kernel.org>
-rw-r--r--_damon_args.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/_damon_args.py b/_damon_args.py
index c0399adf..bfb02e45 100644
--- a/_damon_args.py
+++ b/_damon_args.py
@@ -375,7 +375,37 @@ def deduce_target_update_args(args):
print('warning: override --ops by <deducible target> and --regions')
args.ops = 'fvaddr'
+def evaluate_args(args):
+ '''
+ Verify if 'damons_action' is present when any 'damos_*' is specified
+ '''
+ if not args.damos_action:
+ for key, value in args.__dict__.items():
+ if key.startswith('damos_') and len(value):
+ if key == 'damos_action': continue
+ return False, '\'damos_action\' not specified while using --damos_* option(s)'
+
+ '''
+ Verify if 'reset_interval_ms' is specified in args when setting quota goals
+ '''
+ if args.damos_quota_goal:
+ damos_quotas = args.damos_quotas
+
+ if not len(damos_quotas):
+ return False, '\'reset_interval_ms\' not specified when setting quota goals'
+
+ #reset_interval_ms is specified in --damos_quotas as 3rd arg
+ for quota in damos_quotas:
+ if len(quota) < 3:
+ return False, '\'reset_interval_ms\' not specified when setting quota goals'
+
+ return True, None
+
def kdamonds_for(args):
+ correct, err = evaluate_args(args)
+ if err is not None:
+ return None, err
+
if args.kdamonds:
return kdamonds_from_json_arg(args.kdamonds)