[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 1/3] 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: Stub new
  API
---
 include/libvirt/libvirt.h.in |    4 +++
 src/driver.h                 |    5 ++++
 src/esx/esx_driver.c         |    1 +
 src/libvirt.c                |   47 ++++++++++++++++++++++++++++++++++++++++++
 src/libvirt_public.syms      |    1 +
 src/libxl/libxl_driver.c     |    1 +
 src/lxc/lxc_driver.c         |    1 +
 src/opennebula/one_driver.c  |    1 +
 src/openvz/openvz_driver.c   |    1 +
 src/phyp/phyp_driver.c       |    1 +
 src/qemu/qemu_driver.c       |    1 +
 src/remote/remote_driver.c   |    1 +
 src/test/test_driver.c       |    1 +
 src/uml/uml_driver.c         |    1 +
 src/vbox/vbox_tmpl.c         |    1 +
 src/vmware/vmware_driver.c   |    1 +
 src/xen/xen_driver.c         |    1 +
 17 files changed, 70 insertions(+), 0 deletions(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index fcca39d..1cf9273 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 f03d290..286130a 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 4f013e8..deda372 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 e7c4cc5..e46c18b 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -12557,6 +12557,53 @@ error:
 }
 
 /**
+ * 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
  * @dom: pointer to the domain
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index c027bf7..af25197 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -431,6 +431,7 @@ LIBVIRT_0.9.0 {
         virDomainSetMemoryFlags;
         virEventRegisterDefaultImpl;
         virEventRunDefaultImpl;
+        virDomainMigrateSetMaxSpeed;
 } LIBVIRT_0.8.8;
 
 # .... define new API here using predicted next version number ....
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 615cb47..254c75f 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 0796471..ac6c430 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -2891,6 +2891,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 f3c71ad..3146589 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 7792136..fb30c37 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 b06b3b3..51f9ff6 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 10fe595..93cae00 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7122,6 +7122,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 519c9fa..8741a87 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -11210,6 +11210,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 5f2aed6..17f5ad9 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 7f28ede..9f09289 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 e8ac48f..8bd27dd 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 b9f523f..b5e416b 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 db147a4..2d0fbf5 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 */
-- 
1.7.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]