提交 bdc8861a 编写于 作者: D Daniel P. Berrange

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
上级 f225e560
......@@ -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);
......
......@@ -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;
}
......@@ -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 */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册