Add script hook for VNC server to support mDNS/DNS-SD
PATCH 1/1 Add script hook for VNC server to support mDNS/DNS-SD
Modern DNS clients (like vinagre) support mDNS/DNS-SD discovery of VNC servers. VNC servers like Vino link directly against libavahi to publish themselves. Fitting libavahi into QEMU though would be pretty hairy and not as flexible as simply calling out to a helper script and using the avahi utilities.
This patch adds support for a ',script=/patch/to/script' option to the existing
-vnc option. It also includes an example script which uses avahi-publish the
presence of the QEMU instance. Care has been taken to ensure that errors are silenced if either bash or avahi aren't present and the user hasn't explicitly specified ',script='.
qemu-doc.texi +15 -0
@@ -486,6 +486,21 @@ path following this option specifies where the x509 certificates are to be loaded from. See the @ref{vnc_security} section for details on generating certificates. +@item script=@var{/path/to/script} + +Launch a script when the VNC server is started. The script is expected to +continue running as long as the VNC server is running. When the VNC server +closes, the script will receive either a SIGTERM or standard input will be +shutdown. The script will be passed arguments in the order of @var{NAME} +@var{ADDRESS} @var{PORT} where @var{NAME} is the value passed to the +@option{-name} option, @var{ADDRESS} is the address the server is bound to, +and @var{PORT} is the port the server is listening on. + +This script will not be executed if @var{reverse} is being used or if the +server is listening on a Unix domain socket. If the @option{-name} option is +not specified, the script will not be executed. The default location of the +script is @file{/etc/qemu-vncup}. + @end table @item -k @var{language}
qemu-vncup new file +27 -0
@@ -0,0 +1,27 @@ +#!/bin/bash + +function dokill() { + kill -SIGTERM $1 >& /dev/null +} + +if [ -z "$1" -o -z "$3" ]; then + echo "Usage: $0 NAME ADDRESS PORT" + exit 1 +fi + +which avahi-publish >& /dev/null +if [ $? != 0 ] ; then + exit 0 +fi + +avahi-publish -s "$1 Virtual Console" '_rfb._tcp' $3 > /dev/null 2>&1 < /dev/null & + +pid=`jobs -p %1` + +trap "dokill -SIGTERM $pid; exit" SIGINT SIGTERM + +while read LINE ; do + echo $LINE +done + +dokill -SIGTERM $pid
vnc.c +113 -0
172 lines not on this page · raw message
This version is still a bit chatty when -name isn't specified so attached is an updated version of the patch which is less chatty when -name isn't specified.
Regards,
Anthony Liguori
Quoted 11 lines · Anthony Liguori
Modern DNS clients (like vinagre) support mDNS/DNS-SD discovery of VNC servers. VNC servers like Vino link directly against libavahi to publish themselves. Fitting libavahi into QEMU though would be pretty hairy and not as flexible as simply calling out to a helper script and using the avahi utilities.
This patch adds support for a ',script=/patch/to/script' option to the existing
-vnc option. It also includes an example script which uses avahi-publish the
presence of the QEMU instance. Care has been taken to ensure that errors are silenced if either bash or avahi aren't present and the user hasn't explicitly specified ',script='.
Subject: [PATCH] Add script hook for VNC server to support mDNS/DNS-SD
Modern DNS clients (like vinagre) support mDNS/DNS-SD discovery of VNC servers. VNC servers like Vino link directly against libavahi to publish themselves. Fitting libavahi into QEMU though would be pretty hairy and not as flexible as simply calling out to a helper script and using the avahi utilities.
This patch adds support for a ',script=/patch/to/script' option to the existing
-vnc option. It also includes an example script which uses avahi-publish the
presence of the QEMU instance. Care has been taken to ensure that errors are silenced if either bash or avahi aren't present and the user hasn't explicitly specified ',script='.
qemu-doc.texi +15 -0
@@ -486,6 +486,21 @@ path following this option specifies where the x509 certificates are to be loaded from. See the @ref{vnc_security} section for details on generating certificates. +@item script=@var{/path/to/script} + +Launch a script when the VNC server is started. The script is expected to +continue running as long as the VNC server is running. When the VNC server +closes, the script will receive either a SIGTERM or standard input will be +shutdown. The script will be passed arguments in the order of @var{NAME} +@var{ADDRESS} @var{PORT} where @var{NAME} is the value passed to the +@option{-name} option, @var{ADDRESS} is the address the server is bound to, +and @var{PORT} is the port the server is listening on. + +This script will not be executed if @var{reverse} is being used or if the +server is listening on a Unix domain socket. If the @option{-name} option is +not specified, the script will not be executed. The default location of the +script is @file{/etc/qemu-vncup}. + @end table @item -k @var{language}
qemu-vncup new file +27 -0
@@ -0,0 +1,27 @@ +#!/bin/bash + +function dokill() { + kill -SIGTERM $1 >& /dev/null +} + +if [ -z "$1" -o -z "$3" ]; then + echo "Usage: $0 NAME ADDRESS PORT" + exit 1 +fi + +which avahi-publish >& /dev/null +if [ $? != 0 ] ; then + exit 0 +fi + +avahi-publish -s "$1 Virtual Console" '_rfb._tcp' $3 > /dev/null 2>&1 < /dev/null & + +pid=`jobs -p %1` + +trap "dokill -SIGTERM $pid; exit" SIGINT SIGTERM + +while read LINE ; do + echo $LINE +done + +dokill -SIGTERM $pid
vnc.c +116 -0
175 lines not on this page · raw message