diff options
author | Ot ten Thije <ottenthije@google.com> | 2010-10-05 17:53:30 +0100 |
---|---|---|
committer | Ot ten Thije <ottenthije@google.com> | 2010-10-22 11:18:47 +0100 |
commit | 353b3b1135563e2bcaf7797acfa35a2fe2d3a818 (patch) | |
tree | 49f495ea08d718709426f03205726bfdc957aa57 /android/main.c | |
parent | 6133adcd101e17118354e64771c52355dbafb1d7 (diff) | |
download | external_qemu-353b3b1135563e2bcaf7797acfa35a2fe2d3a818.zip external_qemu-353b3b1135563e2bcaf7797acfa35a2fe2d3a818.tar.gz external_qemu-353b3b1135563e2bcaf7797acfa35a2fe2d3a818.tar.bz2 |
Load state snapshot rather than booting to start emulator.
This patch adds support for an optional file "snapshots.img" in the
data directory of an AVD. This file should be an image formatted with
the qcow2 file system and will be mounted on -hdb when the emulator
starts up. If present, the emulator will attempt to load the snapshot
named "default-boot" from this image, rather than going through the
full boot procedure.
To control the behaviour of this functionality, this patch introduces
the following new command line options for the emulator:
-snapstorage <file>: override the default location of the
snapshot storage file.
-no-snapstorage: do not load the snapshots file, even if an explicit
path is given.
-snapshot <name>: instead of loading "default-boot", load the state
snapshot with the given name.
-no-snapshot: do not load a snapshot, but force a full boot
sequence, even if a snapshots file is mounted. Useful for
creating snapshots.
Note that this functionality is experimental and will be enabled
only if the constant CONFIG_ANDROID_SNAPSHOTS in
android/config/config.h is set to "1" before building. It is turned
off by default.
Change-Id: Iee2e9096a27f3414bacfc271f90ef93a98730c82
Diffstat (limited to 'android/main.c')
-rw-r--r-- | android/main.c | 61 |
1 files changed, 55 insertions, 6 deletions
diff --git a/android/main.c b/android/main.c index b88fb5e..a328ad1 100644 --- a/android/main.c +++ b/android/main.c @@ -998,6 +998,16 @@ int main(int argc, char **argv) D("autoconfig: -sdcard %s", opts->sdcard); } } + +#if CONFIG_ANDROID_SNAPSHOTS + if (!opts->snapstorage && opts->datadir) { + bufprint(tmp, tmpend, "%s/snapshots.img", opts->datadir); + if (path_exists(tmp)) { + opts->snapstorage = qemu_strdup(tmp); + D("autoconfig: -snapstorage %s", opts->snapstorage); + } + } +#endif } /* setup the virtual device parameters from our options @@ -1008,16 +1018,24 @@ int main(int argc, char **argv) if (opts->wipe_data) { android_avdParams->flags |= AVDINFO_WIPE_DATA | AVDINFO_WIPE_CACHE; } +#if CONFIG_ANDROID_SNAPSHOTS + if (opts->no_snapstorage) { + android_avdParams->flags |= AVDINFO_NO_SNAPSHOTS; + } +#endif /* if certain options are set, we can force the path of * certain kernel/disk image files */ - _forceAvdImagePath(AVD_IMAGE_KERNEL, opts->kernel, "kernel", 1); - _forceAvdImagePath(AVD_IMAGE_INITSYSTEM, opts->system, "system", 1); - _forceAvdImagePath(AVD_IMAGE_RAMDISK, opts->ramdisk,"ramdisk", 1); - _forceAvdImagePath(AVD_IMAGE_USERDATA, opts->data, "user data", 0); - _forceAvdImagePath(AVD_IMAGE_CACHE, opts->cache, "cache", 0); - _forceAvdImagePath(AVD_IMAGE_SDCARD, opts->sdcard, "SD Card", 0); + _forceAvdImagePath(AVD_IMAGE_KERNEL, opts->kernel, "kernel", 1); + _forceAvdImagePath(AVD_IMAGE_INITSYSTEM, opts->system, "system", 1); + _forceAvdImagePath(AVD_IMAGE_RAMDISK, opts->ramdisk, "ramdisk", 1); + _forceAvdImagePath(AVD_IMAGE_USERDATA, opts->data, "user data", 0); + _forceAvdImagePath(AVD_IMAGE_CACHE, opts->cache, "cache", 0); + _forceAvdImagePath(AVD_IMAGE_SDCARD, opts->sdcard, "SD Card", 0); +#if CONFIG_ANDROID_SNAPSHOTS + _forceAvdImagePath(AVD_IMAGE_SNAPSHOTS, opts->snapstorage, "snapshots", 0); +#endif /* we don't accept -skindir without -skin now * to simplify the autoconfig stuff with virtual devices @@ -1376,6 +1394,37 @@ int main(int argc, char **argv) } } +#if CONFIG_ANDROID_SNAPSHOTS + if (!opts->no_snapstorage) { + opts->snapstorage = (char*) avdInfo_getImageFile(avd, AVD_IMAGE_SNAPSHOTS); + if(opts->snapstorage) { + if (path_exists(opts->snapstorage)) { + args[n++] = "-hdb"; + args[n++] = opts->snapstorage; + } else { + D("no image at '%s', state snapshots disabled", opts->snapstorage); + } + } + + if (!opts->no_snapshot) { + args[n++] = "-loadvm"; + if (opts->snapshot) { + args[n++] = opts->snapshot; + } else { + // name of state snapshot to load if not specified by user + args[n++] = "default-boot"; + } + } else if (opts->snapshot) { + dwarning("option '-no-snapshot' overrides '-snapshot', continuing with boot sequence"); + } + } else if (opts->snapshot || opts->snapstorage) { + dwarning("option '-no-snapstorage' overrides '-snapshot' and '-snapstorage', " + "continuing with full boot, state snapshots are disabled"); + } else if (opts->no_snapshot) { + D("ignoring redundant option '-no-snapshot' implied by '-no-snapstorage'"); + } +#endif + if (!opts->logcat || opts->logcat[0] == 0) { opts->logcat = getenv("ANDROID_LOG_TAGS"); if (opts->logcat && opts->logcat[0] == 0) |