Summary: Add a new VirtualPartition class to client/bin/partition.py to handle block device emulation trough image files.
Motivation: Sometimes we can't rely on a particular partitioning schema
of a given test machine to perform filesystem tests (think machines of a
test grid). In order to enable machines with enough free space on their
root partitions to run filesystem tests on "block devices", a
VirtualPartiton class was created.
VirtualPartition handles all the process of:
* Creating a disk image (using dd),
* Attach it to a loopback device (using losetup),
* Creating a single partition on this device (using sfdisk),
* Making the newly created partition available under /dev/mapper
The new device behaves exactly as a disk partition, therefore the code
was put under client/bin/partition.py. We are finding this code useful
to test filesystems transparently even when we don't have a particular
partitioning schema on the target machine. The following control file
exemplifies how to use this new API:
import os
from autotest_lib.client.bin import partition
bonnie_part_size = int(2.5 * 1000 * 1024)
bonnie_file = os.path.join('/tmp', 'bonnie.img')
bonnie_partition = partition.virtual_partition(bonnie_file, bonnie_part_size)
test_device = bonnie_partition.device
mountpoint = os.path.join('/media', 'bonnie')
if not os.path.exists(mountpoint):
os.makedirs(mountpoint)
fs = job.filesystem(test_device, mountpoint)
fs.mkfs('ext4')
fs.mount(mountpoint)
job.run_test('bonnie', dir=mountpoint)
fs.unmount(mountpoint)
bonnie_partition.destroy()
As the logging patch is still not ready (probably coming today or
tomorrow), the class implementation still uses prints. But once we get
logging straightened out, I am going to change this.
Signed-off-by: Lucas Meneghel Rodrigues <lucasmr@br.ibm.com>
Updated version of the patch, adding a sanity check before starting to
create the 'virtual partition'. Martin, let me know if that addresses
your concerns.
git-svn-id: http://test.kernel.org/svn/autotest/trunk@2942 592f7852-d20e-0410-864c-8624ca9c26a4
1 file changed