---
title: "hv_vmx_vcpu_write_vmcs(_:_:_:)"
framework: Hypervisor
role: symbol
role_heading: Function
platforms: [macOS 10.10+]
path: "hypervisor/hv_vmx_vcpu_write_vmcs(_:_:_:)"
---

# hv_vmx_vcpu_write_vmcs(_:_:_:)

Sets the value of a virtual machine control structure (VMCS) field of a vCPU.

## Declaration

```swift
func hv_vmx_vcpu_write_vmcs(_ vcpu: hv_vcpuid_t, _ field: UInt32, _ value: UInt64) -> hv_return_t
```

## Parameters

- `vcpu`: The ID of the vCPU.
- `field`: The ID of the VMCS field. For a list of possible values, see Virtual Machine Control Structure (VMCS) Field IDs.
- `value`: The new value for field in the VMCS.

## Return Value

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

## Discussion

Discussion important: This function must be called by the owning thread.

## See Also

### Field management

- [Virtual Machine Control Structure (VMCS) Field IDs](hypervisor/virtual-machine-control-structure-vmcs-field-ids.md)
- [hv_vmx_vcpu_read_vmcs(_:_:_:)](hypervisor/hv_vmx_vcpu_read_vmcs(_:_:_:).md)
- [hv_vmx_vcpu_get_cap_write_vmcs(_:_:_:_:)](hypervisor/hv_vmx_vcpu_get_cap_write_vmcs(_:_:_:_:).md)
- [hv_vmx_vcpu_set_apic_address(_:_:)](hypervisor/hv_vmx_vcpu_set_apic_address(_:_:).md)
- [Virtual Machine control structure (VMCS) Field IDs](hypervisor/1469436-virtual_machine_control_structur-enum.md)
