提交 cb4aba9b 编写于 作者: D Daniel P. Berrange

Add public API for setting migration speed on the fly

It is possible to set a migration speed limit when starting
migration. This new API allows the speed limit to be changed
on the fly to adjust to changing conditions

* src/driver.h, src/libvirt.c, src/libvirt_public.syms,
  include/libvirt/libvirt.h.in: Add virDomainMigrateSetMaxSpeed
* src/esx/esx_driver.c, src/lxc/lxc_driver.c,
  src/opennebula/one_driver.c, src/openvz/openvz_driver.c,
  src/phyp/phyp_driver.c, src/qemu/qemu_driver.c,
  src/remote/remote_driver.c, src/test/test_driver.c,
  src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
  src/vmware/vmware_driver.c, src/xen/xen_driver.c,
  src/libxl/libxl_driver.c: Stub new API
上级 09fb354c
......@@ -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
......
......@@ -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;
......
......@@ -4658,6 +4658,7 @@ static virDriver esxDriver = {
NULL, /* domainGetJobInfo */
NULL, /* domainAbortJob */
NULL, /* domainMigrateSetMaxDowntime */
NULL, /* domainMigrateSetMaxSpeed */
NULL, /* domainEventRegisterAny */
NULL, /* domainEventDeregisterAny */
NULL, /* domainManagedSave */
......
......@@ -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
......
......@@ -427,6 +427,7 @@ LIBVIRT_0.8.8 {
LIBVIRT_0.9.0 {
global:
virDomainGetBlkioParameters;
virDomainMigrateSetMaxSpeed;
virDomainSetBlkioParameters;
virDomainSetMemoryFlags;
virEventRegisterDefaultImpl;
......
......@@ -1414,6 +1414,7 @@ static virDriver libxlDriver = {
NULL, /* domainGetJobInfo */
NULL, /* domainAbortJob */
NULL, /* domainMigrateSetMaxDowntime */
NULL, /* domainMigrateSetMaxSpeed */
NULL, /* domainEventRegisterAny */
NULL, /* domainEventDeregisterAny */
NULL, /* domainManagedSave */
......
......@@ -2883,6 +2883,7 @@ static virDriver lxcDriver = {
NULL, /* domainGetJobInfo */
NULL, /* domainAbortJob */
NULL, /* domainMigrateSetMaxDowntime */
NULL, /* domainMigrateSetMaxSpeed */
lxcDomainEventRegisterAny, /* domainEventRegisterAny */
lxcDomainEventDeregisterAny, /* domainEventDeregisterAny */
NULL, /* domainManagedSave */
......
......@@ -815,6 +815,7 @@ static virDriver oneDriver = {
NULL, /* domainGetJobInfo */
NULL, /* domainAbortJob */
NULL, /* domainMigrateSetMaxDowntime */
NULL, /* domainMigrateSetMaxSpeed */
NULL, /* domainEventRegisterAny */
NULL, /* domainEventDeregisterAny */
NULL, /* domainManagedSave */
......
......@@ -1637,6 +1637,7 @@ static virDriver openvzDriver = {
NULL, /* domainGetJobInfo */
NULL, /* domainAbortJob */
NULL, /* domainMigrateSetMaxDowntime */
NULL, /* domainMigrateSetMaxSpeed */
NULL, /* domainEventRegisterAny */
NULL, /* domainEventDeregisterAny */
NULL, /* domainManagedSave */
......
......@@ -4038,6 +4038,7 @@ static virDriver phypDriver = {
NULL, /* domainGetJobInfo */
NULL, /* domainAbortJob */
NULL, /* domainMigrateSetMaxDowntime */
NULL, /* domainMigrateSetMaxSpeed */
NULL, /* domainEventRegisterAny */
NULL, /* domainEventDeregisterAny */
NULL, /* domainManagedSave */
......
......@@ -7121,6 +7121,7 @@ static virDriver qemuDriver = {
qemuDomainGetJobInfo, /* domainGetJobInfo */
qemuDomainAbortJob, /* domainAbortJob */
qemuDomainMigrateSetMaxDowntime, /* domainMigrateSetMaxDowntime */
NULL, /* domainMigrateSetMaxSpeed */
qemuDomainEventRegisterAny, /* domainEventRegisterAny */
qemuDomainEventDeregisterAny, /* domainEventDeregisterAny */
qemuDomainManagedSave, /* domainManagedSave */
......
......@@ -11156,6 +11156,7 @@ static virDriver remote_driver = {
remoteDomainGetJobInfo, /* domainGetJobInfo */
remoteDomainAbortJob, /* domainFinishJob */
remoteDomainMigrateSetMaxDowntime, /* domainMigrateSetMaxDowntime */
NULL, /* domainMigrateSetMaxSpeed */
remoteDomainEventRegisterAny, /* domainEventRegisterAny */
remoteDomainEventDeregisterAny, /* domainEventDeregisterAny */
remoteDomainManagedSave, /* domainManagedSave */
......
......@@ -5430,6 +5430,7 @@ static virDriver testDriver = {
NULL, /* domainGetJobInfo */
NULL, /* domainAbortJob */
NULL, /* domainMigrateSetMaxDowntime */
NULL, /* domainMigrateSetMaxSpeed */
testDomainEventRegisterAny, /* domainEventRegisterAny */
testDomainEventDeregisterAny, /* domainEventDeregisterAny */
NULL, /* domainManagedSave */
......
......@@ -2232,6 +2232,7 @@ static virDriver umlDriver = {
NULL, /* domainGetJobInfo */
NULL, /* domainAbortJob */
NULL, /* domainMigrateSetMaxDowntime */
NULL, /* domainMigrateSetMaxSpeed */
NULL, /* domainEventRegisterAny */
NULL, /* domainEventDeregisterAny */
NULL, /* domainManagedSave */
......
......@@ -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 */
......
......@@ -990,6 +990,7 @@ static virDriver vmwareDriver = {
NULL, /* domainGetJobInfo */
NULL, /* domainAbortJob */
NULL, /* domainMigrateSetMaxDowntime */
NULL, /* domainMigrateSetMaxSpeed */
NULL, /* domainEventRegisterAny */
NULL, /* domainEventDeregisterAny */
NULL, /* domainManagedSave */
......
......@@ -2124,6 +2124,7 @@ static virDriver xenUnifiedDriver = {
NULL, /* domainGetJobInfo */
NULL, /* domainAbortJob */
NULL, /* domainMigrateSetMaxDowntime */
NULL, /* domainMigrateSetMaxSpeed */
xenUnifiedDomainEventRegisterAny, /* domainEventRegisterAny */
xenUnifiedDomainEventDeregisterAny, /* domainEventDeregisterAny */
NULL, /* domainManagedSave */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册