From mboxrd@z Thu Jan 1 00:00:00 1970 From: lhh@sourceware.org Date: 19 Nov 2007 17:28:33 -0000 Subject: [Cluster-devel] cluster/fence/agents/xvm fence_xvmd.c Message-ID: <20071119172833.14937.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit CVSROOT: /cvs/cluster Module name: cluster Branch: RHEL5 Changes by: lhh at sourceware.org 2007-11-19 17:28:33 Modified files: fence/agents/xvm: fence_xvmd.c Log message: Ancillary NOCLUSTER mode fixes for fence_xvmd Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/agents/xvm/fence_xvmd.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.4.2.9&r2=1.4.2.10 --- cluster/fence/agents/xvm/fence_xvmd.c 2007/11/19 17:03:27 1.4.2.9 +++ cluster/fence/agents/xvm/fence_xvmd.c 2007/11/19 17:28:33 1.4.2.10 @@ -224,6 +224,7 @@ { int fd = -1, ret = -1; virDomainPtr vdp; + virDomainInfo vdi; char response = 1; char *domain_desc, *domain_desc_sanitized; size_t sz; @@ -247,13 +248,18 @@ break; case FENCE_OFF: printf("Destroying domain %s...\n", (char *)req->domain); - if (!vdp && (flags & F_NOCLUSTER)) { - dbg_printf(2, "[OFF + NOCLUSTER] Nothing to do - " - "domain does not exist\n"); - response = 0; - break; + if (flags & F_NOCLUSTER) { + if (!vdp || + ((virDomainGetInfo(vdp, &vdi) == 0) && + (vdi.state == VIR_DOMAIN_SHUTOFF))) { + dbg_printf(2, "[NOCLUSTER] Nothing to " + "do - domain does not exist\n"); + response = 0; + break; + } } + dbg_printf(2, "[OFF] Calling virDomainDestroy\n"); ret = virDomainDestroy(vdp); if (ret < 0) { @@ -271,11 +277,15 @@ printf("Rebooting domain %s...\n", (char *)req->domain); - if (!vdp && (flags & F_NOCLUSTER)) { - dbg_printf(2, "[REBOOT + NOCLUSTER] Nothing to do - " - "domain does not exist\n"); - response = 0; - break; + if (flags & F_NOCLUSTER) { + if (!vdp || + ((virDomainGetInfo(vdp, &vdi) == 0) && + (vdi.state == VIR_DOMAIN_SHUTOFF))) { + dbg_printf(2, "[NOCLUSTER] Nothing to " + "do - domain does not exist\n"); + response = 0; + break; + } } domain_desc = virDomainGetXMLDesc(vdp, 0); @@ -320,7 +330,7 @@ } break; } - + dbg_printf(3, "Sending response to caller...\n"); if (write(fd, &response, 1) < 0) { perror("write");