From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12871 invoked by alias); 27 Mar 2009 14:47:01 -0000 Received: (qmail 12827 invoked by alias); 27 Mar 2009 14:46:59 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS X-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS X-Spam-Check-By: sourceware.org X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bastion.fedora.phx.redhat.com Subject: cluster: RHEL5 - fence: Make fence_xvmd try two methods on reboot To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: cluster.git X-Git-Refname: refs/heads/RHEL5 X-Git-Reftype: branch X-Git-Oldrev: b90358e8b77d0dfbfed4335757feda76d0b677a9 X-Git-Newrev: c635f24c2fe4e07dd40c27dc7c44629b6ddbf045 From: Lon Hohberger Message-Id: <20090327142619.D237A120150@lists.fedorahosted.org> Date: Fri, 27 Mar 2009 14:47:00 -0000 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 Mailing-List: contact cluster-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cluster-cvs-owner@sourceware.org X-SW-Source: 2009-q1/txt/msg00923.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=c635f24c2fe4e07dd40c27dc7c44629b6ddbf045 Commit: c635f24c2fe4e07dd40c27dc7c44629b6ddbf045 Parent: b90358e8b77d0dfbfed4335757feda76d0b677a9 Author: Lon Hohberger AuthorDate: Tue Mar 24 14:24:15 2009 -0400 Committer: Lon Hohberger CommitterDate: Fri Mar 27 10:25:09 2009 -0400 fence: Make fence_xvmd try two methods on reboot rhbz480178 Signed-off-by: Lon Hohberger --- fence/agents/xvm/fence_xvmd.c | 71 +++++++++++++++++++++++++++++----------- 1 files changed, 51 insertions(+), 20 deletions(-) diff --git a/fence/agents/xvm/fence_xvmd.c b/fence/agents/xvm/fence_xvmd.c index 1d496d2..1c22039 100644 --- a/fence/agents/xvm/fence_xvmd.c +++ b/fence/agents/xvm/fence_xvmd.c @@ -291,20 +291,7 @@ do_fence_request_tcp(fence_req_t *req, fence_auth_type_t auth, domain_desc = virDomainGetXMLDesc(vdp, 0); - if (domain_desc) { - dbg_printf(3, "[[ XML Domain Info ]]\n"); - dbg_printf(3, "%s\n[[ XML END ]]\n", domain_desc); - - sz = 0; - if (cleanup_xml(domain_desc, - &domain_desc_sanitized, &sz) == 0) { - free(domain_desc); - domain_desc = domain_desc_sanitized; - } - - dbg_printf(3, "[[ XML Domain Info (modified) ]]\n"); - dbg_printf(3, "%s\n[[ XML END ]]\n", domain_desc); - } else { + if (!domain_desc) { printf("Failed getting domain description from " "libvirt\n"); } @@ -322,14 +309,58 @@ do_fence_request_tcp(fence_req_t *req, fence_auth_type_t auth, if (response) { printf("Domain still exists; fencing failed\n"); - } else if (domain_desc) { - /* Recreate the domain if possible */ - /* Success */ - dbg_printf(2, "Calling virDomainCreateLinux()...\n"); - virDomainCreateLinux(vp, domain_desc, 0); + if (domain_desc) + free(domain_desc); + break; + + } + + if (!domain_desc) + break; + + dbg_printf(3, "[[ XML Domain Info ]]\n"); + dbg_printf(3, "%s\n[[ XML END ]]\n", domain_desc); + dbg_printf(2, "Calling virDomainCreateLinux()...\n"); + + /* + * Due to multiple versions of libvirt in RHEL5, + * we have to try this both ways: + * - first, assume they have the most current + * libvirt for RHEL (0.3.3+). + * - Next, assume they have the older release + * where the block needed to be removed to + * ensure a proper "start" + * + * Testing of the most recent libvirt shows that + * virDomainCreateLinux() returns NULL even if + * it succeeds, though. + */ + vdp = virDomainCreateLinux(vp, domain_desc, 0); + if (vdp != NULL) { free(domain_desc); + break; } - break; + + dbg_printf(1, "That didn't work. Trying older " + "libvirt workaround...\n"); + sz = 0; + if (cleanup_xml(domain_desc, + &domain_desc_sanitized, &sz) == 0) { + free(domain_desc); + domain_desc = domain_desc_sanitized; + } + + dbg_printf(3, "[[ XML Domain Info (modified) ]]\n"); + dbg_printf(3, "%s\n[[ XML END ]]\n", domain_desc); + /* Recreate the domain if possible */ + /* Success */ + vdp = virDomainCreateLinux(vp, domain_desc, 0); + if (vdp == NULL) + dbg_printf(1, "Unable to restart domain.\n"); + + free(domain_desc); + + break; /* case FENCE_REBOOT */ } dbg_printf(3, "Sending response to caller...\n");