---
name: "ibv_open_device"
section: "3"
platform: "linux"
package: "rdma-core"
version: "65.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/ibv_open_device"
---

# ibv\_open\_device(3)

open and close an RDMA device context

## NAME

ibv\_open\_device, ibv\_close\_device - open and close an RDMA device context

## SYNOPSIS

```
#include <infiniband/verbs.h>

struct ibv_context *ibv_open_device(struct ibv_device *device);

int ibv_close_device(struct ibv_context *context);
```

## DESCRIPTION

**ibv\_open\_device()** opens the device *device* and creates a context for further use.

**ibv\_close\_device()** closes the device context *context.*

## RETURN VALUE

**ibv\_open\_device()** returns a pointer to the allocated device context, or NULL if the request fails, and errno is set to indicate the reason.

**ibv\_close\_device()** returns 0 on success, -1 on failure.

## NOTES

**ibv\_close\_device()** does not release all the resources allocated using context *context.* To avoid resource leaks, the user should release all associated resources before closing a context.

Setting the environment variable \*\*RDMAV\_ALLOW\_DISASSOC\_DESTROY\*\* tells the library to relate an EIO from destroy commands as a success as the kernel resources were already released. This comes to prevent memory leakage in the user space area upon device disassociation. Applications using this flag cannot call ibv\_get\_cq\_event or ibv\_get\_async\_event concurrently with any call to an object destruction function.

## SEE ALSO

[**ibv\_get\_device\_list**(3)](/ibv_get_device_list/3.md), [**ibv\_query\_device**(3)](/ibv_query_device/3.md), [**ibv\_query\_port**(3)](/ibv_query_port/3.md), [**ibv\_query\_gid**(3)](/ibv_query_gid/3.md), [**ibv\_query\_pkey**(3)](/ibv_query_pkey/3.md)

## AUTHORS

- Dotan Barak \<dotanba@gmail.com\>
