Updated run_emulator.sh to add 'convert-disk'. ** Description changed:
Being able to create a snapshot and roll back to it is very useful for developers. Eg, developers can - * develop features, etc on the image, then package them up, roll back the image and test on a pristine image - * save time on system-image upgrade testing - * do multiple test runs, reverting to the pristine image between runs to cut down on variances - * verify bugs in the image easily - * etc + * develop features, etc on the image, then package them up, roll back the image and test on a pristine image + * save time on system-image upgrade testing + * do multiple test runs, reverting to the pristine image between runs to cut down on variances + * verify bugs in the image easily + * etc Snapshotting can be complicated, but most of the time you just want to have a pristine snapshot that you can rollback to with the option of committing changes. Attached is an updated run-emulator.sh script to achieve this: $ ./run-emulator.sh help Usage: run-emulator.sh - run-emulator.sh [COMMAND] + run-emulator.sh [COMMAND] Commands: - use-disk-snapshots Convert images to qcow2 and create 'pristine' snapshot - snapshot-disks Update 'pristine' snapshot to current state - revert-disks Revert current images to 'pristine' snapshot - info-disks Show disk information for current images + use-disk-snapshots Convert images to qcow2 and create 'pristine' snapshot + convert-disk DISK Convert DISK to qcow2 and create 'pristine' snapshot + snapshot-disks Update 'pristine' snapshot to current state + revert-disks Revert current images to 'pristine' snapshot + info-disks Show disk information for current images Without arguments, run the emulated image. Note: these commands only manipulate the qemu qcow2 disk images and are - unrelated to the -snapshot* and -no-snapshot* emulator command line - options + unrelated to the -snapshot* and -no-snapshot* emulator command line + options Basic workflow is: $ ./build-emulator-sdcard.sh # create image like normal, skip if already have image $ ./run-emulator.sh use-disk-snapshots $ ./run-emulator.sh <do work> $ ./run-emulator.sh revert-disks $ ./run-emulator.sh <perform tests in pristine environment> $ ./run-emulator.sh revert-disks Once system-image is supported, can update the image like so: $ ./run-emulator.sh revert-disks $ ./run-emulator.sh <run system-image> $ ./run-emulator.sh snapshot-disks The emulator is based on qemu 0.12 and the default disk compatibility option for qcow2 images is 0.10 (though I explicitly use compat=0.10 in the script). The script continues to run as before with raw images and snapshotting is only usable after running 'use-disk-snapshots'. When using this command to run-emulator.sh, disks specified with '-system', 'data', '-cache' and '-sdcard' are all converted to qcow2 and updated to - have a 'pristine' snapshot. + have a 'pristine' snapshot. 'convert-disk DISK' can be used to convert a + single disk, which might be useful when rerunning build-emulator- + sdcard.sh. Note that this script only deals with the disk files themselves and adds a dependency on qemu-utils. It does not require advanced functionality with the emulator and is lightly tested. The emulator itself has other snapshot commands that might be interesting to expose to users (eg, /usr/share/android/emulator/out/host/linux-x86/bin/emulator -help|grep snap). This page could provide inspiration for further enhancements: http://stackoverflow.com/questions/4842612/how-do-you-save-android- emulator-snapshot/5980578#5980578. I believe the above simple disk commands are complementary to the emulator snapshot commands and possibly more desirable for the simple use cases I outlined above. Feel free to adjust as desired. ** Attachment added: "run-emulator_v2.sh" https://bugs.launchpad.net/ubuntu/+source/android/+bug/1253802/+attachment/3915076/+files/run-emulator_v2.sh -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1253802 Title: support disk snapshots with emulator To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/android/+bug/1253802/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs