ia64/xen-unstable

changeset 9807:73d847cafc87

This patch adds a test case for local virtual machine migration with a
virtual TPM attached.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
author emellor@leeni.uk.xensource.com
date Fri Apr 21 11:56:40 2006 +0100 (2006-04-21)
parents 6af7b456e684
children 83b092a2cbe6
files tools/xm-test/tests/vtpm/04_vtpm-loc_migr.py tools/xm-test/tests/vtpm/Makefile.am
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tools/xm-test/tests/vtpm/04_vtpm-loc_migr.py	Fri Apr 21 11:56:40 2006 +0100
     1.3 @@ -0,0 +1,99 @@
     1.4 +#!/usr/bin/python
     1.5 +
     1.6 +# Copyright (C) International Business Machines Corp., 2006
     1.7 +# Author: Stefan Berger <stefanb@us.ibm.com>
     1.8 +
     1.9 +# Positive Test: create domain with virtual TPM attached at build time,
    1.10 +#                check list of pcrs; locally migrate the domain and
    1.11 +#                check list of pcrs again
    1.12 +
    1.13 +from XmTestLib import *
    1.14 +from vtpm_utils import *
    1.15 +import commands
    1.16 +import os
    1.17 +import os.path
    1.18 +
    1.19 +config = {"vtpm":"instance=1,backend=0"}
    1.20 +domain = XmTestDomain(extraConfig=config)
    1.21 +
    1.22 +try:
    1.23 +    domain.start()
    1.24 +except DomainError, e:
    1.25 +    if verbose:
    1.26 +        print e.extra
    1.27 +    vtpm_cleanup(domain.getName())
    1.28 +    FAIL("Unable to create domain")
    1.29 +
    1.30 +domName = domain.getName()
    1.31 +
    1.32 +try:
    1.33 +    console = XmConsole(domain.getName())
    1.34 +except ConsoleError, e:
    1.35 +    vtpm_cleanup(domName)
    1.36 +    FAIL(str(e))
    1.37 +
    1.38 +try:
    1.39 +    console.sendInput("input")
    1.40 +except ConsoleError, e:
    1.41 +    saveLog(console.getHistory())
    1.42 +    vtpm_cleanup(domName)
    1.43 +    FAIL(str(e))
    1.44 +
    1.45 +try:
    1.46 +    run = console.runCmd("cat /sys/devices/platform/tpm_vtpm/pcrs")
    1.47 +except ConsoleError, e:
    1.48 +    saveLog(console.getHistory())
    1.49 +    vtpm_cleanup(domName)
    1.50 +    FAIL(str(e))
    1.51 +
    1.52 +if re.search("No such file",run["output"]):
    1.53 +    vtpm_cleanup(domName)
    1.54 +    FAIL("TPM frontend support not compiled into (domU?) kernel")
    1.55 +
    1.56 +console.closeConsole()
    1.57 +
    1.58 +old_domid = domid(domName)
    1.59 +
    1.60 +try:
    1.61 +    status, ouptut = traceCommand("xm migrate -l %s localhost" %
    1.62 +                                  domName,
    1.63 +                                  timeout=90)
    1.64 +except TimeoutError, e:
    1.65 +    saveLog(console.getHistory())
    1.66 +    vtpm_cleanup(domName)
    1.67 +    FAIL(str(e))
    1.68 +
    1.69 +if status != 0:
    1.70 +    saveLog(console.getHistory())
    1.71 +    vtpm_cleanup(domName)
    1.72 +    FAIL("xm migrate did not succeed. External device migration activated?")
    1.73 +
    1.74 +
    1.75 +domName = domain.getName()
    1.76 +new_domid = domid(domName)
    1.77 +
    1.78 +if (old_domid == new_domid):
    1.79 +    vtpm_cleanup(domName)
    1.80 +    FAIL("xm migrate failed, domain id is still %s" % old_domid)
    1.81 +
    1.82 +try:
    1.83 +    console = XmConsole(domain.getName())
    1.84 +except ConsoleError, e:
    1.85 +    vtpm_cleanup(domName)
    1.86 +    FAIL(str(e))
    1.87 +
    1.88 +try:
    1.89 +    run = console.runCmd("cat /sys/devices/platform/tpm_vtpm/pcrs")
    1.90 +except ConsoleError, e:
    1.91 +    saveLog(console.getHistory())
    1.92 +    vtpm_cleanup(domName)
    1.93 +    FAIL(str(e))
    1.94 +
    1.95 +console.closeConsole()
    1.96 +
    1.97 +domain.stop()
    1.98 +
    1.99 +vtpm_cleanup(domName)
   1.100 +
   1.101 +if not re.search("PCR-00:",run["output"]):
   1.102 +	FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side")
     2.1 --- a/tools/xm-test/tests/vtpm/Makefile.am	Fri Apr 21 11:54:12 2006 +0100
     2.2 +++ b/tools/xm-test/tests/vtpm/Makefile.am	Fri Apr 21 11:56:40 2006 +0100
     2.3 @@ -2,7 +2,8 @@ SUBDIRS =
     2.4  
     2.5  TESTS = 01_vtpm-list_pos.test \
     2.6          02_vtpm-cat_pcrs.test \
     2.7 -        03_vtpm-susp_res.test
     2.8 +        03_vtpm-susp_res.test \
     2.9 +        04_vtpm-loc_migr.test
    2.10  
    2.11  XFAIL_TESTS =
    2.12