]> xenbits.xensource.com Git - libvirt.git/commitdiff
Save migration speed in qemuDomainMigrateSetMaxSpeed
authorJim Fehlig <jfehlig@novell.com>
Fri, 26 Aug 2011 18:10:25 +0000 (12:10 -0600)
committerJim Fehlig <jfehlig@suse.com>
Wed, 14 Sep 2011 22:42:10 +0000 (16:42 -0600)
Now that migration speed is stored in qemuDomainObjPrivate structure,
save the new value when invoking qemuDomainMigrateSetMaxSpeed().

Allow setting migration speed on inactive domain too.

src/qemu/qemu_driver.c

index 458787d6ee84678af7937d2fa3f97ce33a8ad9d9..0ecd257caa29d136a592008064a0f9d26bc1da97 100644 (file)
@@ -8848,31 +8848,25 @@ qemuDomainMigrateSetMaxSpeed(virDomainPtr dom,
         return -1;
     }
 
-    if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MIGRATION_OP) < 0)
-        goto cleanup;
-
-    if (!virDomainObjIsActive(vm)) {
-        qemuReportError(VIR_ERR_OPERATION_INVALID,
-                        "%s", _("domain is not running"));
-        goto endjob;
-    }
-
     priv = vm->privateData;
+    if (virDomainObjIsActive(vm)) {
+        if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MIGRATION_OP) < 0)
+            goto cleanup;
 
-    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)
+            priv->migMaxBandwidth = bandwidth;
 
-endjob:
-    if (qemuDomainObjEndJob(driver, vm) == 0)
-        vm = NULL;
+        if (qemuDomainObjEndJob(driver, vm) == 0)
+            vm = NULL;
+    } else {
+        priv->migMaxBandwidth = bandwidth;
+        ret = 0;
+    }
 
 cleanup:
     if (vm)