---
title: "hv_vcpu_create(_:_:_:)"
framework: hypervisor
role: symbol
role_heading: Function
path: "hypervisor/hv_vcpu_create(_:_:_:)"
---

# hv_vcpu_create(_:_:_:)

Creates a vCPU instance for the current thread.

## Declaration

```swift
func hv_vcpu_create(_ vcpu: UnsafeMutablePointer<hv_vcpu_t>, _ exit: UnsafeMutablePointer<UnsafeMutablePointer<hv_vcpu_exit_t>?>, _ config: hv_vcpu_config_t?) -> hv_return_t
```

## Parameters

- `vcpu`: An argument that the hypervisor populates with the instance of a vCPU on a successful return.
- `exit`: The pointer to the vCPU exit information. The function doc://com.apple.hypervisor/documentation/Hypervisor/hv_vcpu_run(_:) updates this structure on return. Apple silicon only.
- `config`: The configuration of the vCPU or nil for a default configuration. Apple silicon only.

## Return Value

Return Value HV_SUCCESS if the operation was successful, otherwise an error code specified in hv_return_t.

## Discussion

Discussion Intel-based Mac computers have different parameters: flags: The vCPU creation flag. The available flags are HV_VCPU_ACCEL_RDPMC, HV_VCPU_TSC_RELATIVE, and HV_VCPU_DEFAULT. The default is HV_VCPU_DEFAULT. note: Using the HV_VCPU_TSC_RELATIVE flag enables use of the Time-Stamp Counter (TSC) relative offset capabilities, but disables the default TSC for vCPUs that you create with this flag.

## See Also

### Creation and destruction

- [hv_vm_get_max_vcpu_count(_:)](hypervisor/hv_vm_get_max_vcpu_count(_:).md)
- [hv_vcpu_destroy(_:)](hypervisor/hv_vcpu_destroy(_:).md)
- [hv_vcpu_t](hypervisor/hv_vcpu_t.md)
