From: Wei Li <redacted>
A container reports "X" in its enable file when its children have mixed
states. The rv tool fails to list or start such a container.
__ikm_read_enable() cannot parse "X" now and returns -1. 'rv list'
skips the container line and reports "error reading". 'rv mon' takes -1
as a true value and reports a spurious "already enabled" info.
Add support of parsing the mixed enable state of containers. Show a
mixed container as [MIX] in 'rv list'.
Signed-off-by: Wei Li <redacted>
---
tools/verification/rv/src/in_kernel.c | 32 +++++++++++++++++++++------
tools/verification/rv/tests/rv_list.t | 2 +-
2 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/tools/verification/rv/src/in_kernel.c b/tools/verification/rv/src/in_kernel.c
index e6dea4040f8f..0f2e9f1eca51 100644
--- a/tools/verification/rv/src/in_kernel.c
+++ b/tools/verification/rv/src/in_kernel.c
@@ -29,21 +29,38 @@ static char *config_reactor;
*
* __does not log errors.
*
- * Returns the current status, or -1 if the monitor does not exist,
- * __hence not logging errors.
+ * Returns 0 if disabled, 1 if enabled, 2 if a container with children
+ * in mixed states, or -1 if the monitor does not exist, __hence not
+ * logging errors.
*/
static int __ikm_read_enable(char *monitor_name)
{
char path[MAX_PATH];
- long long enabled;
- int retval;
+ char *buffer;
+ int enabled;
snprintf(path, MAX_PATH, "rv/monitors/%s/enable", monitor_name);
- retval = tracefs_instance_file_read_number(NULL, path, &enabled);
- if (retval < 0)
+ buffer = tracefs_instance_file_read(NULL, path, NULL);
+ if (!buffer)
return -1;
+ switch (buffer[0]) {
+ case '0':
+ enabled = 0;
+ break;
+ case '1':
+ enabled = 1;
+ break;
+ case 'X':
+ enabled = 2;
+ break;
+ default:
+ enabled = -1;
+ }
+
+ free(buffer);
+
return enabled;
}
@@ -370,7 +387,8 @@ int ikm_list_monitors(char *container)
list_monitor = 1;
printf("%s%-*s %s %s\n", indent ? " - " : "",
indent ? MAX_DA_NAME_LEN - 3 : MAX_DA_NAME_LEN,
- ikm.name, ikm.desc, ikm.enabled ? "[ON]" : "[OFF]");
+ ikm.name, ikm.desc,
+ ikm.enabled == 2 ? "[MIX]" : ikm.enabled ? "[ON]" : "[OFF]");
}
curr = ++next;
diff --git a/tools/verification/rv/tests/rv_list.t b/tools/verification/rv/tests/rv_list.t
index 201af33a52cc..f63697a903c1 100644
--- a/tools/verification/rv/tests/rv_list.t
+++ b/tools/verification/rv/tests/rv_list.t
@@ -17,7 +17,7 @@ check "verify list subcommand help" \
all_nested=$(grep : $RVDIR/available_monitors | cut -d: -f2 | paste -s | sed 's/\t/\\|/g')
all_non_nested=$(grep -v : $RVDIR/available_monitors | cut -d: -f2 | paste -s | sed 's/\t/\\|/g')
sched_monitors=$(grep sched: $RVDIR/available_monitors | cut -d: -f2 | paste -s | sed 's/\t/\\|/g')
-description_state="[[:space:]]\+[[:print:]]\+\[\(OFF\|ON\)\]"
+description_state="[[:space:]]\+[[:print:]]\+\[\(OFF\|ON\|MIX\)\]"
line_nested=" - \($all_nested\)${description_state}"
line_non_nested="\($all_non_nested\)${description_state}"
--
2.55.0