On 10.08.2015 21:59, Tomas Meszaros wrote: > Also, among with this new API new ACL that restricts rename capability > is invented too. > > Signed-off-by: Tomas Meszaros <exo@xxxxxx> > --- > include/libvirt/libvirt-domain.h | 4 ++++ > src/driver-hypervisor.h | 6 ++++++ > src/libvirt-domain.c | 34 ++++++++++++++++++++++++++++++++++ > src/libvirt_public.syms | 5 +++++ > src/remote/remote_driver.c | 1 + > src/remote/remote_protocol.x | 18 +++++++++++++++++- > src/remote_protocol-structs | 8 ++++++++ > 7 files changed, 75 insertions(+), 1 deletion(-) > > diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h > index e8202cf..82f86bb 100644 > --- a/include/libvirt/libvirt-domain.h > +++ b/include/libvirt/libvirt-domain.h > @@ -3837,4 +3837,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__ */ > diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h > index 3275343..ae2ec4d 100644 > --- a/src/driver-hypervisor.h > +++ b/src/driver-hypervisor.h > @@ -650,6 +650,11 @@ typedef int > (*virDrvDomainIsActive)(virDomainPtr dom); > > typedef int > +(*virDrvDomainRename)(virDomainPtr dom, > + const char *new_name, > + unsigned int flags); > + > +typedef int > (*virDrvDomainIsPersistent)(virDomainPtr dom); > > typedef int > @@ -1347,6 +1352,7 @@ struct _virHypervisorDriver { > virDrvConnectIsEncrypted connectIsEncrypted; > virDrvConnectIsSecure connectIsSecure; > virDrvDomainIsActive domainIsActive; > + virDrvDomainRename domainRename; > virDrvDomainIsPersistent domainIsPersistent; > virDrvDomainIsUpdated domainIsUpdated; > virDrvConnectCompareCPU connectCompareCPU; > diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c > index 837933f..b8618d8 100644 > --- a/src/libvirt-domain.c > +++ b/src/libvirt-domain.c > @@ -8774,6 +8774,40 @@ 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 renamed, -1 on error > + */ > +int > +virDomainRename(virDomainPtr dom, const char *new_name, > + unsigned int flags ATTRIBUTE_UNUSED) Why? @flags are clearly used just a few lines below. > +{ > + 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: > diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms > index 2c653f2..dd94191 100644 > --- a/src/libvirt_public.syms > +++ b/src/libvirt_public.syms > @@ -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 .... > diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c > index 5c4cf7c..ec26ebe 100644 > --- a/src/remote/remote_driver.c > +++ b/src/remote/remote_driver.c > @@ -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 = { > diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x > index 9f1be6b..770aa72 100644 > --- a/src/remote/remote_protocol.x > +++ b/src/remote/remote_protocol.x > @@ -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 > }; > diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs > index 48c3bd8..1fdaa55 100644 > --- a/src/remote_protocol-structs > +++ b/src/remote_protocol-structs > @@ -2684,6 +2684,13 @@ 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; need to add the flags: 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 +3049,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, > }; Michal -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list