direct-io.hg

changeset 7705:b0b854126410

This patch adds a new test that attempts to save and restore a domain
with a block device attached. It starts up a domain, mounts a block
device, writes data to it, saves, restores, and then verifies that the
block device can still be read.

Signed-off-by: Dan Smith <danms@us.ibm.com>
author emellor@leeni.uk.xensource.com
date Wed Nov 09 12:39:05 2005 +0100 (2005-11-09)
parents 003339f0fcb2
children 1e6147db55cf
files tools/xm-test/tests/restore/04_restore_withdevices_pos.py tools/xm-test/tests/restore/Makefile.am
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tools/xm-test/tests/restore/04_restore_withdevices_pos.py	Wed Nov 09 12:39:05 2005 +0100
     1.3 @@ -0,0 +1,72 @@
     1.4 +#!/usr/bin/python
     1.5 +
     1.6 +# Copyright (C) International Business Machines Corp., 2005
     1.7 +# Author: Dan Smith <danms@us.ibm.com>
     1.8 +
     1.9 +from XmTestLib import *
    1.10 +
    1.11 +domain = XmTestDomain()
    1.12 +
    1.13 +domain.configAddDisk("phy:/dev/ram0", "hda1", "w")
    1.14 +
    1.15 +s, o = traceCommand("mkfs /dev/ram0")
    1.16 +if s != 0:
    1.17 +    FAIL("Unable to mkfs /dev/ram0 in dom0")
    1.18 +
    1.19 +try:
    1.20 +    domain.start()
    1.21 +except DomainError, e:
    1.22 +    FAIL(str(e))
    1.23 +
    1.24 +try:
    1.25 +    console = XmConsole(domain.getName())
    1.26 +    console.sendInput("foo")
    1.27 +
    1.28 +    run = console.runCmd("mount /dev/hda1 /mnt")
    1.29 +    if run["return"] != 0:
    1.30 +        FAIL("Unable to mount /dev/hda1")
    1.31 +
    1.32 +    run = console.runCmd("echo bar > /mnt/foo")
    1.33 +    if run["return"] != 0:
    1.34 +        FAIL("Unable to write to block device!")
    1.35 +
    1.36 +except ConsoleError, e:
    1.37 +    FAIL(str(e))
    1.38 +
    1.39 +console.closeConsole()
    1.40 +
    1.41 +try:
    1.42 +    s, o = traceCommand("xm save %s /tmp/test.state" % domain.getName(),
    1.43 +                        timeout=30)
    1.44 +except TimeoutError, e:
    1.45 +    FAIL(str(e))
    1.46 +
    1.47 +if s != 0:
    1.48 +    FAIL("xm save exited with %i != 0" % s)
    1.49 +
    1.50 +# Let things settle
    1.51 +time.sleep(15)
    1.52 +
    1.53 +try:
    1.54 +    s, o = traceCommand("xm restore /tmp/test.state",
    1.55 +                        timeout=30)
    1.56 +except TimeoutError, e:
    1.57 +    FAIL(str(e))
    1.58 +
    1.59 +if s != 0:
    1.60 +    FAIL("xm restore exited with %i != 0" % s)
    1.61 +
    1.62 +try:
    1.63 +    console = XmConsole(domain.getName())
    1.64 +
    1.65 +    run = console.runCmd("ls | grep proc")
    1.66 +    if run["return"] != 0:
    1.67 +        FAIL("ls failed on restored domain")
    1.68 +    
    1.69 +    run = console.runCmd("cat /mnt/foo | grep bar")
    1.70 +    if run["return"] != 0:
    1.71 +        FAIL("Unable to read from block device")
    1.72 +
    1.73 +except ConsoleError, e:
    1.74 +    FAIL(str(e))
    1.75 +        
     2.1 --- a/tools/xm-test/tests/restore/Makefile.am	Wed Nov 09 12:38:46 2005 +0100
     2.2 +++ b/tools/xm-test/tests/restore/Makefile.am	Wed Nov 09 12:39:05 2005 +0100
     2.3 @@ -2,7 +2,8 @@ SUBDIRS =
     2.4  
     2.5  TESTS = 01_restore_basic_pos.test \
     2.6  	02_restore_badparm_neg.test \
     2.7 -	03_restore_badfilename_neg.test
     2.8 +	03_restore_badfilename_neg.test \
     2.9 +	04_restore_withdevices_pos.test
    2.10  
    2.11  XFAIL_TESTS = 
    2.12