From bcfc5703d3856c1ce92d4d4ff5f47e3c2f605b6d Mon Sep 17 00:00:00 2001 From: Ryan McCabe <rmccabe@redhat.com> Date: Sun, 28 May 2017 22:23:28 -0400 Subject: [PATCH] fence_virtd: Implment hostlist for the cpg backend Implment hostlist for the cpg backend. Signed-off-by: Ryan McCabe <rmccabe@redhat.com> --- server/cpg-virt.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/server/cpg-virt.c b/server/cpg-virt.c index 904f108..fdf5991 100644 --- a/server/cpg-virt.c +++ b/server/cpg-virt.c @@ -443,9 +443,21 @@ cpg_virt_reboot(const char *vm_name, const char *src, static int cpg_virt_hostlist(hostlist_callback callback, void *arg, void *priv) { + struct cpg_info *info = (struct cpg_info *) priv; + int i; + VALIDATE(priv); printf("[cpg-virt] HOSTLIST operation\n"); + pthread_mutex_lock(&local_vm_list_lock); + update_local_vms(info); + for (i = 0 ; i < local_vm_list->vm_count ; i++) { + callback(local_vm_list->vm_states[i].v_name, + local_vm_list->vm_states[i].v_uuid, + local_vm_list->vm_states[i].v_state.s_state, arg); + } + pthread_mutex_unlock(&local_vm_list_lock); + return 1; } @@ -593,10 +605,10 @@ cpg_virt_shutdown(backend_context_t c) if (virConnectClose(info->vp[i]) < 0) ret = -errno; } + free(info->vp); free(info); - return ret; }