[libvirt] [PATCH 12/27] Add API for issuing the 'migrate_set_speed' monitor command

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

 



* src/qemu/qemu_driver.c: Use new qemuMonitorSetMigrationSpeed()
  API during migration
* src/qemu/qemu_monitor.h, src/qemu/qemu_monitor.c: Add new
  qemuMonitorSetMigrationSpeed() API
---
 src/qemu/qemu_driver.c       |   11 +++--------
 src/qemu/qemu_monitor_text.c |   28 ++++++++++++++++++++++++++++
 src/qemu/qemu_monitor_text.h |    3 +++
 3 files changed, 34 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f95c473..ccc13c4 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6530,14 +6530,9 @@ qemudDomainMigratePerform (virDomainPtr dom,
         event = NULL;
     }
 
-    if (resource > 0) {
-        /* Issue migrate_set_speed command.  Don't worry if it fails. */
-        snprintf (cmd, sizeof cmd, "migrate_set_speed %lum", resource);
-        qemudMonitorCommand (vm, cmd, &info);
-
-        DEBUG ("%s: migrate_set_speed reply: %s", vm->def->name, info);
-        VIR_FREE (info);
-    }
+    if (resource > 0 &&
+        qemuMonitorSetMigrationSpeed(vm, resource) < 0)
+        goto cleanup;
 
     /* Issue the migrate command. */
     safe_uri = qemudEscapeMonitorArg (uri);
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index f35b1ef..d9227a2 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -969,3 +969,31 @@ int qemuMonitorSavePhysicalMemory(const virDomainObjPtr vm,
 {
     return qemuMonitorSaveMemory(vm, "pmemsave", offset, length, path);
 }
+
+
+int qemuMonitorSetMigrationSpeed(const virDomainObjPtr vm,
+                                 unsigned long bandwidth)
+{
+    char *cmd = NULL;
+    char *info = NULL;
+    int ret = -1;
+
+    if (virAsprintf(&cmd, "migrate_set_speed %lum", bandwidth) < 0) {
+        virReportOOMError(NULL);
+        goto cleanup;
+    }
+
+    if (qemudMonitorCommand (vm, cmd, &info) < 0) {
+        qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
+                         "%s", _("could restrict migration speed"));
+        goto cleanup;
+    }
+
+    DEBUG ("%s: migrate_set_speed reply: %s", vm->def->name, info);
+    ret = 0;
+
+cleanup:
+    VIR_FREE (info);
+    VIR_FREE(cmd);
+    return ret;
+}
diff --git a/src/qemu/qemu_monitor_text.h b/src/qemu/qemu_monitor_text.h
index a047eba..0591f3c 100644
--- a/src/qemu/qemu_monitor_text.h
+++ b/src/qemu/qemu_monitor_text.h
@@ -109,4 +109,7 @@ int qemuMonitorSavePhysicalMemory(const virDomainObjPtr vm,
                                   size_t length,
                                   const char *path);
 
+int qemuMonitorSetMigrationSpeed(const virDomainObjPtr vm,
+                                 unsigned long bandwidth);
+
 #endif /* QEMU_MONITOR_TEXT_H */
-- 
1.6.2.5

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]