aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@android.com>2011-03-01 14:03:20 +0100
committerDavid 'Digit' Turner <digit@android.com>2011-03-01 15:31:11 +0100
commit48a3c66361158678f476fc7c2eca2bef025eae62 (patch)
tree276dd2b4c0c0dd5c64d8d32423ebc5884ba239fa
parentc480cca8d2007f5df62a7431beda310911b963e6 (diff)
downloadexternal_qemu-48a3c66361158678f476fc7c2eca2bef025eae62.zip
external_qemu-48a3c66361158678f476fc7c2eca2bef025eae62.tar.gz
external_qemu-48a3c66361158678f476fc7c2eca2bef025eae62.tar.bz2
Move the SD Card initialization to the core.
Change-Id: I2c8fa2a7df3d79ed4222296a93b787994a8ee11d
-rw-r--r--android/avd/hardware-properties.ini12
-rw-r--r--android/avd/hw-config-defs.h14
-rw-r--r--android/avd/info.c41
-rw-r--r--android/avd/info.h2
-rw-r--r--android/main-common.c10
-rw-r--r--android/main.c51
-rw-r--r--vl-android.c18
7 files changed, 95 insertions, 53 deletions
diff --git a/android/avd/hardware-properties.ini b/android/avd/hardware-properties.ini
index 06ac447..8dca7fe 100644
--- a/android/avd/hardware-properties.ini
+++ b/android/avd/hardware-properties.ini
@@ -136,6 +136,11 @@ default = yes
abstract = SD Card support
description = Whether the device supports insertion/removal of virtual SD Cards.
+name = hw.sdCard.path
+type = string
+default =
+abstract = SD Card image path
+
# Cache partition
name = disk.cachePartition
type = boolean
@@ -265,10 +270,3 @@ type = string
default =
abstract = Path to snapshots
description = Path to a 'snapshot storage' file, where all snapshots are stored, including the default snapshot.
-
-# Path to SD Card image file.
-name = disk.sdCard.path
-type = string
-default =
-abstract = Path to SD Card image file
-description = Path to SD Card image file. Ignored if disk.sdCard is not set to 'yes'.
diff --git a/android/avd/hw-config-defs.h b/android/avd/hw-config-defs.h
index c3e0a77..3d3ba5e 100644
--- a/android/avd/hw-config-defs.h
+++ b/android/avd/hw-config-defs.h
@@ -129,6 +129,13 @@ HWCFG_BOOL(
"SD Card support",
"Whether the device supports insertion/removal of virtual SD Cards.")
+HWCFG_STRING(
+ hw_sdCard_path,
+ "hw.sdCard.path",
+ "",
+ "SD Card image path",
+ "")
+
HWCFG_BOOL(
disk_cachePartition,
"disk.cachePartition",
@@ -262,13 +269,6 @@ HWCFG_STRING(
"Path to snapshots",
"Path to a 'snapshot storage' file, where all snapshots are stored, including the default snapshot.")
-HWCFG_STRING(
- disk_sdCard_path,
- "disk.sdCard.path",
- "",
- "Path to SD Card image file",
- "Path to SD Card image file. Ignored if disk.sdCard is not set to 'yes'.")
-
#undef HWCFG_INT
#undef HWCFG_BOOL
#undef HWCFG_DISKSIZE
diff --git a/android/avd/info.c b/android/avd/info.c
index aad316a..61142ba 100644
--- a/android/avd/info.c
+++ b/android/avd/info.c
@@ -1130,7 +1130,6 @@ static int
_avdInfo_getImagePaths(AvdInfo* i, AvdInfoParams* params )
{
int wipeData = (params->flags & AVDINFO_WIPE_DATA) != 0;
- int noSdCard = (params->flags & AVDINFO_NO_SDCARD) != 0;
int noSnapshots = (params->flags & AVDINFO_NO_SNAPSHOTS) != 0;
ImageLoader l[1];
@@ -1184,15 +1183,6 @@ _avdInfo_getImagePaths(AvdInfo* i, AvdInfoParams* params )
imageLoader_lock( l, 0 );
}
- /* the SD Card image. unless the user doesn't want to, we're
- * going to mount it if available. Note that if the image is
- * already used, we must ignore it.
- */
- if (!noSdCard) {
- imageLoader_loadOptional(l, AVD_IMAGE_SDCARD,
- params->forcePaths[AVD_IMAGE_SDCARD]);
- }
-
/* the state snapshot image. Mounting behaviour identical to
* SD card.
*/
@@ -1294,7 +1284,6 @@ static int
_avdInfo_getBuildImagePaths( AvdInfo* i, AvdInfoParams* params )
{
int wipeData = (params->flags & AVDINFO_WIPE_DATA) != 0;
- int noSdCard = (params->flags & AVDINFO_NO_SDCARD) != 0;
int noSnapshots = (params->flags & AVDINFO_NO_SNAPSHOTS) != 0;
char temp[PATH_MAX];
@@ -1365,13 +1354,6 @@ _avdInfo_getBuildImagePaths( AvdInfo* i, AvdInfoParams* params )
/* force the system image to read-only status */
l->pState[0] = IMAGE_STATE_READONLY;
- /** SD Card image
- **/
- if (!noSdCard) {
- imageLoader_set (l, AVD_IMAGE_SDCARD);
- imageLoader_load(l, IMAGE_OPTIONAL | IMAGE_IGNORE_IF_LOCKED);
- }
-
/** State snapshots image
**/
if (!noSnapshots) {
@@ -1526,6 +1508,29 @@ char* avdInfo_getDefaultCachePath( AvdInfo* i )
return _getFullFilePath(i->contentPath, imageName);
}
+char* avdInfo_getSdCardPath( AvdInfo* i )
+{
+ const char* imageName = _imageFileNames[ AVD_IMAGE_SDCARD ];
+ char* path;
+
+ /* Special case, the config.ini can have a SDCARD_PATH entry
+ * that gives the full path to the SD Card.
+ */
+ if (i->configIni != NULL) {
+ path = iniFile_getString(i->configIni, SDCARD_PATH, NULL);
+ if (path != NULL) {
+ if (path_exists(path))
+ return path;
+
+ dwarning("Ignoring invalid SDCard path: %s", path);
+ AFREE(path);
+ }
+ }
+
+ /* Otherwise, simply look into the content directory */
+ return _avdInfo_getContentFilePath(i, imageName);
+}
+
char*
avdInfo_getSystemInitImagePath( AvdInfo* i )
{
diff --git a/android/avd/info.h b/android/avd/info.h
index 9410653..38f8a9f 100644
--- a/android/avd/info.h
+++ b/android/avd/info.h
@@ -136,6 +136,7 @@ const char* avdInfo_getName( AvdInfo* i );
*/
char* avdInfo_getKernelPath( AvdInfo* i );
char* avdInfo_getRamdiskPath( AvdInfo* i );
+char* avdInfo_getSdCardPath( AvdInfo* i );
/* This function returns NULL if the cache image file cannot be found.
* Use avdInfo_getDefaultCachePath() to retrieve the default path
@@ -144,6 +145,7 @@ char* avdInfo_getRamdiskPath( AvdInfo* i );
char* avdInfo_getCachePath( AvdInfo* i );
char* avdInfo_getDefaultCachePath( AvdInfo* i );
+
char* avdInfo_getSystemInitImagePath( AvdInfo* i );
char* avdInfo_getDataInitImagePath( AvdInfo* i );
diff --git a/android/main-common.c b/android/main-common.c
index bcd5248..cc478b0 100644
--- a/android/main-common.c
+++ b/android/main-common.c
@@ -917,14 +917,6 @@ AvdInfo* createAVD(AndroidOptions* opts, int* inAndroidBuild)
D("autoconfig: -data %s", opts->data);
}
- if (!opts->sdcard && opts->datadir) {
- bufprint(tmp, tmpend, "%s/sdcard.img", opts->datadir);
- if (path_exists(tmp)) {
- opts->sdcard = android_strdup(tmp);
- D("autoconfig: -sdcard %s", opts->sdcard);
- }
- }
-
if (!opts->snapstorage && opts->datadir) {
bufprint(tmp, tmpend, "%s/snapshots.img", opts->datadir);
if (path_exists(tmp)) {
@@ -939,7 +931,6 @@ AvdInfo* createAVD(AndroidOptions* opts, int* inAndroidBuild)
*/
_forceAvdImagePath(AVD_IMAGE_INITSYSTEM, opts->system, "system", 1);
_forceAvdImagePath(AVD_IMAGE_USERDATA, opts->data, "user data", 0);
- _forceAvdImagePath(AVD_IMAGE_SDCARD, opts->sdcard, "SD Card", 0);
_forceAvdImagePath(AVD_IMAGE_SNAPSHOTS, opts->snapstorage, "snapshots", 0);
android_avdParams->skinName = opts->skin;
@@ -1048,7 +1039,6 @@ updateHwConfigFromAVD(AndroidHwConfig* hwConfig,
_update_hwconfig_path(&hwConfig->disk_dataPartition_path, avd, AVD_IMAGE_USERDATA);
_update_hwconfig_path(&hwConfig->disk_systemPartition_path, avd, AVD_IMAGE_USERSYSTEM);
_update_hwconfig_path(&hwConfig->disk_dataPartition_path, avd, AVD_IMAGE_INITDATA);
- _update_hwconfig_path(&hwConfig->disk_sdCard_path, avd, AVD_IMAGE_SDCARD);
_update_hwconfig_path(&hwConfig->disk_snapshots_path, avd, AVD_IMAGE_SNAPSHOTS);
if (opts->partition_size) {
diff --git a/android/main.c b/android/main.c
index dad5d69..ae0fee6 100644
--- a/android/main.c
+++ b/android/main.c
@@ -115,7 +115,6 @@ int main(int argc, char **argv)
char* args[128];
int n;
char* opt;
- int use_sdcard_img = 0;
int serial = 0;
int gps_serial = 0;
int radio_serial = 0;
@@ -472,6 +471,9 @@ int main(int argc, char **argv)
opts->cache = avdInfo_getDefaultCachePath(avd);
}
}
+ if (opts->cache) {
+ D("autoconfig: -cache %s", opts->cache);
+ }
}
if (opts->cache) {
@@ -481,12 +483,38 @@ int main(int argc, char **argv)
/** SD CARD PARTITION */
- // TODO: This should go to core
- if (hw->hw_sdCard != 0)
- opts->sdcard = (char*) avdInfo_getImageFile(avd, AVD_IMAGE_SDCARD);
- else if (opts->sdcard) {
- dwarning( "Emulated hardware doesn't support SD Cards" );
- opts->sdcard = NULL;
+ if (!hw->hw_sdCard) {
+ /* No SD Card emulation, so -sdcard will be ignored */
+ if (opts->sdcard) {
+ dwarning( "Emulated hardware doesn't support SD Cards. -sdcard option ignored." );
+ opts->sdcard = NULL;
+ }
+ } else {
+ /* Auto-configure -sdcard if it is not available */
+ if (!opts->sdcard) {
+ do {
+ /* If -datadir <path> is used, look for a sdcard.img file here */
+ if (opts->datadir) {
+ bufprint(tmp, tmpend, "%s/%s", opts->datadir, "system.img");
+ if (path_exists(tmp)) {
+ opts->sdcard = strdup(tmp);
+ break;
+ }
+ }
+
+ /* Otherwise, look at the AVD's content */
+ opts->sdcard = avdInfo_getSdCardPath(avd);
+ if (opts->sdcard != NULL) {
+ break;
+ }
+
+ /* Nothing */
+ } while (0);
+
+ if (opts->sdcard) {
+ D("autoconfig: -sdcard %s", opts->sdcard);
+ }
+ }
}
if(opts->sdcard) {
@@ -499,15 +527,16 @@ int main(int argc, char **argv)
if (size < 9*1024*1024ULL) {
fprintf(stderr, "### WARNING: SD Card files must be at least 9MB, ignoring '%s'\n", opts->sdcard);
} else {
- args[n++] = "-hda";
- args[n++] = opts->sdcard;
- use_sdcard_img = 1;
+ hw->hw_sdCard_path = ASTRDUP(opts->sdcard);
}
} else {
- D("no SD Card image at '%s'", opts->sdcard);
+ dwarning("no SD Card image at '%s'", opts->sdcard);
}
}
+
+ /** SNAPSHOT STORAGE HANDLING */
+
if (!opts->no_snapstorage) {
// TODO: This should go to core
opts->snapstorage = (char*) avdInfo_getImageFile(avd, AVD_IMAGE_SNAPSHOTS);
diff --git a/vl-android.c b/vl-android.c
index 379741b..d07b6c0 100644
--- a/vl-android.c
+++ b/vl-android.c
@@ -57,6 +57,8 @@
#include "android/globals.h"
#include "android/utils/bufprint.h"
#include "android/utils/debug.h"
+#include "android/utils/filelock.h"
+#include "android/utils/path.h"
#include "android/utils/stralloc.h"
#include "android/display-core.h"
#include "android/utils/timezone.h"
@@ -4835,6 +4837,22 @@ int main(int argc, char **argv, char **envp)
}
#endif // CONFIG_NAND_LIMITS
+ /* Init SD-Card stuff. For Android, it is always hda */
+ /* If the -hda option was used, ignore the Android-provided one */
+ if (hda_opts == NULL) {
+ const char* sdPath = android_hw->hw_sdCard_path;
+ if (sdPath && *sdPath) {
+ if (!path_exists(sdPath)) {
+ fprintf(stderr, "WARNING: SD Card image is missing: %s\n", sdPath);
+ } else if (filelock_create(sdPath) == NULL) {
+ fprintf(stderr, "WARNING: SD Card image already in use: %s\n", sdPath);
+ } else {
+ /* Successful locking */
+ hda_opts = drive_add(sdPath, HD_ALIAS, 0);
+ }
+ }
+ }
+
/* Set the VM's max heap size, passed as a boot property */
if (android_hw->vm_heapSize > 0) {
char tmp[64];