aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbohu <bohu@google.com>2016-05-23 12:32:10 -0700
committerbohu <bohu@google.com>2016-05-23 15:15:56 -0700
commitec1d01d22eaa5e49bc2212aec11bc7ee5682c674 (patch)
tree5ed8898d46d2c67661bd3e4f27fc6447ad45930f
parent6f3f50cccde30f21918b5711435b054a561e9c14 (diff)
downloadqemu-android-ec1d01d22eaa5e49bc2212aec11bc7ee5682c674.tar.gz
Qemu2: resize userdata-qemu.img if requested
User may want to resize userdata-qemu.img without losing data. (-wipe-data will resize but also wipe out data in the same time) bug: b.android.com/196926 Change-Id: Ia39091d235dfd3931160be7530246199d7b83a7b
-rwxr-xr-xandroid-qemu2-glue/main.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/android-qemu2-glue/main.cpp b/android-qemu2-glue/main.cpp
index bd9a1aca8e..4d5329daf7 100755
--- a/android-qemu2-glue/main.cpp
+++ b/android-qemu2-glue/main.cpp
@@ -14,6 +14,7 @@
#include "android/base/Log.h"
#include "android/base/memory/ScopedPtr.h"
#include "android/base/StringFormat.h"
+#include "android/base/system/System.h"
#include "android/android.h"
#include "android/avd/hw-config.h"
@@ -74,6 +75,7 @@ extern bool android_op_wipe_data;
extern bool android_op_writable_system;
using namespace android::base;
+using android::base::System;
namespace {
@@ -614,6 +616,25 @@ extern "C" int main(int argc, char **argv) {
resizeExt4Partition(android_hw->disk_dataPartition_path,
android_hw->disk_dataPartition_size);
}
+ else {
+ // Resize userdata-qemu.img if the size is smaller than what config.ini
+ // says.
+ // This can happen as user wants a larger data partition without wiping
+ // it.
+ // b.android.com/196926
+ System::FileSize current_data_size;
+ if (System::get()->pathFileSize(hw->disk_dataPartition_path,
+ &current_data_size)) {
+ if (current_data_size < android_hw->disk_dataPartition_size) {
+ dwarning("userdata partition is resized from %d M to %d M\n",
+ current_data_size / (1024 * 1024),
+ android_hw->disk_dataPartition_size / (1024 * 1024));
+ resizeExt4Partition(android_hw->disk_dataPartition_path,
+ android_hw->disk_dataPartition_size);
+ }
+ }
+ }
+
// Create cache partition image if it doesn't exist already.
if (!path_exists(hw->disk_cachePartition_path)) {