forked from altcloud/fence-virt
fence_virtd: Return success if a domain exists but is already off.
Return success if a domain exists but is already off. Signed-off-by: Ryan McCabe <rmccabe@redhat.com>
This commit is contained in:
parent
fc7d6bf464
commit
0de5dd3ac9
@ -386,16 +386,18 @@ do_off(const char *vm_name)
|
||||
vdp = virDomainLookupByName(vp, vm_name);
|
||||
}
|
||||
|
||||
if (!vdp ||
|
||||
((virDomainGetInfo(vdp, &vdi) == 0) &&
|
||||
(vdi.state == VIR_DOMAIN_SHUTOFF))) {
|
||||
if (!vdp) {
|
||||
dbg_printf(2, "Nothing to do - domain does not exist\n");
|
||||
|
||||
if (vdp)
|
||||
virDomainFree(vdp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (((virDomainGetInfo(vdp, &vdi) == 0) &&
|
||||
(vdi.state == VIR_DOMAIN_SHUTOFF))) {
|
||||
dbg_printf(2, "Nothing to do - domain is off\n");
|
||||
virDomainFree(vdp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
syslog(LOG_NOTICE, "Destroying domain %s\n", vm_name);
|
||||
dbg_printf(2, "[OFF] Calling virDomainDestroy\n");
|
||||
ret = virDomainDestroy(vdp);
|
||||
@ -446,15 +448,20 @@ do_reboot(const char *vm_name)
|
||||
vdp = virDomainLookupByName(vp, vm_name);
|
||||
}
|
||||
|
||||
if (!vdp || ((virDomainGetInfo(vdp, &vdi) == 0) &&
|
||||
(vdi.state == VIR_DOMAIN_SHUTOFF))) {
|
||||
if (!vdp) {
|
||||
dbg_printf(2, "[libvirt:REBOOT] Nothing to "
|
||||
"do - domain does not exist\n");
|
||||
if (vdp)
|
||||
virDomainFree(vdp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (((virDomainGetInfo(vdp, &vdi) == 0) &&
|
||||
(vdi.state == VIR_DOMAIN_SHUTOFF))) {
|
||||
dbg_printf(2, "[libvirt:REBOOT] Nothing to "
|
||||
"do - domain is off\n");
|
||||
virDomainFree(vdp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
syslog(LOG_NOTICE, "Rebooting domain %s\n", vm_name);
|
||||
printf("Rebooting domain %s...\n", vm_name);
|
||||
domain_desc = virDomainGetXMLDesc(vdp, 0);
|
||||
|
@ -171,16 +171,18 @@ libvirt_off(const char *vm_name, const char *src,
|
||||
vdp = virDomainLookupByName(info->vp, vm_name);
|
||||
}
|
||||
|
||||
if (!vdp ||
|
||||
((virDomainGetInfo(vdp, &vdi) == 0) &&
|
||||
(vdi.state == VIR_DOMAIN_SHUTOFF))) {
|
||||
if (!vdp) {
|
||||
dbg_printf(2, "Nothing to do - domain does not exist\n");
|
||||
|
||||
if (vdp)
|
||||
virDomainFree(vdp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (((virDomainGetInfo(vdp, &vdi) == 0) &&
|
||||
(vdi.state == VIR_DOMAIN_SHUTOFF))) {
|
||||
dbg_printf(2, "Nothing to do - domain is off\n");
|
||||
virDomainFree(vdp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
syslog(LOG_NOTICE, "Destroying domain %s\n", vm_name);
|
||||
dbg_printf(2, "[OFF] Calling virDomainDestroy\n");
|
||||
ret = virDomainDestroy(vdp);
|
||||
@ -314,15 +316,21 @@ libvirt_reboot(const char *vm_name, const char *src,
|
||||
vdp = virDomainLookupByName(info->vp, vm_name);
|
||||
}
|
||||
|
||||
if (!vdp || ((virDomainGetInfo(vdp, &vdi) == 0) &&
|
||||
(vdi.state == VIR_DOMAIN_SHUTOFF))) {
|
||||
if (!vdp) {
|
||||
dbg_printf(2, "[libvirt:REBOOT] Nothing to "
|
||||
"do - domain does not exist\n");
|
||||
if (vdp)
|
||||
virDomainFree(vdp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (((virDomainGetInfo(vdp, &vdi) == 0) &&
|
||||
(vdi.state == VIR_DOMAIN_SHUTOFF))) {
|
||||
dbg_printf(2, "[libvirt:REBOOT] Nothing to "
|
||||
"do - domain is off\n");
|
||||
virDomainFree(vdp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
syslog(LOG_NOTICE, "Rebooting domain %s\n", vm_name);
|
||||
printf("Rebooting domain %s...\n", vm_name);
|
||||
domain_desc = virDomainGetXMLDesc(vdp, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user