Patchwork [v3,2/3] nvram: Add tpm-tis drive support

login
register
mail settings
Submitter Corey Bryant
Date June 6, 2013, 1:32 p.m.
Message ID <1370525564-16912-3-git-send-email-coreyb@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/249415/
State New
Headers show

Comments

Corey Bryant - June 6, 2013, 1:32 p.m.
Add a drive property to the tpm-tis device and initialize the TPM
NVRAM if a drive is specified.

Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
---
v2
  -No changes

v3
  -No changes
---
 hw/tpm/tpm_int.h |    2 ++
 hw/tpm/tpm_tis.c |    8 ++++++++
 2 files changed, 10 insertions(+), 0 deletions(-)

Patch

diff --git a/hw/tpm/tpm_int.h b/hw/tpm/tpm_int.h
index 2f582ca..05471ef 100644
--- a/hw/tpm/tpm_int.h
+++ b/hw/tpm/tpm_int.h
@@ -29,6 +29,8 @@  struct TPMState {
 
     char *backend;
     TPMBackend *be_driver;
+
+    BlockDriverState *bdrv;
 };
 
 #define TPM(obj) OBJECT_CHECK(TPMState, (obj), TYPE_TPM_TIS)
diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
index d4d8152..8648b3b 100644
--- a/hw/tpm/tpm_tis.c
+++ b/hw/tpm/tpm_tis.c
@@ -27,6 +27,7 @@ 
 #include "hw/i386/pc.h"
 #include "hw/pci/pci_ids.h"
 #include "tpm_tis.h"
+#include "tpm_nvram.h"
 #include "qemu-common.h"
 
 /*#define DEBUG_TIS */
@@ -849,6 +850,7 @@  static Property tpm_tis_properties[] = {
     DEFINE_PROP_UINT32("irq", TPMState,
                        s.tis.irq_num, TPM_TIS_IRQ),
     DEFINE_PROP_STRING("tpmdev", TPMState, backend),
+    DEFINE_PROP_DRIVE("drive", TPMState, bdrv),
     DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -864,6 +866,12 @@  static void tpm_tis_realizefn(DeviceState *dev, Error **errp)
         return;
     }
 
+    if (s->bdrv && tpm_nvram_init(s->bdrv)) {
+        error_setg(errp, "tpm_tis: backend drive with id %s could not "
+                   "initialize TPM NVRAM drive", s->backend);
+        return;
+    }
+
     s->be_driver->fe_model = TPM_MODEL_TPM_TIS;
 
     if (tpm_backend_init(s->be_driver, s, tpm_tis_receive_cb)) {