[libvirt] [PATCH 2/2] Change name of the domain upon successful rename

Martin Kletzander mkletzan at redhat.com
Fri Sep 4 12:10:08 UTC 2015


Signed-off-by: Martin Kletzander <mkletzan at redhat.com>
---
 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 aca00c0974e5..a1dd64087b3b 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 92a92e2bfa24..80f4a8b3a181 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
      */
-- 
2.5.1




More information about the libvir-list mailing list