nbd: switch to asynchronous operation

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
diff --git a/nbd.c b/nbd.c
index de880fe..ff701d3 100644
--- a/nbd.c
+++ b/nbd.c
@@ -81,6 +81,14 @@
 {
     size_t offset = 0;
 
+    if (qemu_in_coroutine()) {
+        if (do_read) {
+            return qemu_co_recv(fd, buffer, size);
+        } else {
+            return qemu_co_send(fd, buffer, size);
+        }
+    }
+
     while (offset < size) {
         ssize_t len;