]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Add API for issuing the 'migrate_set_speed' monitor command
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 23 Sep 2009 12:57:56 +0000 (13:57 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 29 Sep 2009 10:54:57 +0000 (11:54 +0100)
* 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
src/qemu/qemu_monitor_text.c
src/qemu/qemu_monitor_text.h

index 24253bc4bea9c2fcfddf8f38f8e3e3289f81b837..a44b99be5e3a004c3fedeac88a77dcb4045a84f7 100644 (file)
@@ -6529,14 +6529,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);
index bad2e25df399aab9da8b63357378a9bd2ee3c60e..e68d993f20d26646a85bbee7c331be89ce53c4c6 100644 (file)
@@ -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;
+}
index 11256cb11f8a3dfecc7c0f8b5e25db4112240130..2bf7931b4cfee12d144cd976ac8c946e9bb90f77 100644 (file)
@@ -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 */