From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:42602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjqNO-0004Rg-Ug for qemu-devel@nongnu.org; Sat, 15 Dec 2012 06:57:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TjqNN-0006B0-4t for qemu-devel@nongnu.org; Sat, 15 Dec 2012 06:57:54 -0500 Received: from v220110690675601.yourvserver.net ([78.47.199.172]:55430) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjqNM-0006Ab-Ug for qemu-devel@nongnu.org; Sat, 15 Dec 2012 06:57:53 -0500 Message-ID: <50CC65BD.7090103@weilnetz.de> Date: Sat, 15 Dec 2012 12:57:49 +0100 From: Stefan Weil MIME-Version: 1.0 References: <1355571343-19878-1-git-send-email-sw@weilnetz.de> In-Reply-To: <1355571343-19878-1-git-send-email-sw@weilnetz.de> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] block: Probe file for specified format List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi , Kevin Wolf Cc: 1090600@bugs.launchpad.net, qemu-devel@nongnu.org Am 15.12.2012 12:35, schrieb Stefan Weil: > Probe for the file format if the file format was specified explicitly > and a probe function is available. > > example: -drive file=myfile,format=qcow2 > > Then myfile is probed and must be in qcow2 format. > > This fixes those bugs: > > https://bugzilla.redhat.com/show_bug.cgi?id=556482 > https://bugs.launchpad.net/qemu/+bug/1090600 > > Signed-off-by: Stefan Weil > --- > > This patch can also be used for the latest stable version of QEMU. > > blockdev.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/blockdev.c b/blockdev.c > index 9a05e57..5a4cd56 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -411,6 +411,13 @@ DriveInfo *drive_init(QemuOpts *opts, BlockInterfaceType block_default_type) > error_report("'%s' invalid format", buf); > return NULL; > } > + if (file && drv->bdrv_probe) { > + uint8_t data[2048]; > + if (drv->bdrv_probe(data, sizeof(data), file) == 0) { > + error_report("file '%s' not in '%s' format", file, buf); > + return NULL; > + } > + } > } > > /* disk I/O throttling */ Sorry, this patch was not tested enough. I'll send a v2. - Stefan Weil