ia64/xen-unstable

changeset 9959:bf56c745515f

Abstract block-attach and block-detach calls, and add to that the correct
polling waiting for the device to connect and disconnect.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Sun May 07 13:34:45 2006 +0100 (2006-05-07)
parents 491f3f48704e
children c2c02e425c06
files tools/xm-test/lib/XmTestLib/block_utils.py tools/xm-test/tests/block-create/01_block_attach_device_pos.py tools/xm-test/tests/block-create/02_block_attach_file_device_pos.py tools/xm-test/tests/block-create/04_block_attach_device_repeatedly_pos.py tools/xm-test/tests/block-create/05_block_attach_and_dettach_device_repeatedly_pos.py tools/xm-test/tests/block-create/07_block_attach_baddevice_neg.py tools/xm-test/tests/block-create/08_block_attach_bad_filedevice_neg.py tools/xm-test/tests/block-create/09_block_attach_and_dettach_device_check_data_pos.py tools/xm-test/tests/block-create/10_block_attach_dettach_multiple_devices.py tools/xm-test/tests/block-destroy/01_block-destroy_btblock_pos.py tools/xm-test/tests/block-destroy/02_block-destroy_rtblock_pos.py tools/xm-test/tests/block-destroy/05_block-destroy_byname_pos.py tools/xm-test/tests/block-destroy/06_block-destroy_check_list_pos.py tools/xm-test/tests/block-list/02_block-list_attachbd_pos.py tools/xm-test/tests/block-list/06_block-list_checkremove_pos.py
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tools/xm-test/lib/XmTestLib/block_utils.py	Sun May 07 13:34:45 2006 +0100
     1.3 @@ -0,0 +1,53 @@
     1.4 +#!/usr/bin/python
     1.5 +
     1.6 +# Copyright (c) 2006 XenSource Inc.
     1.7 +# Author: Ewan Mellor <ewan@xensource.com>
     1.8 +
     1.9 +import time
    1.10 +
    1.11 +from XmTestLib import *
    1.12 +
    1.13 +import xen.util.blkif
    1.14 +
    1.15 +
    1.16 +__all__ = [ "block_attach", "block_detach" ]
    1.17 +
    1.18 +
    1.19 +def get_state(domain, devname):
    1.20 +    number = xen.util.blkif.blkdev_name_to_number(devname)
    1.21 +    s, o = traceCommand("xm block-list %s | awk '/^%d/ {print $4}'" %
    1.22 +                        (domain.getName(), number))
    1.23 +    if s != 0:
    1.24 +        FAIL("block-list failed")
    1.25 +    if o == "":
    1.26 +        return 0
    1.27 +    else:
    1.28 +        return int(o)
    1.29 +
    1.30 +
    1.31 +def block_attach(domain, phy, virt):
    1.32 +    status, output = traceCommand("xm block-attach %s %s %s w" %
    1.33 +                                  (domain.getName(), phy, virt))
    1.34 +    if status != 0:
    1.35 +        FAIL("xm block-attach returned invalid %i != 0" % status)
    1.36 +
    1.37 +    for i in range(10):
    1.38 +        if get_state(domain, virt) == 4:
    1.39 +            break
    1.40 +        time.sleep(1)
    1.41 +    else:
    1.42 +        FAIL("block-attach failed: device did not switch to Connected state")
    1.43 +
    1.44 +
    1.45 +def block_detach(domain, virt):
    1.46 +    status, output = traceCommand("xm block-detach %s %s" %
    1.47 +                                  (domain.getName(), virt))
    1.48 +    if status != 0:
    1.49 +        FAIL("xm block-detach returned invalid %i != 0" % status)
    1.50 +
    1.51 +    for i in range(10):
    1.52 +        if get_state(domain, virt) == 0:
    1.53 +            break
    1.54 +        time.sleep(1)
    1.55 +    else:
    1.56 +        FAIL("block-detach failed: device did not disappear")
     2.1 --- a/tools/xm-test/tests/block-create/01_block_attach_device_pos.py	Sat May 06 15:42:12 2006 +0100
     2.2 +++ b/tools/xm-test/tests/block-create/01_block_attach_device_pos.py	Sun May 07 13:34:45 2006 +0100
     2.3 @@ -3,11 +3,10 @@
     2.4  # Copyright (C) International Business Machines Corp., 2005
     2.5  # Author: Murillo F. Bernardes <mfb@br.ibm.com>
     2.6  
     2.7 -import sys
     2.8  import re
     2.9 -import time
    2.10  
    2.11  from XmTestLib import *
    2.12 +from XmTestLib.block_utils import *
    2.13  
    2.14  if ENABLE_HVM_SUPPORT:
    2.15      SKIP("Block-attach not supported for HVM domains")
    2.16 @@ -33,9 +32,7 @@ except ConsoleError, e:
    2.17      FAIL(str(e))
    2.18      
    2.19  
    2.20 -status, output = traceCommand("xm block-attach %s phy:ram1 sdb1 w" % domain.getName())
    2.21 -if status != 0:
    2.22 -        FAIL("xm block-attach returned invalid %i != 0" % status)
    2.23 +block_attach(domain, "phy:ram1", "sdb1")
    2.24  
    2.25  try:	
    2.26  	run = console.runCmd("cat /proc/partitions")
     3.1 --- a/tools/xm-test/tests/block-create/02_block_attach_file_device_pos.py	Sat May 06 15:42:12 2006 +0100
     3.2 +++ b/tools/xm-test/tests/block-create/02_block_attach_file_device_pos.py	Sun May 07 13:34:45 2006 +0100
     3.3 @@ -3,11 +3,10 @@
     3.4  # Copyright (C) International Business Machines Corp., 2005
     3.5  # Author: Murillo F. Bernardes <mfb@br.ibm.com>
     3.6  
     3.7 -import sys
     3.8  import re
     3.9 -import time
    3.10  
    3.11  from XmTestLib import *
    3.12 +from XmTestLib.block_utils import *
    3.13  
    3.14  if ENABLE_HVM_SUPPORT:
    3.15      SKIP("Block-attach not supported for HVM domains")
    3.16 @@ -33,9 +32,7 @@ except ConsoleError, e:
    3.17      FAIL(str(e))
    3.18      
    3.19  
    3.20 -status, output = traceCommand("xm block-attach %s file:/dev/ram1 sdb2 w" % domain.getName())
    3.21 -if status != 0:
    3.22 -        FAIL("xm block-attach returned invalid %i != 0" % status)
    3.23 +block_attach(domain, "file:/dev/ram1", "sdb2")
    3.24  
    3.25  try:
    3.26  	run = console.runCmd("cat /proc/partitions")
     4.1 --- a/tools/xm-test/tests/block-create/04_block_attach_device_repeatedly_pos.py	Sat May 06 15:42:12 2006 +0100
     4.2 +++ b/tools/xm-test/tests/block-create/04_block_attach_device_repeatedly_pos.py	Sun May 07 13:34:45 2006 +0100
     4.3 @@ -3,9 +3,7 @@
     4.4  # Copyright (C) International Business Machines Corp., 2005
     4.5  # Author: Murillo F. Bernardes <mfb@br.ibm.com>
     4.6  
     4.7 -import sys
     4.8  import re
     4.9 -import time
    4.10  
    4.11  from XmTestLib import *
    4.12  
     5.1 --- a/tools/xm-test/tests/block-create/05_block_attach_and_dettach_device_repeatedly_pos.py	Sat May 06 15:42:12 2006 +0100
     5.2 +++ b/tools/xm-test/tests/block-create/05_block_attach_and_dettach_device_repeatedly_pos.py	Sun May 07 13:34:45 2006 +0100
     5.3 @@ -3,11 +3,10 @@
     5.4  # Copyright (C) International Business Machines Corp., 2005
     5.5  # Author: Murillo F. Bernardes <mfb@br.ibm.com>
     5.6  
     5.7 -import sys
     5.8  import re
     5.9 -import time
    5.10  
    5.11  from XmTestLib import *
    5.12 +from XmTestLib.block_utils import *
    5.13  
    5.14  if ENABLE_HVM_SUPPORT:
    5.15      SKIP("Block-attach not supported for HVM domains")
    5.16 @@ -33,18 +32,12 @@ except ConsoleError, e:
    5.17      
    5.18  
    5.19  for i in range(10):
    5.20 -	status, output = traceCommand("xm block-attach %s phy:ram1 sdb1 w" % domain.getName())
    5.21 -	if status != 0:
    5.22 -        	FAIL("xm block-attach returned invalid %i != 0" % status)
    5.23 -	# verify that it comes
    5.24 +	block_attach(domain, "phy:ram1", "sdb1")
    5.25  	run = console.runCmd("cat /proc/partitions")
    5.26  	if not re.search("sdb1", run["output"]):
    5.27  		FAIL("Failed to attach block device: /proc/partitions does not show that!")
    5.28  		
    5.29 -	status, output = traceCommand("xm block-detach %s 2065" % domain.getName())
    5.30 -	if status != 0:
    5.31 -		FAIL("xm block-detach returned invalid %i != 0" % status)
    5.32 -	# verify that it goes
    5.33 +	block_detach(domain, "sdb1")
    5.34  	run = console.runCmd("cat /proc/partitions")
    5.35  	if re.search("sdb1", run["output"]):
    5.36  		FAIL("Failed to dettach block device: /proc/partitions still showing that!")
     6.1 --- a/tools/xm-test/tests/block-create/07_block_attach_baddevice_neg.py	Sat May 06 15:42:12 2006 +0100
     6.2 +++ b/tools/xm-test/tests/block-create/07_block_attach_baddevice_neg.py	Sun May 07 13:34:45 2006 +0100
     6.3 @@ -3,9 +3,7 @@
     6.4  # Copyright (C) International Business Machines Corp., 2005
     6.5  # Author: Murillo F. Bernardes <mfb@br.ibm.com>
     6.6  
     6.7 -import sys
     6.8  import re
     6.9 -import time
    6.10  
    6.11  from XmTestLib import *
    6.12  
     7.1 --- a/tools/xm-test/tests/block-create/08_block_attach_bad_filedevice_neg.py	Sat May 06 15:42:12 2006 +0100
     7.2 +++ b/tools/xm-test/tests/block-create/08_block_attach_bad_filedevice_neg.py	Sun May 07 13:34:45 2006 +0100
     7.3 @@ -3,9 +3,7 @@
     7.4  # Copyright (C) International Business Machines Corp., 2005
     7.5  # Author: Murillo F. Bernardes <mfb@br.ibm.com>
     7.6  
     7.7 -import sys
     7.8  import re
     7.9 -import time
    7.10  
    7.11  from XmTestLib import *
    7.12  
     8.1 --- a/tools/xm-test/tests/block-create/09_block_attach_and_dettach_device_check_data_pos.py	Sat May 06 15:42:12 2006 +0100
     8.2 +++ b/tools/xm-test/tests/block-create/09_block_attach_and_dettach_device_check_data_pos.py	Sun May 07 13:34:45 2006 +0100
     8.3 @@ -3,11 +3,10 @@
     8.4  # Copyright (C) International Business Machines Corp., 2005
     8.5  # Author: Murillo F. Bernardes <mfb@br.ibm.com>
     8.6  
     8.7 -import sys
     8.8  import re
     8.9 -import time
    8.10  
    8.11  from XmTestLib import *
    8.12 +from XmTestLib.block_utils import *
    8.13  
    8.14  if ENABLE_HVM_SUPPORT:
    8.15      SKIP("Block-attach not supported for HVM domains")
    8.16 @@ -36,10 +35,7 @@ if s != 0:
    8.17      FAIL("mke2fs returned %i != 0" % s)
    8.18  
    8.19  for i in range(10):
    8.20 -	status, output = traceCommand("xm block-attach %s phy:ram1 hda1 w" % domain.getName())
    8.21 -	if status != 0:
    8.22 -        	FAIL("xm block-attach returned invalid %i != 0" % status)
    8.23 -	# verify that it comes
    8.24 +	block_attach(domain, "phy:ram1", "hda1")
    8.25  	run = console.runCmd("cat /proc/partitions")
    8.26  	if not re.search("hda1", run["output"]):
    8.27  		FAIL("Failed to attach block device: /proc/partitions does not show that!")
    8.28 @@ -56,10 +52,7 @@ for i in range(10):
    8.29  	print run['output']
    8.30  	console.runCmd("umount /mnt/hda1")
    8.31  	
    8.32 -	status, output = traceCommand("xm block-detach %s 769" % domain.getName())
    8.33 -	if status != 0:
    8.34 -		FAIL("xm block-detach returned invalid %i != 0" % status)
    8.35 -	# verify that it goes
    8.36 +	block_detach(domain, "hda1")
    8.37  	run = console.runCmd("cat /proc/partitions")
    8.38  	if re.search("hda1", run["output"]):
    8.39  		FAIL("Failed to dettach block device: /proc/partitions still showing that!")
     9.1 --- a/tools/xm-test/tests/block-create/10_block_attach_dettach_multiple_devices.py	Sat May 06 15:42:12 2006 +0100
     9.2 +++ b/tools/xm-test/tests/block-create/10_block_attach_dettach_multiple_devices.py	Sun May 07 13:34:45 2006 +0100
     9.3 @@ -3,15 +3,14 @@
     9.4  # Copyright (C) International Business Machines Corp., 2005
     9.5  # Author: Murillo F. Bernardes <mfb@br.ibm.com>
     9.6  
     9.7 -import sys
     9.8  import re
     9.9 -import time
    9.10  import random
    9.11  from xen.util import blkif
    9.12  
    9.13  from os import path.basename
    9.14  
    9.15  from XmTestLib import *
    9.16 +from XmTestLib.block_utils import *
    9.17  
    9.18  def availableRamdisks():
    9.19      i = 0
    9.20 @@ -21,11 +20,7 @@ def availableRamdisks():
    9.21      return i
    9.22  
    9.23  def attach(phy, devname):
    9.24 -    # Attach 
    9.25 -    status, output = traceCommand("xm block-attach %s phy:%s %s w" % (domain.getName(), phy, devname))
    9.26 -    if status != 0:
    9.27 -    	return -1, "xm block-attach returned invalid %i != 0" % status
    9.28 -	
    9.29 +    block_attach(domain, "phy:%s" % phy, devname)
    9.30      run = console.runCmd("cat /proc/partitions")
    9.31      if not re.search(basename(devname), run["output"]):
    9.32          return -2, "Failed to attach block device: /proc/partitions does not show that!"
    9.33 @@ -33,16 +28,12 @@ def attach(phy, devname):
    9.34      return 0, None
    9.35  
    9.36  
    9.37 -def dettach(devname):
    9.38 -    devnum = blkif.blkdev_name_to_number(devname)
    9.39 -    
    9.40 -    status, output = traceCommand("xm block-detach %s %d" % (domain.getName(), devnum))
    9.41 -    if status != 0:
    9.42 -        return -1, "xm block-attach returned invalid %i != 0" % status
    9.43 +def detach(devname):
    9.44 +    block_detach(domain, devname)
    9.45  
    9.46      run = console.runCmd("cat /proc/partitions")
    9.47      if re.search(basename(devname), run["output"]):
    9.48 -        return -2, "Failed to dettach block device: /proc/partitions still showing that!"
    9.49 +        return -2, "Failed to detach block device: /proc/partitions still showing that!"
    9.50  
    9.51      return 0, None
    9.52  	
    9.53 @@ -91,7 +82,7 @@ while i < ramdisks or devices:
    9.54          devname = random.choice(devices)
    9.55  	devices.remove(devname)
    9.56  	print "Detaching %s" % devname
    9.57 -	status, msg = dettach(devname)
    9.58 +	status, msg = detach(devname)
    9.59  	if status:
    9.60  	    FAIL(msg)
    9.61  
    10.1 --- a/tools/xm-test/tests/block-destroy/01_block-destroy_btblock_pos.py	Sat May 06 15:42:12 2006 +0100
    10.2 +++ b/tools/xm-test/tests/block-destroy/01_block-destroy_btblock_pos.py	Sun May 07 13:34:45 2006 +0100
    10.3 @@ -4,6 +4,7 @@
    10.4  # Author: Dan Smith <danms@us.ibm.com>
    10.5  
    10.6  from XmTestLib import *
    10.7 +from XmTestLib.block_utils import block_detach
    10.8  
    10.9  if ENABLE_HVM_SUPPORT:
   10.10      SKIP("Block-detach not supported for HVM domains")
   10.11 @@ -28,11 +29,7 @@ except ConsoleError, e:
   10.12  if run["return"] != 0:
   10.13      FAIL("block device isn't attached; can't detach!")
   10.14  
   10.15 -status, output = traceCommand("xm block-detach %s 769" % domain.getName(),
   10.16 -                              logOutput=True)
   10.17 -if status != 0:
   10.18 -    FAIL("block-detach returned invalid %i != 0" % status)
   10.19 -
   10.20 +block_detach(domain, "hda1")
   10.21  try:
   10.22  
   10.23      run = console.runCmd("cat /proc/partitions | grep hda1")
    11.1 --- a/tools/xm-test/tests/block-destroy/02_block-destroy_rtblock_pos.py	Sat May 06 15:42:12 2006 +0100
    11.2 +++ b/tools/xm-test/tests/block-destroy/02_block-destroy_rtblock_pos.py	Sun May 07 13:34:45 2006 +0100
    11.3 @@ -4,6 +4,7 @@
    11.4  # Author: Dan Smith <danms@us.ibm.com>
    11.5  
    11.6  from XmTestLib import *
    11.7 +from XmTestLib.block_utils import *
    11.8  
    11.9  if ENABLE_HVM_SUPPORT:
   11.10      SKIP("Block-detach not supported for HVM domains")
   11.11 @@ -17,11 +18,7 @@ except DomainError, e:
   11.12          print e.extra
   11.13      FAIL("Unable to create domain")
   11.14  
   11.15 -status, output = traceCommand("xm block-attach %s phy:/dev/ram0 hda1 w" % domain.getName())
   11.16 -if status != 0:
   11.17 -    FAIL("Failed to attach block device")
   11.18 -    pass
   11.19 -
   11.20 +block_attach(domain, "phy:/dev/ram0", "hda1")
   11.21  try:
   11.22      run = console.runCmd("cat /proc/partitions | grep hda1")
   11.23  except ConsoleError, e:
   11.24 @@ -31,10 +28,7 @@ except ConsoleError, e:
   11.25  if run["return"] != 0:
   11.26      FAIL("Failed to verify that block dev is attached")
   11.27  
   11.28 -status, output = traceCommand("xm block-detach %s 769" % domain.getName())
   11.29 -if status != 0:
   11.30 -    FAIL("block-detach returned invalid %i != 0" % status)
   11.31 -
   11.32 +block_detach(domain, "hda1")
   11.33  try:
   11.34      run = console.runCmd("cat /proc/partitions | grep hda1")
   11.35  except ConsoleError, e:
    12.1 --- a/tools/xm-test/tests/block-destroy/05_block-destroy_byname_pos.py	Sat May 06 15:42:12 2006 +0100
    12.2 +++ b/tools/xm-test/tests/block-destroy/05_block-destroy_byname_pos.py	Sun May 07 13:34:45 2006 +0100
    12.3 @@ -4,6 +4,7 @@
    12.4  # Author: Dan Smith <danms@us.ibm.com>
    12.5  
    12.6  from XmTestLib import *
    12.7 +from XmTestLib.block_utils import block_detach
    12.8  
    12.9  if ENABLE_HVM_SUPPORT:
   12.10      SKIP("Block-detach not supported for HVM domains")
   12.11 @@ -27,11 +28,7 @@ except ConsoleError, e:
   12.12  if run["return"] != 0:
   12.13      FAIL("block device isn't attached; can't detach!")
   12.14  
   12.15 -status, output = traceCommand("xm block-detach %s hda1" % domain.getName(),
   12.16 -                              logOutput=True)
   12.17 -if status != 0:
   12.18 -    FAIL("block-detach returned invalid %i != 0" % status)
   12.19 -
   12.20 +block_detach(domain, "hda1")
   12.21  try:
   12.22  
   12.23      run = console.runCmd("cat /proc/partitions | grep hda1")
    13.1 --- a/tools/xm-test/tests/block-destroy/06_block-destroy_check_list_pos.py	Sat May 06 15:42:12 2006 +0100
    13.2 +++ b/tools/xm-test/tests/block-destroy/06_block-destroy_check_list_pos.py	Sun May 07 13:34:45 2006 +0100
    13.3 @@ -4,18 +4,9 @@
    13.4  # Author: Dan Smith <danms@us.ibm.com>
    13.5  
    13.6  from XmTestLib import *
    13.7 -
    13.8 -import time
    13.9 -import re
   13.10 +from XmTestLib.block_utils import *
   13.11  
   13.12 -def checkBlockList(domain):
   13.13 -    s, o = traceCommand("xm block-list %s" % domain.getName())
   13.14 -    if s != 0:
   13.15 -        FAIL("block-list failed")
   13.16 -    if re.search("769", o):
   13.17 -        return True
   13.18 -    else:
   13.19 -        return False
   13.20 +import re
   13.21  
   13.22  def checkXmLongList(domain):
   13.23      s, o = traceCommand("xm list --long %s" % domain.getName())
   13.24 @@ -26,12 +17,6 @@ def checkXmLongList(domain):
   13.25      else:
   13.26          return False
   13.27  
   13.28 -def checkBlockState(domain):
   13.29 -    s, o = traceCommand("xm block-list %s | awk '{print $4}' |tail -n 1" % domain.getName())
   13.30 -    if s != 0:
   13.31 -        FAIL("block-list failed")
   13.32 -    return int(o)
   13.33 -
   13.34  if ENABLE_HVM_SUPPORT:
   13.35      SKIP("Block-detach not supported for HVM domains")
   13.36  
   13.37 @@ -42,32 +27,12 @@ try:
   13.38  except DomainError,e:
   13.39      FAIL(str(e))
   13.40  
   13.41 -s, o = traceCommand("xm block-attach %s phy:/dev/ram0 hda1 w" % domain.getName())
   13.42 -if s != 0:
   13.43 -    FAIL("block-attach failed")
   13.44 -
   13.45 -if not checkBlockList(domain):
   13.46 -    FAIL("block-list does not show that hda1 was attached")
   13.47 +block_attach(domain, "phy:/dev/ram0", "hda1")
   13.48  
   13.49  if not checkXmLongList(domain):
   13.50      FAIL("xm long list does not show that hda1 was attached")
   13.51  
   13.52 -for i in range(1, 10):
   13.53 -    time.sleep(1)
   13.54 -    state = checkBlockState(domain)
   13.55 -    if state == 4:
   13.56 -        break
   13.57 -
   13.58 -s, o = traceCommand("xm block-detach %s hda1" % domain.getName())
   13.59 -if s != 0:
   13.60 -    FAIL("block-detach failed")
   13.61 -
   13.62 -time.sleep(2)
   13.63 -
   13.64 -if checkBlockList(domain):
   13.65 -    FAIL("block-list does not show that hda1 was removed")
   13.66 +block_detach(domain, "hda1")
   13.67  
   13.68  if checkXmLongList(domain):
   13.69      FAIL("xm long list does not show that hda1 was removed")
   13.70 -
   13.71 -
    14.1 --- a/tools/xm-test/tests/block-list/02_block-list_attachbd_pos.py	Sat May 06 15:42:12 2006 +0100
    14.2 +++ b/tools/xm-test/tests/block-list/02_block-list_attachbd_pos.py	Sun May 07 13:34:45 2006 +0100
    14.3 @@ -1,5 +1,5 @@
    14.4  #!/usr/bin/python
    14.5 -                                                                                              
    14.6 +
    14.7  # Copyright (C) International Business Machines Corp., 2005
    14.8  # Author: Li Ge <lge@us.ibm.com)
    14.9  
   14.10 @@ -7,12 +7,13 @@
   14.11  
   14.12  
   14.13  from XmTestLib import *
   14.14 +from XmTestLib.block_utils import block_attach
   14.15  
   14.16  if ENABLE_HVM_SUPPORT:
   14.17      SKIP("Block-list not supported for HVM domains")
   14.18  
   14.19  domain = XmTestDomain()
   14.20 -                                                                                              
   14.21 +
   14.22  try:
   14.23      console = domain.start()
   14.24  except DomainError, e:
   14.25 @@ -21,9 +22,7 @@ except DomainError, e:
   14.26      FAIL("Unable to create domain")
   14.27  
   14.28  #Attach one virtual block device to domainU
   14.29 -status, output = traceCommand("xm block-attach %s phy:/dev/ram0 hda1 w" % domain.getId())
   14.30 -if status != 0:
   14.31 -    FAIL("Fail to attach block device")
   14.32 +block_attach(domain, "phy:/dev/ram0", "hda1")
   14.33  
   14.34  #Verify block-list on Domain0
   14.35  status, output = traceCommand("xm block-list %s" % domain.getId())
    15.1 --- a/tools/xm-test/tests/block-list/06_block-list_checkremove_pos.py	Sat May 06 15:42:12 2006 +0100
    15.2 +++ b/tools/xm-test/tests/block-list/06_block-list_checkremove_pos.py	Sun May 07 13:34:45 2006 +0100
    15.3 @@ -4,6 +4,7 @@
    15.4  # Author: Dan Smith <danms@us.ibm.com>
    15.5  
    15.6  from XmTestLib import *
    15.7 +from XmTestLib.block_utils import *
    15.8  
    15.9  if ENABLE_HVM_SUPPORT:
   15.10      SKIP("Block-list not supported for HVM domains")
   15.11 @@ -21,9 +22,7 @@ if s != 0:
   15.12  if o:
   15.13      FAIL("block-list without devices reported something!")
   15.14  
   15.15 -s, o = traceCommand("xm block-attach %s phy:/dev/ram0 hda1 w" % domain.getName())
   15.16 -if s != 0:
   15.17 -    FAIL("Unable to attach /dev/ram0->hda1")
   15.18 +block_attach(domain, "phy:/dev/ram0", "hda1")
   15.19  
   15.20  s, o = traceCommand("xm block-list %s" % domain.getName())
   15.21  if s != 0:
   15.22 @@ -31,9 +30,7 @@ if s != 0:
   15.23  if o.find("769") == -1:
   15.24      FAIL("block-list didn't show the block device I just attached!")
   15.25  
   15.26 -s, o = traceCommand("xm block-attach %s phy:/dev/ram1 hda2 w" % domain.getName())
   15.27 -if s != 0:
   15.28 -    FAIL("Unable to attach /dev/ram1->hda2")
   15.29 +block_attach(domain, "phy:/dev/ram1", "hda2")
   15.30  
   15.31  s, o = traceCommand("xm block-list %s" % domain.getName())
   15.32  if s != 0:
   15.33 @@ -41,11 +38,8 @@ if s != 0:
   15.34  if o.find("770") == -1:
   15.35      FAIL("block-list didn't show the other block device I just attached!")
   15.36  
   15.37 -s, o = traceCommand("xm block-detach %s 769" % domain.getName())
   15.38 -if s != 0:
   15.39 -    FAIL("block-detach of hda1 failed")
   15.40 +block_detach(domain, "hda1")
   15.41  
   15.42 -time.sleep(1)
   15.43  s, o = traceCommand("xm block-list %s" % domain.getName())
   15.44  if s != 0:
   15.45      FAIL("block-list failed after detaching a device")
   15.46 @@ -54,11 +48,8 @@ if o.find("769") != -1:
   15.47  if o.find("770") == -1:
   15.48      FAIL("hda2 not shown after detach of hda1!")
   15.49  
   15.50 -s, o = traceCommand("xm block-detach %s 770" % domain.getName())
   15.51 -if s != 0:
   15.52 -    FAIL("block-detach of hda2 failed")
   15.53 +block_detach(domain, "hda2")
   15.54  
   15.55 -time.sleep(1)
   15.56  s, o = traceCommand("xm block-list %s" % domain.getName())
   15.57  if s != 0:
   15.58      FAIL("block-list failed after detaching another device")