[libvirt] [PATCH 07/23] Refactor RPC client private data setup

Eric Blake eblake at redhat.com
Wed Aug 15 00:14:48 UTC 2012


On 08/09/2012 09:20 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange at redhat.com>
> 
> Currently there is a hook function that is invoked when a
> new client connection comes in, which allows an app to
> setup private data. This setup will make it difficult to
> serialize client state during process re-exec(). Change to
> a model where the app registers a callback when creating
> the virNetServerPtr instance, which is used to allocate
> the client private data immediately during virNetClientPtr
> construction.
> 
> Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
> ---
>  daemon/libvirtd.c            |  1 +
>  daemon/remote.c              | 15 ++++++---------
>  daemon/remote.h              |  6 +++---
>  src/lxc/lxc_controller.c     | 23 +++++++++++++++++------
>  src/rpc/virnetserver.c       | 24 +++++++++++++-----------
>  src/rpc/virnetserver.h       |  9 +++------
>  src/rpc/virnetserverclient.c | 31 +++++++++++++------------------
>  src/rpc/virnetserverclient.h | 13 +++++++------
>  8 files changed, 63 insertions(+), 59 deletions(-)

Fails 'make check':

  GEN    check-symfile
Expected symbol virNetServerClientSetPrivateData is not in ELF library

> +++ b/src/lxc/lxc_controller.c
> +static void *virLXCControllerClientPrivateNew(virNetServerClientPtr client,
> +                                              void *opaque)
>  {
>      virLXCControllerPtr ctrl = opaque;
> -    virNetServerClientSetPrivateData(client, ctrl, NULL);
> +    int *dummy;
> +
> +    if (VIR_ALLOC(dummy) < 0) {
> +        virReportOOMError();
> +        return NULL;
> +    }

Maybe use strdup("") instead of dummy as your magic allocation?  Doesn't
matter at the end of the day, though.  And if you never store into the
allocated storage, do you even need to allocate something, or could you
return ((void*)1) and have the free function be a no-op instead of a
VIR_FREE, since the only reason you have to return non-NULL is to
indicate success?

ACK with this squashed in:

diff --git i/src/libvirt_private.syms w/src/libvirt_private.syms
index 75fd7bf..24915e2 100644
--- i/src/libvirt_private.syms
+++ w/src/libvirt_private.syms
@@ -1524,7 +1524,6 @@ virNetServerClientSendMessage;
 virNetServerClientSetCloseHook;
 virNetServerClientSetDispatcher;
 virNetServerClientSetIdentity;
-virNetServerClientSetPrivateData;
 virNetServerClientStartKeepAlive;
 virNetServerClientWantClose;


-- 
Eric Blake   eblake at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120814/790ef610/attachment-0001.sig>


More information about the libvir-list mailing list