<!--
{
  "availability" : [
    "macOS: 14.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Virtualization",
  "identifier" : "/documentation/Virtualization/VZVirtualMachine/saveMachineStateTo(url:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Virtualization"
    ],
    "preciseIdentifier" : "c:objc(cs)VZVirtualMachine(im)saveMachineStateToURL:completionHandler:"
  },
  "title" : "saveMachineStateTo(url:completionHandler:)"
}
-->

# saveMachineStateTo(url:completionHandler:)

Saves the state of a VM.

```
func saveMachineStateTo(url saveFileURL: URL, completionHandler: @escaping ((any Error)?) -> Void)
```

## Parameters

`saveFileURL`

An <doc://com.apple.documentation/documentation/Foundation/NSURL> that indicates the location where the framework writes the saved state of the VM.

`completionHandler`

A block the framework calls after successfully saving the VM or upon returning an error.

    The error parameter passed to the block is     `nil`     if the save was successful.

## Discussion

Use this method to save a paused VM to a file. You can use the contents of this file later to restore the state of the paused VM.

This call fails if the VM isn’t in a paused state or if the Virtualization framework can’t save the VM. If this method fails, the framework returns an error, and the VM state remains unchanged.

If this method is successful, the framework writes the file, and the VM state remains unchanged.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)