Local modifications to ClusterLabs/Anvil by Alteeve
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.1 KiB

#!/bin/bash
#
# Note: libvirt hook scripts execute with uid=0(root) gid=0(root) for all
# operations, i.e., started, stopped.
#
function log {
echo "$(date -Is):libvirt_hooks:ws; $@" >>/var/log/anvil.log;
}
log "wsargs=$@"
domain_xml=$(</dev/stdin)
guest_name="$1"
operation="$2"
# Operation migrate will:
# 1. Trigger migrate->prepare->start->started operation on the destination host.
# 2. Trigger stopped->release operations on the source host.
if [[ ! $operation =~ ^(started|stopped)$ ]]
then
exit
fi
ws_open_flag=""
ws_port_flag=""
if [[ $operation == "started" ]]
then
ws_open_flag="--open"
# Cannot call $ virsh vncdisplay... because libvirt hooks
# cannot call anything related to libvirt, i.e., virsh, because
# a deadlock will happen.
server_vnc_port=$( grep "<graphics.*type=['\"]vnc['\"]" <<<$domain_xml | grep -oPm1 "(?<=port=['\"])\d+" )
ws_port_flag="--server-vnc-port ${server_vnc_port}"
fi
ws_command_args="--server \"$guest_name\" $ws_port_flag $ws_open_flag"
log "wscmd=$ws_command_args"
striker-manage-vnc-pipes $ws_command_args &