mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 22:25:25 +00:00
acf522e85a
Commit0c6ad476
updated gnulib, which rearranged some of the conditions in gnulib wrapper headers such that compilation started failing on BSD systems when the normal system <unistd.h> tried to include another system header but instead got a gnulib wrapper header in an incomplete state; this is because gnulib headers only work if <config.h> is included first. Commitb6f78259
papered over the symptoms of that by including <config.h> in all the examples. But this logic is backwards - if our examples are truly meant to be stand-alone, they should NOT depend on how libvirt was configured, and should NOT depend on the gnulib fixes for system quirks. In particular, if an example does not need to link against libgnulib.la, then it also does not need to use -Ignulib in its compile flags, and likewise does not need to include <config.h> since none of the gnulib wrapper headers should be interfering. So, revert (most of)b6f78259
(except for the bogus pre-patch use of "config.h" in admin/logging.c: if config.h is included, it should be via <> rather than "", and must be before any system headers); then additionally nuke all mention of <config.h>, -Ignulib, and -llibgnu.la, making all of the examples truly standalone. Signed-off-by: Eric Blake <eblake@redhat.com> Acked-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
66 lines
2.0 KiB
C
66 lines
2.0 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;
|
|
ssize_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 threadpool parameters */
|
|
if (virAdmServerGetThreadPoolParameters(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;
|
|
|
|
/* let's set minWorkers to 10, maxWorkers to 15 and prioWorkers to 10 */
|
|
int maxparams = 0;
|
|
if (virTypedParamsAddUInt(¶ms, &nparams, &maxparams,
|
|
VIR_THREADPOOL_WORKERS_MIN, 10) < 0 ||
|
|
virTypedParamsAddUInt(¶ms, &nparams, &maxparams,
|
|
VIR_THREADPOOL_WORKERS_MAX, 15) < 0 ||
|
|
virTypedParamsAddUInt(¶ms, &nparams, &maxparams,
|
|
VIR_THREADPOOL_WORKERS_PRIORITY, 10) < 0)
|
|
goto cleanup;
|
|
|
|
/* now, change the threadpool settings to some different values */
|
|
if (virAdmServerSetThreadPoolParameters(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;
|
|
}
|