Add option to cros_vm to create a disposable copy-on-write boot image before launching VM |
||
Issue descriptionFor the tests running on chrome's CI, we re-use the same boot image in between consecutive tests. This allows for filesystem changes made by previous test runs to persist after the VM's been shut down, and occasionally affect future test runs on the same image. Bug 881638 was one instance of this. It's since been fixed, but other similar issues are popping up now and then. It'd be nice if we could reset the boot image to a clean and unmodified state after every test. Copy-on-write images let us do that. You can create one from a backing boot image (ie chromiumos_qemu_image.bin): $ ./build/cros_cache/chrome-sdk/tarballs/amd64-generic+11079.0.0+qemu/usr/bin/qemu-img create -f qcow2 -o backing_file=build/cros_cache/chrome-sdk/tarballs/amd64-generic+11079.0.0+chromiumos_qemu_image.tar.xz/chromiumos_qemu_image.bin cow.img And then that creates cow.img (initially ~200KB), which you can boot from like normal: $ cros_vm --image-path cow.img --image-format qcow2 --start And that boots a normal cros VM, except any filesystem changes you make after it starts up only shows up in cow.img. Consequently, you can throw that file away after the VM shuts down, and chromiumos_qemu_image.bin will remain unchanged and pristine. If achuith/mike are OK with that, I can look into making the change. It should be pretty trivial since we essentially just need to insert a single command at runtime ("qemu-img create ..."), which takes < 1s to run locally.
,
Sep 28
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/chromite/+/243302c3c92c7dd7d982b5c13ce9ca5c5a6aac2a commit 243302c3c92c7dd7d982b5c13ce9ca5c5a6aac2a Author: Ben Pastene <bpastene@chromium.org> Date: Fri Sep 28 02:44:34 2018 cros_vm: Add an option to create and boot from a temporary qcow2 image. This option (which is off by default) will create a temporary boot image. All filesystem writes will be reflected in that image, and when the VM shuts down, the normal boot image will be unaffected. This will be especially useful for Chrome, where we reuse the same VM image across several consecutive test runs. As it is today, after a test is finished and the VM shut down, the boot image retains any changes to the filesystem that the test made. (eg: Any test artifacts that were failed to be cleaned up will persist into the next test run.) With the '--enable-cow' option, all these changes are confined to the temporary qcow2 image, allowing each test to boot into a clean environment each time. BUG= chromium:887753 TEST=`cros_run_vm_test --enable-cow --deploy` and `cros_run_vm_test --deploy` both work as expected locally. Change-Id: I498c647e9a32d8e18552b4fae2283b4df1487ee1 Reviewed-on: https://chromium-review.googlesource.com/1239577 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Ben Pastene <bpastene@chromium.org> Reviewed-by: Achuith Bhandarkar <achuith@chromium.org> [modify] https://crrev.com/243302c3c92c7dd7d982b5c13ce9ca5c5a6aac2a/scripts/cros_vm.py
,
Sep 28
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/9ed482697ef1ba1baaeee47263c9c2a613c299b6 commit 9ed482697ef1ba1baaeee47263c9c2a613c299b6 Author: Ben Pastene <bpastene@chromium.org> Date: Fri Sep 28 17:33:44 2018 Boot from copy-on-write images for cros VM tests. With this, any changes to the filesystem a test makes will only last for as long as the VM is alive. Since we launch+shutdown for every test, this perfectly isolates consecutive tests from one another. No more out-of-disk errors! Bug: 887753 Change-Id: Ifdf4af22e288583135cfe99d363eb3e79045e08d Reviewed-on: https://chromium-review.googlesource.com/1252005 Reviewed-by: John Budorick <jbudorick@chromium.org> Commit-Queue: Ben Pastene <bpastene@chromium.org> Cr-Commit-Position: refs/heads/master@{#595138} [modify] https://crrev.com/9ed482697ef1ba1baaeee47263c9c2a613c299b6/build/chromeos/run_vm_test.py
,
Sep 28
,
Oct 1
After #3, all of chrome's vm tests are guaranteed to run in a clean env |
||
►
Sign in to add a comment |
||
Comment 1 by achuith@chromium.org
, Sep 27