From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49720) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ai19e-0007RQ-Op for qemu-devel@nongnu.org; Mon, 21 Mar 2016 10:50:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ai19b-0001Gc-HB for qemu-devel@nongnu.org; Mon, 21 Mar 2016 10:50:02 -0400 Received: from e37.co.us.ibm.com ([32.97.110.158]:43558) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ai19b-0001GN-8c for qemu-devel@nongnu.org; Mon, 21 Mar 2016 10:49:59 -0400 Received: from localhost by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 21 Mar 2016 08:39:40 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (b03cxnp08028.gho.boulder.ibm.com [9.17.130.20]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id 238043E40054 for ; Mon, 21 Mar 2016 08:39:37 -0600 (MDT) Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u2LEdVvD34537696 for ; Mon, 21 Mar 2016 07:39:36 -0700 Received: from d03av01.boulder.ibm.com (localhost [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u2LEdVa5013853 for ; Mon, 21 Mar 2016 08:39:31 -0600 From: Stefan Berger Date: Mon, 21 Mar 2016 10:39:28 -0400 Message-Id: <1458571168-2583-1-git-send-email-stefanb@us.ibm.com> Subject: [Qemu-devel] [REPOST v2] [PATCH] tpm: adapt sysfs cancel path for new TPM driver List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: mst@redhat.com, qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: Stefan Berger , Stefan Berger , crobinso@redhat.com This patch addresses BZ 1281413. Adapt the sysfs TPM command cancel path for the TPM driver that does not use a miscdevice anymore since Linux 4.0. Support old and new paths. Signed-off-by: Stefan Berger --- hw/tpm/tpm_passthrough.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c index e98efb7..e1edb38 100644 --- a/hw/tpm/tpm_passthrough.c +++ b/hw/tpm/tpm_passthrough.c @@ -377,6 +377,8 @@ static int tpm_passthrough_open_sysfs_cancel(TPMBackend *tb) int fd = -1; char *dev; char path[PATH_MAX]; + const char *prefix[] = {"misc/", "tpm/"}; + int i; if (tb->cancel_path) { fd = qemu_open(tb->cancel_path, O_WRONLY); @@ -390,16 +392,21 @@ static int tpm_passthrough_open_sysfs_cancel(TPMBackend *tb) dev = strrchr(tpm_pt->tpm_dev, '/'); if (dev) { dev++; - if (snprintf(path, sizeof(path), "/sys/class/misc/%s/device/cancel", - dev) < sizeof(path)) { - fd = qemu_open(path, O_WRONLY); - if (fd >= 0) { - tb->cancel_path = g_strdup(path); - } else { - error_report("tpm_passthrough: Could not open TPM cancel " - "path %s : %s", path, strerror(errno)); + for (i = 0; i < ARRAY_SIZE(prefix); i++) { + if (snprintf(path, sizeof(path), + "/sys/class/%s%s/device/cancel", + prefix[i], dev) < sizeof(path)) { + fd = qemu_open(path, O_WRONLY); + if (fd >= 0) { + tb->cancel_path = g_strdup(path); + break; + } } } + if (fd < 0) { + error_report("tpm_passthrough: Could not open TPM cancel " + "path %s : %s", path, strerror(errno)); + } } else { error_report("tpm_passthrough: Bad TPM device path %s", tpm_pt->tpm_dev); -- 2.4.3