diff options
author | David 'Digit' Turner <digit@android.com> | 2011-03-01 15:03:07 +0100 |
---|---|---|
committer | David 'Digit' Turner <digit@android.com> | 2011-03-01 15:05:04 +0100 |
commit | 26d415322b75784f123d39f36616b8ebd1fbb359 (patch) | |
tree | 67e5d3147062887665f79cc00152bd483b0ae72e /android/main.c | |
parent | 26722dde31c3467cd31a078662810927eec05de5 (diff) | |
download | external_qemu-26d415322b75784f123d39f36616b8ebd1fbb359.zip external_qemu-26d415322b75784f123d39f36616b8ebd1fbb359.tar.gz external_qemu-26d415322b75784f123d39f36616b8ebd1fbb359.tar.bz2 |
Prevent hardware-qemu.ini overwrites.
When launching two instances of the same AVD, we need to ensure that
we don't end-up overwriting the hardware-qemu.ini in the content
directory.
Note that this case is supported at the moment. Both the system and
data partition will be backed by a temporary file when this is detected.
Change-Id: I2c5d9195edc4c5be3b889c8da38cb1c7cae3662a
Diffstat (limited to 'android/main.c')
-rw-r--r-- | android/main.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/android/main.c b/android/main.c index 198212f..4315c4e 100644 --- a/android/main.c +++ b/android/main.c @@ -38,6 +38,7 @@ #include "android/user-config.h" #include "android/utils/bufprint.h" +#include "android/utils/filelock.h" #include "android/utils/path.h" #include "android/utils/tempfile.h" @@ -837,17 +838,26 @@ int main(int argc, char **argv) } args[n] = 0; - /* Generate a temporary hardware.ini for this AVD. The real hardware + /* Generate a hardware-qemu.ini for this AVD. The real hardware * configuration is ususally stored in several files, e.g. the AVD's * config.ini plus the skin-specific hardware.ini. * - * The new temp file will group all definitions and will be used to + * The new file will group all definitions and will be used to * launch the core with the -android-hw <file> option. */ { const char* coreHwIniPath = avdInfo_getCoreHwIniPath(avd); IniFile* hwIni = iniFile_newFromMemory("", NULL); androidHwConfig_write(hw, hwIni); + + if (filelock_create(coreHwIniPath) == NULL) { + /* The AVD is already in use, we still support this as an + * experimental feature. Use a temporary hardware-qemu.ini + * file though to avoid overwriting the existing one. */ + TempFile* tempIni = tempfile_create(); + coreHwIniPath = tempfile_path(tempIni); + } + if (iniFile_saveToFile(hwIni, coreHwIniPath) < 0) { derror("Could not write hardware.ini to %s: %s", coreHwIniPath, strerror(errno)); exit(2); |