virQEMUDriverPtr driver = dom->conn->privateData;
virDomainObjPtr vm;
qemuDomainObjPrivatePtr priv;
+ int rc;
int ret = -1;
virCheckFlags(0, -1);
goto cleanup;
}
- if (virDomainObjIsActive(vm)) {
- if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MIGRATION_OP) < 0)
- goto cleanup;
+ if (!virDomainObjIsActive(vm)) {
+ priv->migMaxBandwidth = bandwidth;
+ ret = 0;
+ goto cleanup;
+ }
- if (virDomainObjCheckActive(vm) < 0)
- goto endjob;
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MIGRATION_OP) < 0)
+ goto cleanup;
- VIR_DEBUG("Setting migration bandwidth to %luMbs", bandwidth);
- qemuDomainObjEnterMonitor(driver, vm);
- ret = qemuMonitorSetMigrationSpeed(priv->mon, bandwidth);
- if (qemuDomainObjExitMonitor(driver, vm) < 0)
- ret = -1;
+ if (virDomainObjCheckActive(vm) < 0)
+ goto endjob;
- if (ret == 0)
- priv->migMaxBandwidth = bandwidth;
+ VIR_DEBUG("Setting migration bandwidth to %luMbs", bandwidth);
+ qemuDomainObjEnterMonitor(driver, vm);
+ rc = qemuMonitorSetMigrationSpeed(priv->mon, bandwidth);
+ if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
+ goto endjob;
+
+ priv->migMaxBandwidth = bandwidth;
+
+ ret = 0;
endjob:
- qemuDomainObjEndJob(driver, vm);
- } else {
- priv->migMaxBandwidth = bandwidth;
- ret = 0;
- }
+ qemuDomainObjEndJob(driver, vm);
cleanup:
virDomainObjEndAPI(&vm);