From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Epmnu-0003Xu-IK for qemu-devel@nongnu.org; Fri, 23 Dec 2005 08:17:50 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Epmns-0003Uc-D9 for qemu-devel@nongnu.org; Fri, 23 Dec 2005 08:17:49 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Epmnr-0003Tj-TR for qemu-devel@nongnu.org; Fri, 23 Dec 2005 08:17:48 -0500 Received: from [66.249.82.195] (helo=xproxy.gmail.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EpmnA-0001EZ-60 for qemu-devel@nongnu.org; Fri, 23 Dec 2005 08:17:04 -0500 Received: by xproxy.gmail.com with SMTP id s6so481159wxc for ; Fri, 23 Dec 2005 05:16:41 -0800 (PST) Message-ID: Date: Fri, 23 Dec 2005 14:16:39 +0100 From: andrzej zaborowski MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Subject: [Qemu-devel] IDE driver error handling Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 =3D s->req_nb_sectors; ret =3D bdrv_write(s->bs, sector_num, s->io_buffer, n); s->nsector -=3D n; - if (s->nsector =3D=3D 0) { + if (ret) { + ide_abort_command(s); + } else if (s->nsector =3D=3D 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 =3D transfer_size1; @@ -717,8 +719,8 @@ if (len =3D=3D 0) { n =3D s->io_buffer_size >> 9; sector_num =3D ide_get_sector(s); - bdrv_write(s->bs, sector_num, s->io_buffer, - s->io_buffer_size >> 9); + ret =3D bdrv_write(s->bs, sector_num, s->io_buffer, + s->io_buffer_size >> 9); sector_num +=3D n; ide_set_sector(s, sector_num); s->nsector -=3D 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 =3D MAX_MULT_SECTORS; s->io_buffer_index =3D 0; -- balrog 2oo5 Dear Outlook users: Please remove me from your address books http://www.newsforge.com/article.pl?sid=3D03/08/21/143258