qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: andrzej zaborowski <balrogg@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] IDE driver error handling
Date: Fri, 23 Dec 2005 14:16:39 +0100	[thread overview]
Message-ID: <fb249edb0512230516o7946d8aai@mail.gmail.com> (raw)

Hi there,
Today when I was running qemu with -snapshot and I noticed strange
things happening in the guest system after some amount of disk IO.
After some time of figuring out I found that the reason was my /tmp
partition (on the host, it is 400 MB big) being full. The guest didn't
receive any error or warning when the temporary QCOW image in /tmp
grew to 400 MB. After some investigation, it turned out that write
errors are generally ignored by the QEMU IDE driver. I came up with
the following changes to make the guest receive an IO error when that
happens. Please note that this works for me but I have little idea
about how IDE works. So I am posting this as a pointer to where the
errors really get ignored for someone who feels like fixing this in
QEMU.
Regards,
wish you a Merry Christmas
Andrew

--- qemu/hw/ide.c       2005-08-06 09:14:32.000000000 +0000
+++ qemu-warnings/hw/ide.c      2005-12-23 12:34:24.000000000 +0000
@@ -676,7 +676,9 @@
         n = s->req_nb_sectors;
     ret = bdrv_write(s->bs, sector_num, s->io_buffer, n);
     s->nsector -= n;
-    if (s->nsector == 0) {
+    if (ret) {
+        ide_abort_command(s);
+    } else if (s->nsector == 0) {
         /* no more sector to write */
         ide_transfer_stop(s);
     } else {
@@ -708,7 +710,7 @@
                             target_phys_addr_t phys_addr,
                             int transfer_size1)
 {
-    int len, transfer_size, n;
+    int len, transfer_size, n, ret;
     int64_t sector_num;

     transfer_size = transfer_size1;
@@ -717,8 +719,8 @@
         if (len == 0) {
             n = s->io_buffer_size >> 9;
             sector_num = ide_get_sector(s);
-            bdrv_write(s->bs, sector_num, s->io_buffer,
-                       s->io_buffer_size >> 9);
+            ret = bdrv_write(s->bs, sector_num, s->io_buffer,
+                             s->io_buffer_size >> 9);
             sector_num += n;
             ide_set_sector(s, sector_num);
             s->nsector -= n;
@@ -729,6 +731,11 @@
                 ide_set_irq(s);
                 return 0;
             }
+            if (ret) {
+                ide_abort_command(s);
+                ide_set_irq(s);
+                return 0;
+            }
             if (n > MAX_MULT_SECTORS)
                 n = MAX_MULT_SECTORS;
             s->io_buffer_index = 0;

--
balrog 2oo5

Dear Outlook users: Please remove me from your address books
http://www.newsforge.com/article.pl?sid=03/08/21/143258

                 reply	other threads:[~2005-12-23 13:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=fb249edb0512230516o7946d8aai@mail.gmail.com \
    --to=balrogg@gmail.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).