From 4ff6519961965deb278093c83ea0f46fb7c7c205 Mon Sep 17 00:00:00 2001 From: Peter Oberparleiter Date: Tue, 12 Mar 2019 14:05:17 +0100 Subject: [PATCH] zdev: Do not export inacceptable attribute values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: e831269e7433 ("zdev: Add support for VNIC Characteristics") Signed-off-by: Peter Oberparleiter Signed-off-by: Jan Höppner --- zdev/src/export.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zdev/src/export.c b/zdev/src/export.c index f1acb8a6..a66db0b1 100644 --- a/zdev/src/export.c +++ b/zdev/src/export.c @@ -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;