From 80bda1b320513252826a92aefe62ad8706a000e5 Mon Sep 17 00:00:00 2001 From: Sebastian Mitterle Date: Wed, 4 Aug 2021 07:54:54 -0400 Subject: [PATCH] libvirt_keywrap: handle hexdump when token unavailable Commit 3bcc957a800ea465db407a783ee4633b453864c6 switched to usage of `hexdump`. Unfortunately, `hexdump` doesn't set error code if no token can be read and instead just notifies "hexdump: /sys/devices/virtual/misc/pkey/protkey/protkey_aes_128: No such device". Check for substring in output to handle this as if error code was set. Signed-off-by: Sebastian Mitterle --- virttest/utils_libvirt/libvirt_keywrap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virttest/utils_libvirt/libvirt_keywrap.py b/virttest/utils_libvirt/libvirt_keywrap.py index 3626ef97f8..56dc5a7934 100644 --- a/virttest/utils_libvirt/libvirt_keywrap.py +++ b/virttest/utils_libvirt/libvirt_keywrap.py @@ -40,7 +40,7 @@ def get_some_aes_key_token(self): attr_path = os.path.join(self.sysfs, some_key_attribute) error, output = cmd_status_output(cmd="hexdump %s" % attr_path, session=self.session) - if error: + if error or "No such device" in output: logging.debug("Error reading from %s: %s", attr_path, output) return None return output