From 6f373b75f1f980305e425002a0a6726b22f1801f Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 5 Jun 2019 15:04:00 -0700 Subject: Introduce a library to contain gsid's image creation logic. README.md contains a full explanation. GsiInstaller's logic will be removed in a follow-up CL. Bug: 134536978 Test: libgsi_image_test gtest Change-Id: I76f273e06bd8633c6c16e3f3c76ade28e59efe6f --- aidl/android/gsi/IGsiService.aidl | 10 ++++++ aidl/android/gsi/IImageManager.aidl | 63 +++++++++++++++++++++++++++++++++++++ aidl/android/gsi/MappedImage.aidl | 23 ++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 aidl/android/gsi/IImageManager.aidl create mode 100644 aidl/android/gsi/MappedImage.aidl (limited to 'aidl') diff --git a/aidl/android/gsi/IGsiService.aidl b/aidl/android/gsi/IGsiService.aidl index 4ffdf62..4468eb7 100644 --- a/aidl/android/gsi/IGsiService.aidl +++ b/aidl/android/gsi/IGsiService.aidl @@ -18,6 +18,7 @@ package android.gsi; import android.gsi.GsiInstallParams; import android.gsi.GsiProgress; +import android.gsi.IImageManager; import android.os.ParcelFileDescriptor; /** {@hide} */ @@ -181,4 +182,13 @@ interface IGsiService { * @return 0 on success, an error code on failure. */ int wipeGsiUserdata(); + + /** + * Open a handle to an IImageManager for the given metadata and data storage paths. + * + * @param prefix A prefix used to organize images. The data path will become + * /data/gsi/{prefix} and the metadata path will become + * /metadata/gsi/{prefix}. + */ + IImageManager openImageManager(@utf8InCpp String prefix); } diff --git a/aidl/android/gsi/IImageManager.aidl b/aidl/android/gsi/IImageManager.aidl new file mode 100644 index 0000000..526b08a --- /dev/null +++ b/aidl/android/gsi/IImageManager.aidl @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.gsi; + +import android.gsi.MappedImage; + +/** {@hide} */ +interface IImageManager { + /** + * Create an image that can be mapped as a block device. + * + * This call will fail if running a GSI. + * + * @param name Image name. If the image already exists, the call will fail. + * @param size Image size, in bytes. If too large, or not enough space is + * free, the call will fail. + * @param readonly If readonly, MapBackingImage() will configure the device as + * readonly. + * @return True on success, false otherwise. + */ + void createBackingImage(@utf8InCpp String name, long size, boolean readonly); + + /** + * Delete an image created with createBackingImage. + * + * @param name Image name as passed to createBackingImage(). + * @return True on success, false otherwise. + */ + void deleteBackingImage(@utf8InCpp String name); + + /** + * Map an image, created with createBackingImage, such that it is accessible as a + * block device. + * + * @param name Image name as passed to createBackingImage(). + * @param timeout_ms Time to wait for a valid mapping, in milliseconds. This must be more + * than zero; 10 seconds is recommended. + * @param mapping Information about the newly mapped block device. + */ + void mapImageDevice(@utf8InCpp String name, int timeout_ms, out MappedImage mapping); + + /** + * Unmap a block device previously mapped with mapBackingImage. This step is necessary before + * calling deleteBackingImage. + * + * @param name Image name as passed to createBackingImage(). + */ + void unmapImageDevice(@utf8InCpp String name); +} diff --git a/aidl/android/gsi/MappedImage.aidl b/aidl/android/gsi/MappedImage.aidl new file mode 100644 index 0000000..aa5af0d --- /dev/null +++ b/aidl/android/gsi/MappedImage.aidl @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.gsi; + +/** {@hide} */ +parcelable MappedImage { + /* Path to the block device. */ + @utf8InCpp String path; +} -- cgit v1.2.3