summaryrefslogtreecommitdiff
path: root/gsi_tool.cpp
AgeCommit message (Collapse)Author
2020-12-29gsi_tool: check closePartition() after installationYo Chiang
Call closePartition() to check error status after each partition installation, so that we don't enable and reboot a DSU while the installation fails. Bug: 165471299 Test: gsi_tool install Change-Id: Ie1e5a97ee486af17c0d435853257d17e436a4553
2020-10-22Add "create-partition" debugging API to gsi_toolYo Chiang
`gsi_tool create-partition [-p <name>] [-s <size>] [--readwrite]` is a debugging API used to create DSU partitions. Readwritable partitions such as userdata and scratch should be created with the "--readwrite" flag. This is like `gsi_tool install` but `create-partition` is more primitive and does less things (doesn't auto-create userdata, doesn't auto-reboot.) This is a debugging API so don't depend on its behavior and don't expect it to be stable. Bug: 165925766 Test: adb shell gsi_tool create-partition --readwrite \ --partition scratch --size $((200 * 1024 * 1024)) Change-Id: I9ce463220534ba46c948ea48e9c52bdc0ff762b1
2020-08-28gsi_tool should send STDIN_FILENO to gsidYo Chiang
`gsi_tool` is `dup()`-ing FD 1, which is the STDOUT_FILENO, and sending it to `gsid`, and `gsid` is calling `read()` on the FD. `gsi_tool` should actually be sending FD 0, the STDIN, to `gsid`. Bug: 166589508 Test: gzip -c system.raw | adb shell "zcat | gsi_tool install ..." Change-Id: I9d7bb5f2a1146d3c5ac7332eae34a67963a6eb5d
2020-03-11Cleanup unused dependenciesandroid-r-preview-4android-r-preview-3android-r-preview-2Yo Chiang
* Cleanup unused headers * Cleanup libgsid unused dependencies Test: Build and boot Change-Id: I22456c176dde524bc51a435bca6fc45d37240f56
2020-03-03Convert gsid to use the dynamic AIDL service infrastructureHoward Chen
Replace the original on demand start mechanism with the new dynamic AIDL service infrastructure to resolve a possible race condition. Bug: 149130673 Test: gsi_tool status Change-Id: I141475b56191eb82efe222bf7522350fc66a7dac
2020-03-03Fix gsi_tool wipe-dataHoward Chen
Bug: 149962466 Test: gsi_tool wipe-data Change-Id: I3265805c95ebad4ed37c4f0f0df2840214e232d4
2020-02-05Add getAvbPublicKey to IGsiService and IImageServiceYo Chiang
Retrieves AVB public key from an image's VBMeta block. Bug: 146418878 Test: adb shell am start-activity \ -n com.android.dynsystem/com.android.dynsystem.VerificationActivity \ -a android.os.image.action.START_INSTALL \ --el KEY_USERDATA_SIZE 8589934592 \ -d file:///storage/emulated/0/Download/aosp_arm64-dsu_test.zip Test: adb shell gsi_tool status \ // command should show sha1 of public key for each partition Change-Id: Ic529275a2678e6c1ce341910e4dbbe9af66742a7
2020-01-14Support multiple DSU installationsHoward Chen
Bug: 144247097 Test: adb shell gsi_tool install --gsi-size $(du -b system.raw|cut -f1) < system.raw Change-Id: I17f4292fc3038040cc5848ce00081e96c79ae769
2019-12-17gsid: Fixes for 32-bitPaul Trautrim
Bug: 146386624 Test: DSUEndtoEndTest Change-Id: I376f253c740575d8350b14faed1d04743d038f81
2019-12-02Fix typo in DSU installation error messageYo Chiang
Test: TH presubmit Change-Id: Ide39c9f71d2daf06591096d50ad9a5aa59aa68db
2019-11-12RefactoringHoward Chen
* Remove GsiInstallParams.aidl * GsiInstaller -> PartitionInstaller * beginGsiInstall -> open, close, createPartition * wipeUserdata -> zeroPartition * GetInstallation returns current installation * SaveInstallation save current installation Test: gsi_tool install & reboot adb shell am start-activity \ -n com.android.dynsystem/com.android.dynsystem.VerificationActivity \ -a android.os.image.action.START_INSTALL \ -d file:///storage/emulated/0/Download/system.raw.gz \ --el KEY_SYSTEM_SIZE $(du -b system.raw|cut -f1) \ --el KEY_USERDATA_SIZE 8589934592 Change-Id: I2be8b12130bd0a5f768a496c3a0ca8a3b2682c45
2019-10-24Enhance the fault tolerance of GSID installationHoward Chen
The gsid may function abnormally when an installation get interrupted. case 1. $ gsi_tool install ... use ctrl+C to stop ... $ gsi_tool wipe Could not remove GSI install. case 2 When it's interrupted. The installer destructor does not have the the chance to run therefore it can be a resource leak because the backing files, e.g. system_gsi and userdata_gsi are not released. Neither can they be enabled because the IsGsiInstalled() == false. This CL fixes cases above by making a integrity model based on IsGsiInstalled() as an atomic switch, e.g. if (IsGsiInstalled()) { The installation must be complete and the enableGsi() must work. } else { All resources that have been allocated must be cleaned up. a. Clean up methods and command must work. b. runStartup method must do the clean up. } All corresponding changes are based on this model. Bug: 140014207 Test: \ 1. gsi_tool install & reboot 2. gsi_tool install & ctrl+C & gsi_tool status & gsi_tool wipe & gsi_tool status 3. gsi_tool install & ctrl+C & gsi_tool status & reboot & gsi_tool status Change-Id: I0dcf043d65b50f0dd82eac1f428a295e94c81812
2019-10-24Make DSU to support multiple partitionsHoward Chen
Make gsid to support multiple partitions in a generic way. Bug: 139402092 Test: \ adb shell gsi_tool install -n --gsi-size $(du -b system.raw|cut -f1) -w < system.raw adb shell gsi_tool install -n --gsi-size $(du -b vendor.raw|cut -f1) -p vendor < vendor.raw Change-Id: Iaf5259cc059daa61cf52efab20bf23a433909b7a
2019-09-28Merge changes from topics "dsu_ashmem", "dsu_clean_up"Treehugger Robot
* changes: Use Ashmem to reduce buffer copies. Clean up legacy methods and naming
2019-09-18Clean up legacy methods and namingHoward Chen
remove: startGsiInstall framework does not use the old prototype any more. remove: getGsiStatus framework does not use it any more. rename: setGsiBootable -> enableGsi make it consistent with its reverse action: disableGsi rename: removeGsiInstall -> removeGsi rename: disableGsiInstall -> disableGsi the word install now refers to the installation session. rename for consistency. Bug: 138544413 Test: gsi_tool install/enable/disable adb shell am start-activity \ -n com.android.dynsystem/com.android.dynsystem.VerificationActivity \ -a android.os.image.action.START_INSTALL \ -d file:///storage/emulated/0/Download/system.raw.gz \ --el KEY_SYSTEM_SIZE $(du -b system.raw|cut -f1) \ --el KEY_USERDATA_SIZE 8589934592 Change-Id: I974d781d1eca82cecd813ad7bf557c5aec6f8f45 Merged-In: I974d781d1eca82cecd813ad7bf557c5aec6f8f45
2019-09-09Factor GetGsiService into a helper library.David Anderson
Bug: 140204341 Test: gsi_tool Change-Id: I40fb2ff6ad58346d0711b971de5d1a7d3fba6774
2019-08-28Add getAllBackingImages to ImageServiceHoward Chen
Add the getAllBackImages to get all installed backing image names. This method is needed to support DSU with multiple partitions. Test: gsi_tool status Bug: 139402092 Change-Id: I91b83398c0a3c9874a38de94140d8a5f00fcf924
2019-07-29Only shut down gsid when it has no more consumers.David Anderson
Consumers of gsiservice must now use IGsid for its top-level interface. IGsiService can be acquired through IGsid::getClient. When the last reference to IGsiService is dropped, gsid will cleanly exit. Callers should no longer stop gsid through init. Bug: 133528572 Test: gsid cleanly exits after gsi_tool runs Change-Id: Ie5cb80fa63e61b143f9f27cca96999a5c71dab2c Merged-In: Ie5cb80fa63e61b143f9f27cca96999a5c71dab2c
2019-06-11Add a wipe-data command to gsi_tool and IGsiService.David Anderson
Bug: 134185850 Test: gsi_tool install reboot; skip setup wizard reboot gsi_tool wipe-data gsi_tool enable reboot; expect setup wizard Change-Id: I44b676f9e08a890b14f056c7ab095c42158d9eb4
2019-04-16Enable clang-format on preupload.David Anderson
Bug: N/A Test: gsid builds Change-Id: Ica52e0c7cc7cba214df274df85bfaf7d533b446e
2019-03-15Add isGsiEnabled to GsiServiceHoward Chen
In order to re-enable the Gsi from framework, we need a method to query the current enable status. Bug: 125079548 Test: use the status command Change-Id: Ia6c0ae12e2e6613f112a241d2cf5733f8bf22984
2019-03-15Make the StartInstall abort-ableHoward Chen
The StartInstall may take more than one mintue. This CL adds an aborting_ flag to notify the allocating procedure to exit once the flag is set. It also adds a "cancel" command to gsi_tool for testing purpose. Test: open two adb consoles: one starts the installation and another uses the cancel command to abort. Bug: 125599267 Change-Id: I8f8fc460df526abda81ed6e0ac8f7176a28e9df3
2019-03-12Allow specifying the GSI install path.David Anderson
This patch follows up on the previous change which removed hardcoding of /data/gsi. Now, the install path can be specified by gsi_tool or IGsiService::beginGsiInstall. The path is normalized and then validated. Currently, only /data/gsi is allowed, however this will be changed in the near future. This patch also introduces a new GsiInstallParams parcelable and startGsiInstall will be deprecated. Bug: 126230649 Test: gsi_tool --install-dir=/data/gsi works Change-Id: Ic654f7c7475c17855b65e5917ebcb9ee60e32b79
2019-03-07Do not hardcode /data/gsi in GsiService.android-q-preview-1David Anderson
This patch removes hardcoding of /data/gsi. Instead, StartInstall is given an installation directory, and this is saved in /metadata/gsi/install_dir. When wiping or re-enabling a GSI, image paths are recovered from install_dir. This does not actually make the path configurable: it is a refactoring to no longer rely on hardcoded image paths. Included are some minor cleanups to ensure that cancelled installs delete files properly. Bug: 126230649 Test: gsi_tool install, enable, wipe Change-Id: Ieb788e84d19127e8e3375909f3c522e16462d384
2019-03-06Allow gsi_tool to set whether GSI installs are single-boot or not.David Anderson
Previously, init would always write "disabled" back to /metadata/gsi/install_status, to effectively restore the host image after the GSI reboots. This is not always desirable, so this patch introduces a new "one_shot_boot" file. If present, the GSI will only boot once, otherwise, it can persist until manually disabled. This also adds a new getGsiBootStatus() method to IGsiService, so the UI can determine whether the GSI is in single-boot mode or not. Bug: 126148526 Test: install GSI, reboot twice - back to normal image gsi_tool enable --single-boot, reboot twice, back to normal image gsi_tool enable, reboot twice, still in GSI Change-Id: I49bffea09bc9871502ce7bf3c27518a435357ecd
2019-02-27Start gsid on-demand.David Anderson
With this patch, gsid is disabled by default. It can be enabled on-demand via setting the ctl.start property to "gsid". In addition, this patch cleans up error reporting in gsi_tool to distinguish between binder and IGsiService errors, and fixes a bug where "gsi_tool enable" would not work from a non-root shell. Bug: 126622385 Test: gsid not running by default Change-Id: Icd6350f146d12e71befafa91ac859cf438376bc1
2019-02-20Allow enabling or disabling a previously installed GSI as non-root.David Anderson
Bug: 123716647 Test: manual test Change-Id: Ia7987ed007e9de57e32df87cd63d999d76402ccc
2019-02-08Use stderr for error messages.David Anderson
Bug: N/A Test: manual test Change-Id: I168be339e00e2e3ecf495902056554d8ca884da3
2019-02-07Gsid should behave more like a normal service.David Anderson
This patch makes the following changes to gsid: - It now runs on startup and is no longer a one-shot service. - /data/gsi is now created via init, with the appropriate permissions. - gsi_tool no longer starts/stops gsid. - /metadata/gsi is readable by the system group, so system_server can read /metadata/gsi/booted. Bug: 122556707 Test: manual test Change-Id: I08c0c6e9a155a0dea113c8535e71bda5aeda0ff6
2019-02-01gsi_tool: Refuse to install/disable/wipe unless root.David Anderson
Bug: 122556707 Test: manual test Change-Id: I8bcb5ce7fd02a6bbf40595a66a5f25c0e2ac1a54
2019-01-31gsi_tool: Fix progress bar quirk.David Anderson
If the progress bar receives a sequence like: T+0 "create system" 99% T+1 "write gsi" 1% It'll draw the "create system" bar at 99% and leave it there forever. Ensure that FinishLastBar() gets called before moving onto a new operation. Bug: 122556707 Test: manual test Change-Id: Ic27ebdd41a088f621a2885a9c2d1db7079ab5223
2019-01-24Add gsi_tool statusHoward Chen
The gsi_tool status command may show "running" : gsi is running "installed": gsi is installed "normal": Test: gsi_tool status Change-Id: Ib789b5ce90e9a60085fd629df56a610a84d66537
2019-01-24Check f2fs pin status before writes and before rebooting.David Anderson
Bug: 122556707 Test: manual test Change-Id: I3f551cc373d74e0977705e575f074953d6b4da5b
2019-01-17Add GSI installation error codes.David Anderson
It is useful to distinguish errors like "not enough free space" from "random syscall failed for unknown reason". To do this, let's introduce some error codes to IGsiService::startGsiInstall and setGsiBootable. Bug: 122556707 Test: manual test Change-Id: I227720129cb0d44599ae7d6f797a071431e0b057
2019-01-17Forbid installing GSIs within live GSIs.David Anderson
This is asking for trouble, and will be properly supported by the migration story rather than nesting images within nested images. Bug: 122556707 Test: manual test Change-Id: I2f2a0c2d737f49b8b8264ddcfd7e7985105c76d1
2019-01-17Add a progress bar API to gsid and use it in gsi_tool.David Anderson
This patch introduces a getInstallProgress API call to IGsiService. It is intended to be called while startGsiInstall or commitGsiChunkFromStream are in progress, and will return details about the current state. These details include the number of bytes left to process and which step of the function is blocking. Callers should invoke getInstallProgress on a separate thread. It is safe to invoke when no operations are in progress. The caller must take care to handle state transitions that are missed due to delays or sleep calls. For example, call #1 may return step A at 50%, and call #2 may return step B at 10%. It is the caller's responsibility to note that the previous step successfully completed. gsi_tool contains sample code for using this API. Bug: 122556707 Test: manual test Change-Id: I9af952368834bc3b5b5dadbbee6e91094d237cad
2019-01-16Allow disabling and re-enabling GSI.David Anderson
This change introduces two new commands to gsi_tool: enable and disable. Disable is similar to "wipe", in that it allows reboot back into the normal system image. However unlike "wipe" the GSI images will not be deleted on startup. The GSI install can then be re-enabled with the "enable" command. Unfortunately, this currently has a high probability of hitting a bug in F2FS where the file cannot be repinned. This can happen if the device has been used or rebooted extensively in between disabling and re-enabling the GSI. In addition, the semantics of the "install" command have changed. It will now attempt to re-use an existing userdata if one exists. To force a clean userdata, the --wipe parameter can be specified. To disable a GSI install: gsi_tool disable adb reboot To re-enable a GSI install: gsi_tool enable adb reboot To install a GSI and preserve userdata: gsi_tool install --gsi-size=SIZE < image To install a GSI and create a userdata if none exists: gsi_tool install --gsi-size=SIZE --userdata-size=SIZE < image To install a GSI and wipe userdata: gsi_tool install --gsi-size=SIZE --userdata-size=SIZE --wipe < image Bug: 122556707 Test: manual test Change-Id: Ia55ca930b0b7f6b2b97a6390568555b4166e2605
2019-01-14Fix platform-java build.David Anderson
Bug: 122556707 Test: m platform-java Change-Id: Ib0dcb332d049c2f240cd8ffd29a628ba04622191 Merged-In: Ib0dcb332d049c2f240cd8ffd29a628ba04622191 Signed-off-by: Sandeep Patil <sspatil@google.com>
2019-01-11Introduce a daemon (gsid) for managing GSI installs.David Anderson
Bug: 122556707 Test: manual test Change-Id: I96d833f77740e6b791992336e590dd1a089895c9
2019-01-08Introduce libgsi, gsi_tool.David Anderson
libgsi is a very small library to communicate critical gsi knowledge to init and fs_mgr, to avoid hardcoding path names and constants. gsi_tool is a shell wrapper to talk to gsid through binder. gsid (currently in vold, will be moved shortly) is the daemon to manage gsi installs. Bug: 121210348 Test: N/A Change-Id: I7942af56cb8e6ed69d28189bcf8d9806aa5e3e45