ia64/xen-unstable

changeset 10580:d85488fd2196

[TPM] Add 3 more test cases to the xm testsuite that extend the
state of a PCR register and test that the value remains the same during
a suspend/resume cycle and during live and non-live local migration.
The patch adapts existing tests to the changes in the driver (moving of
the sysfs entry). Some problems with existing tests are fixed.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed Jun 28 16:22:38 2006 +0100 (2006-06-28)
parents e3ad9b9c95ee
children ca3f2a137159
files tools/xm-test/tests/vtpm/02_vtpm-cat_pcrs.py tools/xm-test/tests/vtpm/03_vtpm-susp_res.py tools/xm-test/tests/vtpm/04_vtpm-loc_migr.py tools/xm-test/tests/vtpm/05_vtpm-loc_migr.py tools/xm-test/tests/vtpm/06_vtpm-susp_res_pcrs.py tools/xm-test/tests/vtpm/07_vtpm-mig_pcrs.py tools/xm-test/tests/vtpm/08_vtpm-mig_pcrs.py tools/xm-test/tests/vtpm/Makefile.am tools/xm-test/tests/vtpm/vtpm_utils.py
line diff
     1.1 --- a/tools/xm-test/tests/vtpm/02_vtpm-cat_pcrs.py	Wed Jun 28 16:21:30 2006 +0100
     1.2 +++ b/tools/xm-test/tests/vtpm/02_vtpm-cat_pcrs.py	Wed Jun 28 16:22:38 2006 +0100
     1.3 @@ -14,16 +14,15 @@ import os.path
     1.4  
     1.5  config = {"vtpm":"instance=1,backend=0"}
     1.6  domain = XmTestDomain(extraConfig=config)
     1.7 +domName = domain.getName()
     1.8  
     1.9  try:
    1.10      console = domain.start()
    1.11  except DomainError, e:
    1.12      if verbose:
    1.13          print e.extra
    1.14 -    vtpm_cleanup(domain.getName())
    1.15 -    FAIL("Unable to create domain")
    1.16 -
    1.17 -domName = domain.getName()
    1.18 +    vtpm_cleanup(domName)
    1.19 +    FAIL("Unable to create domain (%s)" % domName)
    1.20  
    1.21  try:
    1.22      console.sendInput("input")
    1.23 @@ -33,11 +32,11 @@ except ConsoleError, e:
    1.24      FAIL(str(e))
    1.25  
    1.26  try:
    1.27 -    run = console.runCmd("cat /sys/devices/platform/tpm_vtpm/pcrs")
    1.28 +    run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
    1.29  except ConsoleError, e:
    1.30      saveLog(console.getHistory())
    1.31      vtpm_cleanup(domName)
    1.32 -    FAIL(str(e))
    1.33 +    FAIL("No result from dumping the PCRs")
    1.34  
    1.35  if re.search("No such file",run["output"]):
    1.36      vtpm_cleanup(domName)
     2.1 --- a/tools/xm-test/tests/vtpm/03_vtpm-susp_res.py	Wed Jun 28 16:21:30 2006 +0100
     2.2 +++ b/tools/xm-test/tests/vtpm/03_vtpm-susp_res.py	Wed Jun 28 16:22:38 2006 +0100
     2.3 @@ -15,6 +15,7 @@ import os.path
     2.4  
     2.5  config = {"vtpm":"instance=1,backend=0"}
     2.6  domain = XmTestDomain(extraConfig=config)
     2.7 +domName = domain.getName()
     2.8  consoleHistory = ""
     2.9  
    2.10  try:
    2.11 @@ -22,10 +23,8 @@ try:
    2.12  except DomainError, e:
    2.13      if verbose:
    2.14          print e.extra
    2.15 -    vtpm_cleanup(domain.getName())
    2.16 -    FAIL("Unable to create domain")
    2.17 -
    2.18 -domName = domain.getName()
    2.19 +    vtpm_cleanup(domName)
    2.20 +    FAIL("Unable to create domain (%s)" % domName)
    2.21  
    2.22  try:
    2.23      console.sendInput("input")
    2.24 @@ -35,11 +34,11 @@ except ConsoleError, e:
    2.25      FAIL(str(e))
    2.26  
    2.27  try:
    2.28 -    run = console.runCmd("cat /sys/devices/platform/tpm_vtpm/pcrs")
    2.29 +    run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
    2.30  except ConsoleError, e:
    2.31      saveLog(console.getHistory())
    2.32      vtpm_cleanup(domName)
    2.33 -    FAIL(str(e))
    2.34 +    FAIL("No result from dumping the PCRs")
    2.35  
    2.36  if re.search("No such file",run["output"]):
    2.37      vtpm_cleanup(domName)
    2.38 @@ -48,50 +47,59 @@ if re.search("No such file",run["output"
    2.39  consoleHistory = console.getHistory()
    2.40  domain.closeConsole()
    2.41  
    2.42 -try:
    2.43 -    status, ouptut = traceCommand("xm save %s %s.save" %
    2.44 -                                  (domName, domName),
    2.45 -                                  timeout=30)
    2.46 -
    2.47 -except TimeoutError, e:
    2.48 -    saveLog(consoleHistory)
    2.49 -    vtpm_cleanup(domName)
    2.50 -    FAIL(str(e))
    2.51 +loop = 0
    2.52 +while loop < 3:
    2.53 +    try:
    2.54 +        status, ouptut = traceCommand("xm save %s %s.save" %
    2.55 +                                      (domName, domName),
    2.56 +                                      timeout=30)
    2.57  
    2.58 -if status != 0:
    2.59 -    saveLog(consoleHistory)
    2.60 -    vtpm_cleanup(domName)
    2.61 -    FAIL("xm save did not succeed")
    2.62 +    except TimeoutError, e:
    2.63 +        saveLog(consoleHistory)
    2.64 +        vtpm_cleanup(domName)
    2.65 +        FAIL(str(e))
    2.66  
    2.67 -try:
    2.68 -    status, ouptut = traceCommand("xm restore %s.save" %
    2.69 -                                  (domName),
    2.70 -                                  timeout=30)
    2.71 -except TimeoutError, e:
    2.72 +    if status != 0:
    2.73 +        saveLog(consoleHistory)
    2.74 +        vtpm_cleanup(domName)
    2.75 +        FAIL("xm save did not succeed")
    2.76 +
    2.77 +    try:
    2.78 +        status, ouptut = traceCommand("xm restore %s.save" %
    2.79 +                                      (domName),
    2.80 +                                      timeout=30)
    2.81 +    except TimeoutError, e:
    2.82 +        os.remove("%s.save" % domName)
    2.83 +        saveLog(consoleHistory)
    2.84 +        vtpm_cleanup(domName)
    2.85 +        FAIL(str(e))
    2.86 +
    2.87      os.remove("%s.save" % domName)
    2.88 -    saveLog(consoleHistory)
    2.89 -    vtpm_cleanup(domName)
    2.90 -    FAIL(str(e))
    2.91 -
    2.92 -os.remove("%s.save" % domName)
    2.93 -
    2.94 -if status != 0:
    2.95 -    saveLog(consoleHistory)
    2.96 -    vtpm_cleanup(domName)
    2.97 -    FAIL("xm restore did not succeed")
    2.98  
    2.99 -try:
   2.100 -    console = domain.getConsole()
   2.101 -except ConsoleError, e:
   2.102 -    vtpm_cleanup(domName)
   2.103 -    FAIL(str(e))
   2.104 +    if status != 0:
   2.105 +        saveLog(consoleHistory)
   2.106 +        vtpm_cleanup(domName)
   2.107 +        FAIL("xm restore did not succeed")
   2.108  
   2.109 -try:
   2.110 -    run = console.runCmd("cat /sys/devices/platform/tpm_vtpm/pcrs")
   2.111 -except ConsoleError, e:
   2.112 -    saveLog(console.getHistory())
   2.113 -    vtpm_cleanup(domName)
   2.114 -    FAIL(str(e))
   2.115 +    try:
   2.116 +        console = domain.getConsole()
   2.117 +    except ConsoleError, e:
   2.118 +        vtpm_cleanup(domName)
   2.119 +        FAIL(str(e))
   2.120 +
   2.121 +    try:
   2.122 +        run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
   2.123 +    except ConsoleError, e:
   2.124 +        saveLog(console.getHistory())
   2.125 +        vtpm_cleanup(domName)
   2.126 +        FAIL(str(e))
   2.127 +
   2.128 +    if not re.search("PCR-00:",run["output"]):
   2.129 +        saveLog(console.getHistory())
   2.130 +        vtpm_cleanup(domName)
   2.131 +	FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side")
   2.132 +
   2.133 +    loop += 1
   2.134  
   2.135  domain.closeConsole()
   2.136  
   2.137 @@ -99,5 +107,3 @@ domain.stop()
   2.138  
   2.139  vtpm_cleanup(domName)
   2.140  
   2.141 -if not re.search("PCR-00:",run["output"]):
   2.142 -	FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side")
     3.1 --- a/tools/xm-test/tests/vtpm/04_vtpm-loc_migr.py	Wed Jun 28 16:21:30 2006 +0100
     3.2 +++ b/tools/xm-test/tests/vtpm/04_vtpm-loc_migr.py	Wed Jun 28 16:22:38 2006 +0100
     3.3 @@ -16,6 +16,7 @@ import os.path
     3.4  
     3.5  config = {"vtpm":"instance=1,backend=0"}
     3.6  domain = XmTestDomain(extraConfig=config)
     3.7 +domName = domain.getName()
     3.8  consoleHistory = ""
     3.9  
    3.10  try:
    3.11 @@ -23,10 +24,8 @@ try:
    3.12  except DomainError, e:
    3.13      if verbose:
    3.14          print e.extra
    3.15 -    vtpm_cleanup(domain.getName())
    3.16 -    FAIL("Unable to create domain")
    3.17 -
    3.18 -domName = domain.getName()
    3.19 +    vtpm_cleanup(domName)
    3.20 +    FAIL("Unable to create domain (%s)" % domName)
    3.21  
    3.22  try:
    3.23      console.sendInput("input")
    3.24 @@ -36,11 +35,11 @@ except ConsoleError, e:
    3.25      FAIL(str(e))
    3.26  
    3.27  try:
    3.28 -    run = console.runCmd("cat /sys/devices/platform/tpm_vtpm/pcrs")
    3.29 +    run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
    3.30  except ConsoleError, e:
    3.31      saveLog(console.getHistory())
    3.32      vtpm_cleanup(domName)
    3.33 -    FAIL(str(e))
    3.34 +    FAIL("No result from dumping the PCRs")
    3.35  
    3.36  if re.search("No such file",run["output"]):
    3.37      vtpm_cleanup(domName)
    3.38 @@ -83,11 +82,17 @@ while loop < 3:
    3.39          FAIL(str(e))
    3.40  
    3.41      try:
    3.42 -        run = console.runCmd("cat /sys/devices/platform/tpm_vtpm/pcrs")
    3.43 +        run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
    3.44      except ConsoleError, e:
    3.45          saveLog(console.getHistory())
    3.46          vtpm_cleanup(domName)
    3.47 -        FAIL(str(e))
    3.48 +        FAIL("No result from dumping the PCRs")
    3.49 +
    3.50 +    if not re.search("PCR-00:",run["output"]):
    3.51 +        saveLog(console.getHistory())
    3.52 +        vtpm_cleanup(domName)
    3.53 +	FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side")
    3.54 +
    3.55      loop += 1
    3.56  
    3.57  domain.closeConsole()
    3.58 @@ -95,6 +100,3 @@ domain.closeConsole()
    3.59  domain.stop()
    3.60  
    3.61  vtpm_cleanup(domName)
    3.62 -
    3.63 -if not re.search("PCR-00:",run["output"]):
    3.64 -	FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side")
     4.1 --- a/tools/xm-test/tests/vtpm/05_vtpm-loc_migr.py	Wed Jun 28 16:21:30 2006 +0100
     4.2 +++ b/tools/xm-test/tests/vtpm/05_vtpm-loc_migr.py	Wed Jun 28 16:22:38 2006 +0100
     4.3 @@ -16,6 +16,7 @@ import os.path
     4.4  
     4.5  config = {"vtpm":"instance=1,backend=0"}
     4.6  domain = XmTestDomain(extraConfig=config)
     4.7 +domName = domain.getName()
     4.8  consoleHistory = ""
     4.9  
    4.10  try:
    4.11 @@ -23,10 +24,8 @@ try:
    4.12  except DomainError, e:
    4.13      if verbose:
    4.14          print e.extra
    4.15 -    vtpm_cleanup(domain.getName())
    4.16 -    FAIL("Unable to create domain")
    4.17 -
    4.18 -domName = domain.getName()
    4.19 +    vtpm_cleanup(domName)
    4.20 +    FAIL("Unable to create domain (%s)" % domName)
    4.21  
    4.22  try:
    4.23      console.sendInput("input")
    4.24 @@ -36,11 +35,11 @@ except ConsoleError, e:
    4.25      FAIL(str(e))
    4.26  
    4.27  try:
    4.28 -    run = console.runCmd("cat /sys/devices/platform/tpm_vtpm/pcrs")
    4.29 +    run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
    4.30  except ConsoleError, e:
    4.31      saveLog(console.getHistory())
    4.32      vtpm_cleanup(domName)
    4.33 -    FAIL(str(e))
    4.34 +    FAIL("No result from dumping the PCRs")
    4.35  
    4.36  if re.search("No such file",run["output"]):
    4.37      vtpm_cleanup(domName)
    4.38 @@ -83,11 +82,17 @@ while loop < 3:
    4.39          FAIL(str(e))
    4.40  
    4.41      try:
    4.42 -        run = console.runCmd("cat /sys/devices/platform/tpm_vtpm/pcrs")
    4.43 +        run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
    4.44      except ConsoleError, e:
    4.45          saveLog(console.getHistory())
    4.46          vtpm_cleanup(domName)
    4.47 -        FAIL(str(e))
    4.48 +        FAIL("No result from dumping the PCRs")
    4.49 +
    4.50 +    if not re.search("PCR-00:",run["output"]):
    4.51 +        saveLog(console.getHistory())
    4.52 +        vtpm_cleanup(domName)
    4.53 +	FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side")
    4.54 +
    4.55      loop += 1
    4.56  
    4.57  domain.closeConsole()
    4.58 @@ -95,6 +100,3 @@ domain.closeConsole()
    4.59  domain.stop()
    4.60  
    4.61  vtpm_cleanup(domName)
    4.62 -
    4.63 -if not re.search("PCR-00:",run["output"]):
    4.64 -	FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side")
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/tools/xm-test/tests/vtpm/06_vtpm-susp_res_pcrs.py	Wed Jun 28 16:22:38 2006 +0100
     5.3 @@ -0,0 +1,139 @@
     5.4 +#!/usr/bin/python
     5.5 +
     5.6 +# Copyright (C) International Business Machines Corp., 2006
     5.7 +# Author: Stefan Berger <stefanb@us.ibm.com>
     5.8 +
     5.9 +# Positive Test: create domain with virtual TPM attached at build time,
    5.10 +#                extend a pcr
    5.11 +#                check list of pcrs; suspend and resume the domain and
    5.12 +#                check list of pcrs again and validate extended pcr
    5.13 +
    5.14 +from XmTestLib import *
    5.15 +from vtpm_utils import *
    5.16 +import commands
    5.17 +import os
    5.18 +import os.path
    5.19 +
    5.20 +config = {"vtpm":"instance=1,backend=0"}
    5.21 +domain = XmTestDomain(extraConfig=config)
    5.22 +domName = domain.getName()
    5.23 +consoleHistory = ""
    5.24 +
    5.25 +try:
    5.26 +    console = domain.start()
    5.27 +except DomainError, e:
    5.28 +    if verbose:
    5.29 +        print e.extra
    5.30 +    vtpm_cleanup(domName)
    5.31 +    FAIL("Unable to create domain (%s)" % domName)
    5.32 +
    5.33 +try:
    5.34 +    console.sendInput("input")
    5.35 +except ConsoleError, e:
    5.36 +    saveLog(console.getHistory())
    5.37 +    vtpm_cleanup(domName)
    5.38 +    FAIL(str(e))
    5.39 +
    5.40 +try:
    5.41 +    run = console.runCmd("mknod /dev/tpm0 c 10 224")
    5.42 +except ConsoleError, e:
    5.43 +    saveLog(console.getHistory())
    5.44 +    vtpm_cleanup(domName)
    5.45 +    FAIL("Error while creating /dev/tpm0")
    5.46 +
    5.47 +try:
    5.48 +    run = console.runCmd("echo -ne \"\\x00\\xc1\\x00\\x00\\x00\\x22\\x00\\x00\\x00\\x14\\x00\\x00\\x00\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\x09\\x0a\\x0b\\x0c\\x0d\\x0e\\0xf\\x10\\x11\\x12\\x13\\x14\" > /dev/tpm0")
    5.49 +except ConsoleError, e:
    5.50 +    saveLog(console.getHistory())
    5.51 +    vtpm_cleanup(domName)
    5.52 +    FAIL("Error while extending PCR 0")
    5.53 +
    5.54 +try:
    5.55 +    run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
    5.56 +except ConsoleError, e:
    5.57 +    saveLog(console.getHistory())
    5.58 +    vtpm_cleanup(domName)
    5.59 +    FAIL("No result from dumping the PCRs")
    5.60 +
    5.61 +
    5.62 +if re.search("No such file",run["output"]):
    5.63 +    vtpm_cleanup(domName)
    5.64 +    FAIL("TPM frontend support not compiled into (domU?) kernel")
    5.65 +
    5.66 +if not re.search("PCR-00:",run["output"]):
    5.67 +    saveLog(console.getHistory())
    5.68 +    vtpm_cleanup(domName)
    5.69 +    FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side: \n%s" % run["output"])
    5.70 +
    5.71 +if not re.search("PCR-00: 1E A7 BD",run["output"]):
    5.72 +    saveLog(console.getHistory())
    5.73 +    FAIL("Extend did not lead to expected result (1E A7 BD ...): \n%s" % run["output"])
    5.74 +
    5.75 +consoleHistory = console.getHistory()
    5.76 +domain.closeConsole()
    5.77 +
    5.78 +loop = 0
    5.79 +while loop < 3:
    5.80 +    try:
    5.81 +        status, ouptut = traceCommand("xm save %s %s.save" %
    5.82 +                                      (domName, domName),
    5.83 +                                      timeout=30)
    5.84 +
    5.85 +    except TimeoutError, e:
    5.86 +        saveLog(consoleHistory)
    5.87 +        vtpm_cleanup(domName)
    5.88 +        FAIL(str(e))
    5.89 +
    5.90 +    if status != 0:
    5.91 +        saveLog(consoleHistory)
    5.92 +        vtpm_cleanup(domName)
    5.93 +        FAIL("xm save did not succeed")
    5.94 +
    5.95 +    try:
    5.96 +        status, ouptut = traceCommand("xm restore %s.save" %
    5.97 +                                      (domName),
    5.98 +                                      timeout=30)
    5.99 +    except TimeoutError, e:
   5.100 +        os.remove("%s.save" % domName)
   5.101 +        saveLog(consoleHistory)
   5.102 +        vtpm_cleanup(domName)
   5.103 +        FAIL(str(e))
   5.104 +
   5.105 +    os.remove("%s.save" % domName)
   5.106 +
   5.107 +    if status != 0:
   5.108 +        saveLog(consoleHistory)
   5.109 +        vtpm_cleanup(domName)
   5.110 +        FAIL("xm restore did not succeed")
   5.111 +
   5.112 +    try:
   5.113 +        console = domain.getConsole()
   5.114 +    except ConsoleError, e:
   5.115 +        vtpm_cleanup(domName)
   5.116 +        FAIL(str(e))
   5.117 +
   5.118 +    try:
   5.119 +        run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
   5.120 +    except ConsoleError, e:
   5.121 +        saveLog(console.getHistory())
   5.122 +        vtpm_cleanup(domName)
   5.123 +        FAIL(str(e))
   5.124 +
   5.125 +    if not re.search("PCR-00:",run["output"]):
   5.126 +        saveLog(console.getHistory())
   5.127 +        vtpm_cleanup(domName)
   5.128 +	FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side")
   5.129 +
   5.130 +    if not re.search("PCR-00: 1E A7 BD",run["output"]):
   5.131 +        saveLog(console.getHistory())
   5.132 +        vtpm_cleanup(domName)
   5.133 +	FAIL("Virtual TPM lost PCR 0 value: \n%s" % run["output"])
   5.134 +
   5.135 +    loop += 1
   5.136 +
   5.137 +domain.closeConsole()
   5.138 +
   5.139 +domain.stop()
   5.140 +
   5.141 +vtpm_cleanup(domName)
   5.142 +
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/tools/xm-test/tests/vtpm/07_vtpm-mig_pcrs.py	Wed Jun 28 16:22:38 2006 +0100
     6.3 @@ -0,0 +1,132 @@
     6.4 +#!/usr/bin/python
     6.5 +
     6.6 +# Copyright (C) International Business Machines Corp., 2006
     6.7 +# Author: Stefan Berger <stefanb@us.ibm.com>
     6.8 +
     6.9 +# Positive Test: create domain with virtual TPM attached at build time,
    6.10 +#                extend a pcr
    6.11 +#                check list of pcrs; locally migrate the domain and
    6.12 +#                check list of pcrs again and validate extended pcr
    6.13 +#                This test does local live migration.
    6.14 +
    6.15 +from XmTestLib import *
    6.16 +from vtpm_utils import *
    6.17 +import commands
    6.18 +import os
    6.19 +import os.path
    6.20 +
    6.21 +config = {"vtpm":"instance=1,backend=0"}
    6.22 +domain = XmTestDomain(extraConfig=config)
    6.23 +domName = domain.getName()
    6.24 +consoleHistory = ""
    6.25 +
    6.26 +try:
    6.27 +    console = domain.start()
    6.28 +except DomainError, e:
    6.29 +    if verbose:
    6.30 +        print e.extra
    6.31 +    vtpm_cleanup(domName)
    6.32 +    FAIL("Unable to create domain (%s)" % domName)
    6.33 +
    6.34 +try:
    6.35 +    console.sendInput("input")
    6.36 +except ConsoleError, e:
    6.37 +    saveLog(console.getHistory())
    6.38 +    vtpm_cleanup(domName)
    6.39 +    FAIL(str(e))
    6.40 +
    6.41 +try:
    6.42 +    run = console.runCmd("mknod /dev/tpm0 c 10 224")
    6.43 +except ConsoleError, e:
    6.44 +    saveLog(console.getHistory())
    6.45 +    vtpm_cleanup(domName)
    6.46 +    FAIL("Error while creating /dev/tpm0")
    6.47 +
    6.48 +try:
    6.49 +    run = console.runCmd("echo -ne \"\\x00\\xc1\\x00\\x00\\x00\\x22\\x00\\x00\\x00\\x14\\x00\\x00\\x00\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\x09\\x0a\\x0b\\x0c\\x0d\\x0e\\0xf\\x10\\x11\\x12\\x13\\x14\" > /dev/tpm0")
    6.50 +except ConsoleError, e:
    6.51 +    saveLog(console.getHistory())
    6.52 +    vtpm_cleanup(domName)
    6.53 +    FAIL("Error while extending PCR 0")
    6.54 +
    6.55 +try:
    6.56 +    run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
    6.57 +except ConsoleError, e:
    6.58 +    saveLog(console.getHistory())
    6.59 +    vtpm_cleanup(domName)
    6.60 +    FAIL("No result from dumping the PCRs")
    6.61 +
    6.62 +
    6.63 +if re.search("No such file",run["output"]):
    6.64 +    vtpm_cleanup(domName)
    6.65 +    FAIL("TPM frontend support not compiled into (domU?) kernel")
    6.66 +
    6.67 +if not re.search("PCR-00:",run["output"]):
    6.68 +    saveLog(console.getHistory())
    6.69 +    vtpm_cleanup(domName)
    6.70 +    FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side: \n%s" % run["output"])
    6.71 +
    6.72 +if not re.search("PCR-00: 1E A7 BD",run["output"]):
    6.73 +    saveLog(console.getHistory())
    6.74 +    FAIL("Extend did not lead to expected result (1E A7 BD ...): \n%s" % run["output"])
    6.75 +
    6.76 +consoleHistory = console.getHistory()
    6.77 +domain.closeConsole()
    6.78 +
    6.79 +old_domid = domid(domName)
    6.80 +
    6.81 +loop = 0
    6.82 +while loop < 3:
    6.83 +    try:
    6.84 +        status, ouptut = traceCommand("xm migrate -l %s localhost" %
    6.85 +                                      domName,
    6.86 +                                      timeout=90)
    6.87 +    except TimeoutError, e:
    6.88 +        saveLog(consoleHistory)
    6.89 +        vtpm_cleanup(domName)
    6.90 +        FAIL(str(e))
    6.91 +
    6.92 +    if status != 0:
    6.93 +        saveLog(consoleHistory)
    6.94 +        vtpm_cleanup(domName)
    6.95 +        FAIL("xm migrate did not succeed. External device migration activated?")
    6.96 +
    6.97 +
    6.98 +    domName = domain.getName()
    6.99 +    new_domid = domid(domName)
   6.100 +
   6.101 +    if (old_domid == new_domid):
   6.102 +        vtpm_cleanup(domName)
   6.103 +        FAIL("xm migrate failed, domain id is still %s (loop=%d)" %
   6.104 +             (old_domid,loop))
   6.105 +
   6.106 +    try:
   6.107 +        console = domain.getConsole()
   6.108 +    except ConsoleError, e:
   6.109 +        vtpm_cleanup(domName)
   6.110 +        FAIL(str(e))
   6.111 +
   6.112 +    try:
   6.113 +        run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
   6.114 +    except ConsoleError, e:
   6.115 +        saveLog(console.getHistory())
   6.116 +        vtpm_cleanup(domName)
   6.117 +        FAIL("No result from dumping the PCRs")
   6.118 +
   6.119 +    if not re.search("PCR-00:",run["output"]):
   6.120 +        saveLog(console.getHistory())
   6.121 +        vtpm_cleanup(domName)
   6.122 +	FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side")
   6.123 +
   6.124 +    if not re.search("PCR-00: 1E A7 BD",run["output"]):
   6.125 +        saveLog(console.getHistory())
   6.126 +        vtpm_cleanup(domName)
   6.127 +	FAIL("Virtual TPM lost PCR 0 value: \n%s" % run["output"])
   6.128 +
   6.129 +    loop += 1
   6.130 +
   6.131 +domain.closeConsole()
   6.132 +
   6.133 +domain.stop()
   6.134 +
   6.135 +vtpm_cleanup(domName)
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/tools/xm-test/tests/vtpm/08_vtpm-mig_pcrs.py	Wed Jun 28 16:22:38 2006 +0100
     7.3 @@ -0,0 +1,132 @@
     7.4 +#!/usr/bin/python
     7.5 +
     7.6 +# Copyright (C) International Business Machines Corp., 2006
     7.7 +# Author: Stefan Berger <stefanb@us.ibm.com>
     7.8 +
     7.9 +# Positive Test: create domain with virtual TPM attached at build time,
    7.10 +#                extend a pcr
    7.11 +#                check list of pcrs; locally migrate the domain and
    7.12 +#                check list of pcrs again and validate extended pcr
    7.13 +#                This test does local (non-live) migration.
    7.14 +
    7.15 +from XmTestLib import *
    7.16 +from vtpm_utils import *
    7.17 +import commands
    7.18 +import os
    7.19 +import os.path
    7.20 +
    7.21 +config = {"vtpm":"instance=1,backend=0"}
    7.22 +domain = XmTestDomain(extraConfig=config)
    7.23 +domName = domain.getName()
    7.24 +consoleHistory = ""
    7.25 +
    7.26 +try:
    7.27 +    console = domain.start()
    7.28 +except DomainError, e:
    7.29 +    if verbose:
    7.30 +        print e.extra
    7.31 +    vtpm_cleanup(domName)
    7.32 +    FAIL("Unable to create domain (%s)" % domName)
    7.33 +
    7.34 +try:
    7.35 +    console.sendInput("input")
    7.36 +except ConsoleError, e:
    7.37 +    saveLog(console.getHistory())
    7.38 +    vtpm_cleanup(domName)
    7.39 +    FAIL(str(e))
    7.40 +
    7.41 +try:
    7.42 +    run = console.runCmd("mknod /dev/tpm0 c 10 224")
    7.43 +except ConsoleError, e:
    7.44 +    saveLog(console.getHistory())
    7.45 +    vtpm_cleanup(domName)
    7.46 +    FAIL("Error while creating /dev/tpm0")
    7.47 +
    7.48 +try:
    7.49 +    run = console.runCmd("echo -ne \"\\x00\\xc1\\x00\\x00\\x00\\x22\\x00\\x00\\x00\\x14\\x00\\x00\\x00\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\x09\\x0a\\x0b\\x0c\\x0d\\x0e\\0xf\\x10\\x11\\x12\\x13\\x14\" > /dev/tpm0")
    7.50 +except ConsoleError, e:
    7.51 +    saveLog(console.getHistory())
    7.52 +    vtpm_cleanup(domName)
    7.53 +    FAIL("Error while extending PCR 0")
    7.54 +
    7.55 +try:
    7.56 +    run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
    7.57 +except ConsoleError, e:
    7.58 +    saveLog(console.getHistory())
    7.59 +    vtpm_cleanup(domName)
    7.60 +    FAIL("No result from dumping the PCRs")
    7.61 +
    7.62 +
    7.63 +if re.search("No such file",run["output"]):
    7.64 +    vtpm_cleanup(domName)
    7.65 +    FAIL("TPM frontend support not compiled into (domU?) kernel")
    7.66 +
    7.67 +if not re.search("PCR-00:",run["output"]):
    7.68 +    saveLog(console.getHistory())
    7.69 +    vtpm_cleanup(domName)
    7.70 +    FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side: \n%s" % run["output"])
    7.71 +
    7.72 +if not re.search("PCR-00: 1E A7 BD",run["output"]):
    7.73 +    saveLog(console.getHistory())
    7.74 +    FAIL("Extend did not lead to expected result (1E A7 BD ...): \n%s" % run["output"])
    7.75 +
    7.76 +consoleHistory = console.getHistory()
    7.77 +domain.closeConsole()
    7.78 +
    7.79 +old_domid = domid(domName)
    7.80 +
    7.81 +loop = 0
    7.82 +while loop < 3:
    7.83 +    try:
    7.84 +        status, ouptut = traceCommand("xm migrate %s localhost" %
    7.85 +                                      domName,
    7.86 +                                      timeout=90)
    7.87 +    except TimeoutError, e:
    7.88 +        saveLog(consoleHistory)
    7.89 +        vtpm_cleanup(domName)
    7.90 +        FAIL(str(e))
    7.91 +
    7.92 +    if status != 0:
    7.93 +        saveLog(consoleHistory)
    7.94 +        vtpm_cleanup(domName)
    7.95 +        FAIL("xm migrate did not succeed. External device migration activated?")
    7.96 +
    7.97 +
    7.98 +    domName = domain.getName()
    7.99 +    new_domid = domid(domName)
   7.100 +
   7.101 +    if (old_domid == new_domid):
   7.102 +        vtpm_cleanup(domName)
   7.103 +        FAIL("xm migrate failed, domain id is still %s (loop=%d)" %
   7.104 +             (old_domid,loop))
   7.105 +
   7.106 +    try:
   7.107 +        console = domain.getConsole()
   7.108 +    except ConsoleError, e:
   7.109 +        vtpm_cleanup(domName)
   7.110 +        FAIL(str(e))
   7.111 +
   7.112 +    try:
   7.113 +        run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
   7.114 +    except ConsoleError, e:
   7.115 +        saveLog(console.getHistory())
   7.116 +        vtpm_cleanup(domName)
   7.117 +        FAIL("No result from dumping the PCRs")
   7.118 +
   7.119 +    if not re.search("PCR-00:",run["output"]):
   7.120 +        saveLog(console.getHistory())
   7.121 +        vtpm_cleanup(domName)
   7.122 +	FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side")
   7.123 +
   7.124 +    if not re.search("PCR-00: 1E A7 BD",run["output"]):
   7.125 +        saveLog(console.getHistory())
   7.126 +        vtpm_cleanup(domName)
   7.127 +	FAIL("Virtual TPM lost PCR 0 value: \n%s" % run["output"])
   7.128 +
   7.129 +    loop += 1
   7.130 +
   7.131 +domain.closeConsole()
   7.132 +
   7.133 +domain.stop()
   7.134 +
   7.135 +vtpm_cleanup(domName)
     8.1 --- a/tools/xm-test/tests/vtpm/Makefile.am	Wed Jun 28 16:21:30 2006 +0100
     8.2 +++ b/tools/xm-test/tests/vtpm/Makefile.am	Wed Jun 28 16:22:38 2006 +0100
     8.3 @@ -4,7 +4,10 @@ TESTS = 01_vtpm-list_pos.test \
     8.4          02_vtpm-cat_pcrs.test \
     8.5          03_vtpm-susp_res.test \
     8.6          04_vtpm-loc_migr.test \
     8.7 -        05_vtpm-loc_migr.test
     8.8 +        05_vtpm-loc_migr.test \
     8.9 +        06_vtpm-susp_res_pcrs.test \
    8.10 +        07_vtpm-mig_pcrs.test \
    8.11 +        08_vtpm-mig_pcrs.test
    8.12  
    8.13  XFAIL_TESTS =
    8.14  
     9.1 --- a/tools/xm-test/tests/vtpm/vtpm_utils.py	Wed Jun 28 16:21:30 2006 +0100
     9.2 +++ b/tools/xm-test/tests/vtpm/vtpm_utils.py	Wed Jun 28 16:22:38 2006 +0100
     9.3 @@ -16,4 +16,4 @@ if output == "":
     9.4      FAIL("virtual TPM manager must be started to run this test")
     9.5  
     9.6  def vtpm_cleanup(domName):
     9.7 -	traceCommand("/etc/xen/scripts/vtpm-delete %s" % domName)
     9.8 +    traceCommand("/etc/xen/scripts/vtpm-delete %s" % domName)