[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-03-26 UTC。"],[],[],null,["# Cuttlefish: Snapshot and restore\n\nAndroid 15 introduces how to take a snapshot and\nrestore a snapshot of a Cuttlefish virtual device. Taking a snapshot of a\nCuttlefish device lets you save the state of the device in an image on disk.\nYou can then restore the snapshot to bring up a Cuttlefish device to the\npreviously saved state.\n\nYou can use snapshots in various automated or manual workflows. When\nperforming a procedure that modifies the device, you can take a snapshot of\nthe device to ensure you can restore the device back to a specified state.\nFor example, when running test suites that modify the state of the device\nand can potentially cause issues or instabilities in the following tests,\nyou can take a snapshot so you can restore the device to a saved state after\na test, ensuring that subsequent tests run cleanly.\n\nAnother example workflow where snapshots are useful is when testing the\nbehavior of an app. When testing the behavior of an app based on a set of\nactions, you can take a snapshot in between actions as the app is running\nto let you restore to that snapshot without having to restart from the\nbeginning. For example, if launching a game has a long bringup time, you\ncan take a snapshot after reaching the main menu so you can restore the\ndevice to that state, skipping the bringup time.\n\nTake snapshot of a Cuttlefish device\n------------------------------------\n\n| **Note:** Snapshots are only supported on x86_64 platforms.\n\nWhen taking a snapshot of a device, the Cuttlefish device must be suspended\nto make sure the Cuttlefish device is in a stable state. When the device\nis suspended, all vCPUs and devices are stopped, and all buffers push\ntheir state to the VM. The snapshot then saves the vCPU state, memory,\nand device state to disk at a specified destination folder.\n\nVirtiosFS isn't supported and must be disabled when taking a snapshot. To\ndisable VirtioFS, pass the argument\n`--enable_virtiofs=false` when running `cvd create` or `cvd start`.\n\nOnly the SwiftShader (`guest_swiftshader`) GPU mode is supported for\nsnapshots. Other [accelerated graphics modes](/docs/devices/cuttlefish/gpu)\naren't supported.\n\nThe following steps describes the process of launching a Cuttlefish device\nand taking a snapshot.\n\n1. Launch a device, while disabling VirtioFS. (You can then use the device.)\n\n cvd create --enable_virtiofs=false --gpu_mode=guest_swiftshader\n\n2. Take a snapshot by running `cvd snapshot_take` with the following flags:\n\n - `--force`: If a folder exists at the specified snapshot path, this\n flag ensures that the existing folder is deleted, and a new folder\n is created at the snapshot path containing the snapshot\n\n - `--auto_suspend`: Suspends the device before the snapshot is taken and\n resumes the device after the snapshot is taken.\n\n - `--snapshot_path`: The specified path where a new folder is created\n with the snapshot.\n\n cvd snapshot_take --force --auto_suspend \\\n --snapshot_path=\u003cvar translate=\"no\"\u003ePATH\u003c/var\u003e\n\nRestore a Cuttlefish device\n---------------------------\n\nWhen restoring a Cuttlefish device snapshot, the Cuttlefish instance for\nwhich the snapshot was taken must be stopped. If the instance is already\nstopped, no further action is required and the snapshot can be restored.\n\nTo restore a snapshot of a Cuttlefish device, launch a device with `cvd create`\nand include the snapshot path. If the base instance number of the Cuttlefish\ndevice on which the snapshot was taken is different from the base instance\nnumber of the current Cuttlefish instance, pass that base instance\nnumber using the `--base_instance_num` flag. \n\n cvd create --snapshot_path=\u003cvar translate=\"no\"\u003ePATH\u003c/var\u003e \\\n --base_instance_num=\u003cvar translate=\"no\"\u003eID\u003c/var\u003e\n\nSuspend a Cuttlefish device\n---------------------------\n\nYou can suspend a Cuttlefish device without taking a snapshot (no disk space\nis used for saving the state). To suspend a Cuttlefish device, run: \n\n cvd suspend\n\nResume a Cuttlefish device\n--------------------------\n\nTo resume a suspended Cuttlefish device, run: \n\n cvd resume\n\nValidate the Snapshot/Restore feature\n-------------------------------------\n\nThe Snapshot/Restore feature can be validated by running the following test: \n\n atest SnapshotTest"]]