From 54937495e2234fc891c7cea2223f63e5851c95ad Mon Sep 17 00:00:00 2001 From: Ingo Franzki Date: Wed, 25 Oct 2023 15:38:56 +0200 Subject: [PATCH] zkey: Also check for deconfigured and check-stopped cards MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When checking if a card or an APQN is online, not only check the 'online' sysfs attribute, but also check the 'config' and 'chkstop' attribute. Cards and APQNs in check-stopped or deconfigured state can still be reported as online via the sysfs attribute, although they are not available to be used for zkey. In case the 2 additional sysfs attributes are not available in sysfs, then don't fail, but rely on the 'online' attribute only. Signed-off-by: Ingo Franzki Reviewed-by: Harald Freudenberger Signed-off-by: Jan Höppner --- zkey/utils.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/zkey/utils.c b/zkey/utils.c index 8ae93340..47609545 100644 --- a/zkey/utils.c +++ b/zkey/utils.c @@ -49,7 +49,7 @@ */ int sysfs_is_card_online(unsigned int card, enum card_type cardtype) { - long int online; + long int online, config, chkstop; char *dev_path; char type[20]; int rc = 1; @@ -67,6 +67,16 @@ int sysfs_is_card_online(unsigned int card, enum card_type cardtype) rc = 0; goto out; } + if (util_file_read_l(&config, 10, "%s/config", dev_path) == 0 && + config == 0) { + rc = 0; + goto out; + } + if (util_file_read_l(&chkstop, 10, "%s/chkstop", dev_path) == 0 && + chkstop != 0) { + rc = 0; + goto out; + } if (util_file_read_line(type, sizeof(type), "%s/type", dev_path) != 0) { rc = 0; goto out; @@ -111,7 +121,7 @@ out: int sysfs_is_apqn_online(unsigned int card, unsigned int domain, enum card_type cardtype) { - long int online; + long int online, config, chkstop; char *dev_path; int rc = 1; @@ -133,6 +143,16 @@ int sysfs_is_apqn_online(unsigned int card, unsigned int domain, rc = 0; goto out; } + if (util_file_read_l(&config, 10, "%s/config", dev_path) == 0 && + config == 0) { + rc = 0; + goto out; + } + if (util_file_read_l(&chkstop, 10, "%s/chkstop", dev_path) == 0 && + chkstop != 0) { + rc = 0; + goto out; + } out: free(dev_path);