Hello community, here is the log from the commit of package vhostmd for openSUSE:Factory checked in at 2018-07-06 10:43:33 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/vhostmd (Old) and /work/SRC/openSUSE:Factory/.vhostmd.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "vhostmd" Fri Jul 6 10:43:33 2018 rev:26 rq:620925 version:0.4 Changes: -------- --- /work/SRC/openSUSE:Factory/vhostmd/vhostmd.changes 2018-05-01 23:30:07.742342199 +0200 +++ /work/SRC/openSUSE:Factory/.vhostmd.new/vhostmd.changes 2018-07-06 10:43:36.159139985 +0200 @@ -1,0 +2,8 @@ +Mon Jun 25 15:05:23 UTC 2018 - jfeh...@suse.com + +- Handle SIGPIPE and reconnect to libvirtd + c7646e32-handle-sigpipe-reconnect.patch, + 03dc9982-fix-deallocation.patch + bsc#1098804 + +------------------------------------------------------------------- New: ---- 03dc9982-fix-deallocation.patch c7646e32-handle-sigpipe-reconnect.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ vhostmd.spec ++++++ --- /var/tmp/diff_new_pack.4p5qJR/_old 2018-07-06 10:43:36.747139285 +0200 +++ /var/tmp/diff_new_pack.4p5qJR/_new 2018-07-06 10:43:36.751139281 +0200 @@ -38,6 +38,8 @@ Patch3: libmetrics-link.patch Patch4: modernize-build-files.patch Patch5: add-systemd-service.patch +Patch6: c7646e32-handle-sigpipe-reconnect.patch +Patch7: 03dc9982-fix-deallocation.patch BuildRequires: libtool BuildRequires: libvirt-devel BuildRequires: libxml2 @@ -91,6 +93,8 @@ %patch3 -p1 %patch4 -p1 %patch5 -p1 +%patch6 -p1 +%patch7 -p1 %build %if ! %{with_xen} ++++++ 03dc9982-fix-deallocation.patch ++++++ commit 03dc99825ad3d53cfcc7d8c2b8288b1549f261d6 Author: Michael Trapp <michael.tr...@sap.com> Date: Thu Jun 21 15:19:26 2018 +0200 fix deallocation in vu_vm_free Callers of vu_vm_free may pass a partially constructed vu_vm object. Check if members of the object have been allocated before deallocating them. Index: vhostmd-0.4/vhostmd/virt-util.c =================================================================== --- vhostmd-0.4.orig/vhostmd/virt-util.c +++ vhostmd-0.4/vhostmd/virt-util.c @@ -118,15 +118,17 @@ vu_vm *vu_get_vm(int id) error: virDomainFree(dom); - free(vm); + vu_vm_free(vm); return NULL; } void vu_vm_free(vu_vm *vm) { if (vm) { - free(vm->name); - free(vm->uuid); + if (vm->name) + free(vm->name); + if (vm->uuid) + free(vm->uuid); free(vm); } } ++++++ c7646e32-handle-sigpipe-reconnect.patch ++++++ commit c7646e329ca61a038777f58042539611ac42b007 Author: Michael Trapp <michael.tr...@sap.com> Date: Thu Jun 21 15:03:50 2018 +0200 Add SIGPIPE handler and reconnect 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. Index: vhostmd-0.4/vhostmd/vhostmd.c =================================================================== --- vhostmd-0.4.orig/vhostmd/vhostmd.c +++ vhostmd-0.4/vhostmd/vhostmd.c @@ -115,6 +115,7 @@ static void sig_handler(int sig, siginfo case SIGQUIT: down = 1; break; + case SIGPIPE: default: break; } @@ -1050,6 +1051,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(); Index: vhostmd-0.4/vhostmd/virt-util.c =================================================================== --- vhostmd-0.4.orig/vhostmd/virt-util.c +++ vhostmd-0.4/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 reason ATTRIBUTE_UNUSED, + void *p ATTRIBUTE_UNUSED) +{ + if (c == conn) + connection = CLOSED; +} + static int -do_connect (void) +do_connect(void) { + if (connection == ESTABLISHED) + return 0; + + if (conn != NULL) + virConnectClose(conn); + + conn = virConnectOpenReadOnly(libvirt_uri); if (conn == NULL) { - conn = virConnectOpenReadOnly (libvirt_uri); - if (conn == NULL) { - vu_log (VHOSTMD_ERR, "Unable to open libvirt connection to %s", - libvirt_uri ? libvirt_uri : "default hypervisor"); - return -1; - } + vu_log(VHOSTMD_ERR, "Unable to open libvirt connection to %s", + libvirt_uri ? libvirt_uri : "default hypervisor"); + return -1; + } + + if (virConnectRegisterCloseCallback(conn, conn_close_cb, NULL, NULL)) { + vu_log(VHOSTMD_ERR, "Unable to register callback 'virConnectCloseFunc'"); + virConnectClose(conn); + conn = NULL; + return -1; } + + connection = ESTABLISHED; return 0; } @@ -107,8 +134,10 @@ void vu_vm_free(vu_vm *vm) void vu_vm_connect_close() { if (conn) { + virConnectUnregisterCloseCallback(conn, conn_close_cb); virConnectClose(conn); conn = NULL; } + connection = CLOSED; }