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

[Xen-changelog] VTPM_Tools: Fix error when closing only vtpm, and fix restore bug when



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID f3661f9a95dd183bd20b05494d99b7bc0e2d27c0
# Parent  46a6d962691199828fb09963205845e002154fb7
VTPM_Tools: Fix error when closing only vtpm, and fix restore bug when
no dmis exist

The first bug prevented the TPM tests from running successfully more
than once in a row.

Signed-off-by: Vinnie Scarlata <vincent.r.scarlata@xxxxxxxxx>

diff -r 46a6d9626911 -r f3661f9a95dd tools/vtpm_manager/manager/dmictl.c
--- a/tools/vtpm_manager/manager/dmictl.c       Fri Mar  3 09:44:40 2006
+++ b/tools/vtpm_manager/manager/dmictl.c       Fri Mar  3 09:46:06 2006
@@ -74,7 +74,13 @@
          
   close(dmi_res->guest_tx_fh); dmi_res->guest_tx_fh = -1;
   close(dmi_res->vtpm_tx_fh);  dmi_res->vtpm_tx_fh = -1; 
-               
+  vtpm_globals->connected_dmis--;
+
+  if (vtpm_globals->connected_dmis == 0) {
+    // No more DMI's connected. Close fifo to prevent a broken pipe.
+    close(vtpm_globals->guest_rx_fh);
+    vtpm_globals->guest_rx_fh = -1;
+  }
  #ifndef MANUAL_DM_LAUNCH
   if (dmi_res->dmi_id != VTPM_CTL_DM) {
     if (dmi_res->dmi_pid != 0) {
@@ -118,6 +124,7 @@
     status = TPM_BAD_PARAMETER;
     goto abort_egress;
   } else {
+    vtpm_globals->connected_dmis++; // Put this here so we don't count Dom0
     BSG_UnpackList( param_buf->bytes, 3,
                    BSG_TYPE_BYTE, &type,
                    BSG_TYPE_UINT32, &domain_id,
diff -r 46a6d9626911 -r f3661f9a95dd tools/vtpm_manager/manager/securestorage.c
--- a/tools/vtpm_manager/manager/securestorage.c        Fri Mar  3 09:44:40 2006
+++ b/tools/vtpm_manager/manager/securestorage.c        Fri Mar  3 09:46:06 2006
@@ -307,8 +307,8 @@
   TPM_RESULT status=TPM_SUCCESS;
   int fh, dmis=-1;
 
-  BYTE *flat_boot_key, *flat_dmis, *flat_enc;
-  buffer_t clear_flat_global, enc_flat_global;
+  BYTE *flat_boot_key=NULL, *flat_dmis=NULL, *flat_enc=NULL;
+  buffer_t clear_flat_global=NULL_BUF, enc_flat_global=NULL_BUF;
   UINT32 storageKeySize = buffer_len(&vtpm_globals->storageKeyWrap);
   UINT32 bootKeySize = buffer_len(&vtpm_globals->bootKeyWrap);
   struct pack_buf_t storage_key_pack = {storageKeySize, 
vtpm_globals->storageKeyWrap.bytes};
@@ -328,12 +328,9 @@
                                               sizeof(UINT32) +// storagekeysize
                                               storageKeySize, NULL) ); // 
storage key
 
-  flat_dmis_size = (hashtable_count(vtpm_globals->dmi_map) - 1) * // num DMIS 
(-1 for Dom0)
-                   (sizeof(UINT32) + 2*sizeof(TPM_DIGEST)); // Per DMI info
 
   flat_boot_key = (BYTE *) malloc( boot_key_size );
   flat_enc = (BYTE *) malloc( sizeof(UINT32) );
-  flat_dmis = (BYTE *) malloc( flat_dmis_size );
 
   boot_key_size = BSG_PackList(flat_boot_key, 1,
                                BSG_TPM_SIZE32_DATA, &boot_key_pack);
@@ -349,8 +346,12 @@
 
   BSG_PackConst(buffer_len(&enc_flat_global), 4, flat_enc);
 
-  // Per DMI values to be saved
+  // Per DMI values to be saved (if any exit)
   if (hashtable_count(vtpm_globals->dmi_map) > 0) {
+
+    flat_dmis_size = (hashtable_count(vtpm_globals->dmi_map) - 1) * // num 
DMIS (-1 for Dom0)
+                     (sizeof(UINT32) + 2*sizeof(TPM_DIGEST)); // Per DMI info
+    flat_dmis = (BYTE *) malloc( flat_dmis_size );
 
     dmi_itr = hashtable_iterator(vtpm_globals->dmi_map);
     do {
diff -r 46a6d9626911 -r f3661f9a95dd tools/vtpm_manager/manager/vtpm_manager.c
--- a/tools/vtpm_manager/manager/vtpm_manager.c Fri Mar  3 09:44:40 2006
+++ b/tools/vtpm_manager/manager/vtpm_manager.c Fri Mar  3 09:46:06 2006
@@ -754,6 +754,7 @@
 #ifndef VTPM_MULTI_VM
   vtpm_globals->vtpm_rx_fh = -1;
   vtpm_globals->guest_rx_fh = -1;
+  vtpm_globals->connected_dmis = 0;
 #endif
   if ((vtpm_globals->dmi_map = create_hashtable(10, hashfunc32, equals32)) == 
NULL){
     status = TPM_FAIL;
diff -r 46a6d9626911 -r f3661f9a95dd tools/vtpm_manager/manager/vtpmpriv.h
--- a/tools/vtpm_manager/manager/vtpmpriv.h     Fri Mar  3 09:44:40 2006
+++ b/tools/vtpm_manager/manager/vtpmpriv.h     Fri Mar  3 09:46:06 2006
@@ -98,6 +98,7 @@
 #ifndef VTPM_MULTI_VM
   int                 vtpm_rx_fh;
   int                 guest_rx_fh;
+  int                 connected_dmis;     // Used to close guest_rx when no 
dmis are connected
   
   pid_t               master_pid;
 #endif

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.