Received: from eggs.gnu.org ([208.118.235.92]:58307) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SX6xe-0002Ri-Hw for qemu-devel@nongnu.org; Wed, 23 May 2012 04:30:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SX6xX-0008Tc-0K for qemu-devel@nongnu.org; Wed, 23 May 2012 04:30:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:10345) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SX6xW-0008T2-Ga for qemu-devel@nongnu.org; Wed, 23 May 2012 04:30:18 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q4N8UFjZ007635 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 23 May 2012 04:30:15 -0400 From: Markus Armbruster References: <12f91615b8176518ea2aef0356c2bb77eb874d40.1337698475.git.phrdina@redhat.com> Date: Wed, 23 May 2012 10:30:13 +0200 In-Reply-To: <12f91615b8176518ea2aef0356c2bb77eb874d40.1337698475.git.phrdina@redhat.com> (Pavel Hrdina's message of "Tue, 22 May 2012 17:00:54 +0200") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH v2 2/2] fdc: fix media detection List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pavel Hrdina Cc: qemu-devel@nongnu.org Pavel Hrdina writes: > We have to set up 'media_changed' after guest start so floppy driver > could detect that there is no media in drive. For this purpose we call > 'fdctrl_change_cb' instead of 'fd_revalidate' in 'fdctrl_connect_drives'. > 'fd_revalidate' is called inside 'fdctrl_change_cb'. > > We still have to set default drive geometry in 'fd_revalidate' even > if there is no media in drive. When you try to open (windows) or mount (linux) > floppy the driver tries to seek on track 1. Linux guest hang in loop than crash > and windows guest print error message. Got one nitpick inline. > Signed-off-by: Pavel Hrdina > --- > hw/fdc.c | 14 ++++++++------ > 1 files changed, 8 insertions(+), 6 deletions(-) > > diff --git a/hw/fdc.c b/hw/fdc.c > index cb4cd25..b1bc6ed 100644 > --- a/hw/fdc.c > +++ b/hw/fdc.c > @@ -179,12 +179,14 @@ static void fd_revalidate(FDrive *drv) > FDriveRate rate; > > FLOPPY_DPRINTF("revalidate\n"); > - if (drv->bs != NULL && bdrv_is_inserted(drv->bs)) { > + if (drv->bs != NULL) { > ro = bdrv_is_read_only(drv->bs); > bdrv_get_floppy_geometry_hint(drv->bs, &nb_heads, &max_track, > &last_sect, drv->drive, &drive, &rate); > - if (nb_heads != 0 && max_track != 0 && last_sect != 0) { > - FLOPPY_DPRINTF("User defined disk (%d %d %d)", > + if (!bdrv_is_inserted(drv->bs)) { > + FLOPPY_DPRINTF("No disk in drive\n"); > + } else if (nb_heads != 0 && max_track != 0 && last_sect != 0) { > + FLOPPY_DPRINTF("User defined disk (%d %d %d)\n", > nb_heads - 1, max_track, last_sect); > } else { > FLOPPY_DPRINTF("Floppy disk (%d h %d t %d s) %s\n", nb_heads, > @@ -201,7 +203,7 @@ static void fd_revalidate(FDrive *drv) > drv->drive = drive; > drv->media_rate = rate; > } else { > - FLOPPY_DPRINTF("No disk in drive\n"); > + FLOPPY_DPRINTF("Invalid disk in drive\n"); Misleading. What !drv->bs actually means is "no drive connected". > drv->last_sect = 0; > drv->max_track = 0; > drv->flags &= ~FDISK_DBL_SIDES; [...]