|
|
aba6ec |
diff --git a/heartbeat/VirtualDomain b/heartbeat/VirtualDomain
|
|
|
aba6ec |
index 6f80981..b159c2c 100755
|
|
|
aba6ec |
--- a/heartbeat/VirtualDomain
|
|
|
aba6ec |
+++ b/heartbeat/VirtualDomain
|
|
|
aba6ec |
@@ -65,10 +65,10 @@ for this virtual domain.
|
|
|
aba6ec |
<longdesc lang="en">
|
|
|
aba6ec |
Hypervisor URI to connect to. See the libvirt documentation for
|
|
|
aba6ec |
details on supported URI formats. The default is system dependent.
|
|
|
aba6ec |
-Determine your systems default uri by running 'virsh --quiet uri'
|
|
|
aba6ec |
+Determine the system's default uri by running 'virsh --quiet uri'.
|
|
|
aba6ec |
</longdesc>
|
|
|
aba6ec |
<shortdesc lang="en">Hypervisor URI</shortdesc>
|
|
|
aba6ec |
-<content type="string" />
|
|
|
aba6ec |
+<content type="string"/>
|
|
|
aba6ec |
</parameter>
|
|
|
aba6ec |
|
|
|
aba6ec |
<parameter name="force_stop" unique="0" required="0">
|
|
|
aba6ec |
@@ -202,15 +202,44 @@ update_utilization() {
|
|
|
aba6ec |
fi
|
|
|
aba6ec |
}
|
|
|
aba6ec |
|
|
|
aba6ec |
+# attempt to check domain status outside of libvirt using the emulator process
|
|
|
aba6ec |
+pid_status()
|
|
|
aba6ec |
+{
|
|
|
aba6ec |
+ local rc=$OCF_ERR_GENERIC
|
|
|
aba6ec |
+ local emulator
|
|
|
aba6ec |
+
|
|
|
aba6ec |
+ emulator=$(basename $(egrep '[[:space:]]*<emulator>.*</emulator>[[:space:]]*$' ${OCF_RESKEY_config} | sed -e 's/[[:space:]]*<emulator>\(.*\)<\/emulator>[[:space:]]*$/\1/'))
|
|
|
aba6ec |
+
|
|
|
aba6ec |
+ case "$emulator" in
|
|
|
aba6ec |
+ qemu-kvm|qemu-system-*)
|
|
|
aba6ec |
+ ps awx | grep -E "[q]emu-(kvm|system).*-name $DOMAIN_NAME " > /dev/null 2>&1
|
|
|
aba6ec |
+ if [ $? -eq 0 ]; then
|
|
|
aba6ec |
+ # domain exists and is running
|
|
|
aba6ec |
+ ocf_log debug "Virtual domain $DOMAIN_NAME is currently running."
|
|
|
aba6ec |
+ rc=$OCF_SUCCESS
|
|
|
aba6ec |
+ else
|
|
|
aba6ec |
+ # domain pid does not exist on local machine
|
|
|
aba6ec |
+ ocf_log debug "Virtual domain $DOMAIN_NAME is currently not running."
|
|
|
aba6ec |
+ rc=$OCF_NOT_RUNNING
|
|
|
aba6ec |
+ fi
|
|
|
aba6ec |
+ ;;
|
|
|
aba6ec |
+ # This can be expanded to check for additional emulators
|
|
|
aba6ec |
+ *)
|
|
|
aba6ec |
+ ;;
|
|
|
aba6ec |
+ esac
|
|
|
aba6ec |
+
|
|
|
aba6ec |
+ return $rc
|
|
|
aba6ec |
+}
|
|
|
aba6ec |
+
|
|
|
aba6ec |
VirtualDomain_Status() {
|
|
|
aba6ec |
local try=0
|
|
|
aba6ec |
rc=$OCF_ERR_GENERIC
|
|
|
aba6ec |
status="no state"
|
|
|
aba6ec |
while [ "$status" = "no state" ]; do
|
|
|
aba6ec |
try=$(($try + 1 ))
|
|
|
aba6ec |
- status="`virsh $VIRSH_OPTIONS domstate $DOMAIN_NAME 2>&1`"
|
|
|
aba6ec |
+ status=$(virsh $VIRSH_OPTIONS domstate $DOMAIN_NAME 2>&1|tr 'A-Z' 'a-z')
|
|
|
aba6ec |
case "$status" in
|
|
|
aba6ec |
- *"error:"*"Domain not found"*|"shut off")
|
|
|
aba6ec |
+ *"error:"*"domain not found"*|"shut off")
|
|
|
aba6ec |
# shut off: domain is defined, but not started, will not happen if
|
|
|
aba6ec |
# domain is created but not defined
|
|
|
aba6ec |
# Domain not found: domain is not defined and thus not started
|
|
|
aba6ec |
@@ -226,7 +255,7 @@ VirtualDomain_Status() {
|
|
|
aba6ec |
ocf_log debug "Virtual domain $DOMAIN_NAME is currently $status."
|
|
|
aba6ec |
rc=$OCF_SUCCESS
|
|
|
aba6ec |
;;
|
|
|
aba6ec |
- ""|*"Failed to reconnect to the hypervisor"*|"no state")
|
|
|
aba6ec |
+ ""|*"failed to "*"connect to the hypervisor"*|"no state")
|
|
|
aba6ec |
# Empty string may be returned when virsh does not
|
|
|
aba6ec |
# receive a reply from libvirtd.
|
|
|
aba6ec |
# "no state" may occur when the domain is currently
|
|
|
aba6ec |
@@ -240,6 +269,14 @@ VirtualDomain_Status() {
|
|
|
aba6ec |
# the domain if necessary.
|
|
|
aba6ec |
ocf_log error "Virtual domain $DOMAIN_NAME has no state during stop operation, bailing out."
|
|
|
aba6ec |
return $OCF_ERR_GENERIC;
|
|
|
aba6ec |
+ elif [ "$__OCF_ACTION" = "monitor" ]; then
|
|
|
aba6ec |
+ pid_status
|
|
|
aba6ec |
+ rc=$?
|
|
|
aba6ec |
+ if [ $rc -ne $OCF_ERR_GENERIC ]; then
|
|
|
aba6ec |
+ # we've successfully determined the domains status outside of libvirt
|
|
|
aba6ec |
+ return $rc
|
|
|
aba6ec |
+ fi
|
|
|
aba6ec |
+
|
|
|
aba6ec |
else
|
|
|
aba6ec |
# During all other actions, we just wait and try
|
|
|
aba6ec |
# again, relying on the CRM/LRM to time us out if
|
|
|
aba6ec |
@@ -312,11 +349,11 @@ force_stop()
|
|
|
aba6ec |
local status=0
|
|
|
aba6ec |
|
|
|
aba6ec |
ocf_log info "Issuing forced shutdown (destroy) request for domain ${DOMAIN_NAME}."
|
|
|
aba6ec |
- out=$(virsh $VIRSH_OPTIONS destroy ${DOMAIN_NAME} 2>&1)
|
|
|
aba6ec |
+ out=$(virsh $VIRSH_OPTIONS destroy ${DOMAIN_NAME} 2>&1|tr 'A-Z' 'a-z')
|
|
|
aba6ec |
ex=$?
|
|
|
aba6ec |
echo >&2 "$out"
|
|
|
aba6ec |
case $ex$out in
|
|
|
aba6ec |
- *"error:"*"domain is not running"*|*"error:"*"Domain not found"*)
|
|
|
aba6ec |
+ *"error:"*"domain is not running"*|*"error:"*"domain not found"*)
|
|
|
aba6ec |
: ;; # unexpected path to the intended outcome, all is well
|
|
|
aba6ec |
[!0]*)
|
|
|
aba6ec |
return $OCF_ERR_GENERIC ;;
|
|
|
aba6ec |
@@ -544,8 +581,8 @@ case $1 in
|
|
|
aba6ec |
;;
|
|
|
aba6ec |
esac
|
|
|
aba6ec |
|
|
|
aba6ec |
-OCF_RESKEY_hypervisor_default="$(virsh --quiet uri)"
|
|
|
aba6ec |
-: ${OCF_RESKEY_hypervisor=${OCF_RESKEY_hypervisor_default}}
|
|
|
aba6ec |
+# Grab the virsh uri default, but only if hypervisor isn't set
|
|
|
aba6ec |
+: ${OCF_RESKEY_hypervisor=$(virsh --quiet uri)}
|
|
|
aba6ec |
|
|
|
aba6ec |
# Set options to be passed to virsh:
|
|
|
aba6ec |
VIRSH_OPTIONS="--connect=${OCF_RESKEY_hypervisor} --quiet"
|