Received: from [140.186.70.92] (port=34643 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PsFRL-00035y-2u for qemu-devel@nongnu.org; Wed, 23 Feb 2011 09:11:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PsFRJ-0008OB-BE for qemu-devel@nongnu.org; Wed, 23 Feb 2011 09:11:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:17167) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PsFRI-0008Nv-Ul for qemu-devel@nongnu.org; Wed, 23 Feb 2011 09:11:37 -0500 From: Markus Armbruster Subject: Re: [Qemu-devel] [RFC PATCH] block: Fix eject -f for locked devices References: Date: Wed, 23 Feb 2011 15:11:22 +0100 In-Reply-To: (Blue Swirl's message of "Fri, 18 Feb 2011 20:09:47 +0200") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: Jes.Sorensen@redhat.com, qemu-devel@nongnu.org Sorry for my slow reply. Blue Swirl writes: > On Fri, Feb 18, 2011 at 5:16 PM, Markus Armbruster wr= ote: >> From 8cd4978c9be6ff2bcc414bb1c1b258b96b9a74c1 Mon Sep 17 00:00:00 2001 >> From: Markus Armbruster >> Date: Fri, 18 Feb 2011 15:54:02 +0100 >> >> After forcefully ejecting media locked by the guest, you can't ever >> again insert new media. >> >> Example: >> >> =C2=A0 =C2=A0(qemu) info block >> =C2=A0 =C2=A0hda: type=3Dhd removable=3D0 file=3Dtest.img ro=3D0 drv=3Dr= aw encrypted=3D0 >> =C2=A0 =C2=A0cd: type=3Dcdrom removable=3D1 locked=3D1 file=3Dx.iso ro= =3D0 drv=3Draw encrypted=3D0 >> =C2=A0 =C2=A0(qemu) eject cd >> =C2=A0 =C2=A0Device 'cd' is locked >> =C2=A0 =C2=A0(qemu) eject -f cd >> =C2=A0 =C2=A0(qemu) info block >> =C2=A0 =C2=A0hda: type=3Dhd removable=3D0 file=3Dtest.img ro=3D0 drv=3Dr= aw encrypted=3D0 >> =C2=A0 =C2=A0cd: type=3Dcdrom removable=3D1 locked=3D1 [not inserted] >> =C2=A0 =C2=A0(qemu) change cd x.iso >> =C2=A0 =C2=A0Device 'cd' is locked >> >> Signed-off-by: Markus Armbruster >> --- >> I'm not entirely sure this is the appropriate fix, and that's why >> there's RFC in the subject. >> >> Both IDE and SCSI devices expose their drive's BlockDriverState member >> locked to the guest via mode sense. >> >> What does real hardware do when I force-eject media (typically by >> rummaging in that little hole with a paperclip)? =C2=A0Does it actively >> notify the OS? =C2=A0Does mode sense change? > > No idea, but IIRC the drive is still usable after that, That's what I'd expect. If the OS recovers from losing the media, the drive should be fine. > so locking the > drive does not look correct. I'm not sure I get you here. >> A possible alternative fix is to make do_change_block() ignore >> bdrv_is_locked() when inserting media into an empty drive. > > Then the meaning of locked would change, maybe eject_disabled would > then describe the state better. I like the current meaning of BlockDriverState member locked just fine, it nicely mirrors the SCSI / ATAPI mode sense page bit. I'm worried about unwanted side effects of my change. For instance, what about this code in do_snapshot_blkdev(): flags =3D bs->open_flags; bdrv_close(bs); ret =3D bdrv_open(bs, filename, flags, drv); I'm afraid my change would make it screw up bs->locked. Jes?