---
title: "customVirtioDeviceSaveState(forRestore:)"
framework: virtualization
role: symbol
role_heading: Instance Method
path: "virtualization/vzcustomvirtiodevicedelegate/customvirtiodevicesavestate(forrestore:)"
---

# customVirtioDeviceSaveState(forRestore:)

The method the framework calls when a device needs to save its state.

## Declaration

```swift
optional func customVirtioDeviceSaveState(forRestore device: VZCustomVirtioDevice) -> Data?
```

## Parameters

- `device`: The device invoking the delegate method.

## Discussion

Discussion Return the state data to save in an NSData object. If there is no state to save, return an empty NSData object ([NSData data]). If you return nil from this method, the save operation fails.
