zdev: Add support for handling auto-configuration data

Auto-configuration is the name of a new configuration target that is
supported by chzdev and lszdev besides the existing active and
persistent configuration targets. Directives created in this new
configuration are stored as udev rules in the /run/udev/rules.d
directory.

Auto-configuration directives are only in effect if there are no
directives for the same device in the user-provided persistent
configuration. This allows users to override auto-configuration
directives if necessary.

Due to the volatile nature of the /run directory, auto-configuration
directives are cleared on reboot. Therefore mechanisms that generate
auto-configuration directives must recreate them on every boot.

The lszdev tool displays auto-configuration data both in list view
as well as in detail view. Users can specify the new option --auto-conf
to only show data from this configuration target.

Mechanisms that generate automated configuration directives can use
chzdev together with the --auto-conf option to create the corresponding
udev rules.

Note: This change does not include a mechanism that generates
      auto-configuration directives.

Signed-off-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Peter Oberparleiter
2017-09-01 11:05:55 +02:00
committed by Jan Höppner
parent a86fb8b091
commit fe68ec513d
32 changed files with 911 additions and 286 deletions

View File

@@ -1207,7 +1207,7 @@ static exit_code_t check_layer2(struct device *dev, config_t config)
{
struct setting *l;
int layer2_detected, layer2_active = -1, layer2_persistent = -1,
layer2_modified = 0;
layer2_autoconf = -1, layer2_modified = 0;
exit_code_t rc = EXIT_OK;
layer2_detected = detect_layer2(dev);
@@ -1231,13 +1231,25 @@ static exit_code_t check_layer2(struct device *dev, config_t config)
if (rc)
goto out;
}
l = setting_list_find(dev->autoconf.settings, qeth_attr_layer2.name);
if (l) {
layer2_autoconf = atoi(l->value);
layer2_modified |= l->modified;
} else if (SCOPE_AUTOCONF(config)) {
rc = generate_layer2("autoconf", dev->autoconf.settings,
&layer2_autoconf, &layer2_modified);
if (rc)
goto out;
}
/* Check correct layer2 setting. */
if (layer2_detected != -1) {
if ((SCOPE_ACTIVE(config) && layer2_active != -1 &&
layer2_active != layer2_detected) ||
(SCOPE_PERSISTENT(config) && layer2_persistent != -1 &&
layer2_persistent != layer2_detected)) {
layer2_persistent != layer2_detected) ||
(SCOPE_AUTOCONF(config) && layer2_autoconf != -1 &&
layer2_autoconf != layer2_detected)) {
rc = layer2_mismatch(layer2_detected, layer2_modified);
if (rc)
goto out;
@@ -1256,14 +1268,25 @@ static exit_code_t check_layer2(struct device *dev, config_t config)
if (rc)
goto out;
}
if (SCOPE_AUTOCONF(config)) {
rc = check_ineffective_settings(dev->autoconf.settings,
layer2_autoconf);
if (rc)
goto out;
}
/* check for conflicting layer2 attribute groups */
if (SCOPE_ACTIVE(config)) {
rc = check_conflicting_settings(dev->active.settings);
if (rc)
goto out;
}
if (SCOPE_PERSISTENT(config))
if (SCOPE_PERSISTENT(config)) {
rc = check_conflicting_settings(dev->persistent.settings);
if (rc)
goto out;
}
if (SCOPE_AUTOCONF(config))
rc = check_conflicting_settings(dev->autoconf.settings);
out:
return rc;
@@ -1277,7 +1300,8 @@ static exit_code_t qeth_st_check_pre_configure(struct subtype *st,
/* No need to check if device is deconfigured. */
if ((SCOPE_ACTIVE(config) && dev->active.deconfigured) ||
(SCOPE_PERSISTENT(config) && dev->persistent.deconfigured))
(SCOPE_PERSISTENT(config) && dev->persistent.deconfigured) ||
(SCOPE_AUTOCONF(config) && dev->autoconf.deconfigured))
return EXIT_OK;
rc = check_layer2(dev, config);