]> xenbits.xensource.com Git - libvirt.git/commitdiff
Introduce virDomainRename API
authorTomas Meszaros <exo@tty.sk>
Mon, 10 Aug 2015 19:59:14 +0000 (21:59 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 14 Aug 2015 08:50:20 +0000 (10:50 +0200)
Also, among with this new API new ACL that restricts rename
capability is invented too.

Signed-off-by: Tomas Meszaros <exo@tty.sk>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
include/libvirt/libvirt-domain.h
src/driver-hypervisor.h
src/libvirt-domain.c
src/libvirt_public.syms
src/remote/remote_driver.c
src/remote/remote_protocol.x
src/remote_protocol-structs

index e8ea7b4102837caaf15a048c3c2d119b4c42a915..fb3ea0f364466e726edfd5aebcb95f298cd42355 100644 (file)
@@ -3844,4 +3844,8 @@ int virDomainSetUserPassword(virDomainPtr dom,
                              const char *password,
                              unsigned int flags);
 
+int virDomainRename(virDomainPtr dom,
+                    const char *new_name,
+                    unsigned int flags);
+
 #endif /* __VIR_LIBVIRT_DOMAIN_H__ */
index 3275343ea9563fd7f97761d281e1b9c01fec1851..ae2ec4d4565769de99aab5ca3efd9e2f1400ee7a 100644 (file)
@@ -649,6 +649,11 @@ typedef int
 typedef int
 (*virDrvDomainIsActive)(virDomainPtr dom);
 
+typedef int
+(*virDrvDomainRename)(virDomainPtr dom,
+                      const char *new_name,
+                      unsigned int flags);
+
 typedef int
 (*virDrvDomainIsPersistent)(virDomainPtr dom);
 
@@ -1347,6 +1352,7 @@ struct _virHypervisorDriver {
     virDrvConnectIsEncrypted connectIsEncrypted;
     virDrvConnectIsSecure connectIsSecure;
     virDrvDomainIsActive domainIsActive;
+    virDrvDomainRename domainRename;
     virDrvDomainIsPersistent domainIsPersistent;
     virDrvDomainIsUpdated domainIsUpdated;
     virDrvConnectCompareCPU connectCompareCPU;
index dc89bab1191102e16f3fce858764b79e105caef2..9065dab120a9100d9a319f40609725663d071cd4 100644 (file)
@@ -8774,6 +8774,41 @@ virDomainIsPersistent(virDomainPtr dom)
     return -1;
 }
 
+/**
+ * virDomainRename:
+ * @dom: pointer to the domain object
+ * @new_name: new domain name
+ * @flags: extra flags; not used yet, so callers should always pass 0
+ *
+ * Rename a domain. New domain name is specified in the second
+ * argument. Depending on each driver implementation it may be
+ * required that domain is in a specific state.
+ *
+ * Returns 0 if successfully renamed, -1 on error
+ */
+int
+virDomainRename(virDomainPtr dom,
+                const char *new_name,
+                unsigned int flags)
+{
+    VIR_DEBUG("dom=%p, new_name=%s", dom, NULLSTR(new_name));
+
+    virResetLastError();
+    virCheckDomainReturn(dom, -1);
+    virCheckNonNullArgGoto(new_name, error);
+
+    if (dom->conn->driver->domainRename) {
+        int ret = dom->conn->driver->domainRename(dom, new_name, flags);
+        if (ret < 0)
+            goto error;
+        return ret;
+    }
+
+    virReportUnsupportedError();
+ error:
+    virDispatchError(dom->conn);
+    return -1;
+}
 
 /**
  * virDomainIsUpdated:
index 2c653f2fcca1e30599acc7e1d5d74ac8d50905c0..dd9419185f4564ca0307a6102d6374d91a27183e 100644 (file)
@@ -720,4 +720,9 @@ LIBVIRT_1.2.17 {
         virTypedParamsAddStringList;
 } LIBVIRT_1.2.16;
 
+LIBVIRT_1.2.19 {
+    global:
+        virDomainRename;
+} LIBVIRT_1.2.17;
+
 # .... define new API here using predicted next version number ....
index 5c4cf7c1511285b3d466a90aa30e945455c711ec..ec26ebe2c60b78e49242ccbf2cd27686040daea0 100644 (file)
@@ -8391,6 +8391,7 @@ static virHypervisorDriver hypervisor_driver = {
     .domainGetFSInfo = remoteDomainGetFSInfo, /* 1.2.11 */
     .domainInterfaceAddresses = remoteDomainInterfaceAddresses, /* 1.2.14 */
     .domainSetUserPassword = remoteDomainSetUserPassword, /* 1.2.16 */
+    .domainRename = remoteDomainRename, /* 1.2.19 */
 };
 
 static virNetworkDriver network_driver = {
index 9f1be6b3469572d75619eb648f24153a73c462ea..770aa72dc0f6573452acdb5c814bafded96ef096 100644 (file)
@@ -3230,6 +3230,15 @@ struct remote_domain_set_user_password_args {
     unsigned int flags;
 };
 
+struct remote_domain_rename_args {
+    remote_nonnull_domain dom;
+    remote_string new_name;
+    unsigned int flags;
+};
+
+struct remote_domain_rename_ret {
+    int rename;
+};
 
 /*----- Protocol. -----*/
 
@@ -5696,5 +5705,12 @@ 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:write
+     * @acl: domain:save
+     */
+    REMOTE_PROC_DOMAIN_RENAME = 358
 };
index 48c3bd88605a79c907ef2688b9d9d72379abca0a..ca36dc96e634e2e30a017ee0d405cf08b90f7891 100644 (file)
@@ -2684,6 +2684,14 @@ struct remote_domain_set_user_password_args {
         remote_string              password;
         u_int                      flags;
 };
+struct remote_domain_rename_args {
+        remote_nonnull_domain      dom;
+        remote_string              new_name;
+        u_int                      flags;
+};
+struct remote_domain_rename_ret {
+        int                        rename;
+};
 enum remote_procedure {
         REMOTE_PROC_CONNECT_OPEN = 1,
         REMOTE_PROC_CONNECT_CLOSE = 2,
@@ -3042,4 +3050,5 @@ 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_RENAME = 358,
 };