On 20.05.2015 07:19, Martin Kletzander wrote: > Just one of the simplest functions that returns string "Clients: X" > where X is the number of connected clients to daemon's first > subserver (the original one), so it can be tested using virsh, ipython, > etc. > > The subserver is gathered by incrementing its reference > counter (similarly to getting qemu capabilities), so there is no > deadlock with admin subserver in this API. > > Here you can see how functions should be named in the client (virAdm*) > and server (adm*). > > There is also a parameter @flags that must be 0, which helps testing > proper error propagation into the client. > > Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx> > --- > daemon/admin_server.c | 23 +++++++++++++++++++++++ > include/libvirt/libvirt-admin.h | 1 + > po/POTFILES.in | 1 + > src/admin/admin_protocol.x | 15 ++++++++++++++- > src/admin_protocol-structs | 9 +++++++++ > src/libvirt-admin.c | 26 ++++++++++++++++++++++++++ > src/libvirt_admin.syms | 1 + > 7 files changed, 75 insertions(+), 1 deletion(-) > > diff --git a/daemon/admin_server.c b/daemon/admin_server.c > index 810908b..e722757 100644 > --- a/daemon/admin_server.c > +++ b/daemon/admin_server.c > @@ -113,4 +113,27 @@ adminDispatchConnectClose(virNetServerPtr server ATTRIBUTE_UNUSED, > return 0; > } > > + > +static char * > +admHello(virNetDaemonPtr dmn, > + unsigned int flags) > +{ > + char *ret = NULL; > + virNetServerPtr srv = NULL; > + size_t nclients; > + > + virCheckFlags(0, NULL); > + > + if (!(srv = virNetDaemonGetServer(dmn, 0))) > + return NULL; > + > + nclients = virNetServerGetNClients(srv); > + if (virAsprintf(&ret, "Clients: %zu", nclients) < 0) > + goto cleanup; > + > + cleanup: > + virObjectUnref(srv); > + return ret; > +} > + > #include "admin_dispatch.h" > diff --git a/include/libvirt/libvirt-admin.h b/include/libvirt/libvirt-admin.h > index b3cfc93..27178b4 100644 > --- a/include/libvirt/libvirt-admin.h > +++ b/include/libvirt/libvirt-admin.h > @@ -54,6 +54,7 @@ virAdmConnectPtr virAdmConnectOpen(const char *name, unsigned int flags); > int virAdmConnectClose(virAdmConnectPtr conn); > > int virAdmConnectRef(virAdmConnectPtr conn); > +char *virAdmHello(virAdmConnectPtr conn, unsigned int flags); > > # ifdef __cplusplus > } > diff --git a/po/POTFILES.in b/po/POTFILES.in > index 189e2cc..31f03d9 100644 > --- a/po/POTFILES.in > +++ b/po/POTFILES.in > @@ -1,3 +1,4 @@ > +daemon/admin_dispatch.h > daemon/admin_server.c > daemon/libvirtd-config.c > daemon/libvirtd.c > diff --git a/src/admin/admin_protocol.x b/src/admin/admin_protocol.x > index 63f6a53..03b98ec 100644 > --- a/src/admin/admin_protocol.x > +++ b/src/admin/admin_protocol.x > @@ -30,6 +30,14 @@ struct admin_connect_open_args { > unsigned int flags; > }; > > +struct admin_hello_args { > + unsigned int flags; > +}; > + > +struct admin_hello_ret { > + remote_string greeting; A-ha! Now I see why you wanted to drag in remote_protocol.c (my comment to 7/13). Well, if you: const REMOTE_STRING_MAX = 4194304; /* A long string, which may NOT be NULL. */ typedef string remote_nonnull_string<REMOTE_STRING_MAX>; /* A long string, which may be NULL. */ typedef remote_nonnull_string *remote_string; then you don't need anymore. > +}; > + > Michal -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list