: Fix scsi-generic breakage in find_image_format()
PATCH 1/2 : Fix scsi-generic breakage in find_image_format()
From: Nicholas Bellinger <[email protected]>
This patch adds a special BlockDriverState->sg check in block.c:find_image_format() after bdrv_file_open() -> block/raw-posix.c:hdev_open() has been called to determine if we are dealing with a Linux host scsi-generic device or not.
The patch then returns the BlockDriver * from find_protocol(), skipping the subsequent bdrv_read() and rest of find_image_format().
--- block.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
block.c +7 -0
@@ -332,6 +332,13 @@ static BlockDriver *find_image_format(const char *filename) ret =bdrv_file_open (&bs, filename,0 );if (ret <0 )return NULL ; +/* +* For scsi-generic we skip the read and return *drv from +* find_protocol(). +*/ +if (bs->sg) +return drv; + ret =bdrv_pread (bs,0 , buf,sizeof (buf));bdrv_delete (bs);if (ret <0 ) {
Signature · 1 line
1.5.6.5
Quoted 8 lines · Nicholas A. Bellinger
From: Nicholas Bellinger <[email protected]>
This patch adds a special
BlockDriverState->sgcheck in block.c:find_image_format() afterbdrv_file_open()-> block/raw-posix.c:hdev_open() has been called to determine if we are dealing with a Linux host scsi-generic device or not.The patch then returns the BlockDriver * from
find_protocol(), skipping the subsequentbdrv_read()and rest offind_image_format().
That's not quite correct as we don't want to expose formats directly. Returning
bdrv_find_format("raw");should fix it for now, although I really hate having these special cases in block.c.
Quoted 10 lines · Christoph Hellwig
Quoted 8 lines · Nicholas A. Bellinger
From: Nicholas Bellinger <[email protected]>
This patch adds a special
BlockDriverState->sgcheck in block.c:find_image_format() afterbdrv_file_open()-> block/raw-posix.c:hdev_open() has been called to determine if we are dealing with a Linux host scsi-generic device or not.The patch then returns the BlockDriver * from
find_protocol(), skipping the subsequentbdrv_read()and rest offind_image_format().
Quoted 6 lines
That's not quite correct as we don't want to expose formats directly. Returning
bdrv_find_format("raw");should fix it for now,
Ahh, that makes more sense.. Attached is updated patch #1:
[PATCH 1/2] [block]: Make find_image_format() return 'raw' BlockDriver for SG_IO devices
Quoted 2 lines
although I really hate having these special
cases inblock.c.
Indeed having BlockDriverState->sg kinda feels kinda like a hack to begin with, but it appears this is currently QEMU's way of telling block code to disable internal SCSI CDB emulation for devices.
Best,
--nab
Quoted 1 line
From
3d858cb1070e746b58608d91da6dc3d48a568e06Mon Sep 17 00:00:00 2001
From: Nicholas Bellinger <[email protected]>
Date: Sun, 16 May 2010 18:24:34 -0700
Subject: [PATCH 1/2] [block]: Make find_image_format() return 'raw' BlockDriver for SG_IO devices
This patch adds a special BlockDriverState->sg check in block.c:find_image_format() after bdrv_file_open() -> block/raw-posix.c:hdev_open() has been called to determine if we are dealing with a Linux host scsi-generic device.
The patch then returns the BlockDriver * from bdrv_find_format("raw"), skipping the subsequent bdrv_read() and rest of find_image_format().
--- block.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
block.c +5 -0
@@ -332,6 +332,11 @@ static BlockDriver *find_image_format(const char *filename) ret =bdrv_file_open (&bs, filename,0 );if (ret <0 )return NULL ; + +/* Return the raw BlockDriver * to scsi-generic devices */ +if (bs->sg) +return bdrv_find_format ("raw" ); + ret =bdrv_pread (bs,0 , buf,sizeof (buf));bdrv_delete (bs);if (ret <0 ) {
Signature · 1 line
1.5.6.5