[libvirt] [PATCH] Fix pid ouput of libvirt.rpc.socket_new probe

Daniel P. Berrange berrange at redhat.com
Mon Dec 2 09:58:06 UTC 2013


On Mon, Dec 02, 2013 at 10:55:49AM +0800, Jincheng Miao wrote:
> Pass the pid value when invoking virNetSocketNew(). This will make
> libvirt.rpc.socket_new stap probe return the right pid.
> 
> Signed-off-by: Jincheng Miao <jmiao at redhat.com>
> ---
>  src/rpc/virnetsocket.c | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
> index 04bf25a..4c98fa9 100644
> --- a/src/rpc/virnetsocket.c
> +++ b/src/rpc/virnetsocket.c
> @@ -300,7 +300,8 @@ int virNetSocketNewListenTCP(const char *nodename,
>          if (VIR_EXPAND_N(socks, nsocks, 1) < 0)
>              goto error;
>  
> -        if (!(socks[nsocks-1] = virNetSocketNew(&addr, NULL, false, fd, -1, 0)))
> +        if (!(socks[nsocks-1] = virNetSocketNew(&addr, NULL, false, fd, -1,
> +                                                getpid())))

Nooooo, this is seriously wrong. The PID argument here refers to the PID
of the (optional) child process that is tunnelling the socket (eg the
SSH client process).

When libvirt free's the virNetSocketPtr object it will send SIGTERM
and SIGKILL to this process. So your code here will cause libvirtd
to kill itself.

Furthermore systemtap scripts already have direct access to the PID of
the process in which the probe triggers, so your change is not required
at all.

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list