1// Copyright (C) 2018 The Android Open Source Project 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15// Note that if you add/remove methods in this file you must update 16// the metrics sql as well by running ./android/scripts/gen-grpc-sql.py 17// 18// Please group deleted methods in a block including the date (MM/DD/YY) 19// it was removed. This enables us to easily keep metrics around after removal 20// 21// List of deleted methods 22// rpc iWasDeleted (03/12/12) 23// ... 24syntax = "proto3"; 25 26package android.emulation.control; 27 28import "google/protobuf/empty.proto"; 29import "snapshot.proto"; 30 31option java_multiple_files = true; 32option java_package = "com.android.emulator.control"; 33option objc_class_prefix = "AEC"; 34 35// The SnapshotService enables you to list, insert, store, and retrieve 36// snapshots. 37// 38// Currently there are two types of snapshots: 39// 40// - Local (default): These are snapshots that are created locally. They are 41// stored internally inside qcow2 files and are very efficient. These are 42// the snapshots usually created by interacting with the UI. 43// 44// - Remote: These are snapshots that have been exported at a certain point. 45// an exported snapshot is normalized (completely self contained) and 46// can be imported into an emulator with a similar hardware configuration. 47// 48// Currently the emulator has limited support for importing snapshots: 49// - Once an imported snapshot has been loaded into an emulator it is no longer 50// possible to create new snapshots. 51// - The hardware configuration of the emulator your are pushing a snapshot to 52// must match (or be very similar) to the one you pulled the snapshot from. 53// 54// For example do not expect to be able to restore a snapshot on created on an 55// Intel cpu on an AMD cpu. 56service SnapshotService { 57 // Lists all the snapshots, filtered by the given query, that are stored 58 // locally for the currently running avd. This includes all the snapshots that 59 // were imported (pushed) into this emulator. 60 // 61 // Returns a list of snapshot_id's and associated details that describes 62 // the hardware configuration, logical name, etc of the snapshot. 63 rpc ListSnapshots(SnapshotFilter) returns (SnapshotList) {} 64 65 // Pulls down the snapshot stored inside the AVD as a tar.gz/tar stream 66 // This will normalize the snapshot, all relevant data to push a snapshot 67 // into a similar emulator will be placed inside the tar file. 68 // 69 // Pulling down a snapshot will pause the emulator until the snapshots 70 // are rebased and ready for exporting. Once the snapshot is rebased 71 // the emulator will continue and downloading should commence. 72 // 73 // Note that pulling .gz stream is slow. 74 // 75 // You must provide the snapshot_id and (desired) format. 76 // 77 // If SnapshotPackage.path is set, the gRPC service will directly write the 78 // exported snapshot to SnapshotPackage.path without streaming, which is 79 // usually significantly faster. It would require emulator to have direct 80 // access to SnapshotPackage.path, which usually means it can only be used 81 // when pulling from a local emulator. 82 rpc PullSnapshot(SnapshotPackage) returns (stream SnapshotPackage) {} 83 84 // Push a tar.gz stream contain the snapshot. The tar file should 85 // be a snapshot that was exported through the PullSnapshot in the past. 86 // The emulator will try to import the snapshot. The hardware configuration 87 // of the current emulator should match the one used for pulling. 88 // 89 // A detailed description of the snapshot (emulator_snapshot.Snapshot) 90 // is stored in the snapshot.pb file inside the tar. 91 // 92 // You must provide the snapshot_id and format in the first message. 93 // Will return success and a possible error message when a failure occurs. 94 // 95 // If SnapshotPackage.path is set, the gRPC service will directly unzip the 96 // exported snapshot from SnapshotPackage.path without streaming, which is 97 // usually significantly faster. It would require emulator to have direct 98 // access to SnapshotPackage.path, which usually means it can only be used 99 // when pushing to a local emulator. 100 rpc PushSnapshot(stream SnapshotPackage) returns (SnapshotPackage) {} 101 102 // Loads the given snapshot inside the emulator and activates it. 103 // The device will be in the state as it was when the snapshot was created. 104 // 105 // You will no longer be able to call Save if this was an imported 106 // snapshot that was pushed into this emulator. 107 // 108 // You must provide the snapshot_id to indicate which snapshot to load 109 // Will return success and a possible error message when a failure occurs. 110 rpc LoadSnapshot(SnapshotPackage) returns (SnapshotPackage) {} 111 112 // Creates as a snapshot of the current state of the emulator. 113 // You can only save a snapshot if you never activated (Load) an imported 114 // snapshot (Push). 115 // 116 // For example: 117 // - PushSnapshot("some_snap.tar.gz"); 118 // - LoadSnapshot("some_snap"); 119 // - SaveSnapshot("same_newer_snap"); // <--- Will currently fail. 120 // 121 // You can provide the snapshot_id to indicate the name used for storing. 122 // Will return success and a possible error message when a failure occurs. 123 rpc SaveSnapshot(SnapshotPackage) returns (SnapshotPackage) {} 124 125 // Deletes the snapshot with the given snapshot_id from the avd. 126 // 127 // You must provide the snapshot_id to indicate which snapshot to delete. 128 // Will return success and a possible error message when a failure occurs. 129 rpc DeleteSnapshot(SnapshotPackage) returns (SnapshotPackage) {} 130 131 // Tracks the given process for automated snapshot creation in case of 132 // assert failures. 133 // 134 // Will return success and a possible error message when a failure occurs. 135 // The snapshot_id field will contain the name of the snapshot that 136 // will be created. The pid field will contain the process id that is 137 // being tracked. 138 rpc TrackProcess(IceboxTarget) returns (IceboxTarget) {} 139} 140 141// Sets options for SnapshotService. Used for both request and response messages. 142message SnapshotPackage { 143 enum Format { 144 TARGZ = 0; 145 TAR = 1; 146 DIRECTORY = 2; 147 } 148 // The identifier to the snapshot, only required for request messages. For 149 // streaming service, only used in the first stream message of a gRPC call 150 // (would be ignored in consequent stream messages of the same call). 151 string snapshot_id = 1; 152 153 // A stream of bytes. Encoded as a tar (possibly gzipped) file pendinf on the 154 // value of format. 155 bytes payload = 2; 156 157 // [response only] status fields, usually indicates end of transmission. 158 bool success = 3; 159 bytes err = 4; 160 161 // [request only] Format of the payload. Only used in request messages. For 162 // streaming service, only used in the first stream message of a gRPC call 163 // (would be ignored in consequent stream messages of the same call). 164 Format format = 5; 165 166 // [request only] Path to the snapshot package file. Only used in request 167 // messages. 168 // 169 // When set in a request, the PullSnapshot/PushSnapshot operation will directly 170 // write/read the exported snapshot in path without streaming, which is usually 171 // significantly faster. It would require emulator to have direct access to 172 // path, which usually means it can only be used with a local emulator. 173 string path = 6; 174} 175 176// A snapshot filter can be used to filter the results produced by ListSnapshots 177message SnapshotFilter { 178 enum LoadStatus { 179 // Only return compatible snapshots 180 CompatibleOnly = 0; 181 182 // Return all snapshots. 183 All = 1; 184 } 185 186 // Filter snapshots by load status. 187 LoadStatus statusFilter = 1; 188} 189 190// Provides detailed information regarding the snapshot. 191message SnapshotDetails { 192 193 enum LoadStatus { 194 // The emulator believes that the snapshot is compatible with the emulator 195 // that provided this information. The emulator will attempt to load this 196 // snapshot when requested. 197 // 198 // A snapshot is usually compatible when the following statements are true: 199 // - The snapshot was taken by the current emulator version. i.e. 200 // emulator_build_id in the details field matches the build_id of the 201 // emulator that provided this information. 202 // 203 // - The snapshot was taken on the current running machine, and no hardware 204 // changes have taken place between taking and loading the snapshot. 205 // 206 // - The avd configuration has not changed between when this snapshot was 207 // taken and when the snapshot was loaded. 208 // 209 // - The system images on which the avd is based have not changed. 210 Compatible = 0; 211 212 // The emulator will not allow loading of the snapshot, as it deems the 213 // snapshot to be incompatible. Loading of snapshots can be forced by 214 // launching the emulator with the feature "AllowSnapshotMigration" enabled. 215 Incompatible = 1; 216 217 // This snapshot was successfully loaded in the emulator, and was used at 218 // the starting point of the current running emulator. The following holds: 219 // 220 // A loaded snapshot is a compatible snapshot 221 // There is at most one snapshot_id that is in the "Loaded" state 222 Loaded = 2; 223 } 224 225 // The id of this snapshot. Use this id to load/delete/pull the 226 // snapshot. 227 string snapshot_id = 1; 228 229 // Detailed information about this snapshot. This contains a detailed 230 // hardware description of the snapshot. These details are the same 231 // as the "snapshot.pb" file found in an exported snapshot. 232 // Look at the import file for a detailed description of the available 233 // fields. 234 emulator_snapshot.Snapshot details = 2; 235 236 // Provides information about the ability to restore this snapshot. 237 LoadStatus status = 3; 238 239 // The size of the folder that stores required information to load a snapshot. 240 uint64 size = 4; 241} 242 243// A List of on snapshot details. 244message SnapshotList { repeated SnapshotDetails snapshots = 1; } 245 246message IceboxTarget { 247 // This is the process id to attach to, if this value is not set (0) 248 // The process name will be used instead. 249 int64 pid = 1; 250 251 // The process name to attach to if any, if this is not set the pid will 252 // be used. This is usually the application name of your application under 253 // test, that is passed in to the am instrument command. It is likely 254 // what you will find in your AndroidManifest.xml 255 string package_name = 2; 256 257 // The name of the snapshot that icebox will create if a snapshot is 258 // generated. 259 string snapshot_id = 3; 260 261 // [Output Only] True if icebox failed to track the given target. 262 bool failed = 4; 263 264 // [Output Only] Detailed error message that might provide more information. 265 string err = 5; 266 267 // Maximum number of snapshots the emulator can take during one Icebox run. 268 // Set to -1 for unlimited number of snapshots. 269 int32 max_snapshot_number = 6; 270} 271 272// List of deleted methods: 273// 274