---
name: "quorum_model_initialize"
section: "3"
platform: "linux"
package: "libquorum-dev"
version: "3.1.9-2+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/quorum_model_initialize"
---

# quorum\_model\_initialize(3)

Create a new connection to the Quorum service

## NAME

quorum\_model\_initialize - Create a new connection to the Quorum service

## SYNOPSIS

**#include \<corosync/quorum.h\>**

**cs\_error\_t quorum\_model\_initialize(quorum\_handle\_t \****handle***, quorum\_model\_t** *model***, quorum\_model\_data\_t \****model\_data***, uint32\_t \****quorum\_type***,void \****context***);**

## DESCRIPTION

The **quorum\_model\_initialize** function is an enhanced way to initialize a connection to the quorum API.

Each application may have several connections to the quorum API.  Each application uses the *handle* argument to uniquely identify the connection.  The *handle* argument is then used in other function calls to identify the connection to be used for communication with the quorum service.

The *model* is used to explicitly choose set of callbacks and internal parameters. Currently two models *QUORUM\_MODEL\_V0* and *QUORUM\_MODEL\_V1* are defined. *QUORUM\_MODEL\_V0* exists only for compatibility reasons with **[quorum\_initialize(3)](/quorum_initialize/3.md)** function and it is not recommended to be used as an argument for **[quorum\_model\_initialize(3)](/quorum_model_initialize/3.md).**

The Following description is focused only on *QUORUM\_MODEL\_V1* model.

Every time the voting configuration changes (eg a node joins or leave the cluster) or the quorum status changes the quorum callback is called. The quorum callback function is described by the following type definitions:

```
typedef void (*quorum_v1_quorum_notification_fn_t) (
        quorum_handle_t handle,
        uint32_t quorate,
        struct quorum_ring_id ring_id,
        uint32_t member_list_entries,
        const uint32_t *member_list
);
```

Also every time when membership configuration changes (eg a node joins or leave the cluster) the node list change callback is called before the quorum callback. The node list change callback function is described by the following type definitions:

```
typedef void (*quorum_v1_nodelist_notification_fn_t) (
        quorum_handle_t handle,
        struct quorum_ring_id ring_id,
        uint32_t member_list_entries,
        const uint32_t *member_list,
        uint32_t joined_list_entries,
        const uint32_t *joined_list,
        uint32_t left_list_entries,
        const uint32_t *left_list
);
```

The *model\_data* argument for *QUORUM\_MODEL\_V1* is of the type:

```
typedef struct {
        quorum_model_t model;
        quorum_v1_quorum_notification_fn_t quorum_notify_fn;
        quorum_v1_nodelist_notification_fn_t nodelist_notify_fn;
} quorum_model_v1_data_t;
```

It's not required (nor recommended) to set *model* field in the structure. It is also fine if only some of notification callbacks are used (only these events will be delivered then).

The *quorum\_type* argument is set to:

```
#define QUORUM_FREE     0
#define QUORUM_SET      1
```

*QUORUM\_FREE* value means that no quorum algorithm is loaded and that no callbacks will take place.

*QUORUM\_SET* value means that one quorum algorithm is configured and that callbacks will take place.

The *context* argument sets context same way as **[quorum\_context\_set(3)](/quorum_context_set/3.md).**

When a configuration change occurs, the callback is called from the **[quorum\_dispatch(3)](/quorum_dispatch/3.md)** function.

## RETURN VALUE

This call returns the CS\_OK value if successful, otherwise an error is returned.

## ERRORS

**CS\_ERR\_TRY\_AGAIN** Resource temporarily unavailable

**CS\_ERR\_INVALID\_PARAM** Invalid argument

**CS\_ERR\_ACCESS** Permission denied

**CS\_ERR\_LIBRARY** The connection failed

**CS\_ERR\_INTERRUPT** System call interrupted by a signal

**CS\_ERR\_NOT\_SUPPORTED** The requested protocol/functionality not supported

**CS\_ERR\_MESSAGE\_ERROR** Incorrect auth message received

**CS\_ERR\_NO\_MEMORY** Not enough memory to complete the requested task

## SEE ALSO

[**quorum\_overview**(3)](/quorum_overview/3.md), [**quorum\_initialize**(3)](/quorum_initialize/3.md), [**quorum\_finalize**(3)](/quorum_finalize/3.md), [**quorum\_getquorate**(3)](/quorum_getquorate/3.md), [**quorum\_trackstart**(3)](/quorum_trackstart/3.md), [**quorum\_trackstop**(3)](/quorum_trackstop/3.md), [**quorum\_fd\_get**(3)](/quorum_fd_get/3.md), [**quorum\_dispatch**(3)](/quorum_dispatch/3.md), [**quorum\_context\_set**(3)](/quorum_context_set/3.md), [**quorum\_context\_get**(3)](/quorum_context_get/3.md)
