zdev: Do not export inacceptable attribute values

For some device driver SysFS attributes, values read may not be
acceptable input values for that attribute.

An example would be the group of qeth VNICC attributes that return "n/a"
when VNICC setup is not supported, but only accept "0" and "1" as valid
values that can be written to it.

This leads to errors such as the following when data for such attributes
is imported:

  # chzdev f500 --import test.conf
  Importing configuration data from test.conf
  QETH device 0.0.f500:0.0.f501:0.0.f502 configure failed
      Error: Invalid value for qeth attribute: vnicc/flooding=n/a (*)
      Acceptable values:
      - Integers in the range 0 - 1
      Use 'chzdev qeth --help-attribute vnicc/flooding' for more information
  Note: You can use --force to override safety checks (*)

To fix this, change chzdev's --export function to skip any attribute
value that is not acceptable for that attribute.

Fixes: e831269e74 ("zdev: Add support for VNIC Characteristics")
Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Peter Oberparleiter
2019-03-12 14:05:17 +01:00
committed by Jan Höppner
parent 90dc65659f
commit 4ff6519961

View File

@@ -78,6 +78,10 @@ static bool is_exportable(struct setting *s, config_t config)
/* Skip values that cannot be determined. */
return false;
}
if (!attrib_check_value(a, s->value)) {
/* Skip values that are not acceptable input values. */
return false;
}
if (!attrib_match_default(s->attrib, s->value)) {
/* All non-default values should be exported. */
return true;