From: Eli Qiao <liyong.qiao@xxxxxxxxx> Add remote support for the set/get migration parameters API's Signed-off-by: Eli Qiao <liyong.qiao@xxxxxxxxx> Signed-off-by: ShaoHe Feng <shaohe.feng@xxxxxxxxx> --- daemon/remote.c | 62 ++++++++++++++++++++++++++++++++++++++++++++ src/remote/remote_driver.c | 54 ++++++++++++++++++++++++++++++++++++++ src/remote/remote_protocol.x | 30 ++++++++++++++++++++- src/remote_protocol-structs | 26 +++++++++++++++++++ 4 files changed, 171 insertions(+), 1 deletion(-) diff --git a/daemon/remote.c b/daemon/remote.c index e9e2dca..9822d46 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -5642,6 +5642,68 @@ remoteDispatchDomainMigrateFinish3Params(virNetServerPtr server ATTRIBUTE_UNUSED static int +remoteDispatchDomainMigrateGetParameters(virNetServerPtr server ATTRIBUTE_UNUSED, + virNetServerClientPtr client ATTRIBUTE_UNUSED, + virNetMessagePtr hdr ATTRIBUTE_UNUSED, + virNetMessageErrorPtr rerr, + remote_domain_migrate_get_parameters_args *args, + remote_domain_migrate_get_parameters_ret *ret) +{ + virDomainPtr dom = NULL; + int rv = -1; + virTypedParameterPtr params = NULL; + int nparams = 0; + struct daemonClientPrivate *priv = + virNetServerClientGetPrivateData(client); + + if (!priv->conn) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if (args->nparams > REMOTE_DOMAIN_MIGRATE_PARAM_LIST_MAX) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large")); + goto cleanup; + } + + if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) + goto cleanup; + nparams = args->nparams; + + if (!(dom = get_nonnull_domain(priv->conn, args->dom))) + goto cleanup; + + if (virDomainMigrateGetParameters(dom, params, &nparams, args->flags) < 0) + goto cleanup; + + /* In this case, we need to send back the number of parameters + * supported + */ + if (args->nparams == 0) { + ret->nparams = nparams; + goto success; + } + + /* Serialise the migration parameters. */ + if (remoteSerializeTypedParameters(params, nparams, + &ret->params.params_val, + &ret->params.params_len, + args->flags) < 0) + goto cleanup; + + success: + rv = 0; + + cleanup: + if (rv < 0) + virNetMessageSaveError(rerr); + virTypedParamsFree(params, nparams); + virObjectUnref(dom); + return rv; +} + + +static int remoteDispatchDomainMigrateConfirm3Params(virNetServerPtr server ATTRIBUTE_UNUSED, virNetServerClientPtr client ATTRIBUTE_UNUSED, virNetMessagePtr msg ATTRIBUTE_UNUSED, diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 273799b..1a932b6 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -7443,6 +7443,58 @@ remoteDomainMigrateConfirm3Params(virDomainPtr domain, } +static int remoteDomainMigrateGetParameters(virDomainPtr domain, + virTypedParameterPtr params, + int *nparams, + unsigned int flags) +{ + int rv = -1; + remote_domain_migrate_get_parameters_args args; + remote_domain_migrate_get_parameters_ret ret; + struct private_data *priv = domain->conn->privateData; + + remoteDriverLock(priv); + make_nonnull_domain(&args.dom, domain); + args.nparams = *nparams; + args.flags = flags; + + memset(&ret, 0, sizeof(ret)); + + if (call(domain->conn, priv, 0, REMOTE_PROC_DOMAIN_MIGRATE_GET_PARAMETERS, + (xdrproc_t) xdr_remote_domain_migrate_get_parameters_args, + (char *) &args, + (xdrproc_t) xdr_remote_domain_migrate_get_parameters_ret, + (char *) &ret) == -1) { + goto done; + } + + /* Handle the case when the caller does not know the number of parameters + * and is asking for the number of parameters supported + */ + if (*nparams == 0) { + *nparams = ret.nparams; + rv = 0; + goto cleanup; + } + + if (remoteDeserializeTypedParameters(ret.params.params_val, + ret.params.params_len, + REMOTE_DOMAIN_MIGRATE_PARAM_LIST_MAX, + ¶ms, + nparams) < 0) + goto cleanup; + + rv = 0; + + cleanup: + xdr_free((xdrproc_t) xdr_remote_domain_migrate_get_parameters_ret, + (char *) &ret); + done: + remoteDriverUnlock(priv); + return rv; +} + + static virDomainPtr remoteDomainCreateXMLWithFiles(virConnectPtr conn, const char *xml_desc, unsigned int nfiles, int *files, unsigned int flags) @@ -8308,6 +8360,8 @@ static virHypervisorDriver hypervisor_driver = { .domainMigrateSetMaxDowntime = remoteDomainMigrateSetMaxDowntime, /* 0.8.0 */ .domainMigrateGetCompressionCache = remoteDomainMigrateGetCompressionCache, /* 1.0.3 */ .domainMigrateSetCompressionCache = remoteDomainMigrateSetCompressionCache, /* 1.0.3 */ + .domainMigrateGetParameters = remoteDomainMigrateGetParameters, /* 1.2.17 */ + .domainMigrateSetParameters = remoteDomainMigrateSetParameters, /* 1.2.17 */ .domainMigrateSetMaxSpeed = remoteDomainMigrateSetMaxSpeed, /* 0.9.0 */ .domainMigrateGetMaxSpeed = remoteDomainMigrateGetMaxSpeed, /* 0.9.5 */ .connectDomainEventRegisterAny = remoteConnectDomainEventRegisterAny, /* 0.8.0 */ diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 9f1be6b..659ea3b 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -2342,6 +2342,22 @@ struct remote_domain_migrate_get_max_speed_ret { unsigned hyper bandwidth; /* insert@1 */ }; +struct remote_domain_migrate_set_parameters_args { + remote_nonnull_domain dom; + remote_typed_param params<REMOTE_DOMAIN_MIGRATE_PARAM_LIST_MAX>; + unsigned int flags; +}; + +struct remote_domain_migrate_get_parameters_args { + remote_nonnull_domain dom; + int nparams; + unsigned int flags; +}; + +struct remote_domain_migrate_get_parameters_ret { + remote_typed_param params<REMOTE_DOMAIN_MIGRATE_PARAM_LIST_MAX>; + int nparams; +}; struct remote_connect_domain_event_register_any_args { int eventID; @@ -5696,5 +5712,17 @@ enum remote_procedure { * @generate:both * @acl: domain:set_password */ - REMOTE_PROC_DOMAIN_SET_USER_PASSWORD = 357 + REMOTE_PROC_DOMAIN_SET_USER_PASSWORD = 357, + + /** + * @generate: both + * @acl: domain:migrate + */ + REMOTE_PROC_DOMAIN_MIGRATE_SET_PARAMETERS = 358, + + /** + * @generate: none + * @acl: domain:migrate + */ + REMOTE_PROC_DOMAIN_MIGRATE_GET_PARAMETERS = 359 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 48c3bd8..fd39ae8 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -1775,6 +1775,30 @@ struct remote_domain_migrate_get_max_speed_args { struct remote_domain_migrate_get_max_speed_ret { uint64_t bandwidth; }; + +struct remote_domain_migrate_set_parameters_args { + remote_nonnull_domain dom; + struct { + u_int params_len; + remote_typed_param * params_val; + } params; + u_int flags; +}; + +struct remote_domain_migrate_get_parameters_args { + remote_nonnull_domain dom; + int nparams; + u_int flags; +}; + +struct remote_domain_migrate_get_parameters_ret { + struct { + u_int params_len; + remote_typed_param * params_val; + } params; + int nparams; +}; + struct remote_connect_domain_event_register_any_args { int eventID; }; @@ -3042,4 +3066,6 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_ADD_IOTHREAD = 355, REMOTE_PROC_DOMAIN_DEL_IOTHREAD = 356, REMOTE_PROC_DOMAIN_SET_USER_PASSWORD = 357, + REMOTE_PROC_DOMAIN_MIGRATE_SET_PARAMETERS = 358, + REMOTE_PROC_DOMAIN_MIGRATE_GET_PARAMETERS = 359, }; -- 2.1.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list