merge from open-source master

Change-Id: I28be55e2d649c8d52ad7ed47c5a19221a886ae7b
diff --git a/config.mk b/config.mk
index 2cb034d..11f17fc 100644
--- a/config.mk
+++ b/config.mk
@@ -119,9 +119,9 @@
 internal_installerimage_files := \
 	$(filter-out --%,$(internal_installerimage_args))
 
-BOARD_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE))
-ifdef BOARD_KERNEL_CMDLINE
-  internal_installerimage_args += --cmdline "$(BOARD_KERNEL_CMDLINE)"
+BOARD_INSTALLER_CMDLINE := $(strip $(BOARD_INSTALLER_CMDLINE))
+ifdef BOARD_INSTALLER_CMDLINE
+  internal_installerimage_args += --cmdline "$(BOARD_INSTALLER_CMDLINE)"
 endif
 
 installer_tmp_img := $(TARGET_INSTALLER_OUT)/installer_tmp.img
@@ -182,10 +182,27 @@
 		inst_data=$(installer_data_img)
 	@echo "Done with bootable installer image -[ $@ ]-"
 
+
+######################################################################
+# now convert the installer_img (disk image) to a VirtualBox image
+
+INSTALLED_VBOXINSTALLERIMAGE_TARGET := $(PRODUCT_OUT)/installer.vdi
+virtual_box_manager := VBoxManage
+virtual_box_manager_options := convertfromraw
+
+$(INSTALLED_VBOXINSTALLERIMAGE_TARGET): $(INSTALLED_DISKINSTALLERIMAGE_TARGET)
+	@rm -f $(INSTALLED_VBOXINSTALLERIMAGE_TARGET)
+	@$(virtual_box_manager) $(virtual_box_manager_options) $(INSTALLED_DISKINSTALLERIMAGE_TARGET) $(INSTALLED_VBOXINSTALLERIMAGE_TARGET)
+	@echo "Done with VirtualBox bootable installer image -[ $@ ]-"
+
 else  # ! TARGET_USE_DISKINSTALLER
 INSTALLED_DISKINSTALLERIMAGE_TARGET :=
+INSTALLED_VBOXINSTALLERIMAGE_TARGET :=
 endif
 endif # TARGET_ARCH == x86
 
 .PHONY: installer_img
 installer_img: $(INSTALLED_DISKINSTALLERIMAGE_TARGET)
+
+.PHONY: installer_vdi
+installer_vdi: $(INSTALLED_VBOXINSTALLERIMAGE_TARGET)
diff --git a/editdisklbl/editdisklbl.c b/editdisklbl/editdisklbl.c
index 6a0c31c..792a62a 100644
--- a/editdisklbl/editdisklbl.c
+++ b/editdisklbl/editdisklbl.c
@@ -61,7 +61,7 @@
     int x;
     int update_lba = 0;
 
-    while ((x = getopt (argc, argv, "thl:i:")) != EOF) {
+    while ((x = getopt (argc, argv, "vthl:i:")) != EOF) {
         switch (x) {
             case 'h':
                 return usage();
diff --git a/installer.c b/installer.c
index 0bf8f48..7c4762e 100644
--- a/installer.c
+++ b/installer.c
@@ -457,8 +457,10 @@
     }
 
     for (img = images->first_child; img; img = img->next) {
-        if (process_image_node(img, device_disk_info, test))
+        if (process_image_node(img, device_disk_info, test)) {
+            LOGE("Unable to write data to partition. Try running 'installer' again.");
             return 1;
+        }
         ++cnt;
     }
 
@@ -473,5 +475,6 @@
         return 1;
 
     LOGI("Done processing installer config. Configured %d images", cnt);
+    LOGI("Type 'reboot' or reset to run new image");
     return 0;
 }