aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYurii Zubrytskyi <zyy@google.com>2016-06-23 16:26:32 -0700
committerYurii Zubrytskyi <zyy@google.com>2016-06-23 16:43:08 -0700
commit8e3b78ead3d6c7b668e9f26b3ee1062117264487 (patch)
tree6aab0a26ae7fa110789a55d428ab0eda7451d7d8
parentfabed0fd9225560cbe00c26e4318127f12adbd18 (diff)
downloadqemu-android-8e3b78ead3d6c7b668e9f26b3ee1062117264487.tar.gz
[2.2][qemu2] Fix a crash with -no-cache argument
Qemu2 initialization didn't create a temp cache file for -no-cache, calling the ext4 initialization on an empty string. That caused a crash Bug=http://b.android.com/214083 Change-Id: I280384a10da1b32d5901e26f25f58158231c0906
-rwxr-xr-xandroid-qemu2-glue/main.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/android-qemu2-glue/main.cpp b/android-qemu2-glue/main.cpp
index bc967d5c5c..a609f11fda 100755
--- a/android-qemu2-glue/main.cpp
+++ b/android-qemu2-glue/main.cpp
@@ -40,6 +40,7 @@
#include "android/utils/filelock.h"
#include "android/utils/tempfile.h"
#include "android/utils/stralloc.h"
+#include "android/utils/string.h"
#include "android/utils/win32_cmdline_quote.h"
#include "android/skin/winsys.h"
@@ -636,9 +637,19 @@ extern "C" int main(int argc, char **argv) {
}
}
+ bool createEmptyCacheFile = false;
- // Create cache partition image if it doesn't exist already.
- if (!path_exists(hw->disk_cachePartition_path)) {
+ // Make sure there's a temp cache partition if there wasn't a permanent one
+ if (!hw->disk_cachePartition_path ||
+ strcmp(hw->disk_cachePartition_path, "") == 0) {
+ str_reset(&hw->disk_cachePartition_path,
+ tempfile_path(tempfile_create()));
+ createEmptyCacheFile = true;
+ }
+
+ createEmptyCacheFile |= !path_exists(hw->disk_cachePartition_path);
+
+ if (createEmptyCacheFile) {
D("Creating empty ext4 cache partition: %s",
hw->disk_cachePartition_path);
int ret = android_createEmptyExt4Image(