mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-05 05:45:46 +00:00
virt-admin: Introduce commands srv-clients-info and srv-clients-set
Finally wire-up virAdmServer{Get,Set}ClientLimits APIs into virt-admin client. Update the virt-admin's man page accordingly. Signed-off-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
8b1f04693d
commit
90d506e3e5
@ -809,6 +809,168 @@ cmdClientDisconnect(vshControl *ctl, const vshCmd *cmd)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------
|
||||||
|
* Command srv-clients-info
|
||||||
|
* ------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
static const vshCmdInfo info_srv_clients_info[] = {
|
||||||
|
{.name = "help",
|
||||||
|
.data = N_("get server's client-related configuration limits")
|
||||||
|
},
|
||||||
|
{.name = "desc",
|
||||||
|
.data = N_("Retrieve server's client-related configuration limits ")
|
||||||
|
},
|
||||||
|
{.name = NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
static const vshCmdOptDef opts_srv_clients_info[] = {
|
||||||
|
{.name = "server",
|
||||||
|
.type = VSH_OT_DATA,
|
||||||
|
.flags = VSH_OFLAG_REQ,
|
||||||
|
.help = N_("Server to retrieve the client limits from."),
|
||||||
|
},
|
||||||
|
{.name = NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
static bool
|
||||||
|
cmdSrvClientsInfo(vshControl *ctl, const vshCmd *cmd)
|
||||||
|
{
|
||||||
|
bool ret = false;
|
||||||
|
virTypedParameterPtr params = NULL;
|
||||||
|
int nparams = 0;
|
||||||
|
size_t i;
|
||||||
|
const char *srvname = NULL;
|
||||||
|
virAdmServerPtr srv = NULL;
|
||||||
|
vshAdmControlPtr priv = ctl->privData;
|
||||||
|
|
||||||
|
if (vshCommandOptStringReq(ctl, cmd, "server", &srvname) < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!(srv = virAdmConnectLookupServer(priv->conn, srvname, 0)))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (virAdmServerGetClientLimits(srv, ¶ms, &nparams, 0) < 0) {
|
||||||
|
vshError(ctl, "%s", _("Unable to retrieve client limits "
|
||||||
|
"from server's configuration"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < nparams; i++)
|
||||||
|
vshPrint(ctl, "%-20s: %d\n", params[i].field, params[i].value.ui);
|
||||||
|
|
||||||
|
ret = true;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
virTypedParamsFree(params, nparams);
|
||||||
|
virAdmServerFree(srv);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -----------------------
|
||||||
|
* Command srv-clients-set
|
||||||
|
* -----------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
static const vshCmdInfo info_srv_clients_set[] = {
|
||||||
|
{.name = "help",
|
||||||
|
.data = N_("set server's client-related configuration limits")
|
||||||
|
},
|
||||||
|
{.name = "desc",
|
||||||
|
.data = N_("Tune server's client-related configuration limits. "
|
||||||
|
"See OPTIONS for currently supported attributes.")
|
||||||
|
},
|
||||||
|
{.name = NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
static const vshCmdOptDef opts_srv_clients_set[] = {
|
||||||
|
{.name = "server",
|
||||||
|
.type = VSH_OT_DATA,
|
||||||
|
.flags = VSH_OFLAG_REQ,
|
||||||
|
.help = N_("Server to alter the client-related configuration limits on."),
|
||||||
|
},
|
||||||
|
{.name = "max-clients",
|
||||||
|
.type = VSH_OT_INT,
|
||||||
|
.help = N_("Change the upper limit to overall number of clients "
|
||||||
|
"connected to the server."),
|
||||||
|
},
|
||||||
|
{.name = "max-unauth-clients",
|
||||||
|
.type = VSH_OT_INT,
|
||||||
|
.help = N_("Change the upper limit to number of clients waiting for "
|
||||||
|
"authentication to be connected to the server"),
|
||||||
|
},
|
||||||
|
{.name = NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
static bool
|
||||||
|
cmdSrvClientsSet(vshControl *ctl, const vshCmd *cmd)
|
||||||
|
{
|
||||||
|
bool ret = false;
|
||||||
|
int rv = 0;
|
||||||
|
unsigned int val, max, unauth_max;
|
||||||
|
int maxparams = 0;
|
||||||
|
int nparams = 0;
|
||||||
|
const char *srvname = NULL;
|
||||||
|
virAdmServerPtr srv = NULL;
|
||||||
|
virTypedParameterPtr params = NULL;
|
||||||
|
vshAdmControlPtr priv = ctl->privData;
|
||||||
|
|
||||||
|
if (vshCommandOptStringReq(ctl, cmd, "server", &srvname) < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
#define PARSE_CMD_TYPED_PARAM(NAME, FIELD) \
|
||||||
|
if ((rv = vshCommandOptUInt(ctl, cmd, NAME, &val)) < 0) { \
|
||||||
|
vshError(ctl, _("Unable to parse integer parameter '%s'"), NAME); \
|
||||||
|
goto cleanup; \
|
||||||
|
} else if (rv > 0) { \
|
||||||
|
if (virTypedParamsAddUInt(¶ms, &nparams, &maxparams, \
|
||||||
|
FIELD, val) < 0) \
|
||||||
|
goto save_error; \
|
||||||
|
}
|
||||||
|
|
||||||
|
PARSE_CMD_TYPED_PARAM("max-clients", VIR_SERVER_CLIENTS_MAX);
|
||||||
|
PARSE_CMD_TYPED_PARAM("max-unauth-clients", VIR_SERVER_CLIENTS_UNAUTH_MAX);
|
||||||
|
|
||||||
|
#undef PARSE_CMD_TYPED_PARAM
|
||||||
|
|
||||||
|
if (!nparams) {
|
||||||
|
vshError(ctl, "%s", _("At least one of options --max-clients, "
|
||||||
|
"--max-unauth-clients is mandatory"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (virTypedParamsGetUInt(params, nparams,
|
||||||
|
VIR_SERVER_CLIENTS_MAX, &max) &&
|
||||||
|
virTypedParamsGetUInt(params, nparams,
|
||||||
|
VIR_SERVER_CLIENTS_UNAUTH_MAX, &unauth_max) &&
|
||||||
|
unauth_max > max) {
|
||||||
|
vshError(ctl, "%s", _("--max-unauth-clients must be less than "
|
||||||
|
"--max-clients"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(srv = virAdmConnectLookupServer(priv->conn, srvname, 0)))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (virAdmServerSetClientLimits(srv, params, nparams, 0) < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
ret = true;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
virTypedParamsFree(params, nparams);
|
||||||
|
virAdmServerFree(srv);
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
save_error:
|
||||||
|
vshSaveLibvirtError();
|
||||||
|
|
||||||
|
error:
|
||||||
|
vshError(ctl, "%s", _("Unable to change server's client-related "
|
||||||
|
"configuration limits"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
vshAdmConnectionHandler(vshControl *ctl)
|
vshAdmConnectionHandler(vshControl *ctl)
|
||||||
{
|
{
|
||||||
@ -1126,6 +1288,12 @@ static const vshCmdDef monitoringCmds[] = {
|
|||||||
.info = info_client_info,
|
.info = info_client_info,
|
||||||
.flags = 0
|
.flags = 0
|
||||||
},
|
},
|
||||||
|
{.name = "srv-clients-info",
|
||||||
|
.handler = cmdSrvClientsInfo,
|
||||||
|
.opts = opts_srv_clients_info,
|
||||||
|
.info = info_srv_clients_info,
|
||||||
|
.flags = 0
|
||||||
|
},
|
||||||
{.name = NULL}
|
{.name = NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1142,6 +1310,12 @@ static const vshCmdDef managementCmds[] = {
|
|||||||
.info = info_client_disconnect,
|
.info = info_client_disconnect,
|
||||||
.flags = 0
|
.flags = 0
|
||||||
},
|
},
|
||||||
|
{.name = "srv-clients-set",
|
||||||
|
.handler = cmdSrvClientsSet,
|
||||||
|
.opts = opts_srv_clients_set,
|
||||||
|
.info = info_srv_clients_set,
|
||||||
|
.flags = 0
|
||||||
|
},
|
||||||
{.name = NULL}
|
{.name = NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -227,6 +227,44 @@ information about transport type used on client's connection (supported
|
|||||||
transports include B<unix>, B<tcp>, and B<tls>), as well as providing
|
transports include B<unix>, B<tcp>, and B<tls>), as well as providing
|
||||||
information about client's connection time (system local time is used).
|
information about client's connection time (system local time is used).
|
||||||
|
|
||||||
|
=item B<srv-clients-info> I<server>
|
||||||
|
|
||||||
|
Get information about the current setting of limits regarding connections of new
|
||||||
|
clients. This information comprises of the limits to the maximum number of
|
||||||
|
clients connected to I<server>, maximum number of clients waiting for
|
||||||
|
authentication, in order to be connected to the server, as well as the current
|
||||||
|
runtime values, more specifically, the current number of clients connected to
|
||||||
|
I<server> and the current number of clients waiting for authentication.
|
||||||
|
|
||||||
|
B<Example>
|
||||||
|
# virt-admin srv-clients-info libvirtd
|
||||||
|
nclients_max : 120
|
||||||
|
nclients : 3
|
||||||
|
nclients_unauth_max : 20
|
||||||
|
nclients_unauth : 0
|
||||||
|
|
||||||
|
=item B<srv-clients-set> I<server> [I<--max-clients> B<count>]
|
||||||
|
[I<--max-unauth-clients> B<count>]
|
||||||
|
|
||||||
|
Set new client-related limits on I<server>.
|
||||||
|
|
||||||
|
=over 4
|
||||||
|
|
||||||
|
=item I<--max-clients>
|
||||||
|
|
||||||
|
Change the upper limit of the maximum overall number of clients connected to
|
||||||
|
I<server> to value B<count>. The value for this limit has to be always greater
|
||||||
|
than the value of I<--max-unauth-clients>.
|
||||||
|
|
||||||
|
=item I<--max-unauth-clients>
|
||||||
|
|
||||||
|
Change the upper limit of the maximum number of clients waiting for
|
||||||
|
authentication, in order to be connected to I<server>, to value B<count>.
|
||||||
|
The value for this limit has to be always lower than the value of
|
||||||
|
I<--max-clients>.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=head1 CLIENT COMMANDS
|
=head1 CLIENT COMMANDS
|
||||||
|
Loading…
Reference in New Issue
Block a user