Received: from eggs.gnu.org ([140.186.70.92]:32822) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGBMm-0007mt-Kz for qemu-devel@nongnu.org; Tue, 18 Oct 2011 11:14:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RGBMi-0003ej-FX for qemu-devel@nongnu.org; Tue, 18 Oct 2011 11:14:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47064) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGBMi-0003eU-5S for qemu-devel@nongnu.org; Tue, 18 Oct 2011 11:14:04 -0400 From: Markus Armbruster References: Date: Tue, 18 Oct 2011 17:13:36 +0200 In-Reply-To: (Peter Maydell's message of "Tue, 18 Oct 2011 15:01:45 +0100") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] hw/nand hw/onenand and read-only List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: riku.voipio@iki.fi, Juha.Riihimaki@nokia.com, qemu-devel@nongnu.org Peter Maydell writes: > On 18 October 2011 14:38, Markus Armbruster wrote: >> Yes, that way works: >> >> =C2=A0 =C2=A0$ qemu-system-arm -drive if=3Dmtd,file=3Dtmp.qcow2,readonly >> =C2=A0 =C2=A0qemu-system-arm: -drive if=3Dmtd,file=3Dtmp.qcow2,readonly:= readonly not supported by this bus type >> >> But try this way: >> >> =C2=A0 =C2=A0$ qemu-system-arm -drive if=3Dnone,file=3Dtmp.qcow2,readonl= y,id=3Dfoo -device nand,drive=3Dfoo >> =C2=A0 =C2=A0Kernel image must be specified >> >> Grr, force it: >> >> =C2=A0 =C2=A0$ qemu-system-arm -drive if=3Dnone,file=3Dtmp.qcow2,readonl= y,id=3Dfoo -device nand,drive=3Dfoo -kernel /dev/null >> =C2=A0 =C2=A0qemu: hardware error: nand_device_init: Unsupported NAND bl= ock size. >> =C2=A0 =C2=A0[...] >> >> Note that I didn't bother supplying a drive with sensible size. =C2=A0If= I >> did, I guess I'd get nand coupled to a read-only drive. =C2=A0Easy enoug= h for >> you to try :) > > Isn't this a block layer problem? It seems to be blockdev.c that > emits the "readonly not supported" message for MTD devices, so presumably > it ought to do so however the user sets up the device... Only the device knows what kind of drive it needs. The block layer can only find out by asking the device. There's no way to ask yet. It could be added to BlockDevOps, and checked in bdrv_attach_dev(). The existing readonly check in blockdev.c is a layering violation. It predates qdev, and it can't be cleanly extended to cover if=3Dnone.