]> git.proxmox.com Git - mirror_qemu.git/blobdiff - migration/qemu-file-channel.c
Merge remote-tracking branch 'remotes/juanquintela/tags/migration-pull-request' into...
[mirror_qemu.git] / migration / qemu-file-channel.c
index dc991c90510cc841238b2ca33009760371039181..8e639eb496f7cb9688145456280f09b4e04f07fb 100644 (file)
@@ -24,7 +24,8 @@
 
 #include "qemu/osdep.h"
 #include "qemu-file-channel.h"
-#include "migration/qemu-file.h"
+#include "exec/cpu-common.h"
+#include "qemu-file.h"
 #include "io/channel-socket.h"
 #include "qemu/iov.h"
 
@@ -48,7 +49,11 @@ static ssize_t channel_writev_buffer(void *opaque,
         ssize_t len;
         len = qio_channel_writev(ioc, local_iov, nlocal_iov, NULL);
         if (len == QIO_CHANNEL_ERR_BLOCK) {
-            qio_channel_wait(ioc, G_IO_OUT);
+            if (qemu_in_coroutine()) {
+                qio_channel_yield(ioc, G_IO_OUT);
+            } else {
+                qio_channel_wait(ioc, G_IO_OUT);
+            }
             continue;
         }
         if (len < 0) {
@@ -79,7 +84,11 @@ static ssize_t channel_get_buffer(void *opaque,
         ret = qio_channel_read(ioc, (char *)buf, size, NULL);
         if (ret < 0) {
             if (ret == QIO_CHANNEL_ERR_BLOCK) {
-                qio_channel_yield(ioc, G_IO_IN);
+                if (qemu_in_coroutine()) {
+                    qio_channel_yield(ioc, G_IO_IN);
+                } else {
+                    qio_channel_wait(ioc, G_IO_IN);
+                }
             } else {
                 /* XXX handle Error * object */
                 return -EIO;