Re: [PATCH v6 04/11] Helper functions for host TPM support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



After a further simplification the patch now looks like this:


Implement helper function to create the TPM's sysfs cancel file.

Signed-off-by: Stefan Berger <stefanb@xxxxxxxxxxxxxxxxxx>
Reviewed-by: Corey Bryant <coreyb@xxxxxxxxxxxxxxxxxx>
Tested-by: Corey Bryant <coreyb@xxxxxxxxxxxxxxxxxx>

---
 po/POTFILES.in           |    1
 src/Makefile.am          |    1
 src/libvirt_private.syms |    4 ++
src/util/virtpm.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++
 src/util/virtpm.h        |   27 +++++++++++++++++++
 5 files changed, 98 insertions(+)

Index: libvirt/src/Makefile.am
===================================================================
--- libvirt.orig/src/Makefile.am
+++ libvirt/src/Makefile.am
@@ -122,6 +122,7 @@ UTIL_SOURCES =                            \
         util/virthreadwin32.h                \
         util/virthreadpool.c util/virthreadpool.h    \
         util/virtime.h util/virtime.c            \
+        util/virtpm.h util/virtpm.c            \
         util/virtypedparam.c util/virtypedparam.h    \
         util/virusb.c util/virusb.h            \
         util/viruri.h util/viruri.c            \
Index: libvirt/src/util/virtpm.c
===================================================================
--- /dev/null
+++ libvirt/src/util/virtpm.c
@@ -0,0 +1,65 @@
+/*
+ * virtpm.c: TPM support
+ *
+ * Copyright (C) 2013 IBM Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Author: Stefan Berger <stefanb@xxxxxxxxxxxxxxxxxx>
+ */
+
+#include <config.h>
+
+#include <sys/stat.h>
+
+#include "virutil.h"
+#include "virerror.h"
+#include "virtpm.h"
+
+#define VIR_FROM_THIS VIR_FROM_NONE
+
+/**
+ * virTPMCreateCancelPath:
+ * @devpath: Path to the TPM device
+ *
+ * Create the cancel path given the path to the TPM device
+ */
+char *
+virTPMCreateCancelPath(const char *devpath)
+{
+    char *path = NULL;
+    const char *dev;
+
+    if (devpath) {
+        dev = strrchr(devpath, '/');
+        if (dev) {
+            dev++;
+            if (virAsprintf(&path, "/sys/class/misc/%s/device/cancel",
+                            dev) < 0) {
+                virReportOOMError();
+                goto cleanup;
+            }
+        } else {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("TPM device path %s is invalid"), devpath);
+        }
+    } else {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("Missing TPM device path"));
+    }
+
+cleanup:
+    return path;
+}
Index: libvirt/src/libvirt_private.syms
===================================================================
--- libvirt.orig/src/libvirt_private.syms
+++ libvirt/src/libvirt_private.syms
@@ -1781,6 +1781,10 @@ virTimeStringThen;
 virTimeStringThenRaw;


+# util/virtpm.h
+virTPMCreateCancelPath;
+
+
 # util/virtypedparam.h
 virTypedParameterArrayValidate;
 virTypedParameterAssign;
Index: libvirt/src/util/virtpm.h
===================================================================
--- /dev/null
+++ libvirt/src/util/virtpm.h
@@ -0,0 +1,27 @@
+/*
+ * virtpm.h: TPM support
+ *
+ * Copyright (C) 2013 IBM Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Author: Stefan Berger <stefanb@xxxxxxxxxxxxxxxxxx>
+ */
+#ifndef __VIR_TPM_H__
+# define __VIR_TPM_H__
+
+char *virTPMCreateCancelPath(const char *devpath);
+
+#endif /* __VIR_TPM_H__ */
Index: libvirt/po/POTFILES.in
===================================================================
--- libvirt.orig/po/POTFILES.in
+++ libvirt/po/POTFILES.in
@@ -181,6 +181,7 @@ src/util/virsysinfo.c
 src/util/virerror.c
 src/util/virerror.h
 src/util/virtime.c
+src/util/virtpm.c
 src/util/virtypedparam.c
 src/util/viruri.c
 src/util/virusb.c

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]