From 53704bf24e8f89696d551b57f017c930ae9d5909 Mon Sep 17 00:00:00 2001 From: Martin Kletzander Date: Thu, 27 Aug 2015 12:43:15 +0200 Subject: [PATCH] Change name of the domain upon successful rename Signed-off-by: Martin Kletzander --- src/remote/remote_driver.c | 41 ++++++++++++++++++++++++++++++++++++ src/remote/remote_protocol.x | 2 +- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index aca00c0974..a1dd64087b 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8038,6 +8038,47 @@ remoteDomainInterfaceAddresses(virDomainPtr dom, } +static int +remoteDomainRename(virDomainPtr dom, const char *new_name, unsigned int flags) +{ + int rv = -1; + struct private_data *priv = dom->conn->privateData; + remote_domain_rename_args args; + remote_domain_rename_ret ret; + char *tmp = NULL; + + if (VIR_STRDUP(tmp, new_name) < 0) + return -1; + + remoteDriverLock(priv); + + make_nonnull_domain(&args.dom, dom); + args.new_name = new_name ? (char **)&new_name : NULL; + args.flags = flags; + + memset(&ret, 0, sizeof(ret)); + + if (call(dom->conn, priv, 0, REMOTE_PROC_DOMAIN_RENAME, + (xdrproc_t)xdr_remote_domain_rename_args, (char *)&args, + (xdrproc_t)xdr_remote_domain_rename_ret, (char *)&ret) == -1) { + goto done; + } + + rv = ret.retcode; + + if (rv == 0) { + VIR_FREE(dom->name); + dom->name = tmp; + tmp = NULL; + } + + done: + remoteDriverUnlock(priv); + VIR_FREE(tmp); + return rv; +} + + /* get_nonnull_domain and get_nonnull_network turn an on-wire * (name, uuid) pair into virDomainPtr or virNetworkPtr object. * These can return NULL if underlying memory allocations fail, diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 92a92e2bfa..80f4a8b3a1 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -5708,7 +5708,7 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_SET_USER_PASSWORD = 357, /** - * @generate: both + * @generate: server * @acl: domain:write * @acl: domain:save */ -- GitLab