[libvirt] [PATCH 0/2] Yet again a admin API fixup series.

Fluffy bunny ears of shame will be administered to Martin. Peter Krempa (2): rpc: Actually increase reference count on @srv in virNetDaemonAddServer daemon: Add the admin service to the admin server only if it was allocated daemon/libvirtd.c | 6 +++--- src/rpc/virnetdaemon.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) -- 2.4.1

VIR_APPEND_ELEMENT would clear @srv to NULL after it successfully inserted it thus the reference count could not be increased afterwards. Switch to VIR_APPEND_ELEMENT_COPY. This fixes crash after terminating the daemon. --- src/rpc/virnetdaemon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c index a6d6a4b..67dff14 100644 --- a/src/rpc/virnetdaemon.c +++ b/src/rpc/virnetdaemon.c @@ -162,7 +162,7 @@ virNetDaemonAddServer(virNetDaemonPtr dmn, virNetServerPtr srv) virObjectLock(dmn); - if (VIR_APPEND_ELEMENT(dmn->servers, dmn->nservers, srv) < 0) + if (VIR_APPEND_ELEMENT_COPY(dmn->servers, dmn->nservers, srv) < 0) goto cleanup; virObjectRef(srv); -- 2.4.1

If the admin service is disabled it would not be allocated, but the NULL pointer still would be added to the admin server. Since virNetServerAddService would dereference it, the daemon would crash. Move the service registration into the block that allocates it. --- daemon/libvirtd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index 368e10c..286512a 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -534,10 +534,10 @@ daemonSetupNetworking(virNetServerPtr srv, config->admin_max_queued_clients, config->admin_max_client_requests))) goto error; - } - if (virNetServerAddService(srvAdm, svcAdm, NULL) < 0) - goto error; + if (virNetServerAddService(srvAdm, svcAdm, NULL) < 0) + goto error; + } if (ipsock) { if (config->listen_tcp) { -- 2.4.1

On 18.06.2015 11:44, Peter Krempa wrote:
Fluffy bunny ears of shame will be administered to Martin.
Peter Krempa (2): rpc: Actually increase reference count on @srv in virNetDaemonAddServer daemon: Add the admin service to the admin server only if it was allocated
daemon/libvirtd.c | 6 +++--- src/rpc/virnetdaemon.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
ACK series. Funny, I was just about to send the 1/2 patch too. Michal

On Thu, Jun 18, 2015 at 11:53:55 +0200, Michal Privoznik wrote:
On 18.06.2015 11:44, Peter Krempa wrote:
Fluffy bunny ears of shame will be administered to Martin.
Peter Krempa (2): rpc: Actually increase reference count on @srv in virNetDaemonAddServer daemon: Add the admin service to the admin server only if it was allocated
daemon/libvirtd.c | 6 +++--- src/rpc/virnetdaemon.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
ACK series. Funny, I was just about to send the 1/2 patch too.
Pushed; Thanks. Peter
participants (2)
-
Michal Privoznik
-
Peter Krempa