diff --git a/client/main.c b/client/main.c index e5f1f77..5d261bd 100644 --- a/client/main.c +++ b/client/main.c @@ -127,6 +127,7 @@ main(int argc, char **argv) } switch(ret) { + case RESP_OFF: case 0: break; case RESP_FAIL: diff --git a/include/xvm.h b/include/xvm.h index 9bb47bf..e90f6d1 100644 --- a/include/xvm.h +++ b/include/xvm.h @@ -115,7 +115,8 @@ typedef struct __attribute__((packed)) _serial_fense_resp { #define RESP_SUCCESS 0 #define RESP_FAIL 1 -#define RESP_PERM 2 +#define RESP_OFF 2 +#define RESP_PERM 3 #define RESP_HOSTLIST 253 diff --git a/server/checkpoint.c b/server/checkpoint.c index d9e719e..97e2867 100644 --- a/server/checkpoint.c +++ b/server/checkpoint.c @@ -527,7 +527,7 @@ do_real_work(void *data, size_t len, uint32_t nodeid, uint32_t seqno) struct ckpt_fence_req *req = data; struct ckpt_fence_req reply; uint32_t owner; - int ret; + int ret = 1; memcpy(&reply, req, sizeof(reply)); @@ -539,6 +539,9 @@ do_real_work(void *data, size_t len, uint32_t nodeid, uint32_t seqno) if (ret == 2) { return; } + if (ret == 1) { + ret = RESP_OFF; + } break; case FENCE_OFF: ret = cluster_virt_status(req->vm_name, &owner); @@ -558,6 +561,8 @@ do_real_work(void *data, size_t len, uint32_t nodeid, uint32_t seqno) break; } + reply.response = ret; + cpg_send_reply(&reply, sizeof(reply), nodeid, seqno); } diff --git a/server/libvirt-qpid.cpp b/server/libvirt-qpid.cpp index c82a2df..593f47c 100644 --- a/server/libvirt-qpid.cpp +++ b/server/libvirt-qpid.cpp @@ -29,6 +29,7 @@ #include #include #include "uuid-test.h" +#include #include @@ -147,13 +148,14 @@ do_lq_request(struct lq_info *info, const char *vm_name, } } - if (!found) { - return 1; - } - Object::AttributeMap attrs; MethodResponse result; + if (!found) { + result.code = 1; + goto out; + } + vm_state = domain->attrString("state").c_str(); std::cout << domain->attrString(property) << " " @@ -163,11 +165,16 @@ do_lq_request(struct lq_info *info, const char *vm_name, !strcmp( vm_state, "idle" ) || !strcmp( vm_state, "paused" ) || !strcmp( vm_state, "no state" ) ) { - i = 1; + i = RESP_OFF; } else { i = 0; } + if (!strcasecmp(action, "status")) { + result.code = i; + goto out; + } + result.code = 1; if (!strcasecmp(action, "destroy") && !i) { std::cout << "Domain is inactive; nothing to do" << std::endl; @@ -239,7 +246,7 @@ lq_status(const char *vm_name, void *priv) VALIDATE(priv); printf("[libvirt-qpid] STATUS operation on %s\n", vm_name); - return 1; + return do_lq_request((lq_info *)priv, vm_name, "destroy"); } diff --git a/server/libvirt.c b/server/libvirt.c index 11cccb1..7645d00 100644 --- a/server/libvirt.c +++ b/server/libvirt.c @@ -282,7 +282,7 @@ libvirt_status(const char *vm_name, void *priv) if (!vdp || ((virDomainGetInfo(vdp, &vdi) == 0) && (vdi.state == VIR_DOMAIN_SHUTOFF))) { - ret = 1; + ret = RESP_OFF; } if (vdp)