qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com, jan.kiszka@siemens.com, armbru@redhat.com,
	d.hatayama@jp.fujitsu.com, eblake@redhat.com
Subject: [Qemu-devel] [PATCH 2/3] qmp: dump-guest-memory: don't spin if non-blocking fd would block
Date: Wed, 26 Sep 2012 15:56:52 -0300	[thread overview]
Message-ID: <1348685813-29414-3-git-send-email-lcapitulino@redhat.com> (raw)
In-Reply-To: <1348685813-29414-1-git-send-email-lcapitulino@redhat.com>

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 <lcapitulino@redhat.com>
---
 dump.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/dump.c b/dump.c
index 2bf8d8d..81c3624 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

  parent reply	other threads:[~2012-09-26 18:56 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-26 18:56 [Qemu-devel] [PATCH v2 0/3] qmp/hmp: dump-guest-memory fixes Luiz Capitulino
2012-09-26 18:56 ` [Qemu-devel] [PATCH 1/3] qmp: dump-guest-memory: improve schema doc (again) Luiz Capitulino
2012-09-26 18:56 ` Luiz Capitulino [this message]
2012-09-26 18:56 ` [Qemu-devel] [PATCH 3/3] hmp: dump-guest-memory: hardcode protocol argument to "file:" Luiz Capitulino
2012-09-26 20:47 ` [Qemu-devel] [PATCH v2 0/3] qmp/hmp: dump-guest-memory fixes Eric Blake
2012-09-27 11:58 ` Markus Armbruster
  -- strict thread matches above, loose matches on Subject: below --
2012-09-21 17:07 [Qemu-devel] [PATCH 0/3]: " Luiz Capitulino
2012-09-21 17:07 ` [Qemu-devel] [PATCH 2/3] qmp: dump-guest-memory: don't spin if non-blocking fd would block Luiz Capitulino
2012-09-21 18:30   ` Eric Blake
2012-09-24  6:27   ` Wen Congyang
2012-09-24 13:34     ` Luiz Capitulino
2012-09-25  8:19       ` Wen Congyang
2012-09-25  9:01         ` Markus Armbruster
2012-09-25  9:13           ` Wen Congyang
2012-09-25  9:14       ` Wen Congyang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1348685813-29414-3-git-send-email-lcapitulino@redhat.com \
    --to=lcapitulino@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=armbru@redhat.com \
    --cc=d.hatayama@jp.fujitsu.com \
    --cc=eblake@redhat.com \
    --cc=jan.kiszka@siemens.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).