On 29.04.2016 15:45, Erik Skultety wrote: > Wire-up the client identity getter into virt-admin tool. This patch adjusts > man-page accordingly. > > Signed-off-by: Erik Skultety <eskultet@xxxxxxxxxx> > --- > tools/virt-admin.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 91 insertions(+) Missing documentation. > > diff --git a/tools/virt-admin.c b/tools/virt-admin.c > index f0fecdd..72c54ae 100644 > --- a/tools/virt-admin.c > +++ b/tools/virt-admin.c > @@ -655,6 +655,91 @@ cmdSrvClientsList(vshControl *ctl, const vshCmd *cmd) > return ret; > } > > +/* ------------------- > + * Command client-info > + * ------------------- > + */ > + > +static const vshCmdInfo info_client_info[] = { > + {.name = "help", > + .data = N_("retrieve client's identity info from <server>") > + }, > + {.name = "desc", > + .data = N_("Retrieve identity details about <client> from <server>") > + }, > + {.name = NULL} > +}; > + > +static const vshCmdOptDef opts_client_info[] = { > + {.name = "client", > + .type = VSH_OT_DATA, > + .flags = VSH_OFLAG_REQ, > + .help = N_("client which to retrieve identity information for"), > + }, > + {.name = "server", > + .type = VSH_OT_DATA, > + .flags = VSH_OFLAG_REQ, > + .help = N_("server to which <client> is connected to"), > + }, > + {.name = NULL} I wonder if we should reverse the order of these two. Server is more important than client. But maybe I'm bikeshedding, so whatever is your gut feeling. > +}; > + > +static bool > +cmdClientInfo(vshControl *ctl, const vshCmd *cmd) > +{ > + bool ret = false; > + size_t i; > + unsigned long long id; > + const char *srvname = NULL; > + char *timestr = NULL; > + virAdmServerPtr srv = NULL; > + virAdmClientPtr clnt = NULL; > + virTypedParameterPtr params = NULL; > + int nparams = 0; > + vshAdmControlPtr priv = ctl->privData; > + > + if (vshCommandOptULongLong(ctl, cmd, "client", &id) < 0) > + return false; > + > + if (vshCommandOptStringReq(ctl, cmd, "server", &srvname) < 0) > + return false; > + > + if (!(srv = virAdmConnectLookupServer(priv->conn, srvname, 0)) || > + !(clnt = virAdmServerLookupClient(srv, id, 0))) > + goto cleanup; > + > + /* Retrieve client identity info */ > + if (virAdmClientGetInfo(clnt, ¶ms, &nparams, 0) < 0) { > + vshError(ctl, _("failed to retrieve client identity information for " > + "client '%llu' connected to server '%s'"), > + id, virAdmServerGetName(srv)); > + goto cleanup; > + } > + > + if (vshAdmGetTimeStr(ctl, virAdmClientGetTimestamp(clnt), ×tr) < 0) > + goto cleanup; > + > + /* this info is provided by the client object itself */ > + vshPrint(ctl, "%-15s: %llu\n", "id", virAdmClientGetID(clnt)); > + vshPrint(ctl, "%-15s: %s\n", "connection_time", timestr); > + vshPrint(ctl, "%-15s: %s\n", "transport", > + vshAdmClientTransportToString(virAdmClientGetTransport(clnt))); > + > + for (i = 0; i < nparams; i++) { > + char *str = vshGetTypedParamValue(ctl, ¶ms[i]); > + vshPrint(ctl, "%-15s: %s\n", params[i].field, str); > + VIR_FREE(str); > + } > + > + ret = true; > + > + cleanup: > + virTypedParamsFree(params, nparams); > + virAdmServerFree(srv); > + virAdmClientFree(clnt); > + VIR_FREE(timestr); > + return ret; > +} > static void * > vshAdmConnectionHandler(vshControl *ctl) > { > @@ -966,6 +1051,12 @@ static const vshCmdDef monitoringCmds[] = { > .info = info_srv_clients_list, > .flags = 0 > }, > + {.name = "client-info", > + .handler = cmdClientInfo, > + .opts = opts_client_info, > + .info = info_client_info, > + .flags = 0 > + }, > {.name = NULL} > }; > > Michal -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list