chore(libvirt): manage websockify in libvirt hooks, include in build

main
Tsu-ba-me 2 years ago
parent a7b2f7c9e1
commit de23f6e4d4
  1. 2
      Makefile.am
  2. 9
      libvirt/Makefile.am
  3. 29
      libvirt/hooks/qemu.d/ws

@ -20,7 +20,7 @@ TARFILES = $(PACKAGE_NAME)-$(VERSION).tar.bz2 \
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = Anvil cgi-bin html journald.conf.d man ocf \
SUBDIRS = Anvil cgi-bin html journald.conf.d libvirt man ocf \
pxe scancore-agents scripts share striker-ui \
striker-ui-api tools units

@ -0,0 +1,9 @@
MAINTAINERCLEANFILES = Makefile.in
libvirtdir = ${sysconfdir}/libvirt
hooksdir = ${libvirtdir}/hooks
qemuddir = ${hooksdir}/qemu.d
dist_qemud_SCRIPTS = \
hooks/qemu.d/ws

@ -0,0 +1,29 @@
#!/bin/bash
echo "wsargs=$@"
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" || "$operation" == "stopped" ]]
then
ws_open_flag=""
ws_port_flag=""
if [[ "$operation" == "started" ]]
then
ws_open_flag="--open"
# libvirt hooks cannot call anything related to libvirt, i.e.,
# virsh because a deadlock will happen.
server_vnc_port=$(grep "<graphics.*type=['\"]vnc['\"]" - | grep -oPm1 "(?<=port=['\"])\d+")
ws_port_flag="--server-vnc-port ${server_vnc_port}"
fi
ws_command="striker-manage-vnc-pipes -vv --server ${guest_name} ${ws_port_flag} --component ws ${ws_open_flag}"
echo "wscmd=$ws_command"
$ws_command
fi
Loading…
Cancel
Save