aboutsummaryrefslogtreecommitdiff
path: root/nbd.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2011-09-08 14:28:59 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2011-12-22 11:53:57 +0100
commitae255e523c256cf0708f1c16cb946ff96340a800 (patch)
treefbc4e2309f43d337ed7ce0c1c7e3582a6008fa5c /nbd.c
parent8c5135f90e2dcf1d5c3d03106e0ac6e371ccb572 (diff)
downloadqemu-ae255e523c256cf0708f1c16cb946ff96340a800.zip
qemu-ae255e523c256cf0708f1c16cb946ff96340a800.tar.gz
qemu-ae255e523c256cf0708f1c16cb946ff96340a800.tar.bz2
nbd: switch to asynchronous operation
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'nbd.c')
-rw-r--r--nbd.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/nbd.c b/nbd.c
index de880fe..ff701d3 100644
--- a/nbd.c
+++ b/nbd.c
@@ -81,6 +81,14 @@ size_t nbd_wr_sync(int fd, void *buffer, size_t size, bool do_read)
{
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;