source: trunk/packages/xen-3.1/xen-3.1/tools/xm-test/tests/vtpm/07_vtpm-mig_pcrs.py @ 34

Last change on this file since 34 was 34, checked in by hartmans, 18 years ago

Add xen and xen-common

  • Property svn:mime-type set to text/script
File size: 3.7 KB
Line 
1#!/usr/bin/python
2
3# Copyright (C) International Business Machines Corp., 2006
4# Author: Stefan Berger <stefanb@us.ibm.com>
5
6# Positive Test: create domain with virtual TPM attached at build time,
7#                extend a pcr
8#                check list of pcrs; locally migrate the domain and
9#                check list of pcrs again and validate extended pcr
10#                This test does local live migration.
11
12from XmTestLib import *
13from vtpm_utils import *
14import commands
15import os
16import os.path
17
18config = {"vtpm":"instance=1,backend=0"}
19domain = XmTestDomain(extraConfig=config)
20domName = domain.getName()
21consoleHistory = ""
22
23try:
24    console = domain.start()
25except DomainError, e:
26    if verbose:
27        print e.extra
28    vtpm_cleanup(domName)
29    FAIL("Unable to create domain (%s)" % domName)
30
31try:
32    console.sendInput("input")
33except ConsoleError, e:
34    saveLog(console.getHistory())
35    vtpm_cleanup(domName)
36    FAIL(str(e))
37
38try:
39    run = console.runCmd("mknod /dev/tpm0 c 10 224")
40except ConsoleError, e:
41    saveLog(console.getHistory())
42    vtpm_cleanup(domName)
43    FAIL("Error while creating /dev/tpm0")
44
45try:
46    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\" > seq; cat seq > /dev/tpm0")
47except ConsoleError, e:
48    saveLog(console.getHistory())
49    vtpm_cleanup(domName)
50    FAIL("Error while extending PCR 0")
51
52try:
53    run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
54except ConsoleError, e:
55    saveLog(console.getHistory())
56    vtpm_cleanup(domName)
57    FAIL("No result from dumping the PCRs")
58
59
60if re.search("No such file",run["output"]):
61    vtpm_cleanup(domName)
62    FAIL("TPM frontend support not compiled into (domU?) kernel")
63
64if not re.search("PCR-00:",run["output"]):
65    saveLog(console.getHistory())
66    vtpm_cleanup(domName)
67    FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side: \n%s" % run["output"])
68
69if not re.search("PCR-00: 1E A7 BD",run["output"]):
70    saveLog(console.getHistory())
71    FAIL("Extend did not lead to expected result (1E A7 BD ...): \n%s" % run["output"])
72
73consoleHistory = console.getHistory()
74domain.closeConsole()
75
76old_domid = domid(domName)
77
78loop = 0
79while loop < 3:
80    try:
81        status, ouptut = traceCommand("xm migrate -l %s localhost" %
82                                      domName,
83                                      timeout=90)
84    except TimeoutError, e:
85        saveLog(consoleHistory)
86        vtpm_cleanup(domName)
87        FAIL(str(e))
88
89    if status != 0:
90        saveLog(consoleHistory)
91        vtpm_cleanup(domName)
92        FAIL("xm migrate did not succeed. External device migration activated?")
93
94
95    domName = domain.getName()
96    new_domid = domid(domName)
97
98    if (old_domid == new_domid):
99        vtpm_cleanup(domName)
100        FAIL("xm migrate failed, domain id is still %s (loop=%d)" %
101             (old_domid,loop))
102
103    try:
104        console = domain.getConsole()
105    except ConsoleError, e:
106        vtpm_cleanup(domName)
107        FAIL(str(e))
108
109    try:
110        run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
111    except ConsoleError, e:
112        saveLog(console.getHistory())
113        vtpm_cleanup(domName)
114        FAIL("No result from dumping the PCRs")
115
116    if not re.search("PCR-00:",run["output"]):
117        saveLog(console.getHistory())
118        vtpm_cleanup(domName)
119        FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side")
120
121    if not re.search("PCR-00: 1E A7 BD",run["output"]):
122        saveLog(console.getHistory())
123        vtpm_cleanup(domName)
124        FAIL("Virtual TPM lost PCR 0 value: \n%s" % run["output"])
125
126    loop += 1
127
128domain.closeConsole()
129
130domain.stop()
131
132vtpm_cleanup(domName)
Note: See TracBrowser for help on using the repository browser.