[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 5/6] migration: handle EAGAIN while reading QEMUFile
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 5/6] migration: handle EAGAIN while reading QEMUFile |
Date: |
Tue, 7 Aug 2012 17:51:46 +0200 |
This will never happen right now (the assertion would fail). The
next patch will set the socket or pipe in non-blocking mode, thus
enabling this part of the code.
Signed-off-by: Paolo Bonzini <address@hidden>
---
savevm.c | 30 ++++++++++++++++++++++++------
1 file modificato, 24 inserzioni(+), 6 rimozioni(-)
diff --git a/savevm.c b/savevm.c
index 8f075e5..336b53b 100644
--- a/savevm.c
+++ b/savevm.c
@@ -197,13 +197,22 @@ static int socket_get_buffer(void *opaque, uint8_t *buf,
int64_t pos, int size)
QEMUFileSocket *s = opaque;
ssize_t len;
- do {
+ for (;;) {
len = qemu_recv(s->fd, buf, size, 0);
- } while (len == -1 && socket_error() == EINTR);
+ if (len != -1) {
+ break;
+ }
+ if (errno == EAGAIN) {
+ assert(qemu_in_coroutine());
+ qemu_coroutine_yield();
+ } else if (errno != EINTR) {
+ break;
+ }
+ }
- if (len == -1)
+ if (len == -1) {
len = -socket_error();
-
+ }
return len;
}
@@ -228,10 +237,19 @@ static int stdio_get_buffer(void *opaque, uint8_t *buf,
int64_t pos, int size)
FILE *fp = s->stdio_file;
int bytes;
- do {
+ for (;;) {
clearerr(fp);
bytes = fread(buf, 1, size, fp);
- } while ((bytes == 0) && ferror(fp) && (errno == EINTR));
+ if (bytes != 0 || !ferror(fp)) {
+ break;
+ }
+ if (errno == EAGAIN) {
+ assert(qemu_in_coroutine());
+ qemu_coroutine_yield();
+ } else if (errno != EINTR) {
+ break;
+ }
+ }
return bytes;
}
--
1.7.11.2
- [Qemu-devel] [RFC PATCH 0/6] Run incoming migration in a coroutine, Paolo Bonzini, 2012/08/07
- [Qemu-devel] [PATCH 2/6] migration: close socket QEMUFile from socket_close, Paolo Bonzini, 2012/08/07
- [Qemu-devel] [PATCH 3/6] migration: move qemu_fclose to process_incoming_migration, Paolo Bonzini, 2012/08/07
- [Qemu-devel] [PATCH 1/6] migration: clean up server sockets and handlers before invoking process_incoming_migration, Paolo Bonzini, 2012/08/07
- [Qemu-devel] [PATCH 4/6] migration: remove iohandlers before closing the file, Paolo Bonzini, 2012/08/07
- [Qemu-devel] [PATCH 5/6] migration: handle EAGAIN while reading QEMUFile,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 6/6] migration: move process_incoming_migration to a coroutine, Paolo Bonzini, 2012/08/07