2015-04-15 14:23:55 +00:00
|
|
|
/*
|
2018-01-19 11:30:31 +00:00
|
|
|
* admin_server_dispatch.c: handlers for admin RPC method calls
|
2015-04-15 14:23:55 +00:00
|
|
|
*
|
2015-08-10 10:39:33 +00:00
|
|
|
* Copyright (C) 2014-2016 Red Hat, Inc.
|
2015-04-15 14:23:55 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "internal.h"
|
|
|
|
|
2018-01-19 11:30:31 +00:00
|
|
|
#include "admin_server_dispatch.h"
|
2015-08-14 07:17:01 +00:00
|
|
|
#include "admin_server.h"
|
2015-04-15 14:23:55 +00:00
|
|
|
#include "viralloc.h"
|
|
|
|
#include "virerror.h"
|
|
|
|
#include "virlog.h"
|
2018-01-19 11:30:31 +00:00
|
|
|
#include "rpc/virnetdaemon.h"
|
|
|
|
#include "rpc/virnetserver.h"
|
2015-04-15 14:23:55 +00:00
|
|
|
#include "virthreadjob.h"
|
2015-11-23 11:41:32 +00:00
|
|
|
#include "virtypedparam.h"
|
2020-02-25 10:01:09 +00:00
|
|
|
#include "virutil.h"
|
2015-04-15 14:23:55 +00:00
|
|
|
|
|
|
|
#define VIR_FROM_THIS VIR_FROM_ADMIN
|
|
|
|
|
|
|
|
VIR_LOG_INIT("daemon.admin");
|
|
|
|
|
2018-01-19 11:30:31 +00:00
|
|
|
typedef struct daemonAdmClientPrivate daemonAdmClientPrivate;
|
|
|
|
/* Separate private data for admin connection */
|
|
|
|
struct daemonAdmClientPrivate {
|
|
|
|
/* Just a placeholder, not that there is anything to be locked */
|
|
|
|
virMutex lock;
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virNetDaemon *dmn;
|
2018-01-19 11:30:31 +00:00
|
|
|
};
|
2015-04-15 14:23:55 +00:00
|
|
|
|
|
|
|
void
|
2018-01-22 18:29:55 +00:00
|
|
|
remoteAdmClientFree(void *data)
|
2015-04-15 14:23:55 +00:00
|
|
|
{
|
|
|
|
struct daemonAdmClientPrivate *priv = data;
|
|
|
|
|
|
|
|
virMutexDestroy(&priv->lock);
|
|
|
|
virObjectUnref(priv->dmn);
|
2021-02-03 19:57:46 +00:00
|
|
|
g_free(priv);
|
2015-04-15 14:23:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void *
|
2021-03-11 07:16:13 +00:00
|
|
|
remoteAdmClientNew(virNetServerClient *client G_GNUC_UNUSED,
|
2018-01-22 18:29:55 +00:00
|
|
|
void *opaque)
|
2015-04-15 14:23:55 +00:00
|
|
|
{
|
|
|
|
struct daemonAdmClientPrivate *priv;
|
2019-04-30 16:26:13 +00:00
|
|
|
uid_t clientuid;
|
|
|
|
gid_t clientgid;
|
|
|
|
pid_t clientpid;
|
|
|
|
unsigned long long timestamp;
|
|
|
|
|
|
|
|
if (virNetServerClientGetUNIXIdentity(client,
|
|
|
|
&clientuid,
|
|
|
|
&clientgid,
|
|
|
|
&clientpid,
|
|
|
|
×tamp) < 0)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
VIR_DEBUG("New client pid %lld uid %lld",
|
|
|
|
(long long)clientpid,
|
|
|
|
(long long)clientuid);
|
|
|
|
|
|
|
|
if (geteuid() != clientuid) {
|
|
|
|
virReportRestrictedError(_("Disallowing client %lld with uid %lld"),
|
|
|
|
(long long)clientpid,
|
|
|
|
(long long)clientuid);
|
|
|
|
return NULL;
|
|
|
|
}
|
2015-04-15 14:23:55 +00:00
|
|
|
|
2020-09-23 18:44:29 +00:00
|
|
|
priv = g_new0(struct daemonAdmClientPrivate, 1);
|
2015-04-15 14:23:55 +00:00
|
|
|
|
|
|
|
if (virMutexInit(&priv->lock) < 0) {
|
|
|
|
VIR_FREE(priv);
|
|
|
|
virReportSystemError(errno, "%s", _("unable to init mutex"));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We don't necessarily need to ref this object right now as there
|
|
|
|
* must be one ref being held throughout the life of the daemon,
|
|
|
|
* but let's just be safe for future.
|
|
|
|
*/
|
|
|
|
priv->dmn = virObjectRef(opaque);
|
|
|
|
|
|
|
|
return priv;
|
|
|
|
}
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
void *remoteAdmClientNewPostExecRestart(virNetServerClient *client,
|
|
|
|
virJSONValue *object G_GNUC_UNUSED,
|
2018-01-23 13:20:19 +00:00
|
|
|
void *opaque)
|
|
|
|
{
|
|
|
|
return remoteAdmClientNew(client, opaque);
|
|
|
|
}
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virJSONValue *remoteAdmClientPreExecRestart(virNetServerClient *client G_GNUC_UNUSED,
|
|
|
|
void *data G_GNUC_UNUSED)
|
2018-01-23 13:20:19 +00:00
|
|
|
{
|
2021-03-11 07:16:13 +00:00
|
|
|
virJSONValue *object = virJSONValueNewObject();
|
2018-01-23 13:20:19 +00:00
|
|
|
|
|
|
|
/* No content to add at this time - just need empty object */
|
|
|
|
|
|
|
|
return object;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-08-14 07:17:01 +00:00
|
|
|
/* Helpers */
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
static virNetServer *
|
|
|
|
get_nonnull_server(virNetDaemon *dmn, admin_nonnull_server srv)
|
2016-04-14 22:20:11 +00:00
|
|
|
{
|
|
|
|
return virNetDaemonGetServer(dmn, srv.name);
|
|
|
|
}
|
|
|
|
|
2019-10-22 11:46:37 +00:00
|
|
|
static void
|
2015-08-14 07:17:01 +00:00
|
|
|
make_nonnull_server(admin_nonnull_server *srv_dst,
|
2021-03-11 07:16:13 +00:00
|
|
|
virNetServer *srv_src)
|
2015-08-14 07:17:01 +00:00
|
|
|
{
|
2019-10-20 11:49:46 +00:00
|
|
|
srv_dst->name = g_strdup(virNetServerGetName(srv_src));
|
2015-08-14 07:17:01 +00:00
|
|
|
}
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
static virNetServerClient *
|
|
|
|
get_nonnull_client(virNetServer *srv, admin_nonnull_client clnt)
|
2016-04-28 08:26:25 +00:00
|
|
|
{
|
|
|
|
return virNetServerGetClient(srv, clnt.id);
|
|
|
|
}
|
|
|
|
|
2019-10-22 11:46:37 +00:00
|
|
|
static void
|
2016-04-14 22:20:11 +00:00
|
|
|
make_nonnull_client(admin_nonnull_client *clt_dst,
|
2021-03-11 07:16:13 +00:00
|
|
|
virNetServerClient *clt_src)
|
2016-04-14 22:20:11 +00:00
|
|
|
{
|
|
|
|
clt_dst->id = virNetServerClientGetID(clt_src);
|
|
|
|
clt_dst->timestamp = virNetServerClientGetTimestamp(clt_src);
|
|
|
|
clt_dst->transport = virNetServerClientGetTransport(clt_src);
|
|
|
|
}
|
|
|
|
|
2015-04-15 14:23:55 +00:00
|
|
|
/* Functions */
|
|
|
|
static int
|
2021-03-11 07:16:13 +00:00
|
|
|
adminDispatchConnectOpen(virNetServer *server G_GNUC_UNUSED,
|
|
|
|
virNetServerClient *client,
|
|
|
|
virNetMessage *msg G_GNUC_UNUSED,
|
|
|
|
struct virNetMessageError *rerr,
|
2015-12-10 12:46:45 +00:00
|
|
|
struct admin_connect_open_args *args)
|
2015-04-15 14:23:55 +00:00
|
|
|
{
|
|
|
|
unsigned int flags;
|
|
|
|
struct daemonAdmClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
|
|
|
int ret = -1;
|
2022-02-16 15:34:47 +00:00
|
|
|
VIR_LOCK_GUARD lock = virLockGuardLock(&priv->lock);
|
2015-04-15 14:23:55 +00:00
|
|
|
|
|
|
|
VIR_DEBUG("priv=%p dmn=%p", priv, priv->dmn);
|
|
|
|
|
|
|
|
flags = args->flags;
|
|
|
|
virCheckFlagsGoto(0, cleanup);
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
cleanup:
|
|
|
|
if (ret < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2021-03-11 07:16:13 +00:00
|
|
|
adminDispatchConnectClose(virNetServer *server G_GNUC_UNUSED,
|
|
|
|
virNetServerClient *client,
|
|
|
|
virNetMessage *msg G_GNUC_UNUSED,
|
|
|
|
struct virNetMessageError *rerr G_GNUC_UNUSED)
|
2015-04-15 14:23:55 +00:00
|
|
|
{
|
|
|
|
virNetServerClientDelayedClose(client);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-10-05 15:17:51 +00:00
|
|
|
static int
|
2021-03-11 07:16:13 +00:00
|
|
|
adminConnectGetLibVersion(virNetDaemon *dmn G_GNUC_UNUSED,
|
2015-12-10 12:46:45 +00:00
|
|
|
unsigned long long *libVer)
|
2015-10-05 15:17:51 +00:00
|
|
|
{
|
|
|
|
if (libVer)
|
|
|
|
*libVer = LIBVIR_VERSION_NUMBER;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
static virNetDaemon *
|
|
|
|
adminGetConn(virNetServerClient *client)
|
2019-07-17 14:26:08 +00:00
|
|
|
{
|
|
|
|
struct daemonAdmClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
|
|
|
|
|
|
|
return priv->dmn;
|
|
|
|
}
|
|
|
|
|
2015-11-23 11:41:32 +00:00
|
|
|
static int
|
2021-03-11 07:16:13 +00:00
|
|
|
adminDispatchServerGetThreadpoolParameters(virNetServer *server G_GNUC_UNUSED,
|
|
|
|
virNetServerClient *client,
|
|
|
|
virNetMessage *msg G_GNUC_UNUSED,
|
|
|
|
struct virNetMessageError *rerr,
|
2015-11-23 11:41:32 +00:00
|
|
|
struct admin_server_get_threadpool_parameters_args *args,
|
|
|
|
struct admin_server_get_threadpool_parameters_ret *ret)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
2021-03-11 07:16:13 +00:00
|
|
|
virNetServer *srv = NULL;
|
2015-11-23 11:41:32 +00:00
|
|
|
virTypedParameterPtr params = NULL;
|
|
|
|
int nparams = 0;
|
|
|
|
struct daemonAdmClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
|
|
|
|
|
|
|
if (!(srv = virNetDaemonGetServer(priv->dmn, args->srv.name)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (adminServerGetThreadPoolParameters(srv, ¶ms, &nparams,
|
|
|
|
args->flags) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (virTypedParamsSerialize(params, nparams,
|
2019-08-27 08:57:49 +00:00
|
|
|
ADMIN_SERVER_THREADPOOL_PARAMETERS_MAX,
|
2021-03-11 07:16:13 +00:00
|
|
|
(struct _virTypedParameterRemote **) &ret->params.params_val,
|
2015-11-23 11:41:32 +00:00
|
|
|
&ret->params.params_len, 0) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
|
|
|
|
virTypedParamsFree(params, nparams);
|
|
|
|
virObjectUnref(srv);
|
|
|
|
return rv;
|
|
|
|
}
|
admin: Introduce virAdmServerSetThreadPoolParameters
Since threadpool increments the current number of threads according to current
load, i.e. how many jobs are waiting in the queue. The count however, is
constrained by max and min limits of workers. The logic of this new API works
like this:
1) setting the minimum
a) When the limit is increased, depending on the current number of
threads, new threads are possibly spawned if the current number of
threads is less than the new minimum limit
b) Decreasing the minimum limit has no possible effect on the current
number of threads
2) setting the maximum
a) Icreasing the maximum limit has no immediate effect on the current
number of threads, it only allows the threadpool to spawn more
threads when new jobs, that would otherwise end up queued, arrive.
b) Decreasing the maximum limit may affect the current number of
threads, if the current number of threads is less than the new
maximum limit. Since there may be some ongoing time-consuming jobs
that would effectively block this API from killing any threads.
Therefore, this API is asynchronous with best-effort execution,
i.e. the necessary number of workers will be terminated once they
finish their previous job, unless other workers had already
terminated, decreasing the limit to the requested value.
3) setting priority workers
- both increase and decrease in count of these workers have an
immediate impact on the current number of workers, new ones will be
spawned or some of them get terminated respectively.
Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-02-22 13:24:04 +00:00
|
|
|
|
|
|
|
static int
|
2021-03-11 07:16:13 +00:00
|
|
|
adminDispatchServerSetThreadpoolParameters(virNetServer *server G_GNUC_UNUSED,
|
|
|
|
virNetServerClient *client,
|
|
|
|
virNetMessage *msg G_GNUC_UNUSED,
|
|
|
|
struct virNetMessageError *rerr,
|
admin: Introduce virAdmServerSetThreadPoolParameters
Since threadpool increments the current number of threads according to current
load, i.e. how many jobs are waiting in the queue. The count however, is
constrained by max and min limits of workers. The logic of this new API works
like this:
1) setting the minimum
a) When the limit is increased, depending on the current number of
threads, new threads are possibly spawned if the current number of
threads is less than the new minimum limit
b) Decreasing the minimum limit has no possible effect on the current
number of threads
2) setting the maximum
a) Icreasing the maximum limit has no immediate effect on the current
number of threads, it only allows the threadpool to spawn more
threads when new jobs, that would otherwise end up queued, arrive.
b) Decreasing the maximum limit may affect the current number of
threads, if the current number of threads is less than the new
maximum limit. Since there may be some ongoing time-consuming jobs
that would effectively block this API from killing any threads.
Therefore, this API is asynchronous with best-effort execution,
i.e. the necessary number of workers will be terminated once they
finish their previous job, unless other workers had already
terminated, decreasing the limit to the requested value.
3) setting priority workers
- both increase and decrease in count of these workers have an
immediate impact on the current number of workers, new ones will be
spawned or some of them get terminated respectively.
Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-02-22 13:24:04 +00:00
|
|
|
struct admin_server_set_threadpool_parameters_args *args)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
2021-03-11 07:16:13 +00:00
|
|
|
virNetServer *srv = NULL;
|
admin: Introduce virAdmServerSetThreadPoolParameters
Since threadpool increments the current number of threads according to current
load, i.e. how many jobs are waiting in the queue. The count however, is
constrained by max and min limits of workers. The logic of this new API works
like this:
1) setting the minimum
a) When the limit is increased, depending on the current number of
threads, new threads are possibly spawned if the current number of
threads is less than the new minimum limit
b) Decreasing the minimum limit has no possible effect on the current
number of threads
2) setting the maximum
a) Icreasing the maximum limit has no immediate effect on the current
number of threads, it only allows the threadpool to spawn more
threads when new jobs, that would otherwise end up queued, arrive.
b) Decreasing the maximum limit may affect the current number of
threads, if the current number of threads is less than the new
maximum limit. Since there may be some ongoing time-consuming jobs
that would effectively block this API from killing any threads.
Therefore, this API is asynchronous with best-effort execution,
i.e. the necessary number of workers will be terminated once they
finish their previous job, unless other workers had already
terminated, decreasing the limit to the requested value.
3) setting priority workers
- both increase and decrease in count of these workers have an
immediate impact on the current number of workers, new ones will be
spawned or some of them get terminated respectively.
Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-02-22 13:24:04 +00:00
|
|
|
virTypedParameterPtr params = NULL;
|
|
|
|
int nparams = 0;
|
|
|
|
struct daemonAdmClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
|
|
|
|
|
|
|
if (!(srv = virNetDaemonGetServer(priv->dmn, args->srv.name))) {
|
|
|
|
virReportError(VIR_ERR_NO_SERVER,
|
|
|
|
_("no server with matching name '%s' found"),
|
|
|
|
args->srv.name);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
if (virTypedParamsDeserialize((struct _virTypedParameterRemote *) args->params.params_val,
|
admin: Introduce virAdmServerSetThreadPoolParameters
Since threadpool increments the current number of threads according to current
load, i.e. how many jobs are waiting in the queue. The count however, is
constrained by max and min limits of workers. The logic of this new API works
like this:
1) setting the minimum
a) When the limit is increased, depending on the current number of
threads, new threads are possibly spawned if the current number of
threads is less than the new minimum limit
b) Decreasing the minimum limit has no possible effect on the current
number of threads
2) setting the maximum
a) Icreasing the maximum limit has no immediate effect on the current
number of threads, it only allows the threadpool to spawn more
threads when new jobs, that would otherwise end up queued, arrive.
b) Decreasing the maximum limit may affect the current number of
threads, if the current number of threads is less than the new
maximum limit. Since there may be some ongoing time-consuming jobs
that would effectively block this API from killing any threads.
Therefore, this API is asynchronous with best-effort execution,
i.e. the necessary number of workers will be terminated once they
finish their previous job, unless other workers had already
terminated, decreasing the limit to the requested value.
3) setting priority workers
- both increase and decrease in count of these workers have an
immediate impact on the current number of workers, new ones will be
spawned or some of them get terminated respectively.
Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-02-22 13:24:04 +00:00
|
|
|
args->params.params_len,
|
|
|
|
ADMIN_SERVER_THREADPOOL_PARAMETERS_MAX,
|
|
|
|
¶ms,
|
|
|
|
&nparams) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
|
|
|
|
if (adminServerSetThreadPoolParameters(srv, params,
|
|
|
|
nparams, args->flags) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
|
|
|
|
virTypedParamsFree(params, nparams);
|
|
|
|
virObjectUnref(srv);
|
|
|
|
return rv;
|
|
|
|
}
|
2016-04-22 11:05:42 +00:00
|
|
|
|
|
|
|
static int
|
2021-03-11 07:16:13 +00:00
|
|
|
adminDispatchClientGetInfo(virNetServer *server G_GNUC_UNUSED,
|
|
|
|
virNetServerClient *client,
|
|
|
|
virNetMessage *msg G_GNUC_UNUSED,
|
|
|
|
struct virNetMessageError *rerr,
|
2016-04-22 11:05:42 +00:00
|
|
|
struct admin_client_get_info_args *args,
|
|
|
|
struct admin_client_get_info_ret *ret)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
2021-03-11 07:16:13 +00:00
|
|
|
virNetServer *srv = NULL;
|
|
|
|
virNetServerClient *clnt = NULL;
|
2016-04-22 11:05:42 +00:00
|
|
|
virTypedParameterPtr params = NULL;
|
|
|
|
int nparams = 0;
|
|
|
|
struct daemonAdmClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
|
|
|
|
|
|
|
if (!(srv = virNetDaemonGetServer(priv->dmn, args->clnt.srv.name))) {
|
|
|
|
virReportError(VIR_ERR_NO_SERVER,
|
|
|
|
_("no server with matching name '%s' found"),
|
|
|
|
args->clnt.srv.name);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(clnt = virNetServerGetClient(srv, args->clnt.id))) {
|
|
|
|
virReportError(VIR_ERR_NO_CLIENT,
|
2016-05-04 19:15:11 +00:00
|
|
|
_("no client with matching id '%llu' found"),
|
|
|
|
(unsigned long long) args->clnt.id);
|
2016-04-22 11:05:42 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (adminClientGetInfo(clnt, ¶ms, &nparams, args->flags) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (virTypedParamsSerialize(params, nparams,
|
2019-08-27 08:57:49 +00:00
|
|
|
ADMIN_CLIENT_INFO_PARAMETERS_MAX,
|
2021-03-11 07:16:13 +00:00
|
|
|
(struct _virTypedParameterRemote **) &ret->params.params_val,
|
2016-04-22 11:05:42 +00:00
|
|
|
&ret->params.params_len,
|
|
|
|
VIR_TYPED_PARAM_STRING_OKAY) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
|
|
|
|
virTypedParamsFree(params, nparams);
|
|
|
|
virObjectUnref(clnt);
|
|
|
|
virObjectUnref(srv);
|
|
|
|
return rv;
|
|
|
|
}
|
2016-04-04 08:28:22 +00:00
|
|
|
|
|
|
|
static int
|
2021-03-11 07:16:13 +00:00
|
|
|
adminDispatchServerGetClientLimits(virNetServer *server G_GNUC_UNUSED,
|
|
|
|
virNetServerClient *client,
|
|
|
|
virNetMessage *msg G_GNUC_UNUSED,
|
|
|
|
struct virNetMessageError *rerr G_GNUC_UNUSED,
|
2016-04-04 08:28:22 +00:00
|
|
|
admin_server_get_client_limits_args *args,
|
|
|
|
admin_server_get_client_limits_ret *ret)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
2021-03-11 07:16:13 +00:00
|
|
|
virNetServer *srv = NULL;
|
2016-04-04 08:28:22 +00:00
|
|
|
virTypedParameterPtr params = NULL;
|
|
|
|
int nparams = 0;
|
|
|
|
struct daemonAdmClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
|
|
|
|
|
|
|
if (!(srv = virNetDaemonGetServer(priv->dmn, args->srv.name)))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (adminServerGetClientLimits(srv, ¶ms, &nparams, args->flags) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (virTypedParamsSerialize(params, nparams,
|
2019-08-27 08:57:49 +00:00
|
|
|
ADMIN_SERVER_CLIENT_LIMITS_MAX,
|
2021-03-11 07:16:13 +00:00
|
|
|
(struct _virTypedParameterRemote **) &ret->params.params_val,
|
2016-04-04 08:28:22 +00:00
|
|
|
&ret->params.params_len, 0) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
|
|
|
|
virTypedParamsFree(params, nparams);
|
|
|
|
virObjectUnref(srv);
|
|
|
|
return rv;
|
|
|
|
}
|
2016-04-04 12:24:52 +00:00
|
|
|
|
|
|
|
static int
|
2021-03-11 07:16:13 +00:00
|
|
|
adminDispatchServerSetClientLimits(virNetServer *server G_GNUC_UNUSED,
|
|
|
|
virNetServerClient *client,
|
|
|
|
virNetMessage *msg G_GNUC_UNUSED,
|
|
|
|
struct virNetMessageError *rerr G_GNUC_UNUSED,
|
2016-04-04 12:24:52 +00:00
|
|
|
admin_server_set_client_limits_args *args)
|
|
|
|
{
|
|
|
|
int rv = -1;
|
2021-03-11 07:16:13 +00:00
|
|
|
virNetServer *srv = NULL;
|
2016-04-04 12:24:52 +00:00
|
|
|
virTypedParameterPtr params = NULL;
|
|
|
|
int nparams = 0;
|
|
|
|
struct daemonAdmClientPrivate *priv =
|
|
|
|
virNetServerClientGetPrivateData(client);
|
|
|
|
|
|
|
|
if (!(srv = virNetDaemonGetServer(priv->dmn, args->srv.name))) {
|
|
|
|
virReportError(VIR_ERR_NO_SERVER,
|
|
|
|
_("no server with matching name '%s' found"),
|
|
|
|
args->srv.name);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
if (virTypedParamsDeserialize((struct _virTypedParameterRemote *) args->params.params_val,
|
2016-04-04 12:24:52 +00:00
|
|
|
args->params.params_len,
|
|
|
|
ADMIN_SERVER_CLIENT_LIMITS_MAX, ¶ms, &nparams) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (adminServerSetClientLimits(srv, params, nparams, args->flags) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
rv = 0;
|
|
|
|
cleanup:
|
|
|
|
if (rv < 0)
|
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
virTypedParamsFree(params, nparams);
|
|
|
|
virObjectUnref(srv);
|
|
|
|
return rv;
|
|
|
|
}
|
2016-03-04 22:00:40 +00:00
|
|
|
|
|
|
|
/* Returns the number of outputs stored in @outputs */
|
|
|
|
static int
|
|
|
|
adminConnectGetLoggingOutputs(char **outputs, unsigned int flags)
|
|
|
|
{
|
|
|
|
char *tmp = NULL;
|
|
|
|
|
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
|
|
|
if (!(tmp = virLogGetOutputs()))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
*outputs = tmp;
|
|
|
|
return virLogGetNbOutputs();
|
|
|
|
}
|
|
|
|
|
2016-03-04 21:58:55 +00:00
|
|
|
/* Returns the number of defined filters or -1 in case of an error */
|
|
|
|
static int
|
|
|
|
adminConnectGetLoggingFilters(char **filters, unsigned int flags)
|
|
|
|
{
|
|
|
|
char *tmp = NULL;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
|
|
|
if ((ret = virLogGetNbFilters()) > 0 && !(tmp = virLogGetFilters()))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
*filters = tmp;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-03-08 12:37:56 +00:00
|
|
|
static int
|
2021-03-11 07:16:13 +00:00
|
|
|
adminConnectSetLoggingOutputs(virNetDaemon *dmn G_GNUC_UNUSED,
|
2016-03-08 12:37:56 +00:00
|
|
|
const char *outputs,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
|
|
|
return virLogSetOutputs(outputs);
|
|
|
|
}
|
|
|
|
|
2016-03-30 13:14:54 +00:00
|
|
|
static int
|
2021-03-11 07:16:13 +00:00
|
|
|
adminConnectSetLoggingFilters(virNetDaemon *dmn G_GNUC_UNUSED,
|
2016-03-30 13:14:54 +00:00
|
|
|
const char *filters,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
|
|
|
return virLogSetFilters(filters);
|
|
|
|
}
|
|
|
|
|
2022-06-13 11:02:09 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
adminConnectSetDaemonTimeout(virNetDaemon *dmn,
|
|
|
|
unsigned int timeout,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
|
|
|
return virNetDaemonAutoShutdown(dmn, timeout);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-03-04 22:00:40 +00:00
|
|
|
static int
|
2021-03-11 07:16:13 +00:00
|
|
|
adminDispatchConnectGetLoggingOutputs(virNetServer *server G_GNUC_UNUSED,
|
|
|
|
virNetServerClient *client G_GNUC_UNUSED,
|
|
|
|
virNetMessage *msg G_GNUC_UNUSED,
|
|
|
|
struct virNetMessageError *rerr,
|
2016-03-04 22:00:40 +00:00
|
|
|
admin_connect_get_logging_outputs_args *args,
|
|
|
|
admin_connect_get_logging_outputs_ret *ret)
|
|
|
|
{
|
|
|
|
char *outputs = NULL;
|
|
|
|
int noutputs = 0;
|
|
|
|
|
2017-09-05 08:06:33 +00:00
|
|
|
if ((noutputs = adminConnectGetLoggingOutputs(&outputs, args->flags)) < 0) {
|
2016-03-04 22:00:40 +00:00
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2019-10-16 11:45:15 +00:00
|
|
|
ret->outputs = g_steal_pointer(&outputs);
|
2016-03-04 22:00:40 +00:00
|
|
|
ret->noutputs = noutputs;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2016-03-04 21:58:55 +00:00
|
|
|
|
|
|
|
static int
|
2021-03-11 07:16:13 +00:00
|
|
|
adminDispatchConnectGetLoggingFilters(virNetServer *server G_GNUC_UNUSED,
|
|
|
|
virNetServerClient *client G_GNUC_UNUSED,
|
|
|
|
virNetMessage *msg G_GNUC_UNUSED,
|
|
|
|
struct virNetMessageError *rerr,
|
2016-03-04 21:58:55 +00:00
|
|
|
admin_connect_get_logging_filters_args *args,
|
|
|
|
admin_connect_get_logging_filters_ret *ret)
|
|
|
|
{
|
|
|
|
char *filters = NULL;
|
|
|
|
int nfilters = 0;
|
|
|
|
|
|
|
|
if ((nfilters = adminConnectGetLoggingFilters(&filters, args->flags)) < 0) {
|
|
|
|
virNetMessageSaveError(rerr);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nfilters == 0) {
|
|
|
|
ret->filters = NULL;
|
|
|
|
} else {
|
|
|
|
char **ret_filters = NULL;
|
2020-09-23 18:44:29 +00:00
|
|
|
ret_filters = g_new0(char *, 1);
|
2016-03-04 21:58:55 +00:00
|
|
|
|
|
|
|
*ret_filters = filters;
|
|
|
|
ret->filters = ret_filters;
|
|
|
|
}
|
|
|
|
ret->nfilters = nfilters;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2018-01-19 11:30:31 +00:00
|
|
|
#include "admin_server_dispatch_stubs.h"
|