diff options
Diffstat (limited to 'android/avd')
-rw-r--r-- | android/avd/info.c | 80 | ||||
-rw-r--r-- | android/avd/info.h | 12 |
2 files changed, 69 insertions, 23 deletions
diff --git a/android/avd/info.c b/android/avd/info.c index 992f292..e680585 100644 --- a/android/avd/info.c +++ b/android/avd/info.c @@ -10,6 +10,7 @@ ** GNU General Public License for more details. */ #include "android/avd/info.h" +#include "android/config/config.h" #include "android/utils/path.h" #include "android/utils/bufprint.h" #include "android/utils/filelock.h" @@ -681,7 +682,30 @@ EXIT: return l->pPath[0]; } +/* Attempts to load an AVD image, but does not kill the process if loading + * fails. + */ +static void +imageLoader_loadOptional( ImageLoader *l, AvdImageType img_type, + const char *forcedPath ) +{ + imageLoader_set (l, img_type); + imageLoader_load(l, IMAGE_OPTIONAL | + IMAGE_IGNORE_IF_LOCKED); + /* if the file was not found, ignore it */ + if (l->pPath[0] && !path_exists(l->pPath[0])) + { + D("ignoring non-existing %s at %s: %s", + l->imageText, l->pPath[0], strerror(errno)); + + /* if the user provided the path by hand, warn him. */ + if (forcedPath != NULL) + dwarning("ignoring non-existing %s image", l->imageText); + + imageLoader_setPath(l, NULL); + } +} /* find the correct path of all image files we're going to need * and lock the files that need it. @@ -689,10 +713,13 @@ EXIT: static int _getImagePaths(AvdInfo* i, AvdInfoParams* params ) { - int wipeData = (params->flags & AVDINFO_WIPE_DATA) != 0; - int wipeCache = (params->flags & AVDINFO_WIPE_CACHE) != 0; - int noCache = (params->flags & AVDINFO_NO_CACHE) != 0; - int noSdCard = (params->flags & AVDINFO_NO_SDCARD) != 0; + int wipeData = (params->flags & AVDINFO_WIPE_DATA) != 0; + int wipeCache = (params->flags & AVDINFO_WIPE_CACHE) != 0; + int noCache = (params->flags & AVDINFO_NO_CACHE) != 0; + int noSdCard = (params->flags & AVDINFO_NO_SDCARD) != 0; +#if CONFIG_ANDROID_SNAPSHOTS + int noSnapshots = (params->flags & AVDINFO_NO_SNAPSHOTS) != 0; +#endif ImageLoader l[1]; @@ -778,24 +805,19 @@ _getImagePaths(AvdInfo* i, AvdInfoParams* params ) * already used, we must ignore it. */ if (!noSdCard) { - imageLoader_set (l, AVD_IMAGE_SDCARD); - imageLoader_load(l, IMAGE_OPTIONAL | - IMAGE_IGNORE_IF_LOCKED); - - /* if the file was not found, ignore it */ - if (l->pPath[0] && !path_exists(l->pPath[0])) - { - D("ignoring non-existing %s at %s: %s", - l->imageText, l->pPath[0], strerror(errno)); - - /* if the user provided the SD Card path by hand, - * warn him. */ - if (params->forcePaths[AVD_IMAGE_SDCARD] != NULL) - dwarning("ignoring non-existing SD Card image"); + imageLoader_loadOptional(l, AVD_IMAGE_SDCARD, + params->forcePaths[AVD_IMAGE_SDCARD]); + } - imageLoader_setPath(l, NULL); - } +#if CONFIG_ANDROID_SNAPSHOTS + /* the state snapshot image. Mounting behaviour identical to + * SD card. + */ + if (!noSnapshots) { + imageLoader_loadOptional(l, AVD_IMAGE_SNAPSHOTS, + params->forcePaths[AVD_IMAGE_SNAPSHOTS]); } +#endif return 0; } @@ -1146,9 +1168,12 @@ _getBuildConfigIni( AvdInfo* i ) static int _getBuildImagePaths( AvdInfo* i, AvdInfoParams* params ) { - int wipeData = (params->flags & AVDINFO_WIPE_DATA) != 0; - int noCache = (params->flags & AVDINFO_NO_CACHE) != 0; - int noSdCard = (params->flags & AVDINFO_NO_SDCARD) != 0; + int wipeData = (params->flags & AVDINFO_WIPE_DATA) != 0; + int noCache = (params->flags & AVDINFO_NO_CACHE) != 0; + int noSdCard = (params->flags & AVDINFO_NO_SDCARD) != 0; +#if CONFIG_ANDROID_SNAPSHOTS + int noSnapshots = (params->flags & AVDINFO_NO_SNAPSHOTS) != 0; +#endif char temp[PATH_MAX], *p=temp, *end=p+sizeof temp; char* srcData; @@ -1263,6 +1288,15 @@ _getBuildImagePaths( AvdInfo* i, AvdInfoParams* params ) imageLoader_load(l, IMAGE_OPTIONAL | IMAGE_IGNORE_IF_LOCKED); } +#if CONFIG_ANDROID_SNAPSHOTS + /** State snapshots image + **/ + if (!noSnapshots) { + imageLoader_set (l, AVD_IMAGE_SNAPSHOTS); + imageLoader_load(l, IMAGE_OPTIONAL | IMAGE_IGNORE_IF_LOCKED); + } +#endif + return 0; } diff --git a/android/avd/info.h b/android/avd/info.h index 19df807..2b2899f 100644 --- a/android/avd/info.h +++ b/android/avd/info.h @@ -14,6 +14,7 @@ #include "android/utils/ini.h" #include "android/avd/hw-config.h" +#include "android/config/config.h" /* An Android Virtual Device (AVD for short) corresponds to a * directory containing all kernel/disk images for a given virtual @@ -45,6 +46,12 @@ * */ + +#if CONFIG_ANDROID_SNAPSHOTS +#define _AVD_IMG_SNAPSHOT _AVD_IMG(SNAPSHOTS,"snapshots.img","snapshots") +#else +#define _AVD_IMG_SNAPSHOT +#endif /* a macro used to define the list of disk images managed by the * implementation. This macro will be expanded several times with * varying definitions of _AVD_IMG @@ -58,6 +65,7 @@ _AVD_IMG(USERDATA,"userdata-qemu.img", "user data") \ _AVD_IMG(CACHE,"cache.img","cache") \ _AVD_IMG(SDCARD,"sdcard.img","SD Card") \ + _AVD_IMG_SNAPSHOT \ /* define the enumared values corresponding to each AVD image type * examples are: AVD_IMAGE_KERNEL, AVD_IMAGE_SYSTEM, etc.. @@ -86,6 +94,10 @@ typedef enum { AVDINFO_NO_SDCARD = (1 << 3), /* use to wipe the system image with new initial values */ AVDINFO_WIPE_SYSTEM = (1 << 4), +#if CONFIG_ANDROID_SNAPSHOTS + /* use to ignore ignore state snapshot image (default or provided) */ + AVDINFO_NO_SNAPSHOTS = (1 << 5), +#endif } AvdFlags; typedef struct { |