[virt-tools-list] [vhostmd PATCH V3] Add SIGPIPE handler and reconnect
Jim Fehlig
jfehlig at suse.com
Thu Jun 21 15:27:34 UTC 2018
On 06/21/2018 07:03 AM, Michael Trapp wrote:
> vhostmd has no signal handler for SIGPIPE and a restart of libvirtd results in
> a stopped vhostmd. The root cause seems to be a UDS socket between vhostmd and
> libvirtd which is closed by a libvirtd restart.
> In addition to the signal handler the connection to libvirtd has to be opened
> again otherwise vhostmd can't read any data from libvirtd and doesn't update
> the metrics.
> ---
> The reconnect can be checked with
> service libvirtd stop
> This results in a closed UDS socket of the vhostmd process
> /var/run/libvirt/libvirt-sock-ro is not available anymore
> After a
> service libvirtd start
> vhostmd connects to libvirtd (strace)
> connect(6, {sa_family=AF_FILE, path="/var/run/libvirt/libvirt-sock-ro"}, 110) = 0
> /proc/PID/fd contains
> lrwx------ 1 root root 64 ... 6 -> socket:[173298]
> and the VM metrics are updated again.
>
> vhostmd/vhostmd.c | 2 ++
> vhostmd/virt-util.c | 43 ++++++++++++++++++++++++++++++++++++-------
> 2 files changed, 38 insertions(+), 7 deletions(-)
>
> diff --git a/vhostmd/vhostmd.c b/vhostmd/vhostmd.c
> index 7f04705..4cf4630 100644
> --- a/vhostmd/vhostmd.c
> +++ b/vhostmd/vhostmd.c
> @@ -117,6 +117,7 @@ static void sig_handler(int sig, siginfo_t *siginfo ATTRIBUTE_UNUSED,
> case SIGQUIT:
> down = 1;
> break;
> + case SIGPIPE:
> default:
> break;
> }
> @@ -1053,6 +1054,7 @@ int main(int argc, char *argv[])
> sigaction(SIGINT, &sig_action, NULL);
> sigaction(SIGQUIT, &sig_action, NULL);
> sigaction(SIGTERM, &sig_action, NULL);
> + sigaction(SIGPIPE, &sig_action, NULL);
>
> xmlInitParser();
>
> diff --git a/vhostmd/virt-util.c b/vhostmd/virt-util.c
> index 1c31305..c867300 100644
> --- a/vhostmd/virt-util.c
> +++ b/vhostmd/virt-util.c
> @@ -26,21 +26,48 @@
>
> #include "util.h"
>
> +enum {
> + CLOSED = 0,
> + ESTABLISHED
> +} connection = CLOSED;
> +
> static virConnectPtr conn = NULL;
>
> const char *libvirt_uri = NULL;
>
> +void
> +conn_close_cb(virConnectPtr c,
> + int __attribute__((__unused__)) reason,
> + void __attribute__((__unused__)) *p)
We already have this defined in util.h. ACK with the below squashed in. I'll
push it shortly.
Regards,
Jim
diff --git a/vhostmd/virt-util.c b/vhostmd/virt-util.c
index c867300..587146f 100644
--- a/vhostmd/virt-util.c
+++ b/vhostmd/virt-util.c
@@ -37,8 +37,8 @@ const char *libvirt_uri = NULL;
void
conn_close_cb(virConnectPtr c,
- int __attribute__((__unused__)) reason,
- void __attribute__((__unused__)) *p)
+ int reason ATTRIBUTE_UNUSED,
+ void *p ATTRIBUTE_UNUSED)
{
if (c == conn)
connection = CLOSED;
More information about the virt-tools-list
mailing list