# zx_vcpu_read_state

## Summary

Read the state of a VCPU.

## Declaration

    #include <zircon/syscalls.h>

    zx_status_t zx_vcpu_read_state(zx_handle_t handle,
                                   uint32_t kind,
                                   void* buffer,
                                   size_t buffer_size);

## Description

`zx_vcpu_read_state()` reads the state of *handle* as specified by *kind* into
*buffer* . It is only valid to read the state of *handle* when execution has been
paused.

*kind* must be `ZX_VCPU_STATE`.

`zx_vcpu_read_state()` must be called on the same thread *handle* was created
on.

## Rights

*handle* must be of type `ZX_OBJ_TYPE_VCPU` and have `ZX_RIGHT_READ`.

## Return value

`zx_vcpu_read_state()` returns `ZX_OK` on success. On failure, an error value
is returned.

## Errors

`ZX_ERR_ACCESS_DENIED` *handle* does not have the `ZX_RIGHT_READ` right.

`ZX_ERR_BAD_HANDLE` *handle* is an invalid handle.

`ZX_ERR_BAD_STATE` *handle* is in a bad state, and state can not be read.

`ZX_ERR_INVALID_ARGS` *kind* does not name a known VCPU state, *buffer* is an
invalid pointer, or *buffer_size* does not match the expected size of *kind*.

`ZX_ERR_WRONG_TYPE` *handle* is not a handle to a VCPU.

## See also

- [`zx_guest_create()`](https://fuchsia.dev/reference/syscalls/guest_create)
- [`zx_guest_set_trap()`](https://fuchsia.dev/reference/syscalls/guest_set_trap)
- [`zx_vcpu_create()`](https://fuchsia.dev/reference/syscalls/vcpu_create)
- [`zx_vcpu_enter()`](https://fuchsia.dev/reference/syscalls/vcpu_enter)
- [`zx_vcpu_interrupt()`](https://fuchsia.dev/reference/syscalls/vcpu_interrupt)
- [`zx_vcpu_kick()`](https://fuchsia.dev/reference/syscalls/vcpu_kick)
- [`zx_vcpu_write_state()`](https://fuchsia.dev/reference/syscalls/vcpu_write_state)