]> xenbits.xensource.com Git - libvirt.git/commitdiff
BlockPull: Set initial bandwidth limit if specified
authorAdam Litke <agl@us.ibm.com>
Thu, 1 Sep 2011 22:35:36 +0000 (17:35 -0500)
committerEric Blake <eblake@redhat.com>
Fri, 2 Sep 2011 02:11:50 +0000 (20:11 -0600)
The libvirt BlockPull API supports the use of an initial bandwidth limit but the
qemu block_stream API does not.  To get the desired behavior we use the two APIs
strung together: first BlockPull, then BlockJobSetSpeed.  We can do this at the
driver level to avoid duplicated code in each monitor path.

Signed-off-by: Adam Litke <agl@us.ibm.com>
src/qemu/qemu_driver.c
src/qemu/qemu_monitor_json.c

index a150b08f5f7c0343a570efecfd1335e9b9ae7824..eca32b4bbd33937769ba7f199a8f49036dca3e42 100644 (file)
@@ -9418,8 +9418,14 @@ static int
 qemuDomainBlockPull(virDomainPtr dom, const char *path, unsigned long bandwidth,
                     unsigned int flags)
 {
+    int ret;
+
     virCheckFlags(0, -1);
-    return qemuDomainBlockJobImpl(dom, path, bandwidth, NULL, BLOCK_JOB_PULL);
+    ret = qemuDomainBlockJobImpl(dom, path, bandwidth, NULL, BLOCK_JOB_PULL);
+    if (ret == 0 && bandwidth != 0)
+        ret = qemuDomainBlockJobImpl(dom, path, bandwidth, NULL,
+                                     BLOCK_JOB_SPEED);
+    return ret;
 }
 
 static virDriver qemuDriver = {
index 715b26e97b9f5816da2b69553a2044613565a32b..4ceb5365381bf627b60c03a93fcd05f0c4d94c96 100644 (file)
@@ -2956,10 +2956,6 @@ int qemuMonitorJSONBlockJob(qemuMonitorPtr mon,
     if (ret == 0 && mode == BLOCK_JOB_INFO)
         ret = qemuMonitorJSONGetBlockJobInfo(reply, device, info);
 
-    if (ret == 0 && mode == BLOCK_JOB_PULL && bandwidth != 0)
-        ret = qemuMonitorJSONBlockJob(mon, device, bandwidth, NULL,
-                                      BLOCK_JOB_SPEED);
-
     virJSONValueFree(cmd);
     virJSONValueFree(reply);
     return ret;