|
|
54259b |
From 0de5dd3ac988386085c2cb600e8d122974ab3981 Mon Sep 17 00:00:00 2001
|
|
|
54259b |
From: Ryan McCabe <rmccabe@redhat.com>
|
|
|
54259b |
Date: Fri, 26 Oct 2012 18:14:45 -0400
|
|
|
54259b |
Subject: [PATCH] fence_virtd: Return success if a domain exists but is
|
|
|
54259b |
already off.
|
|
|
54259b |
|
|
|
54259b |
Return success if a domain exists but is already off.
|
|
|
54259b |
|
|
|
54259b |
Signed-off-by: Ryan McCabe <rmccabe@redhat.com>
|
|
|
54259b |
---
|
|
|
54259b |
server/checkpoint.c | 27 +++++++++++++++++----------
|
|
|
54259b |
server/libvirt.c | 28 ++++++++++++++++++----------
|
|
|
54259b |
2 files changed, 35 insertions(+), 20 deletions(-)
|
|
|
54259b |
|
|
|
54259b |
diff --git a/server/checkpoint.c b/server/checkpoint.c
|
|
|
54259b |
index 3ac7e6b..edf7728 100644
|
|
|
54259b |
--- a/server/checkpoint.c
|
|
|
54259b |
+++ b/server/checkpoint.c
|
|
|
54259b |
@@ -386,16 +386,18 @@ do_off(const char *vm_name)
|
|
|
54259b |
vdp = virDomainLookupByName(vp, vm_name);
|
|
|
54259b |
}
|
|
|
54259b |
|
|
|
54259b |
- if (!vdp ||
|
|
|
54259b |
- ((virDomainGetInfo(vdp, &vdi) == 0) &&
|
|
|
54259b |
- (vdi.state == VIR_DOMAIN_SHUTOFF))) {
|
|
|
54259b |
+ if (!vdp) {
|
|
|
54259b |
dbg_printf(2, "Nothing to do - domain does not exist\n");
|
|
|
54259b |
-
|
|
|
54259b |
- if (vdp)
|
|
|
54259b |
- virDomainFree(vdp);
|
|
|
54259b |
return 1;
|
|
|
54259b |
}
|
|
|
54259b |
|
|
|
54259b |
+ if (((virDomainGetInfo(vdp, &vdi) == 0) &&
|
|
|
54259b |
+ (vdi.state == VIR_DOMAIN_SHUTOFF))) {
|
|
|
54259b |
+ dbg_printf(2, "Nothing to do - domain is off\n");
|
|
|
54259b |
+ virDomainFree(vdp);
|
|
|
54259b |
+ return 0;
|
|
|
54259b |
+ }
|
|
|
54259b |
+
|
|
|
54259b |
syslog(LOG_NOTICE, "Destroying domain %s\n", vm_name);
|
|
|
54259b |
dbg_printf(2, "[OFF] Calling virDomainDestroy\n");
|
|
|
54259b |
ret = virDomainDestroy(vdp);
|
|
|
54259b |
@@ -446,15 +448,20 @@ do_reboot(const char *vm_name)
|
|
|
54259b |
vdp = virDomainLookupByName(vp, vm_name);
|
|
|
54259b |
}
|
|
|
54259b |
|
|
|
54259b |
- if (!vdp || ((virDomainGetInfo(vdp, &vdi) == 0) &&
|
|
|
54259b |
- (vdi.state == VIR_DOMAIN_SHUTOFF))) {
|
|
|
54259b |
+ if (!vdp) {
|
|
|
54259b |
dbg_printf(2, "[libvirt:REBOOT] Nothing to "
|
|
|
54259b |
"do - domain does not exist\n");
|
|
|
54259b |
- if (vdp)
|
|
|
54259b |
- virDomainFree(vdp);
|
|
|
54259b |
return 1;
|
|
|
54259b |
}
|
|
|
54259b |
|
|
|
54259b |
+ if (((virDomainGetInfo(vdp, &vdi) == 0) &&
|
|
|
54259b |
+ (vdi.state == VIR_DOMAIN_SHUTOFF))) {
|
|
|
54259b |
+ dbg_printf(2, "[libvirt:REBOOT] Nothing to "
|
|
|
54259b |
+ "do - domain is off\n");
|
|
|
54259b |
+ virDomainFree(vdp);
|
|
|
54259b |
+ return 0;
|
|
|
54259b |
+ }
|
|
|
54259b |
+
|
|
|
54259b |
syslog(LOG_NOTICE, "Rebooting domain %s\n", vm_name);
|
|
|
54259b |
printf("Rebooting domain %s...\n", vm_name);
|
|
|
54259b |
domain_desc = virDomainGetXMLDesc(vdp, 0);
|
|
|
54259b |
diff --git a/server/libvirt.c b/server/libvirt.c
|
|
|
54259b |
index 12bb8ad..1d1473b 100644
|
|
|
54259b |
--- a/server/libvirt.c
|
|
|
54259b |
+++ b/server/libvirt.c
|
|
|
54259b |
@@ -171,16 +171,18 @@ libvirt_off(const char *vm_name, const char *src,
|
|
|
54259b |
vdp = virDomainLookupByName(info->vp, vm_name);
|
|
|
54259b |
}
|
|
|
54259b |
|
|
|
54259b |
- if (!vdp ||
|
|
|
54259b |
- ((virDomainGetInfo(vdp, &vdi) == 0) &&
|
|
|
54259b |
- (vdi.state == VIR_DOMAIN_SHUTOFF))) {
|
|
|
54259b |
+ if (!vdp) {
|
|
|
54259b |
dbg_printf(2, "Nothing to do - domain does not exist\n");
|
|
|
54259b |
-
|
|
|
54259b |
- if (vdp)
|
|
|
54259b |
- virDomainFree(vdp);
|
|
|
54259b |
return 1;
|
|
|
54259b |
}
|
|
|
54259b |
|
|
|
54259b |
+ if (((virDomainGetInfo(vdp, &vdi) == 0) &&
|
|
|
54259b |
+ (vdi.state == VIR_DOMAIN_SHUTOFF))) {
|
|
|
54259b |
+ dbg_printf(2, "Nothing to do - domain is off\n");
|
|
|
54259b |
+ virDomainFree(vdp);
|
|
|
54259b |
+ return 0;
|
|
|
54259b |
+ }
|
|
|
54259b |
+
|
|
|
54259b |
syslog(LOG_NOTICE, "Destroying domain %s\n", vm_name);
|
|
|
54259b |
dbg_printf(2, "[OFF] Calling virDomainDestroy\n");
|
|
|
54259b |
ret = virDomainDestroy(vdp);
|
|
|
54259b |
@@ -314,15 +316,21 @@ libvirt_reboot(const char *vm_name, const char *src,
|
|
|
54259b |
vdp = virDomainLookupByName(info->vp, vm_name);
|
|
|
54259b |
}
|
|
|
54259b |
|
|
|
54259b |
- if (!vdp || ((virDomainGetInfo(vdp, &vdi) == 0) &&
|
|
|
54259b |
- (vdi.state == VIR_DOMAIN_SHUTOFF))) {
|
|
|
54259b |
+ if (!vdp) {
|
|
|
54259b |
dbg_printf(2, "[libvirt:REBOOT] Nothing to "
|
|
|
54259b |
"do - domain does not exist\n");
|
|
|
54259b |
- if (vdp)
|
|
|
54259b |
- virDomainFree(vdp);
|
|
|
54259b |
return 1;
|
|
|
54259b |
}
|
|
|
54259b |
|
|
|
54259b |
+ if (((virDomainGetInfo(vdp, &vdi) == 0) &&
|
|
|
54259b |
+ (vdi.state == VIR_DOMAIN_SHUTOFF))) {
|
|
|
54259b |
+ dbg_printf(2, "[libvirt:REBOOT] Nothing to "
|
|
|
54259b |
+ "do - domain is off\n");
|
|
|
54259b |
+ virDomainFree(vdp);
|
|
|
54259b |
+ return 0;
|
|
|
54259b |
+ }
|
|
|
54259b |
+
|
|
|
54259b |
+
|
|
|
54259b |
syslog(LOG_NOTICE, "Rebooting domain %s\n", vm_name);
|
|
|
54259b |
printf("Rebooting domain %s...\n", vm_name);
|
|
|
54259b |
domain_desc = virDomainGetXMLDesc(vdp, 0);
|
|
|
54259b |
--
|
|
|
54259b |
1.7.11.7
|
|
|
54259b |
|