ia64/xen-unstable

view tools/xm-test/tests/security-acm/06_security-acm_dom_block_attach.py @ 14128:2d3ceb082114

xm-test, acm: Use xvda* device name instead of sdb* device inside guest domain.
Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
author kfraser@localhost.localdomain
date Mon Feb 26 09:13:50 2007 +0000 (2007-02-26)
parents 4ecfbf08b449
children 7869f58ff551
line source
1 #!/usr/bin/python
3 # Copyright (C) International Business Machines Corp., 2005
4 # Author: Stefan Berger <stefanb@us.ibm.com>
5 # Based on block-create/01_block_attach_device_pos.py
6 #
7 # Create a domain and attach 2 resources to it. The first resource
8 # should be attacheable, the 2nd one should not be due to the label it has.
10 import re
11 from XmTestLib import *
12 from XmTestLib import block_utils
13 from acm_utils import *
15 testlabel1 = "blue"
16 resource1 = "phy:ram1"
17 resourcelabel1 = "blue"
18 resource2 = "phy:/dev/ram0"
19 resourcelabel2 = "red"
21 if ENABLE_HVM_SUPPORT:
22 SKIP("Block-attach not supported for HVM domains")
24 # Create a domain (default XmTestDomain, with our ramdisk)
25 config = {"access_control":"policy=%s,label=%s" % (testpolicy,testlabel1)}
27 domain = XmTestDomain(extraConfig=config)
29 try:
30 console = domain.start()
31 except DomainError, e:
32 FAIL(str(e))
34 # Attach a console to it
35 try:
36 console.setHistorySaveCmds(value=True)
37 # Run 'ls'
38 run = console.runCmd("ls")
39 except ConsoleError, e:
40 saveLog(console.getHistory())
41 FAIL(str(e))
44 # Explicitly label the 1st resource
45 ACMLabelResource(resource1, resourcelabel1)
46 block_utils.block_attach(domain, resource1, "xvda1")
48 try:
49 run1 = console.runCmd("cat /proc/partitions")
50 except ConsoleError, e:
51 FAIL(str(e))
53 #Explicitly label the 2nd resource
54 ACMLabelResource(resource2, resourcelabel2)
55 #Cannot call block_attach here since we legally may fail the command
56 status, output = traceCommand("xm block-attach %s %s %s w" %
57 (domain.getName(), resource2, "xvda2" ))
59 for i in range(10):
60 if block_utils.get_state(domain, "xvda2") == 4:
61 break
62 time.sleep(1)
64 try:
65 run2 = console.runCmd("cat /proc/partitions")
66 except ConsoleError, e:
67 FAIL(str(e))
69 # Close the console
70 domain.closeConsole()
72 # Stop the domain (nice shutdown)
73 domain.stop()
75 if not re.search("xvda1",run1["output"]):
76 FAIL("Labeled device 'xvda1' is not actually connected to the domU")
78 if not re.search("xvda1",run2["output"]):
79 FAIL("Labeled device 'xbvda1' has disappeared?!")
81 if re.search("xvda2",run2["output"]):
82 FAIL("Labeled device 'xvda2' is connected to the domU but should not be")