Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> --- include/libvirt/libvirt.h.in | 3 ++ src/libvirt.c | 46 ++++++++++++++++++++++++++++++++++++++++++ src/libvirt_public.syms | 5 ++++ 3 files changed, 54 insertions(+), 0 deletions(-) diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index 0d1b5b5..eafab40 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -408,6 +408,9 @@ int virDomainMigrateToURI (virDomainPtr domain, const char *duri, unsigned long flags, const char *dname, unsigned long bandwidth); +int virDomainMigrateSetDowntime (virDomainPtr domain, + unsigned long long downtime); + /** * VIR_NODEINFO_MAXCPUS: * @nodeinfo: virNodeInfo instance diff --git a/src/libvirt.c b/src/libvirt.c index 1d9b878..c73caa3 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -11265,3 +11265,49 @@ error: virDispatchError(conn); return -1; } + + +/** + * virDomainMigrateSetDowntime: + * @domain: a domain object + * @downtime: maximum tolerable downtime for live migration, in nanoseconds + * + * Sets maximum tolerable time for which the domain is allowed to be paused + * at the end of live migration. + * + * Returns 0 in case of success, -1 otherwise. + */ +int +virDomainMigrateSetDowntime(virDomainPtr domain, + unsigned long long downtime) +{ + virConnectPtr conn; + + DEBUG("domain=%p, downtime=%llu", domain, downtime); + + virResetLastError(); + + if (!VIR_IS_CONNECTED_DOMAIN(domain)) { + virLibDomainError(NULL, VIR_ERR_INVALID_DOMAIN, __FUNCTION__); + virDispatchError(NULL); + return -1; + } + + conn = domain->conn; + if (conn->flags & VIR_CONNECT_RO) { + virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__); + goto error; + } + + if (conn->driver->domainMigrateSetDowntime) { + if (conn->driver->domainMigrateSetDowntime(domain, downtime) < 0) + goto error; + return 0; + } + + virLibConnError(conn, VIR_ERR_NO_SUPPORT, __FUNCTION__); + +error: + virDispatchError(conn); + return -1; +} diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 64e7505..9d9f0c2 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -358,4 +358,9 @@ LIBVIRT_0.7.7 { virDomainAbortJob; } LIBVIRT_0.7.5; +LIBVIRT_0.7.8 { + global: + virDomainMigrateSetDowntime; +} LIBVIRT_0.7.7; + # .... define new API here using predicted next version number .... -- 1.7.0.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list