<!--
{
  "availability" : [
    "macOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Virtualization",
  "identifier" : "/documentation/Virtualization/VZCustomVirtioDeviceDelegate",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Virtualization"
    ],
    "preciseIdentifier" : "c:objc(pl)VZCustomVirtioDeviceDelegate"
  },
  "title" : "VZCustomVirtioDeviceDelegate"
}
-->

# VZCustomVirtioDeviceDelegate

A delegate protocol that defines the methods you implement to respond to the life cycle events of a custom Virtio device.

```
protocol VZCustomVirtioDeviceDelegate : NSObjectProtocol
```

## Overview

When you define these methods and set the delegate on your [`VZCustomVirtioDevice`](/documentation/Virtualization/VZCustomVirtioDevice) instance, the Virtualization
framework notifies you when the Virtio device stops, pauses, resumes, or resets by the invocation of the respective methods defined
here, and you can provide code to handle each of these situations.

The framework considers the device to be ready when the guest driver sets `DRIVER_OK`, indicated by the invocation of
[`customVirtioDeviceDidAcceptDriverOk(_:)`](/documentation/Virtualization/VZCustomVirtioDeviceDelegate/customVirtioDeviceDidAcceptDriverOk(_:)), this means that the guest
driver is set up and ready to drive the device, and the device is ready to process any device operations.

Virtqueue (Virtio queue) notifications trigger device operations, then the framework invokes the [`customVirtioDevice(_:didReceiveNotificationFor:)`](/documentation/Virtualization/VZCustomVirtioDeviceDelegate/customVirtioDevice(_:didReceiveNotificationFor:))
method when the guest driver sends the device a virtqueue notification, and you can provide code to handle the
notification.

## Topics

### Instance Methods

[`func customVirtioDevice(VZCustomVirtioDevice, didReceiveNotificationFor: VZVirtioQueue)`](/documentation/Virtualization/VZCustomVirtioDeviceDelegate/customVirtioDevice(_:didReceiveNotificationFor:))

The method the framework calls when the device receives a virtqueue (Virtio queue) notification from the guest.

[`func customVirtioDeviceDidAcceptDriverOk(VZCustomVirtioDevice)`](/documentation/Virtualization/VZCustomVirtioDeviceDelegate/customVirtioDeviceDidAcceptDriverOk(_:))

The method the framework calls when the device and driver successfully complete Virtio negotiation.

[`func customVirtioDeviceSaveState(forRestore: VZCustomVirtioDevice) -> Data?`](/documentation/Virtualization/VZCustomVirtioDeviceDelegate/customVirtioDeviceSaveState(forRestore:))

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

[`func customVirtioDeviceShouldRestore(VZCustomVirtioDevice, saveState: Data) -> Bool`](/documentation/Virtualization/VZCustomVirtioDeviceDelegate/customVirtioDeviceShouldRestore(_:saveState:))

The method the framework calls when a device restores its state.

[`func customVirtioDeviceWillPause(VZCustomVirtioDevice)`](/documentation/Virtualization/VZCustomVirtioDeviceDelegate/customVirtioDeviceWillPause(_:))

The method the framework calls when a device pauses.

[`func customVirtioDeviceWillReset(VZCustomVirtioDevice)`](/documentation/Virtualization/VZCustomVirtioDeviceDelegate/customVirtioDeviceWillReset(_:))

The method the framework calls when a device resets.

[`func customVirtioDeviceWillResume(VZCustomVirtioDevice)`](/documentation/Virtualization/VZCustomVirtioDeviceDelegate/customVirtioDeviceWillResume(_:))

The method the framework calls when a device resumes.

[`func customVirtioDeviceWillStop(VZCustomVirtioDevice)`](/documentation/Virtualization/VZCustomVirtioDeviceDelegate/customVirtioDeviceWillStop(_:))

The method the framework calls when a device will be stopped.

## See Also

[`class VZCustomVirtioDevice`](/documentation/Virtualization/VZCustomVirtioDevice)

An interface that represents a custom Virtio device that you provide the implementation for.

## Relationships

### Inherits From

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

---

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)