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

@@ -316,34 +316,34 @@ static struct attrib dasd_attr_safe_offline = {
* DASD subtype methods.
*/
static bool _check_use_diag(struct setting_list *list)
{
struct setting *u;
u = setting_list_find(list, dasd_attr_use_diag.name);
if (u && u->modified) {
if (u->value && atoi(u->value) == 1) {
delayed_warn("Cannot set 'use_diag=1' on non-z/VM system\n");
return false;
}
}
return true;
}
/* Check if use_diag setting can be correctly applied. */
static exit_code_t check_use_diag(struct device *dev, config_t config)
{
struct setting *u;
int zvm = is_zvm();
if (is_zvm())
return EXIT_OK;
if (SCOPE_ACTIVE(config)) {
u = setting_list_find(dev->active.settings,
dasd_attr_use_diag.name);
if (u && u->modified) {
if (u->value && atoi(u->value) == 1 && !zvm) {
delayed_warn("Cannot set 'use_diag=1' on "
"non-z/VM system\n");
return EXIT_INVALID_CONFIG;
}
}
}
if (SCOPE_PERSISTENT(config)) {
u = setting_list_find(dev->persistent.settings,
dasd_attr_use_diag.name);
if (u && u->modified) {
if (u->value && atoi(u->value) == 1 && !zvm) {
delayed_warn("Cannot set 'use_diag=1' on "
"non-z/VM system\n");
return EXIT_INVALID_CONFIG;
}
}
}
if (SCOPE_ACTIVE(config) && !_check_use_diag(dev->active.settings))
return EXIT_INVALID_CONFIG;
if (SCOPE_PERSISTENT(config) &&
!_check_use_diag(dev->persistent.settings))
return EXIT_INVALID_CONFIG;
if (SCOPE_AUTOCONF(config) &&
!_check_use_diag(dev->autoconf.settings))
return EXIT_INVALID_CONFIG;
return EXIT_OK;
}
@@ -376,6 +376,8 @@ static void dasd_st_add_modules(struct subtype *st, struct device *dev,
dasd_attr_use_diag.name, &changed, &aset);
setting_list_get_bool_state(dev->persistent.settings,
dasd_attr_use_diag.name, &changed, &pset);
setting_list_get_bool_state(dev->autoconf.settings,
dasd_attr_use_diag.name, &changed, &pset);
if (aset || pset)
strlist_add_unique(modules, DASD_DIAG_MOD_NAME);