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);
{
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;
+}