diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index fcca39d2f1257caedd287749d4ebfbe5df6793ca..1cf9273224e231392fd2a24510f4f7c9bbd6c62f 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -436,6 +436,10 @@ int virDomainMigrateSetMaxDowntime (virDomainPtr domain, unsigned long long downtime, unsigned int flags); +int virDomainMigrateSetMaxSpeed(virDomainPtr domain, + unsigned long bandwidth, + unsigned int flags); + /** * VIR_NODEINFO_MAXCPUS: * @nodeinfo: virNodeInfo instance diff --git a/src/driver.h b/src/driver.h index f03d2905dd8865889ceb2a54673349a40401ad91..286130a8e9e51cd13e223fb29ff6bcb79034dcf9 100644 --- a/src/driver.h +++ b/src/driver.h @@ -442,6 +442,10 @@ typedef int (*virDrvDomainMigrateSetMaxDowntime)(virDomainPtr domain, unsigned long long downtime, unsigned int flags); +typedef int + (*virDrvDomainMigrateSetMaxSpeed)(virDomainPtr domain, + unsigned long bandwidth, + unsigned int flags); typedef int (*virDrvDomainEventRegisterAny)(virConnectPtr conn, @@ -618,6 +622,7 @@ struct _virDriver { virDrvDomainGetJobInfo domainGetJobInfo; virDrvDomainAbortJob domainAbortJob; virDrvDomainMigrateSetMaxDowntime domainMigrateSetMaxDowntime; + virDrvDomainMigrateSetMaxSpeed domainMigrateSetMaxSpeed; virDrvDomainEventRegisterAny domainEventRegisterAny; virDrvDomainEventDeregisterAny domainEventDeregisterAny; virDrvDomainManagedSave domainManagedSave; diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 4f013e8028947395a88328143c75b97fb449226b..deda372cad3589bf49db783af3e8fe61557c993a 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -4658,6 +4658,7 @@ static virDriver esxDriver = { NULL, /* domainGetJobInfo */ NULL, /* domainAbortJob */ NULL, /* domainMigrateSetMaxDowntime */ + NULL, /* domainMigrateSetMaxSpeed */ NULL, /* domainEventRegisterAny */ NULL, /* domainEventDeregisterAny */ NULL, /* domainManagedSave */ diff --git a/src/libvirt.c b/src/libvirt.c index e7c4cc554d90efd0f46b513d04e01b0e3fe741ef..e46c18b354b8a5b4ab427b113afbeac69055d404 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -12556,6 +12556,53 @@ error: return -1; } +/** + * virDomainMigrateSetMaxSpeed: + * @domain: a domain object + * @bandwidth: migration bandwidth limit in Mbps + * @flags: fine-tuning flags, currently unused, use 0 + * + * The maximum bandwidth (in Mbps) that will be used to do migration + * can be specified with the bandwidth parameter. Not all hypervisors + * will support a bandwidth cap + * + * Returns 0 in case of success, -1 otherwise. + */ +int +virDomainMigrateSetMaxSpeed(virDomainPtr domain, + unsigned long bandwidth, + unsigned int flags) +{ + virConnectPtr conn; + + VIR_DOMAIN_DEBUG(domain, "bandwidth=%lu, flags=%u", bandwidth, flags); + + virResetLastError(); + + if (!VIR_IS_CONNECTED_DOMAIN(domain)) { + virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); + virDispatchError(NULL); + return -1; + } + + conn = domain->conn; + if (conn->flags & VIR_CONNECT_RO) { + virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); + goto error; + } + + if (conn->driver->domainMigrateSetMaxSpeed) { + if (conn->driver->domainMigrateSetMaxSpeed(domain, bandwidth, flags) < 0) + goto error; + return 0; + } + + virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__); +error: + virDispatchError(conn); + return -1; +} + /** * virConnectDomainEventRegisterAny: * @conn: pointer to the connection diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index c027bf73c5870d102269ac11c47454815f314187..5caab4c9de972c753fbf22a83be757866444405e 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -427,6 +427,7 @@ LIBVIRT_0.8.8 { LIBVIRT_0.9.0 { global: virDomainGetBlkioParameters; + virDomainMigrateSetMaxSpeed; virDomainSetBlkioParameters; virDomainSetMemoryFlags; virEventRegisterDefaultImpl; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 615cb47437140f44c9291701bb7b70b314810c02..254c75ffb94d712a77d5963df534c38693c9c3bd 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -1414,6 +1414,7 @@ static virDriver libxlDriver = { NULL, /* domainGetJobInfo */ NULL, /* domainAbortJob */ NULL, /* domainMigrateSetMaxDowntime */ + NULL, /* domainMigrateSetMaxSpeed */ NULL, /* domainEventRegisterAny */ NULL, /* domainEventDeregisterAny */ NULL, /* domainManagedSave */ diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 60d4204137066a0febfc5903aa9b07c92f0e2144..d5f21b1c3434b1bab25c6277a10378cbe94c879a 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -2883,6 +2883,7 @@ static virDriver lxcDriver = { NULL, /* domainGetJobInfo */ NULL, /* domainAbortJob */ NULL, /* domainMigrateSetMaxDowntime */ + NULL, /* domainMigrateSetMaxSpeed */ lxcDomainEventRegisterAny, /* domainEventRegisterAny */ lxcDomainEventDeregisterAny, /* domainEventDeregisterAny */ NULL, /* domainManagedSave */ diff --git a/src/opennebula/one_driver.c b/src/opennebula/one_driver.c index f3c71add0c04573d0fb4d03538f8b3ef70394660..3146589db3feb76c8c51154dc86f0a3f88601260 100644 --- a/src/opennebula/one_driver.c +++ b/src/opennebula/one_driver.c @@ -815,6 +815,7 @@ static virDriver oneDriver = { NULL, /* domainGetJobInfo */ NULL, /* domainAbortJob */ NULL, /* domainMigrateSetMaxDowntime */ + NULL, /* domainMigrateSetMaxSpeed */ NULL, /* domainEventRegisterAny */ NULL, /* domainEventDeregisterAny */ NULL, /* domainManagedSave */ diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 77921361f9ad9de821508d11b9e8f2078b9927f8..fb30c3757d0ec96476ace06b24b7ec81c1386399 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -1637,6 +1637,7 @@ static virDriver openvzDriver = { NULL, /* domainGetJobInfo */ NULL, /* domainAbortJob */ NULL, /* domainMigrateSetMaxDowntime */ + NULL, /* domainMigrateSetMaxSpeed */ NULL, /* domainEventRegisterAny */ NULL, /* domainEventDeregisterAny */ NULL, /* domainManagedSave */ diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index b06b3b3e1eb4b40e08877e94799e47bf6ff158da..51f9ff6100b131f0c64797a665bfd1eb4e7c1304 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -4038,6 +4038,7 @@ static virDriver phypDriver = { NULL, /* domainGetJobInfo */ NULL, /* domainAbortJob */ NULL, /* domainMigrateSetMaxDowntime */ + NULL, /* domainMigrateSetMaxSpeed */ NULL, /* domainEventRegisterAny */ NULL, /* domainEventDeregisterAny */ NULL, /* domainManagedSave */ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c7d42623e2ac651d7cd7d5e5e0f62f2d5507dd6f..bc6e9dd74024d4a8565443a2b8492da22bd70514 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7121,6 +7121,7 @@ static virDriver qemuDriver = { qemuDomainGetJobInfo, /* domainGetJobInfo */ qemuDomainAbortJob, /* domainAbortJob */ qemuDomainMigrateSetMaxDowntime, /* domainMigrateSetMaxDowntime */ + NULL, /* domainMigrateSetMaxSpeed */ qemuDomainEventRegisterAny, /* domainEventRegisterAny */ qemuDomainEventDeregisterAny, /* domainEventDeregisterAny */ qemuDomainManagedSave, /* domainManagedSave */ diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 5f3e288279b296383a2b07bf233000cb3765f2ce..5a753ab2a865b1a39ff1c809503fb7969b6ea7a7 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -11156,6 +11156,7 @@ static virDriver remote_driver = { remoteDomainGetJobInfo, /* domainGetJobInfo */ remoteDomainAbortJob, /* domainFinishJob */ remoteDomainMigrateSetMaxDowntime, /* domainMigrateSetMaxDowntime */ + NULL, /* domainMigrateSetMaxSpeed */ remoteDomainEventRegisterAny, /* domainEventRegisterAny */ remoteDomainEventDeregisterAny, /* domainEventDeregisterAny */ remoteDomainManagedSave, /* domainManagedSave */ diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 5f2aed6bc7e61ca2b205e7d890daecc94247a550..17f5ad9ae7538c5039a6c3c51a5cd18f45e08acb 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -5430,6 +5430,7 @@ static virDriver testDriver = { NULL, /* domainGetJobInfo */ NULL, /* domainAbortJob */ NULL, /* domainMigrateSetMaxDowntime */ + NULL, /* domainMigrateSetMaxSpeed */ testDomainEventRegisterAny, /* domainEventRegisterAny */ testDomainEventDeregisterAny, /* domainEventDeregisterAny */ NULL, /* domainManagedSave */ diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 538d5f732cc3548c020375b87fd0efd0a918dc8a..f19a4a8202a3d91159b755c0ae9fc09d5573d96e 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -2232,6 +2232,7 @@ static virDriver umlDriver = { NULL, /* domainGetJobInfo */ NULL, /* domainAbortJob */ NULL, /* domainMigrateSetMaxDowntime */ + NULL, /* domainMigrateSetMaxSpeed */ NULL, /* domainEventRegisterAny */ NULL, /* domainEventDeregisterAny */ NULL, /* domainManagedSave */ diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index e8ac48fc66993825ca1060e3e81d85b26e571704..8bd27ddf210c0e5e47ccb550735ca41e8afcd4b8 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -8625,6 +8625,7 @@ virDriver NAME(Driver) = { NULL, /* domainGetJobInfo */ NULL, /* domainAbortJob */ NULL, /* domainMigrateSetMaxDowntime */ + NULL, /* domainMigrateSetMaxSpeed */ #if VBOX_API_VERSION == 2002 || VBOX_API_VERSION == 4000 NULL, /* domainEventRegisterAny */ NULL, /* domainEventDeregisterAny */ diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index b9f523f89b40a64a5bce3ed6c04d75cb95dcf5f9..b5e416be2cb0e931266b4455d73a482fa8fc2853 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -990,6 +990,7 @@ static virDriver vmwareDriver = { NULL, /* domainGetJobInfo */ NULL, /* domainAbortJob */ NULL, /* domainMigrateSetMaxDowntime */ + NULL, /* domainMigrateSetMaxSpeed */ NULL, /* domainEventRegisterAny */ NULL, /* domainEventDeregisterAny */ NULL, /* domainManagedSave */ diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 1162f635212872558c844aed5b6bad2b9d16e746..bf422e60752b4c5d6d80fe5208fb91b313ceca15 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -2124,6 +2124,7 @@ static virDriver xenUnifiedDriver = { NULL, /* domainGetJobInfo */ NULL, /* domainAbortJob */ NULL, /* domainMigrateSetMaxDowntime */ + NULL, /* domainMigrateSetMaxSpeed */ xenUnifiedDomainEventRegisterAny, /* domainEventRegisterAny */ xenUnifiedDomainEventDeregisterAny, /* domainEventDeregisterAny */ NULL, /* domainManagedSave */