Implements the call for remote configuration
Signed-off-by: Nikunj A. Dadhania <nikunj(a)linux.vnet.ibm.com>
---
daemon/remote.c | 66 ++++++++++++++++++++++++++++++++++
daemon/remote_dispatch_prototypes.h | 8 ++++
daemon/remote_dispatch_table.h | 5 +++
src/libvirt.c | 1 -
src/remote/remote_driver.c | 67 ++++++++++++++++++++++++++++++++++-
src/remote/remote_protocol.c | 62 ++++++++++++++++++++++++++++++++
src/remote/remote_protocol.h | 36 +++++++++++++++++++
7 files changed, 242 insertions(+), 3 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index 118654c..2d4dc5d 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -2332,6 +2332,72 @@ remoteDispatchDomainSetMemory (struct qemud_server *server
ATTRIBUTE_UNUSED,
}
static int
+remoteDispatchDomainSetMemoryParameters (struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_set_memory_parameters_args *args,
+ void *ret ATTRIBUTE_UNUSED)
+{
+ virDomainPtr dom;
+ int i, r, nparams;
+ virMemoryParameterPtr params;
+
+ nparams = args->params.params_len;
+
+ if (nparams > REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX) {
+ remoteDispatchFormatError (rerr, "%s", _("nparams too
large"));
+ return -1;
+ }
+ if (VIR_ALLOC_N(params, nparams) < 0) {
+ remoteDispatchOOMError(rerr);
+ return -1;
+ }
+
+ /* Deserialise parameters. */
+ for (i = 0; i < nparams; ++i) {
+ if (virStrcpyStatic(params[i].field, args->params.params_val[i].field) ==
NULL) {
+ remoteDispatchFormatError(rerr, _("Field %s too big for
destination"),
+ args->params.params_val[i].field);
+ return -1;
+ }
+ params[i].type = args->params.params_val[i].value.type;
+ switch (params[i].type) {
+ case VIR_DOMAIN_SCHED_FIELD_INT:
+ params[i].value.i =
args->params.params_val[i].value.remote_memory_param_value_u.i; break;
+ case VIR_DOMAIN_SCHED_FIELD_UINT:
+ params[i].value.ui =
args->params.params_val[i].value.remote_memory_param_value_u.ui; break;
+ case VIR_DOMAIN_SCHED_FIELD_LLONG:
+ params[i].value.l =
args->params.params_val[i].value.remote_memory_param_value_u.l; break;
+ case VIR_DOMAIN_SCHED_FIELD_ULLONG:
+ params[i].value.ul =
args->params.params_val[i].value.remote_memory_param_value_u.ul; break;
+ case VIR_DOMAIN_SCHED_FIELD_DOUBLE:
+ params[i].value.d =
args->params.params_val[i].value.remote_memory_param_value_u.d; break;
+ case VIR_DOMAIN_SCHED_FIELD_BOOLEAN:
+ params[i].value.b =
args->params.params_val[i].value.remote_memory_param_value_u.b; break;
+ }
+ }
+
+ dom = get_nonnull_domain (conn, args->dom);
+ if (dom == NULL) {
+ VIR_FREE(params);
+ remoteDispatchConnError(rerr, conn);
+ return -1;
+ }
+
+ r = virDomainSetMemoryParameters (dom, params, nparams);
+ virDomainFree(dom);
+ VIR_FREE(params);
+ if (r == -1) {
+ remoteDispatchConnError(rerr, conn);
+ return -1;
+ }
+
+ return 0;
+}
+
+static int
remoteDispatchDomainSetVcpus (struct qemud_server *server ATTRIBUTE_UNUSED,
struct qemud_client *client ATTRIBUTE_UNUSED,
virConnectPtr conn,
diff --git a/daemon/remote_dispatch_prototypes.h b/daemon/remote_dispatch_prototypes.h
index cf1a0f9..f2bc207 100644
--- a/daemon/remote_dispatch_prototypes.h
+++ b/daemon/remote_dispatch_prototypes.h
@@ -522,6 +522,14 @@ static int remoteDispatchDomainSetMemory(
remote_error *err,
remote_domain_set_memory_args *args,
void *ret);
+static int remoteDispatchDomainSetMemoryParameters(
+ struct qemud_server *server,
+ struct qemud_client *client,
+ virConnectPtr conn,
+ remote_message_header *hdr,
+ remote_error *err,
+ remote_domain_set_memory_parameters_args *args,
+ void *ret);
static int remoteDispatchDomainSetSchedulerParameters(
struct qemud_server *server,
struct qemud_client *client,
diff --git a/daemon/remote_dispatch_table.h b/daemon/remote_dispatch_table.h
index ef00edd..6692e53 100644
--- a/daemon/remote_dispatch_table.h
+++ b/daemon/remote_dispatch_table.h
@@ -987,3 +987,8 @@
.args_filter = (xdrproc_t) xdr_remote_domain_create_with_flags_args,
.ret_filter = (xdrproc_t) xdr_remote_domain_create_with_flags_ret,
},
+{ /* DomainSetMemoryParameters => 197 */
+ .fn = (dispatch_fn) remoteDispatchDomainSetMemoryParameters,
+ .args_filter = (xdrproc_t) xdr_remote_domain_set_memory_parameters_args,
+ .ret_filter = (xdrproc_t) xdr_void,
+},
diff --git a/src/libvirt.c b/src/libvirt.c
index 64daaa3..3e83f94 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -3040,7 +3040,6 @@ virDomainSetMemoryParameters(virDomainPtr domain,
goto error;
return ret;
}
-
virLibConnError (conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
error:
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 1e9cb6c..7e4427f 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -2284,6 +2284,71 @@ done:
}
static int
+remoteDomainSetMemoryParameters (virDomainPtr domain,
+ virMemoryParameterPtr params, int nparams)
+{
+ int rv = -1;
+ remote_domain_set_memory_parameters_args args;
+ int i, do_error;
+ struct private_data *priv = domain->conn->privateData;
+
+ remoteDriverLock(priv);
+
+ make_nonnull_domain (&args.dom, domain);
+
+ /* Serialise the memory parameters. */
+ args.params.params_len = nparams;
+ if (VIR_ALLOC_N(args.params.params_val, nparams) < 0) {
+ virReportOOMError();
+ goto done;
+ }
+
+ do_error = 0;
+ for (i = 0; i < nparams; ++i) {
+ // call() will free this:
+ args.params.params_val[i].field = strdup (params[i].field);
+ if (args.params.params_val[i].field == NULL) {
+ virReportOOMError();
+ do_error = 1;
+ }
+ args.params.params_val[i].value.type = params[i].type;
+ switch (params[i].type) {
+ case VIR_DOMAIN_SCHED_FIELD_INT:
+ args.params.params_val[i].value.remote_memory_param_value_u.i =
params[i].value.i; break;
+ case VIR_DOMAIN_SCHED_FIELD_UINT:
+ args.params.params_val[i].value.remote_memory_param_value_u.ui =
params[i].value.ui; break;
+ case VIR_DOMAIN_SCHED_FIELD_LLONG:
+ args.params.params_val[i].value.remote_memory_param_value_u.l =
params[i].value.l; break;
+ case VIR_DOMAIN_SCHED_FIELD_ULLONG:
+ args.params.params_val[i].value.remote_memory_param_value_u.ul =
params[i].value.ul; break;
+ case VIR_DOMAIN_SCHED_FIELD_DOUBLE:
+ args.params.params_val[i].value.remote_memory_param_value_u.d =
params[i].value.d; break;
+ case VIR_DOMAIN_SCHED_FIELD_BOOLEAN:
+ args.params.params_val[i].value.remote_memory_param_value_u.b =
params[i].value.b; break;
+ default:
+ remoteError(VIR_ERR_RPC, "%s", _("unknown parameter
type"));
+ do_error = 1;
+ }
+ }
+
+ if (do_error) {
+ xdr_free ((xdrproc_t) xdr_remote_domain_set_memory_parameters_args, (char *)
&args);
+ goto done;
+ }
+
+ if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_SET_MEMORY_PARAMETERS,
+ (xdrproc_t) xdr_remote_domain_set_memory_parameters_args, (char *)
&args,
+ (xdrproc_t) xdr_void, (char *) NULL) == -1)
+ goto done;
+
+ rv = 0;
+
+done:
+ remoteDriverUnlock(priv);
+ return rv;
+}
+
+static int
remoteDomainGetInfo (virDomainPtr domain, virDomainInfoPtr info)
{
int rv = -1;
@@ -10358,7 +10423,7 @@ static virDriver remote_driver = {
remoteDomainRevertToSnapshot, /* domainRevertToSnapshot */
remoteDomainSnapshotDelete, /* domainSnapshotDelete */
remoteQemuDomainMonitorCommand, /* qemuDomainMonitorCommand */
- NULL, /* domainSetMemoryParameters */
+ remoteDomainSetMemoryParameters, /* domainSetMemoryParameters */
};
static virNetworkDriver network_driver = {
diff --git a/src/remote/remote_protocol.c b/src/remote/remote_protocol.c
index 2483004..72a6e39 100644
--- a/src/remote/remote_protocol.c
+++ b/src/remote/remote_protocol.c
@@ -264,7 +264,7 @@ bool_t
xdr_remote_sched_param_value (XDR *xdrs, remote_sched_param_value *objp)
{
- if (!xdr_int (xdrs, &objp->type))
+ if (!xdr_int (xdrs, &objp->type))
return FALSE;
switch (objp->type) {
case VIR_DOMAIN_SCHED_FIELD_INT:
@@ -308,6 +308,53 @@ xdr_remote_sched_param (XDR *xdrs, remote_sched_param *objp)
}
bool_t
+xdr_remote_memory_param_value (XDR *xdrs, remote_memory_param_value *objp)
+{
+
+ if (!xdr_int (xdrs, &objp->type))
+ return FALSE;
+ switch (objp->type) {
+ case VIR_DOMAIN_MEMORY_FIELD_INT:
+ return FALSE;
+ break;
+ case VIR_DOMAIN_MEMORY_FIELD_UINT:
+ if (!xdr_u_int (xdrs, &objp->remote_memory_param_value_u.ui))
+ return FALSE;
+ break;
+ case VIR_DOMAIN_MEMORY_FIELD_LLONG:
+ if (!xdr_int64_t (xdrs, &objp->remote_memory_param_value_u.l))
+ return FALSE;
+ break;
+ case VIR_DOMAIN_MEMORY_FIELD_ULLONG:
+ if (!xdr_uint64_t (xdrs, &objp->remote_memory_param_value_u.ul))
+ return FALSE;
+ break;
+ case VIR_DOMAIN_MEMORY_FIELD_DOUBLE:
+ if (!xdr_double (xdrs, &objp->remote_memory_param_value_u.d))
+ return FALSE;
+ break;
+ case VIR_DOMAIN_MEMORY_FIELD_BOOLEAN:
+ if (!xdr_int (xdrs, &objp->remote_memory_param_value_u.b))
+ return FALSE;
+ break;
+ default:
+ return FALSE;
+ }
+ return TRUE;
+}
+
+bool_t
+xdr_remote_memory_param (XDR *xdrs, remote_memory_param *objp)
+{
+
+ if (!xdr_remote_nonnull_string (xdrs, &objp->field))
+ return FALSE;
+ if (!xdr_remote_memory_param_value (xdrs, &objp->value))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
xdr_remote_open_args (XDR *xdrs, remote_open_args *objp)
{
@@ -964,6 +1011,19 @@ xdr_remote_domain_set_memory_args (XDR *xdrs,
remote_domain_set_memory_args *obj
}
bool_t
+xdr_remote_domain_set_memory_parameters_args (XDR *xdrs,
remote_domain_set_memory_parameters_args *objp)
+{
+ char **objp_cpp0 = (char **) (void *) &objp->params.params_val;
+
+ if (!xdr_remote_nonnull_domain (xdrs, &objp->dom))
+ return FALSE;
+ if (!xdr_array (xdrs, objp_cpp0, (u_int *) &objp->params.params_len,
REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX,
+ sizeof (remote_memory_param), (xdrproc_t) xdr_remote_memory_param))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
xdr_remote_domain_get_info_args (XDR *xdrs, remote_domain_get_info_args *objp)
{
diff --git a/src/remote/remote_protocol.h b/src/remote/remote_protocol.h
index afe9287..b9fa2d3 100644
--- a/src/remote/remote_protocol.h
+++ b/src/remote/remote_protocol.h
@@ -53,6 +53,7 @@ typedef remote_nonnull_string *remote_string;
#define REMOTE_NODE_DEVICE_CAPS_LIST_MAX 16384
#define REMOTE_NWFILTER_NAME_LIST_MAX 1024
#define REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX 16
+#define REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX 16
#define REMOTE_NODE_MAX_CELLS 1024
#define REMOTE_AUTH_SASL_DATA_MAX 65536
#define REMOTE_AUTH_TYPE_LIST_MAX 20
@@ -186,6 +187,25 @@ struct remote_sched_param {
};
typedef struct remote_sched_param remote_sched_param;
+struct remote_memory_param_value {
+ int type;
+ union {
+ int i;
+ u_int ui;
+ int64_t l;
+ uint64_t ul;
+ double d;
+ int b;
+ } remote_memory_param_value_u;
+};
+typedef struct remote_memory_param_value remote_memory_param_value;
+
+struct remote_memory_param {
+ remote_nonnull_string field;
+ remote_memory_param_value value;
+};
+typedef struct remote_memory_param remote_memory_param;
+
struct remote_open_args {
remote_string name;
int flags;
@@ -525,6 +545,15 @@ struct remote_domain_set_memory_args {
};
typedef struct remote_domain_set_memory_args remote_domain_set_memory_args;
+struct remote_domain_set_memory_parameters_args {
+ remote_nonnull_domain dom;
+ struct {
+ u_int params_len;
+ remote_memory_param *params_val;
+ } params;
+};
+typedef struct remote_domain_set_memory_parameters_args
remote_domain_set_memory_parameters_args;
+
struct remote_domain_get_info_args {
remote_nonnull_domain dom;
};
@@ -2233,6 +2262,7 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_GET_BLOCK_INFO = 194,
REMOTE_PROC_DOMAIN_EVENT_IO_ERROR_REASON = 195,
REMOTE_PROC_DOMAIN_CREATE_WITH_FLAGS = 196,
+ REMOTE_PROC_DOMAIN_SET_MEMORY_PARAMETERS = 197,
};
typedef enum remote_procedure remote_procedure;
@@ -2288,6 +2318,8 @@ extern bool_t xdr_remote_auth_type (XDR *, remote_auth_type*);
extern bool_t xdr_remote_vcpu_info (XDR *, remote_vcpu_info*);
extern bool_t xdr_remote_sched_param_value (XDR *, remote_sched_param_value*);
extern bool_t xdr_remote_sched_param (XDR *, remote_sched_param*);
+extern bool_t xdr_remote_memory_param_value (XDR *, remote_memory_param_value*);
+extern bool_t xdr_remote_memory_param (XDR *, remote_memory_param*);
extern bool_t xdr_remote_open_args (XDR *, remote_open_args*);
extern bool_t xdr_remote_supports_feature_args (XDR *, remote_supports_feature_args*);
extern bool_t xdr_remote_supports_feature_ret (XDR *, remote_supports_feature_ret*);
@@ -2343,6 +2375,7 @@ extern bool_t xdr_remote_domain_get_max_memory_args (XDR *,
remote_domain_get_m
extern bool_t xdr_remote_domain_get_max_memory_ret (XDR *,
remote_domain_get_max_memory_ret*);
extern bool_t xdr_remote_domain_set_max_memory_args (XDR *,
remote_domain_set_max_memory_args*);
extern bool_t xdr_remote_domain_set_memory_args (XDR *,
remote_domain_set_memory_args*);
+extern bool_t xdr_remote_domain_set_memory_parameters_args (XDR *,
remote_domain_set_memory_parameters_args*);
extern bool_t xdr_remote_domain_get_info_args (XDR *, remote_domain_get_info_args*);
extern bool_t xdr_remote_domain_get_info_ret (XDR *, remote_domain_get_info_ret*);
extern bool_t xdr_remote_domain_save_args (XDR *, remote_domain_save_args*);
@@ -2623,6 +2656,8 @@ extern bool_t xdr_remote_auth_type ();
extern bool_t xdr_remote_vcpu_info ();
extern bool_t xdr_remote_sched_param_value ();
extern bool_t xdr_remote_sched_param ();
+extern bool_t xdr_remote_memory_param_value ();
+extern bool_t xdr_remote_memory_param ();
extern bool_t xdr_remote_open_args ();
extern bool_t xdr_remote_supports_feature_args ();
extern bool_t xdr_remote_supports_feature_ret ();
@@ -2678,6 +2713,7 @@ extern bool_t xdr_remote_domain_get_max_memory_args ();
extern bool_t xdr_remote_domain_get_max_memory_ret ();
extern bool_t xdr_remote_domain_set_max_memory_args ();
extern bool_t xdr_remote_domain_set_memory_args ();
+extern bool_t xdr_remote_domain_set_memory_parameters_args ();
extern bool_t xdr_remote_domain_get_info_args ();
extern bool_t xdr_remote_domain_get_info_ret ();
extern bool_t xdr_remote_domain_save_args ();