提交 9f7a559a 编写于 作者: T Tomas Meszaros 提交者: Michal Privoznik

Introduce virDomainRename API

Also, among with this new API new ACL that restricts rename
capability is invented too.
Signed-off-by: NTomas Meszaros <exo@tty.sk>
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
上级 0e4972fe
...@@ -3844,4 +3844,8 @@ int virDomainSetUserPassword(virDomainPtr dom, ...@@ -3844,4 +3844,8 @@ int virDomainSetUserPassword(virDomainPtr dom,
const char *password, const char *password,
unsigned int flags); unsigned int flags);
int virDomainRename(virDomainPtr dom,
const char *new_name,
unsigned int flags);
#endif /* __VIR_LIBVIRT_DOMAIN_H__ */ #endif /* __VIR_LIBVIRT_DOMAIN_H__ */
...@@ -649,6 +649,11 @@ typedef int ...@@ -649,6 +649,11 @@ typedef int
typedef int typedef int
(*virDrvDomainIsActive)(virDomainPtr dom); (*virDrvDomainIsActive)(virDomainPtr dom);
typedef int
(*virDrvDomainRename)(virDomainPtr dom,
const char *new_name,
unsigned int flags);
typedef int typedef int
(*virDrvDomainIsPersistent)(virDomainPtr dom); (*virDrvDomainIsPersistent)(virDomainPtr dom);
...@@ -1347,6 +1352,7 @@ struct _virHypervisorDriver { ...@@ -1347,6 +1352,7 @@ struct _virHypervisorDriver {
virDrvConnectIsEncrypted connectIsEncrypted; virDrvConnectIsEncrypted connectIsEncrypted;
virDrvConnectIsSecure connectIsSecure; virDrvConnectIsSecure connectIsSecure;
virDrvDomainIsActive domainIsActive; virDrvDomainIsActive domainIsActive;
virDrvDomainRename domainRename;
virDrvDomainIsPersistent domainIsPersistent; virDrvDomainIsPersistent domainIsPersistent;
virDrvDomainIsUpdated domainIsUpdated; virDrvDomainIsUpdated domainIsUpdated;
virDrvConnectCompareCPU connectCompareCPU; virDrvConnectCompareCPU connectCompareCPU;
......
...@@ -8774,6 +8774,41 @@ virDomainIsPersistent(virDomainPtr dom) ...@@ -8774,6 +8774,41 @@ virDomainIsPersistent(virDomainPtr dom)
return -1; 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: * virDomainIsUpdated:
......
...@@ -720,4 +720,9 @@ LIBVIRT_1.2.17 { ...@@ -720,4 +720,9 @@ LIBVIRT_1.2.17 {
virTypedParamsAddStringList; virTypedParamsAddStringList;
} LIBVIRT_1.2.16; } LIBVIRT_1.2.16;
LIBVIRT_1.2.19 {
global:
virDomainRename;
} LIBVIRT_1.2.17;
# .... define new API here using predicted next version number .... # .... define new API here using predicted next version number ....
...@@ -8391,6 +8391,7 @@ static virHypervisorDriver hypervisor_driver = { ...@@ -8391,6 +8391,7 @@ static virHypervisorDriver hypervisor_driver = {
.domainGetFSInfo = remoteDomainGetFSInfo, /* 1.2.11 */ .domainGetFSInfo = remoteDomainGetFSInfo, /* 1.2.11 */
.domainInterfaceAddresses = remoteDomainInterfaceAddresses, /* 1.2.14 */ .domainInterfaceAddresses = remoteDomainInterfaceAddresses, /* 1.2.14 */
.domainSetUserPassword = remoteDomainSetUserPassword, /* 1.2.16 */ .domainSetUserPassword = remoteDomainSetUserPassword, /* 1.2.16 */
.domainRename = remoteDomainRename, /* 1.2.19 */
}; };
static virNetworkDriver network_driver = { static virNetworkDriver network_driver = {
......
...@@ -3230,6 +3230,15 @@ struct remote_domain_set_user_password_args { ...@@ -3230,6 +3230,15 @@ struct remote_domain_set_user_password_args {
unsigned int flags; 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. -----*/ /*----- Protocol. -----*/
...@@ -5696,5 +5705,12 @@ enum remote_procedure { ...@@ -5696,5 +5705,12 @@ enum remote_procedure {
* @generate:both * @generate:both
* @acl: domain:set_password * @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
}; };
...@@ -2684,6 +2684,14 @@ struct remote_domain_set_user_password_args { ...@@ -2684,6 +2684,14 @@ struct remote_domain_set_user_password_args {
remote_string password; remote_string password;
u_int flags; 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 { enum remote_procedure {
REMOTE_PROC_CONNECT_OPEN = 1, REMOTE_PROC_CONNECT_OPEN = 1,
REMOTE_PROC_CONNECT_CLOSE = 2, REMOTE_PROC_CONNECT_CLOSE = 2,
...@@ -3042,4 +3050,5 @@ enum remote_procedure { ...@@ -3042,4 +3050,5 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_ADD_IOTHREAD = 355, REMOTE_PROC_DOMAIN_ADD_IOTHREAD = 355,
REMOTE_PROC_DOMAIN_DEL_IOTHREAD = 356, REMOTE_PROC_DOMAIN_DEL_IOTHREAD = 356,
REMOTE_PROC_DOMAIN_SET_USER_PASSWORD = 357, REMOTE_PROC_DOMAIN_SET_USER_PASSWORD = 357,
REMOTE_PROC_DOMAIN_RENAME = 358,
}; };
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册