From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=53033 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OwYQZ-0002ED-OA for qemu-devel@nongnu.org; Fri, 17 Sep 2010 06:44:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OwYQY-0003X7-M4 for qemu-devel@nongnu.org; Fri, 17 Sep 2010 06:44:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:15143) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OwYQY-0003Wo-D2 for qemu-devel@nongnu.org; Fri, 17 Sep 2010 06:44:22 -0400 Message-ID: <4C934697.70102@redhat.com> Date: Fri, 17 Sep 2010 12:44:39 +0200 From: Kevin Wolf MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] CMOS file support References: <1284645517-32743-1-git-send-email-mathias.krause@secunet.com> <4C924AB5.1030802@mail.berlios.de> <4C930DED.5050601@secunet.com> In-Reply-To: <4C930DED.5050601@secunet.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Mathias Krause Cc: qemu-devel@nongnu.org Hi Mathias, Am 17.09.2010 08:42, schrieb Mathias Krause: >> Using QEMU's block devices instead of a simple file would be >> more consistent with the rest of QEMU and allow reading the >> CMOS data not only from a file but also from an URL or other >> sources. > > Thanks for the hint. Since this is my first contribution to the project > I'm not that familiar with the code. Looking at other places, e.g. how > the -kernel option gets handled, I just see FILE everywhere. Can you > give me some pointers how to use this interface? Have a look at block.h which contains the prototypes for the public block layer interface. Basically, you need to create a BlockDriverState with bdrv_new() and then open it with bdrv_open(). You'll want to specify the raw block driver for opening the image, you get it with bdrv_find_format("raw"). bdrv_pread/pwrite are the right functions to access the file with byte granularity (other functions work on 512 byte sectors). bdrv_delete frees the the BlockDriverState when you're done. HTH, Kevin