From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55868) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YHIkR-0001Ws-C1 for qemu-devel@nongnu.org; Fri, 30 Jan 2015 16:05:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YHIkL-0000Ds-4c for qemu-devel@nongnu.org; Fri, 30 Jan 2015 16:05:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52015) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YHIkK-0000D3-R1 for qemu-devel@nongnu.org; Fri, 30 Jan 2015 16:04:57 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0UL4tdn032127 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 30 Jan 2015 16:04:56 -0500 Message-ID: <54CBF1F5.9030109@redhat.com> Date: Fri, 30 Jan 2015 16:04:53 -0500 From: John Snow MIME-Version: 1.0 References: <1422387983-32153-1-git-send-email-mreitz@redhat.com> <1422387983-32153-4-git-send-email-mreitz@redhat.com> In-Reply-To: <1422387983-32153-4-git-send-email-mreitz@redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH RESEND 03/50] hw/block/fdc: Implement tray status List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-devel@nongnu.org Cc: Kevin Wolf , Jeff Cody , Fam Zheng , Markus Armbruster , Stefan Hajnoczi On 01/27/2015 02:45 PM, Max Reitz wrote: > The tray of an FDD is open iff there is no medium inserted (there are > only two states for an FDD: "medium inserted" or "no medium inserted"). > > This results in the tray being reported as open if qemu has been started > with the default floppy drive, which breaks some tests. Fix them. > > Signed-off-by: Max Reitz > --- > hw/block/fdc.c | 20 +++++++++++++--- > tests/fdc-test.c | 4 +--- > tests/qemu-iotests/067.out | 60 +++++++--------------------------------------- > tests/qemu-iotests/071.out | 2 -- > tests/qemu-iotests/081.out | 1 - > tests/qemu-iotests/087.out | 5 ---- > 6 files changed, 26 insertions(+), 66 deletions(-) > > diff --git a/hw/block/fdc.c b/hw/block/fdc.c > index 2bf87c9..0c5a6b4 100644 > --- a/hw/block/fdc.c > +++ b/hw/block/fdc.c > @@ -192,6 +192,8 @@ typedef struct FDrive { > uint8_t ro; /* Is read-only */ > uint8_t media_changed; /* Is media changed */ > uint8_t media_rate; /* Data rate of medium */ > + > + bool media_inserted; /* Is there a medium in the tray */ > } FDrive; > > static void fd_init(FDrive *drv) > @@ -261,7 +263,7 @@ static int fd_seek(FDrive *drv, uint8_t head, uint8_t track, uint8_t sect, > #endif > drv->head = head; > if (drv->track != track) { > - if (drv->blk != NULL && blk_is_inserted(drv->blk)) { > + if (drv->media_inserted) { > drv->media_changed = 0; > } > ret = 1; > @@ -270,7 +272,7 @@ static int fd_seek(FDrive *drv, uint8_t head, uint8_t track, uint8_t sect, > drv->sect = sect; > } > > - if (drv->blk == NULL || !blk_is_inserted(drv->blk)) { > + if (!drv->media_inserted) { > ret = 2; > } > > @@ -296,7 +298,7 @@ static void fd_revalidate(FDrive *drv) > ro = blk_is_read_only(drv->blk); > pick_geometry(drv->blk, &nb_heads, &max_track, > &last_sect, drv->drive, &drive, &rate); > - if (!blk_is_inserted(drv->blk)) { > + if (!drv->media_inserted) { > FLOPPY_DPRINTF("No disk in drive\n"); > } else { > FLOPPY_DPRINTF("Floppy disk (%d h %d t %d s) %s\n", nb_heads, > @@ -2062,12 +2064,21 @@ static void fdctrl_change_cb(void *opaque, bool load) > { > FDrive *drive = opaque; > > + drive->media_inserted = load && drive->blk && blk_is_inserted(drive->blk); > + > drive->media_changed = 1; > fd_revalidate(drive); > } > > +static bool fdctrl_is_tray_open(void *opaque) > +{ > + FDrive *drive = opaque; > + return !drive->media_inserted; > +} > + > static const BlockDevOps fdctrl_block_ops = { > .change_media_cb = fdctrl_change_cb, > + .is_tray_open = fdctrl_is_tray_open, > }; > > /* Init functions */ > @@ -2095,6 +2106,9 @@ static void fdctrl_connect_drives(FDCtrl *fdctrl, Error **errp) > fdctrl_change_cb(drive, 0); > if (drive->blk) { > blk_set_dev_ops(drive->blk, &fdctrl_block_ops, drive); > + if (blk_is_inserted(drive->blk)) { > + drive->media_inserted = true; > + } > } > } > } > diff --git a/tests/fdc-test.c b/tests/fdc-test.c > index 3c6c83c..f287c10 100644 > --- a/tests/fdc-test.c > +++ b/tests/fdc-test.c > @@ -293,9 +293,7 @@ static void test_media_insert(void) > qmp_discard_response("{'execute':'change', 'arguments':{" > " 'device':'floppy0', 'target': %s, 'arg': 'raw' }}", > test_image); > - qmp_discard_response(""); /* ignore event > - (FIXME open -> open transition?!) */ > - qmp_discard_response(""); /* ignore event */ > + qmp_discard_response(""); /* ignore event (open -> close) */ > > dir = inb(FLOPPY_BASE + reg_dir); > assert_bit_set(dir, DSKCHG); > diff --git a/tests/qemu-iotests/067.out b/tests/qemu-iotests/067.out > index 00b3eae..42bae32 100644 > --- a/tests/qemu-iotests/067.out > +++ b/tests/qemu-iotests/067.out > @@ -69,7 +69,7 @@ Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,if=none,id=disk -device virti > "device": "floppy0", > "locked": false, > "removable": true, > - "tray_open": false, > + "tray_open": true, > "type": "unknown" > }, > { > @@ -131,7 +131,7 @@ Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,if=none,id=disk -device virti > "device": "floppy0", > "locked": false, > "removable": true, > - "tray_open": false, > + "tray_open": true, > "type": "unknown" > }, > { > @@ -165,17 +165,6 @@ Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,if=none,id=disk -device virti > "tray-open": true > } > } > -{ > - "timestamp": { > - "seconds": TIMESTAMP, > - "microseconds": TIMESTAMP > - }, > - "event": "DEVICE_TRAY_MOVED", > - "data": { > - "device": "floppy0", > - "tray-open": true > - } > -} > > > === -drive/device_add and device_del === > @@ -246,7 +235,7 @@ Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,if=none,id=disk > "device": "floppy0", > "locked": false, > "removable": true, > - "tray_open": false, > + "tray_open": true, > "type": "unknown" > }, > { > @@ -312,7 +301,7 @@ Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,if=none,id=disk > "device": "floppy0", > "locked": false, > "removable": true, > - "tray_open": false, > + "tray_open": true, > "type": "unknown" > }, > { > @@ -346,17 +335,6 @@ Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,if=none,id=disk > "tray-open": true > } > } > -{ > - "timestamp": { > - "seconds": TIMESTAMP, > - "microseconds": TIMESTAMP > - }, > - "event": "DEVICE_TRAY_MOVED", > - "data": { > - "device": "floppy0", > - "tray-open": true > - } > -} > > > === drive_add/device_add and device_del === > @@ -386,7 +364,7 @@ Testing: > "device": "floppy0", > "locked": false, > "removable": true, > - "tray_open": false, > + "tray_open": true, > "type": "unknown" > }, > { > @@ -496,7 +474,7 @@ Testing: > "device": "floppy0", > "locked": false, > "removable": true, > - "tray_open": false, > + "tray_open": true, > "type": "unknown" > }, > { > @@ -530,17 +508,6 @@ Testing: > "tray-open": true > } > } > -{ > - "timestamp": { > - "seconds": TIMESTAMP, > - "microseconds": TIMESTAMP > - }, > - "event": "DEVICE_TRAY_MOVED", > - "data": { > - "device": "floppy0", > - "tray-open": true > - } > -} > > > === blockdev_add/device_add and device_del === > @@ -571,7 +538,7 @@ Testing: > "device": "floppy0", > "locked": false, > "removable": true, > - "tray_open": false, > + "tray_open": true, > "type": "unknown" > }, > { > @@ -681,7 +648,7 @@ Testing: > "device": "floppy0", > "locked": false, > "removable": true, > - "tray_open": false, > + "tray_open": true, > "type": "unknown" > }, > { > @@ -760,16 +727,5 @@ Testing: > "tray-open": true > } > } > -{ > - "timestamp": { > - "seconds": TIMESTAMP, > - "microseconds": TIMESTAMP > - }, > - "event": "DEVICE_TRAY_MOVED", > - "data": { > - "device": "floppy0", > - "tray-open": true > - } > -} > > *** done > diff --git a/tests/qemu-iotests/071.out b/tests/qemu-iotests/071.out > index c8ecfaf..904ce15 100644 > --- a/tests/qemu-iotests/071.out > +++ b/tests/qemu-iotests/071.out > @@ -52,7 +52,6 @@ read failed: Input/output error > {"return": {}} > {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN"} > {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0", "tray-open": true}} > -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "floppy0", "tray-open": true}} > QEMU_PROG: Failed to flush the L2 table cache: Input/output error > QEMU_PROG: Failed to flush the refcount block cache: Input/output error > > @@ -95,7 +94,6 @@ read failed: Input/output error > {"return": {}} > {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN"} > {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0", "tray-open": true}} > -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "floppy0", "tray-open": true}} > QEMU_PROG: Failed to flush the L2 table cache: Input/output error > QEMU_PROG: Failed to flush the refcount block cache: Input/output error > > diff --git a/tests/qemu-iotests/081.out b/tests/qemu-iotests/081.out > index 2375916..b1e4909 100644 > --- a/tests/qemu-iotests/081.out > +++ b/tests/qemu-iotests/081.out > @@ -38,7 +38,6 @@ read 10485760/10485760 bytes at offset 0 > {"return": {}} > {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN"} > {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0", "tray-open": true}} > -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "floppy0", "tray-open": true}} > > > == using quorum rewrite corrupted mode == > diff --git a/tests/qemu-iotests/087.out b/tests/qemu-iotests/087.out > index 681ef93..033cc3b 100644 > --- a/tests/qemu-iotests/087.out > +++ b/tests/qemu-iotests/087.out > @@ -15,7 +15,6 @@ QMP_VERSION > {"return": {}} > {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN"} > {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0", "tray-open": true}} > -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "floppy0", "tray-open": true}} > > > === aio=native without O_DIRECT === > @@ -27,7 +26,6 @@ QMP_VERSION > {"return": {}} > {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN"} > {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0", "tray-open": true}} > -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "floppy0", "tray-open": true}} > > > === Encrypted image === > @@ -40,7 +38,6 @@ QMP_VERSION > {"return": {}} > {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN"} > {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0", "tray-open": true}} > -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "floppy0", "tray-open": true}} > > Testing: > QMP_VERSION > @@ -49,7 +46,6 @@ QMP_VERSION > {"return": {}} > {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN"} > {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0", "tray-open": true}} > -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "floppy0", "tray-open": true}} > > > === Missing driver === > @@ -62,6 +58,5 @@ QMP_VERSION > {"return": {}} > {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN"} > {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0", "tray-open": true}} > -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "floppy0", "tray-open": true}} > > *** done > Since I am fated to care more about floppy disks than I have in the past: Reviewed-by: John Snow