From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37214) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZzAyO-0003yi-Li for qemu-devel@nongnu.org; Wed, 18 Nov 2015 17:13:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZzAyL-0005Ss-A9 for qemu-devel@nongnu.org; Wed, 18 Nov 2015 17:13:04 -0500 Received: from e17.ny.us.ibm.com ([129.33.205.207]:48957) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZzAyL-0005Sj-5d for qemu-devel@nongnu.org; Wed, 18 Nov 2015 17:13:01 -0500 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 18 Nov 2015 17:12:59 -0500 Received: from b01cxnp22033.gho.pok.ibm.com (b01cxnp22033.gho.pok.ibm.com [9.57.198.23]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id 52E0DC90046 for ; Wed, 18 Nov 2015 17:01:06 -0500 (EST) Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id tAIMCuuY53215316 for ; Wed, 18 Nov 2015 22:12:56 GMT Received: from d01av01.pok.ibm.com (localhost [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id tAIMCtAu024143 for ; Wed, 18 Nov 2015 17:12:55 -0500 From: Stefan Berger Date: Wed, 18 Nov 2015 17:12:40 -0500 Message-Id: <1447884760-23667-1-git-send-email-stefanb@us.ibm.com> Subject: [Qemu-devel] [REPOST] [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 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 8d8523a..424d7e3 100644 --- a/hw/tpm/tpm_passthrough.c +++ b/hw/tpm/tpm_passthrough.c @@ -353,6 +353,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); @@ -366,16 +368,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