mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-11-08 22:39:56 +00:00
fbb8205de3
Some of the examples make use of asprintf and strtol functions (to keep things simple) which are prohibited to use within our code (enforced by syntax-check). Therefore besides adding some examples, this patch also updates cfg.mk to exclude examples directory from asprintf and strtol rules, as well as updates .gitignore to exclude all the new admin binaries created in the 'examples' dir. Signed-off-by: Erik Skultety <eskultet@redhat.com>
64 lines
1.8 KiB
C
64 lines
1.8 KiB
C
#include<stdio.h>
|
|
#include<stdlib.h>
|
|
#include<libvirt/libvirt-admin.h>
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
int ret = -1;
|
|
virAdmConnectPtr conn = NULL;
|
|
virAdmServerPtr srv = NULL; /* which server to work with */
|
|
virTypedParameterPtr params = NULL;
|
|
int nparams = 0;
|
|
size_t i;
|
|
|
|
if (argc != 2) {
|
|
fprintf(stderr, "One argument specifying the server which to work "
|
|
"with is expected\n");
|
|
return -1;
|
|
}
|
|
|
|
/* first, open a connection to the daemon */
|
|
if (!(conn = virAdmConnectOpen(NULL, 0)))
|
|
goto cleanup;
|
|
|
|
/* a server handle is necessary before any API regarding threadpool
|
|
* parameters can be issued
|
|
*/
|
|
if (!(srv = virAdmConnectLookupServer(conn, argv[1], 0)))
|
|
goto cleanup;
|
|
|
|
/* get the current client limits */
|
|
if (virAdmServerGetClientLimits(srv, ¶ms, &nparams, 0) < 0)
|
|
goto cleanup;
|
|
|
|
for (i = 0; i < nparams; i++)
|
|
printf("%-15s: %d\n", params[i].field, params[i].value.ui);
|
|
|
|
virTypedParamsFree(params, nparams);
|
|
params = NULL;
|
|
nparams = 0;
|
|
|
|
/* set nclients_max to 100 and nclients_unauth_max to 20 */
|
|
int maxparams = 0;
|
|
if (virTypedParamsAddUInt(¶ms, &nparams, &maxparams,
|
|
VIR_SERVER_CLIENTS_MAX, 100) < 0 ||
|
|
virTypedParamsAddUInt(¶ms, &nparams, &maxparams,
|
|
VIR_SERVER_CLIENTS_UNAUTH_MAX, 20) < 0)
|
|
goto cleanup;
|
|
|
|
/* now, change the client limits on the server */
|
|
if (virAdmServerSetClientLimits(srv, params, nparams, 0) < 0)
|
|
goto cleanup;
|
|
|
|
ret = 0;
|
|
cleanup:
|
|
virTypedParamsFree(params, nparams);
|
|
|
|
/* Once finished deallocate the server handle and close the connection
|
|
* properly, @conn will be deallocated automatically
|
|
*/
|
|
virAdmServerFree(srv);
|
|
virAdmConnectClose(conn);
|
|
return ret;
|
|
}
|