[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 10/15] qmp: dump-guest-memory: don't spin if non-bloc
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PULL 10/15] qmp: dump-guest-memory: don't spin if non-blocking fd would block |
Date: |
Thu, 27 Sep 2012 10:28:24 -0300 |
fd_write_vmcore() will indefinitely spin for a non-blocking
file-descriptor that would block. However, if the fd is non-blocking,
how does it make sense to spin?
Change this behavior to return an error instead.
Note that this can only happen with an fd provided by a management
application. The fd opened internally by dump-guest-memory is blocking.
While there, also fix 'writen_size' variable name.
Signed-off-by: Luiz Capitulino <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Markus Armbruster <address@hidden>
---
dump.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/dump.c b/dump.c
index 1a3c716..6b7c127 100644
--- a/dump.c
+++ b/dump.c
@@ -100,18 +100,11 @@ static void dump_error(DumpState *s, const char *reason)
static int fd_write_vmcore(void *buf, size_t size, void *opaque)
{
DumpState *s = opaque;
- int fd = s->fd;
- size_t writen_size;
+ size_t written_size;
- /* The fd may be passed from user, and it can be non-blocked */
- while (size) {
- writen_size = qemu_write_full(fd, buf, size);
- if (writen_size != size && errno != EAGAIN) {
- return -1;
- }
-
- buf += writen_size;
- size -= writen_size;
+ written_size = qemu_write_full(s->fd, buf, size);
+ if (written_size != size) {
+ return -1;
}
return 0;
--
1.7.12.315.g682ce8b
- [Qemu-devel] [PULL 08/15] qapi: convert add_client, (continued)
- [Qemu-devel] [PULL 08/15] qapi: convert add_client, Luiz Capitulino, 2012/09/27
- [Qemu-devel] [PULL 07/15] monitor: add Error * argument to monitor_get_fd, Luiz Capitulino, 2012/09/27
- [Qemu-devel] [PULL 11/15] hmp: dump-guest-memory: hardcode protocol argument to "file:", Luiz Capitulino, 2012/09/27
- [Qemu-devel] [PULL 09/15] qmp: dump-guest-memory: improve schema doc (again), Luiz Capitulino, 2012/09/27
- [Qemu-devel] [PULL 13/15] qmp: qmp_send_key(): accept key codes in hex, Luiz Capitulino, 2012/09/27
[Qemu-devel] [PULL 10/15] qmp: dump-guest-memory: don't spin if non-blocking fd would block,
Luiz Capitulino <=
[Qemu-devel] [PULL 14/15] input: index_from_key(): drop unused code, Luiz Capitulino, 2012/09/27
[Qemu-devel] [PULL 12/15] input: qmp_send_key(): simplify, Luiz Capitulino, 2012/09/27
[Qemu-devel] [PULL 15/15] block: live snapshot documentation tweaks, Luiz Capitulino, 2012/09/27