aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xm-test/tests/block-destroy/02_block-destroy_rtblock_pos.py
blob: 6c87db819851dcf56631a4890dad294c7bfcc957 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/python

# Copyright (C) International Business Machines Corp., 2005
# Author: Dan Smith <danms@us.ibm.com>

from XmTestLib import *

if ENABLE_VMX_SUPPORT:
    SKIP("Block-detach not supported for VMX domains")

domain = XmTestDomain()

try:
    domain.start()
except DomainError, e:
    if verbose:
        print e.extra
    FAIL("Unable to create domain")

status, output = traceCommand("xm block-attach %s phy:/dev/ram0 hda1 w" % domain.getName())
if status != 0:
    FAIL("Failed to attach block device")
    pass

try:
    console = XmConsole(domain.getName())
except ConsoleError, e:
    FAIL(str(e))

try:
    console.sendInput("input")
    run = console.runCmd("cat /proc/partitions | grep hda1")
except ConsoleError, e:
    saveLog(console.getHistory())
    FAIL(str(e))

if run["return"] != 0:
    FAIL("Failed to verify that block dev is attached")

status, output = traceCommand("xm block-detach %s 769" % domain.getName())
if status != 0:
    FAIL("block-detach returned invalid %i != 0" % status)

try:
    run = console.runCmd("cat /proc/partitions | grep hda1")
except ConsoleError, e:
    saveLog(console.getHistory())
    FAIL(str(e))

if run["return"] == 0:
    FAIL("block-detach failed to detach block device")