vpd_get_value status code inconsistent on missing keys |
|||||
Issue descriptionWhen running vpd_get_value to read a key that is not present in VPD, the utility returns different status codes based on the read path it decides to take: 1. For VPD reads from sysfs, it'll exit with a status code of 1, indicating error. 2. For VPD reads from the cache file, it'll exit with a status code of 0, indicating success. We should decide which is the correct behavior. In my use case, I need to gracefully deal with the key being absent in R/W VPD, so I'd appreciate a decision to have callers distinguish "error" and "key absent" cases. It'll be somewhat difficult to fix this in a backwards-compatible way - callers may depend on one or the other behavior depending on which boards they run. Hung-Te, can you clarify the intention?
,
Aug 30 2017
From what I understand, most programs calling vpd_get_value don't look at return code. Instead they check the output, because that's the one really matters. sysfs vpd does know if a key exists or not, so it returns 1 on non-exist. 'vpd -g non_exist' returns 0, so actually we don't really know if the key exists or not. This is probably because 'vpd' command didn't support "deletion" in the very beginning, I'm not sure. It is possible to find the difference between empty value and absence in the cache version (via "vpd -l"), but the scripting will be more complicated and I'm not sure if it's worthy. If you do want the 3 different ways (sysfs, vpd-g, cache) to return same value, always returning 0 may be the most easy solution, and more compatible to existing scripts. If you do want to know if a key is "missing", that is also possible I think - but will need more changes and I'm not sure if there's any real case that people want to know if a value is empty or missing.
,
Aug 30 2017
OK, I'll take a quick look at existing callers of vpd_get_value then and if I don't find any problems, I'll prepare a change to exit with status 0 on missing keys for the sysfs case.
,
Aug 30 2017
Here's a CL: https://chromium-review.googlesource.com/c/chromiumos/platform/vpd/+/643188 It works fine in local testing, but let's see what the CQ says about it.
,
Aug 31 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/platform/vpd/+/bc0fd5a3aca8a2619b5f6abfe537a6b33e60450f commit bc0fd5a3aca8a2619b5f6abfe537a6b33e60450f Author: Mattias Nissler <mnissler@chromium.org> Date: Thu Aug 31 11:52:20 2017 Make sure vpd_get_value succeeds for missing keys Using attempting vpd_get_value to read a VPD key that isn't present, it was unclear what the exit status should be. The sysfs read path would exit with status 1 whereas the legacy cache read would not consider this an error and exit with status 0. Existing callers of vpd_get_value are expecting failure for an actual error condition, but not absence of keys, so adjust the sysfs path exit successful on absent keys as well. BUG= chromium:760500 TEST=vpd_get_value no_such_key ; echo $? should print 0 on all devices. BRANCH=none Change-Id: I7c3c08f44fa09eaeb0fe2f5b483199b5313cf7de Reviewed-on: https://chromium-review.googlesource.com/643188 Commit-Ready: Mattias Nissler <mnissler@chromium.org> Tested-by: Mattias Nissler <mnissler@chromium.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org> [modify] https://crrev.com/bc0fd5a3aca8a2619b5f6abfe537a6b33e60450f/util/vpd_get_value
,
Aug 31 2017
,
Sep 8 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/platform/vpd/+/573e9d1f6c34df84129222ca18c74d6a6886d7c0 commit 573e9d1f6c34df84129222ca18c74d6a6886d7c0 Author: Mattias Nissler <mnissler@chromium.org> Date: Fri Sep 08 19:43:50 2017 Make sure vpd_get_value succeeds for missing keys Using attempting vpd_get_value to read a VPD key that isn't present, it was unclear what the exit status should be. The sysfs read path would exit with status 1 whereas the legacy cache read would not consider this an error and exit with status 0. Existing callers of vpd_get_value are expecting failure for an actual error condition, but not absence of keys, so adjust the sysfs path exit successful on absent keys as well. BUG= chromium:760500 TEST=vpd_get_value no_such_key ; echo $? should print 0 on all devices. BRANCH=none Reviewed-on: https://chromium-review.googlesource.com/643188 Commit-Ready: Mattias Nissler <mnissler@chromium.org> Tested-by: Mattias Nissler <mnissler@chromium.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org> BUG=chromium:761803 Change-Id: I69b8f9b079adb93868dee3784788c946c033abdd Reviewed-on: https://chromium-review.googlesource.com/657411 Reviewed-by: Mattias Nissler <mnissler@chromium.org> Tested-by: Mattias Nissler <mnissler@chromium.org> [modify] https://crrev.com/573e9d1f6c34df84129222ca18c74d6a6886d7c0/util/vpd_get_value
,
Jan 22 2018
,
Jan 23 2018
|
|||||
►
Sign in to add a comment |
|||||
Comment 1 by mnissler@chromium.org
, Aug 30 2017