Add API for issuing the 'migrate_set_speed' monitor command

* 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
This commit is contained in:
Daniel P. Berrange 2009-09-23 13:57:56 +01:00
parent f225e560de
commit bdc8861aac
3 changed files with 34 additions and 8 deletions

View 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);

View 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;
}

View 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 */