Now that migration speed is represented in XML, save the new value
to domain conf when invoking qemuDomainMigrateSetMaxSpeed().
Allow setting migration speed on inactive domain too.
---
src/qemu/qemu_driver.c | 45 ++++++++++++++++++++++++---------------------
1 files changed, 24 insertions(+), 21 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b932e67..9c91e49 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8208,7 +8208,8 @@ qemuDomainMigrateSetMaxSpeed(virDomainPtr dom,
struct qemud_driver *driver = dom->conn->privateData;
virDomainObjPtr vm;
qemuDomainObjPrivatePtr priv;
- int ret = -1;
+ virDomainDefPtr persistentDef = NULL;
+ int ret = 0;
virCheckFlags(0, -1);
@@ -8224,31 +8225,33 @@ qemuDomainMigrateSetMaxSpeed(virDomainPtr dom,
return -1;
}
- if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MIGRATION_OP) < 0)
- goto cleanup;
+ if (vm->persistent)
+ persistentDef = virDomainObjGetPersistentDef(driver->caps, vm);
- if (!virDomainObjIsActive(vm)) {
- qemuReportError(VIR_ERR_OPERATION_INVALID,
- "%s", _("domain is not running"));
- goto endjob;
- }
+ if (virDomainObjIsActive(vm)) {
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MIGRATION_OP) < 0) {
+ ret = -1;
+ goto cleanup;
+ }
- priv = vm->privateData;
+ priv = vm->privateData;
- if (priv->job.asyncJob != QEMU_ASYNC_JOB_MIGRATION_OUT) {
- qemuReportError(VIR_ERR_OPERATION_INVALID,
- "%s", _("domain is not being migrated"));
- goto endjob;
- }
+ VIR_DEBUG("Setting migration bandwidth to %luMbs", bandwidth);
+ qemuDomainObjEnterMonitor(driver, vm);
+ ret = qemuMonitorSetMigrationSpeed(priv->mon, bandwidth);
+ qemuDomainObjExitMonitor(driver, vm);
- VIR_DEBUG("Setting migration bandwidth to %luMbs", bandwidth);
- qemuDomainObjEnterMonitor(driver, vm);
- ret = qemuMonitorSetMigrationSpeed(priv->mon, bandwidth);
- qemuDomainObjExitMonitor(driver, vm);
+ if (ret == 0)
+ vm->def->migration_max_bandwidth = bandwidth;
-endjob:
- if (qemuDomainObjEndJob(driver, vm) == 0)
- vm = NULL;
+ if (qemuDomainObjEndJob(driver, vm) == 0)
+ vm = NULL;
+ }
+
+ if (ret == 0 && persistentDef) {
+ persistentDef->migration_max_bandwidth = bandwidth;
+ ret = virDomainSaveConfig(driver->configDir, persistentDef);
+ }
cleanup:
if (vm)
--
1.7.5.4