Run qemu in snapshot mode to avoid unpacking
authorEd Bartosh <eduard.bartosh@intel.com>
Sun, 15 Sep 2013 13:01:08 +0000 (16:01 +0300)
committerHasan Wan <hasan.wan@intel.com>
Mon, 16 Sep 2013 06:22:12 +0000 (23:22 -0700)
Snapshot mode allows us to use the same mic-seed in multiple qemu
sessions as changes in snapshot mode go to snapshot. This saves time
and resouces as untarring is not needed anymore.

Change-Id: I5eced1439ea310e8d7cc025e7a8d82c1d221e9fa
Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
Reviewed-on: https://otctools.jf.intel.com/review/6436
Tested-by: OTC Tools Tester <ed.bartosh@linux.intel.com>
Reviewed-by: Hasan Wan <hasan.wan@intel.com>
job_imager.py

index 0c5cc20..dc4e902 100755 (executable)
@@ -27,7 +27,7 @@ def run_inside_vm(vm_image, vm_memory, vm_cpus, basedir):
     for cache and results
     """
     cmd = 'qemu-system-x86_64 -machine accel=kvm:xen:tcg -name opensuse -M pc '\
-          '-m %d -smp %d -vga none -hda %s -nographic -virtfs '\
+          '-m %d -smp %d -vga none -drive file=%s,snapshot=on -nographic -virtfs '\
           'local,id=test_dev,path=%s,security_model=mapped,mount_tag=share' % \
           (vm_memory, vm_cpus, vm_image, basedir)
 
@@ -76,23 +76,14 @@ def main():
 
     if int(os.getenv('USE_VM')):
         vm_image = os.getenv("VM_IMAGE",
-                os.path.join(os.getenv('JENKINS_HOME'), 'mic-seed.tar'))
+                os.path.join(os.getenv('JENKINS_HOME'), 'mic-seed'))
         # check if tarball exists
         if not vm_image or not os.access(vm_image, os.R_OK):
             print 'VM image %s is not found' % vm_image
             return -1
-        # untar it
-        ret = subprocess.call("tar -Sxf %s" % vm_image, stdout=sys.stdout,
-                              stderr=sys.stderr, shell=True)
-
-        # check if image exists
-        unpacked_image = os.path.basename(vm_image).split('.tar')[0]
-        if not os.access(unpacked_image, os.R_OK | os.W_OK):
-            print 'Not enough permissions to run VM image %s' % unpacked_image
-            return -1
 
         print 'starting mic inside VM to create image'
-        ret = run_inside_vm(unpacked_image, os.getenv("VM_MEMORY", 8192),
+        ret = run_inside_vm(vm_image, os.getenv("VM_MEMORY", 8192),
                             os.getenv("VM_CPUS", 8), basedir)
     else:
         log = os.path.join(outdir, '%s_%s.log.txt' % (build_id, name))