From: lhh@sourceware.org <lhh@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] cluster/fence/agents/xvm fence_xvmd.c
Date: 1 Dec 2006 22:14:18 -0000 [thread overview]
Message-ID: <20061201221418.31761.qmail@sourceware.org> (raw)
CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL5
Changes by: lhh at sourceware.org 2006-12-01 22:14:17
Modified files:
fence/agents/xvm: fence_xvmd.c
Log message:
Handle 0.1.9 case of libvirt returning a virDomainPtr + state for a VM that doesn't exist (vm state == VIR_DOMAIN_SHUTOFF)
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.1&r2=1.4.2.2
--- cluster/fence/agents/xvm/fence_xvmd.c 2006/11/13 16:14:06 1.4.2.1
+++ cluster/fence/agents/xvm/fence_xvmd.c 2006/12/01 22:14:17 1.4.2.2
@@ -207,6 +207,54 @@
}
+static inline int
+wait_domain(fence_req_t *req, virConnectPtr vp, int timeout)
+{
+ int tries = 0;
+ int response = 1;
+ virDomainPtr vdp;
+ virDomainInfo di;
+
+ if (!(vdp = get_domain(req, vp)))
+ return 0;
+
+ /* Check domain liveliness. If the domain is still here,
+ we return failure, and the client must then retry */
+ /* XXX On the xen 3.0.4 API, we will be able to guarantee
+ synchronous virDomainDestroy, so this check will not
+ be necessary */
+ do {
+ sleep(1);
+ vdp = get_domain(req, vp);
+ if (!vdp) {
+ dprintf(2, "Domain no longer exists\n");
+ response = 0;
+ break;
+ }
+
+ memset(&di, 0, sizeof(di));
+ virDomainGetInfo(vdp, &di);
+ virDomainFree(vdp);
+
+ if (di.state == VIR_DOMAIN_SHUTOFF) {
+ dprintf(2, "Domain has been shut off\n");
+ response = 0;
+ break;
+ }
+
+ dprintf(4, "Domain still exists (state %d) after %d seconds\n",
+ di.state, tries);
+
+ if (++tries >= timeout)
+ break;
+ } while (1);
+
+ return response;
+}
+
+
+
+
int
do_fence_request_tcp(fence_req_t *req, fence_auth_type_t auth,
void *key, size_t key_len, virConnectPtr vp)
@@ -235,24 +283,18 @@
break;
case FENCE_OFF:
printf("Destroying domain %s...\n", (char *)req->domain);
+
+ dprintf(2, "[OFF] Calling virDomainDestroy\n");
ret = virDomainDestroy(vdp);
if (ret < 0) {
- /* raise_error(vp); */
+ printf("virDomainDestroy() failed: %d\n", ret);
break;
- } else {
- sleep(1);
}
- /* Check domain liveliness. If the domain is still here,
- we return failure, and the client must then retry */
- /* XXX On the xen 3.0.4 API, we will be able to guarantee
- synchronous virDomainDestroy, so this check will not
- be necessary */
- vdp = get_domain(req, vp);
- if (!vdp) {
- response = 0; /* Success! */
- } else {
- virDomainFree(vdp);
+ response = wait_domain(req, vp, 15);
+
+ if (response) {
+ printf("Domain still exists; fencing failed\n");
}
break;
case FENCE_REBOOT:
@@ -271,42 +313,26 @@
"libvirt\n");
}
- dprintf(2, "Calling virDomainDestroy\n");
+ dprintf(2, "[REBOOT] Calling virDomainDestroy\n");
ret = virDomainDestroy(vdp);
if (ret < 0) {
printf("virDomainDestroy() failed: %d\n", ret);
if (domain_desc)
free(domain_desc);
break;
- } else {
- /* Give it time for the operation to complete */
- sleep(3);
}
- /* Check domain liveliness. If the domain is still here,
- we return failure, and the client must then retry */
- /* XXX On the xen 3.0.4 API, we will be able to guarantee
- synchronous virDomainDestroy, so this check will not
- be necessary */
- vdp = get_domain(req, vp);
- if (!vdp) {
- dprintf(2, "Domain no longer exists\n");
- response = 0; /* Success! */
- } else {
- printf("Domain still exists; fencing failed\n");
- virDomainFree(vdp);
- ret = 1; /* Failed to kill it */
- }
+ response = wait_domain(req, vp, 15);
- /* Recreate the domain if possible */
- if (ret == 0 && domain_desc) {
+ if (response) {
+ printf("Domain still exists; fencing failed\n");
+ } else if (domain_desc) {
+ /* Recreate the domain if possible */
/* Success */
dprintf(2, "Calling virDomainCreateLinux()...\n");
virDomainCreateLinux(vp, domain_desc, 0);
- }
-
- if (domain_desc)
free(domain_desc);
+ }
break;
}
@@ -646,17 +672,14 @@
int mc_sock;
char key[4096];
int key_len = 0;
- char *my_options = "dfi:a:p:C:c:k:u?hVX";
+ char *my_options = "dfi:a:p:C:c:k:u?hV";
void *h;
args_init(&args);
args_get_getopt(argc, argv, my_options, &args);
- if (!(args.flags & F_NOCCS)) {
- args_get_ccs(my_options, &args);
- }
args_finalize(&args);
if (args.debug > 0) {
- dset(args.debug);
+ _debug = args.debug;
args_print(&args);
}
next reply other threads:[~2006-12-01 22:14 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-01 22:14 lhh [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-12-14 14:49 [Cluster-devel] cluster/fence/agents/xvm fence_xvmd.c fabbione
2007-11-19 17:28 lhh
2007-10-17 18:29 lhh
2007-10-17 18:21 lhh
2007-09-11 13:44 pcaulfield
2007-01-10 20:31 lhh
2007-01-10 20:30 lhh
2007-01-10 20:25 lhh
2006-12-04 17:26 lhh
2006-12-04 17:26 lhh
2006-12-04 17:25 lhh
2006-12-01 22:13 lhh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20061201221418.31761.qmail@sourceware.org \
--to=lhh@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.