| 741 | }; |
| 742 | |
| 743 | gboolean |
| 744 | init_quorum_connection(gboolean(*dispatch) (unsigned long long, gboolean), |
| 745 | void (*destroy) (gpointer)) |
| 746 | { |
| 747 | int rc = -1; |
| 748 | int fd = 0; |
| 749 | int quorate = 0; |
| 750 | uint32_t quorum_type = 0; |
| 751 | struct mainloop_fd_callbacks quorum_fd_callbacks; |
| 752 | quorum_fd_callbacks.dispatch = pcmk_quorum_dispatch; |
| 753 | quorum_fd_callbacks.destroy = destroy; |
| 754 | |
| 755 | crm_debug("Configuring Pacemaker to obtain quorum from Corosync"); |
| 756 | |
| 757 | rc = quorum_initialize(&pcmk_quorum_handle, &quorum_callbacks, &quorum_type); |
| 758 | if (rc != CS_OK) { |
| 759 | crm_err("Could not connect to the Quorum API: %d\n", rc); |
| 760 | goto bail; |
| 761 | |
| 762 | } else if (quorum_type != QUORUM_SET) { |
| 763 | crm_err("Corosync quorum is not configured\n"); |
| 764 | goto bail; |
| 765 | } |
| 766 | |
| 767 | rc = quorum_getquorate(pcmk_quorum_handle, &quorate); |
| 768 | if (rc != CS_OK) { |
| 769 | crm_err("Could not obtain the current Quorum API state: %d\n", rc); |
| 770 | goto bail; |
| 771 | } |
| 772 | |
| 773 | crm_notice("Quorum %s", quorate ? "acquired" : "lost"); |
| 774 | quorum_app_callback = dispatch; |
| 775 | crm_have_quorum = quorate; |
| 776 | |
| 777 | rc = quorum_trackstart(pcmk_quorum_handle, CS_TRACK_CHANGES | CS_TRACK_CURRENT); |
| 778 | if (rc != CS_OK) { |
| 779 | crm_err("Could not setup Quorum API notifications: %d\n", rc); |
| 780 | goto bail; |
| 781 | } |
| 782 | |
| 783 | rc = quorum_fd_get(pcmk_quorum_handle, &fd); |
| 784 | if (rc != CS_OK) { |
| 785 | crm_err("Could not obtain the Quorum API connection: %d\n", rc); |
| 786 | goto bail; |
| 787 | } |
| 788 | |
| 789 | mainloop_add_fd("quorum", G_PRIORITY_HIGH, fd, dispatch, &quorum_fd_callbacks); |
| 790 | |
| 791 | corosync_initialize_nodelist(NULL, FALSE, NULL); |
| 792 | |
| 793 | bail: |
| 794 | if (rc != CS_OK) { |
| 795 | quorum_finalize(pcmk_quorum_handle); |
| 796 | return FALSE; |
| 797 | } |
| 798 | return TRUE; |
| 799 | } |
| 800 |
nothing calls this directly
no test coverage detected